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