Clarence Ip | aac9f33 | 2016-08-31 15:46:35 -0400 | [diff] [blame] | 1 | /* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 12 | |
| 13 | #define pr_fmt(fmt) "[drm:%s:%d] " fmt, __func__, __LINE__ |
| 14 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 15 | #include <linux/debugfs.h> |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 16 | #include <uapi/drm/sde_drm.h> |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 17 | |
| 18 | #include "msm_prop.h" |
| 19 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 20 | #include "sde_kms.h" |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 21 | #include "sde_fence.h" |
Clarence Ip | c475b08 | 2016-06-26 09:27:23 -0400 | [diff] [blame] | 22 | #include "sde_formats.h" |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 23 | #include "sde_hw_sspp.h" |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 24 | #include "sde_trace.h" |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 25 | #include "sde_crtc.h" |
Lloyd Atkinson | 8772e20 | 2016-09-26 17:52:16 -0400 | [diff] [blame] | 26 | #include "sde_vbif.h" |
Alan Kwong | 83285fb | 2016-10-21 20:51:17 -0400 | [diff] [blame] | 27 | #include "sde_plane.h" |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 28 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 29 | #define SDE_DEBUG_PLANE(pl, fmt, ...) SDE_DEBUG("plane%d " fmt,\ |
| 30 | (pl) ? (pl)->base.base.id : -1, ##__VA_ARGS__) |
| 31 | |
| 32 | #define SDE_ERROR_PLANE(pl, fmt, ...) SDE_ERROR("plane%d " fmt,\ |
| 33 | (pl) ? (pl)->base.base.id : -1, ##__VA_ARGS__) |
| 34 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 35 | #define DECIMATED_DIMENSION(dim, deci) (((dim) + ((1 << (deci)) - 1)) >> (deci)) |
| 36 | #define PHASE_STEP_SHIFT 21 |
| 37 | #define PHASE_STEP_UNIT_SCALE ((int) (1 << PHASE_STEP_SHIFT)) |
| 38 | #define PHASE_RESIDUAL 15 |
| 39 | |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 40 | #define SHARP_STRENGTH_DEFAULT 32 |
| 41 | #define SHARP_EDGE_THR_DEFAULT 112 |
| 42 | #define SHARP_SMOOTH_THR_DEFAULT 8 |
| 43 | #define SHARP_NOISE_THR_DEFAULT 2 |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 44 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 45 | #define SDE_NAME_SIZE 12 |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 46 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 47 | #define SDE_PLANE_COLOR_FILL_FLAG BIT(31) |
| 48 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 49 | /* dirty bits for update function */ |
| 50 | #define SDE_PLANE_DIRTY_RECTS 0x1 |
| 51 | #define SDE_PLANE_DIRTY_FORMAT 0x2 |
| 52 | #define SDE_PLANE_DIRTY_SHARPEN 0x4 |
| 53 | #define SDE_PLANE_DIRTY_ALL 0xFFFFFFFF |
| 54 | |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 55 | /** |
| 56 | * enum sde_plane_qos - Different qos configurations for each pipe |
| 57 | * |
| 58 | * @SDE_PLANE_QOS_VBLANK_CTRL: Setup VBLANK qos for the pipe. |
| 59 | * @SDE_PLANE_QOS_VBLANK_AMORTIZE: Enables Amortization within pipe. |
| 60 | * this configuration is mutually exclusive from VBLANK_CTRL. |
| 61 | * @SDE_PLANE_QOS_PANIC_CTRL: Setup panic for the pipe. |
| 62 | */ |
| 63 | enum sde_plane_qos { |
| 64 | SDE_PLANE_QOS_VBLANK_CTRL = BIT(0), |
| 65 | SDE_PLANE_QOS_VBLANK_AMORTIZE = BIT(1), |
| 66 | SDE_PLANE_QOS_PANIC_CTRL = BIT(2), |
| 67 | }; |
| 68 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 69 | /* |
| 70 | * struct sde_plane - local sde plane structure |
| 71 | * @csc_cfg: Decoded user configuration for csc |
| 72 | * @csc_usr_ptr: Points to csc_cfg if valid user config available |
| 73 | * @csc_ptr: Points to sde_csc_cfg structure to use for current |
| 74 | */ |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 75 | struct sde_plane { |
| 76 | struct drm_plane base; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 77 | |
| 78 | int mmu_id; |
| 79 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 80 | struct mutex lock; |
| 81 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 82 | enum sde_sspp pipe; |
| 83 | uint32_t features; /* capabilities from catalog */ |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 84 | uint32_t nformats; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 85 | uint32_t formats[64]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 86 | |
| 87 | struct sde_hw_pipe *pipe_hw; |
| 88 | struct sde_hw_pipe_cfg pipe_cfg; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 89 | struct sde_hw_sharp_cfg sharp_cfg; |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 90 | struct sde_hw_scaler3_cfg *scaler3_cfg; |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 91 | struct sde_hw_pipe_qos_cfg pipe_qos_cfg; |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 92 | uint32_t color_fill; |
| 93 | bool is_error; |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 94 | bool is_rt_pipe; |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 95 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 96 | struct sde_hw_pixel_ext pixel_ext; |
| 97 | bool pixel_ext_usr; |
| 98 | |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 99 | struct sde_csc_cfg csc_cfg; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 100 | struct sde_csc_cfg *csc_usr_ptr; |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 101 | struct sde_csc_cfg *csc_ptr; |
| 102 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 103 | const struct sde_sspp_sub_blks *pipe_sblk; |
| 104 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 105 | char pipe_name[SDE_NAME_SIZE]; |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 106 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 107 | struct msm_property_info property_info; |
| 108 | struct msm_property_data property_data[PLANE_PROP_COUNT]; |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 109 | struct drm_property_blob *blob_info; |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 110 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 111 | /* debugfs related stuff */ |
| 112 | struct dentry *debugfs_root; |
| 113 | struct sde_debugfs_regset32 debugfs_src; |
| 114 | struct sde_debugfs_regset32 debugfs_scaler; |
| 115 | struct sde_debugfs_regset32 debugfs_csc; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 116 | }; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 117 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 118 | #define to_sde_plane(x) container_of(x, struct sde_plane, base) |
| 119 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 120 | static bool sde_plane_enabled(struct drm_plane_state *state) |
| 121 | { |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 122 | return state && state->fb && state->crtc; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 123 | } |
| 124 | |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 125 | /** |
| 126 | * _sde_plane_calc_fill_level - calculate fill level of the given source format |
| 127 | * @plane: Pointer to drm plane |
| 128 | * @fmt: Pointer to source buffer format |
| 129 | * @src_wdith: width of source buffer |
| 130 | * Return: fill level corresponding to the source buffer/format or 0 if error |
| 131 | */ |
| 132 | static inline int _sde_plane_calc_fill_level(struct drm_plane *plane, |
| 133 | const struct sde_format *fmt, u32 src_width) |
| 134 | { |
| 135 | struct sde_plane *psde; |
| 136 | u32 fixed_buff_size; |
| 137 | u32 total_fl; |
| 138 | |
| 139 | if (!plane || !fmt) { |
| 140 | SDE_ERROR("invalid arguments\n"); |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | psde = to_sde_plane(plane); |
| 145 | fixed_buff_size = psde->pipe_sblk->pixel_ram_size; |
| 146 | |
| 147 | if (fmt->fetch_planes == SDE_PLANE_PSEUDO_PLANAR) { |
| 148 | if (fmt->chroma_sample == SDE_CHROMA_420) { |
| 149 | /* NV12 */ |
| 150 | total_fl = (fixed_buff_size / 2) / |
| 151 | ((src_width + 32) * fmt->bpp); |
| 152 | } else { |
| 153 | /* non NV12 */ |
| 154 | total_fl = (fixed_buff_size) / |
| 155 | ((src_width + 32) * fmt->bpp); |
| 156 | } |
| 157 | } else { |
| 158 | total_fl = (fixed_buff_size * 2) / |
| 159 | ((src_width + 32) * fmt->bpp); |
| 160 | } |
| 161 | |
| 162 | SDE_DEBUG("plane%u: pnum:%d fmt:%x w:%u fl:%u\n", |
| 163 | plane->base.id, psde->pipe - SSPP_VIG0, |
| 164 | fmt->base.pixel_format, src_width, total_fl); |
| 165 | |
| 166 | return total_fl; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * _sde_plane_get_qos_lut_linear - get linear LUT mapping |
| 171 | * @total_fl: fill level |
| 172 | * Return: LUT setting corresponding to the fill level |
| 173 | */ |
| 174 | static inline u32 _sde_plane_get_qos_lut_linear(u32 total_fl) |
| 175 | { |
| 176 | u32 qos_lut; |
| 177 | |
| 178 | if (total_fl <= 4) |
| 179 | qos_lut = 0x1B; |
| 180 | else if (total_fl <= 5) |
| 181 | qos_lut = 0x5B; |
| 182 | else if (total_fl <= 6) |
| 183 | qos_lut = 0x15B; |
| 184 | else if (total_fl <= 7) |
| 185 | qos_lut = 0x55B; |
| 186 | else if (total_fl <= 8) |
| 187 | qos_lut = 0x155B; |
| 188 | else if (total_fl <= 9) |
| 189 | qos_lut = 0x555B; |
| 190 | else if (total_fl <= 10) |
| 191 | qos_lut = 0x1555B; |
| 192 | else if (total_fl <= 11) |
| 193 | qos_lut = 0x5555B; |
| 194 | else if (total_fl <= 12) |
| 195 | qos_lut = 0x15555B; |
| 196 | else |
| 197 | qos_lut = 0x55555B; |
| 198 | |
| 199 | return qos_lut; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * _sde_plane_get_qos_lut_macrotile - get macrotile LUT mapping |
| 204 | * @total_fl: fill level |
| 205 | * Return: LUT setting corresponding to the fill level |
| 206 | */ |
| 207 | static inline u32 _sde_plane_get_qos_lut_macrotile(u32 total_fl) |
| 208 | { |
| 209 | u32 qos_lut; |
| 210 | |
| 211 | if (total_fl <= 10) |
| 212 | qos_lut = 0x1AAff; |
| 213 | else if (total_fl <= 11) |
| 214 | qos_lut = 0x5AAFF; |
| 215 | else if (total_fl <= 12) |
| 216 | qos_lut = 0x15AAFF; |
| 217 | else |
| 218 | qos_lut = 0x55AAFF; |
| 219 | |
| 220 | return qos_lut; |
| 221 | } |
| 222 | |
| 223 | /** |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 224 | * _sde_plane_set_qos_lut - set QoS LUT of the given plane |
| 225 | * @plane: Pointer to drm plane |
| 226 | * @fb: Pointer to framebuffer associated with the given plane |
| 227 | */ |
| 228 | static void _sde_plane_set_qos_lut(struct drm_plane *plane, |
| 229 | struct drm_framebuffer *fb) |
| 230 | { |
| 231 | struct sde_plane *psde; |
| 232 | const struct sde_format *fmt = NULL; |
| 233 | u32 qos_lut; |
| 234 | u32 total_fl = 0; |
| 235 | |
| 236 | if (!plane || !fb) { |
| 237 | SDE_ERROR("invalid arguments plane %d fb %d\n", |
| 238 | plane != 0, fb != 0); |
| 239 | return; |
| 240 | } |
| 241 | |
| 242 | psde = to_sde_plane(plane); |
| 243 | |
| 244 | if (!psde->pipe_hw || !psde->pipe_sblk) { |
| 245 | SDE_ERROR("invalid arguments\n"); |
| 246 | return; |
| 247 | } else if (!psde->pipe_hw->ops.setup_creq_lut) { |
| 248 | return; |
| 249 | } |
| 250 | |
| 251 | if (!psde->is_rt_pipe) { |
| 252 | qos_lut = psde->pipe_sblk->creq_lut_nrt; |
| 253 | } else { |
| 254 | fmt = sde_get_sde_format_ext( |
| 255 | fb->pixel_format, |
| 256 | fb->modifier, |
| 257 | drm_format_num_planes(fb->pixel_format)); |
| 258 | total_fl = _sde_plane_calc_fill_level(plane, fmt, |
| 259 | psde->pipe_cfg.src_rect.w); |
| 260 | |
| 261 | if (SDE_FORMAT_IS_LINEAR(fmt)) |
| 262 | qos_lut = _sde_plane_get_qos_lut_linear(total_fl); |
| 263 | else |
| 264 | qos_lut = _sde_plane_get_qos_lut_macrotile(total_fl); |
| 265 | } |
| 266 | |
| 267 | psde->pipe_qos_cfg.creq_lut = qos_lut; |
| 268 | |
| 269 | trace_sde_perf_set_qos_luts(psde->pipe - SSPP_VIG0, |
| 270 | (fmt) ? fmt->base.pixel_format : 0, |
| 271 | psde->is_rt_pipe, total_fl, qos_lut, |
| 272 | (fmt) ? SDE_FORMAT_IS_LINEAR(fmt) : 0); |
| 273 | |
| 274 | SDE_DEBUG("plane%u: pnum:%d fmt:%x rt:%d fl:%u lut:0x%x\n", |
| 275 | plane->base.id, |
| 276 | psde->pipe - SSPP_VIG0, |
| 277 | (fmt) ? fmt->base.pixel_format : 0, |
| 278 | psde->is_rt_pipe, total_fl, qos_lut); |
| 279 | |
| 280 | psde->pipe_hw->ops.setup_creq_lut(psde->pipe_hw, &psde->pipe_qos_cfg); |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * _sde_plane_set_panic_lut - set danger/safe LUT of the given plane |
| 285 | * @plane: Pointer to drm plane |
| 286 | * @fb: Pointer to framebuffer associated with the given plane |
| 287 | */ |
| 288 | static void _sde_plane_set_danger_lut(struct drm_plane *plane, |
| 289 | struct drm_framebuffer *fb) |
| 290 | { |
| 291 | struct sde_plane *psde; |
| 292 | const struct sde_format *fmt = NULL; |
| 293 | u32 danger_lut, safe_lut; |
| 294 | |
| 295 | if (!plane || !fb) { |
| 296 | SDE_ERROR("invalid arguments\n"); |
| 297 | return; |
| 298 | } |
| 299 | |
| 300 | psde = to_sde_plane(plane); |
| 301 | |
| 302 | if (!psde->pipe_hw || !psde->pipe_sblk) { |
| 303 | SDE_ERROR("invalid arguments\n"); |
| 304 | return; |
| 305 | } else if (!psde->pipe_hw->ops.setup_danger_safe_lut) { |
| 306 | return; |
| 307 | } |
| 308 | |
| 309 | if (!psde->is_rt_pipe) { |
| 310 | danger_lut = psde->pipe_sblk->danger_lut_nrt; |
| 311 | safe_lut = psde->pipe_sblk->safe_lut_nrt; |
| 312 | } else { |
| 313 | fmt = sde_get_sde_format_ext( |
| 314 | fb->pixel_format, |
| 315 | fb->modifier, |
| 316 | drm_format_num_planes(fb->pixel_format)); |
| 317 | |
| 318 | if (SDE_FORMAT_IS_LINEAR(fmt)) { |
| 319 | danger_lut = psde->pipe_sblk->danger_lut_linear; |
| 320 | safe_lut = psde->pipe_sblk->safe_lut_linear; |
| 321 | } else { |
| 322 | danger_lut = psde->pipe_sblk->danger_lut_tile; |
| 323 | safe_lut = psde->pipe_sblk->safe_lut_tile; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | psde->pipe_qos_cfg.danger_lut = danger_lut; |
| 328 | psde->pipe_qos_cfg.safe_lut = safe_lut; |
| 329 | |
| 330 | trace_sde_perf_set_danger_luts(psde->pipe - SSPP_VIG0, |
| 331 | (fmt) ? fmt->base.pixel_format : 0, |
| 332 | (fmt) ? fmt->fetch_mode : 0, |
| 333 | psde->pipe_qos_cfg.danger_lut, |
| 334 | psde->pipe_qos_cfg.safe_lut); |
| 335 | |
| 336 | SDE_DEBUG("plane%u: pnum:%d fmt:%x mode:%d luts[0x%x, 0x%x]\n", |
| 337 | plane->base.id, |
| 338 | psde->pipe - SSPP_VIG0, |
| 339 | fmt ? fmt->base.pixel_format : 0, |
| 340 | fmt ? fmt->fetch_mode : -1, |
| 341 | psde->pipe_qos_cfg.danger_lut, |
| 342 | psde->pipe_qos_cfg.safe_lut); |
| 343 | |
| 344 | psde->pipe_hw->ops.setup_danger_safe_lut(psde->pipe_hw, |
| 345 | &psde->pipe_qos_cfg); |
| 346 | } |
| 347 | |
| 348 | /** |
| 349 | * _sde_plane_set_qos_ctrl - set QoS control of the given plane |
| 350 | * @plane: Pointer to drm plane |
| 351 | * @enable: true to enable QoS control |
| 352 | * @flags: QoS control mode (enum sde_plane_qos) |
| 353 | */ |
| 354 | static void _sde_plane_set_qos_ctrl(struct drm_plane *plane, |
| 355 | bool enable, u32 flags) |
| 356 | { |
| 357 | struct sde_plane *psde; |
| 358 | |
| 359 | if (!plane) { |
| 360 | SDE_ERROR("invalid arguments\n"); |
| 361 | return; |
| 362 | } |
| 363 | |
| 364 | psde = to_sde_plane(plane); |
| 365 | |
| 366 | if (!psde->pipe_hw || !psde->pipe_sblk) { |
| 367 | SDE_ERROR("invalid arguments\n"); |
| 368 | return; |
| 369 | } else if (!psde->pipe_hw->ops.setup_qos_ctrl) { |
| 370 | return; |
| 371 | } |
| 372 | |
| 373 | if (flags & SDE_PLANE_QOS_VBLANK_CTRL) { |
| 374 | psde->pipe_qos_cfg.creq_vblank = psde->pipe_sblk->creq_vblank; |
| 375 | psde->pipe_qos_cfg.danger_vblank = |
| 376 | psde->pipe_sblk->danger_vblank; |
| 377 | psde->pipe_qos_cfg.vblank_en = enable; |
| 378 | } |
| 379 | |
| 380 | if (flags & SDE_PLANE_QOS_VBLANK_AMORTIZE) { |
| 381 | /* this feature overrules previous VBLANK_CTRL */ |
| 382 | psde->pipe_qos_cfg.vblank_en = false; |
| 383 | psde->pipe_qos_cfg.creq_vblank = 0; /* clear vblank bits */ |
| 384 | } |
| 385 | |
| 386 | if (flags & SDE_PLANE_QOS_PANIC_CTRL) |
| 387 | psde->pipe_qos_cfg.danger_safe_en = enable; |
| 388 | |
| 389 | if (!psde->is_rt_pipe) { |
| 390 | psde->pipe_qos_cfg.vblank_en = false; |
| 391 | psde->pipe_qos_cfg.danger_safe_en = false; |
| 392 | } |
| 393 | |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 394 | SDE_DEBUG("plane%u: pnum:%d ds:%d vb:%d pri[0x%x, 0x%x] is_rt:%d\n", |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 395 | plane->base.id, |
| 396 | psde->pipe - SSPP_VIG0, |
| 397 | psde->pipe_qos_cfg.danger_safe_en, |
| 398 | psde->pipe_qos_cfg.vblank_en, |
| 399 | psde->pipe_qos_cfg.creq_vblank, |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 400 | psde->pipe_qos_cfg.danger_vblank, |
| 401 | psde->is_rt_pipe); |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 402 | |
| 403 | psde->pipe_hw->ops.setup_qos_ctrl(psde->pipe_hw, |
| 404 | &psde->pipe_qos_cfg); |
| 405 | } |
| 406 | |
Alan Kwong | 5d324e4 | 2016-07-28 22:56:18 -0400 | [diff] [blame] | 407 | /** |
| 408 | * _sde_plane_set_ot_limit - set OT limit for the given plane |
| 409 | * @plane: Pointer to drm plane |
| 410 | * @crtc: Pointer to drm crtc |
| 411 | */ |
| 412 | static void _sde_plane_set_ot_limit(struct drm_plane *plane, |
| 413 | struct drm_crtc *crtc) |
| 414 | { |
| 415 | struct sde_plane *psde; |
| 416 | struct sde_vbif_set_ot_params ot_params; |
| 417 | struct msm_drm_private *priv; |
| 418 | struct sde_kms *sde_kms; |
| 419 | |
| 420 | if (!plane || !plane->dev || !crtc) { |
| 421 | SDE_ERROR("invalid arguments plane %d crtc %d\n", |
| 422 | plane != 0, crtc != 0); |
| 423 | return; |
| 424 | } |
| 425 | |
| 426 | priv = plane->dev->dev_private; |
| 427 | if (!priv || !priv->kms) { |
| 428 | SDE_ERROR("invalid KMS reference\n"); |
| 429 | return; |
| 430 | } |
| 431 | |
| 432 | sde_kms = to_sde_kms(priv->kms); |
| 433 | psde = to_sde_plane(plane); |
| 434 | if (!psde->pipe_hw) { |
| 435 | SDE_ERROR("invalid pipe reference\n"); |
| 436 | return; |
| 437 | } |
| 438 | |
| 439 | memset(&ot_params, 0, sizeof(ot_params)); |
| 440 | ot_params.xin_id = psde->pipe_hw->cap->xin_id; |
| 441 | ot_params.num = psde->pipe_hw->idx - SSPP_NONE; |
| 442 | ot_params.width = psde->pipe_cfg.src_rect.w; |
| 443 | ot_params.height = psde->pipe_cfg.src_rect.h; |
| 444 | ot_params.is_wfd = !psde->is_rt_pipe; |
| 445 | ot_params.frame_rate = crtc->mode.vrefresh; |
| 446 | ot_params.vbif_idx = VBIF_RT; |
| 447 | ot_params.clk_ctrl = psde->pipe_hw->cap->clk_ctrl; |
| 448 | ot_params.rd = true; |
| 449 | |
| 450 | sde_vbif_set_ot_limit(sde_kms, &ot_params); |
| 451 | } |
| 452 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 453 | /* helper to update a state's input fence pointer from the property */ |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 454 | static void _sde_plane_set_input_fence(struct sde_plane *psde, |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 455 | struct sde_plane_state *pstate, uint64_t fd) |
| 456 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 457 | if (!psde || !pstate) { |
| 458 | SDE_ERROR("invalid arg(s), plane %d state %d\n", |
| 459 | psde != 0, pstate != 0); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 460 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 461 | } |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 462 | |
| 463 | /* clear previous reference */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 464 | if (pstate->input_fence) |
| 465 | sde_sync_put(pstate->input_fence); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 466 | |
| 467 | /* get fence pointer for later */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 468 | pstate->input_fence = sde_sync_get(fd); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 469 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 470 | SDE_DEBUG_PLANE(psde, "0x%llX\n", fd); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 471 | } |
| 472 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 473 | int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms) |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 474 | { |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 475 | struct sde_plane *psde; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 476 | struct sde_plane_state *pstate; |
Clarence Ip | 78a04ed | 2016-10-04 15:57:45 -0400 | [diff] [blame] | 477 | uint32_t prefix; |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 478 | void *input_fence; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 479 | int ret = -EINVAL; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 480 | |
| 481 | if (!plane) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 482 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 483 | } else if (!plane->state) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 484 | SDE_ERROR_PLANE(to_sde_plane(plane), "invalid state\n"); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 485 | } else { |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 486 | psde = to_sde_plane(plane); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 487 | pstate = to_sde_plane_state(plane->state); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 488 | input_fence = pstate->input_fence; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 489 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 490 | if (input_fence) { |
Clarence Ip | 78a04ed | 2016-10-04 15:57:45 -0400 | [diff] [blame] | 491 | prefix = sde_sync_get_name_prefix(input_fence); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 492 | ret = sde_sync_wait(input_fence, wait_ms); |
Clarence Ip | 78a04ed | 2016-10-04 15:57:45 -0400 | [diff] [blame] | 493 | |
Lloyd Atkinson | 5d40d31 | 2016-09-06 08:34:13 -0400 | [diff] [blame^] | 494 | SDE_EVT32(DRMID(plane), -ret, prefix); |
Clarence Ip | 78a04ed | 2016-10-04 15:57:45 -0400 | [diff] [blame] | 495 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 496 | switch (ret) { |
| 497 | case 0: |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 498 | SDE_DEBUG_PLANE(psde, "signaled\n"); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 499 | break; |
| 500 | case -ETIME: |
Clarence Ip | 78a04ed | 2016-10-04 15:57:45 -0400 | [diff] [blame] | 501 | SDE_ERROR_PLANE(psde, "%ums timeout on %08X\n", |
| 502 | wait_ms, prefix); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 503 | psde->is_error = true; |
| 504 | break; |
| 505 | default: |
Clarence Ip | 78a04ed | 2016-10-04 15:57:45 -0400 | [diff] [blame] | 506 | SDE_ERROR_PLANE(psde, "error %d on %08X\n", |
| 507 | ret, prefix); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 508 | psde->is_error = true; |
| 509 | break; |
| 510 | } |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 511 | } else { |
| 512 | ret = 0; |
| 513 | } |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 514 | } |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 515 | return ret; |
| 516 | } |
| 517 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 518 | static inline void _sde_plane_set_scanout(struct drm_plane *plane, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 519 | struct sde_plane_state *pstate, |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 520 | struct sde_hw_pipe_cfg *pipe_cfg, |
| 521 | struct drm_framebuffer *fb) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 522 | { |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 523 | struct sde_plane *psde; |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 524 | int ret; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 525 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 526 | if (!plane || !pstate || !pipe_cfg || !fb) { |
| 527 | SDE_ERROR( |
| 528 | "invalid arg(s), plane %d state %d cfg %d fb %d\n", |
| 529 | plane != 0, pstate != 0, pipe_cfg != 0, fb != 0); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 530 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 531 | } |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 532 | |
| 533 | psde = to_sde_plane(plane); |
Clarence Ip | b6eb236 | 2016-09-08 16:18:13 -0400 | [diff] [blame] | 534 | if (!psde->pipe_hw) { |
| 535 | SDE_ERROR_PLANE(psde, "invalid pipe_hw\n"); |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 536 | return; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 537 | } |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 538 | |
Clarence Ip | b6eb236 | 2016-09-08 16:18:13 -0400 | [diff] [blame] | 539 | ret = sde_format_populate_layout(psde->mmu_id, fb, &pipe_cfg->layout); |
| 540 | if (ret == -EAGAIN) |
| 541 | SDE_DEBUG_PLANE(psde, "not updating same src addrs\n"); |
| 542 | else if (ret) |
| 543 | SDE_ERROR_PLANE(psde, "failed to get format layout, %d\n", ret); |
| 544 | else if (psde->pipe_hw->ops.setup_sourceaddress) |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 545 | psde->pipe_hw->ops.setup_sourceaddress(psde->pipe_hw, pipe_cfg); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 546 | } |
| 547 | |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 548 | static int _sde_plane_setup_scaler3_lut(struct sde_plane *psde, |
| 549 | struct sde_plane_state *pstate) |
| 550 | { |
| 551 | struct sde_hw_scaler3_cfg *cfg = psde->scaler3_cfg; |
| 552 | int ret = 0; |
| 553 | |
| 554 | cfg->dir_lut = msm_property_get_blob( |
| 555 | &psde->property_info, |
| 556 | pstate->property_blobs, &cfg->dir_len, |
| 557 | PLANE_PROP_SCALER_LUT_ED); |
| 558 | cfg->cir_lut = msm_property_get_blob( |
| 559 | &psde->property_info, |
| 560 | pstate->property_blobs, &cfg->cir_len, |
| 561 | PLANE_PROP_SCALER_LUT_CIR); |
| 562 | cfg->sep_lut = msm_property_get_blob( |
| 563 | &psde->property_info, |
| 564 | pstate->property_blobs, &cfg->sep_len, |
| 565 | PLANE_PROP_SCALER_LUT_SEP); |
| 566 | if (!cfg->dir_lut || !cfg->cir_lut || !cfg->sep_lut) |
| 567 | ret = -ENODATA; |
| 568 | return ret; |
| 569 | } |
| 570 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 571 | static void _sde_plane_setup_scaler3(struct sde_plane *psde, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 572 | uint32_t src_w, uint32_t src_h, uint32_t dst_w, uint32_t dst_h, |
| 573 | struct sde_hw_scaler3_cfg *scale_cfg, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 574 | const struct sde_format *fmt, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 575 | uint32_t chroma_subsmpl_h, uint32_t chroma_subsmpl_v) |
| 576 | { |
| 577 | } |
| 578 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 579 | /** |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 580 | * _sde_plane_setup_scaler2 - determine default scaler phase steps/filter type |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 581 | * @psde: Pointer to SDE plane object |
| 582 | * @src: Source size |
| 583 | * @dst: Destination size |
| 584 | * @phase_steps: Pointer to output array for phase steps |
| 585 | * @filter: Pointer to output array for filter type |
| 586 | * @fmt: Pointer to format definition |
| 587 | * @chroma_subsampling: Subsampling amount for chroma channel |
| 588 | * |
| 589 | * Returns: 0 on success |
| 590 | */ |
| 591 | static int _sde_plane_setup_scaler2(struct sde_plane *psde, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 592 | uint32_t src, uint32_t dst, uint32_t *phase_steps, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 593 | enum sde_hw_filter *filter, const struct sde_format *fmt, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 594 | uint32_t chroma_subsampling) |
| 595 | { |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 596 | if (!psde || !phase_steps || !filter || !fmt) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 597 | SDE_ERROR( |
| 598 | "invalid arg(s), plane %d phase %d filter %d fmt %d\n", |
| 599 | psde != 0, phase_steps != 0, filter != 0, fmt != 0); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 600 | return -EINVAL; |
| 601 | } |
| 602 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 603 | /* calculate phase steps, leave init phase as zero */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 604 | phase_steps[SDE_SSPP_COMP_0] = |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 605 | mult_frac(1 << PHASE_STEP_SHIFT, src, dst); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 606 | phase_steps[SDE_SSPP_COMP_1_2] = |
| 607 | phase_steps[SDE_SSPP_COMP_0] / chroma_subsampling; |
| 608 | phase_steps[SDE_SSPP_COMP_2] = phase_steps[SDE_SSPP_COMP_1_2]; |
| 609 | phase_steps[SDE_SSPP_COMP_3] = phase_steps[SDE_SSPP_COMP_0]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 610 | |
| 611 | /* calculate scaler config, if necessary */ |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 612 | if (SDE_FORMAT_IS_YUV(fmt) || src != dst) { |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 613 | filter[SDE_SSPP_COMP_3] = |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 614 | (src <= dst) ? SDE_SCALE_FILTER_BIL : |
| 615 | SDE_SCALE_FILTER_PCMN; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 616 | |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 617 | if (SDE_FORMAT_IS_YUV(fmt)) { |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 618 | filter[SDE_SSPP_COMP_0] = SDE_SCALE_FILTER_CA; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 619 | filter[SDE_SSPP_COMP_1_2] = filter[SDE_SSPP_COMP_3]; |
| 620 | } else { |
| 621 | filter[SDE_SSPP_COMP_0] = filter[SDE_SSPP_COMP_3]; |
| 622 | filter[SDE_SSPP_COMP_1_2] = |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 623 | SDE_SCALE_FILTER_NEAREST; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 624 | } |
| 625 | } else { |
| 626 | /* disable scaler */ |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 627 | filter[SDE_SSPP_COMP_0] = SDE_SCALE_FILTER_MAX; |
| 628 | filter[SDE_SSPP_COMP_1_2] = SDE_SCALE_FILTER_MAX; |
| 629 | filter[SDE_SSPP_COMP_3] = SDE_SCALE_FILTER_MAX; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 630 | } |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 631 | return 0; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 632 | } |
| 633 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 634 | /** |
| 635 | * _sde_plane_setup_pixel_ext - determine default pixel extension values |
| 636 | * @psde: Pointer to SDE plane object |
| 637 | * @src: Source size |
| 638 | * @dst: Destination size |
| 639 | * @decimated_src: Source size after decimation, if any |
| 640 | * @phase_steps: Pointer to output array for phase steps |
| 641 | * @out_src: Output array for pixel extension values |
| 642 | * @out_edge1: Output array for pixel extension first edge |
| 643 | * @out_edge2: Output array for pixel extension second edge |
| 644 | * @filter: Pointer to array for filter type |
| 645 | * @fmt: Pointer to format definition |
| 646 | * @chroma_subsampling: Subsampling amount for chroma channel |
| 647 | * @post_compare: Whether to chroma subsampled source size for comparisions |
| 648 | */ |
| 649 | static void _sde_plane_setup_pixel_ext(struct sde_plane *psde, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 650 | uint32_t src, uint32_t dst, uint32_t decimated_src, |
| 651 | uint32_t *phase_steps, uint32_t *out_src, int *out_edge1, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 652 | int *out_edge2, enum sde_hw_filter *filter, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 653 | const struct sde_format *fmt, uint32_t chroma_subsampling, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 654 | bool post_compare) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 655 | { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 656 | int64_t edge1, edge2, caf; |
| 657 | uint32_t src_work; |
| 658 | int i, tmp; |
| 659 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 660 | if (psde && phase_steps && out_src && out_edge1 && |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 661 | out_edge2 && filter && fmt) { |
| 662 | /* handle CAF for YUV formats */ |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 663 | if (SDE_FORMAT_IS_YUV(fmt) && *filter == SDE_SCALE_FILTER_CA) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 664 | caf = PHASE_STEP_UNIT_SCALE; |
| 665 | else |
| 666 | caf = 0; |
| 667 | |
| 668 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 669 | src_work = decimated_src; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 670 | if (i == SDE_SSPP_COMP_1_2 || i == SDE_SSPP_COMP_2) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 671 | src_work /= chroma_subsampling; |
| 672 | if (post_compare) |
| 673 | src = src_work; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 674 | if (!SDE_FORMAT_IS_YUV(fmt) && (src == dst)) { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 675 | /* unity */ |
| 676 | edge1 = 0; |
| 677 | edge2 = 0; |
| 678 | } else if (dst >= src) { |
| 679 | /* upscale */ |
| 680 | edge1 = (1 << PHASE_RESIDUAL); |
| 681 | edge1 -= caf; |
| 682 | edge2 = (1 << PHASE_RESIDUAL); |
| 683 | edge2 += (dst - 1) * *(phase_steps + i); |
| 684 | edge2 -= (src_work - 1) * PHASE_STEP_UNIT_SCALE; |
| 685 | edge2 += caf; |
| 686 | edge2 = -(edge2); |
| 687 | } else { |
| 688 | /* downscale */ |
| 689 | edge1 = 0; |
| 690 | edge2 = (dst - 1) * *(phase_steps + i); |
| 691 | edge2 -= (src_work - 1) * PHASE_STEP_UNIT_SCALE; |
| 692 | edge2 += *(phase_steps + i); |
| 693 | edge2 = -(edge2); |
| 694 | } |
| 695 | |
| 696 | /* only enable CAF for luma plane */ |
| 697 | caf = 0; |
| 698 | |
| 699 | /* populate output arrays */ |
| 700 | *(out_src + i) = src_work; |
| 701 | |
| 702 | /* edge updates taken from __pxl_extn_helper */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 703 | if (edge1 >= 0) { |
| 704 | tmp = (uint32_t)edge1; |
| 705 | tmp >>= PHASE_STEP_SHIFT; |
| 706 | *(out_edge1 + i) = -tmp; |
| 707 | } else { |
| 708 | tmp = (uint32_t)(-edge1); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 709 | *(out_edge1 + i) = |
| 710 | (tmp + PHASE_STEP_UNIT_SCALE - 1) >> |
| 711 | PHASE_STEP_SHIFT; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 712 | } |
| 713 | if (edge2 >= 0) { |
| 714 | tmp = (uint32_t)edge2; |
| 715 | tmp >>= PHASE_STEP_SHIFT; |
| 716 | *(out_edge2 + i) = -tmp; |
| 717 | } else { |
| 718 | tmp = (uint32_t)(-edge2); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 719 | *(out_edge2 + i) = |
| 720 | (tmp + PHASE_STEP_UNIT_SCALE - 1) >> |
| 721 | PHASE_STEP_SHIFT; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 722 | } |
| 723 | } |
| 724 | } |
| 725 | } |
| 726 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 727 | static inline void _sde_plane_setup_csc(struct sde_plane *psde) |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 728 | { |
| 729 | static const struct sde_csc_cfg sde_csc_YUV2RGB_601L = { |
| 730 | { |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 731 | /* S15.16 format */ |
| 732 | 0x00012A00, 0x00000000, 0x00019880, |
| 733 | 0x00012A00, 0xFFFF9B80, 0xFFFF3000, |
| 734 | 0x00012A00, 0x00020480, 0x00000000, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 735 | }, |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 736 | /* signed bias */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 737 | { 0xfff0, 0xff80, 0xff80,}, |
| 738 | { 0x0, 0x0, 0x0,}, |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 739 | /* unsigned clamp */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 740 | { 0x10, 0xeb, 0x10, 0xf0, 0x10, 0xf0,}, |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 741 | { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,}, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 742 | }; |
abeykun | 1c312f6 | 2016-08-26 09:47:12 -0400 | [diff] [blame] | 743 | static const struct sde_csc_cfg sde_csc10_YUV2RGB_601L = { |
| 744 | { |
| 745 | /* S15.16 format */ |
| 746 | 0x00012A00, 0x00000000, 0x00019880, |
| 747 | 0x00012A00, 0xFFFF9B80, 0xFFFF3000, |
| 748 | 0x00012A00, 0x00020480, 0x00000000, |
| 749 | }, |
| 750 | /* signed bias */ |
| 751 | { 0xffc0, 0xfe00, 0xfe00,}, |
| 752 | { 0x0, 0x0, 0x0,}, |
| 753 | /* unsigned clamp */ |
| 754 | { 0x40, 0x3ac, 0x40, 0x3c0, 0x40, 0x3c0,}, |
| 755 | { 0x00, 0x3ff, 0x00, 0x3ff, 0x00, 0x3ff,}, |
| 756 | }; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 757 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 758 | if (!psde) { |
| 759 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 760 | return; |
| 761 | } |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 762 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 763 | /* revert to kernel default if override not available */ |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 764 | if (psde->csc_usr_ptr) |
| 765 | psde->csc_ptr = psde->csc_usr_ptr; |
abeykun | 1c312f6 | 2016-08-26 09:47:12 -0400 | [diff] [blame] | 766 | else if (BIT(SDE_SSPP_CSC_10BIT) & psde->features) |
| 767 | psde->csc_ptr = (struct sde_csc_cfg *)&sde_csc10_YUV2RGB_601L; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 768 | else |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 769 | psde->csc_ptr = (struct sde_csc_cfg *)&sde_csc_YUV2RGB_601L; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 770 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 771 | SDE_DEBUG_PLANE(psde, "using 0x%X 0x%X 0x%X...\n", |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 772 | psde->csc_ptr->csc_mv[0], |
| 773 | psde->csc_ptr->csc_mv[1], |
| 774 | psde->csc_ptr->csc_mv[2]); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 775 | } |
| 776 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 777 | static void _sde_plane_setup_scaler(struct sde_plane *psde, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 778 | const struct sde_format *fmt, |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 779 | struct sde_plane_state *pstate) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 780 | { |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 781 | struct sde_hw_pixel_ext *pe; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 782 | uint32_t chroma_subsmpl_h, chroma_subsmpl_v; |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 783 | uint32_t tmp, i; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 784 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 785 | if (!psde || !fmt) { |
| 786 | SDE_ERROR("invalid arg(s), plane %d fmt %d state %d\n", |
| 787 | psde != 0, fmt != 0, pstate != 0); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 788 | return; |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 789 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 790 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 791 | pe = &(psde->pixel_ext); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 792 | |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 793 | psde->pipe_cfg.horz_decimation = |
| 794 | sde_plane_get_property(pstate, PLANE_PROP_H_DECIMATE); |
| 795 | psde->pipe_cfg.vert_decimation = |
| 796 | sde_plane_get_property(pstate, PLANE_PROP_V_DECIMATE); |
Clarence Ip | 04ec67d | 2016-05-26 01:16:15 -0400 | [diff] [blame] | 797 | |
| 798 | /* don't chroma subsample if decimating */ |
| 799 | chroma_subsmpl_h = psde->pipe_cfg.horz_decimation ? 1 : |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 800 | drm_format_horz_chroma_subsampling(fmt->base.pixel_format); |
Clarence Ip | 04ec67d | 2016-05-26 01:16:15 -0400 | [diff] [blame] | 801 | chroma_subsmpl_v = psde->pipe_cfg.vert_decimation ? 1 : |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 802 | drm_format_vert_chroma_subsampling(fmt->base.pixel_format); |
Clarence Ip | 04ec67d | 2016-05-26 01:16:15 -0400 | [diff] [blame] | 803 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 804 | /* update scaler */ |
| 805 | if (psde->features & BIT(SDE_SSPP_SCALER_QSEED3)) { |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 806 | int error; |
| 807 | |
| 808 | error = _sde_plane_setup_scaler3_lut(psde, pstate); |
| 809 | if (error || !psde->pixel_ext_usr) { |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 810 | /* calculate default config for QSEED3 */ |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 811 | _sde_plane_setup_scaler3(psde, |
| 812 | psde->pipe_cfg.src_rect.w, |
| 813 | psde->pipe_cfg.src_rect.h, |
| 814 | psde->pipe_cfg.dst_rect.w, |
| 815 | psde->pipe_cfg.dst_rect.h, |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 816 | psde->scaler3_cfg, fmt, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 817 | chroma_subsmpl_h, chroma_subsmpl_v); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 818 | } |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 819 | } else if (!psde->pixel_ext_usr) { |
| 820 | /* calculate default configuration for QSEED2 */ |
| 821 | memset(pe, 0, sizeof(struct sde_hw_pixel_ext)); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 822 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 823 | SDE_DEBUG_PLANE(psde, "default config\n"); |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 824 | _sde_plane_setup_scaler2(psde, |
| 825 | psde->pipe_cfg.src_rect.w, |
| 826 | psde->pipe_cfg.dst_rect.w, |
| 827 | pe->phase_step_x, |
| 828 | pe->horz_filter, fmt, chroma_subsmpl_h); |
| 829 | _sde_plane_setup_scaler2(psde, |
| 830 | psde->pipe_cfg.src_rect.h, |
| 831 | psde->pipe_cfg.dst_rect.h, |
| 832 | pe->phase_step_y, |
| 833 | pe->vert_filter, fmt, chroma_subsmpl_v); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 834 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 835 | /* calculate left/right/top/bottom pixel extensions */ |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 836 | tmp = DECIMATED_DIMENSION(psde->pipe_cfg.src_rect.w, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 837 | psde->pipe_cfg.horz_decimation); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 838 | if (SDE_FORMAT_IS_YUV(fmt)) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 839 | tmp &= ~0x1; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 840 | _sde_plane_setup_pixel_ext(psde, psde->pipe_cfg.src_rect.w, |
| 841 | psde->pipe_cfg.dst_rect.w, tmp, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 842 | pe->phase_step_x, |
| 843 | pe->roi_w, |
| 844 | pe->num_ext_pxls_left, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 845 | pe->num_ext_pxls_right, pe->horz_filter, fmt, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 846 | chroma_subsmpl_h, 0); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 847 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 848 | tmp = DECIMATED_DIMENSION(psde->pipe_cfg.src_rect.h, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 849 | psde->pipe_cfg.vert_decimation); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 850 | _sde_plane_setup_pixel_ext(psde, psde->pipe_cfg.src_rect.h, |
| 851 | psde->pipe_cfg.dst_rect.h, tmp, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 852 | pe->phase_step_y, |
| 853 | pe->roi_h, |
| 854 | pe->num_ext_pxls_top, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 855 | pe->num_ext_pxls_btm, pe->vert_filter, fmt, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 856 | chroma_subsmpl_v, 1); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 857 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 858 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 859 | if (pe->num_ext_pxls_left[i] >= 0) |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 860 | pe->left_rpt[i] = pe->num_ext_pxls_left[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 861 | else |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 862 | pe->left_ftch[i] = pe->num_ext_pxls_left[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 863 | |
| 864 | if (pe->num_ext_pxls_right[i] >= 0) |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 865 | pe->right_rpt[i] = pe->num_ext_pxls_right[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 866 | else |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 867 | pe->right_ftch[i] = pe->num_ext_pxls_right[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 868 | |
| 869 | if (pe->num_ext_pxls_top[i] >= 0) |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 870 | pe->top_rpt[i] = pe->num_ext_pxls_top[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 871 | else |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 872 | pe->top_ftch[i] = pe->num_ext_pxls_top[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 873 | |
| 874 | if (pe->num_ext_pxls_btm[i] >= 0) |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 875 | pe->btm_rpt[i] = pe->num_ext_pxls_btm[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 876 | else |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 877 | pe->btm_ftch[i] = pe->num_ext_pxls_btm[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 878 | } |
| 879 | } |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 880 | } |
| 881 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 882 | /** |
| 883 | * _sde_plane_color_fill - enables color fill on plane |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 884 | * @psde: Pointer to SDE plane object |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 885 | * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red |
| 886 | * @alpha: 8-bit fill alpha value, 255 selects 100% alpha |
| 887 | * Returns: 0 on success |
| 888 | */ |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 889 | static int _sde_plane_color_fill(struct sde_plane *psde, |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 890 | uint32_t color, uint32_t alpha) |
| 891 | { |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 892 | const struct sde_format *fmt; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 893 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 894 | if (!psde) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 895 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 896 | return -EINVAL; |
| 897 | } |
| 898 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 899 | if (!psde->pipe_hw) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 900 | SDE_ERROR_PLANE(psde, "invalid plane h/w pointer\n"); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 901 | return -EINVAL; |
| 902 | } |
| 903 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 904 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 905 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 906 | /* |
| 907 | * select fill format to match user property expectation, |
| 908 | * h/w only supports RGB variants |
| 909 | */ |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 910 | fmt = sde_get_sde_format(DRM_FORMAT_ABGR8888); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 911 | |
| 912 | /* update sspp */ |
| 913 | if (fmt && psde->pipe_hw->ops.setup_solidfill) { |
| 914 | psde->pipe_hw->ops.setup_solidfill(psde->pipe_hw, |
| 915 | (color & 0xFFFFFF) | ((alpha & 0xFF) << 24)); |
| 916 | |
| 917 | /* override scaler/decimation if solid fill */ |
| 918 | psde->pipe_cfg.src_rect.x = 0; |
| 919 | psde->pipe_cfg.src_rect.y = 0; |
| 920 | psde->pipe_cfg.src_rect.w = psde->pipe_cfg.dst_rect.w; |
| 921 | psde->pipe_cfg.src_rect.h = psde->pipe_cfg.dst_rect.h; |
| 922 | |
| 923 | _sde_plane_setup_scaler(psde, fmt, 0); |
| 924 | |
| 925 | if (psde->pipe_hw->ops.setup_format) |
| 926 | psde->pipe_hw->ops.setup_format(psde->pipe_hw, |
| 927 | fmt, SDE_SSPP_SOLID_FILL); |
| 928 | |
| 929 | if (psde->pipe_hw->ops.setup_rects) |
| 930 | psde->pipe_hw->ops.setup_rects(psde->pipe_hw, |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 931 | &psde->pipe_cfg, &psde->pixel_ext, |
| 932 | psde->scaler3_cfg); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 933 | } |
| 934 | |
| 935 | return 0; |
| 936 | } |
| 937 | |
| 938 | static int _sde_plane_mode_set(struct drm_plane *plane, |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 939 | struct drm_plane_state *state) |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 940 | { |
Clarence Ip | c47a069 | 2016-10-11 10:54:17 -0400 | [diff] [blame] | 941 | uint32_t nplanes, src_flags; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 942 | struct sde_plane *psde; |
| 943 | struct sde_plane_state *pstate; |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 944 | const struct sde_format *fmt; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 945 | struct drm_crtc *crtc; |
| 946 | struct drm_framebuffer *fb; |
| 947 | struct sde_rect src, dst; |
| 948 | bool q16_data = true; |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 949 | int idx; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 950 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 951 | if (!plane) { |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 952 | SDE_ERROR("invalid plane\n"); |
| 953 | return -EINVAL; |
| 954 | } else if (!plane->state) { |
| 955 | SDE_ERROR("invalid plane state\n"); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 956 | return -EINVAL; |
| 957 | } |
| 958 | |
| 959 | psde = to_sde_plane(plane); |
| 960 | pstate = to_sde_plane_state(plane->state); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 961 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 962 | crtc = state->crtc; |
| 963 | fb = state->fb; |
| 964 | if (!crtc || !fb) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 965 | SDE_ERROR_PLANE(psde, "invalid crtc %d or fb %d\n", |
| 966 | crtc != 0, fb != 0); |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 967 | return -EINVAL; |
| 968 | } |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 969 | fmt = to_sde_format(msm_framebuffer_format(fb)); |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 970 | nplanes = fmt->num_planes; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 971 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 972 | /* determine what needs to be refreshed */ |
| 973 | while ((idx = msm_property_pop_dirty(&psde->property_info)) >= 0) { |
| 974 | switch (idx) { |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 975 | case PLANE_PROP_SCALER_V1: |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 976 | case PLANE_PROP_SCALER_V2: |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 977 | case PLANE_PROP_H_DECIMATE: |
| 978 | case PLANE_PROP_V_DECIMATE: |
| 979 | case PLANE_PROP_SRC_CONFIG: |
| 980 | case PLANE_PROP_ZPOS: |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 981 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
| 982 | break; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 983 | case PLANE_PROP_CSC_V1: |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 984 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT; |
| 985 | break; |
| 986 | case PLANE_PROP_COLOR_FILL: |
| 987 | /* potentially need to refresh everything */ |
| 988 | pstate->dirty = SDE_PLANE_DIRTY_ALL; |
| 989 | break; |
| 990 | case PLANE_PROP_ROTATION: |
| 991 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT; |
| 992 | break; |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 993 | case PLANE_PROP_INFO: |
| 994 | case PLANE_PROP_ALPHA: |
| 995 | case PLANE_PROP_INPUT_FENCE: |
| 996 | case PLANE_PROP_BLEND_OP: |
| 997 | /* no special action required */ |
| 998 | break; |
| 999 | default: |
| 1000 | /* unknown property, refresh everything */ |
| 1001 | pstate->dirty |= SDE_PLANE_DIRTY_ALL; |
| 1002 | SDE_ERROR("executing full mode set, prp_idx %d\n", idx); |
| 1003 | break; |
| 1004 | } |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1005 | } |
| 1006 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1007 | if (pstate->dirty & SDE_PLANE_DIRTY_RECTS) |
| 1008 | memset(&(psde->pipe_cfg), 0, sizeof(struct sde_hw_pipe_cfg)); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1009 | |
| 1010 | _sde_plane_set_scanout(plane, pstate, &psde->pipe_cfg, fb); |
| 1011 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1012 | /* early out if nothing dirty */ |
| 1013 | if (!pstate->dirty) |
| 1014 | return 0; |
| 1015 | pstate->pending = true; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1016 | |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 1017 | psde->is_rt_pipe = sde_crtc_is_rt(crtc); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1018 | _sde_plane_set_qos_ctrl(plane, false, SDE_PLANE_QOS_PANIC_CTRL); |
| 1019 | |
| 1020 | /* update roi config */ |
| 1021 | if (pstate->dirty & SDE_PLANE_DIRTY_RECTS) { |
| 1022 | POPULATE_RECT(&src, state->src_x, state->src_y, |
| 1023 | state->src_w, state->src_h, q16_data); |
| 1024 | POPULATE_RECT(&dst, state->crtc_x, state->crtc_y, |
| 1025 | state->crtc_w, state->crtc_h, !q16_data); |
| 1026 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1027 | SDE_DEBUG_PLANE(psde, |
| 1028 | "FB[%u] %u,%u,%ux%u->crtc%u %d,%d,%ux%u, %s ubwc %d\n", |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1029 | fb->base.id, src.x, src.y, src.w, src.h, |
| 1030 | crtc->base.id, dst.x, dst.y, dst.w, dst.h, |
| 1031 | drm_get_format_name(fmt->base.pixel_format), |
| 1032 | SDE_FORMAT_IS_UBWC(fmt)); |
| 1033 | |
| 1034 | if (sde_plane_get_property(pstate, PLANE_PROP_SRC_CONFIG) & |
| 1035 | BIT(SDE_DRM_DEINTERLACE)) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1036 | SDE_DEBUG_PLANE(psde, "deinterlace\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1037 | for (idx = 0; idx < SDE_MAX_PLANES; ++idx) |
| 1038 | psde->pipe_cfg.layout.plane_pitch[idx] <<= 1; |
| 1039 | src.h /= 2; |
| 1040 | src.y = DIV_ROUND_UP(src.y, 2); |
| 1041 | src.y &= ~0x1; |
| 1042 | } |
| 1043 | |
| 1044 | psde->pipe_cfg.src_rect = src; |
| 1045 | psde->pipe_cfg.dst_rect = dst; |
| 1046 | |
| 1047 | /* check for color fill */ |
| 1048 | psde->color_fill = (uint32_t)sde_plane_get_property(pstate, |
| 1049 | PLANE_PROP_COLOR_FILL); |
| 1050 | if (psde->color_fill & SDE_PLANE_COLOR_FILL_FLAG) { |
| 1051 | /* skip remaining processing on color fill */ |
| 1052 | pstate->dirty = 0x0; |
| 1053 | } else if (psde->pipe_hw->ops.setup_rects) { |
| 1054 | _sde_plane_setup_scaler(psde, fmt, pstate); |
| 1055 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1056 | psde->pipe_hw->ops.setup_rects(psde->pipe_hw, |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 1057 | &psde->pipe_cfg, &psde->pixel_ext, |
| 1058 | psde->scaler3_cfg); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1059 | } |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 1060 | } |
| 1061 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1062 | if ((pstate->dirty & SDE_PLANE_DIRTY_FORMAT) && |
| 1063 | psde->pipe_hw->ops.setup_format) { |
| 1064 | src_flags = 0x0; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1065 | SDE_DEBUG_PLANE(psde, "rotation 0x%llX\n", |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1066 | sde_plane_get_property(pstate, PLANE_PROP_ROTATION)); |
| 1067 | if (sde_plane_get_property(pstate, PLANE_PROP_ROTATION) & |
| 1068 | BIT(DRM_REFLECT_X)) |
| 1069 | src_flags |= SDE_SSPP_FLIP_LR; |
| 1070 | if (sde_plane_get_property(pstate, PLANE_PROP_ROTATION) & |
| 1071 | BIT(DRM_REFLECT_Y)) |
| 1072 | src_flags |= SDE_SSPP_FLIP_UD; |
| 1073 | |
| 1074 | /* update format */ |
| 1075 | psde->pipe_hw->ops.setup_format(psde->pipe_hw, fmt, src_flags); |
| 1076 | |
| 1077 | /* update csc */ |
| 1078 | if (SDE_FORMAT_IS_YUV(fmt)) |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1079 | _sde_plane_setup_csc(psde); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1080 | else |
| 1081 | psde->csc_ptr = 0; |
| 1082 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1083 | |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1084 | /* update sharpening */ |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1085 | if ((pstate->dirty & SDE_PLANE_DIRTY_SHARPEN) && |
| 1086 | psde->pipe_hw->ops.setup_sharpening) { |
| 1087 | psde->sharp_cfg.strength = SHARP_STRENGTH_DEFAULT; |
| 1088 | psde->sharp_cfg.edge_thr = SHARP_EDGE_THR_DEFAULT; |
| 1089 | psde->sharp_cfg.smooth_thr = SHARP_SMOOTH_THR_DEFAULT; |
| 1090 | psde->sharp_cfg.noise_thr = SHARP_NOISE_THR_DEFAULT; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1091 | |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1092 | psde->pipe_hw->ops.setup_sharpening(psde->pipe_hw, |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1093 | &psde->sharp_cfg); |
| 1094 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1095 | |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 1096 | _sde_plane_set_qos_lut(plane, fb); |
| 1097 | _sde_plane_set_danger_lut(plane, fb); |
| 1098 | |
Alan Kwong | 5d324e4 | 2016-07-28 22:56:18 -0400 | [diff] [blame] | 1099 | if (plane->type != DRM_PLANE_TYPE_CURSOR) { |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 1100 | _sde_plane_set_qos_ctrl(plane, true, SDE_PLANE_QOS_PANIC_CTRL); |
Alan Kwong | 5d324e4 | 2016-07-28 22:56:18 -0400 | [diff] [blame] | 1101 | _sde_plane_set_ot_limit(plane, crtc); |
| 1102 | } |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 1103 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1104 | /* clear dirty */ |
| 1105 | pstate->dirty = 0x0; |
| 1106 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1107 | return 0; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1108 | } |
| 1109 | |
| 1110 | static int sde_plane_prepare_fb(struct drm_plane *plane, |
| 1111 | const struct drm_plane_state *new_state) |
| 1112 | { |
| 1113 | struct drm_framebuffer *fb = new_state->fb; |
| 1114 | struct sde_plane *psde = to_sde_plane(plane); |
| 1115 | |
| 1116 | if (!new_state->fb) |
| 1117 | return 0; |
| 1118 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1119 | SDE_DEBUG_PLANE(psde, "FB[%u]\n", fb->base.id); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1120 | return msm_framebuffer_prepare(fb, psde->mmu_id); |
| 1121 | } |
| 1122 | |
| 1123 | static void sde_plane_cleanup_fb(struct drm_plane *plane, |
| 1124 | const struct drm_plane_state *old_state) |
| 1125 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1126 | struct drm_framebuffer *fb = old_state ? old_state->fb : NULL; |
| 1127 | struct sde_plane *psde = plane ? to_sde_plane(plane) : NULL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1128 | |
| 1129 | if (!fb) |
| 1130 | return; |
| 1131 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1132 | SDE_DEBUG_PLANE(psde, "FB[%u]\n", fb->base.id); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1133 | msm_framebuffer_cleanup(fb, psde->mmu_id); |
| 1134 | } |
| 1135 | |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1136 | static void _sde_plane_atomic_check_mode_changed(struct sde_plane *psde, |
| 1137 | struct drm_plane_state *state, |
| 1138 | struct drm_plane_state *old_state) |
| 1139 | { |
| 1140 | struct sde_plane_state *pstate = to_sde_plane_state(state); |
| 1141 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1142 | /* no need to check it again */ |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1143 | if (pstate->dirty == SDE_PLANE_DIRTY_ALL) |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1144 | return; |
| 1145 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1146 | if (!sde_plane_enabled(state) || !sde_plane_enabled(old_state) |
| 1147 | || psde->is_error) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1148 | SDE_DEBUG_PLANE(psde, |
| 1149 | "enabling/disabling full modeset required\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1150 | pstate->dirty |= SDE_PLANE_DIRTY_ALL; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1151 | } else if (to_sde_plane_state(old_state)->pending) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1152 | SDE_DEBUG_PLANE(psde, "still pending\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1153 | pstate->dirty |= SDE_PLANE_DIRTY_ALL; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1154 | } else if (state->src_w != old_state->src_w || |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1155 | state->src_h != old_state->src_h || |
| 1156 | state->src_x != old_state->src_x || |
| 1157 | state->src_y != old_state->src_y) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1158 | SDE_DEBUG_PLANE(psde, "src rect updated\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1159 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1160 | } else if (state->crtc_w != old_state->crtc_w || |
| 1161 | state->crtc_h != old_state->crtc_h || |
| 1162 | state->crtc_x != old_state->crtc_x || |
| 1163 | state->crtc_y != old_state->crtc_y) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1164 | SDE_DEBUG_PLANE(psde, "crtc rect updated\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1165 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
| 1166 | } |
| 1167 | |
| 1168 | if (!state->fb || !old_state->fb) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1169 | SDE_DEBUG_PLANE(psde, "can't compare fb handles\n"); |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1170 | } else if (state->fb->pixel_format != old_state->fb->pixel_format) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1171 | SDE_DEBUG_PLANE(psde, "format change\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1172 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT | SDE_PLANE_DIRTY_RECTS; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1173 | } else { |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1174 | uint64_t *new_mods = state->fb->modifier; |
| 1175 | uint64_t *old_mods = old_state->fb->modifier; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1176 | uint32_t *new_pitches = state->fb->pitches; |
| 1177 | uint32_t *old_pitches = old_state->fb->pitches; |
| 1178 | uint32_t *new_offset = state->fb->offsets; |
| 1179 | uint32_t *old_offset = old_state->fb->offsets; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1180 | int i; |
| 1181 | |
| 1182 | for (i = 0; i < ARRAY_SIZE(state->fb->modifier); i++) { |
| 1183 | if (new_mods[i] != old_mods[i]) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1184 | SDE_DEBUG_PLANE(psde, |
| 1185 | "format modifiers change\"\ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1186 | plane:%d new_mode:%llu old_mode:%llu\n", |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1187 | i, new_mods[i], old_mods[i]); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1188 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT | |
| 1189 | SDE_PLANE_DIRTY_RECTS; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1190 | break; |
| 1191 | } |
| 1192 | } |
Lloyd Atkinson | 3ab9ef7 | 2016-07-14 17:42:41 -0400 | [diff] [blame] | 1193 | for (i = 0; i < ARRAY_SIZE(state->fb->pitches); i++) { |
| 1194 | if (new_pitches[i] != old_pitches[i]) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1195 | SDE_DEBUG_PLANE(psde, |
| 1196 | "pitches change plane:%d\"\ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1197 | old_pitches:%u new_pitches:%u\n", |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1198 | i, old_pitches[i], new_pitches[i]); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1199 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
Lloyd Atkinson | 3ab9ef7 | 2016-07-14 17:42:41 -0400 | [diff] [blame] | 1200 | break; |
| 1201 | } |
| 1202 | } |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1203 | for (i = 0; i < ARRAY_SIZE(state->fb->offsets); i++) { |
| 1204 | if (new_offset[i] != old_offset[i]) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1205 | SDE_DEBUG_PLANE(psde, |
| 1206 | "offset change plane:%d\"\ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1207 | old_offset:%u new_offset:%u\n", |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1208 | i, old_offset[i], new_offset[i]); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1209 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT | |
| 1210 | SDE_PLANE_DIRTY_RECTS; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1211 | break; |
| 1212 | } |
| 1213 | } |
Lloyd Atkinson | 3ab9ef7 | 2016-07-14 17:42:41 -0400 | [diff] [blame] | 1214 | } |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1215 | } |
| 1216 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1217 | static int sde_plane_atomic_check(struct drm_plane *plane, |
| 1218 | struct drm_plane_state *state) |
| 1219 | { |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 1220 | int ret = 0; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1221 | struct sde_plane *psde; |
| 1222 | struct sde_plane_state *pstate; |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 1223 | const struct sde_format *fmt; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1224 | struct sde_rect src, dst; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1225 | uint32_t deci_w, deci_h, src_deci_w, src_deci_h; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1226 | uint32_t max_upscale, max_downscale, min_src_size, max_linewidth; |
| 1227 | bool q16_data = true; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1228 | |
| 1229 | if (!plane || !state) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1230 | SDE_ERROR("invalid arg(s), plane %d state %d\n", |
| 1231 | plane != 0, state != 0); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1232 | ret = -EINVAL; |
| 1233 | goto exit; |
| 1234 | } |
| 1235 | |
| 1236 | psde = to_sde_plane(plane); |
| 1237 | pstate = to_sde_plane_state(state); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1238 | |
| 1239 | if (!psde->pipe_sblk) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1240 | SDE_ERROR_PLANE(psde, "invalid catalog\n"); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1241 | ret = -EINVAL; |
| 1242 | goto exit; |
| 1243 | } |
| 1244 | |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 1245 | deci_w = sde_plane_get_property(pstate, PLANE_PROP_H_DECIMATE); |
| 1246 | deci_h = sde_plane_get_property(pstate, PLANE_PROP_V_DECIMATE); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1247 | |
| 1248 | /* src values are in Q16 fixed point, convert to integer */ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1249 | POPULATE_RECT(&src, state->src_x, state->src_y, state->src_w, |
| 1250 | state->src_h, q16_data); |
| 1251 | POPULATE_RECT(&dst, state->crtc_x, state->crtc_y, state->crtc_w, |
| 1252 | state->crtc_h, !q16_data); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1253 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1254 | src_deci_w = DECIMATED_DIMENSION(src.w, deci_w); |
| 1255 | src_deci_h = DECIMATED_DIMENSION(src.h, deci_h); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1256 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1257 | max_upscale = psde->pipe_sblk->maxupscale; |
| 1258 | max_downscale = psde->pipe_sblk->maxdwnscale; |
| 1259 | max_linewidth = psde->pipe_sblk->maxlinewidth; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1260 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1261 | SDE_DEBUG_PLANE(psde, "check %d -> %d\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1262 | sde_plane_enabled(plane->state), sde_plane_enabled(state)); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1263 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1264 | if (!sde_plane_enabled(state)) |
| 1265 | goto modeset_update; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1266 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1267 | fmt = to_sde_format(msm_framebuffer_format(state->fb)); |
| 1268 | |
| 1269 | min_src_size = SDE_FORMAT_IS_YUV(fmt) ? 2 : 1; |
| 1270 | |
| 1271 | if (SDE_FORMAT_IS_YUV(fmt) && |
| 1272 | (!(psde->features & SDE_SSPP_SCALER) || |
abeykun | 1c312f6 | 2016-08-26 09:47:12 -0400 | [diff] [blame] | 1273 | !(psde->features & (BIT(SDE_SSPP_CSC) |
| 1274 | | BIT(SDE_SSPP_CSC_10BIT))))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1275 | SDE_ERROR_PLANE(psde, |
| 1276 | "plane doesn't have scaler/csc for yuv\n"); |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1277 | ret = -EINVAL; |
| 1278 | |
| 1279 | /* check src bounds */ |
| 1280 | } else if (state->fb->width > MAX_IMG_WIDTH || |
| 1281 | state->fb->height > MAX_IMG_HEIGHT || |
| 1282 | src.w < min_src_size || src.h < min_src_size || |
| 1283 | CHECK_LAYER_BOUNDS(src.x, src.w, state->fb->width) || |
| 1284 | CHECK_LAYER_BOUNDS(src.y, src.h, state->fb->height)) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1285 | SDE_ERROR_PLANE(psde, "invalid source %u, %u, %ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1286 | src.x, src.y, src.w, src.h); |
| 1287 | ret = -E2BIG; |
| 1288 | |
| 1289 | /* valid yuv image */ |
| 1290 | } else if (SDE_FORMAT_IS_YUV(fmt) && ((src.x & 0x1) || (src.y & 0x1) || |
| 1291 | (src.w & 0x1) || (src.h & 0x1))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1292 | SDE_ERROR_PLANE(psde, "invalid yuv source %u, %u, %ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1293 | src.x, src.y, src.w, src.h); |
| 1294 | ret = -EINVAL; |
| 1295 | |
| 1296 | /* min dst support */ |
| 1297 | } else if (dst.w < 0x1 || dst.h < 0x1) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1298 | SDE_ERROR_PLANE(psde, "invalid dest rect %u, %u, %ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1299 | dst.x, dst.y, dst.w, dst.h); |
| 1300 | ret = -EINVAL; |
| 1301 | |
| 1302 | /* decimation validation */ |
| 1303 | } else if (deci_w || deci_h) { |
| 1304 | if ((deci_w > psde->pipe_sblk->maxhdeciexp) || |
| 1305 | (deci_h > psde->pipe_sblk->maxvdeciexp)) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1306 | SDE_ERROR_PLANE(psde, |
| 1307 | "too much decimation requested\n"); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1308 | ret = -EINVAL; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1309 | } else if (fmt->fetch_mode != SDE_FETCH_LINEAR) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1310 | SDE_ERROR_PLANE(psde, |
| 1311 | "decimation requires linear fetch\n"); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1312 | ret = -EINVAL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1313 | } |
| 1314 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1315 | } else if (!(psde->features & SDE_SSPP_SCALER) && |
| 1316 | ((src.w != dst.w) || (src.h != dst.h))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1317 | SDE_ERROR_PLANE(psde, |
| 1318 | "pipe doesn't support scaling %ux%u->%ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1319 | src.w, src.h, dst.w, dst.h); |
| 1320 | ret = -EINVAL; |
| 1321 | |
| 1322 | /* check decimated source width */ |
| 1323 | } else if (src_deci_w > max_linewidth) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1324 | SDE_ERROR_PLANE(psde, |
| 1325 | "invalid src w:%u, deci w:%u, line w:%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1326 | src.w, src_deci_w, max_linewidth); |
| 1327 | ret = -E2BIG; |
| 1328 | |
| 1329 | /* check max scaler capability */ |
| 1330 | } else if (((src_deci_w * max_upscale) < dst.w) || |
| 1331 | ((src_deci_h * max_upscale) < dst.h) || |
| 1332 | ((dst.w * max_downscale) < src_deci_w) || |
| 1333 | ((dst.h * max_downscale) < src_deci_h)) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1334 | SDE_ERROR_PLANE(psde, |
| 1335 | "too much scaling requested %ux%u->%ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1336 | src_deci_w, src_deci_h, dst.w, dst.h); |
| 1337 | ret = -E2BIG; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1338 | } |
| 1339 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1340 | modeset_update: |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1341 | if (!ret) |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1342 | _sde_plane_atomic_check_mode_changed(psde, state, plane->state); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1343 | exit: |
| 1344 | return ret; |
| 1345 | } |
| 1346 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1347 | /** |
| 1348 | * sde_plane_flush - final plane operations before commit flush |
| 1349 | * @plane: Pointer to drm plane structure |
| 1350 | */ |
| 1351 | void sde_plane_flush(struct drm_plane *plane) |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1352 | { |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1353 | struct sde_plane *psde; |
| 1354 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1355 | if (!plane) { |
| 1356 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1357 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1358 | } |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1359 | |
| 1360 | psde = to_sde_plane(plane); |
| 1361 | |
| 1362 | /* |
| 1363 | * These updates have to be done immediately before the plane flush |
| 1364 | * timing, and may not be moved to the atomic_update/mode_set functions. |
| 1365 | */ |
| 1366 | if (psde->is_error) |
| 1367 | /* force white frame with 0% alpha pipe output on error */ |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1368 | _sde_plane_color_fill(psde, 0xFFFFFF, 0x0); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1369 | else if (psde->color_fill & SDE_PLANE_COLOR_FILL_FLAG) |
| 1370 | /* force 100% alpha */ |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1371 | _sde_plane_color_fill(psde, psde->color_fill, 0xFF); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1372 | else if (psde->pipe_hw && psde->csc_ptr && psde->pipe_hw->ops.setup_csc) |
| 1373 | psde->pipe_hw->ops.setup_csc(psde->pipe_hw, psde->csc_ptr); |
| 1374 | |
| 1375 | /* flag h/w flush complete */ |
| 1376 | if (plane->state) |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1377 | to_sde_plane_state(plane->state)->pending = false; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1378 | } |
| 1379 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1380 | static void sde_plane_atomic_update(struct drm_plane *plane, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1381 | struct drm_plane_state *old_state) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1382 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1383 | struct sde_plane *psde; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1384 | struct drm_plane_state *state; |
| 1385 | struct sde_plane_state *pstate; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1386 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1387 | if (!plane) { |
| 1388 | SDE_ERROR("invalid plane\n"); |
| 1389 | return; |
| 1390 | } else if (!plane->state) { |
| 1391 | SDE_ERROR("invalid plane state\n"); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1392 | return; |
| 1393 | } |
| 1394 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1395 | psde = to_sde_plane(plane); |
| 1396 | psde->is_error = false; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1397 | state = plane->state; |
| 1398 | pstate = to_sde_plane_state(state); |
| 1399 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1400 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1401 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1402 | if (!sde_plane_enabled(state)) { |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1403 | pstate->pending = true; |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1404 | } else { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1405 | int ret; |
| 1406 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1407 | ret = _sde_plane_mode_set(plane, state); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1408 | /* atomic_check should have ensured that this doesn't fail */ |
| 1409 | WARN_ON(ret < 0); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1410 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1411 | } |
| 1412 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1413 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1414 | /* helper to install properties which are common to planes and crtcs */ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1415 | static void _sde_plane_install_properties(struct drm_plane *plane, |
Clarence Ip | c47a069 | 2016-10-11 10:54:17 -0400 | [diff] [blame] | 1416 | struct sde_mdss_cfg *catalog) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1417 | { |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1418 | static const struct drm_prop_enum_list e_blend_op[] = { |
| 1419 | {SDE_DRM_BLEND_OP_NOT_DEFINED, "not_defined"}, |
| 1420 | {SDE_DRM_BLEND_OP_OPAQUE, "opaque"}, |
| 1421 | {SDE_DRM_BLEND_OP_PREMULTIPLIED, "premultiplied"}, |
| 1422 | {SDE_DRM_BLEND_OP_COVERAGE, "coverage"} |
| 1423 | }; |
| 1424 | static const struct drm_prop_enum_list e_src_config[] = { |
| 1425 | {SDE_DRM_DEINTERLACE, "deinterlace"} |
| 1426 | }; |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 1427 | const struct sde_format_extended *format_list; |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1428 | struct sde_kms_info *info; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1429 | struct sde_plane *psde = to_sde_plane(plane); |
Clarence Ip | c47a069 | 2016-10-11 10:54:17 -0400 | [diff] [blame] | 1430 | int zpos_max = 255; |
| 1431 | int zpos_def = 0; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1432 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1433 | if (!plane || !psde) { |
| 1434 | SDE_ERROR("invalid plane\n"); |
| 1435 | return; |
| 1436 | } else if (!psde->pipe_hw || !psde->pipe_sblk) { |
| 1437 | SDE_ERROR("invalid plane, pipe_hw %d pipe_sblk %d\n", |
| 1438 | psde->pipe_hw != 0, psde->pipe_sblk != 0); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1439 | return; |
Clarence Ip | c47a069 | 2016-10-11 10:54:17 -0400 | [diff] [blame] | 1440 | } else if (!catalog) { |
| 1441 | SDE_ERROR("invalid catalog\n"); |
| 1442 | return; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1443 | } |
| 1444 | |
Clarence Ip | c47a069 | 2016-10-11 10:54:17 -0400 | [diff] [blame] | 1445 | if (sde_is_custom_client()) { |
| 1446 | if (catalog->mixer_count && catalog->mixer) |
| 1447 | zpos_max = catalog->mixer[0].sblk->maxblendstages; |
| 1448 | } else if (plane->type != DRM_PLANE_TYPE_PRIMARY) { |
| 1449 | /* reserve zpos == 0 for primary planes */ |
| 1450 | zpos_def = drm_plane_index(plane) + 1; |
| 1451 | } |
| 1452 | |
| 1453 | msm_property_install_range(&psde->property_info, "zpos", |
| 1454 | 0x0, 0, zpos_max, zpos_def, PLANE_PROP_ZPOS); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1455 | |
Lloyd Atkinson | 38ad8c9 | 2016-07-06 10:39:32 -0400 | [diff] [blame] | 1456 | msm_property_install_range(&psde->property_info, "alpha", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1457 | 0x0, 0, 255, 255, PLANE_PROP_ALPHA); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1458 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1459 | /* linux default file descriptor range on each process */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1460 | msm_property_install_range(&psde->property_info, "input_fence", |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1461 | 0x0, 0, INR_OPEN_MAX, 0, PLANE_PROP_INPUT_FENCE); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1462 | |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 1463 | if (psde->pipe_sblk->maxhdeciexp) { |
| 1464 | msm_property_install_range(&psde->property_info, "h_decimate", |
| 1465 | 0x0, 0, psde->pipe_sblk->maxhdeciexp, 0, |
| 1466 | PLANE_PROP_H_DECIMATE); |
| 1467 | } |
| 1468 | |
| 1469 | if (psde->pipe_sblk->maxvdeciexp) { |
| 1470 | msm_property_install_range(&psde->property_info, "v_decimate", |
| 1471 | 0x0, 0, psde->pipe_sblk->maxvdeciexp, 0, |
| 1472 | PLANE_PROP_V_DECIMATE); |
| 1473 | } |
| 1474 | |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 1475 | if (psde->features & BIT(SDE_SSPP_SCALER_QSEED3)) { |
| 1476 | msm_property_install_volatile_range(&psde->property_info, |
| 1477 | "scaler_v2", 0x0, 0, ~0, 0, PLANE_PROP_SCALER_V2); |
| 1478 | msm_property_install_blob(&psde->property_info, "lut_ed", 0, |
| 1479 | PLANE_PROP_SCALER_LUT_ED); |
| 1480 | msm_property_install_blob(&psde->property_info, "lut_cir", 0, |
| 1481 | PLANE_PROP_SCALER_LUT_CIR); |
| 1482 | msm_property_install_blob(&psde->property_info, "lut_sep", 0, |
| 1483 | PLANE_PROP_SCALER_LUT_SEP); |
| 1484 | } else if (psde->features & SDE_SSPP_SCALER) { |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1485 | msm_property_install_volatile_range(&psde->property_info, |
| 1486 | "scaler_v1", 0x0, 0, ~0, 0, PLANE_PROP_SCALER_V1); |
| 1487 | } |
| 1488 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1489 | if (psde->features & BIT(SDE_SSPP_CSC)) { |
| 1490 | msm_property_install_volatile_range(&psde->property_info, |
| 1491 | "csc_v1", 0x0, 0, ~0, 0, PLANE_PROP_CSC_V1); |
| 1492 | } |
| 1493 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1494 | /* standard properties */ |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1495 | msm_property_install_rotation(&psde->property_info, |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1496 | BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y), PLANE_PROP_ROTATION); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1497 | |
Lloyd Atkinson | 38ad8c9 | 2016-07-06 10:39:32 -0400 | [diff] [blame] | 1498 | msm_property_install_enum(&psde->property_info, "blend_op", 0x0, 0, |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1499 | e_blend_op, ARRAY_SIZE(e_blend_op), PLANE_PROP_BLEND_OP); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1500 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1501 | msm_property_install_enum(&psde->property_info, "src_config", 0x0, 1, |
| 1502 | e_src_config, ARRAY_SIZE(e_src_config), PLANE_PROP_SRC_CONFIG); |
| 1503 | |
| 1504 | if (psde->pipe_hw->ops.setup_solidfill) |
| 1505 | msm_property_install_range(&psde->property_info, "color_fill", |
| 1506 | 0, 0, 0xFFFFFFFF, 0, PLANE_PROP_COLOR_FILL); |
| 1507 | |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1508 | info = kzalloc(sizeof(struct sde_kms_info), GFP_KERNEL); |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1509 | if (!info) { |
| 1510 | SDE_ERROR("failed to allocate info memory\n"); |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1511 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1512 | } |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1513 | |
| 1514 | msm_property_install_blob(&psde->property_info, "capabilities", |
| 1515 | DRM_MODE_PROP_IMMUTABLE, PLANE_PROP_INFO); |
| 1516 | sde_kms_info_reset(info); |
| 1517 | |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 1518 | format_list = psde->pipe_sblk->format_list; |
| 1519 | if (format_list) { |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 1520 | sde_kms_info_start(info, "pixel_formats"); |
| 1521 | while (format_list->fourcc_format) { |
| 1522 | sde_kms_info_append_format(info, |
| 1523 | format_list->fourcc_format, |
| 1524 | format_list->modifier); |
| 1525 | ++format_list; |
| 1526 | } |
| 1527 | sde_kms_info_stop(info); |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 1528 | } |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1529 | |
| 1530 | sde_kms_info_add_keyint(info, "max_linewidth", |
| 1531 | psde->pipe_sblk->maxlinewidth); |
| 1532 | sde_kms_info_add_keyint(info, "max_upscale", |
| 1533 | psde->pipe_sblk->maxupscale); |
| 1534 | sde_kms_info_add_keyint(info, "max_downscale", |
| 1535 | psde->pipe_sblk->maxdwnscale); |
| 1536 | sde_kms_info_add_keyint(info, "max_horizontal_deci", |
| 1537 | psde->pipe_sblk->maxhdeciexp); |
| 1538 | sde_kms_info_add_keyint(info, "max_vertical_deci", |
| 1539 | psde->pipe_sblk->maxvdeciexp); |
| 1540 | msm_property_set_blob(&psde->property_info, &psde->blob_info, |
| 1541 | info->data, info->len, PLANE_PROP_INFO); |
| 1542 | |
| 1543 | kfree(info); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1544 | } |
| 1545 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1546 | static inline void _sde_plane_set_csc_v1(struct sde_plane *psde, void *usr_ptr) |
| 1547 | { |
| 1548 | struct sde_drm_csc_v1 csc_v1; |
| 1549 | int i; |
| 1550 | |
| 1551 | if (!psde) { |
| 1552 | SDE_ERROR("invalid plane\n"); |
| 1553 | return; |
| 1554 | } |
| 1555 | |
| 1556 | psde->csc_usr_ptr = NULL; |
| 1557 | if (!usr_ptr) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1558 | SDE_DEBUG_PLANE(psde, "csc data removed\n"); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1559 | return; |
| 1560 | } |
| 1561 | |
| 1562 | if (copy_from_user(&csc_v1, usr_ptr, sizeof(csc_v1))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1563 | SDE_ERROR_PLANE(psde, "failed to copy csc data\n"); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1564 | return; |
| 1565 | } |
| 1566 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1567 | /* populate from user space */ |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1568 | for (i = 0; i < SDE_CSC_MATRIX_COEFF_SIZE; ++i) |
| 1569 | psde->csc_cfg.csc_mv[i] = csc_v1.ctm_coeff[i] >> 16; |
| 1570 | for (i = 0; i < SDE_CSC_BIAS_SIZE; ++i) { |
| 1571 | psde->csc_cfg.csc_pre_bv[i] = csc_v1.pre_bias[i]; |
| 1572 | psde->csc_cfg.csc_post_bv[i] = csc_v1.post_bias[i]; |
| 1573 | } |
| 1574 | for (i = 0; i < SDE_CSC_CLAMP_SIZE; ++i) { |
| 1575 | psde->csc_cfg.csc_pre_lv[i] = csc_v1.pre_clamp[i]; |
| 1576 | psde->csc_cfg.csc_post_lv[i] = csc_v1.post_clamp[i]; |
| 1577 | } |
| 1578 | psde->csc_usr_ptr = &psde->csc_cfg; |
| 1579 | } |
| 1580 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1581 | static inline void _sde_plane_set_scaler_v1(struct sde_plane *psde, void *usr) |
| 1582 | { |
| 1583 | struct sde_drm_scaler_v1 scale_v1; |
| 1584 | struct sde_hw_pixel_ext *pe; |
| 1585 | int i; |
| 1586 | |
| 1587 | if (!psde) { |
| 1588 | SDE_ERROR("invalid plane\n"); |
| 1589 | return; |
| 1590 | } |
| 1591 | |
| 1592 | psde->pixel_ext_usr = false; |
| 1593 | if (!usr) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1594 | SDE_DEBUG_PLANE(psde, "scale data removed\n"); |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1595 | return; |
| 1596 | } |
| 1597 | |
| 1598 | if (copy_from_user(&scale_v1, usr, sizeof(scale_v1))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1599 | SDE_ERROR_PLANE(psde, "failed to copy scale data\n"); |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1600 | return; |
| 1601 | } |
| 1602 | |
| 1603 | /* populate from user space */ |
| 1604 | pe = &(psde->pixel_ext); |
| 1605 | memset(pe, 0, sizeof(struct sde_hw_pixel_ext)); |
| 1606 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 1607 | pe->init_phase_x[i] = scale_v1.init_phase_x[i]; |
| 1608 | pe->phase_step_x[i] = scale_v1.phase_step_x[i]; |
| 1609 | pe->init_phase_y[i] = scale_v1.init_phase_y[i]; |
| 1610 | pe->phase_step_y[i] = scale_v1.phase_step_y[i]; |
| 1611 | |
| 1612 | pe->horz_filter[i] = scale_v1.horz_filter[i]; |
| 1613 | pe->vert_filter[i] = scale_v1.vert_filter[i]; |
| 1614 | } |
| 1615 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 1616 | pe->num_ext_pxls_left[i] = scale_v1.lr.num_pxls_start[i]; |
| 1617 | pe->num_ext_pxls_right[i] = scale_v1.lr.num_pxls_end[i]; |
| 1618 | pe->left_ftch[i] = scale_v1.lr.ftch_start[i]; |
| 1619 | pe->right_ftch[i] = scale_v1.lr.ftch_end[i]; |
| 1620 | pe->left_rpt[i] = scale_v1.lr.rpt_start[i]; |
| 1621 | pe->right_rpt[i] = scale_v1.lr.rpt_end[i]; |
| 1622 | pe->roi_w[i] = scale_v1.lr.roi[i]; |
| 1623 | |
| 1624 | pe->num_ext_pxls_top[i] = scale_v1.tb.num_pxls_start[i]; |
| 1625 | pe->num_ext_pxls_btm[i] = scale_v1.tb.num_pxls_end[i]; |
| 1626 | pe->top_ftch[i] = scale_v1.tb.ftch_start[i]; |
| 1627 | pe->btm_ftch[i] = scale_v1.tb.ftch_end[i]; |
| 1628 | pe->top_rpt[i] = scale_v1.tb.rpt_start[i]; |
| 1629 | pe->btm_rpt[i] = scale_v1.tb.rpt_end[i]; |
| 1630 | pe->roi_h[i] = scale_v1.tb.roi[i]; |
| 1631 | } |
| 1632 | psde->pixel_ext_usr = true; |
| 1633 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1634 | SDE_DEBUG_PLANE(psde, "user property data copied\n"); |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1635 | } |
| 1636 | |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 1637 | static inline void _sde_plane_set_scaler_v2(struct sde_plane *psde, |
| 1638 | struct sde_plane_state *pstate, void *usr) |
| 1639 | { |
| 1640 | struct sde_drm_scaler_v2 scale_v2; |
| 1641 | struct sde_hw_pixel_ext *pe; |
| 1642 | int i; |
| 1643 | struct sde_hw_scaler3_cfg *cfg; |
| 1644 | |
| 1645 | if (!psde) { |
| 1646 | SDE_ERROR("invalid plane\n"); |
| 1647 | return; |
| 1648 | } |
| 1649 | |
| 1650 | cfg = psde->scaler3_cfg; |
| 1651 | psde->pixel_ext_usr = false; |
| 1652 | if (!usr) { |
| 1653 | SDE_DEBUG_PLANE(psde, "scale data removed\n"); |
| 1654 | return; |
| 1655 | } |
| 1656 | |
| 1657 | if (copy_from_user(&scale_v2, usr, sizeof(scale_v2))) { |
| 1658 | SDE_ERROR_PLANE(psde, "failed to copy scale data\n"); |
| 1659 | return; |
| 1660 | } |
| 1661 | |
| 1662 | /* populate from user space */ |
| 1663 | pe = &(psde->pixel_ext); |
| 1664 | memset(pe, 0, sizeof(struct sde_hw_pixel_ext)); |
| 1665 | cfg->enable = scale_v2.enable; |
| 1666 | cfg->dir_en = scale_v2.dir_en; |
| 1667 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 1668 | cfg->init_phase_x[i] = scale_v2.init_phase_x[i]; |
| 1669 | cfg->phase_step_x[i] = scale_v2.phase_step_x[i]; |
| 1670 | cfg->init_phase_y[i] = scale_v2.init_phase_y[i]; |
| 1671 | cfg->phase_step_y[i] = scale_v2.phase_step_y[i]; |
| 1672 | |
| 1673 | cfg->preload_x[i] = scale_v2.preload_x[i]; |
| 1674 | cfg->preload_y[i] = scale_v2.preload_y[i]; |
| 1675 | cfg->src_width[i] = scale_v2.src_width[i]; |
| 1676 | cfg->src_height[i] = scale_v2.src_height[i]; |
| 1677 | } |
| 1678 | cfg->dst_width = scale_v2.dst_width; |
| 1679 | cfg->dst_height = scale_v2.dst_height; |
| 1680 | |
| 1681 | cfg->y_rgb_filter_cfg = scale_v2.y_rgb_filter_cfg; |
| 1682 | cfg->uv_filter_cfg = scale_v2.uv_filter_cfg; |
| 1683 | cfg->alpha_filter_cfg = scale_v2.alpha_filter_cfg; |
| 1684 | cfg->blend_cfg = scale_v2.blend_cfg; |
| 1685 | |
| 1686 | cfg->lut_flag = scale_v2.lut_flag; |
| 1687 | cfg->dir_lut_idx = scale_v2.dir_lut_idx; |
| 1688 | cfg->y_rgb_cir_lut_idx = scale_v2.y_rgb_cir_lut_idx; |
| 1689 | cfg->uv_cir_lut_idx = scale_v2.uv_cir_lut_idx; |
| 1690 | cfg->y_rgb_sep_lut_idx = scale_v2.y_rgb_sep_lut_idx; |
| 1691 | cfg->uv_sep_lut_idx = scale_v2.uv_sep_lut_idx; |
| 1692 | |
| 1693 | cfg->de.enable = scale_v2.de.enable; |
| 1694 | cfg->de.sharpen_level1 = scale_v2.de.sharpen_level1; |
| 1695 | cfg->de.sharpen_level2 = scale_v2.de.sharpen_level2; |
| 1696 | cfg->de.clip = scale_v2.de.clip; |
| 1697 | cfg->de.limit = scale_v2.de.limit; |
| 1698 | cfg->de.thr_quiet = scale_v2.de.thr_quiet; |
| 1699 | cfg->de.thr_dieout = scale_v2.de.thr_dieout; |
| 1700 | cfg->de.thr_low = scale_v2.de.thr_low; |
| 1701 | cfg->de.thr_high = scale_v2.de.thr_high; |
| 1702 | cfg->de.prec_shift = scale_v2.de.prec_shift; |
| 1703 | for (i = 0; i < SDE_MAX_DE_CURVES; i++) { |
| 1704 | cfg->de.adjust_a[i] = scale_v2.de.adjust_a[i]; |
| 1705 | cfg->de.adjust_b[i] = scale_v2.de.adjust_b[i]; |
| 1706 | cfg->de.adjust_c[i] = scale_v2.de.adjust_c[i]; |
| 1707 | } |
| 1708 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 1709 | pe->num_ext_pxls_left[i] = scale_v2.lr.num_pxls_start[i]; |
| 1710 | pe->num_ext_pxls_right[i] = scale_v2.lr.num_pxls_end[i]; |
| 1711 | pe->left_ftch[i] = scale_v2.lr.ftch_start[i]; |
| 1712 | pe->right_ftch[i] = scale_v2.lr.ftch_end[i]; |
| 1713 | pe->left_rpt[i] = scale_v2.lr.rpt_start[i]; |
| 1714 | pe->right_rpt[i] = scale_v2.lr.rpt_end[i]; |
| 1715 | pe->roi_w[i] = scale_v2.lr.roi[i]; |
| 1716 | |
| 1717 | pe->num_ext_pxls_top[i] = scale_v2.tb.num_pxls_start[i]; |
| 1718 | pe->num_ext_pxls_btm[i] = scale_v2.tb.num_pxls_end[i]; |
| 1719 | pe->top_ftch[i] = scale_v2.tb.ftch_start[i]; |
| 1720 | pe->btm_ftch[i] = scale_v2.tb.ftch_end[i]; |
| 1721 | pe->top_rpt[i] = scale_v2.tb.rpt_start[i]; |
| 1722 | pe->btm_rpt[i] = scale_v2.tb.rpt_end[i]; |
| 1723 | pe->roi_h[i] = scale_v2.tb.roi[i]; |
| 1724 | } |
| 1725 | psde->pixel_ext_usr = true; |
| 1726 | |
| 1727 | SDE_DEBUG_PLANE(psde, "user property data copied\n"); |
| 1728 | } |
| 1729 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1730 | static int sde_plane_atomic_set_property(struct drm_plane *plane, |
| 1731 | struct drm_plane_state *state, struct drm_property *property, |
| 1732 | uint64_t val) |
| 1733 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1734 | struct sde_plane *psde = plane ? to_sde_plane(plane) : NULL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1735 | struct sde_plane_state *pstate; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1736 | int idx, ret = -EINVAL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1737 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1738 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1739 | |
| 1740 | if (!plane) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1741 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1742 | } else if (!state) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1743 | SDE_ERROR_PLANE(psde, "invalid state\n"); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1744 | } else { |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1745 | pstate = to_sde_plane_state(state); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1746 | ret = msm_property_atomic_set(&psde->property_info, |
| 1747 | pstate->property_values, pstate->property_blobs, |
| 1748 | property, val); |
| 1749 | if (!ret) { |
| 1750 | idx = msm_property_index(&psde->property_info, |
| 1751 | property); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1752 | switch (idx) { |
| 1753 | case PLANE_PROP_INPUT_FENCE: |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1754 | _sde_plane_set_input_fence(psde, pstate, val); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1755 | break; |
| 1756 | case PLANE_PROP_CSC_V1: |
| 1757 | _sde_plane_set_csc_v1(psde, (void *)val); |
| 1758 | break; |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1759 | case PLANE_PROP_SCALER_V1: |
| 1760 | _sde_plane_set_scaler_v1(psde, (void *)val); |
| 1761 | break; |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 1762 | case PLANE_PROP_SCALER_V2: |
| 1763 | _sde_plane_set_scaler_v2(psde, pstate, |
| 1764 | (void *)val); |
| 1765 | break; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1766 | default: |
| 1767 | /* nothing to do */ |
| 1768 | break; |
| 1769 | } |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1770 | } |
| 1771 | } |
| 1772 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1773 | return ret; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1774 | } |
| 1775 | |
| 1776 | static int sde_plane_set_property(struct drm_plane *plane, |
| 1777 | struct drm_property *property, uint64_t val) |
| 1778 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1779 | SDE_DEBUG("\n"); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1780 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1781 | return sde_plane_atomic_set_property(plane, |
| 1782 | plane->state, property, val); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1783 | } |
| 1784 | |
| 1785 | static int sde_plane_atomic_get_property(struct drm_plane *plane, |
| 1786 | const struct drm_plane_state *state, |
| 1787 | struct drm_property *property, uint64_t *val) |
| 1788 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1789 | struct sde_plane *psde = plane ? to_sde_plane(plane) : NULL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1790 | struct sde_plane_state *pstate; |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1791 | int ret = -EINVAL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1792 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1793 | if (!plane) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1794 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1795 | } else if (!state) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1796 | SDE_ERROR("invalid state\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1797 | } else { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1798 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1799 | pstate = to_sde_plane_state(state); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1800 | ret = msm_property_atomic_get(&psde->property_info, |
| 1801 | pstate->property_values, pstate->property_blobs, |
| 1802 | property, val); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1803 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1804 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1805 | return ret; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1806 | } |
| 1807 | |
| 1808 | static void sde_plane_destroy(struct drm_plane *plane) |
| 1809 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1810 | struct sde_plane *psde = plane ? to_sde_plane(plane) : NULL; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1811 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1812 | SDE_DEBUG_PLANE(psde, "\n"); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1813 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1814 | if (psde) { |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 1815 | _sde_plane_set_qos_ctrl(plane, false, SDE_PLANE_QOS_PANIC_CTRL); |
| 1816 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1817 | debugfs_remove_recursive(psde->debugfs_root); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1818 | |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1819 | if (psde->blob_info) |
| 1820 | drm_property_unreference_blob(psde->blob_info); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1821 | msm_property_destroy(&psde->property_info); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1822 | mutex_destroy(&psde->lock); |
| 1823 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1824 | drm_plane_helper_disable(plane); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1825 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1826 | /* this will destroy the states as well */ |
| 1827 | drm_plane_cleanup(plane); |
| 1828 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1829 | if (psde->pipe_hw) |
| 1830 | sde_hw_sspp_destroy(psde->pipe_hw); |
| 1831 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1832 | kfree(psde); |
| 1833 | } |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1834 | } |
| 1835 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1836 | static void sde_plane_destroy_state(struct drm_plane *plane, |
| 1837 | struct drm_plane_state *state) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1838 | { |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1839 | struct sde_plane *psde; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1840 | struct sde_plane_state *pstate; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1841 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1842 | if (!plane || !state) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1843 | SDE_ERROR("invalid arg(s), plane %d state %d\n", |
| 1844 | plane != 0, state != 0); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1845 | return; |
| 1846 | } |
| 1847 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1848 | psde = to_sde_plane(plane); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1849 | pstate = to_sde_plane_state(state); |
| 1850 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1851 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1852 | |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1853 | /* remove ref count for frame buffers */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1854 | if (state->fb) |
| 1855 | drm_framebuffer_unreference(state->fb); |
| 1856 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1857 | /* remove ref count for fence */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1858 | if (pstate->input_fence) |
| 1859 | sde_sync_put(pstate->input_fence); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1860 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1861 | /* destroy value helper */ |
| 1862 | msm_property_destroy_state(&psde->property_info, pstate, |
| 1863 | pstate->property_values, pstate->property_blobs); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1864 | } |
| 1865 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1866 | static struct drm_plane_state * |
| 1867 | sde_plane_duplicate_state(struct drm_plane *plane) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1868 | { |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1869 | struct sde_plane *psde; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1870 | struct sde_plane_state *pstate; |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1871 | struct sde_plane_state *old_state; |
Clarence Ip | 17e908b | 2016-09-29 15:58:00 -0400 | [diff] [blame] | 1872 | uint64_t input_fence_default; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1873 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1874 | if (!plane) { |
| 1875 | SDE_ERROR("invalid plane\n"); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1876 | return NULL; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1877 | } else if (!plane->state) { |
| 1878 | SDE_ERROR("invalid plane state\n"); |
| 1879 | return NULL; |
| 1880 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1881 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1882 | old_state = to_sde_plane_state(plane->state); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1883 | psde = to_sde_plane(plane); |
| 1884 | pstate = msm_property_alloc_state(&psde->property_info); |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1885 | if (!pstate) { |
| 1886 | SDE_ERROR_PLANE(psde, "failed to allocate state\n"); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1887 | return NULL; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1888 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1889 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1890 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1891 | |
| 1892 | /* duplicate value helper */ |
| 1893 | msm_property_duplicate_state(&psde->property_info, old_state, pstate, |
| 1894 | pstate->property_values, pstate->property_blobs); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1895 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1896 | /* add ref count for frame buffer */ |
| 1897 | if (pstate->base.fb) |
| 1898 | drm_framebuffer_reference(pstate->base.fb); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1899 | |
Clarence Ip | 17e908b | 2016-09-29 15:58:00 -0400 | [diff] [blame] | 1900 | /* clear out any input fence */ |
| 1901 | pstate->input_fence = 0; |
| 1902 | input_fence_default = msm_property_get_default( |
| 1903 | &psde->property_info, PLANE_PROP_INPUT_FENCE); |
| 1904 | msm_property_set_property(&psde->property_info, pstate->property_values, |
| 1905 | PLANE_PROP_INPUT_FENCE, input_fence_default); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1906 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1907 | pstate->dirty = 0x0; |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1908 | pstate->pending = false; |
| 1909 | |
| 1910 | return &pstate->base; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1911 | } |
| 1912 | |
| 1913 | static void sde_plane_reset(struct drm_plane *plane) |
| 1914 | { |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1915 | struct sde_plane *psde; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1916 | struct sde_plane_state *pstate; |
| 1917 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1918 | if (!plane) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1919 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1920 | return; |
| 1921 | } |
| 1922 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1923 | psde = to_sde_plane(plane); |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1924 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1925 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1926 | /* remove previous state, if present */ |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1927 | if (plane->state) { |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1928 | sde_plane_destroy_state(plane, plane->state); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1929 | plane->state = 0; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1930 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1931 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1932 | pstate = msm_property_alloc_state(&psde->property_info); |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1933 | if (!pstate) { |
| 1934 | SDE_ERROR_PLANE(psde, "failed to allocate state\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1935 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1936 | } |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1937 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1938 | /* reset value helper */ |
| 1939 | msm_property_reset_state(&psde->property_info, pstate, |
| 1940 | pstate->property_values, pstate->property_blobs); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1941 | |
| 1942 | pstate->base.plane = plane; |
| 1943 | |
| 1944 | plane->state = &pstate->base; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1945 | } |
| 1946 | |
| 1947 | static const struct drm_plane_funcs sde_plane_funcs = { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1948 | .update_plane = drm_atomic_helper_update_plane, |
| 1949 | .disable_plane = drm_atomic_helper_disable_plane, |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1950 | .destroy = sde_plane_destroy, |
| 1951 | .set_property = sde_plane_set_property, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1952 | .atomic_set_property = sde_plane_atomic_set_property, |
| 1953 | .atomic_get_property = sde_plane_atomic_get_property, |
| 1954 | .reset = sde_plane_reset, |
| 1955 | .atomic_duplicate_state = sde_plane_duplicate_state, |
| 1956 | .atomic_destroy_state = sde_plane_destroy_state, |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1957 | }; |
| 1958 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1959 | static const struct drm_plane_helper_funcs sde_plane_helper_funcs = { |
| 1960 | .prepare_fb = sde_plane_prepare_fb, |
| 1961 | .cleanup_fb = sde_plane_cleanup_fb, |
| 1962 | .atomic_check = sde_plane_atomic_check, |
| 1963 | .atomic_update = sde_plane_atomic_update, |
| 1964 | }; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1965 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1966 | enum sde_sspp sde_plane_pipe(struct drm_plane *plane) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1967 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1968 | return plane ? to_sde_plane(plane)->pipe : SSPP_NONE; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1969 | } |
| 1970 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1971 | static void _sde_plane_init_debugfs(struct sde_plane *psde, struct sde_kms *kms) |
| 1972 | { |
| 1973 | const struct sde_sspp_sub_blks *sblk = 0; |
| 1974 | const struct sde_sspp_cfg *cfg = 0; |
| 1975 | |
| 1976 | if (psde && psde->pipe_hw) |
| 1977 | cfg = psde->pipe_hw->cap; |
| 1978 | if (cfg) |
| 1979 | sblk = cfg->sblk; |
| 1980 | |
| 1981 | if (kms && sblk) { |
| 1982 | /* create overall sub-directory for the pipe */ |
| 1983 | psde->debugfs_root = |
| 1984 | debugfs_create_dir(psde->pipe_name, |
| 1985 | sde_debugfs_get_root(kms)); |
| 1986 | if (psde->debugfs_root) { |
| 1987 | /* don't error check these */ |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1988 | debugfs_create_x32("features", 0644, |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1989 | psde->debugfs_root, &psde->features); |
| 1990 | |
| 1991 | /* add register dump support */ |
| 1992 | sde_debugfs_setup_regset32(&psde->debugfs_src, |
| 1993 | sblk->src_blk.base + cfg->base, |
| 1994 | sblk->src_blk.len, |
Clarence Ip | aac9f33 | 2016-08-31 15:46:35 -0400 | [diff] [blame] | 1995 | kms); |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1996 | sde_debugfs_create_regset32("src_blk", 0444, |
| 1997 | psde->debugfs_root, &psde->debugfs_src); |
| 1998 | |
| 1999 | sde_debugfs_setup_regset32(&psde->debugfs_scaler, |
| 2000 | sblk->scaler_blk.base + cfg->base, |
| 2001 | sblk->scaler_blk.len, |
Clarence Ip | aac9f33 | 2016-08-31 15:46:35 -0400 | [diff] [blame] | 2002 | kms); |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 2003 | sde_debugfs_create_regset32("scaler_blk", 0444, |
| 2004 | psde->debugfs_root, |
| 2005 | &psde->debugfs_scaler); |
| 2006 | |
| 2007 | sde_debugfs_setup_regset32(&psde->debugfs_csc, |
| 2008 | sblk->csc_blk.base + cfg->base, |
| 2009 | sblk->csc_blk.len, |
Clarence Ip | aac9f33 | 2016-08-31 15:46:35 -0400 | [diff] [blame] | 2010 | kms); |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 2011 | sde_debugfs_create_regset32("csc_blk", 0444, |
| 2012 | psde->debugfs_root, &psde->debugfs_csc); |
| 2013 | } |
| 2014 | } |
| 2015 | } |
| 2016 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2017 | /* initialize plane */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 2018 | struct drm_plane *sde_plane_init(struct drm_device *dev, |
Clarence Ip | 2bbf7b3 | 2016-09-23 15:07:16 -0400 | [diff] [blame] | 2019 | uint32_t pipe, bool primary_plane, |
| 2020 | unsigned long possible_crtcs) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2021 | { |
| 2022 | struct drm_plane *plane = NULL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2023 | struct sde_plane *psde; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2024 | struct msm_drm_private *priv; |
| 2025 | struct sde_kms *kms; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2026 | enum drm_plane_type type; |
Clarence Ip | c47a069 | 2016-10-11 10:54:17 -0400 | [diff] [blame] | 2027 | int ret = -EINVAL; |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2028 | |
| 2029 | if (!dev) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2030 | SDE_ERROR("[%u]device is NULL\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2031 | goto exit; |
| 2032 | } |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2033 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2034 | priv = dev->dev_private; |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 2035 | if (!priv) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2036 | SDE_ERROR("[%u]private data is NULL\n", pipe); |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 2037 | goto exit; |
| 2038 | } |
| 2039 | |
| 2040 | if (!priv->kms) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2041 | SDE_ERROR("[%u]invalid KMS reference\n", pipe); |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 2042 | goto exit; |
| 2043 | } |
| 2044 | kms = to_sde_kms(priv->kms); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2045 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2046 | if (!kms->catalog) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2047 | SDE_ERROR("[%u]invalid catalog reference\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2048 | goto exit; |
| 2049 | } |
| 2050 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 2051 | /* create and zero local structure */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2052 | psde = kzalloc(sizeof(*psde), GFP_KERNEL); |
| 2053 | if (!psde) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2054 | SDE_ERROR("[%u]failed to allocate local plane struct\n", pipe); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2055 | ret = -ENOMEM; |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2056 | goto exit; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2057 | } |
| 2058 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2059 | /* cache local stuff for later */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2060 | plane = &psde->base; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2061 | psde->pipe = pipe; |
Alan Kwong | 112a84f | 2016-05-24 20:49:21 -0400 | [diff] [blame] | 2062 | psde->mmu_id = kms->mmu_id[MSM_SMMU_DOMAIN_UNSECURE]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2063 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2064 | /* initialize underlying h/w driver */ |
| 2065 | psde->pipe_hw = sde_hw_sspp_init(pipe, kms->mmio, kms->catalog); |
| 2066 | if (IS_ERR(psde->pipe_hw)) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2067 | SDE_ERROR("[%u]SSPP init failed\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2068 | ret = PTR_ERR(psde->pipe_hw); |
| 2069 | goto clean_plane; |
| 2070 | } else if (!psde->pipe_hw->cap || !psde->pipe_hw->cap->sblk) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2071 | SDE_ERROR("[%u]SSPP init returned invalid cfg\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2072 | goto clean_sspp; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2073 | } |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2074 | |
| 2075 | /* cache features mask for later */ |
| 2076 | psde->features = psde->pipe_hw->cap->features; |
| 2077 | psde->pipe_sblk = psde->pipe_hw->cap->sblk; |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 2078 | if (!psde->pipe_sblk) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2079 | SDE_ERROR("[%u]invalid sblk\n", pipe); |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 2080 | goto clean_sspp; |
| 2081 | } |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2082 | |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 2083 | if (psde->features & BIT(SDE_SSPP_SCALER_QSEED3)) { |
| 2084 | psde->scaler3_cfg = kzalloc(sizeof(struct sde_hw_scaler3_cfg), |
| 2085 | GFP_KERNEL); |
| 2086 | if (!psde->scaler3_cfg) { |
| 2087 | SDE_ERROR("[%u]failed to allocate scale struct\n", |
| 2088 | pipe); |
| 2089 | ret = -ENOMEM; |
| 2090 | goto clean_sspp; |
| 2091 | } |
| 2092 | } |
| 2093 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2094 | /* add plane to DRM framework */ |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 2095 | psde->nformats = sde_populate_formats(psde->pipe_sblk->format_list, |
| 2096 | psde->formats, |
| 2097 | 0, |
| 2098 | ARRAY_SIZE(psde->formats)); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2099 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2100 | if (!psde->nformats) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2101 | SDE_ERROR("[%u]no valid formats for plane\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2102 | goto clean_sspp; |
| 2103 | } |
| 2104 | |
| 2105 | if (psde->features & BIT(SDE_SSPP_CURSOR)) |
| 2106 | type = DRM_PLANE_TYPE_CURSOR; |
| 2107 | else if (primary_plane) |
| 2108 | type = DRM_PLANE_TYPE_PRIMARY; |
| 2109 | else |
| 2110 | type = DRM_PLANE_TYPE_OVERLAY; |
Clarence Ip | 2bbf7b3 | 2016-09-23 15:07:16 -0400 | [diff] [blame] | 2111 | ret = drm_universal_plane_init(dev, plane, possible_crtcs, |
| 2112 | &sde_plane_funcs, psde->formats, psde->nformats, type); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2113 | if (ret) |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2114 | goto clean_sspp; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2115 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2116 | /* success! finalize initialization */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2117 | drm_plane_helper_add(plane, &sde_plane_helper_funcs); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2118 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 2119 | msm_property_init(&psde->property_info, &plane->base, dev, |
| 2120 | priv->plane_property, psde->property_data, |
| 2121 | PLANE_PROP_COUNT, PLANE_PROP_BLOBCOUNT, |
| 2122 | sizeof(struct sde_plane_state)); |
| 2123 | |
Clarence Ip | c47a069 | 2016-10-11 10:54:17 -0400 | [diff] [blame] | 2124 | _sde_plane_install_properties(plane, kms->catalog); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 2125 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 2126 | /* save user friendly pipe name for later */ |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 2127 | snprintf(psde->pipe_name, SDE_NAME_SIZE, "plane%u", plane->base.id); |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 2128 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 2129 | mutex_init(&psde->lock); |
| 2130 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 2131 | _sde_plane_init_debugfs(psde, kms); |
| 2132 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2133 | DRM_INFO("%s created for pipe %u\n", psde->pipe_name, pipe); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2134 | return plane; |
| 2135 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2136 | clean_sspp: |
| 2137 | if (psde && psde->pipe_hw) |
| 2138 | sde_hw_sspp_destroy(psde->pipe_hw); |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 2139 | |
| 2140 | if (psde && psde->scaler3_cfg) |
| 2141 | kfree(psde->scaler3_cfg); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 2142 | clean_plane: |
| 2143 | kfree(psde); |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 2144 | exit: |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2145 | return ERR_PTR(ret); |
| 2146 | } |