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