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