Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/video/omap2/dss/dispc.c |
| 3 | * |
| 4 | * Copyright (C) 2009 Nokia Corporation |
| 5 | * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com> |
| 6 | * |
| 7 | * Some code and ideas taken from drivers/video/omap/ driver |
| 8 | * by Imre Deak. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License version 2 as published by |
| 12 | * the Free Software Foundation. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 17 | * more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License along with |
| 20 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | */ |
| 22 | |
| 23 | #define DSS_SUBSYS_NAME "DISPC" |
| 24 | |
| 25 | #include <linux/kernel.h> |
| 26 | #include <linux/dma-mapping.h> |
| 27 | #include <linux/vmalloc.h> |
Paul Gortmaker | a8a3593 | 2011-07-10 13:20:26 -0400 | [diff] [blame] | 28 | #include <linux/export.h> |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 29 | #include <linux/clk.h> |
| 30 | #include <linux/io.h> |
| 31 | #include <linux/jiffies.h> |
| 32 | #include <linux/seq_file.h> |
| 33 | #include <linux/delay.h> |
| 34 | #include <linux/workqueue.h> |
Tomi Valkeinen | ab83b14 | 2010-06-09 15:31:01 +0300 | [diff] [blame] | 35 | #include <linux/hardirq.h> |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 36 | #include <linux/interrupt.h> |
Tomi Valkeinen | 24e6289 | 2011-05-23 11:51:18 +0300 | [diff] [blame] | 37 | #include <linux/platform_device.h> |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 38 | #include <linux/pm_runtime.h> |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 39 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 40 | #include <plat/clock.h> |
| 41 | |
Tomi Valkeinen | a0b38cc | 2011-05-11 14:05:07 +0300 | [diff] [blame] | 42 | #include <video/omapdss.h> |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 43 | |
| 44 | #include "dss.h" |
Archit Taneja | a0acb55 | 2010-09-15 19:20:00 +0530 | [diff] [blame] | 45 | #include "dss_features.h" |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 46 | #include "dispc.h" |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 47 | |
| 48 | /* DISPC */ |
Sumit Semwal | 8613b00 | 2010-12-02 11:27:09 +0000 | [diff] [blame] | 49 | #define DISPC_SZ_REGS SZ_4K |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 50 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 51 | #define DISPC_IRQ_MASK_ERROR (DISPC_IRQ_GFX_FIFO_UNDERFLOW | \ |
| 52 | DISPC_IRQ_OCP_ERR | \ |
| 53 | DISPC_IRQ_VID1_FIFO_UNDERFLOW | \ |
| 54 | DISPC_IRQ_VID2_FIFO_UNDERFLOW | \ |
| 55 | DISPC_IRQ_SYNC_LOST | \ |
| 56 | DISPC_IRQ_SYNC_LOST_DIGIT) |
| 57 | |
| 58 | #define DISPC_MAX_NR_ISRS 8 |
| 59 | |
| 60 | struct omap_dispc_isr_data { |
| 61 | omap_dispc_isr_t isr; |
| 62 | void *arg; |
| 63 | u32 mask; |
| 64 | }; |
| 65 | |
Tomi Valkeinen | 5ed8cf5 | 2011-06-21 09:35:36 +0300 | [diff] [blame] | 66 | enum omap_burst_size { |
| 67 | BURST_SIZE_X2 = 0, |
| 68 | BURST_SIZE_X4 = 1, |
| 69 | BURST_SIZE_X8 = 2, |
| 70 | }; |
| 71 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 72 | #define REG_GET(idx, start, end) \ |
| 73 | FLD_GET(dispc_read_reg(idx), start, end) |
| 74 | |
| 75 | #define REG_FLD_MOD(idx, val, start, end) \ |
| 76 | dispc_write_reg(idx, FLD_MOD(dispc_read_reg(idx), val, start, end)) |
| 77 | |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 78 | struct dispc_irq_stats { |
| 79 | unsigned long last_reset; |
| 80 | unsigned irq_count; |
| 81 | unsigned irqs[32]; |
| 82 | }; |
| 83 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 84 | static struct { |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 85 | struct platform_device *pdev; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 86 | void __iomem *base; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 87 | |
| 88 | int ctx_loss_cnt; |
| 89 | |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 90 | int irq; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 91 | struct clk *dss_clk; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 92 | |
Archit Taneja | e13a138 | 2011-08-05 19:06:04 +0530 | [diff] [blame] | 93 | u32 fifo_size[MAX_DSS_OVERLAYS]; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 94 | |
| 95 | spinlock_t irq_lock; |
| 96 | u32 irq_error_mask; |
| 97 | struct omap_dispc_isr_data registered_isr[DISPC_MAX_NR_ISRS]; |
| 98 | u32 error_irqs; |
| 99 | struct work_struct error_work; |
| 100 | |
Tomi Valkeinen | 49ea86f | 2011-06-01 15:54:06 +0300 | [diff] [blame] | 101 | bool ctx_valid; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 102 | u32 ctx[DISPC_SZ_REGS / sizeof(u32)]; |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 103 | |
| 104 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS |
| 105 | spinlock_t irq_stats_lock; |
| 106 | struct dispc_irq_stats irq_stats; |
| 107 | #endif |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 108 | } dispc; |
| 109 | |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 110 | enum omap_color_component { |
| 111 | /* used for all color formats for OMAP3 and earlier |
| 112 | * and for RGB and Y color component on OMAP4 |
| 113 | */ |
| 114 | DISPC_COLOR_COMPONENT_RGB_Y = 1 << 0, |
| 115 | /* used for UV component for |
| 116 | * OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_UYVY, OMAP_DSS_COLOR_NV12 |
| 117 | * color formats on OMAP4 |
| 118 | */ |
| 119 | DISPC_COLOR_COMPONENT_UV = 1 << 1, |
| 120 | }; |
| 121 | |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 122 | enum mgr_reg_fields { |
| 123 | DISPC_MGR_FLD_ENABLE, |
| 124 | DISPC_MGR_FLD_STNTFT, |
| 125 | DISPC_MGR_FLD_GO, |
| 126 | DISPC_MGR_FLD_TFTDATALINES, |
| 127 | DISPC_MGR_FLD_STALLMODE, |
| 128 | DISPC_MGR_FLD_TCKENABLE, |
| 129 | DISPC_MGR_FLD_TCKSELECTION, |
| 130 | DISPC_MGR_FLD_CPR, |
| 131 | DISPC_MGR_FLD_FIFOHANDCHECK, |
| 132 | /* used to maintain a count of the above fields */ |
| 133 | DISPC_MGR_FLD_NUM, |
| 134 | }; |
| 135 | |
| 136 | static const struct { |
| 137 | const char *name; |
| 138 | u32 vsync_irq; |
| 139 | u32 framedone_irq; |
| 140 | u32 sync_lost_irq; |
| 141 | struct reg_field reg_desc[DISPC_MGR_FLD_NUM]; |
| 142 | } mgr_desc[] = { |
| 143 | [OMAP_DSS_CHANNEL_LCD] = { |
| 144 | .name = "LCD", |
| 145 | .vsync_irq = DISPC_IRQ_VSYNC, |
| 146 | .framedone_irq = DISPC_IRQ_FRAMEDONE, |
| 147 | .sync_lost_irq = DISPC_IRQ_SYNC_LOST, |
| 148 | .reg_desc = { |
| 149 | [DISPC_MGR_FLD_ENABLE] = { DISPC_CONTROL, 0, 0 }, |
| 150 | [DISPC_MGR_FLD_STNTFT] = { DISPC_CONTROL, 3, 3 }, |
| 151 | [DISPC_MGR_FLD_GO] = { DISPC_CONTROL, 5, 5 }, |
| 152 | [DISPC_MGR_FLD_TFTDATALINES] = { DISPC_CONTROL, 9, 8 }, |
| 153 | [DISPC_MGR_FLD_STALLMODE] = { DISPC_CONTROL, 11, 11 }, |
| 154 | [DISPC_MGR_FLD_TCKENABLE] = { DISPC_CONFIG, 10, 10 }, |
| 155 | [DISPC_MGR_FLD_TCKSELECTION] = { DISPC_CONFIG, 11, 11 }, |
| 156 | [DISPC_MGR_FLD_CPR] = { DISPC_CONFIG, 15, 15 }, |
| 157 | [DISPC_MGR_FLD_FIFOHANDCHECK] = { DISPC_CONFIG, 16, 16 }, |
| 158 | }, |
| 159 | }, |
| 160 | [OMAP_DSS_CHANNEL_DIGIT] = { |
| 161 | .name = "DIGIT", |
| 162 | .vsync_irq = DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_EVSYNC_EVEN, |
| 163 | .framedone_irq = 0, |
| 164 | .sync_lost_irq = DISPC_IRQ_SYNC_LOST_DIGIT, |
| 165 | .reg_desc = { |
| 166 | [DISPC_MGR_FLD_ENABLE] = { DISPC_CONTROL, 1, 1 }, |
| 167 | [DISPC_MGR_FLD_STNTFT] = { }, |
| 168 | [DISPC_MGR_FLD_GO] = { DISPC_CONTROL, 6, 6 }, |
| 169 | [DISPC_MGR_FLD_TFTDATALINES] = { }, |
| 170 | [DISPC_MGR_FLD_STALLMODE] = { }, |
| 171 | [DISPC_MGR_FLD_TCKENABLE] = { DISPC_CONFIG, 12, 12 }, |
| 172 | [DISPC_MGR_FLD_TCKSELECTION] = { DISPC_CONFIG, 13, 13 }, |
| 173 | [DISPC_MGR_FLD_CPR] = { }, |
| 174 | [DISPC_MGR_FLD_FIFOHANDCHECK] = { DISPC_CONFIG, 16, 16 }, |
| 175 | }, |
| 176 | }, |
| 177 | [OMAP_DSS_CHANNEL_LCD2] = { |
| 178 | .name = "LCD2", |
| 179 | .vsync_irq = DISPC_IRQ_VSYNC2, |
| 180 | .framedone_irq = DISPC_IRQ_FRAMEDONE2, |
| 181 | .sync_lost_irq = DISPC_IRQ_SYNC_LOST2, |
| 182 | .reg_desc = { |
| 183 | [DISPC_MGR_FLD_ENABLE] = { DISPC_CONTROL2, 0, 0 }, |
| 184 | [DISPC_MGR_FLD_STNTFT] = { DISPC_CONTROL2, 3, 3 }, |
| 185 | [DISPC_MGR_FLD_GO] = { DISPC_CONTROL2, 5, 5 }, |
| 186 | [DISPC_MGR_FLD_TFTDATALINES] = { DISPC_CONTROL2, 9, 8 }, |
| 187 | [DISPC_MGR_FLD_STALLMODE] = { DISPC_CONTROL2, 11, 11 }, |
| 188 | [DISPC_MGR_FLD_TCKENABLE] = { DISPC_CONFIG2, 10, 10 }, |
| 189 | [DISPC_MGR_FLD_TCKSELECTION] = { DISPC_CONFIG2, 11, 11 }, |
| 190 | [DISPC_MGR_FLD_CPR] = { DISPC_CONFIG2, 15, 15 }, |
| 191 | [DISPC_MGR_FLD_FIFOHANDCHECK] = { DISPC_CONFIG2, 16, 16 }, |
| 192 | }, |
| 193 | }, |
| 194 | }; |
| 195 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 196 | static void _omap_dispc_set_irqs(void); |
| 197 | |
Archit Taneja | 55978cc | 2011-05-06 11:45:51 +0530 | [diff] [blame] | 198 | static inline void dispc_write_reg(const u16 idx, u32 val) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 199 | { |
Archit Taneja | 55978cc | 2011-05-06 11:45:51 +0530 | [diff] [blame] | 200 | __raw_writel(val, dispc.base + idx); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 201 | } |
| 202 | |
Archit Taneja | 55978cc | 2011-05-06 11:45:51 +0530 | [diff] [blame] | 203 | static inline u32 dispc_read_reg(const u16 idx) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 204 | { |
Archit Taneja | 55978cc | 2011-05-06 11:45:51 +0530 | [diff] [blame] | 205 | return __raw_readl(dispc.base + idx); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 206 | } |
| 207 | |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 208 | static u32 mgr_fld_read(enum omap_channel channel, enum mgr_reg_fields regfld) |
| 209 | { |
| 210 | const struct reg_field rfld = mgr_desc[channel].reg_desc[regfld]; |
| 211 | return REG_GET(rfld.reg, rfld.high, rfld.low); |
| 212 | } |
| 213 | |
| 214 | static void mgr_fld_write(enum omap_channel channel, |
| 215 | enum mgr_reg_fields regfld, int val) { |
| 216 | const struct reg_field rfld = mgr_desc[channel].reg_desc[regfld]; |
| 217 | REG_FLD_MOD(rfld.reg, val, rfld.high, rfld.low); |
| 218 | } |
| 219 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 220 | #define SR(reg) \ |
Archit Taneja | 55978cc | 2011-05-06 11:45:51 +0530 | [diff] [blame] | 221 | dispc.ctx[DISPC_##reg / sizeof(u32)] = dispc_read_reg(DISPC_##reg) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 222 | #define RR(reg) \ |
Archit Taneja | 55978cc | 2011-05-06 11:45:51 +0530 | [diff] [blame] | 223 | dispc_write_reg(DISPC_##reg, dispc.ctx[DISPC_##reg / sizeof(u32)]) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 224 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 225 | static void dispc_save_context(void) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 226 | { |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 227 | int i, j; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 228 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 229 | DSSDBG("dispc_save_context\n"); |
| 230 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 231 | SR(IRQENABLE); |
| 232 | SR(CONTROL); |
| 233 | SR(CONFIG); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 234 | SR(LINE_NUMBER); |
Archit Taneja | 11354dd | 2011-09-26 11:47:29 +0530 | [diff] [blame] | 235 | if (dss_has_feature(FEAT_ALPHA_FIXED_ZORDER) || |
| 236 | dss_has_feature(FEAT_ALPHA_FREE_ZORDER)) |
Tomi Valkeinen | 332e9d7 | 2011-05-27 14:22:16 +0300 | [diff] [blame] | 237 | SR(GLOBAL_ALPHA); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 238 | if (dss_has_feature(FEAT_MGR_LCD2)) { |
| 239 | SR(CONTROL2); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 240 | SR(CONFIG2); |
| 241 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 242 | |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 243 | for (i = 0; i < dss_feat_get_num_mgrs(); i++) { |
| 244 | SR(DEFAULT_COLOR(i)); |
| 245 | SR(TRANS_COLOR(i)); |
| 246 | SR(SIZE_MGR(i)); |
| 247 | if (i == OMAP_DSS_CHANNEL_DIGIT) |
| 248 | continue; |
| 249 | SR(TIMING_H(i)); |
| 250 | SR(TIMING_V(i)); |
| 251 | SR(POL_FREQ(i)); |
| 252 | SR(DIVISORo(i)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 253 | |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 254 | SR(DATA_CYCLE1(i)); |
| 255 | SR(DATA_CYCLE2(i)); |
| 256 | SR(DATA_CYCLE3(i)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 257 | |
Tomi Valkeinen | 332e9d7 | 2011-05-27 14:22:16 +0300 | [diff] [blame] | 258 | if (dss_has_feature(FEAT_CPR)) { |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 259 | SR(CPR_COEF_R(i)); |
| 260 | SR(CPR_COEF_G(i)); |
| 261 | SR(CPR_COEF_B(i)); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | for (i = 0; i < dss_feat_get_num_ovls(); i++) { |
| 266 | SR(OVL_BA0(i)); |
| 267 | SR(OVL_BA1(i)); |
| 268 | SR(OVL_POSITION(i)); |
| 269 | SR(OVL_SIZE(i)); |
| 270 | SR(OVL_ATTRIBUTES(i)); |
| 271 | SR(OVL_FIFO_THRESHOLD(i)); |
| 272 | SR(OVL_ROW_INC(i)); |
| 273 | SR(OVL_PIXEL_INC(i)); |
| 274 | if (dss_has_feature(FEAT_PRELOAD)) |
| 275 | SR(OVL_PRELOAD(i)); |
| 276 | if (i == OMAP_DSS_GFX) { |
| 277 | SR(OVL_WINDOW_SKIP(i)); |
| 278 | SR(OVL_TABLE_BA(i)); |
| 279 | continue; |
| 280 | } |
| 281 | SR(OVL_FIR(i)); |
| 282 | SR(OVL_PICTURE_SIZE(i)); |
| 283 | SR(OVL_ACCU0(i)); |
| 284 | SR(OVL_ACCU1(i)); |
| 285 | |
| 286 | for (j = 0; j < 8; j++) |
| 287 | SR(OVL_FIR_COEF_H(i, j)); |
| 288 | |
| 289 | for (j = 0; j < 8; j++) |
| 290 | SR(OVL_FIR_COEF_HV(i, j)); |
| 291 | |
| 292 | for (j = 0; j < 5; j++) |
| 293 | SR(OVL_CONV_COEF(i, j)); |
| 294 | |
| 295 | if (dss_has_feature(FEAT_FIR_COEF_V)) { |
| 296 | for (j = 0; j < 8; j++) |
| 297 | SR(OVL_FIR_COEF_V(i, j)); |
Tomi Valkeinen | 332e9d7 | 2011-05-27 14:22:16 +0300 | [diff] [blame] | 298 | } |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 299 | |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 300 | if (dss_has_feature(FEAT_HANDLE_UV_SEPARATE)) { |
| 301 | SR(OVL_BA0_UV(i)); |
| 302 | SR(OVL_BA1_UV(i)); |
| 303 | SR(OVL_FIR2(i)); |
| 304 | SR(OVL_ACCU2_0(i)); |
| 305 | SR(OVL_ACCU2_1(i)); |
| 306 | |
| 307 | for (j = 0; j < 8; j++) |
| 308 | SR(OVL_FIR_COEF_H2(i, j)); |
| 309 | |
| 310 | for (j = 0; j < 8; j++) |
| 311 | SR(OVL_FIR_COEF_HV2(i, j)); |
| 312 | |
| 313 | for (j = 0; j < 8; j++) |
| 314 | SR(OVL_FIR_COEF_V2(i, j)); |
| 315 | } |
| 316 | if (dss_has_feature(FEAT_ATTR2)) |
| 317 | SR(OVL_ATTRIBUTES2(i)); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 318 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 319 | |
Murthy, Raghuveer | 0cf35df | 2011-03-03 09:28:00 -0600 | [diff] [blame] | 320 | if (dss_has_feature(FEAT_CORE_CLK_DIV)) |
| 321 | SR(DIVISOR); |
Tomi Valkeinen | 49ea86f | 2011-06-01 15:54:06 +0300 | [diff] [blame] | 322 | |
Tomi Valkeinen | 00928ea | 2012-02-20 11:50:06 +0200 | [diff] [blame] | 323 | dispc.ctx_loss_cnt = dss_get_ctx_loss_count(&dispc.pdev->dev); |
Tomi Valkeinen | 49ea86f | 2011-06-01 15:54:06 +0300 | [diff] [blame] | 324 | dispc.ctx_valid = true; |
| 325 | |
| 326 | DSSDBG("context saved, ctx_loss_count %d\n", dispc.ctx_loss_cnt); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 327 | } |
| 328 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 329 | static void dispc_restore_context(void) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 330 | { |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 331 | int i, j, ctx; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 332 | |
| 333 | DSSDBG("dispc_restore_context\n"); |
| 334 | |
Tomi Valkeinen | 49ea86f | 2011-06-01 15:54:06 +0300 | [diff] [blame] | 335 | if (!dispc.ctx_valid) |
| 336 | return; |
| 337 | |
Tomi Valkeinen | 00928ea | 2012-02-20 11:50:06 +0200 | [diff] [blame] | 338 | ctx = dss_get_ctx_loss_count(&dispc.pdev->dev); |
Tomi Valkeinen | 49ea86f | 2011-06-01 15:54:06 +0300 | [diff] [blame] | 339 | |
| 340 | if (ctx >= 0 && ctx == dispc.ctx_loss_cnt) |
| 341 | return; |
| 342 | |
| 343 | DSSDBG("ctx_loss_count: saved %d, current %d\n", |
| 344 | dispc.ctx_loss_cnt, ctx); |
| 345 | |
Ville Syrjälä | 75c7d59 | 2010-03-05 01:13:11 +0200 | [diff] [blame] | 346 | /*RR(IRQENABLE);*/ |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 347 | /*RR(CONTROL);*/ |
| 348 | RR(CONFIG); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 349 | RR(LINE_NUMBER); |
Archit Taneja | 11354dd | 2011-09-26 11:47:29 +0530 | [diff] [blame] | 350 | if (dss_has_feature(FEAT_ALPHA_FIXED_ZORDER) || |
| 351 | dss_has_feature(FEAT_ALPHA_FREE_ZORDER)) |
Tomi Valkeinen | 332e9d7 | 2011-05-27 14:22:16 +0300 | [diff] [blame] | 352 | RR(GLOBAL_ALPHA); |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 353 | if (dss_has_feature(FEAT_MGR_LCD2)) |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 354 | RR(CONFIG2); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 355 | |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 356 | for (i = 0; i < dss_feat_get_num_mgrs(); i++) { |
| 357 | RR(DEFAULT_COLOR(i)); |
| 358 | RR(TRANS_COLOR(i)); |
| 359 | RR(SIZE_MGR(i)); |
| 360 | if (i == OMAP_DSS_CHANNEL_DIGIT) |
| 361 | continue; |
| 362 | RR(TIMING_H(i)); |
| 363 | RR(TIMING_V(i)); |
| 364 | RR(POL_FREQ(i)); |
| 365 | RR(DIVISORo(i)); |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 366 | |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 367 | RR(DATA_CYCLE1(i)); |
| 368 | RR(DATA_CYCLE2(i)); |
| 369 | RR(DATA_CYCLE3(i)); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 370 | |
Tomi Valkeinen | 332e9d7 | 2011-05-27 14:22:16 +0300 | [diff] [blame] | 371 | if (dss_has_feature(FEAT_CPR)) { |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 372 | RR(CPR_COEF_R(i)); |
| 373 | RR(CPR_COEF_G(i)); |
| 374 | RR(CPR_COEF_B(i)); |
Tomi Valkeinen | 332e9d7 | 2011-05-27 14:22:16 +0300 | [diff] [blame] | 375 | } |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 376 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 377 | |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 378 | for (i = 0; i < dss_feat_get_num_ovls(); i++) { |
| 379 | RR(OVL_BA0(i)); |
| 380 | RR(OVL_BA1(i)); |
| 381 | RR(OVL_POSITION(i)); |
| 382 | RR(OVL_SIZE(i)); |
| 383 | RR(OVL_ATTRIBUTES(i)); |
| 384 | RR(OVL_FIFO_THRESHOLD(i)); |
| 385 | RR(OVL_ROW_INC(i)); |
| 386 | RR(OVL_PIXEL_INC(i)); |
| 387 | if (dss_has_feature(FEAT_PRELOAD)) |
| 388 | RR(OVL_PRELOAD(i)); |
| 389 | if (i == OMAP_DSS_GFX) { |
| 390 | RR(OVL_WINDOW_SKIP(i)); |
| 391 | RR(OVL_TABLE_BA(i)); |
| 392 | continue; |
| 393 | } |
| 394 | RR(OVL_FIR(i)); |
| 395 | RR(OVL_PICTURE_SIZE(i)); |
| 396 | RR(OVL_ACCU0(i)); |
| 397 | RR(OVL_ACCU1(i)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 398 | |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 399 | for (j = 0; j < 8; j++) |
| 400 | RR(OVL_FIR_COEF_H(i, j)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 401 | |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 402 | for (j = 0; j < 8; j++) |
| 403 | RR(OVL_FIR_COEF_HV(i, j)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 404 | |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 405 | for (j = 0; j < 5; j++) |
| 406 | RR(OVL_CONV_COEF(i, j)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 407 | |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 408 | if (dss_has_feature(FEAT_FIR_COEF_V)) { |
| 409 | for (j = 0; j < 8; j++) |
| 410 | RR(OVL_FIR_COEF_V(i, j)); |
| 411 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 412 | |
Archit Taneja | c6104b8 | 2011-08-05 19:06:02 +0530 | [diff] [blame] | 413 | if (dss_has_feature(FEAT_HANDLE_UV_SEPARATE)) { |
| 414 | RR(OVL_BA0_UV(i)); |
| 415 | RR(OVL_BA1_UV(i)); |
| 416 | RR(OVL_FIR2(i)); |
| 417 | RR(OVL_ACCU2_0(i)); |
| 418 | RR(OVL_ACCU2_1(i)); |
| 419 | |
| 420 | for (j = 0; j < 8; j++) |
| 421 | RR(OVL_FIR_COEF_H2(i, j)); |
| 422 | |
| 423 | for (j = 0; j < 8; j++) |
| 424 | RR(OVL_FIR_COEF_HV2(i, j)); |
| 425 | |
| 426 | for (j = 0; j < 8; j++) |
| 427 | RR(OVL_FIR_COEF_V2(i, j)); |
| 428 | } |
| 429 | if (dss_has_feature(FEAT_ATTR2)) |
| 430 | RR(OVL_ATTRIBUTES2(i)); |
Tomi Valkeinen | 332e9d7 | 2011-05-27 14:22:16 +0300 | [diff] [blame] | 431 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 432 | |
Murthy, Raghuveer | 0cf35df | 2011-03-03 09:28:00 -0600 | [diff] [blame] | 433 | if (dss_has_feature(FEAT_CORE_CLK_DIV)) |
| 434 | RR(DIVISOR); |
| 435 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 436 | /* enable last, because LCD & DIGIT enable are here */ |
| 437 | RR(CONTROL); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 438 | if (dss_has_feature(FEAT_MGR_LCD2)) |
| 439 | RR(CONTROL2); |
Ville Syrjälä | 75c7d59 | 2010-03-05 01:13:11 +0200 | [diff] [blame] | 440 | /* clear spurious SYNC_LOST_DIGIT interrupts */ |
| 441 | dispc_write_reg(DISPC_IRQSTATUS, DISPC_IRQ_SYNC_LOST_DIGIT); |
| 442 | |
| 443 | /* |
| 444 | * enable last so IRQs won't trigger before |
| 445 | * the context is fully restored |
| 446 | */ |
| 447 | RR(IRQENABLE); |
Tomi Valkeinen | 49ea86f | 2011-06-01 15:54:06 +0300 | [diff] [blame] | 448 | |
| 449 | DSSDBG("context restored\n"); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | #undef SR |
| 453 | #undef RR |
| 454 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 455 | int dispc_runtime_get(void) |
| 456 | { |
| 457 | int r; |
| 458 | |
| 459 | DSSDBG("dispc_runtime_get\n"); |
| 460 | |
| 461 | r = pm_runtime_get_sync(&dispc.pdev->dev); |
| 462 | WARN_ON(r < 0); |
| 463 | return r < 0 ? r : 0; |
| 464 | } |
| 465 | |
| 466 | void dispc_runtime_put(void) |
| 467 | { |
| 468 | int r; |
| 469 | |
| 470 | DSSDBG("dispc_runtime_put\n"); |
| 471 | |
Tomi Valkeinen | 0eaf9f5 | 2012-01-23 13:23:08 +0200 | [diff] [blame] | 472 | r = pm_runtime_put_sync(&dispc.pdev->dev); |
Tomi Valkeinen | 5be3aeb | 2012-06-27 16:37:18 +0300 | [diff] [blame] | 473 | WARN_ON(r < 0 && r != -ENOSYS); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 474 | } |
| 475 | |
Archit Taneja | dac57a0 | 2011-09-08 12:30:19 +0530 | [diff] [blame] | 476 | static inline bool dispc_mgr_is_lcd(enum omap_channel channel) |
| 477 | { |
| 478 | if (channel == OMAP_DSS_CHANNEL_LCD || |
| 479 | channel == OMAP_DSS_CHANNEL_LCD2) |
| 480 | return true; |
| 481 | else |
| 482 | return false; |
| 483 | } |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 484 | |
Tomi Valkeinen | 3dcec4d | 2011-11-07 15:50:09 +0200 | [diff] [blame] | 485 | u32 dispc_mgr_get_vsync_irq(enum omap_channel channel) |
| 486 | { |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 487 | return mgr_desc[channel].vsync_irq; |
Tomi Valkeinen | 3dcec4d | 2011-11-07 15:50:09 +0200 | [diff] [blame] | 488 | } |
| 489 | |
Tomi Valkeinen | 7d1365c | 2011-11-18 15:39:52 +0200 | [diff] [blame] | 490 | u32 dispc_mgr_get_framedone_irq(enum omap_channel channel) |
| 491 | { |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 492 | return mgr_desc[channel].framedone_irq; |
Tomi Valkeinen | 7d1365c | 2011-11-18 15:39:52 +0200 | [diff] [blame] | 493 | } |
| 494 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 495 | bool dispc_mgr_go_busy(enum omap_channel channel) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 496 | { |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 497 | return mgr_fld_read(channel, DISPC_MGR_FLD_GO) == 1; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 498 | } |
| 499 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 500 | void dispc_mgr_go(enum omap_channel channel) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 501 | { |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 502 | bool enable_bit, go_bit; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 503 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 504 | /* if the channel is not enabled, we don't need GO */ |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 505 | enable_bit = mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE) == 1; |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 506 | |
| 507 | if (!enable_bit) |
Tomi Valkeinen | e6d80f9 | 2011-05-19 14:12:26 +0300 | [diff] [blame] | 508 | return; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 509 | |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 510 | go_bit = mgr_fld_read(channel, DISPC_MGR_FLD_GO) == 1; |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 511 | |
| 512 | if (go_bit) { |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 513 | DSSERR("GO bit not down for channel %d\n", channel); |
Tomi Valkeinen | e6d80f9 | 2011-05-19 14:12:26 +0300 | [diff] [blame] | 514 | return; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 515 | } |
| 516 | |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 517 | DSSDBG("GO %s\n", mgr_desc[channel].name); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 518 | |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 519 | mgr_fld_write(channel, DISPC_MGR_FLD_GO, 1); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 520 | } |
| 521 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 522 | static void dispc_ovl_write_firh_reg(enum omap_plane plane, int reg, u32 value) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 523 | { |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 524 | dispc_write_reg(DISPC_OVL_FIR_COEF_H(plane, reg), value); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 525 | } |
| 526 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 527 | static void dispc_ovl_write_firhv_reg(enum omap_plane plane, int reg, u32 value) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 528 | { |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 529 | dispc_write_reg(DISPC_OVL_FIR_COEF_HV(plane, reg), value); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 530 | } |
| 531 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 532 | static void dispc_ovl_write_firv_reg(enum omap_plane plane, int reg, u32 value) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 533 | { |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 534 | dispc_write_reg(DISPC_OVL_FIR_COEF_V(plane, reg), value); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 535 | } |
| 536 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 537 | static void dispc_ovl_write_firh2_reg(enum omap_plane plane, int reg, u32 value) |
Amber Jain | ab5ca07 | 2011-05-19 19:47:53 +0530 | [diff] [blame] | 538 | { |
| 539 | BUG_ON(plane == OMAP_DSS_GFX); |
| 540 | |
| 541 | dispc_write_reg(DISPC_OVL_FIR_COEF_H2(plane, reg), value); |
| 542 | } |
| 543 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 544 | static void dispc_ovl_write_firhv2_reg(enum omap_plane plane, int reg, |
| 545 | u32 value) |
Amber Jain | ab5ca07 | 2011-05-19 19:47:53 +0530 | [diff] [blame] | 546 | { |
| 547 | BUG_ON(plane == OMAP_DSS_GFX); |
| 548 | |
| 549 | dispc_write_reg(DISPC_OVL_FIR_COEF_HV2(plane, reg), value); |
| 550 | } |
| 551 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 552 | static void dispc_ovl_write_firv2_reg(enum omap_plane plane, int reg, u32 value) |
Amber Jain | ab5ca07 | 2011-05-19 19:47:53 +0530 | [diff] [blame] | 553 | { |
| 554 | BUG_ON(plane == OMAP_DSS_GFX); |
| 555 | |
| 556 | dispc_write_reg(DISPC_OVL_FIR_COEF_V2(plane, reg), value); |
| 557 | } |
| 558 | |
Chandrabhanu Mahapatra | debd907 | 2011-12-19 14:03:44 +0530 | [diff] [blame] | 559 | static void dispc_ovl_set_scale_coef(enum omap_plane plane, int fir_hinc, |
| 560 | int fir_vinc, int five_taps, |
| 561 | enum omap_color_component color_comp) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 562 | { |
Chandrabhanu Mahapatra | debd907 | 2011-12-19 14:03:44 +0530 | [diff] [blame] | 563 | const struct dispc_coef *h_coef, *v_coef; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 564 | int i; |
| 565 | |
Chandrabhanu Mahapatra | debd907 | 2011-12-19 14:03:44 +0530 | [diff] [blame] | 566 | h_coef = dispc_ovl_get_scale_coef(fir_hinc, true); |
| 567 | v_coef = dispc_ovl_get_scale_coef(fir_vinc, five_taps); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 568 | |
| 569 | for (i = 0; i < 8; i++) { |
| 570 | u32 h, hv; |
| 571 | |
Chandrabhanu Mahapatra | debd907 | 2011-12-19 14:03:44 +0530 | [diff] [blame] | 572 | h = FLD_VAL(h_coef[i].hc0_vc00, 7, 0) |
| 573 | | FLD_VAL(h_coef[i].hc1_vc0, 15, 8) |
| 574 | | FLD_VAL(h_coef[i].hc2_vc1, 23, 16) |
| 575 | | FLD_VAL(h_coef[i].hc3_vc2, 31, 24); |
| 576 | hv = FLD_VAL(h_coef[i].hc4_vc22, 7, 0) |
| 577 | | FLD_VAL(v_coef[i].hc1_vc0, 15, 8) |
| 578 | | FLD_VAL(v_coef[i].hc2_vc1, 23, 16) |
| 579 | | FLD_VAL(v_coef[i].hc3_vc2, 31, 24); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 580 | |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 581 | if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y) { |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 582 | dispc_ovl_write_firh_reg(plane, i, h); |
| 583 | dispc_ovl_write_firhv_reg(plane, i, hv); |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 584 | } else { |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 585 | dispc_ovl_write_firh2_reg(plane, i, h); |
| 586 | dispc_ovl_write_firhv2_reg(plane, i, hv); |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 587 | } |
| 588 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 589 | } |
| 590 | |
Grazvydas Ignotas | 66be8f6 | 2010-08-24 15:18:43 +0200 | [diff] [blame] | 591 | if (five_taps) { |
| 592 | for (i = 0; i < 8; i++) { |
| 593 | u32 v; |
Chandrabhanu Mahapatra | debd907 | 2011-12-19 14:03:44 +0530 | [diff] [blame] | 594 | v = FLD_VAL(v_coef[i].hc0_vc00, 7, 0) |
| 595 | | FLD_VAL(v_coef[i].hc4_vc22, 15, 8); |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 596 | if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y) |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 597 | dispc_ovl_write_firv_reg(plane, i, v); |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 598 | else |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 599 | dispc_ovl_write_firv2_reg(plane, i, v); |
Grazvydas Ignotas | 66be8f6 | 2010-08-24 15:18:43 +0200 | [diff] [blame] | 600 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 601 | } |
| 602 | } |
| 603 | |
| 604 | static void _dispc_setup_color_conv_coef(void) |
| 605 | { |
Archit Taneja | ac01c29 | 2011-08-05 19:06:03 +0530 | [diff] [blame] | 606 | int i; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 607 | const struct color_conv_coef { |
| 608 | int ry, rcr, rcb, gy, gcr, gcb, by, bcr, bcb; |
| 609 | int full_range; |
| 610 | } ctbl_bt601_5 = { |
| 611 | 298, 409, 0, 298, -208, -100, 298, 0, 517, 0, |
| 612 | }; |
| 613 | |
| 614 | const struct color_conv_coef *ct; |
| 615 | |
| 616 | #define CVAL(x, y) (FLD_VAL(x, 26, 16) | FLD_VAL(y, 10, 0)) |
| 617 | |
| 618 | ct = &ctbl_bt601_5; |
| 619 | |
Archit Taneja | ac01c29 | 2011-08-05 19:06:03 +0530 | [diff] [blame] | 620 | for (i = 1; i < dss_feat_get_num_ovls(); i++) { |
| 621 | dispc_write_reg(DISPC_OVL_CONV_COEF(i, 0), |
| 622 | CVAL(ct->rcr, ct->ry)); |
| 623 | dispc_write_reg(DISPC_OVL_CONV_COEF(i, 1), |
| 624 | CVAL(ct->gy, ct->rcb)); |
| 625 | dispc_write_reg(DISPC_OVL_CONV_COEF(i, 2), |
| 626 | CVAL(ct->gcb, ct->gcr)); |
| 627 | dispc_write_reg(DISPC_OVL_CONV_COEF(i, 3), |
| 628 | CVAL(ct->bcr, ct->by)); |
| 629 | dispc_write_reg(DISPC_OVL_CONV_COEF(i, 4), |
| 630 | CVAL(0, ct->bcb)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 631 | |
Archit Taneja | ac01c29 | 2011-08-05 19:06:03 +0530 | [diff] [blame] | 632 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(i), ct->full_range, |
| 633 | 11, 11); |
| 634 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 635 | |
| 636 | #undef CVAL |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 640 | static void dispc_ovl_set_ba0(enum omap_plane plane, u32 paddr) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 641 | { |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 642 | dispc_write_reg(DISPC_OVL_BA0(plane), paddr); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 643 | } |
| 644 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 645 | static void dispc_ovl_set_ba1(enum omap_plane plane, u32 paddr) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 646 | { |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 647 | dispc_write_reg(DISPC_OVL_BA1(plane), paddr); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 648 | } |
| 649 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 650 | static void dispc_ovl_set_ba0_uv(enum omap_plane plane, u32 paddr) |
Amber Jain | ab5ca07 | 2011-05-19 19:47:53 +0530 | [diff] [blame] | 651 | { |
| 652 | dispc_write_reg(DISPC_OVL_BA0_UV(plane), paddr); |
| 653 | } |
| 654 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 655 | static void dispc_ovl_set_ba1_uv(enum omap_plane plane, u32 paddr) |
Amber Jain | ab5ca07 | 2011-05-19 19:47:53 +0530 | [diff] [blame] | 656 | { |
| 657 | dispc_write_reg(DISPC_OVL_BA1_UV(plane), paddr); |
| 658 | } |
| 659 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 660 | static void dispc_ovl_set_pos(enum omap_plane plane, int x, int y) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 661 | { |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 662 | u32 val = FLD_VAL(y, 26, 16) | FLD_VAL(x, 10, 0); |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 663 | |
| 664 | dispc_write_reg(DISPC_OVL_POSITION(plane), val); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 665 | } |
| 666 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 667 | static void dispc_ovl_set_pic_size(enum omap_plane plane, int width, int height) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 668 | { |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 669 | u32 val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0); |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 670 | |
| 671 | if (plane == OMAP_DSS_GFX) |
| 672 | dispc_write_reg(DISPC_OVL_SIZE(plane), val); |
| 673 | else |
| 674 | dispc_write_reg(DISPC_OVL_PICTURE_SIZE(plane), val); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 675 | } |
| 676 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 677 | static void dispc_ovl_set_vid_size(enum omap_plane plane, int width, int height) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 678 | { |
| 679 | u32 val; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 680 | |
| 681 | BUG_ON(plane == OMAP_DSS_GFX); |
| 682 | |
| 683 | val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0); |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 684 | |
| 685 | dispc_write_reg(DISPC_OVL_SIZE(plane), val); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 686 | } |
| 687 | |
Archit Taneja | 5412870 | 2011-09-08 11:29:17 +0530 | [diff] [blame] | 688 | static void dispc_ovl_set_zorder(enum omap_plane plane, u8 zorder) |
| 689 | { |
| 690 | struct omap_overlay *ovl = omap_dss_get_overlay(plane); |
| 691 | |
| 692 | if ((ovl->caps & OMAP_DSS_OVL_CAP_ZORDER) == 0) |
| 693 | return; |
| 694 | |
| 695 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), zorder, 27, 26); |
| 696 | } |
| 697 | |
| 698 | static void dispc_ovl_enable_zorder_planes(void) |
| 699 | { |
| 700 | int i; |
| 701 | |
| 702 | if (!dss_has_feature(FEAT_ALPHA_FREE_ZORDER)) |
| 703 | return; |
| 704 | |
| 705 | for (i = 0; i < dss_feat_get_num_ovls(); i++) |
| 706 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(i), 1, 25, 25); |
| 707 | } |
| 708 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 709 | static void dispc_ovl_set_pre_mult_alpha(enum omap_plane plane, bool enable) |
Rajkumar N | fd28a39 | 2010-11-04 12:28:42 +0100 | [diff] [blame] | 710 | { |
Tomi Valkeinen | f6dc815 | 2011-08-15 15:18:20 +0300 | [diff] [blame] | 711 | struct omap_overlay *ovl = omap_dss_get_overlay(plane); |
Rajkumar N | fd28a39 | 2010-11-04 12:28:42 +0100 | [diff] [blame] | 712 | |
Tomi Valkeinen | f6dc815 | 2011-08-15 15:18:20 +0300 | [diff] [blame] | 713 | if ((ovl->caps & OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA) == 0) |
Rajkumar N | fd28a39 | 2010-11-04 12:28:42 +0100 | [diff] [blame] | 714 | return; |
| 715 | |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 716 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 28, 28); |
Rajkumar N | fd28a39 | 2010-11-04 12:28:42 +0100 | [diff] [blame] | 717 | } |
| 718 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 719 | static void dispc_ovl_setup_global_alpha(enum omap_plane plane, u8 global_alpha) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 720 | { |
Archit Taneja | b8c095b | 2011-09-13 18:20:33 +0530 | [diff] [blame] | 721 | static const unsigned shifts[] = { 0, 8, 16, 24, }; |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 722 | int shift; |
Tomi Valkeinen | f6dc815 | 2011-08-15 15:18:20 +0300 | [diff] [blame] | 723 | struct omap_overlay *ovl = omap_dss_get_overlay(plane); |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 724 | |
Tomi Valkeinen | f6dc815 | 2011-08-15 15:18:20 +0300 | [diff] [blame] | 725 | if ((ovl->caps & OMAP_DSS_OVL_CAP_GLOBAL_ALPHA) == 0) |
Rajkumar N | fd28a39 | 2010-11-04 12:28:42 +0100 | [diff] [blame] | 726 | return; |
Archit Taneja | a0acb55 | 2010-09-15 19:20:00 +0530 | [diff] [blame] | 727 | |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 728 | shift = shifts[plane]; |
| 729 | REG_FLD_MOD(DISPC_GLOBAL_ALPHA, global_alpha, shift + 7, shift); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 730 | } |
| 731 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 732 | static void dispc_ovl_set_pix_inc(enum omap_plane plane, s32 inc) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 733 | { |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 734 | dispc_write_reg(DISPC_OVL_PIXEL_INC(plane), inc); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 735 | } |
| 736 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 737 | static void dispc_ovl_set_row_inc(enum omap_plane plane, s32 inc) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 738 | { |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 739 | dispc_write_reg(DISPC_OVL_ROW_INC(plane), inc); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 740 | } |
| 741 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 742 | static void dispc_ovl_set_color_mode(enum omap_plane plane, |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 743 | enum omap_color_mode color_mode) |
| 744 | { |
| 745 | u32 m = 0; |
Amber Jain | f20e422 | 2011-05-19 19:47:50 +0530 | [diff] [blame] | 746 | if (plane != OMAP_DSS_GFX) { |
| 747 | switch (color_mode) { |
| 748 | case OMAP_DSS_COLOR_NV12: |
| 749 | m = 0x0; break; |
Lajos Molnar | 08f3267 | 2012-02-21 19:36:30 +0530 | [diff] [blame] | 750 | case OMAP_DSS_COLOR_RGBX16: |
Amber Jain | f20e422 | 2011-05-19 19:47:50 +0530 | [diff] [blame] | 751 | m = 0x1; break; |
| 752 | case OMAP_DSS_COLOR_RGBA16: |
| 753 | m = 0x2; break; |
Lajos Molnar | 08f3267 | 2012-02-21 19:36:30 +0530 | [diff] [blame] | 754 | case OMAP_DSS_COLOR_RGB12U: |
Amber Jain | f20e422 | 2011-05-19 19:47:50 +0530 | [diff] [blame] | 755 | m = 0x4; break; |
| 756 | case OMAP_DSS_COLOR_ARGB16: |
| 757 | m = 0x5; break; |
| 758 | case OMAP_DSS_COLOR_RGB16: |
| 759 | m = 0x6; break; |
| 760 | case OMAP_DSS_COLOR_ARGB16_1555: |
| 761 | m = 0x7; break; |
| 762 | case OMAP_DSS_COLOR_RGB24U: |
| 763 | m = 0x8; break; |
| 764 | case OMAP_DSS_COLOR_RGB24P: |
| 765 | m = 0x9; break; |
| 766 | case OMAP_DSS_COLOR_YUV2: |
| 767 | m = 0xa; break; |
| 768 | case OMAP_DSS_COLOR_UYVY: |
| 769 | m = 0xb; break; |
| 770 | case OMAP_DSS_COLOR_ARGB32: |
| 771 | m = 0xc; break; |
| 772 | case OMAP_DSS_COLOR_RGBA32: |
| 773 | m = 0xd; break; |
| 774 | case OMAP_DSS_COLOR_RGBX32: |
| 775 | m = 0xe; break; |
| 776 | case OMAP_DSS_COLOR_XRGB16_1555: |
| 777 | m = 0xf; break; |
| 778 | default: |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 779 | BUG(); return; |
Amber Jain | f20e422 | 2011-05-19 19:47:50 +0530 | [diff] [blame] | 780 | } |
| 781 | } else { |
| 782 | switch (color_mode) { |
| 783 | case OMAP_DSS_COLOR_CLUT1: |
| 784 | m = 0x0; break; |
| 785 | case OMAP_DSS_COLOR_CLUT2: |
| 786 | m = 0x1; break; |
| 787 | case OMAP_DSS_COLOR_CLUT4: |
| 788 | m = 0x2; break; |
| 789 | case OMAP_DSS_COLOR_CLUT8: |
| 790 | m = 0x3; break; |
| 791 | case OMAP_DSS_COLOR_RGB12U: |
| 792 | m = 0x4; break; |
| 793 | case OMAP_DSS_COLOR_ARGB16: |
| 794 | m = 0x5; break; |
| 795 | case OMAP_DSS_COLOR_RGB16: |
| 796 | m = 0x6; break; |
| 797 | case OMAP_DSS_COLOR_ARGB16_1555: |
| 798 | m = 0x7; break; |
| 799 | case OMAP_DSS_COLOR_RGB24U: |
| 800 | m = 0x8; break; |
| 801 | case OMAP_DSS_COLOR_RGB24P: |
| 802 | m = 0x9; break; |
Lajos Molnar | 08f3267 | 2012-02-21 19:36:30 +0530 | [diff] [blame] | 803 | case OMAP_DSS_COLOR_RGBX16: |
Amber Jain | f20e422 | 2011-05-19 19:47:50 +0530 | [diff] [blame] | 804 | m = 0xa; break; |
Lajos Molnar | 08f3267 | 2012-02-21 19:36:30 +0530 | [diff] [blame] | 805 | case OMAP_DSS_COLOR_RGBA16: |
Amber Jain | f20e422 | 2011-05-19 19:47:50 +0530 | [diff] [blame] | 806 | m = 0xb; break; |
| 807 | case OMAP_DSS_COLOR_ARGB32: |
| 808 | m = 0xc; break; |
| 809 | case OMAP_DSS_COLOR_RGBA32: |
| 810 | m = 0xd; break; |
| 811 | case OMAP_DSS_COLOR_RGBX32: |
| 812 | m = 0xe; break; |
| 813 | case OMAP_DSS_COLOR_XRGB16_1555: |
| 814 | m = 0xf; break; |
| 815 | default: |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 816 | BUG(); return; |
Amber Jain | f20e422 | 2011-05-19 19:47:50 +0530 | [diff] [blame] | 817 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 818 | } |
| 819 | |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 820 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), m, 4, 1); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 821 | } |
| 822 | |
Chandrabhanu Mahapatra | 65e006f | 2012-05-11 19:19:55 +0530 | [diff] [blame] | 823 | static void dispc_ovl_configure_burst_type(enum omap_plane plane, |
| 824 | enum omap_dss_rotation_type rotation_type) |
| 825 | { |
| 826 | if (dss_has_feature(FEAT_BURST_2D) == 0) |
| 827 | return; |
| 828 | |
| 829 | if (rotation_type == OMAP_DSS_ROT_TILER) |
| 830 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), 1, 29, 29); |
| 831 | else |
| 832 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), 0, 29, 29); |
| 833 | } |
| 834 | |
Tomi Valkeinen | f427984 | 2011-10-28 15:26:26 +0300 | [diff] [blame] | 835 | void dispc_ovl_set_channel_out(enum omap_plane plane, enum omap_channel channel) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 836 | { |
| 837 | int shift; |
| 838 | u32 val; |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 839 | int chan = 0, chan2 = 0; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 840 | |
| 841 | switch (plane) { |
| 842 | case OMAP_DSS_GFX: |
| 843 | shift = 8; |
| 844 | break; |
| 845 | case OMAP_DSS_VIDEO1: |
| 846 | case OMAP_DSS_VIDEO2: |
Archit Taneja | b8c095b | 2011-09-13 18:20:33 +0530 | [diff] [blame] | 847 | case OMAP_DSS_VIDEO3: |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 848 | shift = 16; |
| 849 | break; |
| 850 | default: |
| 851 | BUG(); |
| 852 | return; |
| 853 | } |
| 854 | |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 855 | val = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane)); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 856 | if (dss_has_feature(FEAT_MGR_LCD2)) { |
| 857 | switch (channel) { |
| 858 | case OMAP_DSS_CHANNEL_LCD: |
| 859 | chan = 0; |
| 860 | chan2 = 0; |
| 861 | break; |
| 862 | case OMAP_DSS_CHANNEL_DIGIT: |
| 863 | chan = 1; |
| 864 | chan2 = 0; |
| 865 | break; |
| 866 | case OMAP_DSS_CHANNEL_LCD2: |
| 867 | chan = 0; |
| 868 | chan2 = 1; |
| 869 | break; |
| 870 | default: |
| 871 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 872 | return; |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 873 | } |
| 874 | |
| 875 | val = FLD_MOD(val, chan, shift, shift); |
| 876 | val = FLD_MOD(val, chan2, 31, 30); |
| 877 | } else { |
| 878 | val = FLD_MOD(val, channel, shift, shift); |
| 879 | } |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 880 | dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), val); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 881 | } |
| 882 | |
Tomi Valkeinen | 2cc5d1a | 2011-11-03 17:03:44 +0200 | [diff] [blame] | 883 | static enum omap_channel dispc_ovl_get_channel_out(enum omap_plane plane) |
| 884 | { |
| 885 | int shift; |
| 886 | u32 val; |
| 887 | enum omap_channel channel; |
| 888 | |
| 889 | switch (plane) { |
| 890 | case OMAP_DSS_GFX: |
| 891 | shift = 8; |
| 892 | break; |
| 893 | case OMAP_DSS_VIDEO1: |
| 894 | case OMAP_DSS_VIDEO2: |
| 895 | case OMAP_DSS_VIDEO3: |
| 896 | shift = 16; |
| 897 | break; |
| 898 | default: |
| 899 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 900 | return 0; |
Tomi Valkeinen | 2cc5d1a | 2011-11-03 17:03:44 +0200 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | val = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane)); |
| 904 | |
| 905 | if (dss_has_feature(FEAT_MGR_LCD2)) { |
| 906 | if (FLD_GET(val, 31, 30) == 0) |
| 907 | channel = FLD_GET(val, shift, shift); |
| 908 | else |
| 909 | channel = OMAP_DSS_CHANNEL_LCD2; |
| 910 | } else { |
| 911 | channel = FLD_GET(val, shift, shift); |
| 912 | } |
| 913 | |
| 914 | return channel; |
| 915 | } |
| 916 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 917 | static void dispc_ovl_set_burst_size(enum omap_plane plane, |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 918 | enum omap_burst_size burst_size) |
| 919 | { |
Archit Taneja | b8c095b | 2011-09-13 18:20:33 +0530 | [diff] [blame] | 920 | static const unsigned shifts[] = { 6, 14, 14, 14, }; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 921 | int shift; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 922 | |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 923 | shift = shifts[plane]; |
Tomi Valkeinen | 5ed8cf5 | 2011-06-21 09:35:36 +0300 | [diff] [blame] | 924 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), burst_size, shift + 1, shift); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 925 | } |
| 926 | |
Tomi Valkeinen | 5ed8cf5 | 2011-06-21 09:35:36 +0300 | [diff] [blame] | 927 | static void dispc_configure_burst_sizes(void) |
| 928 | { |
| 929 | int i; |
| 930 | const int burst_size = BURST_SIZE_X8; |
| 931 | |
| 932 | /* Configure burst size always to maximum size */ |
| 933 | for (i = 0; i < omap_dss_get_num_overlays(); ++i) |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 934 | dispc_ovl_set_burst_size(i, burst_size); |
Tomi Valkeinen | 5ed8cf5 | 2011-06-21 09:35:36 +0300 | [diff] [blame] | 935 | } |
| 936 | |
Tomi Valkeinen | 83fa2f2 | 2012-01-13 13:17:01 +0200 | [diff] [blame] | 937 | static u32 dispc_ovl_get_burst_size(enum omap_plane plane) |
Tomi Valkeinen | 5ed8cf5 | 2011-06-21 09:35:36 +0300 | [diff] [blame] | 938 | { |
| 939 | unsigned unit = dss_feat_get_burst_size_unit(); |
| 940 | /* burst multiplier is always x8 (see dispc_configure_burst_sizes()) */ |
| 941 | return unit * 8; |
| 942 | } |
| 943 | |
Mythri P K | d386261 | 2011-03-11 18:02:49 +0530 | [diff] [blame] | 944 | void dispc_enable_gamma_table(bool enable) |
| 945 | { |
| 946 | /* |
| 947 | * This is partially implemented to support only disabling of |
| 948 | * the gamma table. |
| 949 | */ |
| 950 | if (enable) { |
| 951 | DSSWARN("Gamma table enabling for TV not yet supported"); |
| 952 | return; |
| 953 | } |
| 954 | |
| 955 | REG_FLD_MOD(DISPC_CONFIG, enable, 9, 9); |
| 956 | } |
| 957 | |
Tomi Valkeinen | c64dca4 | 2011-11-04 18:14:20 +0200 | [diff] [blame] | 958 | static void dispc_mgr_enable_cpr(enum omap_channel channel, bool enable) |
Tomi Valkeinen | 3c07cae | 2011-06-21 09:34:30 +0300 | [diff] [blame] | 959 | { |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 960 | if (channel == OMAP_DSS_CHANNEL_DIGIT) |
Tomi Valkeinen | 3c07cae | 2011-06-21 09:34:30 +0300 | [diff] [blame] | 961 | return; |
| 962 | |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 963 | mgr_fld_write(channel, DISPC_MGR_FLD_CPR, enable); |
Tomi Valkeinen | 3c07cae | 2011-06-21 09:34:30 +0300 | [diff] [blame] | 964 | } |
| 965 | |
Tomi Valkeinen | c64dca4 | 2011-11-04 18:14:20 +0200 | [diff] [blame] | 966 | static void dispc_mgr_set_cpr_coef(enum omap_channel channel, |
Tomi Valkeinen | 3c07cae | 2011-06-21 09:34:30 +0300 | [diff] [blame] | 967 | struct omap_dss_cpr_coefs *coefs) |
| 968 | { |
| 969 | u32 coef_r, coef_g, coef_b; |
| 970 | |
Archit Taneja | dac57a0 | 2011-09-08 12:30:19 +0530 | [diff] [blame] | 971 | if (!dispc_mgr_is_lcd(channel)) |
Tomi Valkeinen | 3c07cae | 2011-06-21 09:34:30 +0300 | [diff] [blame] | 972 | return; |
| 973 | |
| 974 | coef_r = FLD_VAL(coefs->rr, 31, 22) | FLD_VAL(coefs->rg, 20, 11) | |
| 975 | FLD_VAL(coefs->rb, 9, 0); |
| 976 | coef_g = FLD_VAL(coefs->gr, 31, 22) | FLD_VAL(coefs->gg, 20, 11) | |
| 977 | FLD_VAL(coefs->gb, 9, 0); |
| 978 | coef_b = FLD_VAL(coefs->br, 31, 22) | FLD_VAL(coefs->bg, 20, 11) | |
| 979 | FLD_VAL(coefs->bb, 9, 0); |
| 980 | |
| 981 | dispc_write_reg(DISPC_CPR_COEF_R(channel), coef_r); |
| 982 | dispc_write_reg(DISPC_CPR_COEF_G(channel), coef_g); |
| 983 | dispc_write_reg(DISPC_CPR_COEF_B(channel), coef_b); |
| 984 | } |
| 985 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 986 | static void dispc_ovl_set_vid_color_conv(enum omap_plane plane, bool enable) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 987 | { |
| 988 | u32 val; |
| 989 | |
| 990 | BUG_ON(plane == OMAP_DSS_GFX); |
| 991 | |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 992 | val = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 993 | val = FLD_MOD(val, enable, 9, 9); |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 994 | dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), val); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 995 | } |
| 996 | |
Archit Taneja | c3d92529 | 2011-09-14 11:52:54 +0530 | [diff] [blame] | 997 | static void dispc_ovl_enable_replication(enum omap_plane plane, bool enable) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 998 | { |
Archit Taneja | b8c095b | 2011-09-13 18:20:33 +0530 | [diff] [blame] | 999 | static const unsigned shifts[] = { 5, 10, 10, 10 }; |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 1000 | int shift; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1001 | |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 1002 | shift = shifts[plane]; |
| 1003 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable, shift, shift); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1004 | } |
| 1005 | |
Archit Taneja | 8f36616 | 2012-04-16 12:53:44 +0530 | [diff] [blame] | 1006 | static void dispc_mgr_set_size(enum omap_channel channel, u16 width, |
Archit Taneja | e5c09e0 | 2012-04-16 12:53:42 +0530 | [diff] [blame] | 1007 | u16 height) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1008 | { |
| 1009 | u32 val; |
Archit Taneja | 8f36616 | 2012-04-16 12:53:44 +0530 | [diff] [blame] | 1010 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1011 | val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0); |
Archit Taneja | 702d144 | 2011-05-06 11:45:50 +0530 | [diff] [blame] | 1012 | dispc_write_reg(DISPC_SIZE_MGR(channel), val); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1013 | } |
| 1014 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1015 | static void dispc_read_plane_fifo_sizes(void) |
| 1016 | { |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1017 | u32 size; |
| 1018 | int plane; |
Archit Taneja | a0acb55 | 2010-09-15 19:20:00 +0530 | [diff] [blame] | 1019 | u8 start, end; |
Tomi Valkeinen | 5ed8cf5 | 2011-06-21 09:35:36 +0300 | [diff] [blame] | 1020 | u32 unit; |
| 1021 | |
| 1022 | unit = dss_feat_get_buffer_size_unit(); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1023 | |
Archit Taneja | a0acb55 | 2010-09-15 19:20:00 +0530 | [diff] [blame] | 1024 | dss_feat_get_reg_field(FEAT_REG_FIFOSIZE, &start, &end); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1025 | |
Archit Taneja | e13a138 | 2011-08-05 19:06:04 +0530 | [diff] [blame] | 1026 | for (plane = 0; plane < dss_feat_get_num_ovls(); ++plane) { |
Tomi Valkeinen | 5ed8cf5 | 2011-06-21 09:35:36 +0300 | [diff] [blame] | 1027 | size = REG_GET(DISPC_OVL_FIFO_SIZE_STATUS(plane), start, end); |
| 1028 | size *= unit; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1029 | dispc.fifo_size[plane] = size; |
| 1030 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1031 | } |
| 1032 | |
Tomi Valkeinen | 83fa2f2 | 2012-01-13 13:17:01 +0200 | [diff] [blame] | 1033 | static u32 dispc_ovl_get_fifo_size(enum omap_plane plane) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1034 | { |
| 1035 | return dispc.fifo_size[plane]; |
| 1036 | } |
| 1037 | |
Tomi Valkeinen | 6f04e1b | 2011-10-31 08:58:52 +0200 | [diff] [blame] | 1038 | void dispc_ovl_set_fifo_threshold(enum omap_plane plane, u32 low, u32 high) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1039 | { |
Archit Taneja | a0acb55 | 2010-09-15 19:20:00 +0530 | [diff] [blame] | 1040 | u8 hi_start, hi_end, lo_start, lo_end; |
Tomi Valkeinen | 5ed8cf5 | 2011-06-21 09:35:36 +0300 | [diff] [blame] | 1041 | u32 unit; |
| 1042 | |
| 1043 | unit = dss_feat_get_buffer_size_unit(); |
| 1044 | |
| 1045 | WARN_ON(low % unit != 0); |
| 1046 | WARN_ON(high % unit != 0); |
| 1047 | |
| 1048 | low /= unit; |
| 1049 | high /= unit; |
Archit Taneja | a0acb55 | 2010-09-15 19:20:00 +0530 | [diff] [blame] | 1050 | |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 1051 | dss_feat_get_reg_field(FEAT_REG_FIFOHIGHTHRESHOLD, &hi_start, &hi_end); |
| 1052 | dss_feat_get_reg_field(FEAT_REG_FIFOLOWTHRESHOLD, &lo_start, &lo_end); |
| 1053 | |
Tomi Valkeinen | 3cb5d96 | 2012-01-13 13:14:57 +0200 | [diff] [blame] | 1054 | DSSDBG("fifo(%d) threshold (bytes), old %u/%u, new %u/%u\n", |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1055 | plane, |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 1056 | REG_GET(DISPC_OVL_FIFO_THRESHOLD(plane), |
Tomi Valkeinen | 3cb5d96 | 2012-01-13 13:14:57 +0200 | [diff] [blame] | 1057 | lo_start, lo_end) * unit, |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 1058 | REG_GET(DISPC_OVL_FIFO_THRESHOLD(plane), |
Tomi Valkeinen | 3cb5d96 | 2012-01-13 13:14:57 +0200 | [diff] [blame] | 1059 | hi_start, hi_end) * unit, |
| 1060 | low * unit, high * unit); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1061 | |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 1062 | dispc_write_reg(DISPC_OVL_FIFO_THRESHOLD(plane), |
Archit Taneja | a0acb55 | 2010-09-15 19:20:00 +0530 | [diff] [blame] | 1063 | FLD_VAL(high, hi_start, hi_end) | |
| 1064 | FLD_VAL(low, lo_start, lo_end)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1065 | } |
| 1066 | |
| 1067 | void dispc_enable_fifomerge(bool enable) |
| 1068 | { |
Tomi Valkeinen | e6b0f88 | 2012-01-13 13:24:04 +0200 | [diff] [blame] | 1069 | if (!dss_has_feature(FEAT_FIFO_MERGE)) { |
| 1070 | WARN_ON(enable); |
| 1071 | return; |
| 1072 | } |
| 1073 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1074 | DSSDBG("FIFO merge %s\n", enable ? "enabled" : "disabled"); |
| 1075 | REG_FLD_MOD(DISPC_CONFIG, enable ? 1 : 0, 14, 14); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1076 | } |
| 1077 | |
Tomi Valkeinen | 83fa2f2 | 2012-01-13 13:17:01 +0200 | [diff] [blame] | 1078 | void dispc_ovl_compute_fifo_thresholds(enum omap_plane plane, |
Tomi Valkeinen | 3568f2a | 2012-05-15 15:31:01 +0300 | [diff] [blame] | 1079 | u32 *fifo_low, u32 *fifo_high, bool use_fifomerge, |
| 1080 | bool manual_update) |
Tomi Valkeinen | 83fa2f2 | 2012-01-13 13:17:01 +0200 | [diff] [blame] | 1081 | { |
| 1082 | /* |
| 1083 | * All sizes are in bytes. Both the buffer and burst are made of |
| 1084 | * buffer_units, and the fifo thresholds must be buffer_unit aligned. |
| 1085 | */ |
| 1086 | |
| 1087 | unsigned buf_unit = dss_feat_get_buffer_size_unit(); |
Tomi Valkeinen | e0e405b | 2012-01-13 13:18:11 +0200 | [diff] [blame] | 1088 | unsigned ovl_fifo_size, total_fifo_size, burst_size; |
| 1089 | int i; |
Tomi Valkeinen | 83fa2f2 | 2012-01-13 13:17:01 +0200 | [diff] [blame] | 1090 | |
| 1091 | burst_size = dispc_ovl_get_burst_size(plane); |
Tomi Valkeinen | e0e405b | 2012-01-13 13:18:11 +0200 | [diff] [blame] | 1092 | ovl_fifo_size = dispc_ovl_get_fifo_size(plane); |
Tomi Valkeinen | 83fa2f2 | 2012-01-13 13:17:01 +0200 | [diff] [blame] | 1093 | |
Tomi Valkeinen | e0e405b | 2012-01-13 13:18:11 +0200 | [diff] [blame] | 1094 | if (use_fifomerge) { |
| 1095 | total_fifo_size = 0; |
| 1096 | for (i = 0; i < omap_dss_get_num_overlays(); ++i) |
| 1097 | total_fifo_size += dispc_ovl_get_fifo_size(i); |
| 1098 | } else { |
| 1099 | total_fifo_size = ovl_fifo_size; |
| 1100 | } |
| 1101 | |
| 1102 | /* |
| 1103 | * We use the same low threshold for both fifomerge and non-fifomerge |
| 1104 | * cases, but for fifomerge we calculate the high threshold using the |
| 1105 | * combined fifo size |
| 1106 | */ |
| 1107 | |
Tomi Valkeinen | 3568f2a | 2012-05-15 15:31:01 +0300 | [diff] [blame] | 1108 | if (manual_update && dss_has_feature(FEAT_OMAP3_DSI_FIFO_BUG)) { |
Tomi Valkeinen | e0e405b | 2012-01-13 13:18:11 +0200 | [diff] [blame] | 1109 | *fifo_low = ovl_fifo_size - burst_size * 2; |
| 1110 | *fifo_high = total_fifo_size - burst_size; |
| 1111 | } else { |
| 1112 | *fifo_low = ovl_fifo_size - burst_size; |
| 1113 | *fifo_high = total_fifo_size - buf_unit; |
| 1114 | } |
Tomi Valkeinen | 83fa2f2 | 2012-01-13 13:17:01 +0200 | [diff] [blame] | 1115 | } |
| 1116 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1117 | static void dispc_ovl_set_fir(enum omap_plane plane, |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1118 | int hinc, int vinc, |
| 1119 | enum omap_color_component color_comp) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1120 | { |
| 1121 | u32 val; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1122 | |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1123 | if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y) { |
| 1124 | u8 hinc_start, hinc_end, vinc_start, vinc_end; |
Archit Taneja | a0acb55 | 2010-09-15 19:20:00 +0530 | [diff] [blame] | 1125 | |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1126 | dss_feat_get_reg_field(FEAT_REG_FIRHINC, |
| 1127 | &hinc_start, &hinc_end); |
| 1128 | dss_feat_get_reg_field(FEAT_REG_FIRVINC, |
| 1129 | &vinc_start, &vinc_end); |
| 1130 | val = FLD_VAL(vinc, vinc_start, vinc_end) | |
| 1131 | FLD_VAL(hinc, hinc_start, hinc_end); |
Archit Taneja | a0acb55 | 2010-09-15 19:20:00 +0530 | [diff] [blame] | 1132 | |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1133 | dispc_write_reg(DISPC_OVL_FIR(plane), val); |
| 1134 | } else { |
| 1135 | val = FLD_VAL(vinc, 28, 16) | FLD_VAL(hinc, 12, 0); |
| 1136 | dispc_write_reg(DISPC_OVL_FIR2(plane), val); |
| 1137 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1138 | } |
| 1139 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1140 | static void dispc_ovl_set_vid_accu0(enum omap_plane plane, int haccu, int vaccu) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1141 | { |
| 1142 | u32 val; |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame] | 1143 | u8 hor_start, hor_end, vert_start, vert_end; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1144 | |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame] | 1145 | dss_feat_get_reg_field(FEAT_REG_HORIZONTALACCU, &hor_start, &hor_end); |
| 1146 | dss_feat_get_reg_field(FEAT_REG_VERTICALACCU, &vert_start, &vert_end); |
| 1147 | |
| 1148 | val = FLD_VAL(vaccu, vert_start, vert_end) | |
| 1149 | FLD_VAL(haccu, hor_start, hor_end); |
| 1150 | |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 1151 | dispc_write_reg(DISPC_OVL_ACCU0(plane), val); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1152 | } |
| 1153 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1154 | static void dispc_ovl_set_vid_accu1(enum omap_plane plane, int haccu, int vaccu) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1155 | { |
| 1156 | u32 val; |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame] | 1157 | u8 hor_start, hor_end, vert_start, vert_end; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1158 | |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame] | 1159 | dss_feat_get_reg_field(FEAT_REG_HORIZONTALACCU, &hor_start, &hor_end); |
| 1160 | dss_feat_get_reg_field(FEAT_REG_VERTICALACCU, &vert_start, &vert_end); |
| 1161 | |
| 1162 | val = FLD_VAL(vaccu, vert_start, vert_end) | |
| 1163 | FLD_VAL(haccu, hor_start, hor_end); |
| 1164 | |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 1165 | dispc_write_reg(DISPC_OVL_ACCU1(plane), val); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1166 | } |
| 1167 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1168 | static void dispc_ovl_set_vid_accu2_0(enum omap_plane plane, int haccu, |
| 1169 | int vaccu) |
Amber Jain | ab5ca07 | 2011-05-19 19:47:53 +0530 | [diff] [blame] | 1170 | { |
| 1171 | u32 val; |
| 1172 | |
| 1173 | val = FLD_VAL(vaccu, 26, 16) | FLD_VAL(haccu, 10, 0); |
| 1174 | dispc_write_reg(DISPC_OVL_ACCU2_0(plane), val); |
| 1175 | } |
| 1176 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1177 | static void dispc_ovl_set_vid_accu2_1(enum omap_plane plane, int haccu, |
| 1178 | int vaccu) |
Amber Jain | ab5ca07 | 2011-05-19 19:47:53 +0530 | [diff] [blame] | 1179 | { |
| 1180 | u32 val; |
| 1181 | |
| 1182 | val = FLD_VAL(vaccu, 26, 16) | FLD_VAL(haccu, 10, 0); |
| 1183 | dispc_write_reg(DISPC_OVL_ACCU2_1(plane), val); |
| 1184 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1185 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1186 | static void dispc_ovl_set_scale_param(enum omap_plane plane, |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1187 | u16 orig_width, u16 orig_height, |
| 1188 | u16 out_width, u16 out_height, |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1189 | bool five_taps, u8 rotation, |
| 1190 | enum omap_color_component color_comp) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1191 | { |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1192 | int fir_hinc, fir_vinc; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1193 | |
Amber Jain | ed14a3c | 2011-05-19 19:47:51 +0530 | [diff] [blame] | 1194 | fir_hinc = 1024 * orig_width / out_width; |
| 1195 | fir_vinc = 1024 * orig_height / out_height; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1196 | |
Chandrabhanu Mahapatra | debd907 | 2011-12-19 14:03:44 +0530 | [diff] [blame] | 1197 | dispc_ovl_set_scale_coef(plane, fir_hinc, fir_vinc, five_taps, |
| 1198 | color_comp); |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1199 | dispc_ovl_set_fir(plane, fir_hinc, fir_vinc, color_comp); |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1200 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1201 | |
Chandrabhanu Mahapatra | 05dd0f5 | 2012-05-15 12:22:34 +0530 | [diff] [blame] | 1202 | static void dispc_ovl_set_accu_uv(enum omap_plane plane, |
| 1203 | u16 orig_width, u16 orig_height, u16 out_width, u16 out_height, |
| 1204 | bool ilace, enum omap_color_mode color_mode, u8 rotation) |
| 1205 | { |
| 1206 | int h_accu2_0, h_accu2_1; |
| 1207 | int v_accu2_0, v_accu2_1; |
| 1208 | int chroma_hinc, chroma_vinc; |
| 1209 | int idx; |
| 1210 | |
| 1211 | struct accu { |
| 1212 | s8 h0_m, h0_n; |
| 1213 | s8 h1_m, h1_n; |
| 1214 | s8 v0_m, v0_n; |
| 1215 | s8 v1_m, v1_n; |
| 1216 | }; |
| 1217 | |
| 1218 | const struct accu *accu_table; |
| 1219 | const struct accu *accu_val; |
| 1220 | |
| 1221 | static const struct accu accu_nv12[4] = { |
| 1222 | { 0, 1, 0, 1 , -1, 2, 0, 1 }, |
| 1223 | { 1, 2, -3, 4 , 0, 1, 0, 1 }, |
| 1224 | { -1, 1, 0, 1 , -1, 2, 0, 1 }, |
| 1225 | { -1, 2, -1, 2 , -1, 1, 0, 1 }, |
| 1226 | }; |
| 1227 | |
| 1228 | static const struct accu accu_nv12_ilace[4] = { |
| 1229 | { 0, 1, 0, 1 , -3, 4, -1, 4 }, |
| 1230 | { -1, 4, -3, 4 , 0, 1, 0, 1 }, |
| 1231 | { -1, 1, 0, 1 , -1, 4, -3, 4 }, |
| 1232 | { -3, 4, -3, 4 , -1, 1, 0, 1 }, |
| 1233 | }; |
| 1234 | |
| 1235 | static const struct accu accu_yuv[4] = { |
| 1236 | { 0, 1, 0, 1, 0, 1, 0, 1 }, |
| 1237 | { 0, 1, 0, 1, 0, 1, 0, 1 }, |
| 1238 | { -1, 1, 0, 1, 0, 1, 0, 1 }, |
| 1239 | { 0, 1, 0, 1, -1, 1, 0, 1 }, |
| 1240 | }; |
| 1241 | |
| 1242 | switch (rotation) { |
| 1243 | case OMAP_DSS_ROT_0: |
| 1244 | idx = 0; |
| 1245 | break; |
| 1246 | case OMAP_DSS_ROT_90: |
| 1247 | idx = 1; |
| 1248 | break; |
| 1249 | case OMAP_DSS_ROT_180: |
| 1250 | idx = 2; |
| 1251 | break; |
| 1252 | case OMAP_DSS_ROT_270: |
| 1253 | idx = 3; |
| 1254 | break; |
| 1255 | default: |
| 1256 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 1257 | return; |
Chandrabhanu Mahapatra | 05dd0f5 | 2012-05-15 12:22:34 +0530 | [diff] [blame] | 1258 | } |
| 1259 | |
| 1260 | switch (color_mode) { |
| 1261 | case OMAP_DSS_COLOR_NV12: |
| 1262 | if (ilace) |
| 1263 | accu_table = accu_nv12_ilace; |
| 1264 | else |
| 1265 | accu_table = accu_nv12; |
| 1266 | break; |
| 1267 | case OMAP_DSS_COLOR_YUV2: |
| 1268 | case OMAP_DSS_COLOR_UYVY: |
| 1269 | accu_table = accu_yuv; |
| 1270 | break; |
| 1271 | default: |
| 1272 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 1273 | return; |
Chandrabhanu Mahapatra | 05dd0f5 | 2012-05-15 12:22:34 +0530 | [diff] [blame] | 1274 | } |
| 1275 | |
| 1276 | accu_val = &accu_table[idx]; |
| 1277 | |
| 1278 | chroma_hinc = 1024 * orig_width / out_width; |
| 1279 | chroma_vinc = 1024 * orig_height / out_height; |
| 1280 | |
| 1281 | h_accu2_0 = (accu_val->h0_m * chroma_hinc / accu_val->h0_n) % 1024; |
| 1282 | h_accu2_1 = (accu_val->h1_m * chroma_hinc / accu_val->h1_n) % 1024; |
| 1283 | v_accu2_0 = (accu_val->v0_m * chroma_vinc / accu_val->v0_n) % 1024; |
| 1284 | v_accu2_1 = (accu_val->v1_m * chroma_vinc / accu_val->v1_n) % 1024; |
| 1285 | |
| 1286 | dispc_ovl_set_vid_accu2_0(plane, h_accu2_0, v_accu2_0); |
| 1287 | dispc_ovl_set_vid_accu2_1(plane, h_accu2_1, v_accu2_1); |
| 1288 | } |
| 1289 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1290 | static void dispc_ovl_set_scaling_common(enum omap_plane plane, |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1291 | u16 orig_width, u16 orig_height, |
| 1292 | u16 out_width, u16 out_height, |
| 1293 | bool ilace, bool five_taps, |
| 1294 | bool fieldmode, enum omap_color_mode color_mode, |
| 1295 | u8 rotation) |
| 1296 | { |
| 1297 | int accu0 = 0; |
| 1298 | int accu1 = 0; |
| 1299 | u32 l; |
| 1300 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1301 | dispc_ovl_set_scale_param(plane, orig_width, orig_height, |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1302 | out_width, out_height, five_taps, |
| 1303 | rotation, DISPC_COLOR_COMPONENT_RGB_Y); |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 1304 | l = dispc_read_reg(DISPC_OVL_ATTRIBUTES(plane)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1305 | |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame] | 1306 | /* RESIZEENABLE and VERTICALTAPS */ |
| 1307 | l &= ~((0x3 << 5) | (0x1 << 21)); |
Amber Jain | ed14a3c | 2011-05-19 19:47:51 +0530 | [diff] [blame] | 1308 | l |= (orig_width != out_width) ? (1 << 5) : 0; |
| 1309 | l |= (orig_height != out_height) ? (1 << 6) : 0; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1310 | l |= five_taps ? (1 << 21) : 0; |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame] | 1311 | |
| 1312 | /* VRESIZECONF and HRESIZECONF */ |
| 1313 | if (dss_has_feature(FEAT_RESIZECONF)) { |
| 1314 | l &= ~(0x3 << 7); |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1315 | l |= (orig_width <= out_width) ? 0 : (1 << 7); |
| 1316 | l |= (orig_height <= out_height) ? 0 : (1 << 8); |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame] | 1317 | } |
| 1318 | |
| 1319 | /* LINEBUFFERSPLIT */ |
| 1320 | if (dss_has_feature(FEAT_LINEBUFFERSPLIT)) { |
| 1321 | l &= ~(0x1 << 22); |
| 1322 | l |= five_taps ? (1 << 22) : 0; |
| 1323 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1324 | |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 1325 | dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), l); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1326 | |
| 1327 | /* |
| 1328 | * field 0 = even field = bottom field |
| 1329 | * field 1 = odd field = top field |
| 1330 | */ |
| 1331 | if (ilace && !fieldmode) { |
| 1332 | accu1 = 0; |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1333 | accu0 = ((1024 * orig_height / out_height) / 2) & 0x3ff; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1334 | if (accu0 >= 1024/2) { |
| 1335 | accu1 = 1024/2; |
| 1336 | accu0 -= accu1; |
| 1337 | } |
| 1338 | } |
| 1339 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1340 | dispc_ovl_set_vid_accu0(plane, 0, accu0); |
| 1341 | dispc_ovl_set_vid_accu1(plane, 0, accu1); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1342 | } |
| 1343 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1344 | static void dispc_ovl_set_scaling_uv(enum omap_plane plane, |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1345 | u16 orig_width, u16 orig_height, |
| 1346 | u16 out_width, u16 out_height, |
| 1347 | bool ilace, bool five_taps, |
| 1348 | bool fieldmode, enum omap_color_mode color_mode, |
| 1349 | u8 rotation) |
| 1350 | { |
| 1351 | int scale_x = out_width != orig_width; |
| 1352 | int scale_y = out_height != orig_height; |
| 1353 | |
| 1354 | if (!dss_has_feature(FEAT_HANDLE_UV_SEPARATE)) |
| 1355 | return; |
| 1356 | if ((color_mode != OMAP_DSS_COLOR_YUV2 && |
| 1357 | color_mode != OMAP_DSS_COLOR_UYVY && |
| 1358 | color_mode != OMAP_DSS_COLOR_NV12)) { |
| 1359 | /* reset chroma resampling for RGB formats */ |
| 1360 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane), 0, 8, 8); |
| 1361 | return; |
| 1362 | } |
Tomi Valkeinen | 3637735 | 2012-05-15 15:54:15 +0300 | [diff] [blame] | 1363 | |
| 1364 | dispc_ovl_set_accu_uv(plane, orig_width, orig_height, out_width, |
| 1365 | out_height, ilace, color_mode, rotation); |
| 1366 | |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1367 | switch (color_mode) { |
| 1368 | case OMAP_DSS_COLOR_NV12: |
| 1369 | /* UV is subsampled by 2 vertically*/ |
| 1370 | orig_height >>= 1; |
| 1371 | /* UV is subsampled by 2 horz.*/ |
| 1372 | orig_width >>= 1; |
| 1373 | break; |
| 1374 | case OMAP_DSS_COLOR_YUV2: |
| 1375 | case OMAP_DSS_COLOR_UYVY: |
| 1376 | /*For YUV422 with 90/270 rotation, |
| 1377 | *we don't upsample chroma |
| 1378 | */ |
| 1379 | if (rotation == OMAP_DSS_ROT_0 || |
| 1380 | rotation == OMAP_DSS_ROT_180) |
| 1381 | /* UV is subsampled by 2 hrz*/ |
| 1382 | orig_width >>= 1; |
| 1383 | /* must use FIR for YUV422 if rotated */ |
| 1384 | if (rotation != OMAP_DSS_ROT_0) |
| 1385 | scale_x = scale_y = true; |
| 1386 | break; |
| 1387 | default: |
| 1388 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 1389 | return; |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1390 | } |
| 1391 | |
| 1392 | if (out_width != orig_width) |
| 1393 | scale_x = true; |
| 1394 | if (out_height != orig_height) |
| 1395 | scale_y = true; |
| 1396 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1397 | dispc_ovl_set_scale_param(plane, orig_width, orig_height, |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1398 | out_width, out_height, five_taps, |
| 1399 | rotation, DISPC_COLOR_COMPONENT_UV); |
| 1400 | |
| 1401 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane), |
| 1402 | (scale_x || scale_y) ? 1 : 0, 8, 8); |
| 1403 | /* set H scaling */ |
| 1404 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), scale_x ? 1 : 0, 5, 5); |
| 1405 | /* set V scaling */ |
| 1406 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), scale_y ? 1 : 0, 6, 6); |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1407 | } |
| 1408 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1409 | static void dispc_ovl_set_scaling(enum omap_plane plane, |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1410 | u16 orig_width, u16 orig_height, |
| 1411 | u16 out_width, u16 out_height, |
| 1412 | bool ilace, bool five_taps, |
| 1413 | bool fieldmode, enum omap_color_mode color_mode, |
| 1414 | u8 rotation) |
| 1415 | { |
| 1416 | BUG_ON(plane == OMAP_DSS_GFX); |
| 1417 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1418 | dispc_ovl_set_scaling_common(plane, |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1419 | orig_width, orig_height, |
| 1420 | out_width, out_height, |
| 1421 | ilace, five_taps, |
| 1422 | fieldmode, color_mode, |
| 1423 | rotation); |
| 1424 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1425 | dispc_ovl_set_scaling_uv(plane, |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 1426 | orig_width, orig_height, |
| 1427 | out_width, out_height, |
| 1428 | ilace, five_taps, |
| 1429 | fieldmode, color_mode, |
| 1430 | rotation); |
| 1431 | } |
| 1432 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 1433 | static void dispc_ovl_set_rotation_attrs(enum omap_plane plane, u8 rotation, |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1434 | bool mirroring, enum omap_color_mode color_mode) |
| 1435 | { |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame] | 1436 | bool row_repeat = false; |
| 1437 | int vidrot = 0; |
| 1438 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1439 | if (color_mode == OMAP_DSS_COLOR_YUV2 || |
| 1440 | color_mode == OMAP_DSS_COLOR_UYVY) { |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1441 | |
| 1442 | if (mirroring) { |
| 1443 | switch (rotation) { |
| 1444 | case OMAP_DSS_ROT_0: |
| 1445 | vidrot = 2; |
| 1446 | break; |
| 1447 | case OMAP_DSS_ROT_90: |
| 1448 | vidrot = 1; |
| 1449 | break; |
| 1450 | case OMAP_DSS_ROT_180: |
| 1451 | vidrot = 0; |
| 1452 | break; |
| 1453 | case OMAP_DSS_ROT_270: |
| 1454 | vidrot = 3; |
| 1455 | break; |
| 1456 | } |
| 1457 | } else { |
| 1458 | switch (rotation) { |
| 1459 | case OMAP_DSS_ROT_0: |
| 1460 | vidrot = 0; |
| 1461 | break; |
| 1462 | case OMAP_DSS_ROT_90: |
| 1463 | vidrot = 1; |
| 1464 | break; |
| 1465 | case OMAP_DSS_ROT_180: |
| 1466 | vidrot = 2; |
| 1467 | break; |
| 1468 | case OMAP_DSS_ROT_270: |
| 1469 | vidrot = 3; |
| 1470 | break; |
| 1471 | } |
| 1472 | } |
| 1473 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1474 | if (rotation == OMAP_DSS_ROT_90 || rotation == OMAP_DSS_ROT_270) |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame] | 1475 | row_repeat = true; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1476 | else |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame] | 1477 | row_repeat = false; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1478 | } |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame] | 1479 | |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 1480 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), vidrot, 13, 12); |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame] | 1481 | if (dss_has_feature(FEAT_ROWREPEATENABLE)) |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 1482 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), |
| 1483 | row_repeat ? 1 : 0, 18, 18); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1484 | } |
| 1485 | |
| 1486 | static int color_mode_to_bpp(enum omap_color_mode color_mode) |
| 1487 | { |
| 1488 | switch (color_mode) { |
| 1489 | case OMAP_DSS_COLOR_CLUT1: |
| 1490 | return 1; |
| 1491 | case OMAP_DSS_COLOR_CLUT2: |
| 1492 | return 2; |
| 1493 | case OMAP_DSS_COLOR_CLUT4: |
| 1494 | return 4; |
| 1495 | case OMAP_DSS_COLOR_CLUT8: |
Amber Jain | f20e422 | 2011-05-19 19:47:50 +0530 | [diff] [blame] | 1496 | case OMAP_DSS_COLOR_NV12: |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1497 | return 8; |
| 1498 | case OMAP_DSS_COLOR_RGB12U: |
| 1499 | case OMAP_DSS_COLOR_RGB16: |
| 1500 | case OMAP_DSS_COLOR_ARGB16: |
| 1501 | case OMAP_DSS_COLOR_YUV2: |
| 1502 | case OMAP_DSS_COLOR_UYVY: |
Amber Jain | f20e422 | 2011-05-19 19:47:50 +0530 | [diff] [blame] | 1503 | case OMAP_DSS_COLOR_RGBA16: |
| 1504 | case OMAP_DSS_COLOR_RGBX16: |
| 1505 | case OMAP_DSS_COLOR_ARGB16_1555: |
| 1506 | case OMAP_DSS_COLOR_XRGB16_1555: |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1507 | return 16; |
| 1508 | case OMAP_DSS_COLOR_RGB24P: |
| 1509 | return 24; |
| 1510 | case OMAP_DSS_COLOR_RGB24U: |
| 1511 | case OMAP_DSS_COLOR_ARGB32: |
| 1512 | case OMAP_DSS_COLOR_RGBA32: |
| 1513 | case OMAP_DSS_COLOR_RGBX32: |
| 1514 | return 32; |
| 1515 | default: |
| 1516 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 1517 | return 0; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1518 | } |
| 1519 | } |
| 1520 | |
| 1521 | static s32 pixinc(int pixels, u8 ps) |
| 1522 | { |
| 1523 | if (pixels == 1) |
| 1524 | return 1; |
| 1525 | else if (pixels > 1) |
| 1526 | return 1 + (pixels - 1) * ps; |
| 1527 | else if (pixels < 0) |
| 1528 | return 1 - (-pixels + 1) * ps; |
| 1529 | else |
| 1530 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 1531 | return 0; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1532 | } |
| 1533 | |
| 1534 | static void calc_vrfb_rotation_offset(u8 rotation, bool mirror, |
| 1535 | u16 screen_width, |
| 1536 | u16 width, u16 height, |
| 1537 | enum omap_color_mode color_mode, bool fieldmode, |
| 1538 | unsigned int field_offset, |
| 1539 | unsigned *offset0, unsigned *offset1, |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1540 | s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1541 | { |
| 1542 | u8 ps; |
| 1543 | |
| 1544 | /* FIXME CLUT formats */ |
| 1545 | switch (color_mode) { |
| 1546 | case OMAP_DSS_COLOR_CLUT1: |
| 1547 | case OMAP_DSS_COLOR_CLUT2: |
| 1548 | case OMAP_DSS_COLOR_CLUT4: |
| 1549 | case OMAP_DSS_COLOR_CLUT8: |
| 1550 | BUG(); |
| 1551 | return; |
| 1552 | case OMAP_DSS_COLOR_YUV2: |
| 1553 | case OMAP_DSS_COLOR_UYVY: |
| 1554 | ps = 4; |
| 1555 | break; |
| 1556 | default: |
| 1557 | ps = color_mode_to_bpp(color_mode) / 8; |
| 1558 | break; |
| 1559 | } |
| 1560 | |
| 1561 | DSSDBG("calc_rot(%d): scrw %d, %dx%d\n", rotation, screen_width, |
| 1562 | width, height); |
| 1563 | |
| 1564 | /* |
| 1565 | * field 0 = even field = bottom field |
| 1566 | * field 1 = odd field = top field |
| 1567 | */ |
| 1568 | switch (rotation + mirror * 4) { |
| 1569 | case OMAP_DSS_ROT_0: |
| 1570 | case OMAP_DSS_ROT_180: |
| 1571 | /* |
| 1572 | * If the pixel format is YUV or UYVY divide the width |
| 1573 | * of the image by 2 for 0 and 180 degree rotation. |
| 1574 | */ |
| 1575 | if (color_mode == OMAP_DSS_COLOR_YUV2 || |
| 1576 | color_mode == OMAP_DSS_COLOR_UYVY) |
| 1577 | width = width >> 1; |
| 1578 | case OMAP_DSS_ROT_90: |
| 1579 | case OMAP_DSS_ROT_270: |
| 1580 | *offset1 = 0; |
| 1581 | if (field_offset) |
| 1582 | *offset0 = field_offset * screen_width * ps; |
| 1583 | else |
| 1584 | *offset0 = 0; |
| 1585 | |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1586 | *row_inc = pixinc(1 + |
| 1587 | (y_predecim * screen_width - x_predecim * width) + |
| 1588 | (fieldmode ? screen_width : 0), ps); |
| 1589 | *pix_inc = pixinc(x_predecim, ps); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1590 | break; |
| 1591 | |
| 1592 | case OMAP_DSS_ROT_0 + 4: |
| 1593 | case OMAP_DSS_ROT_180 + 4: |
| 1594 | /* If the pixel format is YUV or UYVY divide the width |
| 1595 | * of the image by 2 for 0 degree and 180 degree |
| 1596 | */ |
| 1597 | if (color_mode == OMAP_DSS_COLOR_YUV2 || |
| 1598 | color_mode == OMAP_DSS_COLOR_UYVY) |
| 1599 | width = width >> 1; |
| 1600 | case OMAP_DSS_ROT_90 + 4: |
| 1601 | case OMAP_DSS_ROT_270 + 4: |
| 1602 | *offset1 = 0; |
| 1603 | if (field_offset) |
| 1604 | *offset0 = field_offset * screen_width * ps; |
| 1605 | else |
| 1606 | *offset0 = 0; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1607 | *row_inc = pixinc(1 - |
| 1608 | (y_predecim * screen_width + x_predecim * width) - |
| 1609 | (fieldmode ? screen_width : 0), ps); |
| 1610 | *pix_inc = pixinc(x_predecim, ps); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1611 | break; |
| 1612 | |
| 1613 | default: |
| 1614 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 1615 | return; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1616 | } |
| 1617 | } |
| 1618 | |
| 1619 | static void calc_dma_rotation_offset(u8 rotation, bool mirror, |
| 1620 | u16 screen_width, |
| 1621 | u16 width, u16 height, |
| 1622 | enum omap_color_mode color_mode, bool fieldmode, |
| 1623 | unsigned int field_offset, |
| 1624 | unsigned *offset0, unsigned *offset1, |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1625 | s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1626 | { |
| 1627 | u8 ps; |
| 1628 | u16 fbw, fbh; |
| 1629 | |
| 1630 | /* FIXME CLUT formats */ |
| 1631 | switch (color_mode) { |
| 1632 | case OMAP_DSS_COLOR_CLUT1: |
| 1633 | case OMAP_DSS_COLOR_CLUT2: |
| 1634 | case OMAP_DSS_COLOR_CLUT4: |
| 1635 | case OMAP_DSS_COLOR_CLUT8: |
| 1636 | BUG(); |
| 1637 | return; |
| 1638 | default: |
| 1639 | ps = color_mode_to_bpp(color_mode) / 8; |
| 1640 | break; |
| 1641 | } |
| 1642 | |
| 1643 | DSSDBG("calc_rot(%d): scrw %d, %dx%d\n", rotation, screen_width, |
| 1644 | width, height); |
| 1645 | |
| 1646 | /* width & height are overlay sizes, convert to fb sizes */ |
| 1647 | |
| 1648 | if (rotation == OMAP_DSS_ROT_0 || rotation == OMAP_DSS_ROT_180) { |
| 1649 | fbw = width; |
| 1650 | fbh = height; |
| 1651 | } else { |
| 1652 | fbw = height; |
| 1653 | fbh = width; |
| 1654 | } |
| 1655 | |
| 1656 | /* |
| 1657 | * field 0 = even field = bottom field |
| 1658 | * field 1 = odd field = top field |
| 1659 | */ |
| 1660 | switch (rotation + mirror * 4) { |
| 1661 | case OMAP_DSS_ROT_0: |
| 1662 | *offset1 = 0; |
| 1663 | if (field_offset) |
| 1664 | *offset0 = *offset1 + field_offset * screen_width * ps; |
| 1665 | else |
| 1666 | *offset0 = *offset1; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1667 | *row_inc = pixinc(1 + |
| 1668 | (y_predecim * screen_width - fbw * x_predecim) + |
| 1669 | (fieldmode ? screen_width : 0), ps); |
| 1670 | if (color_mode == OMAP_DSS_COLOR_YUV2 || |
| 1671 | color_mode == OMAP_DSS_COLOR_UYVY) |
| 1672 | *pix_inc = pixinc(x_predecim, 2 * ps); |
| 1673 | else |
| 1674 | *pix_inc = pixinc(x_predecim, ps); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1675 | break; |
| 1676 | case OMAP_DSS_ROT_90: |
| 1677 | *offset1 = screen_width * (fbh - 1) * ps; |
| 1678 | if (field_offset) |
| 1679 | *offset0 = *offset1 + field_offset * ps; |
| 1680 | else |
| 1681 | *offset0 = *offset1; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1682 | *row_inc = pixinc(screen_width * (fbh * x_predecim - 1) + |
| 1683 | y_predecim + (fieldmode ? 1 : 0), ps); |
| 1684 | *pix_inc = pixinc(-x_predecim * screen_width, ps); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1685 | break; |
| 1686 | case OMAP_DSS_ROT_180: |
| 1687 | *offset1 = (screen_width * (fbh - 1) + fbw - 1) * ps; |
| 1688 | if (field_offset) |
| 1689 | *offset0 = *offset1 - field_offset * screen_width * ps; |
| 1690 | else |
| 1691 | *offset0 = *offset1; |
| 1692 | *row_inc = pixinc(-1 - |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1693 | (y_predecim * screen_width - fbw * x_predecim) - |
| 1694 | (fieldmode ? screen_width : 0), ps); |
| 1695 | if (color_mode == OMAP_DSS_COLOR_YUV2 || |
| 1696 | color_mode == OMAP_DSS_COLOR_UYVY) |
| 1697 | *pix_inc = pixinc(-x_predecim, 2 * ps); |
| 1698 | else |
| 1699 | *pix_inc = pixinc(-x_predecim, ps); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1700 | break; |
| 1701 | case OMAP_DSS_ROT_270: |
| 1702 | *offset1 = (fbw - 1) * ps; |
| 1703 | if (field_offset) |
| 1704 | *offset0 = *offset1 - field_offset * ps; |
| 1705 | else |
| 1706 | *offset0 = *offset1; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1707 | *row_inc = pixinc(-screen_width * (fbh * x_predecim - 1) - |
| 1708 | y_predecim - (fieldmode ? 1 : 0), ps); |
| 1709 | *pix_inc = pixinc(x_predecim * screen_width, ps); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1710 | break; |
| 1711 | |
| 1712 | /* mirroring */ |
| 1713 | case OMAP_DSS_ROT_0 + 4: |
| 1714 | *offset1 = (fbw - 1) * ps; |
| 1715 | if (field_offset) |
| 1716 | *offset0 = *offset1 + field_offset * screen_width * ps; |
| 1717 | else |
| 1718 | *offset0 = *offset1; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1719 | *row_inc = pixinc(y_predecim * screen_width * 2 - 1 + |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1720 | (fieldmode ? screen_width : 0), |
| 1721 | ps); |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1722 | if (color_mode == OMAP_DSS_COLOR_YUV2 || |
| 1723 | color_mode == OMAP_DSS_COLOR_UYVY) |
| 1724 | *pix_inc = pixinc(-x_predecim, 2 * ps); |
| 1725 | else |
| 1726 | *pix_inc = pixinc(-x_predecim, ps); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1727 | break; |
| 1728 | |
| 1729 | case OMAP_DSS_ROT_90 + 4: |
| 1730 | *offset1 = 0; |
| 1731 | if (field_offset) |
| 1732 | *offset0 = *offset1 + field_offset * ps; |
| 1733 | else |
| 1734 | *offset0 = *offset1; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1735 | *row_inc = pixinc(-screen_width * (fbh * x_predecim - 1) + |
| 1736 | y_predecim + (fieldmode ? 1 : 0), |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1737 | ps); |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1738 | *pix_inc = pixinc(x_predecim * screen_width, ps); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1739 | break; |
| 1740 | |
| 1741 | case OMAP_DSS_ROT_180 + 4: |
| 1742 | *offset1 = screen_width * (fbh - 1) * ps; |
| 1743 | if (field_offset) |
| 1744 | *offset0 = *offset1 - field_offset * screen_width * ps; |
| 1745 | else |
| 1746 | *offset0 = *offset1; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1747 | *row_inc = pixinc(1 - y_predecim * screen_width * 2 - |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1748 | (fieldmode ? screen_width : 0), |
| 1749 | ps); |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1750 | if (color_mode == OMAP_DSS_COLOR_YUV2 || |
| 1751 | color_mode == OMAP_DSS_COLOR_UYVY) |
| 1752 | *pix_inc = pixinc(x_predecim, 2 * ps); |
| 1753 | else |
| 1754 | *pix_inc = pixinc(x_predecim, ps); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1755 | break; |
| 1756 | |
| 1757 | case OMAP_DSS_ROT_270 + 4: |
| 1758 | *offset1 = (screen_width * (fbh - 1) + fbw - 1) * ps; |
| 1759 | if (field_offset) |
| 1760 | *offset0 = *offset1 - field_offset * ps; |
| 1761 | else |
| 1762 | *offset0 = *offset1; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1763 | *row_inc = pixinc(screen_width * (fbh * x_predecim - 1) - |
| 1764 | y_predecim - (fieldmode ? 1 : 0), |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1765 | ps); |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1766 | *pix_inc = pixinc(-x_predecim * screen_width, ps); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1767 | break; |
| 1768 | |
| 1769 | default: |
| 1770 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 1771 | return; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1772 | } |
| 1773 | } |
| 1774 | |
Chandrabhanu Mahapatra | 65e006f | 2012-05-11 19:19:55 +0530 | [diff] [blame] | 1775 | static void calc_tiler_rotation_offset(u16 screen_width, u16 width, |
| 1776 | enum omap_color_mode color_mode, bool fieldmode, |
| 1777 | unsigned int field_offset, unsigned *offset0, unsigned *offset1, |
| 1778 | s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim) |
| 1779 | { |
| 1780 | u8 ps; |
| 1781 | |
| 1782 | switch (color_mode) { |
| 1783 | case OMAP_DSS_COLOR_CLUT1: |
| 1784 | case OMAP_DSS_COLOR_CLUT2: |
| 1785 | case OMAP_DSS_COLOR_CLUT4: |
| 1786 | case OMAP_DSS_COLOR_CLUT8: |
| 1787 | BUG(); |
| 1788 | return; |
| 1789 | default: |
| 1790 | ps = color_mode_to_bpp(color_mode) / 8; |
| 1791 | break; |
| 1792 | } |
| 1793 | |
| 1794 | DSSDBG("scrw %d, width %d\n", screen_width, width); |
| 1795 | |
| 1796 | /* |
| 1797 | * field 0 = even field = bottom field |
| 1798 | * field 1 = odd field = top field |
| 1799 | */ |
| 1800 | *offset1 = 0; |
| 1801 | if (field_offset) |
| 1802 | *offset0 = *offset1 + field_offset * screen_width * ps; |
| 1803 | else |
| 1804 | *offset0 = *offset1; |
| 1805 | *row_inc = pixinc(1 + (y_predecim * screen_width - width * x_predecim) + |
| 1806 | (fieldmode ? screen_width : 0), ps); |
| 1807 | if (color_mode == OMAP_DSS_COLOR_YUV2 || |
| 1808 | color_mode == OMAP_DSS_COLOR_UYVY) |
| 1809 | *pix_inc = pixinc(x_predecim, 2 * ps); |
| 1810 | else |
| 1811 | *pix_inc = pixinc(x_predecim, ps); |
| 1812 | } |
| 1813 | |
Chandrabhanu Mahapatra | 7faa923 | 2012-04-02 20:43:17 +0530 | [diff] [blame] | 1814 | /* |
| 1815 | * This function is used to avoid synclosts in OMAP3, because of some |
| 1816 | * undocumented horizontal position and timing related limitations. |
| 1817 | */ |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 1818 | static int check_horiz_timing_omap3(enum omap_channel channel, |
| 1819 | const struct omap_video_timings *t, u16 pos_x, |
Chandrabhanu Mahapatra | 7faa923 | 2012-04-02 20:43:17 +0530 | [diff] [blame] | 1820 | u16 width, u16 height, u16 out_width, u16 out_height) |
| 1821 | { |
| 1822 | int DS = DIV_ROUND_UP(height, out_height); |
Chandrabhanu Mahapatra | 7faa923 | 2012-04-02 20:43:17 +0530 | [diff] [blame] | 1823 | unsigned long nonactive, lclk, pclk; |
| 1824 | static const u8 limits[3] = { 8, 10, 20 }; |
| 1825 | u64 val, blank; |
| 1826 | int i; |
| 1827 | |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 1828 | nonactive = t->x_res + t->hfp + t->hsw + t->hbp - out_width; |
Chandrabhanu Mahapatra | 7faa923 | 2012-04-02 20:43:17 +0530 | [diff] [blame] | 1829 | pclk = dispc_mgr_pclk_rate(channel); |
| 1830 | if (dispc_mgr_is_lcd(channel)) |
| 1831 | lclk = dispc_mgr_lclk_rate(channel); |
| 1832 | else |
| 1833 | lclk = dispc_fclk_rate(); |
| 1834 | |
| 1835 | i = 0; |
| 1836 | if (out_height < height) |
| 1837 | i++; |
| 1838 | if (out_width < width) |
| 1839 | i++; |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 1840 | blank = div_u64((u64)(t->hbp + t->hsw + t->hfp) * lclk, pclk); |
Chandrabhanu Mahapatra | 7faa923 | 2012-04-02 20:43:17 +0530 | [diff] [blame] | 1841 | DSSDBG("blanking period + ppl = %llu (limit = %u)\n", blank, limits[i]); |
| 1842 | if (blank <= limits[i]) |
| 1843 | return -EINVAL; |
| 1844 | |
| 1845 | /* |
| 1846 | * Pixel data should be prepared before visible display point starts. |
| 1847 | * So, atleast DS-2 lines must have already been fetched by DISPC |
| 1848 | * during nonactive - pos_x period. |
| 1849 | */ |
| 1850 | val = div_u64((u64)(nonactive - pos_x) * lclk, pclk); |
| 1851 | DSSDBG("(nonactive - pos_x) * pcd = %llu max(0, DS - 2) * width = %d\n", |
| 1852 | val, max(0, DS - 2) * width); |
| 1853 | if (val < max(0, DS - 2) * width) |
| 1854 | return -EINVAL; |
| 1855 | |
| 1856 | /* |
| 1857 | * All lines need to be refilled during the nonactive period of which |
| 1858 | * only one line can be loaded during the active period. So, atleast |
| 1859 | * DS - 1 lines should be loaded during nonactive period. |
| 1860 | */ |
| 1861 | val = div_u64((u64)nonactive * lclk, pclk); |
| 1862 | DSSDBG("nonactive * pcd = %llu, max(0, DS - 1) * width = %d\n", |
| 1863 | val, max(0, DS - 1) * width); |
| 1864 | if (val < max(0, DS - 1) * width) |
| 1865 | return -EINVAL; |
| 1866 | |
| 1867 | return 0; |
| 1868 | } |
| 1869 | |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 1870 | static unsigned long calc_core_clk_five_taps(enum omap_channel channel, |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 1871 | const struct omap_video_timings *mgr_timings, u16 width, |
| 1872 | u16 height, u16 out_width, u16 out_height, |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 1873 | enum omap_color_mode color_mode) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1874 | { |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 1875 | u32 core_clk = 0; |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 1876 | u64 tmp, pclk = dispc_mgr_pclk_rate(channel); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1877 | |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 1878 | if (height <= out_height && width <= out_width) |
| 1879 | return (unsigned long) pclk; |
| 1880 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1881 | if (height > out_height) { |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 1882 | unsigned int ppl = mgr_timings->x_res; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1883 | |
| 1884 | tmp = pclk * height * out_width; |
| 1885 | do_div(tmp, 2 * out_height * ppl); |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 1886 | core_clk = tmp; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1887 | |
Ville Syrjälä | 2d9c559 | 2010-01-08 11:56:41 +0200 | [diff] [blame] | 1888 | if (height > 2 * out_height) { |
| 1889 | if (ppl == out_width) |
| 1890 | return 0; |
| 1891 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1892 | tmp = pclk * (height - 2 * out_height) * out_width; |
| 1893 | do_div(tmp, 2 * out_height * (ppl - out_width)); |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 1894 | core_clk = max_t(u32, core_clk, tmp); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1895 | } |
| 1896 | } |
| 1897 | |
| 1898 | if (width > out_width) { |
| 1899 | tmp = pclk * width; |
| 1900 | do_div(tmp, out_width); |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 1901 | core_clk = max_t(u32, core_clk, tmp); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1902 | |
| 1903 | if (color_mode == OMAP_DSS_COLOR_RGB24U) |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 1904 | core_clk <<= 1; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1905 | } |
| 1906 | |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 1907 | return core_clk; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1908 | } |
| 1909 | |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 1910 | static unsigned long calc_core_clk(enum omap_channel channel, u16 width, |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 1911 | u16 height, u16 out_width, u16 out_height) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1912 | { |
| 1913 | unsigned int hf, vf; |
Archit Taneja | 79ee89c | 2012-01-30 10:54:17 +0530 | [diff] [blame] | 1914 | unsigned long pclk = dispc_mgr_pclk_rate(channel); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1915 | |
| 1916 | /* |
| 1917 | * FIXME how to determine the 'A' factor |
| 1918 | * for the no downscaling case ? |
| 1919 | */ |
| 1920 | |
| 1921 | if (width > 3 * out_width) |
| 1922 | hf = 4; |
| 1923 | else if (width > 2 * out_width) |
| 1924 | hf = 3; |
| 1925 | else if (width > out_width) |
| 1926 | hf = 2; |
| 1927 | else |
| 1928 | hf = 1; |
| 1929 | |
| 1930 | if (height > out_height) |
| 1931 | vf = 2; |
| 1932 | else |
| 1933 | vf = 1; |
| 1934 | |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 1935 | if (cpu_is_omap24xx()) { |
| 1936 | if (vf > 1 && hf > 1) |
Archit Taneja | 79ee89c | 2012-01-30 10:54:17 +0530 | [diff] [blame] | 1937 | return pclk * 4; |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 1938 | else |
Archit Taneja | 79ee89c | 2012-01-30 10:54:17 +0530 | [diff] [blame] | 1939 | return pclk * 2; |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 1940 | } else if (cpu_is_omap34xx()) { |
Archit Taneja | 79ee89c | 2012-01-30 10:54:17 +0530 | [diff] [blame] | 1941 | return pclk * vf * hf; |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 1942 | } else { |
Archit Taneja | 79ee89c | 2012-01-30 10:54:17 +0530 | [diff] [blame] | 1943 | if (hf > 1) |
| 1944 | return DIV_ROUND_UP(pclk, out_width) * width; |
| 1945 | else |
| 1946 | return pclk; |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 1947 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 1948 | } |
| 1949 | |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 1950 | static int dispc_ovl_calc_scaling(enum omap_plane plane, |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 1951 | enum omap_channel channel, |
| 1952 | const struct omap_video_timings *mgr_timings, |
| 1953 | u16 width, u16 height, u16 out_width, u16 out_height, |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1954 | enum omap_color_mode color_mode, bool *five_taps, |
Chandrabhanu Mahapatra | 7faa923 | 2012-04-02 20:43:17 +0530 | [diff] [blame] | 1955 | int *x_predecim, int *y_predecim, u16 pos_x) |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 1956 | { |
| 1957 | struct omap_overlay *ovl = omap_dss_get_overlay(plane); |
Archit Taneja | 0373cac | 2011-09-08 13:25:17 +0530 | [diff] [blame] | 1958 | const int maxdownscale = dss_feat_get_param_max(FEAT_PARAM_DOWNSCALE); |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 1959 | const int maxsinglelinewidth = |
| 1960 | dss_feat_get_param_max(FEAT_PARAM_LINEWIDTH); |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1961 | const int max_decim_limit = 16; |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 1962 | unsigned long core_clk = 0; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1963 | int decim_x, decim_y, error, min_factor; |
| 1964 | u16 in_width, in_height, in_width_max = 0; |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 1965 | |
Tomi Valkeinen | f95cb5e | 2011-11-01 10:50:45 +0200 | [diff] [blame] | 1966 | if (width == out_width && height == out_height) |
| 1967 | return 0; |
| 1968 | |
| 1969 | if ((ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0) |
| 1970 | return -EINVAL; |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 1971 | |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1972 | *x_predecim = max_decim_limit; |
| 1973 | *y_predecim = max_decim_limit; |
| 1974 | |
| 1975 | if (color_mode == OMAP_DSS_COLOR_CLUT1 || |
| 1976 | color_mode == OMAP_DSS_COLOR_CLUT2 || |
| 1977 | color_mode == OMAP_DSS_COLOR_CLUT4 || |
| 1978 | color_mode == OMAP_DSS_COLOR_CLUT8) { |
| 1979 | *x_predecim = 1; |
| 1980 | *y_predecim = 1; |
| 1981 | *five_taps = false; |
| 1982 | return 0; |
| 1983 | } |
| 1984 | |
| 1985 | decim_x = DIV_ROUND_UP(DIV_ROUND_UP(width, out_width), maxdownscale); |
| 1986 | decim_y = DIV_ROUND_UP(DIV_ROUND_UP(height, out_height), maxdownscale); |
| 1987 | |
| 1988 | min_factor = min(decim_x, decim_y); |
| 1989 | |
| 1990 | if (decim_x > *x_predecim || out_width > width * 8) |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 1991 | return -EINVAL; |
| 1992 | |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1993 | if (decim_y > *y_predecim || out_height > height * 8) |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 1994 | return -EINVAL; |
| 1995 | |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 1996 | if (cpu_is_omap24xx()) { |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 1997 | *five_taps = false; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 1998 | |
| 1999 | do { |
| 2000 | in_height = DIV_ROUND_UP(height, decim_y); |
| 2001 | in_width = DIV_ROUND_UP(width, decim_x); |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 2002 | core_clk = calc_core_clk(channel, in_width, in_height, |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2003 | out_width, out_height); |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 2004 | error = (in_width > maxsinglelinewidth || !core_clk || |
| 2005 | core_clk > dispc_core_clk_rate()); |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2006 | if (error) { |
| 2007 | if (decim_x == decim_y) { |
| 2008 | decim_x = min_factor; |
| 2009 | decim_y++; |
| 2010 | } else { |
| 2011 | swap(decim_x, decim_y); |
| 2012 | if (decim_x < decim_y) |
| 2013 | decim_x++; |
| 2014 | } |
| 2015 | } |
| 2016 | } while (decim_x <= *x_predecim && decim_y <= *y_predecim && |
| 2017 | error); |
| 2018 | |
| 2019 | if (in_width > maxsinglelinewidth) { |
| 2020 | DSSERR("Cannot scale max input width exceeded"); |
| 2021 | return -EINVAL; |
| 2022 | } |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 2023 | } else if (cpu_is_omap34xx()) { |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2024 | |
| 2025 | do { |
| 2026 | in_height = DIV_ROUND_UP(height, decim_y); |
| 2027 | in_width = DIV_ROUND_UP(width, decim_x); |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 2028 | core_clk = calc_core_clk_five_taps(channel, mgr_timings, |
| 2029 | in_width, in_height, out_width, out_height, |
| 2030 | color_mode); |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2031 | |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 2032 | error = check_horiz_timing_omap3(channel, mgr_timings, |
| 2033 | pos_x, in_width, in_height, out_width, |
| 2034 | out_height); |
Chandrabhanu Mahapatra | 7faa923 | 2012-04-02 20:43:17 +0530 | [diff] [blame] | 2035 | |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2036 | if (in_width > maxsinglelinewidth) |
| 2037 | if (in_height > out_height && |
| 2038 | in_height < out_height * 2) |
| 2039 | *five_taps = false; |
| 2040 | if (!*five_taps) |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 2041 | core_clk = calc_core_clk(channel, in_width, |
| 2042 | in_height, out_width, out_height); |
Chandrabhanu Mahapatra | 7faa923 | 2012-04-02 20:43:17 +0530 | [diff] [blame] | 2043 | error = (error || in_width > maxsinglelinewidth * 2 || |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2044 | (in_width > maxsinglelinewidth && *five_taps) || |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 2045 | !core_clk || core_clk > dispc_core_clk_rate()); |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2046 | if (error) { |
| 2047 | if (decim_x == decim_y) { |
| 2048 | decim_x = min_factor; |
| 2049 | decim_y++; |
| 2050 | } else { |
| 2051 | swap(decim_x, decim_y); |
| 2052 | if (decim_x < decim_y) |
| 2053 | decim_x++; |
| 2054 | } |
| 2055 | } |
| 2056 | } while (decim_x <= *x_predecim && decim_y <= *y_predecim |
| 2057 | && error); |
| 2058 | |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 2059 | if (check_horiz_timing_omap3(channel, mgr_timings, pos_x, width, |
| 2060 | height, out_width, out_height)){ |
Chandrabhanu Mahapatra | 7faa923 | 2012-04-02 20:43:17 +0530 | [diff] [blame] | 2061 | DSSERR("horizontal timing too tight\n"); |
| 2062 | return -EINVAL; |
| 2063 | } |
| 2064 | |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2065 | if (in_width > (maxsinglelinewidth * 2)) { |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 2066 | DSSERR("Cannot setup scaling"); |
| 2067 | DSSERR("width exceeds maximum width possible"); |
| 2068 | return -EINVAL; |
| 2069 | } |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2070 | |
| 2071 | if (in_width > maxsinglelinewidth && *five_taps) { |
| 2072 | DSSERR("cannot setup scaling with five taps"); |
| 2073 | return -EINVAL; |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 2074 | } |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 2075 | } else { |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2076 | int decim_x_min = decim_x; |
| 2077 | in_height = DIV_ROUND_UP(height, decim_y); |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 2078 | in_width_max = dispc_core_clk_rate() / |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2079 | DIV_ROUND_UP(dispc_mgr_pclk_rate(channel), |
| 2080 | out_width); |
| 2081 | decim_x = DIV_ROUND_UP(width, in_width_max); |
| 2082 | |
| 2083 | decim_x = decim_x > decim_x_min ? decim_x : decim_x_min; |
| 2084 | if (decim_x > *x_predecim) |
| 2085 | return -EINVAL; |
| 2086 | |
| 2087 | do { |
| 2088 | in_width = DIV_ROUND_UP(width, decim_x); |
| 2089 | } while (decim_x <= *x_predecim && |
| 2090 | in_width > maxsinglelinewidth && decim_x++); |
| 2091 | |
| 2092 | if (in_width > maxsinglelinewidth) { |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 2093 | DSSERR("Cannot scale width exceeds max line width"); |
| 2094 | return -EINVAL; |
| 2095 | } |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2096 | |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 2097 | core_clk = calc_core_clk(channel, in_width, in_height, |
| 2098 | out_width, out_height); |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 2099 | } |
| 2100 | |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 2101 | DSSDBG("required core clk rate = %lu Hz\n", core_clk); |
| 2102 | DSSDBG("current core clk rate = %lu Hz\n", dispc_core_clk_rate()); |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 2103 | |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 2104 | if (!core_clk || core_clk > dispc_core_clk_rate()) { |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 2105 | DSSERR("failed to set up scaling, " |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 2106 | "required core clk rate = %lu Hz, " |
| 2107 | "current core clk rate = %lu Hz\n", |
| 2108 | core_clk, dispc_core_clk_rate()); |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 2109 | return -EINVAL; |
| 2110 | } |
| 2111 | |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2112 | *x_predecim = decim_x; |
| 2113 | *y_predecim = decim_y; |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 2114 | return 0; |
| 2115 | } |
| 2116 | |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2117 | int dispc_ovl_setup(enum omap_plane plane, struct omap_overlay_info *oi, |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 2118 | bool ilace, bool replication, |
| 2119 | const struct omap_video_timings *mgr_timings) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2120 | { |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 2121 | struct omap_overlay *ovl = omap_dss_get_overlay(plane); |
Chandrabhanu Mahapatra | 7282f1b | 2011-12-19 14:03:56 +0530 | [diff] [blame] | 2122 | bool five_taps = true; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2123 | bool fieldmode = 0; |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 2124 | int r, cconv = 0; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2125 | unsigned offset0, offset1; |
| 2126 | s32 row_inc; |
| 2127 | s32 pix_inc; |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2128 | u16 frame_height = oi->height; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2129 | unsigned int field_offset = 0; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2130 | u16 in_height = oi->height; |
| 2131 | u16 in_width = oi->width; |
| 2132 | u16 out_width, out_height; |
Tomi Valkeinen | 2cc5d1a | 2011-11-03 17:03:44 +0200 | [diff] [blame] | 2133 | enum omap_channel channel; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2134 | int x_predecim = 1, y_predecim = 1; |
Tomi Valkeinen | 2cc5d1a | 2011-11-03 17:03:44 +0200 | [diff] [blame] | 2135 | |
| 2136 | channel = dispc_ovl_get_channel_out(plane); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2137 | |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2138 | DSSDBG("dispc_ovl_setup %d, pa %x, pa_uv %x, sw %d, %d,%d, %dx%d -> " |
Tomi Valkeinen | f38545d | 2011-11-03 17:00:07 +0200 | [diff] [blame] | 2139 | "%dx%d, cmode %x, rot %d, mir %d, ilace %d chan %d repl %d\n", |
| 2140 | plane, oi->paddr, oi->p_uv_addr, |
Archit Taneja | c3d92529 | 2011-09-14 11:52:54 +0530 | [diff] [blame] | 2141 | oi->screen_width, oi->pos_x, oi->pos_y, oi->width, oi->height, |
| 2142 | oi->out_width, oi->out_height, oi->color_mode, oi->rotation, |
Tomi Valkeinen | f38545d | 2011-11-03 17:00:07 +0200 | [diff] [blame] | 2143 | oi->mirror, ilace, channel, replication); |
Tomi Valkeinen | e6d80f9 | 2011-05-19 14:12:26 +0300 | [diff] [blame] | 2144 | |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2145 | if (oi->paddr == 0) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2146 | return -EINVAL; |
| 2147 | |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2148 | out_width = oi->out_width == 0 ? oi->width : oi->out_width; |
| 2149 | out_height = oi->out_height == 0 ? oi->height : oi->out_height; |
Tomi Valkeinen | cf07366 | 2011-11-03 16:08:27 +0200 | [diff] [blame] | 2150 | |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2151 | if (ilace && oi->height == out_height) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2152 | fieldmode = 1; |
| 2153 | |
| 2154 | if (ilace) { |
| 2155 | if (fieldmode) |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2156 | in_height /= 2; |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2157 | oi->pos_y /= 2; |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2158 | out_height /= 2; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2159 | |
| 2160 | DSSDBG("adjusting for ilace: height %d, pos_y %d, " |
| 2161 | "out_height %d\n", |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2162 | in_height, oi->pos_y, out_height); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2163 | } |
| 2164 | |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2165 | if (!dss_feat_color_mode_supported(plane, oi->color_mode)) |
Archit Taneja | 8dad2ab | 2010-11-25 17:58:10 +0530 | [diff] [blame] | 2166 | return -EINVAL; |
| 2167 | |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 2168 | r = dispc_ovl_calc_scaling(plane, channel, mgr_timings, in_width, |
| 2169 | in_height, out_width, out_height, oi->color_mode, |
| 2170 | &five_taps, &x_predecim, &y_predecim, oi->pos_x); |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 2171 | if (r) |
| 2172 | return r; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2173 | |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2174 | in_width = DIV_ROUND_UP(in_width, x_predecim); |
| 2175 | in_height = DIV_ROUND_UP(in_height, y_predecim); |
| 2176 | |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 2177 | if (oi->color_mode == OMAP_DSS_COLOR_YUV2 || |
| 2178 | oi->color_mode == OMAP_DSS_COLOR_UYVY || |
| 2179 | oi->color_mode == OMAP_DSS_COLOR_NV12) |
| 2180 | cconv = 1; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2181 | |
| 2182 | if (ilace && !fieldmode) { |
| 2183 | /* |
| 2184 | * when downscaling the bottom field may have to start several |
| 2185 | * source lines below the top field. Unfortunately ACCUI |
| 2186 | * registers will only hold the fractional part of the offset |
| 2187 | * so the integer part must be added to the base address of the |
| 2188 | * bottom field. |
| 2189 | */ |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2190 | if (!in_height || in_height == out_height) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2191 | field_offset = 0; |
| 2192 | else |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2193 | field_offset = in_height / out_height / 2; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2194 | } |
| 2195 | |
| 2196 | /* Fields are independent but interleaved in memory. */ |
| 2197 | if (fieldmode) |
| 2198 | field_offset = 1; |
| 2199 | |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 2200 | offset0 = 0; |
| 2201 | offset1 = 0; |
| 2202 | row_inc = 0; |
| 2203 | pix_inc = 0; |
| 2204 | |
Chandrabhanu Mahapatra | 65e006f | 2012-05-11 19:19:55 +0530 | [diff] [blame] | 2205 | if (oi->rotation_type == OMAP_DSS_ROT_TILER) |
| 2206 | calc_tiler_rotation_offset(oi->screen_width, in_width, |
| 2207 | oi->color_mode, fieldmode, field_offset, |
| 2208 | &offset0, &offset1, &row_inc, &pix_inc, |
| 2209 | x_predecim, y_predecim); |
| 2210 | else if (oi->rotation_type == OMAP_DSS_ROT_DMA) |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2211 | calc_dma_rotation_offset(oi->rotation, oi->mirror, |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2212 | oi->screen_width, in_width, frame_height, |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2213 | oi->color_mode, fieldmode, field_offset, |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2214 | &offset0, &offset1, &row_inc, &pix_inc, |
| 2215 | x_predecim, y_predecim); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2216 | else |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2217 | calc_vrfb_rotation_offset(oi->rotation, oi->mirror, |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2218 | oi->screen_width, in_width, frame_height, |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2219 | oi->color_mode, fieldmode, field_offset, |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2220 | &offset0, &offset1, &row_inc, &pix_inc, |
| 2221 | x_predecim, y_predecim); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2222 | |
| 2223 | DSSDBG("offset0 %u, offset1 %u, row_inc %d, pix_inc %d\n", |
| 2224 | offset0, offset1, row_inc, pix_inc); |
| 2225 | |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2226 | dispc_ovl_set_color_mode(plane, oi->color_mode); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2227 | |
Chandrabhanu Mahapatra | 65e006f | 2012-05-11 19:19:55 +0530 | [diff] [blame] | 2228 | dispc_ovl_configure_burst_type(plane, oi->rotation_type); |
| 2229 | |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2230 | dispc_ovl_set_ba0(plane, oi->paddr + offset0); |
| 2231 | dispc_ovl_set_ba1(plane, oi->paddr + offset1); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2232 | |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2233 | if (OMAP_DSS_COLOR_NV12 == oi->color_mode) { |
| 2234 | dispc_ovl_set_ba0_uv(plane, oi->p_uv_addr + offset0); |
| 2235 | dispc_ovl_set_ba1_uv(plane, oi->p_uv_addr + offset1); |
Amber Jain | 0d66cbb | 2011-05-19 19:47:54 +0530 | [diff] [blame] | 2236 | } |
| 2237 | |
| 2238 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 2239 | dispc_ovl_set_row_inc(plane, row_inc); |
| 2240 | dispc_ovl_set_pix_inc(plane, pix_inc); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2241 | |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2242 | DSSDBG("%d,%d %dx%d -> %dx%d\n", oi->pos_x, oi->pos_y, in_width, |
| 2243 | in_height, out_width, out_height); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2244 | |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2245 | dispc_ovl_set_pos(plane, oi->pos_x, oi->pos_y); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2246 | |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2247 | dispc_ovl_set_pic_size(plane, in_width, in_height); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2248 | |
Archit Taneja | 79ad75f | 2011-09-08 13:15:11 +0530 | [diff] [blame] | 2249 | if (ovl->caps & OMAP_DSS_OVL_CAP_SCALE) { |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2250 | dispc_ovl_set_scaling(plane, in_width, in_height, out_width, |
| 2251 | out_height, ilace, five_taps, fieldmode, |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2252 | oi->color_mode, oi->rotation); |
Chandrabhanu Mahapatra | aed74b55 | 2012-04-02 20:43:16 +0530 | [diff] [blame] | 2253 | dispc_ovl_set_vid_size(plane, out_width, out_height); |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 2254 | dispc_ovl_set_vid_color_conv(plane, cconv); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2255 | } |
| 2256 | |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2257 | dispc_ovl_set_rotation_attrs(plane, oi->rotation, oi->mirror, |
| 2258 | oi->color_mode); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2259 | |
Archit Taneja | 5412870 | 2011-09-08 11:29:17 +0530 | [diff] [blame] | 2260 | dispc_ovl_set_zorder(plane, oi->zorder); |
Archit Taneja | a4273b7 | 2011-09-14 11:10:10 +0530 | [diff] [blame] | 2261 | dispc_ovl_set_pre_mult_alpha(plane, oi->pre_mult_alpha); |
| 2262 | dispc_ovl_setup_global_alpha(plane, oi->global_alpha); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2263 | |
Archit Taneja | c3d92529 | 2011-09-14 11:52:54 +0530 | [diff] [blame] | 2264 | dispc_ovl_enable_replication(plane, replication); |
Archit Taneja | c3d92529 | 2011-09-14 11:52:54 +0530 | [diff] [blame] | 2265 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2266 | return 0; |
| 2267 | } |
| 2268 | |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 2269 | int dispc_ovl_enable(enum omap_plane plane, bool enable) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2270 | { |
Tomi Valkeinen | e6d80f9 | 2011-05-19 14:12:26 +0300 | [diff] [blame] | 2271 | DSSDBG("dispc_enable_plane %d, %d\n", plane, enable); |
| 2272 | |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 2273 | REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 0, 0); |
Tomi Valkeinen | e6d80f9 | 2011-05-19 14:12:26 +0300 | [diff] [blame] | 2274 | |
| 2275 | return 0; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2276 | } |
| 2277 | |
| 2278 | static void dispc_disable_isr(void *data, u32 mask) |
| 2279 | { |
| 2280 | struct completion *compl = data; |
| 2281 | complete(compl); |
| 2282 | } |
| 2283 | |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2284 | static void _enable_lcd_out(enum omap_channel channel, bool enable) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2285 | { |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 2286 | mgr_fld_write(channel, DISPC_MGR_FLD_ENABLE, enable); |
| 2287 | /* flush posted write */ |
| 2288 | mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2289 | } |
| 2290 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2291 | static void dispc_mgr_enable_lcd_out(enum omap_channel channel, bool enable) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2292 | { |
| 2293 | struct completion frame_done_completion; |
| 2294 | bool is_on; |
| 2295 | int r; |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2296 | u32 irq; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2297 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2298 | /* When we disable LCD output, we need to wait until frame is done. |
| 2299 | * Otherwise the DSS is still working, and turning off the clocks |
| 2300 | * prevents DSS from going to OFF mode */ |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 2301 | is_on = mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2302 | |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 2303 | irq = mgr_desc[channel].framedone_irq; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2304 | |
| 2305 | if (!enable && is_on) { |
| 2306 | init_completion(&frame_done_completion); |
| 2307 | |
| 2308 | r = omap_dispc_register_isr(dispc_disable_isr, |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2309 | &frame_done_completion, irq); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2310 | |
| 2311 | if (r) |
| 2312 | DSSERR("failed to register FRAMEDONE isr\n"); |
| 2313 | } |
| 2314 | |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2315 | _enable_lcd_out(channel, enable); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2316 | |
| 2317 | if (!enable && is_on) { |
| 2318 | if (!wait_for_completion_timeout(&frame_done_completion, |
| 2319 | msecs_to_jiffies(100))) |
| 2320 | DSSERR("timeout waiting for FRAME DONE\n"); |
| 2321 | |
| 2322 | r = omap_dispc_unregister_isr(dispc_disable_isr, |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2323 | &frame_done_completion, irq); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2324 | |
| 2325 | if (r) |
| 2326 | DSSERR("failed to unregister FRAMEDONE isr\n"); |
| 2327 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2328 | } |
| 2329 | |
| 2330 | static void _enable_digit_out(bool enable) |
| 2331 | { |
| 2332 | REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 1, 1); |
Tomi Valkeinen | b6a44e7 | 2011-10-12 10:17:02 +0300 | [diff] [blame] | 2333 | /* flush posted write */ |
| 2334 | dispc_read_reg(DISPC_CONTROL); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2335 | } |
| 2336 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2337 | static void dispc_mgr_enable_digit_out(bool enable) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2338 | { |
| 2339 | struct completion frame_done_completion; |
Tomi Valkeinen | e82b090 | 2011-08-31 14:42:49 +0300 | [diff] [blame] | 2340 | enum dss_hdmi_venc_clk_source_select src; |
| 2341 | int r, i; |
| 2342 | u32 irq_mask; |
| 2343 | int num_irqs; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2344 | |
Tomi Valkeinen | e6d80f9 | 2011-05-19 14:12:26 +0300 | [diff] [blame] | 2345 | if (REG_GET(DISPC_CONTROL, 1, 1) == enable) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2346 | return; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2347 | |
Tomi Valkeinen | e82b090 | 2011-08-31 14:42:49 +0300 | [diff] [blame] | 2348 | src = dss_get_hdmi_venc_clk_source(); |
| 2349 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2350 | if (enable) { |
| 2351 | unsigned long flags; |
| 2352 | /* When we enable digit output, we'll get an extra digit |
| 2353 | * sync lost interrupt, that we need to ignore */ |
| 2354 | spin_lock_irqsave(&dispc.irq_lock, flags); |
| 2355 | dispc.irq_error_mask &= ~DISPC_IRQ_SYNC_LOST_DIGIT; |
| 2356 | _omap_dispc_set_irqs(); |
| 2357 | spin_unlock_irqrestore(&dispc.irq_lock, flags); |
| 2358 | } |
| 2359 | |
| 2360 | /* When we disable digit output, we need to wait until fields are done. |
| 2361 | * Otherwise the DSS is still working, and turning off the clocks |
| 2362 | * prevents DSS from going to OFF mode. And when enabling, we need to |
| 2363 | * wait for the extra sync losts */ |
| 2364 | init_completion(&frame_done_completion); |
| 2365 | |
Tomi Valkeinen | e82b090 | 2011-08-31 14:42:49 +0300 | [diff] [blame] | 2366 | if (src == DSS_HDMI_M_PCLK && enable == false) { |
| 2367 | irq_mask = DISPC_IRQ_FRAMEDONETV; |
| 2368 | num_irqs = 1; |
| 2369 | } else { |
| 2370 | irq_mask = DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD; |
| 2371 | /* XXX I understand from TRM that we should only wait for the |
| 2372 | * current field to complete. But it seems we have to wait for |
| 2373 | * both fields */ |
| 2374 | num_irqs = 2; |
| 2375 | } |
| 2376 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2377 | r = omap_dispc_register_isr(dispc_disable_isr, &frame_done_completion, |
Tomi Valkeinen | e82b090 | 2011-08-31 14:42:49 +0300 | [diff] [blame] | 2378 | irq_mask); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2379 | if (r) |
Tomi Valkeinen | e82b090 | 2011-08-31 14:42:49 +0300 | [diff] [blame] | 2380 | DSSERR("failed to register %x isr\n", irq_mask); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2381 | |
| 2382 | _enable_digit_out(enable); |
| 2383 | |
Tomi Valkeinen | e82b090 | 2011-08-31 14:42:49 +0300 | [diff] [blame] | 2384 | for (i = 0; i < num_irqs; ++i) { |
| 2385 | if (!wait_for_completion_timeout(&frame_done_completion, |
| 2386 | msecs_to_jiffies(100))) |
| 2387 | DSSERR("timeout waiting for digit out to %s\n", |
| 2388 | enable ? "start" : "stop"); |
| 2389 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2390 | |
Tomi Valkeinen | e82b090 | 2011-08-31 14:42:49 +0300 | [diff] [blame] | 2391 | r = omap_dispc_unregister_isr(dispc_disable_isr, &frame_done_completion, |
| 2392 | irq_mask); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2393 | if (r) |
Tomi Valkeinen | e82b090 | 2011-08-31 14:42:49 +0300 | [diff] [blame] | 2394 | DSSERR("failed to unregister %x isr\n", irq_mask); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2395 | |
| 2396 | if (enable) { |
| 2397 | unsigned long flags; |
| 2398 | spin_lock_irqsave(&dispc.irq_lock, flags); |
Tomi Valkeinen | e82b090 | 2011-08-31 14:42:49 +0300 | [diff] [blame] | 2399 | dispc.irq_error_mask |= DISPC_IRQ_SYNC_LOST_DIGIT; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2400 | dispc_write_reg(DISPC_IRQSTATUS, DISPC_IRQ_SYNC_LOST_DIGIT); |
| 2401 | _omap_dispc_set_irqs(); |
| 2402 | spin_unlock_irqrestore(&dispc.irq_lock, flags); |
| 2403 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2404 | } |
| 2405 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2406 | bool dispc_mgr_is_enabled(enum omap_channel channel) |
Tomi Valkeinen | a2faee8 | 2010-01-08 17:14:53 +0200 | [diff] [blame] | 2407 | { |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 2408 | return !!mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE); |
Tomi Valkeinen | a2faee8 | 2010-01-08 17:14:53 +0200 | [diff] [blame] | 2409 | } |
| 2410 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2411 | void dispc_mgr_enable(enum omap_channel channel, bool enable) |
Tomi Valkeinen | a2faee8 | 2010-01-08 17:14:53 +0200 | [diff] [blame] | 2412 | { |
Archit Taneja | dac57a0 | 2011-09-08 12:30:19 +0530 | [diff] [blame] | 2413 | if (dispc_mgr_is_lcd(channel)) |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2414 | dispc_mgr_enable_lcd_out(channel, enable); |
Tomi Valkeinen | a2faee8 | 2010-01-08 17:14:53 +0200 | [diff] [blame] | 2415 | else if (channel == OMAP_DSS_CHANNEL_DIGIT) |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2416 | dispc_mgr_enable_digit_out(enable); |
Tomi Valkeinen | a2faee8 | 2010-01-08 17:14:53 +0200 | [diff] [blame] | 2417 | else |
| 2418 | BUG(); |
| 2419 | } |
| 2420 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2421 | void dispc_lcd_enable_signal_polarity(bool act_high) |
| 2422 | { |
Archit Taneja | 6ced40b | 2010-12-02 11:27:13 +0000 | [diff] [blame] | 2423 | if (!dss_has_feature(FEAT_LCDENABLEPOL)) |
| 2424 | return; |
| 2425 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2426 | REG_FLD_MOD(DISPC_CONTROL, act_high ? 1 : 0, 29, 29); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2427 | } |
| 2428 | |
| 2429 | void dispc_lcd_enable_signal(bool enable) |
| 2430 | { |
Archit Taneja | 6ced40b | 2010-12-02 11:27:13 +0000 | [diff] [blame] | 2431 | if (!dss_has_feature(FEAT_LCDENABLESIGNAL)) |
| 2432 | return; |
| 2433 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2434 | REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 28, 28); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2435 | } |
| 2436 | |
| 2437 | void dispc_pck_free_enable(bool enable) |
| 2438 | { |
Archit Taneja | 6ced40b | 2010-12-02 11:27:13 +0000 | [diff] [blame] | 2439 | if (!dss_has_feature(FEAT_PCKFREEENABLE)) |
| 2440 | return; |
| 2441 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2442 | REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 27, 27); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2443 | } |
| 2444 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2445 | void dispc_mgr_enable_fifohandcheck(enum omap_channel channel, bool enable) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2446 | { |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 2447 | mgr_fld_write(channel, DISPC_MGR_FLD_FIFOHANDCHECK, enable); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2448 | } |
| 2449 | |
| 2450 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2451 | void dispc_mgr_set_lcd_display_type(enum omap_channel channel, |
Sumit Semwal | 64ba4f7 | 2010-12-02 11:27:10 +0000 | [diff] [blame] | 2452 | enum omap_lcd_display_type type) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2453 | { |
| 2454 | int mode; |
| 2455 | |
| 2456 | switch (type) { |
| 2457 | case OMAP_DSS_LCD_DISPLAY_STN: |
| 2458 | mode = 0; |
| 2459 | break; |
| 2460 | |
| 2461 | case OMAP_DSS_LCD_DISPLAY_TFT: |
| 2462 | mode = 1; |
| 2463 | break; |
| 2464 | |
| 2465 | default: |
| 2466 | BUG(); |
| 2467 | return; |
| 2468 | } |
| 2469 | |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 2470 | mgr_fld_write(channel, DISPC_MGR_FLD_STNTFT, mode); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2471 | } |
| 2472 | |
| 2473 | void dispc_set_loadmode(enum omap_dss_load_mode mode) |
| 2474 | { |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2475 | REG_FLD_MOD(DISPC_CONFIG, mode, 2, 1); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2476 | } |
| 2477 | |
| 2478 | |
Tomi Valkeinen | c64dca4 | 2011-11-04 18:14:20 +0200 | [diff] [blame] | 2479 | static void dispc_mgr_set_default_color(enum omap_channel channel, u32 color) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2480 | { |
Sumit Semwal | 8613b00 | 2010-12-02 11:27:09 +0000 | [diff] [blame] | 2481 | dispc_write_reg(DISPC_DEFAULT_COLOR(channel), color); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2482 | } |
| 2483 | |
Tomi Valkeinen | c64dca4 | 2011-11-04 18:14:20 +0200 | [diff] [blame] | 2484 | static void dispc_mgr_set_trans_key(enum omap_channel ch, |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2485 | enum omap_dss_trans_key_type type, |
| 2486 | u32 trans_key) |
| 2487 | { |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 2488 | mgr_fld_write(ch, DISPC_MGR_FLD_TCKSELECTION, type); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2489 | |
Sumit Semwal | 8613b00 | 2010-12-02 11:27:09 +0000 | [diff] [blame] | 2490 | dispc_write_reg(DISPC_TRANS_COLOR(ch), trans_key); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2491 | } |
| 2492 | |
Tomi Valkeinen | c64dca4 | 2011-11-04 18:14:20 +0200 | [diff] [blame] | 2493 | static void dispc_mgr_enable_trans_key(enum omap_channel ch, bool enable) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2494 | { |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 2495 | mgr_fld_write(ch, DISPC_MGR_FLD_TCKENABLE, enable); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2496 | } |
Archit Taneja | 11354dd | 2011-09-26 11:47:29 +0530 | [diff] [blame] | 2497 | |
Tomi Valkeinen | c64dca4 | 2011-11-04 18:14:20 +0200 | [diff] [blame] | 2498 | static void dispc_mgr_enable_alpha_fixed_zorder(enum omap_channel ch, |
| 2499 | bool enable) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2500 | { |
Archit Taneja | 11354dd | 2011-09-26 11:47:29 +0530 | [diff] [blame] | 2501 | if (!dss_has_feature(FEAT_ALPHA_FIXED_ZORDER)) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2502 | return; |
| 2503 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2504 | if (ch == OMAP_DSS_CHANNEL_LCD) |
| 2505 | REG_FLD_MOD(DISPC_CONFIG, enable, 18, 18); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2506 | else if (ch == OMAP_DSS_CHANNEL_DIGIT) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2507 | REG_FLD_MOD(DISPC_CONFIG, enable, 19, 19); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2508 | } |
Archit Taneja | 11354dd | 2011-09-26 11:47:29 +0530 | [diff] [blame] | 2509 | |
Tomi Valkeinen | c64dca4 | 2011-11-04 18:14:20 +0200 | [diff] [blame] | 2510 | void dispc_mgr_setup(enum omap_channel channel, |
| 2511 | struct omap_overlay_manager_info *info) |
| 2512 | { |
| 2513 | dispc_mgr_set_default_color(channel, info->default_color); |
| 2514 | dispc_mgr_set_trans_key(channel, info->trans_key_type, info->trans_key); |
| 2515 | dispc_mgr_enable_trans_key(channel, info->trans_enabled); |
| 2516 | dispc_mgr_enable_alpha_fixed_zorder(channel, |
| 2517 | info->partial_alpha_enabled); |
| 2518 | if (dss_has_feature(FEAT_CPR)) { |
| 2519 | dispc_mgr_enable_cpr(channel, info->cpr_enable); |
| 2520 | dispc_mgr_set_cpr_coef(channel, &info->cpr_coefs); |
| 2521 | } |
| 2522 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2523 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2524 | void dispc_mgr_set_tft_data_lines(enum omap_channel channel, u8 data_lines) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2525 | { |
| 2526 | int code; |
| 2527 | |
| 2528 | switch (data_lines) { |
| 2529 | case 12: |
| 2530 | code = 0; |
| 2531 | break; |
| 2532 | case 16: |
| 2533 | code = 1; |
| 2534 | break; |
| 2535 | case 18: |
| 2536 | code = 2; |
| 2537 | break; |
| 2538 | case 24: |
| 2539 | code = 3; |
| 2540 | break; |
| 2541 | default: |
| 2542 | BUG(); |
| 2543 | return; |
| 2544 | } |
| 2545 | |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 2546 | mgr_fld_write(channel, DISPC_MGR_FLD_TFTDATALINES, code); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2547 | } |
| 2548 | |
Archit Taneja | 569969d | 2011-08-22 17:41:57 +0530 | [diff] [blame] | 2549 | void dispc_mgr_set_io_pad_mode(enum dss_io_pad_mode mode) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2550 | { |
| 2551 | u32 l; |
Archit Taneja | 569969d | 2011-08-22 17:41:57 +0530 | [diff] [blame] | 2552 | int gpout0, gpout1; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2553 | |
| 2554 | switch (mode) { |
Archit Taneja | 569969d | 2011-08-22 17:41:57 +0530 | [diff] [blame] | 2555 | case DSS_IO_PAD_MODE_RESET: |
| 2556 | gpout0 = 0; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2557 | gpout1 = 0; |
| 2558 | break; |
Archit Taneja | 569969d | 2011-08-22 17:41:57 +0530 | [diff] [blame] | 2559 | case DSS_IO_PAD_MODE_RFBI: |
| 2560 | gpout0 = 1; |
| 2561 | gpout1 = 0; |
| 2562 | break; |
| 2563 | case DSS_IO_PAD_MODE_BYPASS: |
| 2564 | gpout0 = 1; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2565 | gpout1 = 1; |
| 2566 | break; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2567 | default: |
| 2568 | BUG(); |
| 2569 | return; |
| 2570 | } |
| 2571 | |
Archit Taneja | 569969d | 2011-08-22 17:41:57 +0530 | [diff] [blame] | 2572 | l = dispc_read_reg(DISPC_CONTROL); |
| 2573 | l = FLD_MOD(l, gpout0, 15, 15); |
| 2574 | l = FLD_MOD(l, gpout1, 16, 16); |
| 2575 | dispc_write_reg(DISPC_CONTROL, l); |
| 2576 | } |
| 2577 | |
| 2578 | void dispc_mgr_enable_stallmode(enum omap_channel channel, bool enable) |
| 2579 | { |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 2580 | mgr_fld_write(channel, DISPC_MGR_FLD_STALLMODE, enable); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2581 | } |
| 2582 | |
Archit Taneja | 8f36616 | 2012-04-16 12:53:44 +0530 | [diff] [blame] | 2583 | static bool _dispc_mgr_size_ok(u16 width, u16 height) |
| 2584 | { |
| 2585 | return width <= dss_feat_get_param_max(FEAT_PARAM_MGR_WIDTH) && |
| 2586 | height <= dss_feat_get_param_max(FEAT_PARAM_MGR_HEIGHT); |
| 2587 | } |
| 2588 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2589 | static bool _dispc_lcd_timings_ok(int hsw, int hfp, int hbp, |
| 2590 | int vsw, int vfp, int vbp) |
| 2591 | { |
| 2592 | if (cpu_is_omap24xx() || omap_rev() < OMAP3430_REV_ES3_0) { |
| 2593 | if (hsw < 1 || hsw > 64 || |
| 2594 | hfp < 1 || hfp > 256 || |
| 2595 | hbp < 1 || hbp > 256 || |
| 2596 | vsw < 1 || vsw > 64 || |
| 2597 | vfp < 0 || vfp > 255 || |
| 2598 | vbp < 0 || vbp > 255) |
| 2599 | return false; |
| 2600 | } else { |
| 2601 | if (hsw < 1 || hsw > 256 || |
| 2602 | hfp < 1 || hfp > 4096 || |
| 2603 | hbp < 1 || hbp > 4096 || |
| 2604 | vsw < 1 || vsw > 256 || |
| 2605 | vfp < 0 || vfp > 4095 || |
| 2606 | vbp < 0 || vbp > 4095) |
| 2607 | return false; |
| 2608 | } |
| 2609 | |
| 2610 | return true; |
| 2611 | } |
| 2612 | |
Archit Taneja | 8f36616 | 2012-04-16 12:53:44 +0530 | [diff] [blame] | 2613 | bool dispc_mgr_timings_ok(enum omap_channel channel, |
Archit Taneja | b917fa3 | 2012-04-27 01:07:28 +0530 | [diff] [blame] | 2614 | const struct omap_video_timings *timings) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2615 | { |
Archit Taneja | 8f36616 | 2012-04-16 12:53:44 +0530 | [diff] [blame] | 2616 | bool timings_ok; |
| 2617 | |
| 2618 | timings_ok = _dispc_mgr_size_ok(timings->x_res, timings->y_res); |
| 2619 | |
| 2620 | if (dispc_mgr_is_lcd(channel)) |
| 2621 | timings_ok = timings_ok && _dispc_lcd_timings_ok(timings->hsw, |
| 2622 | timings->hfp, timings->hbp, |
| 2623 | timings->vsw, timings->vfp, |
| 2624 | timings->vbp); |
| 2625 | |
| 2626 | return timings_ok; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2627 | } |
| 2628 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2629 | static void _dispc_mgr_set_lcd_timings(enum omap_channel channel, int hsw, |
Sumit Semwal | 64ba4f7 | 2010-12-02 11:27:10 +0000 | [diff] [blame] | 2630 | int hfp, int hbp, int vsw, int vfp, int vbp) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2631 | { |
| 2632 | u32 timing_h, timing_v; |
| 2633 | |
| 2634 | if (cpu_is_omap24xx() || omap_rev() < OMAP3430_REV_ES3_0) { |
| 2635 | timing_h = FLD_VAL(hsw-1, 5, 0) | FLD_VAL(hfp-1, 15, 8) | |
| 2636 | FLD_VAL(hbp-1, 27, 20); |
| 2637 | |
| 2638 | timing_v = FLD_VAL(vsw-1, 5, 0) | FLD_VAL(vfp, 15, 8) | |
| 2639 | FLD_VAL(vbp, 27, 20); |
| 2640 | } else { |
| 2641 | timing_h = FLD_VAL(hsw-1, 7, 0) | FLD_VAL(hfp-1, 19, 8) | |
| 2642 | FLD_VAL(hbp-1, 31, 20); |
| 2643 | |
| 2644 | timing_v = FLD_VAL(vsw-1, 7, 0) | FLD_VAL(vfp, 19, 8) | |
| 2645 | FLD_VAL(vbp, 31, 20); |
| 2646 | } |
| 2647 | |
Sumit Semwal | 64ba4f7 | 2010-12-02 11:27:10 +0000 | [diff] [blame] | 2648 | dispc_write_reg(DISPC_TIMING_H(channel), timing_h); |
| 2649 | dispc_write_reg(DISPC_TIMING_V(channel), timing_v); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2650 | } |
| 2651 | |
| 2652 | /* change name to mode? */ |
Archit Taneja | c51d921 | 2012-04-16 12:53:43 +0530 | [diff] [blame] | 2653 | void dispc_mgr_set_timings(enum omap_channel channel, |
Sumit Semwal | 64ba4f7 | 2010-12-02 11:27:10 +0000 | [diff] [blame] | 2654 | struct omap_video_timings *timings) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2655 | { |
| 2656 | unsigned xtot, ytot; |
| 2657 | unsigned long ht, vt; |
Archit Taneja | 2aefad4 | 2012-05-18 14:36:54 +0530 | [diff] [blame] | 2658 | struct omap_video_timings t = *timings; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2659 | |
Archit Taneja | 2aefad4 | 2012-05-18 14:36:54 +0530 | [diff] [blame] | 2660 | DSSDBG("channel %d xres %u yres %u\n", channel, t.x_res, t.y_res); |
Archit Taneja | c51d921 | 2012-04-16 12:53:43 +0530 | [diff] [blame] | 2661 | |
Archit Taneja | 2aefad4 | 2012-05-18 14:36:54 +0530 | [diff] [blame] | 2662 | if (!dispc_mgr_timings_ok(channel, &t)) { |
Archit Taneja | 8f36616 | 2012-04-16 12:53:44 +0530 | [diff] [blame] | 2663 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 2664 | return; |
| 2665 | } |
Archit Taneja | c51d921 | 2012-04-16 12:53:43 +0530 | [diff] [blame] | 2666 | |
Archit Taneja | 8f36616 | 2012-04-16 12:53:44 +0530 | [diff] [blame] | 2667 | if (dispc_mgr_is_lcd(channel)) { |
Archit Taneja | 2aefad4 | 2012-05-18 14:36:54 +0530 | [diff] [blame] | 2668 | _dispc_mgr_set_lcd_timings(channel, t.hsw, t.hfp, t.hbp, t.vsw, |
| 2669 | t.vfp, t.vbp); |
Archit Taneja | c51d921 | 2012-04-16 12:53:43 +0530 | [diff] [blame] | 2670 | |
Archit Taneja | 2aefad4 | 2012-05-18 14:36:54 +0530 | [diff] [blame] | 2671 | xtot = t.x_res + t.hfp + t.hsw + t.hbp; |
| 2672 | ytot = t.y_res + t.vfp + t.vsw + t.vbp; |
Archit Taneja | c51d921 | 2012-04-16 12:53:43 +0530 | [diff] [blame] | 2673 | |
| 2674 | ht = (timings->pixel_clock * 1000) / xtot; |
| 2675 | vt = (timings->pixel_clock * 1000) / xtot / ytot; |
| 2676 | |
| 2677 | DSSDBG("pck %u\n", timings->pixel_clock); |
| 2678 | DSSDBG("hsw %d hfp %d hbp %d vsw %d vfp %d vbp %d\n", |
Archit Taneja | 2aefad4 | 2012-05-18 14:36:54 +0530 | [diff] [blame] | 2679 | t.hsw, t.hfp, t.hbp, t.vsw, t.vfp, t.vbp); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2680 | |
Archit Taneja | c51d921 | 2012-04-16 12:53:43 +0530 | [diff] [blame] | 2681 | DSSDBG("hsync %luHz, vsync %luHz\n", ht, vt); |
Archit Taneja | 2aefad4 | 2012-05-18 14:36:54 +0530 | [diff] [blame] | 2682 | } else { |
| 2683 | enum dss_hdmi_venc_clk_source_select source; |
| 2684 | |
| 2685 | source = dss_get_hdmi_venc_clk_source(); |
| 2686 | |
| 2687 | if (source == DSS_VENC_TV_CLK) |
| 2688 | t.y_res /= 2; |
Archit Taneja | c51d921 | 2012-04-16 12:53:43 +0530 | [diff] [blame] | 2689 | } |
Archit Taneja | 8f36616 | 2012-04-16 12:53:44 +0530 | [diff] [blame] | 2690 | |
Archit Taneja | 2aefad4 | 2012-05-18 14:36:54 +0530 | [diff] [blame] | 2691 | dispc_mgr_set_size(channel, t.x_res, t.y_res); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2692 | } |
| 2693 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2694 | static void dispc_mgr_set_lcd_divisor(enum omap_channel channel, u16 lck_div, |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 2695 | u16 pck_div) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2696 | { |
| 2697 | BUG_ON(lck_div < 1); |
Tomi Valkeinen | 9eaaf20 | 2011-08-29 15:56:04 +0300 | [diff] [blame] | 2698 | BUG_ON(pck_div < 1); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2699 | |
Murthy, Raghuveer | ce7fa5e | 2011-03-03 09:27:59 -0600 | [diff] [blame] | 2700 | dispc_write_reg(DISPC_DIVISORo(channel), |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2701 | FLD_VAL(lck_div, 23, 16) | FLD_VAL(pck_div, 7, 0)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2702 | } |
| 2703 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2704 | static void dispc_mgr_get_lcd_divisor(enum omap_channel channel, int *lck_div, |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2705 | int *pck_div) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2706 | { |
| 2707 | u32 l; |
Murthy, Raghuveer | ce7fa5e | 2011-03-03 09:27:59 -0600 | [diff] [blame] | 2708 | l = dispc_read_reg(DISPC_DIVISORo(channel)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2709 | *lck_div = FLD_GET(l, 23, 16); |
| 2710 | *pck_div = FLD_GET(l, 7, 0); |
| 2711 | } |
| 2712 | |
| 2713 | unsigned long dispc_fclk_rate(void) |
| 2714 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2715 | struct platform_device *dsidev; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2716 | unsigned long r = 0; |
| 2717 | |
Taneja, Archit | 66534e8 | 2011-03-08 05:50:34 -0600 | [diff] [blame] | 2718 | switch (dss_get_dispc_clk_source()) { |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 2719 | case OMAP_DSS_CLK_SRC_FCK: |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 2720 | r = clk_get_rate(dispc.dss_clk); |
Taneja, Archit | 66534e8 | 2011-03-08 05:50:34 -0600 | [diff] [blame] | 2721 | break; |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 2722 | case OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2723 | dsidev = dsi_get_dsidev_from_id(0); |
| 2724 | r = dsi_get_pll_hsdiv_dispc_rate(dsidev); |
Taneja, Archit | 66534e8 | 2011-03-08 05:50:34 -0600 | [diff] [blame] | 2725 | break; |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 2726 | case OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC: |
| 2727 | dsidev = dsi_get_dsidev_from_id(1); |
| 2728 | r = dsi_get_pll_hsdiv_dispc_rate(dsidev); |
| 2729 | break; |
Taneja, Archit | 66534e8 | 2011-03-08 05:50:34 -0600 | [diff] [blame] | 2730 | default: |
| 2731 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 2732 | return 0; |
Taneja, Archit | 66534e8 | 2011-03-08 05:50:34 -0600 | [diff] [blame] | 2733 | } |
| 2734 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2735 | return r; |
| 2736 | } |
| 2737 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2738 | unsigned long dispc_mgr_lclk_rate(enum omap_channel channel) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2739 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2740 | struct platform_device *dsidev; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2741 | int lcd; |
| 2742 | unsigned long r; |
| 2743 | u32 l; |
| 2744 | |
Murthy, Raghuveer | ce7fa5e | 2011-03-03 09:27:59 -0600 | [diff] [blame] | 2745 | l = dispc_read_reg(DISPC_DIVISORo(channel)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2746 | |
| 2747 | lcd = FLD_GET(l, 23, 16); |
| 2748 | |
Taneja, Archit | ea75159 | 2011-03-08 05:50:35 -0600 | [diff] [blame] | 2749 | switch (dss_get_lcd_clk_source(channel)) { |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 2750 | case OMAP_DSS_CLK_SRC_FCK: |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 2751 | r = clk_get_rate(dispc.dss_clk); |
Taneja, Archit | ea75159 | 2011-03-08 05:50:35 -0600 | [diff] [blame] | 2752 | break; |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 2753 | case OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2754 | dsidev = dsi_get_dsidev_from_id(0); |
| 2755 | r = dsi_get_pll_hsdiv_dispc_rate(dsidev); |
Taneja, Archit | ea75159 | 2011-03-08 05:50:35 -0600 | [diff] [blame] | 2756 | break; |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 2757 | case OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC: |
| 2758 | dsidev = dsi_get_dsidev_from_id(1); |
| 2759 | r = dsi_get_pll_hsdiv_dispc_rate(dsidev); |
| 2760 | break; |
Taneja, Archit | ea75159 | 2011-03-08 05:50:35 -0600 | [diff] [blame] | 2761 | default: |
| 2762 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 2763 | return 0; |
Taneja, Archit | ea75159 | 2011-03-08 05:50:35 -0600 | [diff] [blame] | 2764 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2765 | |
| 2766 | return r / lcd; |
| 2767 | } |
| 2768 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2769 | unsigned long dispc_mgr_pclk_rate(enum omap_channel channel) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2770 | { |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2771 | unsigned long r; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2772 | |
Archit Taneja | c3dc6a7 | 2011-09-13 18:28:41 +0530 | [diff] [blame] | 2773 | if (dispc_mgr_is_lcd(channel)) { |
| 2774 | int pcd; |
| 2775 | u32 l; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2776 | |
Archit Taneja | c3dc6a7 | 2011-09-13 18:28:41 +0530 | [diff] [blame] | 2777 | l = dispc_read_reg(DISPC_DIVISORo(channel)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2778 | |
Archit Taneja | c3dc6a7 | 2011-09-13 18:28:41 +0530 | [diff] [blame] | 2779 | pcd = FLD_GET(l, 7, 0); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2780 | |
Archit Taneja | c3dc6a7 | 2011-09-13 18:28:41 +0530 | [diff] [blame] | 2781 | r = dispc_mgr_lclk_rate(channel); |
| 2782 | |
| 2783 | return r / pcd; |
| 2784 | } else { |
Archit Taneja | 3fa03ba | 2012-04-09 15:06:41 +0530 | [diff] [blame] | 2785 | enum dss_hdmi_venc_clk_source_select source; |
Archit Taneja | c3dc6a7 | 2011-09-13 18:28:41 +0530 | [diff] [blame] | 2786 | |
Archit Taneja | 3fa03ba | 2012-04-09 15:06:41 +0530 | [diff] [blame] | 2787 | source = dss_get_hdmi_venc_clk_source(); |
| 2788 | |
| 2789 | switch (source) { |
| 2790 | case DSS_VENC_TV_CLK: |
Archit Taneja | c3dc6a7 | 2011-09-13 18:28:41 +0530 | [diff] [blame] | 2791 | return venc_get_pixel_clock(); |
Archit Taneja | 3fa03ba | 2012-04-09 15:06:41 +0530 | [diff] [blame] | 2792 | case DSS_HDMI_M_PCLK: |
Archit Taneja | c3dc6a7 | 2011-09-13 18:28:41 +0530 | [diff] [blame] | 2793 | return hdmi_get_pixel_clock(); |
| 2794 | default: |
| 2795 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 2796 | return 0; |
Archit Taneja | c3dc6a7 | 2011-09-13 18:28:41 +0530 | [diff] [blame] | 2797 | } |
| 2798 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2799 | } |
| 2800 | |
Chandrabhanu Mahapatra | 8b53d99 | 2012-04-23 12:16:50 +0530 | [diff] [blame] | 2801 | unsigned long dispc_core_clk_rate(void) |
| 2802 | { |
| 2803 | int lcd; |
| 2804 | unsigned long fclk = dispc_fclk_rate(); |
| 2805 | |
| 2806 | if (dss_has_feature(FEAT_CORE_CLK_DIV)) |
| 2807 | lcd = REG_GET(DISPC_DIVISOR, 23, 16); |
| 2808 | else |
| 2809 | lcd = REG_GET(DISPC_DIVISORo(OMAP_DSS_CHANNEL_LCD), 23, 16); |
| 2810 | |
| 2811 | return fclk / lcd; |
| 2812 | } |
| 2813 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2814 | void dispc_dump_clocks(struct seq_file *s) |
| 2815 | { |
| 2816 | int lcd, pcd; |
Murthy, Raghuveer | 0cf35df | 2011-03-03 09:28:00 -0600 | [diff] [blame] | 2817 | u32 l; |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 2818 | enum omap_dss_clk_source dispc_clk_src = dss_get_dispc_clk_source(); |
| 2819 | enum omap_dss_clk_source lcd_clk_src; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2820 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 2821 | if (dispc_runtime_get()) |
| 2822 | return; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2823 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2824 | seq_printf(s, "- DISPC -\n"); |
| 2825 | |
Archit Taneja | 067a57e | 2011-03-02 11:57:25 +0530 | [diff] [blame] | 2826 | seq_printf(s, "dispc fclk source = %s (%s)\n", |
| 2827 | dss_get_generic_clk_source_name(dispc_clk_src), |
| 2828 | dss_feat_get_clk_source_name(dispc_clk_src)); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2829 | |
| 2830 | seq_printf(s, "fck\t\t%-16lu\n", dispc_fclk_rate()); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2831 | |
Murthy, Raghuveer | 0cf35df | 2011-03-03 09:28:00 -0600 | [diff] [blame] | 2832 | if (dss_has_feature(FEAT_CORE_CLK_DIV)) { |
| 2833 | seq_printf(s, "- DISPC-CORE-CLK -\n"); |
| 2834 | l = dispc_read_reg(DISPC_DIVISOR); |
| 2835 | lcd = FLD_GET(l, 23, 16); |
| 2836 | |
| 2837 | seq_printf(s, "lck\t\t%-16lulck div\t%u\n", |
| 2838 | (dispc_fclk_rate()/lcd), lcd); |
| 2839 | } |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2840 | seq_printf(s, "- LCD1 -\n"); |
| 2841 | |
Taneja, Archit | ea75159 | 2011-03-08 05:50:35 -0600 | [diff] [blame] | 2842 | lcd_clk_src = dss_get_lcd_clk_source(OMAP_DSS_CHANNEL_LCD); |
| 2843 | |
| 2844 | seq_printf(s, "lcd1_clk source = %s (%s)\n", |
| 2845 | dss_get_generic_clk_source_name(lcd_clk_src), |
| 2846 | dss_feat_get_clk_source_name(lcd_clk_src)); |
| 2847 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2848 | dispc_mgr_get_lcd_divisor(OMAP_DSS_CHANNEL_LCD, &lcd, &pcd); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2849 | |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 2850 | seq_printf(s, "lck\t\t%-16lulck div\t%u\n", |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2851 | dispc_mgr_lclk_rate(OMAP_DSS_CHANNEL_LCD), lcd); |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 2852 | seq_printf(s, "pck\t\t%-16lupck div\t%u\n", |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2853 | dispc_mgr_pclk_rate(OMAP_DSS_CHANNEL_LCD), pcd); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2854 | if (dss_has_feature(FEAT_MGR_LCD2)) { |
| 2855 | seq_printf(s, "- LCD2 -\n"); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2856 | |
Taneja, Archit | ea75159 | 2011-03-08 05:50:35 -0600 | [diff] [blame] | 2857 | lcd_clk_src = dss_get_lcd_clk_source(OMAP_DSS_CHANNEL_LCD2); |
| 2858 | |
| 2859 | seq_printf(s, "lcd2_clk source = %s (%s)\n", |
| 2860 | dss_get_generic_clk_source_name(lcd_clk_src), |
| 2861 | dss_feat_get_clk_source_name(lcd_clk_src)); |
| 2862 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2863 | dispc_mgr_get_lcd_divisor(OMAP_DSS_CHANNEL_LCD2, &lcd, &pcd); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2864 | |
| 2865 | seq_printf(s, "lck\t\t%-16lulck div\t%u\n", |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2866 | dispc_mgr_lclk_rate(OMAP_DSS_CHANNEL_LCD2), lcd); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2867 | seq_printf(s, "pck\t\t%-16lupck div\t%u\n", |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 2868 | dispc_mgr_pclk_rate(OMAP_DSS_CHANNEL_LCD2), pcd); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2869 | } |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 2870 | |
| 2871 | dispc_runtime_put(); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2872 | } |
| 2873 | |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 2874 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS |
| 2875 | void dispc_dump_irqs(struct seq_file *s) |
| 2876 | { |
| 2877 | unsigned long flags; |
| 2878 | struct dispc_irq_stats stats; |
| 2879 | |
| 2880 | spin_lock_irqsave(&dispc.irq_stats_lock, flags); |
| 2881 | |
| 2882 | stats = dispc.irq_stats; |
| 2883 | memset(&dispc.irq_stats, 0, sizeof(dispc.irq_stats)); |
| 2884 | dispc.irq_stats.last_reset = jiffies; |
| 2885 | |
| 2886 | spin_unlock_irqrestore(&dispc.irq_stats_lock, flags); |
| 2887 | |
| 2888 | seq_printf(s, "period %u ms\n", |
| 2889 | jiffies_to_msecs(jiffies - stats.last_reset)); |
| 2890 | |
| 2891 | seq_printf(s, "irqs %d\n", stats.irq_count); |
| 2892 | #define PIS(x) \ |
| 2893 | seq_printf(s, "%-20s %10d\n", #x, stats.irqs[ffs(DISPC_IRQ_##x)-1]); |
| 2894 | |
| 2895 | PIS(FRAMEDONE); |
| 2896 | PIS(VSYNC); |
| 2897 | PIS(EVSYNC_EVEN); |
| 2898 | PIS(EVSYNC_ODD); |
| 2899 | PIS(ACBIAS_COUNT_STAT); |
| 2900 | PIS(PROG_LINE_NUM); |
| 2901 | PIS(GFX_FIFO_UNDERFLOW); |
| 2902 | PIS(GFX_END_WIN); |
| 2903 | PIS(PAL_GAMMA_MASK); |
| 2904 | PIS(OCP_ERR); |
| 2905 | PIS(VID1_FIFO_UNDERFLOW); |
| 2906 | PIS(VID1_END_WIN); |
| 2907 | PIS(VID2_FIFO_UNDERFLOW); |
| 2908 | PIS(VID2_END_WIN); |
Archit Taneja | b8c095b | 2011-09-13 18:20:33 +0530 | [diff] [blame] | 2909 | if (dss_feat_get_num_ovls() > 3) { |
| 2910 | PIS(VID3_FIFO_UNDERFLOW); |
| 2911 | PIS(VID3_END_WIN); |
| 2912 | } |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 2913 | PIS(SYNC_LOST); |
| 2914 | PIS(SYNC_LOST_DIGIT); |
| 2915 | PIS(WAKEUP); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2916 | if (dss_has_feature(FEAT_MGR_LCD2)) { |
| 2917 | PIS(FRAMEDONE2); |
| 2918 | PIS(VSYNC2); |
| 2919 | PIS(ACBIAS_COUNT_STAT2); |
| 2920 | PIS(SYNC_LOST2); |
| 2921 | } |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 2922 | #undef PIS |
| 2923 | } |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 2924 | #endif |
| 2925 | |
Tomi Valkeinen | e40402c | 2012-03-02 18:01:07 +0200 | [diff] [blame] | 2926 | static void dispc_dump_regs(struct seq_file *s) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2927 | { |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 2928 | int i, j; |
| 2929 | const char *mgr_names[] = { |
| 2930 | [OMAP_DSS_CHANNEL_LCD] = "LCD", |
| 2931 | [OMAP_DSS_CHANNEL_DIGIT] = "TV", |
| 2932 | [OMAP_DSS_CHANNEL_LCD2] = "LCD2", |
| 2933 | }; |
| 2934 | const char *ovl_names[] = { |
| 2935 | [OMAP_DSS_GFX] = "GFX", |
| 2936 | [OMAP_DSS_VIDEO1] = "VID1", |
| 2937 | [OMAP_DSS_VIDEO2] = "VID2", |
Archit Taneja | b8c095b | 2011-09-13 18:20:33 +0530 | [diff] [blame] | 2938 | [OMAP_DSS_VIDEO3] = "VID3", |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 2939 | }; |
| 2940 | const char **p_names; |
| 2941 | |
Archit Taneja | 9b372c2 | 2011-05-06 11:45:49 +0530 | [diff] [blame] | 2942 | #define DUMPREG(r) seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(r)) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2943 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 2944 | if (dispc_runtime_get()) |
| 2945 | return; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2946 | |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 2947 | /* DISPC common registers */ |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2948 | DUMPREG(DISPC_REVISION); |
| 2949 | DUMPREG(DISPC_SYSCONFIG); |
| 2950 | DUMPREG(DISPC_SYSSTATUS); |
| 2951 | DUMPREG(DISPC_IRQSTATUS); |
| 2952 | DUMPREG(DISPC_IRQENABLE); |
| 2953 | DUMPREG(DISPC_CONTROL); |
| 2954 | DUMPREG(DISPC_CONFIG); |
| 2955 | DUMPREG(DISPC_CAPABLE); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2956 | DUMPREG(DISPC_LINE_STATUS); |
| 2957 | DUMPREG(DISPC_LINE_NUMBER); |
Archit Taneja | 11354dd | 2011-09-26 11:47:29 +0530 | [diff] [blame] | 2958 | if (dss_has_feature(FEAT_ALPHA_FIXED_ZORDER) || |
| 2959 | dss_has_feature(FEAT_ALPHA_FREE_ZORDER)) |
Tomi Valkeinen | 332e9d7 | 2011-05-27 14:22:16 +0300 | [diff] [blame] | 2960 | DUMPREG(DISPC_GLOBAL_ALPHA); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2961 | if (dss_has_feature(FEAT_MGR_LCD2)) { |
| 2962 | DUMPREG(DISPC_CONTROL2); |
| 2963 | DUMPREG(DISPC_CONFIG2); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2964 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2965 | |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 2966 | #undef DUMPREG |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2967 | |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 2968 | #define DISPC_REG(i, name) name(i) |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 2969 | #define DUMPREG(i, r) seq_printf(s, "%s(%s)%*s %08x\n", #r, p_names[i], \ |
| 2970 | 48 - strlen(#r) - strlen(p_names[i]), " ", \ |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 2971 | dispc_read_reg(DISPC_REG(i, r))) |
| 2972 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 2973 | p_names = mgr_names; |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 2974 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 2975 | /* DISPC channel specific registers */ |
| 2976 | for (i = 0; i < dss_feat_get_num_mgrs(); i++) { |
| 2977 | DUMPREG(i, DISPC_DEFAULT_COLOR); |
| 2978 | DUMPREG(i, DISPC_TRANS_COLOR); |
| 2979 | DUMPREG(i, DISPC_SIZE_MGR); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 2980 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 2981 | if (i == OMAP_DSS_CHANNEL_DIGIT) |
| 2982 | continue; |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 2983 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 2984 | DUMPREG(i, DISPC_DEFAULT_COLOR); |
| 2985 | DUMPREG(i, DISPC_TRANS_COLOR); |
| 2986 | DUMPREG(i, DISPC_TIMING_H); |
| 2987 | DUMPREG(i, DISPC_TIMING_V); |
| 2988 | DUMPREG(i, DISPC_POL_FREQ); |
| 2989 | DUMPREG(i, DISPC_DIVISORo); |
| 2990 | DUMPREG(i, DISPC_SIZE_MGR); |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 2991 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 2992 | DUMPREG(i, DISPC_DATA_CYCLE1); |
| 2993 | DUMPREG(i, DISPC_DATA_CYCLE2); |
| 2994 | DUMPREG(i, DISPC_DATA_CYCLE3); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 2995 | |
Tomi Valkeinen | 332e9d7 | 2011-05-27 14:22:16 +0300 | [diff] [blame] | 2996 | if (dss_has_feature(FEAT_CPR)) { |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 2997 | DUMPREG(i, DISPC_CPR_COEF_R); |
| 2998 | DUMPREG(i, DISPC_CPR_COEF_G); |
| 2999 | DUMPREG(i, DISPC_CPR_COEF_B); |
Tomi Valkeinen | 332e9d7 | 2011-05-27 14:22:16 +0300 | [diff] [blame] | 3000 | } |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 3001 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3002 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 3003 | p_names = ovl_names; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3004 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 3005 | for (i = 0; i < dss_feat_get_num_ovls(); i++) { |
| 3006 | DUMPREG(i, DISPC_OVL_BA0); |
| 3007 | DUMPREG(i, DISPC_OVL_BA1); |
| 3008 | DUMPREG(i, DISPC_OVL_POSITION); |
| 3009 | DUMPREG(i, DISPC_OVL_SIZE); |
| 3010 | DUMPREG(i, DISPC_OVL_ATTRIBUTES); |
| 3011 | DUMPREG(i, DISPC_OVL_FIFO_THRESHOLD); |
| 3012 | DUMPREG(i, DISPC_OVL_FIFO_SIZE_STATUS); |
| 3013 | DUMPREG(i, DISPC_OVL_ROW_INC); |
| 3014 | DUMPREG(i, DISPC_OVL_PIXEL_INC); |
| 3015 | if (dss_has_feature(FEAT_PRELOAD)) |
| 3016 | DUMPREG(i, DISPC_OVL_PRELOAD); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3017 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 3018 | if (i == OMAP_DSS_GFX) { |
| 3019 | DUMPREG(i, DISPC_OVL_WINDOW_SKIP); |
| 3020 | DUMPREG(i, DISPC_OVL_TABLE_BA); |
| 3021 | continue; |
| 3022 | } |
| 3023 | |
| 3024 | DUMPREG(i, DISPC_OVL_FIR); |
| 3025 | DUMPREG(i, DISPC_OVL_PICTURE_SIZE); |
| 3026 | DUMPREG(i, DISPC_OVL_ACCU0); |
| 3027 | DUMPREG(i, DISPC_OVL_ACCU1); |
| 3028 | if (dss_has_feature(FEAT_HANDLE_UV_SEPARATE)) { |
| 3029 | DUMPREG(i, DISPC_OVL_BA0_UV); |
| 3030 | DUMPREG(i, DISPC_OVL_BA1_UV); |
| 3031 | DUMPREG(i, DISPC_OVL_FIR2); |
| 3032 | DUMPREG(i, DISPC_OVL_ACCU2_0); |
| 3033 | DUMPREG(i, DISPC_OVL_ACCU2_1); |
| 3034 | } |
| 3035 | if (dss_has_feature(FEAT_ATTR2)) |
| 3036 | DUMPREG(i, DISPC_OVL_ATTRIBUTES2); |
| 3037 | if (dss_has_feature(FEAT_PRELOAD)) |
| 3038 | DUMPREG(i, DISPC_OVL_PRELOAD); |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 3039 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3040 | |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 3041 | #undef DISPC_REG |
| 3042 | #undef DUMPREG |
| 3043 | |
| 3044 | #define DISPC_REG(plane, name, i) name(plane, i) |
| 3045 | #define DUMPREG(plane, name, i) \ |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 3046 | seq_printf(s, "%s_%d(%s)%*s %08x\n", #name, i, p_names[plane], \ |
| 3047 | 46 - strlen(#name) - strlen(p_names[plane]), " ", \ |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 3048 | dispc_read_reg(DISPC_REG(plane, name, i))) |
| 3049 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 3050 | /* Video pipeline coefficient registers */ |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 3051 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 3052 | /* start from OMAP_DSS_VIDEO1 */ |
| 3053 | for (i = 1; i < dss_feat_get_num_ovls(); i++) { |
| 3054 | for (j = 0; j < 8; j++) |
| 3055 | DUMPREG(i, DISPC_OVL_FIR_COEF_H, j); |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 3056 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 3057 | for (j = 0; j < 8; j++) |
| 3058 | DUMPREG(i, DISPC_OVL_FIR_COEF_HV, j); |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 3059 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 3060 | for (j = 0; j < 5; j++) |
| 3061 | DUMPREG(i, DISPC_OVL_CONV_COEF, j); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3062 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 3063 | if (dss_has_feature(FEAT_FIR_COEF_V)) { |
| 3064 | for (j = 0; j < 8; j++) |
| 3065 | DUMPREG(i, DISPC_OVL_FIR_COEF_V, j); |
| 3066 | } |
Amber Jain | ab5ca07 | 2011-05-19 19:47:53 +0530 | [diff] [blame] | 3067 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 3068 | if (dss_has_feature(FEAT_HANDLE_UV_SEPARATE)) { |
| 3069 | for (j = 0; j < 8; j++) |
| 3070 | DUMPREG(i, DISPC_OVL_FIR_COEF_H2, j); |
Amber Jain | ab5ca07 | 2011-05-19 19:47:53 +0530 | [diff] [blame] | 3071 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 3072 | for (j = 0; j < 8; j++) |
| 3073 | DUMPREG(i, DISPC_OVL_FIR_COEF_HV2, j); |
Amber Jain | ab5ca07 | 2011-05-19 19:47:53 +0530 | [diff] [blame] | 3074 | |
Archit Taneja | 4dd2da1 | 2011-08-05 19:06:01 +0530 | [diff] [blame] | 3075 | for (j = 0; j < 8; j++) |
| 3076 | DUMPREG(i, DISPC_OVL_FIR_COEF_V2, j); |
| 3077 | } |
Tomi Valkeinen | 332e9d7 | 2011-05-27 14:22:16 +0300 | [diff] [blame] | 3078 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3079 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 3080 | dispc_runtime_put(); |
Archit Taneja | 5010be8 | 2011-08-05 19:06:00 +0530 | [diff] [blame] | 3081 | |
| 3082 | #undef DISPC_REG |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3083 | #undef DUMPREG |
| 3084 | } |
| 3085 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 3086 | static void _dispc_mgr_set_pol_freq(enum omap_channel channel, bool onoff, |
| 3087 | bool rf, bool ieo, bool ipc, bool ihs, bool ivs, u8 acbi, |
| 3088 | u8 acb) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3089 | { |
| 3090 | u32 l = 0; |
| 3091 | |
| 3092 | DSSDBG("onoff %d rf %d ieo %d ipc %d ihs %d ivs %d acbi %d acb %d\n", |
| 3093 | onoff, rf, ieo, ipc, ihs, ivs, acbi, acb); |
| 3094 | |
| 3095 | l |= FLD_VAL(onoff, 17, 17); |
| 3096 | l |= FLD_VAL(rf, 16, 16); |
| 3097 | l |= FLD_VAL(ieo, 15, 15); |
| 3098 | l |= FLD_VAL(ipc, 14, 14); |
| 3099 | l |= FLD_VAL(ihs, 13, 13); |
| 3100 | l |= FLD_VAL(ivs, 12, 12); |
| 3101 | l |= FLD_VAL(acbi, 11, 8); |
| 3102 | l |= FLD_VAL(acb, 7, 0); |
| 3103 | |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 3104 | dispc_write_reg(DISPC_POL_FREQ(channel), l); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3105 | } |
| 3106 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 3107 | void dispc_mgr_set_pol_freq(enum omap_channel channel, |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 3108 | enum omap_panel_config config, u8 acbi, u8 acb) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3109 | { |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 3110 | _dispc_mgr_set_pol_freq(channel, (config & OMAP_DSS_LCD_ONOFF) != 0, |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3111 | (config & OMAP_DSS_LCD_RF) != 0, |
| 3112 | (config & OMAP_DSS_LCD_IEO) != 0, |
| 3113 | (config & OMAP_DSS_LCD_IPC) != 0, |
| 3114 | (config & OMAP_DSS_LCD_IHS) != 0, |
| 3115 | (config & OMAP_DSS_LCD_IVS) != 0, |
| 3116 | acbi, acb); |
| 3117 | } |
| 3118 | |
| 3119 | /* with fck as input clock rate, find dispc dividers that produce req_pck */ |
| 3120 | void dispc_find_clk_divs(bool is_tft, unsigned long req_pck, unsigned long fck, |
| 3121 | struct dispc_clock_info *cinfo) |
| 3122 | { |
Tomi Valkeinen | 9eaaf20 | 2011-08-29 15:56:04 +0300 | [diff] [blame] | 3123 | u16 pcd_min, pcd_max; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3124 | unsigned long best_pck; |
| 3125 | u16 best_ld, cur_ld; |
| 3126 | u16 best_pd, cur_pd; |
| 3127 | |
Tomi Valkeinen | 9eaaf20 | 2011-08-29 15:56:04 +0300 | [diff] [blame] | 3128 | pcd_min = dss_feat_get_param_min(FEAT_PARAM_DSS_PCD); |
| 3129 | pcd_max = dss_feat_get_param_max(FEAT_PARAM_DSS_PCD); |
| 3130 | |
| 3131 | if (!is_tft) |
| 3132 | pcd_min = 3; |
| 3133 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3134 | best_pck = 0; |
| 3135 | best_ld = 0; |
| 3136 | best_pd = 0; |
| 3137 | |
| 3138 | for (cur_ld = 1; cur_ld <= 255; ++cur_ld) { |
| 3139 | unsigned long lck = fck / cur_ld; |
| 3140 | |
Tomi Valkeinen | 9eaaf20 | 2011-08-29 15:56:04 +0300 | [diff] [blame] | 3141 | for (cur_pd = pcd_min; cur_pd <= pcd_max; ++cur_pd) { |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3142 | unsigned long pck = lck / cur_pd; |
| 3143 | long old_delta = abs(best_pck - req_pck); |
| 3144 | long new_delta = abs(pck - req_pck); |
| 3145 | |
| 3146 | if (best_pck == 0 || new_delta < old_delta) { |
| 3147 | best_pck = pck; |
| 3148 | best_ld = cur_ld; |
| 3149 | best_pd = cur_pd; |
| 3150 | |
| 3151 | if (pck == req_pck) |
| 3152 | goto found; |
| 3153 | } |
| 3154 | |
| 3155 | if (pck < req_pck) |
| 3156 | break; |
| 3157 | } |
| 3158 | |
| 3159 | if (lck / pcd_min < req_pck) |
| 3160 | break; |
| 3161 | } |
| 3162 | |
| 3163 | found: |
| 3164 | cinfo->lck_div = best_ld; |
| 3165 | cinfo->pck_div = best_pd; |
| 3166 | cinfo->lck = fck / cinfo->lck_div; |
| 3167 | cinfo->pck = cinfo->lck / cinfo->pck_div; |
| 3168 | } |
| 3169 | |
| 3170 | /* calculate clock rates using dividers in cinfo */ |
| 3171 | int dispc_calc_clock_rates(unsigned long dispc_fclk_rate, |
| 3172 | struct dispc_clock_info *cinfo) |
| 3173 | { |
| 3174 | if (cinfo->lck_div > 255 || cinfo->lck_div == 0) |
| 3175 | return -EINVAL; |
Tomi Valkeinen | 9eaaf20 | 2011-08-29 15:56:04 +0300 | [diff] [blame] | 3176 | if (cinfo->pck_div < 1 || cinfo->pck_div > 255) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3177 | return -EINVAL; |
| 3178 | |
| 3179 | cinfo->lck = dispc_fclk_rate / cinfo->lck_div; |
| 3180 | cinfo->pck = cinfo->lck / cinfo->pck_div; |
| 3181 | |
| 3182 | return 0; |
| 3183 | } |
| 3184 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 3185 | int dispc_mgr_set_clock_div(enum omap_channel channel, |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 3186 | struct dispc_clock_info *cinfo) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3187 | { |
| 3188 | DSSDBG("lck = %lu (%u)\n", cinfo->lck, cinfo->lck_div); |
| 3189 | DSSDBG("pck = %lu (%u)\n", cinfo->pck, cinfo->pck_div); |
| 3190 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 3191 | dispc_mgr_set_lcd_divisor(channel, cinfo->lck_div, cinfo->pck_div); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3192 | |
| 3193 | return 0; |
| 3194 | } |
| 3195 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 3196 | int dispc_mgr_get_clock_div(enum omap_channel channel, |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 3197 | struct dispc_clock_info *cinfo) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3198 | { |
| 3199 | unsigned long fck; |
| 3200 | |
| 3201 | fck = dispc_fclk_rate(); |
| 3202 | |
Murthy, Raghuveer | ce7fa5e | 2011-03-03 09:27:59 -0600 | [diff] [blame] | 3203 | cinfo->lck_div = REG_GET(DISPC_DIVISORo(channel), 23, 16); |
| 3204 | cinfo->pck_div = REG_GET(DISPC_DIVISORo(channel), 7, 0); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3205 | |
| 3206 | cinfo->lck = fck / cinfo->lck_div; |
| 3207 | cinfo->pck = cinfo->lck / cinfo->pck_div; |
| 3208 | |
| 3209 | return 0; |
| 3210 | } |
| 3211 | |
| 3212 | /* dispc.irq_lock has to be locked by the caller */ |
| 3213 | static void _omap_dispc_set_irqs(void) |
| 3214 | { |
| 3215 | u32 mask; |
| 3216 | u32 old_mask; |
| 3217 | int i; |
| 3218 | struct omap_dispc_isr_data *isr_data; |
| 3219 | |
| 3220 | mask = dispc.irq_error_mask; |
| 3221 | |
| 3222 | for (i = 0; i < DISPC_MAX_NR_ISRS; i++) { |
| 3223 | isr_data = &dispc.registered_isr[i]; |
| 3224 | |
| 3225 | if (isr_data->isr == NULL) |
| 3226 | continue; |
| 3227 | |
| 3228 | mask |= isr_data->mask; |
| 3229 | } |
| 3230 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3231 | old_mask = dispc_read_reg(DISPC_IRQENABLE); |
| 3232 | /* clear the irqstatus for newly enabled irqs */ |
| 3233 | dispc_write_reg(DISPC_IRQSTATUS, (mask ^ old_mask) & mask); |
| 3234 | |
| 3235 | dispc_write_reg(DISPC_IRQENABLE, mask); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3236 | } |
| 3237 | |
| 3238 | int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask) |
| 3239 | { |
| 3240 | int i; |
| 3241 | int ret; |
| 3242 | unsigned long flags; |
| 3243 | struct omap_dispc_isr_data *isr_data; |
| 3244 | |
| 3245 | if (isr == NULL) |
| 3246 | return -EINVAL; |
| 3247 | |
| 3248 | spin_lock_irqsave(&dispc.irq_lock, flags); |
| 3249 | |
| 3250 | /* check for duplicate entry */ |
| 3251 | for (i = 0; i < DISPC_MAX_NR_ISRS; i++) { |
| 3252 | isr_data = &dispc.registered_isr[i]; |
| 3253 | if (isr_data->isr == isr && isr_data->arg == arg && |
| 3254 | isr_data->mask == mask) { |
| 3255 | ret = -EINVAL; |
| 3256 | goto err; |
| 3257 | } |
| 3258 | } |
| 3259 | |
| 3260 | isr_data = NULL; |
| 3261 | ret = -EBUSY; |
| 3262 | |
| 3263 | for (i = 0; i < DISPC_MAX_NR_ISRS; i++) { |
| 3264 | isr_data = &dispc.registered_isr[i]; |
| 3265 | |
| 3266 | if (isr_data->isr != NULL) |
| 3267 | continue; |
| 3268 | |
| 3269 | isr_data->isr = isr; |
| 3270 | isr_data->arg = arg; |
| 3271 | isr_data->mask = mask; |
| 3272 | ret = 0; |
| 3273 | |
| 3274 | break; |
| 3275 | } |
| 3276 | |
Tomi Valkeinen | b9cb098 | 2011-03-04 18:19:54 +0200 | [diff] [blame] | 3277 | if (ret) |
| 3278 | goto err; |
| 3279 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3280 | _omap_dispc_set_irqs(); |
| 3281 | |
| 3282 | spin_unlock_irqrestore(&dispc.irq_lock, flags); |
| 3283 | |
| 3284 | return 0; |
| 3285 | err: |
| 3286 | spin_unlock_irqrestore(&dispc.irq_lock, flags); |
| 3287 | |
| 3288 | return ret; |
| 3289 | } |
| 3290 | EXPORT_SYMBOL(omap_dispc_register_isr); |
| 3291 | |
| 3292 | int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask) |
| 3293 | { |
| 3294 | int i; |
| 3295 | unsigned long flags; |
| 3296 | int ret = -EINVAL; |
| 3297 | struct omap_dispc_isr_data *isr_data; |
| 3298 | |
| 3299 | spin_lock_irqsave(&dispc.irq_lock, flags); |
| 3300 | |
| 3301 | for (i = 0; i < DISPC_MAX_NR_ISRS; i++) { |
| 3302 | isr_data = &dispc.registered_isr[i]; |
| 3303 | if (isr_data->isr != isr || isr_data->arg != arg || |
| 3304 | isr_data->mask != mask) |
| 3305 | continue; |
| 3306 | |
| 3307 | /* found the correct isr */ |
| 3308 | |
| 3309 | isr_data->isr = NULL; |
| 3310 | isr_data->arg = NULL; |
| 3311 | isr_data->mask = 0; |
| 3312 | |
| 3313 | ret = 0; |
| 3314 | break; |
| 3315 | } |
| 3316 | |
| 3317 | if (ret == 0) |
| 3318 | _omap_dispc_set_irqs(); |
| 3319 | |
| 3320 | spin_unlock_irqrestore(&dispc.irq_lock, flags); |
| 3321 | |
| 3322 | return ret; |
| 3323 | } |
| 3324 | EXPORT_SYMBOL(omap_dispc_unregister_isr); |
| 3325 | |
| 3326 | #ifdef DEBUG |
| 3327 | static void print_irq_status(u32 status) |
| 3328 | { |
| 3329 | if ((status & dispc.irq_error_mask) == 0) |
| 3330 | return; |
| 3331 | |
| 3332 | printk(KERN_DEBUG "DISPC IRQ: 0x%x: ", status); |
| 3333 | |
| 3334 | #define PIS(x) \ |
| 3335 | if (status & DISPC_IRQ_##x) \ |
| 3336 | printk(#x " "); |
| 3337 | PIS(GFX_FIFO_UNDERFLOW); |
| 3338 | PIS(OCP_ERR); |
| 3339 | PIS(VID1_FIFO_UNDERFLOW); |
| 3340 | PIS(VID2_FIFO_UNDERFLOW); |
Archit Taneja | b8c095b | 2011-09-13 18:20:33 +0530 | [diff] [blame] | 3341 | if (dss_feat_get_num_ovls() > 3) |
| 3342 | PIS(VID3_FIFO_UNDERFLOW); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3343 | PIS(SYNC_LOST); |
| 3344 | PIS(SYNC_LOST_DIGIT); |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 3345 | if (dss_has_feature(FEAT_MGR_LCD2)) |
| 3346 | PIS(SYNC_LOST2); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3347 | #undef PIS |
| 3348 | |
| 3349 | printk("\n"); |
| 3350 | } |
| 3351 | #endif |
| 3352 | |
| 3353 | /* Called from dss.c. Note that we don't touch clocks here, |
| 3354 | * but we presume they are on because we got an IRQ. However, |
| 3355 | * an irq handler may turn the clocks off, so we may not have |
| 3356 | * clock later in the function. */ |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 3357 | static irqreturn_t omap_dispc_irq_handler(int irq, void *arg) |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3358 | { |
| 3359 | int i; |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 3360 | u32 irqstatus, irqenable; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3361 | u32 handledirqs = 0; |
| 3362 | u32 unhandled_errors; |
| 3363 | struct omap_dispc_isr_data *isr_data; |
| 3364 | struct omap_dispc_isr_data registered_isr[DISPC_MAX_NR_ISRS]; |
| 3365 | |
| 3366 | spin_lock(&dispc.irq_lock); |
| 3367 | |
| 3368 | irqstatus = dispc_read_reg(DISPC_IRQSTATUS); |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 3369 | irqenable = dispc_read_reg(DISPC_IRQENABLE); |
| 3370 | |
| 3371 | /* IRQ is not for us */ |
| 3372 | if (!(irqstatus & irqenable)) { |
| 3373 | spin_unlock(&dispc.irq_lock); |
| 3374 | return IRQ_NONE; |
| 3375 | } |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3376 | |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 3377 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS |
| 3378 | spin_lock(&dispc.irq_stats_lock); |
| 3379 | dispc.irq_stats.irq_count++; |
| 3380 | dss_collect_irq_stats(irqstatus, dispc.irq_stats.irqs); |
| 3381 | spin_unlock(&dispc.irq_stats_lock); |
| 3382 | #endif |
| 3383 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3384 | #ifdef DEBUG |
| 3385 | if (dss_debug) |
| 3386 | print_irq_status(irqstatus); |
| 3387 | #endif |
| 3388 | /* Ack the interrupt. Do it here before clocks are possibly turned |
| 3389 | * off */ |
| 3390 | dispc_write_reg(DISPC_IRQSTATUS, irqstatus); |
| 3391 | /* flush posted write */ |
| 3392 | dispc_read_reg(DISPC_IRQSTATUS); |
| 3393 | |
| 3394 | /* make a copy and unlock, so that isrs can unregister |
| 3395 | * themselves */ |
| 3396 | memcpy(registered_isr, dispc.registered_isr, |
| 3397 | sizeof(registered_isr)); |
| 3398 | |
| 3399 | spin_unlock(&dispc.irq_lock); |
| 3400 | |
| 3401 | for (i = 0; i < DISPC_MAX_NR_ISRS; i++) { |
| 3402 | isr_data = ®istered_isr[i]; |
| 3403 | |
| 3404 | if (!isr_data->isr) |
| 3405 | continue; |
| 3406 | |
| 3407 | if (isr_data->mask & irqstatus) { |
| 3408 | isr_data->isr(isr_data->arg, irqstatus); |
| 3409 | handledirqs |= isr_data->mask; |
| 3410 | } |
| 3411 | } |
| 3412 | |
| 3413 | spin_lock(&dispc.irq_lock); |
| 3414 | |
| 3415 | unhandled_errors = irqstatus & ~handledirqs & dispc.irq_error_mask; |
| 3416 | |
| 3417 | if (unhandled_errors) { |
| 3418 | dispc.error_irqs |= unhandled_errors; |
| 3419 | |
| 3420 | dispc.irq_error_mask &= ~unhandled_errors; |
| 3421 | _omap_dispc_set_irqs(); |
| 3422 | |
| 3423 | schedule_work(&dispc.error_work); |
| 3424 | } |
| 3425 | |
| 3426 | spin_unlock(&dispc.irq_lock); |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 3427 | |
| 3428 | return IRQ_HANDLED; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3429 | } |
| 3430 | |
| 3431 | static void dispc_error_worker(struct work_struct *work) |
| 3432 | { |
| 3433 | int i; |
| 3434 | u32 errors; |
| 3435 | unsigned long flags; |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 3436 | static const unsigned fifo_underflow_bits[] = { |
| 3437 | DISPC_IRQ_GFX_FIFO_UNDERFLOW, |
| 3438 | DISPC_IRQ_VID1_FIFO_UNDERFLOW, |
| 3439 | DISPC_IRQ_VID2_FIFO_UNDERFLOW, |
Archit Taneja | b8c095b | 2011-09-13 18:20:33 +0530 | [diff] [blame] | 3440 | DISPC_IRQ_VID3_FIFO_UNDERFLOW, |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 3441 | }; |
| 3442 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3443 | spin_lock_irqsave(&dispc.irq_lock, flags); |
| 3444 | errors = dispc.error_irqs; |
| 3445 | dispc.error_irqs = 0; |
| 3446 | spin_unlock_irqrestore(&dispc.irq_lock, flags); |
| 3447 | |
Dima Zavin | 13eae1f | 2011-06-27 10:31:05 -0700 | [diff] [blame] | 3448 | dispc_runtime_get(); |
| 3449 | |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 3450 | for (i = 0; i < omap_dss_get_num_overlays(); ++i) { |
| 3451 | struct omap_overlay *ovl; |
| 3452 | unsigned bit; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3453 | |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 3454 | ovl = omap_dss_get_overlay(i); |
| 3455 | bit = fifo_underflow_bits[i]; |
| 3456 | |
| 3457 | if (bit & errors) { |
| 3458 | DSSERR("FIFO UNDERFLOW on %s, disabling the overlay\n", |
| 3459 | ovl->name); |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 3460 | dispc_ovl_enable(ovl->id, false); |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 3461 | dispc_mgr_go(ovl->manager->id); |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 3462 | mdelay(50); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3463 | } |
| 3464 | } |
| 3465 | |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 3466 | for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) { |
| 3467 | struct omap_overlay_manager *mgr; |
| 3468 | unsigned bit; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3469 | |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 3470 | mgr = omap_dss_get_overlay_manager(i); |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 3471 | bit = mgr_desc[i].sync_lost_irq; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3472 | |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 3473 | if (bit & errors) { |
| 3474 | struct omap_dss_device *dssdev = mgr->device; |
| 3475 | bool enable; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3476 | |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 3477 | DSSERR("SYNC_LOST on channel %s, restarting the output " |
| 3478 | "with video overlays disabled\n", |
| 3479 | mgr->name); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3480 | |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 3481 | enable = dssdev->state == OMAP_DSS_DISPLAY_ACTIVE; |
| 3482 | dssdev->driver->disable(dssdev); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3483 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3484 | for (i = 0; i < omap_dss_get_num_overlays(); ++i) { |
| 3485 | struct omap_overlay *ovl; |
| 3486 | ovl = omap_dss_get_overlay(i); |
| 3487 | |
Tomi Valkeinen | fe3cc9d | 2011-08-15 11:51:50 +0300 | [diff] [blame] | 3488 | if (ovl->id != OMAP_DSS_GFX && |
| 3489 | ovl->manager == mgr) |
Tomi Valkeinen | f0e5caa | 2011-08-16 13:25:00 +0300 | [diff] [blame] | 3490 | dispc_ovl_enable(ovl->id, false); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3491 | } |
| 3492 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 3493 | dispc_mgr_go(mgr->id); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3494 | mdelay(50); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3495 | |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 3496 | if (enable) |
| 3497 | dssdev->driver->enable(dssdev); |
| 3498 | } |
| 3499 | } |
| 3500 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3501 | if (errors & DISPC_IRQ_OCP_ERR) { |
| 3502 | DSSERR("OCP_ERR\n"); |
| 3503 | for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) { |
| 3504 | struct omap_overlay_manager *mgr; |
| 3505 | mgr = omap_dss_get_overlay_manager(i); |
Rob Clark | 00f17e4 | 2011-12-11 14:02:27 -0600 | [diff] [blame] | 3506 | if (mgr->device && mgr->device->driver) |
| 3507 | mgr->device->driver->disable(mgr->device); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3508 | } |
| 3509 | } |
| 3510 | |
| 3511 | spin_lock_irqsave(&dispc.irq_lock, flags); |
| 3512 | dispc.irq_error_mask |= errors; |
| 3513 | _omap_dispc_set_irqs(); |
| 3514 | spin_unlock_irqrestore(&dispc.irq_lock, flags); |
Dima Zavin | 13eae1f | 2011-06-27 10:31:05 -0700 | [diff] [blame] | 3515 | |
| 3516 | dispc_runtime_put(); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3517 | } |
| 3518 | |
| 3519 | int omap_dispc_wait_for_irq_timeout(u32 irqmask, unsigned long timeout) |
| 3520 | { |
| 3521 | void dispc_irq_wait_handler(void *data, u32 mask) |
| 3522 | { |
| 3523 | complete((struct completion *)data); |
| 3524 | } |
| 3525 | |
| 3526 | int r; |
| 3527 | DECLARE_COMPLETION_ONSTACK(completion); |
| 3528 | |
| 3529 | r = omap_dispc_register_isr(dispc_irq_wait_handler, &completion, |
| 3530 | irqmask); |
| 3531 | |
| 3532 | if (r) |
| 3533 | return r; |
| 3534 | |
| 3535 | timeout = wait_for_completion_timeout(&completion, timeout); |
| 3536 | |
| 3537 | omap_dispc_unregister_isr(dispc_irq_wait_handler, &completion, irqmask); |
| 3538 | |
| 3539 | if (timeout == 0) |
| 3540 | return -ETIMEDOUT; |
| 3541 | |
| 3542 | if (timeout == -ERESTARTSYS) |
| 3543 | return -ERESTARTSYS; |
| 3544 | |
| 3545 | return 0; |
| 3546 | } |
| 3547 | |
| 3548 | int omap_dispc_wait_for_irq_interruptible_timeout(u32 irqmask, |
| 3549 | unsigned long timeout) |
| 3550 | { |
| 3551 | void dispc_irq_wait_handler(void *data, u32 mask) |
| 3552 | { |
| 3553 | complete((struct completion *)data); |
| 3554 | } |
| 3555 | |
| 3556 | int r; |
| 3557 | DECLARE_COMPLETION_ONSTACK(completion); |
| 3558 | |
| 3559 | r = omap_dispc_register_isr(dispc_irq_wait_handler, &completion, |
| 3560 | irqmask); |
| 3561 | |
| 3562 | if (r) |
| 3563 | return r; |
| 3564 | |
| 3565 | timeout = wait_for_completion_interruptible_timeout(&completion, |
| 3566 | timeout); |
| 3567 | |
| 3568 | omap_dispc_unregister_isr(dispc_irq_wait_handler, &completion, irqmask); |
| 3569 | |
| 3570 | if (timeout == 0) |
| 3571 | return -ETIMEDOUT; |
| 3572 | |
| 3573 | if (timeout == -ERESTARTSYS) |
| 3574 | return -ERESTARTSYS; |
| 3575 | |
| 3576 | return 0; |
| 3577 | } |
| 3578 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3579 | static void _omap_dispc_initialize_irq(void) |
| 3580 | { |
| 3581 | unsigned long flags; |
| 3582 | |
| 3583 | spin_lock_irqsave(&dispc.irq_lock, flags); |
| 3584 | |
| 3585 | memset(dispc.registered_isr, 0, sizeof(dispc.registered_isr)); |
| 3586 | |
| 3587 | dispc.irq_error_mask = DISPC_IRQ_MASK_ERROR; |
Sumit Semwal | 2a205f3 | 2010-12-02 11:27:12 +0000 | [diff] [blame] | 3588 | if (dss_has_feature(FEAT_MGR_LCD2)) |
| 3589 | dispc.irq_error_mask |= DISPC_IRQ_SYNC_LOST2; |
Archit Taneja | b8c095b | 2011-09-13 18:20:33 +0530 | [diff] [blame] | 3590 | if (dss_feat_get_num_ovls() > 3) |
| 3591 | dispc.irq_error_mask |= DISPC_IRQ_VID3_FIFO_UNDERFLOW; |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3592 | |
| 3593 | /* there's SYNC_LOST_DIGIT waiting after enabling the DSS, |
| 3594 | * so clear it */ |
| 3595 | dispc_write_reg(DISPC_IRQSTATUS, dispc_read_reg(DISPC_IRQSTATUS)); |
| 3596 | |
| 3597 | _omap_dispc_set_irqs(); |
| 3598 | |
| 3599 | spin_unlock_irqrestore(&dispc.irq_lock, flags); |
| 3600 | } |
| 3601 | |
| 3602 | void dispc_enable_sidle(void) |
| 3603 | { |
| 3604 | REG_FLD_MOD(DISPC_SYSCONFIG, 2, 4, 3); /* SIDLEMODE: smart idle */ |
| 3605 | } |
| 3606 | |
| 3607 | void dispc_disable_sidle(void) |
| 3608 | { |
| 3609 | REG_FLD_MOD(DISPC_SYSCONFIG, 1, 4, 3); /* SIDLEMODE: no idle */ |
| 3610 | } |
| 3611 | |
| 3612 | static void _omap_dispc_initial_config(void) |
| 3613 | { |
| 3614 | u32 l; |
| 3615 | |
Murthy, Raghuveer | 0cf35df | 2011-03-03 09:28:00 -0600 | [diff] [blame] | 3616 | /* Exclusively enable DISPC_CORE_CLK and set divider to 1 */ |
| 3617 | if (dss_has_feature(FEAT_CORE_CLK_DIV)) { |
| 3618 | l = dispc_read_reg(DISPC_DIVISOR); |
| 3619 | /* Use DISPC_DIVISOR.LCD, instead of DISPC_DIVISOR1.LCD */ |
| 3620 | l = FLD_MOD(l, 1, 0, 0); |
| 3621 | l = FLD_MOD(l, 1, 23, 16); |
| 3622 | dispc_write_reg(DISPC_DIVISOR, l); |
| 3623 | } |
| 3624 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3625 | /* FUNCGATED */ |
Archit Taneja | 6ced40b | 2010-12-02 11:27:13 +0000 | [diff] [blame] | 3626 | if (dss_has_feature(FEAT_FUNCGATED)) |
| 3627 | REG_FLD_MOD(DISPC_CONFIG, 1, 9, 9); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3628 | |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3629 | _dispc_setup_color_conv_coef(); |
| 3630 | |
| 3631 | dispc_set_loadmode(OMAP_DSS_LOAD_FRAME_ONLY); |
| 3632 | |
| 3633 | dispc_read_plane_fifo_sizes(); |
Tomi Valkeinen | 5ed8cf5 | 2011-06-21 09:35:36 +0300 | [diff] [blame] | 3634 | |
| 3635 | dispc_configure_burst_sizes(); |
Archit Taneja | 5412870 | 2011-09-08 11:29:17 +0530 | [diff] [blame] | 3636 | |
| 3637 | dispc_ovl_enable_zorder_planes(); |
Tomi Valkeinen | 80c3971 | 2009-11-12 11:41:42 +0200 | [diff] [blame] | 3638 | } |
| 3639 | |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3640 | /* DISPC HW IP initialisation */ |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 3641 | static int __init omap_dispchw_probe(struct platform_device *pdev) |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3642 | { |
| 3643 | u32 rev; |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 3644 | int r = 0; |
Senthilvadivu Guruswamy | ea9da36 | 2011-01-24 06:22:04 +0000 | [diff] [blame] | 3645 | struct resource *dispc_mem; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 3646 | struct clk *clk; |
Senthilvadivu Guruswamy | ea9da36 | 2011-01-24 06:22:04 +0000 | [diff] [blame] | 3647 | |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3648 | dispc.pdev = pdev; |
| 3649 | |
| 3650 | spin_lock_init(&dispc.irq_lock); |
| 3651 | |
| 3652 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS |
| 3653 | spin_lock_init(&dispc.irq_stats_lock); |
| 3654 | dispc.irq_stats.last_reset = jiffies; |
| 3655 | #endif |
| 3656 | |
| 3657 | INIT_WORK(&dispc.error_work, dispc_error_worker); |
| 3658 | |
Senthilvadivu Guruswamy | ea9da36 | 2011-01-24 06:22:04 +0000 | [diff] [blame] | 3659 | dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0); |
| 3660 | if (!dispc_mem) { |
| 3661 | DSSERR("can't get IORESOURCE_MEM DISPC\n"); |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 3662 | return -EINVAL; |
Senthilvadivu Guruswamy | ea9da36 | 2011-01-24 06:22:04 +0000 | [diff] [blame] | 3663 | } |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 3664 | |
Julia Lawall | 6e2a14d | 2012-01-24 14:00:45 +0100 | [diff] [blame] | 3665 | dispc.base = devm_ioremap(&pdev->dev, dispc_mem->start, |
| 3666 | resource_size(dispc_mem)); |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3667 | if (!dispc.base) { |
| 3668 | DSSERR("can't ioremap DISPC\n"); |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 3669 | return -ENOMEM; |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 3670 | } |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 3671 | |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 3672 | dispc.irq = platform_get_irq(dispc.pdev, 0); |
| 3673 | if (dispc.irq < 0) { |
| 3674 | DSSERR("platform_get_irq failed\n"); |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 3675 | return -ENODEV; |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 3676 | } |
| 3677 | |
Julia Lawall | 6e2a14d | 2012-01-24 14:00:45 +0100 | [diff] [blame] | 3678 | r = devm_request_irq(&pdev->dev, dispc.irq, omap_dispc_irq_handler, |
| 3679 | IRQF_SHARED, "OMAP DISPC", dispc.pdev); |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 3680 | if (r < 0) { |
| 3681 | DSSERR("request_irq failed\n"); |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 3682 | return r; |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3683 | } |
| 3684 | |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 3685 | clk = clk_get(&pdev->dev, "fck"); |
| 3686 | if (IS_ERR(clk)) { |
| 3687 | DSSERR("can't get fck\n"); |
| 3688 | r = PTR_ERR(clk); |
| 3689 | return r; |
| 3690 | } |
| 3691 | |
| 3692 | dispc.dss_clk = clk; |
| 3693 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 3694 | pm_runtime_enable(&pdev->dev); |
| 3695 | |
| 3696 | r = dispc_runtime_get(); |
| 3697 | if (r) |
| 3698 | goto err_runtime_get; |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3699 | |
| 3700 | _omap_dispc_initial_config(); |
| 3701 | |
| 3702 | _omap_dispc_initialize_irq(); |
| 3703 | |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3704 | rev = dispc_read_reg(DISPC_REVISION); |
Sumit Semwal | a06b62f | 2011-01-24 06:22:03 +0000 | [diff] [blame] | 3705 | dev_dbg(&pdev->dev, "OMAP DISPC rev %d.%d\n", |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3706 | FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0)); |
| 3707 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 3708 | dispc_runtime_put(); |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3709 | |
Tomi Valkeinen | e40402c | 2012-03-02 18:01:07 +0200 | [diff] [blame] | 3710 | dss_debugfs_create_file("dispc", dispc_dump_regs); |
| 3711 | |
| 3712 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS |
| 3713 | dss_debugfs_create_file("dispc_irq", dispc_dump_irqs); |
| 3714 | #endif |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3715 | return 0; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 3716 | |
| 3717 | err_runtime_get: |
| 3718 | pm_runtime_disable(&pdev->dev); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 3719 | clk_put(dispc.dss_clk); |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 3720 | return r; |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3721 | } |
| 3722 | |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 3723 | static int __exit omap_dispchw_remove(struct platform_device *pdev) |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3724 | { |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 3725 | pm_runtime_disable(&pdev->dev); |
| 3726 | |
| 3727 | clk_put(dispc.dss_clk); |
| 3728 | |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3729 | return 0; |
| 3730 | } |
| 3731 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 3732 | static int dispc_runtime_suspend(struct device *dev) |
| 3733 | { |
| 3734 | dispc_save_context(); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 3735 | |
| 3736 | return 0; |
| 3737 | } |
| 3738 | |
| 3739 | static int dispc_runtime_resume(struct device *dev) |
| 3740 | { |
Tomi Valkeinen | 49ea86f | 2011-06-01 15:54:06 +0300 | [diff] [blame] | 3741 | dispc_restore_context(); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 3742 | |
| 3743 | return 0; |
| 3744 | } |
| 3745 | |
| 3746 | static const struct dev_pm_ops dispc_pm_ops = { |
| 3747 | .runtime_suspend = dispc_runtime_suspend, |
| 3748 | .runtime_resume = dispc_runtime_resume, |
| 3749 | }; |
| 3750 | |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3751 | static struct platform_driver omap_dispchw_driver = { |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 3752 | .remove = __exit_p(omap_dispchw_remove), |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3753 | .driver = { |
| 3754 | .name = "omapdss_dispc", |
| 3755 | .owner = THIS_MODULE, |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 3756 | .pm = &dispc_pm_ops, |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3757 | }, |
| 3758 | }; |
| 3759 | |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 3760 | int __init dispc_init_platform_driver(void) |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3761 | { |
Tomi Valkeinen | 11436e1 | 2012-03-07 12:53:18 +0200 | [diff] [blame] | 3762 | return platform_driver_probe(&omap_dispchw_driver, omap_dispchw_probe); |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3763 | } |
| 3764 | |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 3765 | void __exit dispc_uninit_platform_driver(void) |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3766 | { |
Tomi Valkeinen | 04c742c | 2012-02-23 15:32:37 +0200 | [diff] [blame] | 3767 | platform_driver_unregister(&omap_dispchw_driver); |
Senthilvadivu Guruswamy | 060b6d9 | 2011-01-24 06:22:00 +0000 | [diff] [blame] | 3768 | } |