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