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