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