Dhaval Patel | 14d46ce | 2017-01-17 16:28:12 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014-2017 The Linux Foundation. All rights reserved. |
| 3 | * Copyright (C) 2013 Red Hat |
| 4 | * Author: Rob Clark <robdclark@gmail.com> |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 5 | * |
Dhaval Patel | 14d46ce | 2017-01-17 16:28:12 -0800 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published by |
| 8 | * the Free Software Foundation. |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 9 | * |
Dhaval Patel | 14d46ce | 2017-01-17 16:28:12 -0800 | [diff] [blame] | 10 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along with |
| 16 | * this program. If not, see <http://www.gnu.org/licenses/>. |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 17 | */ |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 18 | |
| 19 | #define pr_fmt(fmt) "[drm:%s:%d] " fmt, __func__, __LINE__ |
| 20 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 21 | #include <linux/debugfs.h> |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 22 | #include <linux/dma-buf.h> |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 23 | #include <uapi/drm/sde_drm.h> |
Benet Clark | d009b1d | 2016-06-27 14:45:59 -0700 | [diff] [blame] | 24 | #include <uapi/drm/msm_drm_pp.h> |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 25 | |
| 26 | #include "msm_prop.h" |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 27 | #include "msm_drv.h" |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 28 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 29 | #include "sde_kms.h" |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 30 | #include "sde_fence.h" |
Clarence Ip | c475b08 | 2016-06-26 09:27:23 -0400 | [diff] [blame] | 31 | #include "sde_formats.h" |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 32 | #include "sde_hw_sspp.h" |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 33 | #include "sde_hw_catalog_format.h" |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 34 | #include "sde_trace.h" |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 35 | #include "sde_crtc.h" |
Lloyd Atkinson | 8772e20 | 2016-09-26 17:52:16 -0400 | [diff] [blame] | 36 | #include "sde_vbif.h" |
Alan Kwong | 83285fb | 2016-10-21 20:51:17 -0400 | [diff] [blame] | 37 | #include "sde_plane.h" |
Benet Clark | d009b1d | 2016-06-27 14:45:59 -0700 | [diff] [blame] | 38 | #include "sde_color_processing.h" |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 39 | #include "sde_hw_rot.h" |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 40 | |
Clarence Ip | 5690279 | 2017-03-17 15:22:07 -0400 | [diff] [blame] | 41 | static bool suspend_blank = true; |
| 42 | module_param(suspend_blank, bool, 0400); |
| 43 | MODULE_PARM_DESC(suspend_blank, |
| 44 | "If set, active planes will force their outputs to black,\n" |
| 45 | "by temporarily enabling the color fill, when recovering\n" |
| 46 | "from a system resume instead of attempting to display the\n" |
| 47 | "last provided frame buffer."); |
| 48 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 49 | #define SDE_DEBUG_PLANE(pl, fmt, ...) SDE_DEBUG("plane%d " fmt,\ |
| 50 | (pl) ? (pl)->base.base.id : -1, ##__VA_ARGS__) |
| 51 | |
| 52 | #define SDE_ERROR_PLANE(pl, fmt, ...) SDE_ERROR("plane%d " fmt,\ |
| 53 | (pl) ? (pl)->base.base.id : -1, ##__VA_ARGS__) |
| 54 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 55 | #define DECIMATED_DIMENSION(dim, deci) (((dim) + ((1 << (deci)) - 1)) >> (deci)) |
| 56 | #define PHASE_STEP_SHIFT 21 |
| 57 | #define PHASE_STEP_UNIT_SCALE ((int) (1 << PHASE_STEP_SHIFT)) |
| 58 | #define PHASE_RESIDUAL 15 |
| 59 | |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 60 | #define SHARP_STRENGTH_DEFAULT 32 |
| 61 | #define SHARP_EDGE_THR_DEFAULT 112 |
| 62 | #define SHARP_SMOOTH_THR_DEFAULT 8 |
| 63 | #define SHARP_NOISE_THR_DEFAULT 2 |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 64 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 65 | #define SDE_NAME_SIZE 12 |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 66 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 67 | #define SDE_PLANE_COLOR_FILL_FLAG BIT(31) |
| 68 | |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 69 | /* multirect rect index */ |
| 70 | enum { |
| 71 | R0, |
| 72 | R1, |
| 73 | R_MAX |
| 74 | }; |
| 75 | |
| 76 | #define TX_MODE_BUFFER_LINE_THRES 2 |
| 77 | |
Gopikrishnaiah Anandan | f4c3429 | 2016-10-20 15:42:04 -0700 | [diff] [blame] | 78 | #define SDE_QSEED3_DEFAULT_PRELOAD_H 0x4 |
| 79 | #define SDE_QSEED3_DEFAULT_PRELOAD_V 0x3 |
| 80 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 81 | #define DEFAULT_REFRESH_RATE 60 |
| 82 | |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 83 | /** |
| 84 | * enum sde_plane_qos - Different qos configurations for each pipe |
| 85 | * |
| 86 | * @SDE_PLANE_QOS_VBLANK_CTRL: Setup VBLANK qos for the pipe. |
| 87 | * @SDE_PLANE_QOS_VBLANK_AMORTIZE: Enables Amortization within pipe. |
| 88 | * this configuration is mutually exclusive from VBLANK_CTRL. |
| 89 | * @SDE_PLANE_QOS_PANIC_CTRL: Setup panic for the pipe. |
| 90 | */ |
| 91 | enum sde_plane_qos { |
| 92 | SDE_PLANE_QOS_VBLANK_CTRL = BIT(0), |
| 93 | SDE_PLANE_QOS_VBLANK_AMORTIZE = BIT(1), |
| 94 | SDE_PLANE_QOS_PANIC_CTRL = BIT(2), |
| 95 | }; |
| 96 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 97 | /* |
| 98 | * struct sde_plane - local sde plane structure |
| 99 | * @csc_cfg: Decoded user configuration for csc |
| 100 | * @csc_usr_ptr: Points to csc_cfg if valid user config available |
| 101 | * @csc_ptr: Points to sde_csc_cfg structure to use for current |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 102 | * @catalog: Points to sde catalog structure |
| 103 | * @sbuf_mode: force stream buffer mode if set |
Veera Sundaram Sankaran | 82916e0 | 2017-03-29 18:44:22 -0700 | [diff] [blame] | 104 | * @sbuf_writeback: force stream buffer writeback if set |
| 105 | * @revalidate: force revalidation of all the plane properties |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 106 | * @blob_rot_caps: Pointer to rotator capability blob |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 107 | */ |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 108 | struct sde_plane { |
| 109 | struct drm_plane base; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 110 | |
| 111 | int mmu_id; |
| 112 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 113 | struct mutex lock; |
| 114 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 115 | enum sde_sspp pipe; |
| 116 | uint32_t features; /* capabilities from catalog */ |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 117 | uint32_t nformats; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 118 | uint32_t formats[64]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 119 | |
| 120 | struct sde_hw_pipe *pipe_hw; |
| 121 | struct sde_hw_pipe_cfg pipe_cfg; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 122 | struct sde_hw_sharp_cfg sharp_cfg; |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 123 | struct sde_hw_scaler3_cfg *scaler3_cfg; |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 124 | struct sde_hw_pipe_qos_cfg pipe_qos_cfg; |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 125 | uint32_t color_fill; |
| 126 | bool is_error; |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 127 | bool is_rt_pipe; |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 128 | bool is_virtual; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 129 | struct sde_mdss_cfg *catalog; |
| 130 | u32 sbuf_mode; |
| 131 | u32 sbuf_writeback; |
Veera Sundaram Sankaran | 82916e0 | 2017-03-29 18:44:22 -0700 | [diff] [blame] | 132 | bool revalidate; |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 133 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 134 | struct sde_hw_pixel_ext pixel_ext; |
| 135 | bool pixel_ext_usr; |
| 136 | |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 137 | struct sde_csc_cfg csc_cfg; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 138 | struct sde_csc_cfg *csc_usr_ptr; |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 139 | struct sde_csc_cfg *csc_ptr; |
| 140 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 141 | const struct sde_sspp_sub_blks *pipe_sblk; |
| 142 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 143 | char pipe_name[SDE_NAME_SIZE]; |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 144 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 145 | struct msm_property_info property_info; |
| 146 | struct msm_property_data property_data[PLANE_PROP_COUNT]; |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 147 | struct drm_property_blob *blob_info; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 148 | struct drm_property_blob *blob_rot_caps; |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 149 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 150 | /* debugfs related stuff */ |
| 151 | struct dentry *debugfs_root; |
| 152 | struct sde_debugfs_regset32 debugfs_src; |
| 153 | struct sde_debugfs_regset32 debugfs_scaler; |
| 154 | struct sde_debugfs_regset32 debugfs_csc; |
Clarence Ip | 716ab66 | 2017-03-20 06:51:24 -0700 | [diff] [blame] | 155 | bool debugfs_default_scale; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 156 | }; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 157 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 158 | #define to_sde_plane(x) container_of(x, struct sde_plane, base) |
| 159 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 160 | static struct sde_kms *_sde_plane_get_kms(struct drm_plane *plane) |
| 161 | { |
| 162 | struct msm_drm_private *priv; |
| 163 | |
| 164 | if (!plane || !plane->dev) |
| 165 | return NULL; |
| 166 | priv = plane->dev->dev_private; |
| 167 | if (!priv) |
| 168 | return NULL; |
| 169 | return to_sde_kms(priv->kms); |
| 170 | } |
| 171 | |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 172 | /** |
| 173 | * _sde_plane_get_crtc_state - obtain crtc state attached to given plane state |
| 174 | * @pstate: Pointer to drm plane state |
| 175 | * return: Pointer to crtc state if success; pointer error, otherwise |
| 176 | */ |
| 177 | static struct drm_crtc_state *_sde_plane_get_crtc_state( |
| 178 | struct drm_plane_state *pstate) |
| 179 | { |
| 180 | struct drm_crtc_state *cstate; |
| 181 | |
| 182 | if (!pstate || !pstate->crtc) |
| 183 | return NULL; |
| 184 | |
| 185 | if (pstate->state) |
| 186 | cstate = drm_atomic_get_crtc_state(pstate->state, pstate->crtc); |
| 187 | else |
| 188 | cstate = pstate->crtc->state; |
| 189 | |
| 190 | return cstate; |
| 191 | } |
| 192 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 193 | static bool sde_plane_enabled(struct drm_plane_state *state) |
| 194 | { |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 195 | return state && state->fb && state->crtc; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 196 | } |
| 197 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 198 | static bool sde_plane_sspp_enabled(struct drm_plane_state *state) |
| 199 | { |
| 200 | return state && to_sde_plane_state(state)->rot.out_fb && state->crtc; |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * sde_plane_crtc_enabled - determine if crtc of given plane state is enabled |
| 205 | * @state: Pointer to drm plane state |
| 206 | * return: true if plane and the associated crtc are both enabled |
| 207 | */ |
| 208 | static bool sde_plane_crtc_enabled(struct drm_plane_state *state) |
| 209 | { |
| 210 | return sde_plane_enabled(state) && state->crtc->state && |
| 211 | state->crtc->state->active && |
| 212 | state->crtc->state->enable; |
| 213 | } |
| 214 | |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 215 | /** |
| 216 | * _sde_plane_calc_fill_level - calculate fill level of the given source format |
| 217 | * @plane: Pointer to drm plane |
| 218 | * @fmt: Pointer to source buffer format |
| 219 | * @src_wdith: width of source buffer |
| 220 | * Return: fill level corresponding to the source buffer/format or 0 if error |
| 221 | */ |
| 222 | static inline int _sde_plane_calc_fill_level(struct drm_plane *plane, |
| 223 | const struct sde_format *fmt, u32 src_width) |
| 224 | { |
| 225 | struct sde_plane *psde; |
| 226 | u32 fixed_buff_size; |
| 227 | u32 total_fl; |
| 228 | |
| 229 | if (!plane || !fmt) { |
| 230 | SDE_ERROR("invalid arguments\n"); |
| 231 | return 0; |
| 232 | } |
| 233 | |
| 234 | psde = to_sde_plane(plane); |
| 235 | fixed_buff_size = psde->pipe_sblk->pixel_ram_size; |
| 236 | |
| 237 | if (fmt->fetch_planes == SDE_PLANE_PSEUDO_PLANAR) { |
| 238 | if (fmt->chroma_sample == SDE_CHROMA_420) { |
| 239 | /* NV12 */ |
| 240 | total_fl = (fixed_buff_size / 2) / |
| 241 | ((src_width + 32) * fmt->bpp); |
| 242 | } else { |
| 243 | /* non NV12 */ |
| 244 | total_fl = (fixed_buff_size) / |
| 245 | ((src_width + 32) * fmt->bpp); |
| 246 | } |
| 247 | } else { |
| 248 | total_fl = (fixed_buff_size * 2) / |
| 249 | ((src_width + 32) * fmt->bpp); |
| 250 | } |
| 251 | |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 252 | SDE_DEBUG("plane%u: pnum:%d fmt: %4.4s w:%u fl:%u\n", |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 253 | plane->base.id, psde->pipe - SSPP_VIG0, |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 254 | (char *)&fmt->base.pixel_format, |
| 255 | src_width, total_fl); |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 256 | |
| 257 | return total_fl; |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * _sde_plane_get_qos_lut_linear - get linear LUT mapping |
| 262 | * @total_fl: fill level |
| 263 | * Return: LUT setting corresponding to the fill level |
| 264 | */ |
| 265 | static inline u32 _sde_plane_get_qos_lut_linear(u32 total_fl) |
| 266 | { |
| 267 | u32 qos_lut; |
| 268 | |
| 269 | if (total_fl <= 4) |
| 270 | qos_lut = 0x1B; |
| 271 | else if (total_fl <= 5) |
| 272 | qos_lut = 0x5B; |
| 273 | else if (total_fl <= 6) |
| 274 | qos_lut = 0x15B; |
| 275 | else if (total_fl <= 7) |
| 276 | qos_lut = 0x55B; |
| 277 | else if (total_fl <= 8) |
| 278 | qos_lut = 0x155B; |
| 279 | else if (total_fl <= 9) |
| 280 | qos_lut = 0x555B; |
| 281 | else if (total_fl <= 10) |
| 282 | qos_lut = 0x1555B; |
| 283 | else if (total_fl <= 11) |
| 284 | qos_lut = 0x5555B; |
| 285 | else if (total_fl <= 12) |
| 286 | qos_lut = 0x15555B; |
| 287 | else |
| 288 | qos_lut = 0x55555B; |
| 289 | |
| 290 | return qos_lut; |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * _sde_plane_get_qos_lut_macrotile - get macrotile LUT mapping |
| 295 | * @total_fl: fill level |
| 296 | * Return: LUT setting corresponding to the fill level |
| 297 | */ |
| 298 | static inline u32 _sde_plane_get_qos_lut_macrotile(u32 total_fl) |
| 299 | { |
| 300 | u32 qos_lut; |
| 301 | |
| 302 | if (total_fl <= 10) |
| 303 | qos_lut = 0x1AAff; |
| 304 | else if (total_fl <= 11) |
| 305 | qos_lut = 0x5AAFF; |
| 306 | else if (total_fl <= 12) |
| 307 | qos_lut = 0x15AAFF; |
| 308 | else |
| 309 | qos_lut = 0x55AAFF; |
| 310 | |
| 311 | return qos_lut; |
| 312 | } |
| 313 | |
| 314 | /** |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 315 | * _sde_plane_set_qos_lut - set QoS LUT of the given plane |
| 316 | * @plane: Pointer to drm plane |
| 317 | * @fb: Pointer to framebuffer associated with the given plane |
| 318 | */ |
| 319 | static void _sde_plane_set_qos_lut(struct drm_plane *plane, |
| 320 | struct drm_framebuffer *fb) |
| 321 | { |
| 322 | struct sde_plane *psde; |
| 323 | const struct sde_format *fmt = NULL; |
| 324 | u32 qos_lut; |
| 325 | u32 total_fl = 0; |
| 326 | |
| 327 | if (!plane || !fb) { |
| 328 | SDE_ERROR("invalid arguments plane %d fb %d\n", |
| 329 | plane != 0, fb != 0); |
| 330 | return; |
| 331 | } |
| 332 | |
| 333 | psde = to_sde_plane(plane); |
| 334 | |
| 335 | if (!psde->pipe_hw || !psde->pipe_sblk) { |
| 336 | SDE_ERROR("invalid arguments\n"); |
| 337 | return; |
| 338 | } else if (!psde->pipe_hw->ops.setup_creq_lut) { |
| 339 | return; |
| 340 | } |
| 341 | |
| 342 | if (!psde->is_rt_pipe) { |
| 343 | qos_lut = psde->pipe_sblk->creq_lut_nrt; |
| 344 | } else { |
| 345 | fmt = sde_get_sde_format_ext( |
| 346 | fb->pixel_format, |
| 347 | fb->modifier, |
| 348 | drm_format_num_planes(fb->pixel_format)); |
| 349 | total_fl = _sde_plane_calc_fill_level(plane, fmt, |
| 350 | psde->pipe_cfg.src_rect.w); |
| 351 | |
| 352 | if (SDE_FORMAT_IS_LINEAR(fmt)) |
| 353 | qos_lut = _sde_plane_get_qos_lut_linear(total_fl); |
| 354 | else |
| 355 | qos_lut = _sde_plane_get_qos_lut_macrotile(total_fl); |
| 356 | } |
| 357 | |
| 358 | psde->pipe_qos_cfg.creq_lut = qos_lut; |
| 359 | |
| 360 | trace_sde_perf_set_qos_luts(psde->pipe - SSPP_VIG0, |
| 361 | (fmt) ? fmt->base.pixel_format : 0, |
| 362 | psde->is_rt_pipe, total_fl, qos_lut, |
| 363 | (fmt) ? SDE_FORMAT_IS_LINEAR(fmt) : 0); |
| 364 | |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 365 | SDE_DEBUG("plane%u: pnum:%d fmt: %4.4s rt:%d fl:%u lut:0x%x\n", |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 366 | plane->base.id, |
| 367 | psde->pipe - SSPP_VIG0, |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 368 | fmt ? (char *)&fmt->base.pixel_format : NULL, |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 369 | psde->is_rt_pipe, total_fl, qos_lut); |
| 370 | |
| 371 | psde->pipe_hw->ops.setup_creq_lut(psde->pipe_hw, &psde->pipe_qos_cfg); |
| 372 | } |
| 373 | |
| 374 | /** |
| 375 | * _sde_plane_set_panic_lut - set danger/safe LUT of the given plane |
| 376 | * @plane: Pointer to drm plane |
| 377 | * @fb: Pointer to framebuffer associated with the given plane |
| 378 | */ |
| 379 | static void _sde_plane_set_danger_lut(struct drm_plane *plane, |
| 380 | struct drm_framebuffer *fb) |
| 381 | { |
| 382 | struct sde_plane *psde; |
| 383 | const struct sde_format *fmt = NULL; |
| 384 | u32 danger_lut, safe_lut; |
| 385 | |
| 386 | if (!plane || !fb) { |
| 387 | SDE_ERROR("invalid arguments\n"); |
| 388 | return; |
| 389 | } |
| 390 | |
| 391 | psde = to_sde_plane(plane); |
| 392 | |
| 393 | if (!psde->pipe_hw || !psde->pipe_sblk) { |
| 394 | SDE_ERROR("invalid arguments\n"); |
| 395 | return; |
| 396 | } else if (!psde->pipe_hw->ops.setup_danger_safe_lut) { |
| 397 | return; |
| 398 | } |
| 399 | |
| 400 | if (!psde->is_rt_pipe) { |
| 401 | danger_lut = psde->pipe_sblk->danger_lut_nrt; |
| 402 | safe_lut = psde->pipe_sblk->safe_lut_nrt; |
| 403 | } else { |
| 404 | fmt = sde_get_sde_format_ext( |
| 405 | fb->pixel_format, |
| 406 | fb->modifier, |
| 407 | drm_format_num_planes(fb->pixel_format)); |
| 408 | |
| 409 | if (SDE_FORMAT_IS_LINEAR(fmt)) { |
| 410 | danger_lut = psde->pipe_sblk->danger_lut_linear; |
| 411 | safe_lut = psde->pipe_sblk->safe_lut_linear; |
| 412 | } else { |
| 413 | danger_lut = psde->pipe_sblk->danger_lut_tile; |
| 414 | safe_lut = psde->pipe_sblk->safe_lut_tile; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | psde->pipe_qos_cfg.danger_lut = danger_lut; |
| 419 | psde->pipe_qos_cfg.safe_lut = safe_lut; |
| 420 | |
| 421 | trace_sde_perf_set_danger_luts(psde->pipe - SSPP_VIG0, |
| 422 | (fmt) ? fmt->base.pixel_format : 0, |
| 423 | (fmt) ? fmt->fetch_mode : 0, |
| 424 | psde->pipe_qos_cfg.danger_lut, |
| 425 | psde->pipe_qos_cfg.safe_lut); |
| 426 | |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 427 | SDE_DEBUG("plane%u: pnum:%d fmt: %4.4s mode:%d luts[0x%x, 0x%x]\n", |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 428 | plane->base.id, |
| 429 | psde->pipe - SSPP_VIG0, |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 430 | fmt ? (char *)&fmt->base.pixel_format : NULL, |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 431 | fmt ? fmt->fetch_mode : -1, |
| 432 | psde->pipe_qos_cfg.danger_lut, |
| 433 | psde->pipe_qos_cfg.safe_lut); |
| 434 | |
| 435 | psde->pipe_hw->ops.setup_danger_safe_lut(psde->pipe_hw, |
| 436 | &psde->pipe_qos_cfg); |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * _sde_plane_set_qos_ctrl - set QoS control of the given plane |
| 441 | * @plane: Pointer to drm plane |
| 442 | * @enable: true to enable QoS control |
| 443 | * @flags: QoS control mode (enum sde_plane_qos) |
| 444 | */ |
| 445 | static void _sde_plane_set_qos_ctrl(struct drm_plane *plane, |
| 446 | bool enable, u32 flags) |
| 447 | { |
| 448 | struct sde_plane *psde; |
| 449 | |
| 450 | if (!plane) { |
| 451 | SDE_ERROR("invalid arguments\n"); |
| 452 | return; |
| 453 | } |
| 454 | |
| 455 | psde = to_sde_plane(plane); |
| 456 | |
| 457 | if (!psde->pipe_hw || !psde->pipe_sblk) { |
| 458 | SDE_ERROR("invalid arguments\n"); |
| 459 | return; |
| 460 | } else if (!psde->pipe_hw->ops.setup_qos_ctrl) { |
| 461 | return; |
| 462 | } |
| 463 | |
| 464 | if (flags & SDE_PLANE_QOS_VBLANK_CTRL) { |
| 465 | psde->pipe_qos_cfg.creq_vblank = psde->pipe_sblk->creq_vblank; |
| 466 | psde->pipe_qos_cfg.danger_vblank = |
| 467 | psde->pipe_sblk->danger_vblank; |
| 468 | psde->pipe_qos_cfg.vblank_en = enable; |
| 469 | } |
| 470 | |
| 471 | if (flags & SDE_PLANE_QOS_VBLANK_AMORTIZE) { |
| 472 | /* this feature overrules previous VBLANK_CTRL */ |
| 473 | psde->pipe_qos_cfg.vblank_en = false; |
| 474 | psde->pipe_qos_cfg.creq_vblank = 0; /* clear vblank bits */ |
| 475 | } |
| 476 | |
| 477 | if (flags & SDE_PLANE_QOS_PANIC_CTRL) |
| 478 | psde->pipe_qos_cfg.danger_safe_en = enable; |
| 479 | |
| 480 | if (!psde->is_rt_pipe) { |
| 481 | psde->pipe_qos_cfg.vblank_en = false; |
| 482 | psde->pipe_qos_cfg.danger_safe_en = false; |
| 483 | } |
| 484 | |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 485 | 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] | 486 | plane->base.id, |
| 487 | psde->pipe - SSPP_VIG0, |
| 488 | psde->pipe_qos_cfg.danger_safe_en, |
| 489 | psde->pipe_qos_cfg.vblank_en, |
| 490 | psde->pipe_qos_cfg.creq_vblank, |
Clarence Ip | 0d0e96d | 2016-10-24 18:13:13 -0400 | [diff] [blame] | 491 | psde->pipe_qos_cfg.danger_vblank, |
| 492 | psde->is_rt_pipe); |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 493 | |
| 494 | psde->pipe_hw->ops.setup_qos_ctrl(psde->pipe_hw, |
| 495 | &psde->pipe_qos_cfg); |
| 496 | } |
| 497 | |
Veera Sundaram Sankaran | 82916e0 | 2017-03-29 18:44:22 -0700 | [diff] [blame] | 498 | void sde_plane_set_revalidate(struct drm_plane *plane, bool enable) |
| 499 | { |
| 500 | struct sde_plane *psde; |
| 501 | |
| 502 | if (!plane) |
| 503 | return; |
| 504 | |
| 505 | psde = to_sde_plane(plane); |
| 506 | psde->revalidate = enable; |
| 507 | } |
| 508 | |
Alan Kwong | f0fd851 | 2016-10-24 21:39:26 -0400 | [diff] [blame] | 509 | int sde_plane_danger_signal_ctrl(struct drm_plane *plane, bool enable) |
| 510 | { |
| 511 | struct sde_plane *psde; |
| 512 | struct msm_drm_private *priv; |
| 513 | struct sde_kms *sde_kms; |
| 514 | |
| 515 | if (!plane || !plane->dev) { |
| 516 | SDE_ERROR("invalid arguments\n"); |
| 517 | return -EINVAL; |
| 518 | } |
| 519 | |
| 520 | priv = plane->dev->dev_private; |
| 521 | if (!priv || !priv->kms) { |
| 522 | SDE_ERROR("invalid KMS reference\n"); |
| 523 | return -EINVAL; |
| 524 | } |
| 525 | |
| 526 | sde_kms = to_sde_kms(priv->kms); |
| 527 | psde = to_sde_plane(plane); |
| 528 | |
| 529 | if (!psde->is_rt_pipe) |
| 530 | goto end; |
| 531 | |
| 532 | sde_power_resource_enable(&priv->phandle, sde_kms->core_client, true); |
| 533 | |
| 534 | _sde_plane_set_qos_ctrl(plane, enable, SDE_PLANE_QOS_PANIC_CTRL); |
| 535 | |
| 536 | sde_power_resource_enable(&priv->phandle, sde_kms->core_client, false); |
| 537 | |
| 538 | end: |
| 539 | return 0; |
| 540 | } |
| 541 | |
Alan Kwong | 5d324e4 | 2016-07-28 22:56:18 -0400 | [diff] [blame] | 542 | /** |
| 543 | * _sde_plane_set_ot_limit - set OT limit for the given plane |
| 544 | * @plane: Pointer to drm plane |
| 545 | * @crtc: Pointer to drm crtc |
| 546 | */ |
| 547 | static void _sde_plane_set_ot_limit(struct drm_plane *plane, |
| 548 | struct drm_crtc *crtc) |
| 549 | { |
| 550 | struct sde_plane *psde; |
| 551 | struct sde_vbif_set_ot_params ot_params; |
| 552 | struct msm_drm_private *priv; |
| 553 | struct sde_kms *sde_kms; |
| 554 | |
| 555 | if (!plane || !plane->dev || !crtc) { |
| 556 | SDE_ERROR("invalid arguments plane %d crtc %d\n", |
| 557 | plane != 0, crtc != 0); |
| 558 | return; |
| 559 | } |
| 560 | |
| 561 | priv = plane->dev->dev_private; |
| 562 | if (!priv || !priv->kms) { |
| 563 | SDE_ERROR("invalid KMS reference\n"); |
| 564 | return; |
| 565 | } |
| 566 | |
| 567 | sde_kms = to_sde_kms(priv->kms); |
| 568 | psde = to_sde_plane(plane); |
| 569 | if (!psde->pipe_hw) { |
| 570 | SDE_ERROR("invalid pipe reference\n"); |
| 571 | return; |
| 572 | } |
| 573 | |
| 574 | memset(&ot_params, 0, sizeof(ot_params)); |
| 575 | ot_params.xin_id = psde->pipe_hw->cap->xin_id; |
| 576 | ot_params.num = psde->pipe_hw->idx - SSPP_NONE; |
| 577 | ot_params.width = psde->pipe_cfg.src_rect.w; |
| 578 | ot_params.height = psde->pipe_cfg.src_rect.h; |
| 579 | ot_params.is_wfd = !psde->is_rt_pipe; |
| 580 | ot_params.frame_rate = crtc->mode.vrefresh; |
| 581 | ot_params.vbif_idx = VBIF_RT; |
| 582 | ot_params.clk_ctrl = psde->pipe_hw->cap->clk_ctrl; |
| 583 | ot_params.rd = true; |
| 584 | |
| 585 | sde_vbif_set_ot_limit(sde_kms, &ot_params); |
| 586 | } |
| 587 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 588 | /* helper to update a state's input fence pointer from the property */ |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 589 | static void _sde_plane_set_input_fence(struct sde_plane *psde, |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 590 | struct sde_plane_state *pstate, uint64_t fd) |
| 591 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 592 | if (!psde || !pstate) { |
| 593 | SDE_ERROR("invalid arg(s), plane %d state %d\n", |
| 594 | psde != 0, pstate != 0); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 595 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 596 | } |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 597 | |
| 598 | /* clear previous reference */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 599 | if (pstate->input_fence) |
| 600 | sde_sync_put(pstate->input_fence); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 601 | |
| 602 | /* get fence pointer for later */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 603 | pstate->input_fence = sde_sync_get(fd); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 604 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 605 | SDE_DEBUG_PLANE(psde, "0x%llX\n", fd); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 606 | } |
| 607 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 608 | 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] | 609 | { |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 610 | struct sde_plane *psde; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 611 | struct sde_plane_state *pstate; |
Clarence Ip | 78a04ed | 2016-10-04 15:57:45 -0400 | [diff] [blame] | 612 | uint32_t prefix; |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 613 | void *input_fence; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 614 | int ret = -EINVAL; |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 615 | signed long rc; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 616 | |
| 617 | if (!plane) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 618 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 619 | } else if (!plane->state) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 620 | SDE_ERROR_PLANE(to_sde_plane(plane), "invalid state\n"); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 621 | } else { |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 622 | psde = to_sde_plane(plane); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 623 | pstate = to_sde_plane_state(plane->state); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 624 | input_fence = pstate->input_fence; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 625 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 626 | if (input_fence) { |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 627 | psde->is_error = false; |
Clarence Ip | 78a04ed | 2016-10-04 15:57:45 -0400 | [diff] [blame] | 628 | prefix = sde_sync_get_name_prefix(input_fence); |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 629 | rc = sde_sync_wait(input_fence, wait_ms); |
Clarence Ip | 78a04ed | 2016-10-04 15:57:45 -0400 | [diff] [blame] | 630 | |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 631 | switch (rc) { |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 632 | case 0: |
Clarence Ip | 78a04ed | 2016-10-04 15:57:45 -0400 | [diff] [blame] | 633 | SDE_ERROR_PLANE(psde, "%ums timeout on %08X\n", |
| 634 | wait_ms, prefix); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 635 | psde->is_error = true; |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 636 | ret = -ETIMEDOUT; |
| 637 | break; |
| 638 | case -ERESTARTSYS: |
| 639 | SDE_ERROR_PLANE(psde, |
| 640 | "%ums wait interrupted on %08X\n", |
| 641 | wait_ms, prefix); |
| 642 | psde->is_error = true; |
| 643 | ret = -ERESTARTSYS; |
| 644 | break; |
| 645 | case -EINVAL: |
| 646 | SDE_ERROR_PLANE(psde, |
| 647 | "invalid fence param for %08X\n", |
| 648 | prefix); |
| 649 | psde->is_error = true; |
| 650 | ret = -EINVAL; |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 651 | break; |
| 652 | default: |
Dhaval Patel | 39323d4 | 2017-03-01 23:48:24 -0800 | [diff] [blame] | 653 | SDE_DEBUG_PLANE(psde, "signaled\n"); |
| 654 | ret = 0; |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 655 | break; |
| 656 | } |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 657 | |
| 658 | SDE_EVT32_VERBOSE(DRMID(plane), -ret, prefix); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 659 | } else { |
| 660 | ret = 0; |
| 661 | } |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 662 | } |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 663 | return ret; |
| 664 | } |
| 665 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 666 | static inline void _sde_plane_set_scanout(struct drm_plane *plane, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 667 | struct sde_plane_state *pstate, |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 668 | struct sde_hw_pipe_cfg *pipe_cfg, |
| 669 | struct drm_framebuffer *fb) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 670 | { |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 671 | struct sde_plane *psde; |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 672 | int ret; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 673 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 674 | if (!plane || !pstate || !pipe_cfg || !fb) { |
| 675 | SDE_ERROR( |
| 676 | "invalid arg(s), plane %d state %d cfg %d fb %d\n", |
| 677 | plane != 0, pstate != 0, pipe_cfg != 0, fb != 0); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 678 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 679 | } |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 680 | |
| 681 | psde = to_sde_plane(plane); |
Clarence Ip | b6eb236 | 2016-09-08 16:18:13 -0400 | [diff] [blame] | 682 | if (!psde->pipe_hw) { |
| 683 | SDE_ERROR_PLANE(psde, "invalid pipe_hw\n"); |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 684 | return; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 685 | } |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 686 | |
Clarence Ip | b6eb236 | 2016-09-08 16:18:13 -0400 | [diff] [blame] | 687 | ret = sde_format_populate_layout(psde->mmu_id, fb, &pipe_cfg->layout); |
| 688 | if (ret == -EAGAIN) |
| 689 | SDE_DEBUG_PLANE(psde, "not updating same src addrs\n"); |
| 690 | else if (ret) |
| 691 | SDE_ERROR_PLANE(psde, "failed to get format layout, %d\n", ret); |
| 692 | else if (psde->pipe_hw->ops.setup_sourceaddress) |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 693 | psde->pipe_hw->ops.setup_sourceaddress(psde->pipe_hw, pipe_cfg, |
| 694 | pstate->multirect_index); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 695 | } |
| 696 | |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 697 | static int _sde_plane_setup_scaler3_lut(struct sde_plane *psde, |
| 698 | struct sde_plane_state *pstate) |
| 699 | { |
Clarence Ip | 3bf8d87 | 2017-02-16 15:25:38 -0500 | [diff] [blame] | 700 | struct sde_hw_scaler3_cfg *cfg; |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 701 | int ret = 0; |
| 702 | |
Clarence Ip | 3bf8d87 | 2017-02-16 15:25:38 -0500 | [diff] [blame] | 703 | if (!psde || !psde->scaler3_cfg) { |
| 704 | SDE_ERROR("invalid args\n"); |
| 705 | return -EINVAL; |
| 706 | } else if (!pstate) { |
| 707 | /* pstate is expected to be null on forced color fill */ |
| 708 | SDE_DEBUG("null pstate\n"); |
| 709 | return -EINVAL; |
| 710 | } |
| 711 | |
| 712 | cfg = psde->scaler3_cfg; |
| 713 | |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 714 | cfg->dir_lut = msm_property_get_blob( |
| 715 | &psde->property_info, |
| 716 | pstate->property_blobs, &cfg->dir_len, |
| 717 | PLANE_PROP_SCALER_LUT_ED); |
| 718 | cfg->cir_lut = msm_property_get_blob( |
| 719 | &psde->property_info, |
| 720 | pstate->property_blobs, &cfg->cir_len, |
| 721 | PLANE_PROP_SCALER_LUT_CIR); |
| 722 | cfg->sep_lut = msm_property_get_blob( |
| 723 | &psde->property_info, |
| 724 | pstate->property_blobs, &cfg->sep_len, |
| 725 | PLANE_PROP_SCALER_LUT_SEP); |
| 726 | if (!cfg->dir_lut || !cfg->cir_lut || !cfg->sep_lut) |
| 727 | ret = -ENODATA; |
| 728 | return ret; |
| 729 | } |
| 730 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 731 | static void _sde_plane_setup_scaler3(struct sde_plane *psde, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 732 | uint32_t src_w, uint32_t src_h, uint32_t dst_w, uint32_t dst_h, |
| 733 | struct sde_hw_scaler3_cfg *scale_cfg, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 734 | const struct sde_format *fmt, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 735 | uint32_t chroma_subsmpl_h, uint32_t chroma_subsmpl_v) |
| 736 | { |
Gopikrishnaiah Anandan | f4c3429 | 2016-10-20 15:42:04 -0700 | [diff] [blame] | 737 | uint32_t decimated, i; |
| 738 | |
| 739 | if (!psde || !scale_cfg || !fmt || !chroma_subsmpl_h || |
| 740 | !chroma_subsmpl_v) { |
| 741 | SDE_ERROR("psde %pK scale_cfg %pK fmt %pK smp_h %d smp_v %d\n" |
| 742 | , psde, scale_cfg, fmt, chroma_subsmpl_h, |
| 743 | chroma_subsmpl_v); |
| 744 | return; |
| 745 | } |
| 746 | |
| 747 | memset(scale_cfg, 0, sizeof(*scale_cfg)); |
Clarence Ip | 716ab66 | 2017-03-20 06:51:24 -0700 | [diff] [blame] | 748 | memset(&psde->pixel_ext, 0, sizeof(struct sde_hw_pixel_ext)); |
Gopikrishnaiah Anandan | f4c3429 | 2016-10-20 15:42:04 -0700 | [diff] [blame] | 749 | |
| 750 | decimated = DECIMATED_DIMENSION(src_w, |
| 751 | psde->pipe_cfg.horz_decimation); |
| 752 | scale_cfg->phase_step_x[SDE_SSPP_COMP_0] = |
| 753 | mult_frac((1 << PHASE_STEP_SHIFT), decimated, dst_w); |
| 754 | decimated = DECIMATED_DIMENSION(src_h, |
| 755 | psde->pipe_cfg.vert_decimation); |
| 756 | scale_cfg->phase_step_y[SDE_SSPP_COMP_0] = |
| 757 | mult_frac((1 << PHASE_STEP_SHIFT), decimated, dst_h); |
| 758 | |
| 759 | |
| 760 | scale_cfg->phase_step_y[SDE_SSPP_COMP_1_2] = |
| 761 | scale_cfg->phase_step_y[SDE_SSPP_COMP_0] / chroma_subsmpl_v; |
| 762 | scale_cfg->phase_step_x[SDE_SSPP_COMP_1_2] = |
| 763 | scale_cfg->phase_step_x[SDE_SSPP_COMP_0] / chroma_subsmpl_h; |
| 764 | |
| 765 | scale_cfg->phase_step_x[SDE_SSPP_COMP_2] = |
| 766 | scale_cfg->phase_step_x[SDE_SSPP_COMP_1_2]; |
| 767 | scale_cfg->phase_step_y[SDE_SSPP_COMP_2] = |
| 768 | scale_cfg->phase_step_y[SDE_SSPP_COMP_1_2]; |
| 769 | |
| 770 | scale_cfg->phase_step_x[SDE_SSPP_COMP_3] = |
| 771 | scale_cfg->phase_step_x[SDE_SSPP_COMP_0]; |
| 772 | scale_cfg->phase_step_y[SDE_SSPP_COMP_3] = |
| 773 | scale_cfg->phase_step_y[SDE_SSPP_COMP_0]; |
| 774 | |
| 775 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 776 | scale_cfg->src_width[i] = DECIMATED_DIMENSION(src_w, |
| 777 | psde->pipe_cfg.horz_decimation); |
| 778 | scale_cfg->src_height[i] = DECIMATED_DIMENSION(src_h, |
| 779 | psde->pipe_cfg.vert_decimation); |
Gopikrishnaiah Anandan | f4c3429 | 2016-10-20 15:42:04 -0700 | [diff] [blame] | 780 | if (i == SDE_SSPP_COMP_1_2 || i == SDE_SSPP_COMP_2) { |
| 781 | scale_cfg->src_width[i] /= chroma_subsmpl_h; |
| 782 | scale_cfg->src_height[i] /= chroma_subsmpl_v; |
| 783 | } |
| 784 | scale_cfg->preload_x[i] = SDE_QSEED3_DEFAULT_PRELOAD_H; |
| 785 | scale_cfg->preload_y[i] = SDE_QSEED3_DEFAULT_PRELOAD_V; |
| 786 | psde->pixel_ext.num_ext_pxls_top[i] = |
| 787 | scale_cfg->src_height[i]; |
| 788 | psde->pixel_ext.num_ext_pxls_left[i] = |
| 789 | scale_cfg->src_width[i]; |
| 790 | } |
| 791 | if (!(SDE_FORMAT_IS_YUV(fmt)) && (src_h == dst_h) |
| 792 | && (src_w == dst_w)) |
| 793 | return; |
| 794 | |
| 795 | scale_cfg->dst_width = dst_w; |
| 796 | scale_cfg->dst_height = dst_h; |
| 797 | scale_cfg->y_rgb_filter_cfg = SDE_SCALE_BIL; |
| 798 | scale_cfg->uv_filter_cfg = SDE_SCALE_BIL; |
| 799 | scale_cfg->alpha_filter_cfg = SDE_SCALE_ALPHA_BIL; |
| 800 | scale_cfg->lut_flag = 0; |
| 801 | scale_cfg->blend_cfg = 1; |
| 802 | scale_cfg->enable = 1; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 803 | } |
| 804 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 805 | /** |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 806 | * _sde_plane_setup_scaler2 - determine default scaler phase steps/filter type |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 807 | * @psde: Pointer to SDE plane object |
| 808 | * @src: Source size |
| 809 | * @dst: Destination size |
| 810 | * @phase_steps: Pointer to output array for phase steps |
| 811 | * @filter: Pointer to output array for filter type |
| 812 | * @fmt: Pointer to format definition |
| 813 | * @chroma_subsampling: Subsampling amount for chroma channel |
| 814 | * |
| 815 | * Returns: 0 on success |
| 816 | */ |
| 817 | static int _sde_plane_setup_scaler2(struct sde_plane *psde, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 818 | uint32_t src, uint32_t dst, uint32_t *phase_steps, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 819 | enum sde_hw_filter *filter, const struct sde_format *fmt, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 820 | uint32_t chroma_subsampling) |
| 821 | { |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 822 | if (!psde || !phase_steps || !filter || !fmt) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 823 | SDE_ERROR( |
| 824 | "invalid arg(s), plane %d phase %d filter %d fmt %d\n", |
| 825 | psde != 0, phase_steps != 0, filter != 0, fmt != 0); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 826 | return -EINVAL; |
| 827 | } |
| 828 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 829 | /* calculate phase steps, leave init phase as zero */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 830 | phase_steps[SDE_SSPP_COMP_0] = |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 831 | mult_frac(1 << PHASE_STEP_SHIFT, src, dst); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 832 | phase_steps[SDE_SSPP_COMP_1_2] = |
| 833 | phase_steps[SDE_SSPP_COMP_0] / chroma_subsampling; |
| 834 | phase_steps[SDE_SSPP_COMP_2] = phase_steps[SDE_SSPP_COMP_1_2]; |
| 835 | phase_steps[SDE_SSPP_COMP_3] = phase_steps[SDE_SSPP_COMP_0]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 836 | |
| 837 | /* calculate scaler config, if necessary */ |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 838 | if (SDE_FORMAT_IS_YUV(fmt) || src != dst) { |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 839 | filter[SDE_SSPP_COMP_3] = |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 840 | (src <= dst) ? SDE_SCALE_FILTER_BIL : |
| 841 | SDE_SCALE_FILTER_PCMN; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 842 | |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 843 | if (SDE_FORMAT_IS_YUV(fmt)) { |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 844 | filter[SDE_SSPP_COMP_0] = SDE_SCALE_FILTER_CA; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 845 | filter[SDE_SSPP_COMP_1_2] = filter[SDE_SSPP_COMP_3]; |
| 846 | } else { |
| 847 | filter[SDE_SSPP_COMP_0] = filter[SDE_SSPP_COMP_3]; |
| 848 | filter[SDE_SSPP_COMP_1_2] = |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 849 | SDE_SCALE_FILTER_NEAREST; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 850 | } |
| 851 | } else { |
| 852 | /* disable scaler */ |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 853 | filter[SDE_SSPP_COMP_0] = SDE_SCALE_FILTER_MAX; |
| 854 | filter[SDE_SSPP_COMP_1_2] = SDE_SCALE_FILTER_MAX; |
| 855 | filter[SDE_SSPP_COMP_3] = SDE_SCALE_FILTER_MAX; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 856 | } |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 857 | return 0; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 858 | } |
| 859 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 860 | /** |
| 861 | * _sde_plane_setup_pixel_ext - determine default pixel extension values |
| 862 | * @psde: Pointer to SDE plane object |
| 863 | * @src: Source size |
| 864 | * @dst: Destination size |
| 865 | * @decimated_src: Source size after decimation, if any |
| 866 | * @phase_steps: Pointer to output array for phase steps |
| 867 | * @out_src: Output array for pixel extension values |
| 868 | * @out_edge1: Output array for pixel extension first edge |
| 869 | * @out_edge2: Output array for pixel extension second edge |
| 870 | * @filter: Pointer to array for filter type |
| 871 | * @fmt: Pointer to format definition |
| 872 | * @chroma_subsampling: Subsampling amount for chroma channel |
| 873 | * @post_compare: Whether to chroma subsampled source size for comparisions |
| 874 | */ |
| 875 | static void _sde_plane_setup_pixel_ext(struct sde_plane *psde, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 876 | uint32_t src, uint32_t dst, uint32_t decimated_src, |
| 877 | uint32_t *phase_steps, uint32_t *out_src, int *out_edge1, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 878 | int *out_edge2, enum sde_hw_filter *filter, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 879 | const struct sde_format *fmt, uint32_t chroma_subsampling, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 880 | bool post_compare) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 881 | { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 882 | int64_t edge1, edge2, caf; |
| 883 | uint32_t src_work; |
| 884 | int i, tmp; |
| 885 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 886 | if (psde && phase_steps && out_src && out_edge1 && |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 887 | out_edge2 && filter && fmt) { |
| 888 | /* handle CAF for YUV formats */ |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 889 | if (SDE_FORMAT_IS_YUV(fmt) && *filter == SDE_SCALE_FILTER_CA) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 890 | caf = PHASE_STEP_UNIT_SCALE; |
| 891 | else |
| 892 | caf = 0; |
| 893 | |
| 894 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 895 | src_work = decimated_src; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 896 | if (i == SDE_SSPP_COMP_1_2 || i == SDE_SSPP_COMP_2) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 897 | src_work /= chroma_subsampling; |
| 898 | if (post_compare) |
| 899 | src = src_work; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 900 | if (!SDE_FORMAT_IS_YUV(fmt) && (src == dst)) { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 901 | /* unity */ |
| 902 | edge1 = 0; |
| 903 | edge2 = 0; |
| 904 | } else if (dst >= src) { |
| 905 | /* upscale */ |
| 906 | edge1 = (1 << PHASE_RESIDUAL); |
| 907 | edge1 -= caf; |
| 908 | edge2 = (1 << PHASE_RESIDUAL); |
| 909 | edge2 += (dst - 1) * *(phase_steps + i); |
| 910 | edge2 -= (src_work - 1) * PHASE_STEP_UNIT_SCALE; |
| 911 | edge2 += caf; |
| 912 | edge2 = -(edge2); |
| 913 | } else { |
| 914 | /* downscale */ |
| 915 | edge1 = 0; |
| 916 | edge2 = (dst - 1) * *(phase_steps + i); |
| 917 | edge2 -= (src_work - 1) * PHASE_STEP_UNIT_SCALE; |
| 918 | edge2 += *(phase_steps + i); |
| 919 | edge2 = -(edge2); |
| 920 | } |
| 921 | |
| 922 | /* only enable CAF for luma plane */ |
| 923 | caf = 0; |
| 924 | |
| 925 | /* populate output arrays */ |
| 926 | *(out_src + i) = src_work; |
| 927 | |
| 928 | /* edge updates taken from __pxl_extn_helper */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 929 | if (edge1 >= 0) { |
| 930 | tmp = (uint32_t)edge1; |
| 931 | tmp >>= PHASE_STEP_SHIFT; |
| 932 | *(out_edge1 + i) = -tmp; |
| 933 | } else { |
| 934 | tmp = (uint32_t)(-edge1); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 935 | *(out_edge1 + i) = |
| 936 | (tmp + PHASE_STEP_UNIT_SCALE - 1) >> |
| 937 | PHASE_STEP_SHIFT; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 938 | } |
| 939 | if (edge2 >= 0) { |
| 940 | tmp = (uint32_t)edge2; |
| 941 | tmp >>= PHASE_STEP_SHIFT; |
| 942 | *(out_edge2 + i) = -tmp; |
| 943 | } else { |
| 944 | tmp = (uint32_t)(-edge2); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 945 | *(out_edge2 + i) = |
| 946 | (tmp + PHASE_STEP_UNIT_SCALE - 1) >> |
| 947 | PHASE_STEP_SHIFT; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 948 | } |
| 949 | } |
| 950 | } |
| 951 | } |
| 952 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 953 | static inline void _sde_plane_setup_csc(struct sde_plane *psde) |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 954 | { |
| 955 | static const struct sde_csc_cfg sde_csc_YUV2RGB_601L = { |
| 956 | { |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 957 | /* S15.16 format */ |
| 958 | 0x00012A00, 0x00000000, 0x00019880, |
| 959 | 0x00012A00, 0xFFFF9B80, 0xFFFF3000, |
| 960 | 0x00012A00, 0x00020480, 0x00000000, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 961 | }, |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 962 | /* signed bias */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 963 | { 0xfff0, 0xff80, 0xff80,}, |
| 964 | { 0x0, 0x0, 0x0,}, |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 965 | /* unsigned clamp */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 966 | { 0x10, 0xeb, 0x10, 0xf0, 0x10, 0xf0,}, |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 967 | { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,}, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 968 | }; |
abeykun | 1c312f6 | 2016-08-26 09:47:12 -0400 | [diff] [blame] | 969 | static const struct sde_csc_cfg sde_csc10_YUV2RGB_601L = { |
| 970 | { |
| 971 | /* S15.16 format */ |
| 972 | 0x00012A00, 0x00000000, 0x00019880, |
| 973 | 0x00012A00, 0xFFFF9B80, 0xFFFF3000, |
| 974 | 0x00012A00, 0x00020480, 0x00000000, |
| 975 | }, |
| 976 | /* signed bias */ |
| 977 | { 0xffc0, 0xfe00, 0xfe00,}, |
| 978 | { 0x0, 0x0, 0x0,}, |
| 979 | /* unsigned clamp */ |
| 980 | { 0x40, 0x3ac, 0x40, 0x3c0, 0x40, 0x3c0,}, |
| 981 | { 0x00, 0x3ff, 0x00, 0x3ff, 0x00, 0x3ff,}, |
| 982 | }; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 983 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 984 | if (!psde) { |
| 985 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 986 | return; |
| 987 | } |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 988 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 989 | /* revert to kernel default if override not available */ |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 990 | if (psde->csc_usr_ptr) |
| 991 | psde->csc_ptr = psde->csc_usr_ptr; |
abeykun | 1c312f6 | 2016-08-26 09:47:12 -0400 | [diff] [blame] | 992 | else if (BIT(SDE_SSPP_CSC_10BIT) & psde->features) |
| 993 | psde->csc_ptr = (struct sde_csc_cfg *)&sde_csc10_YUV2RGB_601L; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 994 | else |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 995 | psde->csc_ptr = (struct sde_csc_cfg *)&sde_csc_YUV2RGB_601L; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 996 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 997 | SDE_DEBUG_PLANE(psde, "using 0x%X 0x%X 0x%X...\n", |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 998 | psde->csc_ptr->csc_mv[0], |
| 999 | psde->csc_ptr->csc_mv[1], |
| 1000 | psde->csc_ptr->csc_mv[2]); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1001 | } |
| 1002 | |
Benet Clark | eb1b446 | 2016-06-27 14:43:06 -0700 | [diff] [blame] | 1003 | static void sde_color_process_plane_setup(struct drm_plane *plane) |
| 1004 | { |
| 1005 | struct sde_plane *psde; |
| 1006 | struct sde_plane_state *pstate; |
| 1007 | uint32_t hue, saturation, value, contrast; |
Benet Clark | d009b1d | 2016-06-27 14:45:59 -0700 | [diff] [blame] | 1008 | struct drm_msm_memcol *memcol = NULL; |
| 1009 | size_t memcol_sz = 0; |
Benet Clark | eb1b446 | 2016-06-27 14:43:06 -0700 | [diff] [blame] | 1010 | |
| 1011 | psde = to_sde_plane(plane); |
| 1012 | pstate = to_sde_plane_state(plane->state); |
| 1013 | |
| 1014 | hue = (uint32_t) sde_plane_get_property(pstate, PLANE_PROP_HUE_ADJUST); |
| 1015 | if (psde->pipe_hw->ops.setup_pa_hue) |
| 1016 | psde->pipe_hw->ops.setup_pa_hue(psde->pipe_hw, &hue); |
| 1017 | saturation = (uint32_t) sde_plane_get_property(pstate, |
| 1018 | PLANE_PROP_SATURATION_ADJUST); |
| 1019 | if (psde->pipe_hw->ops.setup_pa_sat) |
| 1020 | psde->pipe_hw->ops.setup_pa_sat(psde->pipe_hw, &saturation); |
| 1021 | value = (uint32_t) sde_plane_get_property(pstate, |
| 1022 | PLANE_PROP_VALUE_ADJUST); |
| 1023 | if (psde->pipe_hw->ops.setup_pa_val) |
| 1024 | psde->pipe_hw->ops.setup_pa_val(psde->pipe_hw, &value); |
| 1025 | contrast = (uint32_t) sde_plane_get_property(pstate, |
| 1026 | PLANE_PROP_CONTRAST_ADJUST); |
| 1027 | if (psde->pipe_hw->ops.setup_pa_cont) |
| 1028 | psde->pipe_hw->ops.setup_pa_cont(psde->pipe_hw, &contrast); |
Benet Clark | eb1b446 | 2016-06-27 14:43:06 -0700 | [diff] [blame] | 1029 | |
Benet Clark | d009b1d | 2016-06-27 14:45:59 -0700 | [diff] [blame] | 1030 | if (psde->pipe_hw->ops.setup_pa_memcolor) { |
| 1031 | /* Skin memory color setup */ |
| 1032 | memcol = msm_property_get_blob(&psde->property_info, |
| 1033 | pstate->property_blobs, |
| 1034 | &memcol_sz, |
| 1035 | PLANE_PROP_SKIN_COLOR); |
| 1036 | psde->pipe_hw->ops.setup_pa_memcolor(psde->pipe_hw, |
| 1037 | MEMCOLOR_SKIN, memcol); |
| 1038 | |
| 1039 | /* Sky memory color setup */ |
| 1040 | memcol = msm_property_get_blob(&psde->property_info, |
| 1041 | pstate->property_blobs, |
| 1042 | &memcol_sz, |
| 1043 | PLANE_PROP_SKY_COLOR); |
| 1044 | psde->pipe_hw->ops.setup_pa_memcolor(psde->pipe_hw, |
| 1045 | MEMCOLOR_SKY, memcol); |
| 1046 | |
| 1047 | /* Foliage memory color setup */ |
| 1048 | memcol = msm_property_get_blob(&psde->property_info, |
| 1049 | pstate->property_blobs, |
| 1050 | &memcol_sz, |
| 1051 | PLANE_PROP_FOLIAGE_COLOR); |
| 1052 | psde->pipe_hw->ops.setup_pa_memcolor(psde->pipe_hw, |
| 1053 | MEMCOLOR_FOLIAGE, memcol); |
| 1054 | } |
| 1055 | } |
Benet Clark | eb1b446 | 2016-06-27 14:43:06 -0700 | [diff] [blame] | 1056 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1057 | static void _sde_plane_setup_scaler(struct sde_plane *psde, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 1058 | const struct sde_format *fmt, |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1059 | struct sde_plane_state *pstate) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1060 | { |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1061 | struct sde_hw_pixel_ext *pe; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1062 | uint32_t chroma_subsmpl_h, chroma_subsmpl_v; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1063 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1064 | if (!psde || !fmt) { |
| 1065 | SDE_ERROR("invalid arg(s), plane %d fmt %d state %d\n", |
| 1066 | psde != 0, fmt != 0, pstate != 0); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1067 | return; |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1068 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1069 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1070 | pe = &(psde->pixel_ext); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1071 | |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 1072 | psde->pipe_cfg.horz_decimation = |
| 1073 | sde_plane_get_property(pstate, PLANE_PROP_H_DECIMATE); |
| 1074 | psde->pipe_cfg.vert_decimation = |
| 1075 | sde_plane_get_property(pstate, PLANE_PROP_V_DECIMATE); |
Clarence Ip | 04ec67d | 2016-05-26 01:16:15 -0400 | [diff] [blame] | 1076 | |
| 1077 | /* don't chroma subsample if decimating */ |
| 1078 | chroma_subsmpl_h = psde->pipe_cfg.horz_decimation ? 1 : |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 1079 | drm_format_horz_chroma_subsampling(fmt->base.pixel_format); |
Clarence Ip | 04ec67d | 2016-05-26 01:16:15 -0400 | [diff] [blame] | 1080 | chroma_subsmpl_v = psde->pipe_cfg.vert_decimation ? 1 : |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 1081 | drm_format_vert_chroma_subsampling(fmt->base.pixel_format); |
Clarence Ip | 04ec67d | 2016-05-26 01:16:15 -0400 | [diff] [blame] | 1082 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1083 | /* update scaler */ |
| 1084 | if (psde->features & BIT(SDE_SSPP_SCALER_QSEED3)) { |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 1085 | int error; |
| 1086 | |
| 1087 | error = _sde_plane_setup_scaler3_lut(psde, pstate); |
Clarence Ip | 716ab66 | 2017-03-20 06:51:24 -0700 | [diff] [blame] | 1088 | if (error || !psde->pixel_ext_usr || |
| 1089 | psde->debugfs_default_scale) { |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1090 | /* calculate default config for QSEED3 */ |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1091 | _sde_plane_setup_scaler3(psde, |
| 1092 | psde->pipe_cfg.src_rect.w, |
| 1093 | psde->pipe_cfg.src_rect.h, |
| 1094 | psde->pipe_cfg.dst_rect.w, |
| 1095 | psde->pipe_cfg.dst_rect.h, |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 1096 | psde->scaler3_cfg, fmt, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1097 | chroma_subsmpl_h, chroma_subsmpl_v); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1098 | } |
Clarence Ip | 716ab66 | 2017-03-20 06:51:24 -0700 | [diff] [blame] | 1099 | } else if (!psde->pixel_ext_usr || !pstate || |
| 1100 | psde->debugfs_default_scale) { |
Lloyd Atkinson | cd43ca6 | 2016-11-29 14:13:11 -0500 | [diff] [blame] | 1101 | uint32_t deci_dim, i; |
| 1102 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1103 | /* calculate default configuration for QSEED2 */ |
| 1104 | memset(pe, 0, sizeof(struct sde_hw_pixel_ext)); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1105 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1106 | SDE_DEBUG_PLANE(psde, "default config\n"); |
Lloyd Atkinson | cd43ca6 | 2016-11-29 14:13:11 -0500 | [diff] [blame] | 1107 | deci_dim = DECIMATED_DIMENSION(psde->pipe_cfg.src_rect.w, |
| 1108 | psde->pipe_cfg.horz_decimation); |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1109 | _sde_plane_setup_scaler2(psde, |
Lloyd Atkinson | cd43ca6 | 2016-11-29 14:13:11 -0500 | [diff] [blame] | 1110 | deci_dim, |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1111 | psde->pipe_cfg.dst_rect.w, |
| 1112 | pe->phase_step_x, |
| 1113 | pe->horz_filter, fmt, chroma_subsmpl_h); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1114 | |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1115 | if (SDE_FORMAT_IS_YUV(fmt)) |
Lloyd Atkinson | cd43ca6 | 2016-11-29 14:13:11 -0500 | [diff] [blame] | 1116 | deci_dim &= ~0x1; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1117 | _sde_plane_setup_pixel_ext(psde, psde->pipe_cfg.src_rect.w, |
Lloyd Atkinson | cd43ca6 | 2016-11-29 14:13:11 -0500 | [diff] [blame] | 1118 | psde->pipe_cfg.dst_rect.w, deci_dim, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1119 | pe->phase_step_x, |
| 1120 | pe->roi_w, |
| 1121 | pe->num_ext_pxls_left, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1122 | pe->num_ext_pxls_right, pe->horz_filter, fmt, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1123 | chroma_subsmpl_h, 0); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1124 | |
Lloyd Atkinson | cd43ca6 | 2016-11-29 14:13:11 -0500 | [diff] [blame] | 1125 | deci_dim = DECIMATED_DIMENSION(psde->pipe_cfg.src_rect.h, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1126 | psde->pipe_cfg.vert_decimation); |
Lloyd Atkinson | cd43ca6 | 2016-11-29 14:13:11 -0500 | [diff] [blame] | 1127 | _sde_plane_setup_scaler2(psde, |
| 1128 | deci_dim, |
| 1129 | psde->pipe_cfg.dst_rect.h, |
| 1130 | pe->phase_step_y, |
| 1131 | pe->vert_filter, fmt, chroma_subsmpl_v); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1132 | _sde_plane_setup_pixel_ext(psde, psde->pipe_cfg.src_rect.h, |
Lloyd Atkinson | cd43ca6 | 2016-11-29 14:13:11 -0500 | [diff] [blame] | 1133 | psde->pipe_cfg.dst_rect.h, deci_dim, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1134 | pe->phase_step_y, |
| 1135 | pe->roi_h, |
| 1136 | pe->num_ext_pxls_top, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1137 | pe->num_ext_pxls_btm, pe->vert_filter, fmt, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1138 | chroma_subsmpl_v, 1); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1139 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1140 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 1141 | if (pe->num_ext_pxls_left[i] >= 0) |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1142 | pe->left_rpt[i] = pe->num_ext_pxls_left[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1143 | else |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1144 | pe->left_ftch[i] = pe->num_ext_pxls_left[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1145 | |
| 1146 | if (pe->num_ext_pxls_right[i] >= 0) |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1147 | pe->right_rpt[i] = pe->num_ext_pxls_right[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1148 | else |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1149 | pe->right_ftch[i] = pe->num_ext_pxls_right[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1150 | |
| 1151 | if (pe->num_ext_pxls_top[i] >= 0) |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1152 | pe->top_rpt[i] = pe->num_ext_pxls_top[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1153 | else |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1154 | pe->top_ftch[i] = pe->num_ext_pxls_top[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1155 | |
| 1156 | if (pe->num_ext_pxls_btm[i] >= 0) |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1157 | pe->btm_rpt[i] = pe->num_ext_pxls_btm[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1158 | else |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1159 | pe->btm_ftch[i] = pe->num_ext_pxls_btm[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1160 | } |
| 1161 | } |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1162 | } |
| 1163 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1164 | /** |
| 1165 | * _sde_plane_color_fill - enables color fill on plane |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1166 | * @psde: Pointer to SDE plane object |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1167 | * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red |
| 1168 | * @alpha: 8-bit fill alpha value, 255 selects 100% alpha |
| 1169 | * Returns: 0 on success |
| 1170 | */ |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1171 | static int _sde_plane_color_fill(struct sde_plane *psde, |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1172 | uint32_t color, uint32_t alpha) |
| 1173 | { |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 1174 | const struct sde_format *fmt; |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 1175 | const struct drm_plane *plane; |
| 1176 | const struct sde_plane_state *pstate; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1177 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1178 | if (!psde) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1179 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1180 | return -EINVAL; |
| 1181 | } |
| 1182 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1183 | if (!psde->pipe_hw) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1184 | SDE_ERROR_PLANE(psde, "invalid plane h/w pointer\n"); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1185 | return -EINVAL; |
| 1186 | } |
| 1187 | |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 1188 | plane = &psde->base; |
| 1189 | pstate = to_sde_plane_state(plane->state); |
| 1190 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1191 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1192 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1193 | /* |
| 1194 | * select fill format to match user property expectation, |
| 1195 | * h/w only supports RGB variants |
| 1196 | */ |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 1197 | fmt = sde_get_sde_format(DRM_FORMAT_ABGR8888); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1198 | |
| 1199 | /* update sspp */ |
| 1200 | if (fmt && psde->pipe_hw->ops.setup_solidfill) { |
| 1201 | psde->pipe_hw->ops.setup_solidfill(psde->pipe_hw, |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 1202 | (color & 0xFFFFFF) | ((alpha & 0xFF) << 24), |
| 1203 | pstate->multirect_index); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1204 | |
| 1205 | /* override scaler/decimation if solid fill */ |
| 1206 | psde->pipe_cfg.src_rect.x = 0; |
| 1207 | psde->pipe_cfg.src_rect.y = 0; |
| 1208 | psde->pipe_cfg.src_rect.w = psde->pipe_cfg.dst_rect.w; |
| 1209 | psde->pipe_cfg.src_rect.h = psde->pipe_cfg.dst_rect.h; |
Dhaval Patel | e4b6bb2 | 2017-03-27 17:22:21 -0700 | [diff] [blame] | 1210 | _sde_plane_setup_scaler(psde, fmt, 0); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1211 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1212 | if (psde->pipe_hw->ops.setup_format) |
| 1213 | psde->pipe_hw->ops.setup_format(psde->pipe_hw, |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 1214 | fmt, SDE_SSPP_SOLID_FILL, |
| 1215 | pstate->multirect_index); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1216 | |
| 1217 | if (psde->pipe_hw->ops.setup_rects) |
| 1218 | psde->pipe_hw->ops.setup_rects(psde->pipe_hw, |
Jeykumar Sankaran | 9fcfa48 | 2017-02-16 16:03:14 -0800 | [diff] [blame] | 1219 | &psde->pipe_cfg, |
| 1220 | pstate->multirect_index); |
| 1221 | |
Jeykumar Sankaran | 9fcfa48 | 2017-02-16 16:03:14 -0800 | [diff] [blame] | 1222 | if (psde->pipe_hw->ops.setup_pe) |
| 1223 | psde->pipe_hw->ops.setup_pe(psde->pipe_hw, |
| 1224 | &psde->pixel_ext); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 1225 | } |
| 1226 | |
| 1227 | return 0; |
| 1228 | } |
| 1229 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1230 | /** |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1231 | * _sde_plane_fb_get/put - framebuffer callback for crtc res ops |
| 1232 | */ |
| 1233 | static void *_sde_plane_fb_get(void *fb, u32 type, u64 tag) |
| 1234 | { |
| 1235 | drm_framebuffer_reference(fb); |
| 1236 | return fb; |
| 1237 | } |
| 1238 | static void _sde_plane_fb_put(void *fb) |
| 1239 | { |
| 1240 | drm_framebuffer_unreference(fb); |
| 1241 | } |
| 1242 | static struct sde_crtc_res_ops fb_res_ops = { |
| 1243 | .put = _sde_plane_fb_put, |
| 1244 | .get = _sde_plane_fb_get, |
| 1245 | }; |
| 1246 | |
| 1247 | /** |
| 1248 | * _sde_plane_fbo_get/put - framebuffer object callback for crtc res ops |
| 1249 | */ |
| 1250 | static void *_sde_plane_fbo_get(void *fbo, u32 type, u64 tag) |
| 1251 | { |
| 1252 | sde_kms_fbo_reference(fbo); |
| 1253 | return fbo; |
| 1254 | } |
| 1255 | static void _sde_plane_fbo_put(void *fbo) |
| 1256 | { |
| 1257 | sde_kms_fbo_unreference(fbo); |
| 1258 | } |
| 1259 | static struct sde_crtc_res_ops fbo_res_ops = { |
| 1260 | .put = _sde_plane_fbo_put, |
| 1261 | .get = _sde_plane_fbo_get, |
| 1262 | }; |
| 1263 | |
| 1264 | /** |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 1265 | * sde_plane_rot_calc_prefill - calculate rotator start prefill |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1266 | * @plane: Pointer to drm plane |
| 1267 | * return: prefill time in line |
| 1268 | */ |
| 1269 | static u32 sde_plane_rot_calc_prefill(struct drm_plane *plane) |
| 1270 | { |
| 1271 | struct drm_plane_state *state; |
| 1272 | struct drm_crtc_state *cstate; |
| 1273 | struct sde_plane_state *pstate; |
| 1274 | struct sde_plane_rot_state *rstate; |
| 1275 | struct sde_kms *sde_kms; |
| 1276 | u32 blocksize = 128; |
| 1277 | u32 prefill_line = 0; |
| 1278 | |
| 1279 | if (!plane || !plane->state || !plane->state->fb || |
| 1280 | !plane->state->crtc || !plane->state->crtc->state) { |
| 1281 | SDE_ERROR("invalid parameters\n"); |
| 1282 | return 0; |
| 1283 | } |
| 1284 | |
| 1285 | sde_kms = _sde_plane_get_kms(plane); |
| 1286 | state = plane->state; |
| 1287 | cstate = state->crtc->state; |
| 1288 | pstate = to_sde_plane_state(state); |
| 1289 | rstate = &pstate->rot; |
| 1290 | |
| 1291 | if (!rstate->rot_hw || !rstate->rot_hw->caps || !rstate->out_src_h || |
| 1292 | !sde_kms || !sde_kms->catalog) { |
| 1293 | SDE_ERROR("invalid parameters\n"); |
| 1294 | return 0; |
| 1295 | } |
| 1296 | |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 1297 | sde_format_get_block_size(rstate->out_fb_format, &blocksize, |
| 1298 | &blocksize); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1299 | prefill_line = blocksize + sde_kms->catalog->sbuf_headroom; |
| 1300 | |
| 1301 | SDE_DEBUG("plane%d prefill:%u\n", plane->base.id, prefill_line); |
| 1302 | |
| 1303 | return prefill_line; |
| 1304 | } |
| 1305 | |
| 1306 | /** |
| 1307 | * sde_plane_is_sbuf_mode - check if sspp of given plane is in streaming |
| 1308 | * buffer mode |
| 1309 | * @plane: Pointer to drm plane |
| 1310 | * @prefill: Pointer to prefill line count |
| 1311 | * return: true if sspp is in stream buffer mode |
| 1312 | */ |
| 1313 | bool sde_plane_is_sbuf_mode(struct drm_plane *plane, u32 *prefill) |
| 1314 | { |
| 1315 | struct sde_plane_state *pstate = plane && plane->state ? |
| 1316 | to_sde_plane_state(plane->state) : NULL; |
| 1317 | struct sde_plane_rot_state *rstate = pstate ? &pstate->rot : NULL; |
| 1318 | bool sbuf_mode = rstate ? rstate->out_sbuf : false; |
| 1319 | |
| 1320 | if (prefill && sbuf_mode) |
| 1321 | *prefill = sde_plane_rot_calc_prefill(plane); |
| 1322 | |
| 1323 | return sbuf_mode; |
| 1324 | } |
| 1325 | |
| 1326 | /** |
| 1327 | * sde_plane_rot_calc_cfg - calculate rotator/sspp configuration by |
| 1328 | * enumerating over all planes attached to the same rotator |
| 1329 | * @plane: Pointer to drm plane |
| 1330 | * @state: Pointer to drm state to be updated |
| 1331 | * return: none |
| 1332 | */ |
| 1333 | static void sde_plane_rot_calc_cfg(struct drm_plane *plane, |
| 1334 | struct drm_plane_state *state) |
| 1335 | { |
| 1336 | struct sde_plane_state *pstate; |
| 1337 | struct sde_plane_rot_state *rstate; |
| 1338 | struct sde_hw_blk *hw_blk; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1339 | struct drm_crtc_state *cstate; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1340 | struct drm_rect *in_rot, *out_rot; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1341 | struct drm_plane *attached_plane; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1342 | u32 dst_x, dst_y, dst_w, dst_h; |
| 1343 | int found = 0; |
| 1344 | int xpos = 0; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1345 | int ret; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1346 | |
| 1347 | if (!plane || !state || !state->state) { |
| 1348 | SDE_ERROR("invalid parameters\n"); |
| 1349 | return; |
| 1350 | } |
| 1351 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1352 | cstate = _sde_plane_get_crtc_state(state); |
| 1353 | if (IS_ERR_OR_NULL(cstate)) { |
| 1354 | ret = PTR_ERR(cstate); |
| 1355 | SDE_ERROR("invalid crtc state %d\n", ret); |
| 1356 | return; |
| 1357 | } |
| 1358 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1359 | pstate = to_sde_plane_state(state); |
| 1360 | rstate = &pstate->rot; |
| 1361 | |
| 1362 | if (!rstate->rot_hw) { |
| 1363 | SDE_ERROR("invalid rotator hw\n"); |
| 1364 | return; |
| 1365 | } |
| 1366 | |
| 1367 | in_rot = &rstate->in_rot_rect; |
| 1368 | in_rot->x1 = state->src_x; |
| 1369 | in_rot->y1 = state->src_y; |
| 1370 | in_rot->x2 = state->src_x + state->src_w; |
| 1371 | in_rot->y2 = state->src_y + state->src_h; |
| 1372 | |
| 1373 | out_rot = &rstate->out_rot_rect; |
| 1374 | dst_x = sde_plane_get_property(pstate, PLANE_PROP_ROT_DST_X); |
| 1375 | dst_y = sde_plane_get_property(pstate, PLANE_PROP_ROT_DST_Y); |
| 1376 | dst_w = sde_plane_get_property(pstate, PLANE_PROP_ROT_DST_W); |
| 1377 | dst_h = sde_plane_get_property(pstate, PLANE_PROP_ROT_DST_H); |
| 1378 | |
| 1379 | if (!dst_w && !dst_h) { |
| 1380 | rstate->out_rot_rect = rstate->in_rot_rect; |
| 1381 | drm_rect_rotate(&rstate->out_rot_rect, state->fb->width << 16, |
| 1382 | state->fb->height << 16, rstate->in_rotation); |
| 1383 | } else { |
| 1384 | out_rot->x1 = dst_x; |
| 1385 | out_rot->y1 = dst_y; |
| 1386 | out_rot->x2 = dst_x + dst_w; |
| 1387 | out_rot->y2 = dst_y + dst_h; |
| 1388 | } |
| 1389 | |
| 1390 | rstate->out_src_rect = rstate->out_rot_rect; |
| 1391 | |
| 1392 | hw_blk = &rstate->rot_hw->base; |
| 1393 | |
| 1394 | /* enumerating over all planes attached to the same rotator */ |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1395 | drm_atomic_crtc_state_for_each_plane(attached_plane, cstate) { |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1396 | struct drm_plane_state *attached_state; |
| 1397 | struct sde_plane_state *attached_pstate; |
| 1398 | struct sde_plane_rot_state *attached_rstate; |
| 1399 | struct drm_rect attached_out_rect; |
| 1400 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1401 | attached_state = drm_atomic_get_existing_plane_state( |
| 1402 | state->state, attached_plane); |
| 1403 | |
| 1404 | if (!attached_state) |
| 1405 | continue; |
| 1406 | |
| 1407 | attached_pstate = to_sde_plane_state(attached_state); |
| 1408 | attached_rstate = &attached_pstate->rot; |
| 1409 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1410 | if (attached_rstate->rot_hw != rstate->rot_hw) |
| 1411 | continue; |
| 1412 | |
| 1413 | found++; |
| 1414 | |
| 1415 | /* skip itself */ |
| 1416 | if (attached_plane == plane) |
| 1417 | continue; |
| 1418 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1419 | /* find bounding rotator source roi */ |
| 1420 | if (attached_state->src_x < in_rot->x1) |
| 1421 | in_rot->x1 = attached_state->src_x; |
| 1422 | |
| 1423 | if (attached_state->src_y < in_rot->y1) |
| 1424 | in_rot->y1 = attached_state->src_y; |
| 1425 | |
| 1426 | if (attached_state->src_x + attached_state->src_w > in_rot->x2) |
| 1427 | in_rot->x2 = attached_state->src_x + |
| 1428 | attached_state->src_w; |
| 1429 | |
| 1430 | if (attached_state->src_y + attached_state->src_h > in_rot->y2) |
| 1431 | in_rot->y2 = attached_state->src_y + |
| 1432 | attached_state->src_h; |
| 1433 | |
| 1434 | /* find bounding rotator destination roi */ |
| 1435 | dst_x = sde_plane_get_property(attached_pstate, |
| 1436 | PLANE_PROP_ROT_DST_X); |
| 1437 | dst_y = sde_plane_get_property(attached_pstate, |
| 1438 | PLANE_PROP_ROT_DST_Y); |
| 1439 | dst_w = sde_plane_get_property(attached_pstate, |
| 1440 | PLANE_PROP_ROT_DST_W); |
| 1441 | dst_h = sde_plane_get_property(attached_pstate, |
| 1442 | PLANE_PROP_ROT_DST_H); |
| 1443 | if (!dst_w && !dst_h) { |
| 1444 | attached_out_rect.x1 = attached_state->src_x; |
| 1445 | attached_out_rect.y1 = attached_state->src_y; |
| 1446 | attached_out_rect.x2 = attached_out_rect.x1 + |
| 1447 | attached_state->src_w; |
| 1448 | attached_out_rect.y2 = attached_out_rect.y1 + |
| 1449 | attached_state->src_h; |
| 1450 | drm_rect_rotate(&attached_out_rect, |
| 1451 | state->fb->width << 16, |
| 1452 | state->fb->height << 16, |
| 1453 | rstate->in_rotation); |
| 1454 | } else { |
| 1455 | attached_out_rect.x1 = dst_x; |
| 1456 | attached_out_rect.y1 = dst_y; |
| 1457 | attached_out_rect.x2 = dst_x + dst_w; |
| 1458 | attached_out_rect.y2 = dst_y + dst_h; |
| 1459 | } |
| 1460 | |
| 1461 | /* find relative sspp position */ |
| 1462 | if (attached_out_rect.x1 < rstate->out_src_rect.x1) |
| 1463 | xpos++; |
| 1464 | |
| 1465 | if (attached_out_rect.x1 < out_rot->x1) |
| 1466 | out_rot->x1 = attached_out_rect.x1; |
| 1467 | |
| 1468 | if (attached_out_rect.y1 < out_rot->y1) |
| 1469 | out_rot->y1 = attached_out_rect.y1; |
| 1470 | |
| 1471 | if (attached_out_rect.x2 > out_rot->x2) |
| 1472 | out_rot->x2 = attached_out_rect.x2; |
| 1473 | |
| 1474 | if (attached_out_rect.y2 > out_rot->y2) |
| 1475 | out_rot->y2 = attached_out_rect.y2; |
| 1476 | |
| 1477 | SDE_DEBUG("plane%d.%u src_x:%d sspp:%dx%d+%d+%d/%dx%d+%d+%d\n", |
| 1478 | attached_plane->base.id, |
| 1479 | attached_rstate->sequence_id, |
| 1480 | attached_rstate->out_src_rect.x1 >> 16, |
| 1481 | attached_state->src_w >> 16, |
| 1482 | attached_state->src_h >> 16, |
| 1483 | attached_state->src_x >> 16, |
| 1484 | attached_state->src_y >> 16, |
| 1485 | drm_rect_width(&attached_rstate->out_src_rect) >> 16, |
| 1486 | drm_rect_height(&attached_rstate->out_src_rect) >> 16, |
| 1487 | attached_rstate->out_src_rect.x1 >> 16, |
| 1488 | attached_rstate->out_src_rect.y1 >> 16); |
| 1489 | } |
| 1490 | |
| 1491 | rstate->out_xpos = xpos; |
| 1492 | rstate->nplane = found; |
| 1493 | |
| 1494 | SDE_DEBUG("plane%d.%u xpos:%d/%d rot:%dx%d+%d+%d/%dx%d+%d+%d\n", |
| 1495 | plane->base.id, rstate->sequence_id, |
| 1496 | rstate->out_xpos, rstate->nplane, |
| 1497 | drm_rect_width(in_rot) >> 16, |
| 1498 | drm_rect_height(in_rot) >> 16, |
| 1499 | in_rot->x1 >> 16, in_rot->y1 >> 16, |
| 1500 | drm_rect_width(&rstate->out_rot_rect) >> 16, |
| 1501 | drm_rect_height(&rstate->out_rot_rect) >> 16, |
| 1502 | rstate->out_rot_rect.x1 >> 16, |
| 1503 | rstate->out_rot_rect.y1 >> 16); |
| 1504 | } |
| 1505 | |
| 1506 | /** |
| 1507 | * sde_plane_rot_submit_command - commit given state for the rotator stage |
| 1508 | * @plane: Pointer to drm plane |
| 1509 | * @state: Pointer to the state to be committed |
| 1510 | * @hw_cmd: rotator command type |
| 1511 | * return: 0 if success; error code otherwise |
| 1512 | */ |
| 1513 | static int sde_plane_rot_submit_command(struct drm_plane *plane, |
| 1514 | struct drm_plane_state *state, enum sde_hw_rot_cmd_type hw_cmd) |
| 1515 | { |
| 1516 | struct sde_plane *psde = to_sde_plane(plane); |
| 1517 | struct sde_plane_state *pstate = to_sde_plane_state(state); |
| 1518 | struct sde_plane_rot_state *rstate = &pstate->rot; |
| 1519 | struct sde_hw_rot_cmd *rot_cmd; |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 1520 | struct drm_crtc_state *cstate; |
| 1521 | struct sde_crtc_state *sde_cstate; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1522 | int ret, i; |
| 1523 | |
| 1524 | if (!plane || !state || !state->fb || !rstate->rot_hw) { |
| 1525 | SDE_ERROR("invalid parameters\n"); |
| 1526 | return -EINVAL; |
| 1527 | } |
| 1528 | |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 1529 | cstate = _sde_plane_get_crtc_state(state); |
| 1530 | if (IS_ERR_OR_NULL(cstate)) { |
| 1531 | SDE_ERROR("invalid crtc state %ld\n", PTR_ERR(cstate)); |
| 1532 | return -EINVAL; |
| 1533 | } |
| 1534 | sde_cstate = to_sde_crtc_state(cstate); |
| 1535 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1536 | rot_cmd = &rstate->rot_cmd; |
| 1537 | |
| 1538 | rot_cmd->master = (rstate->out_xpos == 0); |
| 1539 | rot_cmd->sequence_id = rstate->sequence_id; |
| 1540 | rot_cmd->fps = pstate->base.crtc && pstate->base.crtc->state ? |
| 1541 | drm_mode_vrefresh(&pstate->base.crtc->state->adjusted_mode) : |
| 1542 | DEFAULT_REFRESH_RATE; |
| 1543 | rot_cmd->rot90 = rstate->rot90; |
| 1544 | rot_cmd->hflip = rstate->hflip; |
| 1545 | rot_cmd->vflip = rstate->vflip; |
| 1546 | rot_cmd->secure = state->fb->flags & DRM_MODE_FB_SECURE ? true : false; |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 1547 | rot_cmd->prefill_bw = sde_crtc_get_property(sde_cstate, |
| 1548 | CRTC_PROP_ROT_PREFILL_BW); |
Alan Kwong | 8c176bf | 2017-02-09 19:34:32 -0800 | [diff] [blame] | 1549 | rot_cmd->clkrate = sde_crtc_get_property(sde_cstate, |
| 1550 | CRTC_PROP_ROT_CLK); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1551 | rot_cmd->dst_writeback = psde->sbuf_writeback; |
| 1552 | |
| 1553 | if (sde_crtc_get_intf_mode(state->crtc) == INTF_MODE_VIDEO) |
| 1554 | rot_cmd->video_mode = true; |
| 1555 | else |
| 1556 | rot_cmd->video_mode = false; |
| 1557 | |
| 1558 | rot_cmd->src_pixel_format = state->fb->pixel_format; |
| 1559 | rot_cmd->src_modifier = state->fb->modifier[0]; |
| 1560 | rot_cmd->src_stride = state->fb->pitches[0]; |
| 1561 | |
| 1562 | rot_cmd->src_format = to_sde_format(msm_framebuffer_format(state->fb)); |
| 1563 | if (!rot_cmd->src_format) { |
| 1564 | SDE_ERROR("failed to get src format\n"); |
| 1565 | return -EINVAL; |
| 1566 | } |
| 1567 | |
| 1568 | rot_cmd->src_width = state->fb->width; |
| 1569 | rot_cmd->src_height = state->fb->height; |
| 1570 | rot_cmd->src_rect_x = rstate->in_rot_rect.x1 >> 16; |
| 1571 | rot_cmd->src_rect_y = rstate->in_rot_rect.y1 >> 16; |
| 1572 | rot_cmd->src_rect_w = drm_rect_width(&rstate->in_rot_rect) >> 16; |
| 1573 | rot_cmd->src_rect_h = drm_rect_height(&rstate->in_rot_rect) >> 16; |
| 1574 | rot_cmd->dst_rect_x = rstate->out_rot_rect.x1 >> 16; |
| 1575 | rot_cmd->dst_rect_y = rstate->out_rot_rect.y1 >> 16; |
| 1576 | rot_cmd->dst_rect_w = drm_rect_width(&rstate->out_rot_rect) >> 16; |
| 1577 | rot_cmd->dst_rect_h = drm_rect_height(&rstate->out_rot_rect) >> 16; |
| 1578 | |
| 1579 | if (hw_cmd == SDE_HW_ROT_CMD_COMMIT) { |
| 1580 | struct sde_hw_fmt_layout layout; |
| 1581 | |
| 1582 | memset(&layout, 0, sizeof(struct sde_hw_fmt_layout)); |
| 1583 | sde_format_populate_layout(rstate->mmu_id, state->fb, |
| 1584 | &layout); |
| 1585 | for (i = 0; i < ARRAY_SIZE(rot_cmd->src_iova); i++) { |
| 1586 | rot_cmd->src_iova[i] = layout.plane_addr[i]; |
| 1587 | rot_cmd->src_len[i] = layout.plane_size[i]; |
| 1588 | } |
| 1589 | rot_cmd->src_planes = layout.num_planes; |
| 1590 | |
| 1591 | memset(&layout, 0, sizeof(struct sde_hw_fmt_layout)); |
| 1592 | sde_format_populate_layout(rstate->mmu_id, rstate->out_fb, |
| 1593 | &layout); |
| 1594 | for (i = 0; i < ARRAY_SIZE(rot_cmd->dst_iova); i++) { |
| 1595 | rot_cmd->dst_iova[i] = layout.plane_addr[i]; |
| 1596 | rot_cmd->dst_len[i] = layout.plane_size[i]; |
| 1597 | } |
| 1598 | rot_cmd->dst_planes = layout.num_planes; |
| 1599 | } |
| 1600 | |
| 1601 | ret = rstate->rot_hw->ops.commit(rstate->rot_hw, rot_cmd, hw_cmd); |
| 1602 | if (ret) { |
| 1603 | SDE_ERROR("failed to commit rotator %d\n", ret); |
| 1604 | return ret; |
| 1605 | } |
| 1606 | |
| 1607 | rstate->out_rotation = rstate->in_rotation; |
| 1608 | rstate->out_fb_flags = rot_cmd->dst_modifier ? |
| 1609 | DRM_MODE_FB_MODIFIERS : 0; |
| 1610 | rstate->out_fb_flags |= rot_cmd->secure ? DRM_MODE_FB_SECURE : 0; |
| 1611 | rstate->out_fb_format = rot_cmd->dst_format; |
| 1612 | rstate->out_fb_pixel_format = rot_cmd->dst_pixel_format; |
| 1613 | |
| 1614 | for (i = 0; i < ARRAY_SIZE(rstate->out_fb_modifier); i++) |
| 1615 | rstate->out_fb_modifier[i] = rot_cmd->dst_modifier; |
| 1616 | |
| 1617 | rstate->out_fb_width = drm_rect_width(&rstate->out_rot_rect) >> 16; |
| 1618 | rstate->out_fb_height = drm_rect_height(&rstate->out_rot_rect) >> 16; |
| 1619 | rstate->out_src_x = rstate->out_src_rect.x1 - rstate->out_rot_rect.x1; |
| 1620 | rstate->out_src_y = rstate->out_src_rect.y1 - rstate->out_rot_rect.y1; |
| 1621 | rstate->out_src_w = drm_rect_width(&rstate->out_src_rect); |
| 1622 | rstate->out_src_h = drm_rect_height(&rstate->out_src_rect); |
| 1623 | |
| 1624 | if (rot_cmd->rot90) |
| 1625 | rstate->out_rotation &= ~DRM_ROTATE_90; |
| 1626 | |
| 1627 | if (rot_cmd->hflip) |
| 1628 | rstate->out_rotation &= ~DRM_REFLECT_X; |
| 1629 | |
| 1630 | if (rot_cmd->vflip) |
| 1631 | rstate->out_rotation &= ~DRM_REFLECT_Y; |
| 1632 | |
| 1633 | SDE_DEBUG( |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 1634 | "plane%d.%d rot:%d/%c%c%c%c/%dx%d/%4.4s/%llx/%dx%d+%d+%d\n", |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1635 | plane->base.id, rstate->sequence_id, hw_cmd, |
| 1636 | rot_cmd->rot90 ? 'r' : '_', |
| 1637 | rot_cmd->hflip ? 'h' : '_', |
| 1638 | rot_cmd->vflip ? 'v' : '_', |
| 1639 | rot_cmd->video_mode ? 'V' : 'C', |
| 1640 | state->fb->width, state->fb->height, |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 1641 | (char *) &state->fb->pixel_format, |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1642 | state->fb->modifier[0], |
| 1643 | drm_rect_width(&rstate->in_rot_rect) >> 16, |
| 1644 | drm_rect_height(&rstate->in_rot_rect) >> 16, |
| 1645 | rstate->in_rot_rect.x1 >> 16, |
| 1646 | rstate->in_rot_rect.y1 >> 16); |
| 1647 | |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 1648 | SDE_DEBUG("plane%d.%d sspp:%d/%x/%dx%d/%4.4s/%llx/%dx%d+%d+%d\n", |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1649 | plane->base.id, rstate->sequence_id, hw_cmd, |
| 1650 | rstate->out_rotation, |
| 1651 | rstate->out_fb_width, rstate->out_fb_height, |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 1652 | (char *) &rstate->out_fb_pixel_format, |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1653 | rstate->out_fb_modifier[0], |
| 1654 | rstate->out_src_w >> 16, rstate->out_src_h >> 16, |
| 1655 | rstate->out_src_x >> 16, rstate->out_src_y >> 16); |
| 1656 | |
| 1657 | return ret; |
| 1658 | } |
| 1659 | |
| 1660 | /** |
| 1661 | * sde_plane_rot_prepare_fb - prepare framebuffer of the new state |
| 1662 | * for rotator (pre-sspp) stage |
| 1663 | * @plane: Pointer to drm plane |
| 1664 | * @new_state: Pointer to new drm plane state |
| 1665 | * return: 0 if success; error code otherwise |
| 1666 | */ |
| 1667 | static int sde_plane_rot_prepare_fb(struct drm_plane *plane, |
| 1668 | struct drm_plane_state *new_state) |
| 1669 | { |
| 1670 | struct drm_framebuffer *fb = new_state->fb; |
| 1671 | struct sde_plane_state *new_pstate = to_sde_plane_state(new_state); |
| 1672 | struct sde_plane_rot_state *new_rstate = &new_pstate->rot; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1673 | struct drm_crtc_state *cstate; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1674 | int ret; |
| 1675 | |
| 1676 | SDE_DEBUG("plane%d.%d FB[%u] sbuf:%d rot:%d crtc:%d\n", |
| 1677 | plane->base.id, |
| 1678 | new_rstate->sequence_id, fb ? fb->base.id : 0, |
| 1679 | !!new_rstate->out_sbuf, !!new_rstate->rot_hw, |
| 1680 | sde_plane_crtc_enabled(new_state)); |
| 1681 | |
| 1682 | if (!new_rstate->out_sbuf || !new_rstate->rot_hw) |
| 1683 | return 0; |
| 1684 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1685 | cstate = _sde_plane_get_crtc_state(new_state); |
| 1686 | if (IS_ERR(cstate)) { |
| 1687 | ret = PTR_ERR(cstate); |
| 1688 | SDE_ERROR("invalid crtc state %d\n", ret); |
| 1689 | return ret; |
| 1690 | } |
| 1691 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1692 | /* need to re-calc based on all newly validated plane states */ |
| 1693 | sde_plane_rot_calc_cfg(plane, new_state); |
| 1694 | |
| 1695 | /* check if stream buffer is already attached to rotator */ |
| 1696 | if (sde_plane_enabled(new_state)) { |
| 1697 | struct sde_kms_fbo *fbo; |
| 1698 | struct drm_framebuffer *fb; |
| 1699 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1700 | fbo = sde_crtc_res_get(cstate, SDE_CRTC_RES_ROT_OUT_FBO, |
| 1701 | (u64) &new_rstate->rot_hw->base); |
| 1702 | fb = sde_crtc_res_get(cstate, SDE_CRTC_RES_ROT_OUT_FB, |
| 1703 | (u64) &new_rstate->rot_hw->base); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1704 | if (fb && fbo) { |
| 1705 | SDE_DEBUG("plane%d.%d get fb/fbo\n", plane->base.id, |
| 1706 | new_rstate->sequence_id); |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1707 | } else if (fbo) { |
| 1708 | sde_crtc_res_put(cstate, SDE_CRTC_RES_ROT_OUT_FBO, |
| 1709 | (u64) &new_rstate->rot_hw->base); |
| 1710 | fbo = NULL; |
| 1711 | } else if (fb) { |
| 1712 | sde_crtc_res_put(cstate, SDE_CRTC_RES_ROT_OUT_FB, |
| 1713 | (u64) &new_rstate->rot_hw->base); |
| 1714 | fb = NULL; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1715 | } |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1716 | |
| 1717 | new_rstate->out_fbo = fbo; |
| 1718 | new_rstate->out_fb = fb; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1719 | } |
| 1720 | |
| 1721 | /* release buffer if output format configuration changes */ |
| 1722 | if (new_rstate->out_fb && |
| 1723 | ((new_rstate->out_fb_height != new_rstate->out_fb->height) || |
| 1724 | (new_rstate->out_fb_width != new_rstate->out_fb->width) || |
| 1725 | (new_rstate->out_fb_pixel_format != |
| 1726 | new_rstate->out_fb->pixel_format) || |
| 1727 | (new_rstate->out_fb_modifier[0] != |
| 1728 | new_rstate->out_fb->modifier[0]) || |
| 1729 | (new_rstate->out_fb_flags != new_rstate->out_fb->flags))) { |
| 1730 | |
| 1731 | SDE_DEBUG("plane%d.%d release fb/fbo\n", plane->base.id, |
| 1732 | new_rstate->sequence_id); |
| 1733 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1734 | sde_crtc_res_put(cstate, SDE_CRTC_RES_ROT_OUT_FB, |
| 1735 | (u64) &new_rstate->rot_hw->base); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1736 | new_rstate->out_fb = NULL; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1737 | sde_crtc_res_put(cstate, SDE_CRTC_RES_ROT_OUT_FBO, |
| 1738 | (u64) &new_rstate->rot_hw->base); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1739 | new_rstate->out_fbo = NULL; |
| 1740 | } |
| 1741 | |
| 1742 | /* create new stream buffer if it is not available */ |
| 1743 | if (sde_plane_enabled(new_state) && !new_rstate->out_fb) { |
| 1744 | u32 fb_w = drm_rect_width(&new_rstate->out_rot_rect) >> 16; |
| 1745 | u32 fb_h = drm_rect_height(&new_rstate->out_rot_rect) >> 16; |
| 1746 | |
| 1747 | SDE_DEBUG("plane%d.%d allocate fb/fbo\n", plane->base.id, |
| 1748 | new_rstate->sequence_id); |
| 1749 | |
| 1750 | if (new_state->fb->flags & DRM_MODE_FB_SECURE) |
| 1751 | new_rstate->mmu_id = MSM_SMMU_DOMAIN_SECURE; |
| 1752 | else |
| 1753 | new_rstate->mmu_id = MSM_SMMU_DOMAIN_UNSECURE; |
| 1754 | |
| 1755 | /* check if out_fb is already attached to rotator */ |
| 1756 | new_rstate->out_fbo = sde_kms_fbo_alloc(plane->dev, fb_w, fb_h, |
| 1757 | new_rstate->out_fb_pixel_format, |
| 1758 | new_rstate->out_fb_modifier, |
| 1759 | new_rstate->out_fb_flags); |
| 1760 | if (!new_rstate->out_fbo) { |
| 1761 | SDE_ERROR("failed to allocate inline buffer object\n"); |
| 1762 | ret = -EINVAL; |
| 1763 | goto error_create_fbo; |
| 1764 | } |
| 1765 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1766 | ret = sde_crtc_res_add(cstate, SDE_CRTC_RES_ROT_OUT_FBO, |
| 1767 | (u64) &new_rstate->rot_hw->base, |
| 1768 | new_rstate->out_fbo, &fbo_res_ops); |
| 1769 | if (ret) { |
| 1770 | SDE_ERROR("failed to add crtc resource\n"); |
| 1771 | goto error_create_fbo_res; |
| 1772 | } |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1773 | |
| 1774 | new_rstate->out_fb = sde_kms_fbo_create_fb(plane->dev, |
| 1775 | new_rstate->out_fbo); |
| 1776 | if (!new_rstate->out_fb) { |
| 1777 | SDE_ERROR("failed to create inline framebuffer\n"); |
| 1778 | ret = -EINVAL; |
| 1779 | goto error_create_fb; |
| 1780 | } |
| 1781 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1782 | ret = sde_crtc_res_add(cstate, SDE_CRTC_RES_ROT_OUT_FB, |
| 1783 | (u64) &new_rstate->rot_hw->base, |
| 1784 | new_rstate->out_fb, &fb_res_ops); |
| 1785 | if (ret) { |
| 1786 | SDE_ERROR("failed to add crtc resource %d\n", ret); |
| 1787 | goto error_create_fb_res; |
| 1788 | } |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1789 | } |
| 1790 | |
| 1791 | /* prepare rotator input buffer */ |
| 1792 | ret = msm_framebuffer_prepare(new_state->fb, new_rstate->mmu_id); |
| 1793 | if (ret) { |
| 1794 | SDE_ERROR("failed to prepare input framebuffer\n"); |
| 1795 | goto error_prepare_input_buffer; |
| 1796 | } |
| 1797 | |
| 1798 | /* prepare rotator output buffer */ |
| 1799 | if (sde_plane_enabled(new_state) && new_rstate->out_fb) { |
| 1800 | SDE_DEBUG("plane%d.%d prepare fb/fbo\n", plane->base.id, |
| 1801 | new_rstate->sequence_id); |
| 1802 | |
| 1803 | ret = msm_framebuffer_prepare(new_rstate->out_fb, |
| 1804 | new_rstate->mmu_id); |
| 1805 | if (ret) { |
| 1806 | SDE_ERROR("failed to prepare inline framebuffer\n"); |
| 1807 | goto error_prepare_output_buffer; |
| 1808 | } |
| 1809 | } |
| 1810 | |
| 1811 | return 0; |
| 1812 | |
| 1813 | error_prepare_output_buffer: |
| 1814 | msm_framebuffer_cleanup(new_state->fb, new_rstate->mmu_id); |
| 1815 | error_prepare_input_buffer: |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1816 | sde_crtc_res_put(cstate, SDE_CRTC_RES_ROT_OUT_FB, |
| 1817 | (u64) &new_rstate->rot_hw->base); |
| 1818 | error_create_fb_res: |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1819 | new_rstate->out_fb = NULL; |
| 1820 | error_create_fb: |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1821 | sde_crtc_res_put(cstate, SDE_CRTC_RES_ROT_OUT_FBO, |
| 1822 | (u64) &new_rstate->rot_hw->base); |
| 1823 | error_create_fbo_res: |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1824 | new_rstate->out_fbo = NULL; |
| 1825 | error_create_fbo: |
| 1826 | return ret; |
| 1827 | } |
| 1828 | |
| 1829 | /** |
| 1830 | * sde_plane_rot_cleanup_fb - cleanup framebuffer of previous state for the |
| 1831 | * rotator (pre-sspp) stage |
| 1832 | * @plane: Pointer to drm plane |
| 1833 | * @old_state: Pointer to previous drm plane state |
| 1834 | * return: none |
| 1835 | */ |
| 1836 | static void sde_plane_rot_cleanup_fb(struct drm_plane *plane, |
| 1837 | struct drm_plane_state *old_state) |
| 1838 | { |
| 1839 | struct sde_plane_state *old_pstate = to_sde_plane_state(old_state); |
| 1840 | struct sde_plane_rot_state *old_rstate = &old_pstate->rot; |
| 1841 | struct sde_hw_rot_cmd *cmd = &old_rstate->rot_cmd; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1842 | struct drm_crtc_state *cstate; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1843 | int ret; |
| 1844 | |
| 1845 | SDE_DEBUG("plane%d.%d FB[%u] sbuf:%d rot:%d crtc:%d\n", plane->base.id, |
| 1846 | old_rstate->sequence_id, old_state->fb->base.id, |
| 1847 | !!old_rstate->out_sbuf, !!old_rstate->rot_hw, |
| 1848 | sde_plane_crtc_enabled(old_state)); |
| 1849 | |
| 1850 | if (!old_rstate->out_sbuf || !old_rstate->rot_hw) |
| 1851 | return; |
| 1852 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1853 | cstate = _sde_plane_get_crtc_state(old_state); |
| 1854 | if (IS_ERR(cstate)) { |
| 1855 | ret = PTR_ERR(cstate); |
| 1856 | SDE_ERROR("invalid crtc state %d\n", ret); |
| 1857 | return; |
| 1858 | } |
| 1859 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1860 | if (sde_plane_crtc_enabled(old_state)) { |
| 1861 | ret = old_rstate->rot_hw->ops.commit(old_rstate->rot_hw, cmd, |
| 1862 | SDE_HW_ROT_CMD_CLEANUP); |
| 1863 | if (ret) |
| 1864 | SDE_ERROR("failed to cleanup rotator buffers\n"); |
| 1865 | } |
| 1866 | |
| 1867 | if (sde_plane_enabled(old_state)) { |
| 1868 | if (old_rstate->out_fb) { |
| 1869 | msm_framebuffer_cleanup(old_rstate->out_fb, |
| 1870 | old_rstate->mmu_id); |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1871 | sde_crtc_res_put(cstate, SDE_CRTC_RES_ROT_OUT_FB, |
| 1872 | (u64) &old_rstate->rot_hw->base); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1873 | old_rstate->out_fb = NULL; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1874 | sde_crtc_res_put(cstate, SDE_CRTC_RES_ROT_OUT_FBO, |
| 1875 | (u64) &old_rstate->rot_hw->base); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1876 | old_rstate->out_fbo = NULL; |
| 1877 | } |
| 1878 | |
| 1879 | msm_framebuffer_cleanup(old_state->fb, old_rstate->mmu_id); |
| 1880 | } |
| 1881 | } |
| 1882 | |
| 1883 | /** |
| 1884 | * sde_plane_rot_atomic_check - verify rotator update of the given state |
| 1885 | * @plane: Pointer to drm plane |
| 1886 | * @state: Pointer to drm plane state to be validated |
| 1887 | * return: 0 if success; error code otherwise |
| 1888 | */ |
| 1889 | static int sde_plane_rot_atomic_check(struct drm_plane *plane, |
| 1890 | struct drm_plane_state *state) |
| 1891 | { |
| 1892 | struct sde_plane *psde; |
| 1893 | struct sde_plane_state *pstate, *old_pstate; |
| 1894 | struct sde_plane_rot_state *rstate, *old_rstate; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1895 | struct drm_crtc_state *cstate; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1896 | struct sde_hw_blk *hw_blk; |
| 1897 | int i, ret = 0; |
| 1898 | |
| 1899 | if (!plane || !state) { |
| 1900 | SDE_ERROR("invalid plane/state\n"); |
| 1901 | return -EINVAL; |
| 1902 | } |
| 1903 | |
| 1904 | psde = to_sde_plane(plane); |
| 1905 | pstate = to_sde_plane_state(state); |
| 1906 | old_pstate = to_sde_plane_state(plane->state); |
| 1907 | rstate = &pstate->rot; |
| 1908 | old_rstate = &old_pstate->rot; |
| 1909 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1910 | /* cstate will be null if crtc is disconnected from plane */ |
| 1911 | cstate = _sde_plane_get_crtc_state(state); |
| 1912 | if (IS_ERR(cstate)) { |
| 1913 | ret = PTR_ERR(cstate); |
| 1914 | SDE_ERROR("invalid crtc state %d\n", ret); |
| 1915 | return ret; |
| 1916 | } |
| 1917 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1918 | SDE_DEBUG("plane%d.%d FB[%u] sbuf:%d rot:%d crtc:%d\n", plane->base.id, |
| 1919 | rstate->sequence_id, state->fb ? state->fb->base.id : 0, |
| 1920 | !!rstate->out_sbuf, !!rstate->rot_hw, |
| 1921 | sde_plane_crtc_enabled(state)); |
| 1922 | |
| 1923 | rstate->in_rotation = drm_rotation_simplify( |
| 1924 | sde_plane_get_property(pstate, PLANE_PROP_ROTATION), |
Alan Kwong | 709150c | 2017-04-03 08:44:31 -0700 | [diff] [blame] | 1925 | DRM_ROTATE_0 | DRM_ROTATE_90 | |
| 1926 | DRM_REFLECT_X | DRM_REFLECT_Y); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1927 | rstate->rot90 = rstate->in_rotation & DRM_ROTATE_90 ? true : false; |
| 1928 | rstate->hflip = rstate->in_rotation & DRM_REFLECT_X ? true : false; |
| 1929 | rstate->vflip = rstate->in_rotation & DRM_REFLECT_Y ? true : false; |
| 1930 | rstate->out_sbuf = psde->sbuf_mode || rstate->rot90; |
| 1931 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1932 | if (sde_plane_enabled(state) && rstate->out_sbuf) { |
| 1933 | SDE_DEBUG("plane%d.%d acquire rotator\n", |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1934 | plane->base.id, rstate->sequence_id); |
| 1935 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1936 | hw_blk = sde_crtc_res_get(cstate, SDE_HW_BLK_ROT, |
| 1937 | (u64) state->fb); |
| 1938 | if (!hw_blk) { |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1939 | SDE_ERROR("plane%d no available rotator\n", |
| 1940 | plane->base.id); |
| 1941 | return -EINVAL; |
| 1942 | } |
| 1943 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1944 | rstate->rot_hw = to_sde_hw_rot(hw_blk); |
| 1945 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1946 | if (!rstate->rot_hw->ops.commit) { |
| 1947 | SDE_ERROR("plane%d invalid rotator ops\n", |
| 1948 | plane->base.id); |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1949 | sde_crtc_res_put(cstate, |
| 1950 | SDE_HW_BLK_ROT, (u64) state->fb); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1951 | rstate->rot_hw = NULL; |
| 1952 | return -EINVAL; |
| 1953 | } |
| 1954 | |
| 1955 | rstate->in_fb = state->fb; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 1956 | } else { |
| 1957 | rstate->in_fb = NULL; |
| 1958 | rstate->rot_hw = NULL; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1959 | } |
| 1960 | |
| 1961 | if (sde_plane_enabled(state) && rstate->out_sbuf && rstate->rot_hw) { |
| 1962 | |
| 1963 | SDE_DEBUG("plane%d.%d use rotator\n", |
| 1964 | plane->base.id, rstate->sequence_id); |
| 1965 | |
| 1966 | sde_plane_rot_calc_cfg(plane, state); |
| 1967 | |
| 1968 | ret = sde_plane_rot_submit_command(plane, state, |
| 1969 | SDE_HW_ROT_CMD_VALIDATE); |
| 1970 | |
Clarence Ip | 4475d58 | 2017-04-18 11:36:00 -0400 | [diff] [blame] | 1971 | } else { |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1972 | |
| 1973 | SDE_DEBUG("plane%d.%d bypass rotator\n", plane->base.id, |
| 1974 | rstate->sequence_id); |
| 1975 | |
| 1976 | /* bypass rotator - initialize output setting as input */ |
Clarence Ip | 4475d58 | 2017-04-18 11:36:00 -0400 | [diff] [blame] | 1977 | for (i = 0; i < ARRAY_SIZE(rstate->out_fb_modifier); i++) |
| 1978 | rstate->out_fb_modifier[i] = state->fb ? |
| 1979 | state->fb->modifier[i] : 0x0; |
| 1980 | |
| 1981 | if (state->fb) { |
| 1982 | rstate->out_fb_pixel_format = state->fb->pixel_format; |
| 1983 | rstate->out_fb_flags = state->fb->flags; |
| 1984 | rstate->out_fb_width = state->fb->width; |
| 1985 | rstate->out_fb_height = state->fb->height; |
| 1986 | } else { |
| 1987 | rstate->out_fb_pixel_format = 0x0; |
| 1988 | rstate->out_fb_flags = 0x0; |
| 1989 | rstate->out_fb_width = 0; |
| 1990 | rstate->out_fb_height = 0; |
| 1991 | } |
| 1992 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1993 | rstate->out_rotation = rstate->in_rotation; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1994 | rstate->out_src_x = state->src_x; |
| 1995 | rstate->out_src_y = state->src_y; |
| 1996 | rstate->out_src_w = state->src_w; |
| 1997 | rstate->out_src_h = state->src_h; |
| 1998 | |
| 1999 | rstate->out_fb_format = NULL; |
| 2000 | rstate->out_sbuf = false; |
| 2001 | rstate->out_fb = state->fb; |
| 2002 | } |
| 2003 | |
| 2004 | return ret; |
| 2005 | } |
| 2006 | |
| 2007 | /** |
| 2008 | * sde_plane_rot_atomic_update - perform atomic update for rotator stage |
| 2009 | * @plane: Pointer to drm plane |
| 2010 | * @old_state: Pointer to previous state |
| 2011 | * return: none |
| 2012 | */ |
| 2013 | static void sde_plane_rot_atomic_update(struct drm_plane *plane, |
| 2014 | struct drm_plane_state *old_state) |
| 2015 | { |
| 2016 | struct drm_plane_state *state; |
| 2017 | struct sde_plane_state *pstate; |
| 2018 | struct sde_plane_rot_state *rstate; |
| 2019 | |
| 2020 | if (!plane || !plane->state) { |
| 2021 | SDE_ERROR("invalid plane/state\n"); |
| 2022 | return; |
| 2023 | } |
| 2024 | |
| 2025 | state = plane->state; |
| 2026 | pstate = to_sde_plane_state(state); |
| 2027 | rstate = &pstate->rot; |
| 2028 | |
| 2029 | SDE_DEBUG("plane%d.%d sbuf:%d rot:%d crtc:%d\n", plane->base.id, |
| 2030 | rstate->sequence_id, |
| 2031 | !!rstate->out_sbuf, !!rstate->rot_hw, |
| 2032 | sde_plane_crtc_enabled(plane->state)); |
| 2033 | |
| 2034 | if (!sde_plane_crtc_enabled(state)) |
| 2035 | return; |
| 2036 | |
| 2037 | if (!rstate->out_sbuf || !rstate->rot_hw) |
| 2038 | return; |
| 2039 | |
| 2040 | sde_plane_rot_submit_command(plane, state, SDE_HW_ROT_CMD_COMMIT); |
| 2041 | } |
| 2042 | |
| 2043 | /** |
| 2044 | * sde_plane_rot_destroy_state - destroy state for rotator stage |
| 2045 | * @plane: Pointer to drm plane |
| 2046 | * @state: Pointer to state to be destroyed |
| 2047 | * return: none |
| 2048 | */ |
| 2049 | static void sde_plane_rot_destroy_state(struct drm_plane *plane, |
| 2050 | struct drm_plane_state *state) |
| 2051 | { |
| 2052 | struct sde_plane_state *pstate = to_sde_plane_state(state); |
| 2053 | struct sde_plane_rot_state *rstate = &pstate->rot; |
| 2054 | |
| 2055 | SDE_DEBUG("plane%d.%d sbuf:%d rot:%d crtc:%d\n", plane->base.id, |
| 2056 | rstate->sequence_id, |
| 2057 | !!rstate->out_sbuf, !!rstate->rot_hw, |
| 2058 | sde_plane_crtc_enabled(state)); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2059 | } |
| 2060 | |
| 2061 | /** |
| 2062 | * sde_plane_rot_duplicate_state - duplicate state for rotator stage |
| 2063 | * @plane: Pointer to drm plane |
| 2064 | * @new_state: Pointer to duplicated state |
| 2065 | * return: 0 if success; error code otherwise |
| 2066 | */ |
| 2067 | static int sde_plane_rot_duplicate_state(struct drm_plane *plane, |
| 2068 | struct drm_plane_state *new_state) |
| 2069 | { |
| 2070 | struct sde_plane_state *pstate = to_sde_plane_state(new_state); |
| 2071 | struct sde_plane_rot_state *rstate = &pstate->rot; |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 2072 | struct drm_crtc_state *cstate; |
| 2073 | int ret; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2074 | |
| 2075 | rstate->sequence_id++; |
| 2076 | |
| 2077 | SDE_DEBUG("plane%d.%d sbuf:%d rot:%d\n", plane->base.id, |
| 2078 | rstate->sequence_id, |
| 2079 | !!rstate->out_sbuf, !!rstate->rot_hw); |
| 2080 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 2081 | cstate = _sde_plane_get_crtc_state(new_state); |
| 2082 | if (IS_ERR(cstate)) { |
| 2083 | ret = PTR_ERR(cstate); |
| 2084 | SDE_ERROR("invalid crtc state %d\n", ret); |
| 2085 | return -EINVAL; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2086 | } |
| 2087 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 2088 | if (rstate->rot_hw && cstate) |
| 2089 | sde_crtc_res_get(cstate, SDE_HW_BLK_ROT, (u64) rstate->in_fb); |
| 2090 | else if (rstate->rot_hw && !cstate) |
| 2091 | SDE_ERROR("plane%d.%d zombie rotator hw\n", |
| 2092 | plane->base.id, rstate->sequence_id); |
| 2093 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2094 | rstate->out_fb = NULL; |
| 2095 | rstate->out_fbo = NULL; |
| 2096 | |
| 2097 | return 0; |
| 2098 | } |
| 2099 | |
| 2100 | /** |
| 2101 | * sde_plane_rot_install_caps - install plane rotator capabilities |
| 2102 | * @plane: Pointer to drm plane |
| 2103 | * return: none |
| 2104 | */ |
| 2105 | static void sde_plane_rot_install_caps(struct drm_plane *plane) |
| 2106 | { |
| 2107 | struct sde_plane *psde = to_sde_plane(plane); |
| 2108 | const struct sde_format_extended *format_list; |
| 2109 | struct sde_kms_info *info; |
| 2110 | struct sde_hw_rot *rot_hw; |
| 2111 | const char *downscale_caps; |
| 2112 | |
| 2113 | if (!psde->catalog || !(psde->features & BIT(SDE_SSPP_SBUF)) || |
| 2114 | !psde->catalog->rot_count) |
| 2115 | return; |
| 2116 | |
| 2117 | if (psde->blob_rot_caps) |
| 2118 | return; |
| 2119 | |
| 2120 | info = kzalloc(sizeof(struct sde_kms_info), GFP_KERNEL); |
| 2121 | if (!info) |
| 2122 | return; |
| 2123 | |
| 2124 | rot_hw = sde_hw_rot_get(NULL); |
| 2125 | if (!rot_hw || !rot_hw->ops.get_format_caps || |
| 2126 | !rot_hw->ops.get_downscale_caps) { |
| 2127 | SDE_ERROR("invalid rotator hw\n"); |
| 2128 | goto error_rot; |
| 2129 | } |
| 2130 | |
| 2131 | sde_kms_info_reset(info); |
| 2132 | |
| 2133 | format_list = rot_hw->ops.get_format_caps(rot_hw); |
| 2134 | if (format_list) { |
| 2135 | sde_kms_info_start(info, "pixel_formats"); |
| 2136 | while (format_list->fourcc_format) { |
| 2137 | sde_kms_info_append_format(info, |
| 2138 | format_list->fourcc_format, |
| 2139 | format_list->modifier); |
| 2140 | ++format_list; |
| 2141 | } |
| 2142 | sde_kms_info_stop(info); |
| 2143 | } |
| 2144 | |
| 2145 | downscale_caps = rot_hw->ops.get_downscale_caps(rot_hw); |
| 2146 | if (downscale_caps) { |
| 2147 | sde_kms_info_start(info, "downscale_ratios"); |
| 2148 | sde_kms_info_append(info, downscale_caps); |
| 2149 | sde_kms_info_stop(info); |
| 2150 | } |
| 2151 | |
| 2152 | if (rot_hw->ops.get_cache_size) |
| 2153 | sde_kms_info_add_keyint(info, "cache_size", |
| 2154 | rot_hw->ops.get_cache_size(rot_hw)); |
| 2155 | |
Alan Kwong | 1a91580 | 2017-03-31 12:55:46 -0700 | [diff] [blame] | 2156 | if (rot_hw->ops.get_maxlinewidth) |
| 2157 | sde_kms_info_add_keyint(info, "max_linewidth", |
| 2158 | rot_hw->ops.get_maxlinewidth(rot_hw)); |
| 2159 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2160 | msm_property_set_blob(&psde->property_info, &psde->blob_rot_caps, |
| 2161 | info->data, info->len, PLANE_PROP_ROT_CAPS_V1); |
| 2162 | |
| 2163 | sde_hw_rot_put(rot_hw); |
| 2164 | error_rot: |
| 2165 | kfree(info); |
| 2166 | } |
| 2167 | |
| 2168 | /** |
| 2169 | * sde_plane_rot_install_properties - install plane rotator properties |
| 2170 | * @plane: Pointer to drm plane |
| 2171 | * @catalog: Pointer to mdss configuration |
| 2172 | * return: none |
| 2173 | */ |
| 2174 | static void sde_plane_rot_install_properties(struct drm_plane *plane, |
| 2175 | struct sde_mdss_cfg *catalog) |
| 2176 | { |
| 2177 | struct sde_plane *psde = to_sde_plane(plane); |
Alan Kwong | 709150c | 2017-04-03 08:44:31 -0700 | [diff] [blame] | 2178 | unsigned long supported_rotations = DRM_ROTATE_0 | DRM_REFLECT_X | |
| 2179 | DRM_REFLECT_Y; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2180 | |
| 2181 | if (!plane || !psde) { |
| 2182 | SDE_ERROR("invalid plane\n"); |
| 2183 | return; |
| 2184 | } else if (!catalog) { |
| 2185 | SDE_ERROR("invalid catalog\n"); |
| 2186 | return; |
| 2187 | } |
| 2188 | |
| 2189 | if ((psde->features & BIT(SDE_SSPP_SBUF)) && catalog->rot_count) |
| 2190 | supported_rotations |= DRM_ROTATE_0 | DRM_ROTATE_90 | |
| 2191 | DRM_ROTATE_180 | DRM_ROTATE_270; |
| 2192 | |
| 2193 | msm_property_install_rotation(&psde->property_info, |
| 2194 | supported_rotations, PLANE_PROP_ROTATION); |
| 2195 | |
| 2196 | if (!(psde->features & BIT(SDE_SSPP_SBUF)) || !catalog->rot_count) |
| 2197 | return; |
| 2198 | |
| 2199 | msm_property_install_range(&psde->property_info, "rot_dst_x", |
| 2200 | 0, 0, U64_MAX, 0, PLANE_PROP_ROT_DST_X); |
| 2201 | msm_property_install_range(&psde->property_info, "rot_dst_y", |
| 2202 | 0, 0, U64_MAX, 0, PLANE_PROP_ROT_DST_Y); |
| 2203 | msm_property_install_range(&psde->property_info, "rot_dst_w", |
| 2204 | 0, 0, U64_MAX, 0, PLANE_PROP_ROT_DST_W); |
| 2205 | msm_property_install_range(&psde->property_info, "rot_dst_h", |
| 2206 | 0, 0, U64_MAX, 0, PLANE_PROP_ROT_DST_H); |
| 2207 | msm_property_install_blob(&psde->property_info, "rot_caps_v1", |
| 2208 | DRM_MODE_PROP_IMMUTABLE, PLANE_PROP_ROT_CAPS_V1); |
| 2209 | } |
| 2210 | |
Jeykumar Sankaran | e964dc7 | 2017-05-10 19:26:43 -0700 | [diff] [blame^] | 2211 | void sde_plane_clear_multirect(const struct drm_plane_state *drm_state) |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 2212 | { |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 2213 | struct sde_plane_state *pstate; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 2214 | |
Jeykumar Sankaran | e964dc7 | 2017-05-10 19:26:43 -0700 | [diff] [blame^] | 2215 | if (!drm_state) |
| 2216 | return; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 2217 | |
Jeykumar Sankaran | e964dc7 | 2017-05-10 19:26:43 -0700 | [diff] [blame^] | 2218 | pstate = to_sde_plane_state(drm_state); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 2219 | |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 2220 | pstate->multirect_index = SDE_SSPP_RECT_SOLO; |
| 2221 | pstate->multirect_mode = SDE_SSPP_MULTIRECT_NONE; |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 2222 | } |
| 2223 | |
| 2224 | int sde_plane_validate_multirect_v2(struct sde_multirect_plane_states *plane) |
| 2225 | { |
| 2226 | struct sde_plane_state *pstate[R_MAX]; |
| 2227 | const struct drm_plane_state *drm_state[R_MAX]; |
| 2228 | struct sde_rect src[R_MAX], dst[R_MAX]; |
| 2229 | struct sde_plane *sde_plane[R_MAX]; |
| 2230 | const struct sde_format *fmt[R_MAX]; |
| 2231 | bool q16_data = true; |
Jeykumar Sankaran | e964dc7 | 2017-05-10 19:26:43 -0700 | [diff] [blame^] | 2232 | int i, buffer_lines = TX_MODE_BUFFER_LINE_THRES; |
| 2233 | bool parallel_fetch_qualified = true; |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 2234 | |
| 2235 | for (i = 0; i < R_MAX; i++) { |
| 2236 | const struct msm_format *msm_fmt; |
Jeykumar Sankaran | e964dc7 | 2017-05-10 19:26:43 -0700 | [diff] [blame^] | 2237 | int width_threshold; |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 2238 | |
| 2239 | drm_state[i] = i ? plane->r1 : plane->r0; |
| 2240 | pstate[i] = to_sde_plane_state(drm_state[i]); |
| 2241 | sde_plane[i] = to_sde_plane(drm_state[i]->plane); |
| 2242 | |
| 2243 | if (pstate[i] == NULL) { |
| 2244 | SDE_ERROR("SDE plane state of plane id %d is NULL\n", |
| 2245 | drm_state[i]->plane->base.id); |
| 2246 | return -EINVAL; |
| 2247 | } |
| 2248 | |
| 2249 | POPULATE_RECT(&src[i], drm_state[i]->src_x, drm_state[i]->src_y, |
| 2250 | drm_state[i]->src_w, drm_state[i]->src_h, q16_data); |
| 2251 | POPULATE_RECT(&dst[i], drm_state[i]->crtc_x, |
| 2252 | drm_state[i]->crtc_y, drm_state[i]->crtc_w, |
| 2253 | drm_state[i]->crtc_h, !q16_data); |
| 2254 | |
| 2255 | if (src[i].w != dst[i].w || src[i].h != dst[i].h) { |
| 2256 | SDE_ERROR_PLANE(sde_plane[i], |
| 2257 | "scaling is not supported in multirect mode\n"); |
| 2258 | return -EINVAL; |
| 2259 | } |
| 2260 | |
| 2261 | msm_fmt = msm_framebuffer_format(drm_state[i]->fb); |
| 2262 | fmt[i] = to_sde_format(msm_fmt); |
| 2263 | if (SDE_FORMAT_IS_YUV(fmt[i])) { |
| 2264 | SDE_ERROR_PLANE(sde_plane[i], |
| 2265 | "Unsupported format for multirect mode\n"); |
| 2266 | return -EINVAL; |
| 2267 | } |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 2268 | |
Jeykumar Sankaran | e964dc7 | 2017-05-10 19:26:43 -0700 | [diff] [blame^] | 2269 | /** |
| 2270 | * SSPP PD_MEM is split half - one for each RECT. |
| 2271 | * Tiled formats need 5 lines of buffering while fetching |
| 2272 | * whereas linear formats need only 2 lines. |
| 2273 | * So we cannot support more than half of the supported SSPP |
| 2274 | * width for tiled formats. |
| 2275 | */ |
| 2276 | width_threshold = sde_plane[i]->pipe_sblk->maxlinewidth; |
| 2277 | if (SDE_FORMAT_IS_UBWC(fmt[i])) |
| 2278 | width_threshold /= 2; |
| 2279 | |
| 2280 | if (parallel_fetch_qualified && src[i].w > width_threshold) |
| 2281 | parallel_fetch_qualified = false; |
| 2282 | |
| 2283 | } |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 2284 | |
| 2285 | /* Validate RECT's and set the mode */ |
| 2286 | |
| 2287 | /* Prefer PARALLEL FETCH Mode over TIME_MX Mode */ |
Jeykumar Sankaran | e964dc7 | 2017-05-10 19:26:43 -0700 | [diff] [blame^] | 2288 | if (parallel_fetch_qualified) { |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 2289 | if (dst[R0].x <= dst[R1].x) { |
| 2290 | pstate[R0]->multirect_index = SDE_SSPP_RECT_0; |
| 2291 | pstate[R1]->multirect_index = SDE_SSPP_RECT_1; |
| 2292 | } else { |
| 2293 | pstate[R0]->multirect_index = SDE_SSPP_RECT_1; |
| 2294 | pstate[R1]->multirect_index = SDE_SSPP_RECT_0; |
| 2295 | } |
| 2296 | |
| 2297 | pstate[R0]->multirect_mode = SDE_SSPP_MULTIRECT_PARALLEL; |
| 2298 | pstate[R1]->multirect_mode = SDE_SSPP_MULTIRECT_PARALLEL; |
| 2299 | goto done; |
| 2300 | } |
| 2301 | |
| 2302 | /* TIME_MX Mode */ |
| 2303 | if (SDE_FORMAT_IS_UBWC(fmt[R0])) |
| 2304 | buffer_lines = 2 * fmt[R0]->tile_height; |
| 2305 | |
| 2306 | if (dst[R1].y >= dst[R0].y + dst[R0].h + buffer_lines) { |
| 2307 | pstate[R0]->multirect_index = SDE_SSPP_RECT_0; |
| 2308 | pstate[R1]->multirect_index = SDE_SSPP_RECT_1; |
| 2309 | } else if (dst[R0].y >= dst[R1].y + dst[R1].h + buffer_lines) { |
| 2310 | pstate[R0]->multirect_index = SDE_SSPP_RECT_1; |
| 2311 | pstate[R1]->multirect_index = SDE_SSPP_RECT_0; |
| 2312 | } else { |
| 2313 | SDE_ERROR( |
| 2314 | "No multirect mode possible for the planes (%d - %d)\n", |
| 2315 | drm_state[R0]->plane->base.id, |
| 2316 | drm_state[R1]->plane->base.id); |
| 2317 | return -EINVAL; |
| 2318 | } |
| 2319 | |
| 2320 | pstate[R0]->multirect_mode = SDE_SSPP_MULTIRECT_TIME_MX; |
| 2321 | pstate[R1]->multirect_mode = SDE_SSPP_MULTIRECT_TIME_MX; |
| 2322 | done: |
Jeykumar Sankaran | e964dc7 | 2017-05-10 19:26:43 -0700 | [diff] [blame^] | 2323 | SDE_DEBUG_PLANE(sde_plane[R0], "R0: %d - %d\n", |
| 2324 | pstate[R0]->multirect_mode, pstate[R0]->multirect_index); |
| 2325 | SDE_DEBUG_PLANE(sde_plane[R1], "R1: %d - %d\n", |
| 2326 | pstate[R1]->multirect_mode, pstate[R1]->multirect_index); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 2327 | return 0; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2328 | } |
| 2329 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2330 | /** |
| 2331 | * sde_plane_get_ctl_flush - get control flush for the given plane |
| 2332 | * @plane: Pointer to drm plane structure |
| 2333 | * @ctl: Pointer to hardware control driver |
| 2334 | * @flush: Pointer to flush control word |
| 2335 | */ |
| 2336 | void sde_plane_get_ctl_flush(struct drm_plane *plane, struct sde_hw_ctl *ctl, |
| 2337 | u32 *flush) |
| 2338 | { |
| 2339 | struct sde_plane_state *pstate; |
| 2340 | struct sde_plane_rot_state *rstate; |
| 2341 | u32 bitmask; |
| 2342 | |
| 2343 | if (!plane || !flush) { |
| 2344 | SDE_ERROR("invalid parameters\n"); |
| 2345 | return; |
| 2346 | } |
| 2347 | |
| 2348 | pstate = to_sde_plane_state(plane->state); |
| 2349 | rstate = &pstate->rot; |
| 2350 | |
| 2351 | bitmask = ctl->ops.get_bitmask_sspp(ctl, sde_plane_pipe(plane)); |
| 2352 | |
| 2353 | if (sde_plane_is_sbuf_mode(plane, NULL) && rstate->rot_hw && |
| 2354 | ctl->ops.get_bitmask_rot) |
| 2355 | ctl->ops.get_bitmask_rot(ctl, &bitmask, rstate->rot_hw->idx); |
| 2356 | |
| 2357 | *flush = bitmask; |
| 2358 | } |
| 2359 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2360 | static int sde_plane_prepare_fb(struct drm_plane *plane, |
Dhaval Patel | 04c7e8e | 2016-09-26 20:14:31 -0700 | [diff] [blame] | 2361 | struct drm_plane_state *new_state) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2362 | { |
| 2363 | struct drm_framebuffer *fb = new_state->fb; |
| 2364 | struct sde_plane *psde = to_sde_plane(plane); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2365 | struct sde_plane_rot_state *new_rstate; |
| 2366 | int ret; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2367 | |
| 2368 | if (!new_state->fb) |
| 2369 | return 0; |
| 2370 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2371 | SDE_DEBUG_PLANE(psde, "FB[%u]\n", fb->base.id); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2372 | |
| 2373 | ret = sde_plane_rot_prepare_fb(plane, new_state); |
| 2374 | if (ret) { |
| 2375 | SDE_ERROR("failed to prepare rot framebuffer\n"); |
| 2376 | return ret; |
| 2377 | } |
| 2378 | |
| 2379 | new_rstate = &to_sde_plane_state(new_state)->rot; |
| 2380 | |
| 2381 | ret = msm_framebuffer_prepare(new_rstate->out_fb, new_rstate->mmu_id); |
| 2382 | if (ret) { |
| 2383 | SDE_ERROR("failed to prepare framebuffer\n"); |
| 2384 | return ret; |
| 2385 | } |
| 2386 | |
| 2387 | return 0; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2388 | } |
| 2389 | |
| 2390 | static void sde_plane_cleanup_fb(struct drm_plane *plane, |
Dhaval Patel | 04c7e8e | 2016-09-26 20:14:31 -0700 | [diff] [blame] | 2391 | struct drm_plane_state *old_state) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2392 | { |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2393 | struct sde_plane *psde = to_sde_plane(plane); |
| 2394 | struct sde_plane_rot_state *old_rstate; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2395 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2396 | if (!old_state->fb) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2397 | return; |
| 2398 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2399 | SDE_DEBUG_PLANE(psde, "FB[%u]\n", old_state->fb->base.id); |
| 2400 | |
| 2401 | old_rstate = &to_sde_plane_state(old_state)->rot; |
| 2402 | |
| 2403 | msm_framebuffer_cleanup(old_rstate->out_fb, old_rstate->mmu_id); |
| 2404 | |
| 2405 | sde_plane_rot_cleanup_fb(plane, old_state); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2406 | } |
| 2407 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2408 | static void _sde_plane_sspp_atomic_check_mode_changed(struct sde_plane *psde, |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 2409 | struct drm_plane_state *state, |
| 2410 | struct drm_plane_state *old_state) |
| 2411 | { |
| 2412 | struct sde_plane_state *pstate = to_sde_plane_state(state); |
Veera Sundaram Sankaran | 02dd6ac | 2016-12-22 15:08:29 -0800 | [diff] [blame] | 2413 | struct sde_plane_state *old_pstate = to_sde_plane_state(old_state); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2414 | struct sde_plane_rot_state *rstate = &pstate->rot; |
| 2415 | struct sde_plane_rot_state *old_rstate = &old_pstate->rot; |
| 2416 | struct drm_framebuffer *fb, *old_fb; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 2417 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2418 | /* no need to check it again */ |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 2419 | if (pstate->dirty == SDE_PLANE_DIRTY_ALL) |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2420 | return; |
| 2421 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 2422 | if (!sde_plane_enabled(state) || !sde_plane_enabled(old_state) |
| 2423 | || psde->is_error) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2424 | SDE_DEBUG_PLANE(psde, |
| 2425 | "enabling/disabling full modeset required\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 2426 | pstate->dirty |= SDE_PLANE_DIRTY_ALL; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 2427 | } else if (to_sde_plane_state(old_state)->pending) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2428 | SDE_DEBUG_PLANE(psde, "still pending\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 2429 | pstate->dirty |= SDE_PLANE_DIRTY_ALL; |
Jeykumar Sankaran | e964dc7 | 2017-05-10 19:26:43 -0700 | [diff] [blame^] | 2430 | } else if (pstate->multirect_index != old_pstate->multirect_index || |
| 2431 | pstate->multirect_mode != old_pstate->multirect_mode) { |
| 2432 | SDE_DEBUG_PLANE(psde, "multirect config updated\n"); |
| 2433 | pstate->dirty |= SDE_PLANE_DIRTY_ALL; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2434 | } else if (rstate->out_src_w != old_rstate->out_src_w || |
| 2435 | rstate->out_src_h != old_rstate->out_src_h || |
| 2436 | rstate->out_src_x != old_rstate->out_src_x || |
| 2437 | rstate->out_src_y != old_rstate->out_src_y) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2438 | SDE_DEBUG_PLANE(psde, "src rect updated\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 2439 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2440 | } else if (state->crtc_w != old_state->crtc_w || |
| 2441 | state->crtc_h != old_state->crtc_h || |
| 2442 | state->crtc_x != old_state->crtc_x || |
| 2443 | state->crtc_y != old_state->crtc_y) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2444 | SDE_DEBUG_PLANE(psde, "crtc rect updated\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 2445 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
Veera Sundaram Sankaran | 02dd6ac | 2016-12-22 15:08:29 -0800 | [diff] [blame] | 2446 | } else if (pstate->excl_rect.w != old_pstate->excl_rect.w || |
| 2447 | pstate->excl_rect.h != old_pstate->excl_rect.h || |
| 2448 | pstate->excl_rect.x != old_pstate->excl_rect.x || |
| 2449 | pstate->excl_rect.y != old_pstate->excl_rect.y) { |
| 2450 | SDE_DEBUG_PLANE(psde, "excl rect updated\n"); |
| 2451 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 2452 | } |
| 2453 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2454 | fb = rstate->out_fb; |
| 2455 | old_fb = old_rstate->out_fb; |
| 2456 | |
| 2457 | if (!fb || !old_fb) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2458 | SDE_DEBUG_PLANE(psde, "can't compare fb handles\n"); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2459 | } else if (fb->pixel_format != old_fb->pixel_format) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2460 | SDE_DEBUG_PLANE(psde, "format change\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 2461 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT | SDE_PLANE_DIRTY_RECTS; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2462 | } else { |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2463 | uint64_t *new_mods = fb->modifier; |
| 2464 | uint64_t *old_mods = old_fb->modifier; |
| 2465 | uint32_t *new_pitches = fb->pitches; |
| 2466 | uint32_t *old_pitches = old_fb->pitches; |
| 2467 | uint32_t *new_offset = fb->offsets; |
| 2468 | uint32_t *old_offset = old_fb->offsets; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 2469 | int i; |
| 2470 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2471 | for (i = 0; i < ARRAY_SIZE(fb->modifier); i++) { |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 2472 | if (new_mods[i] != old_mods[i]) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2473 | SDE_DEBUG_PLANE(psde, |
| 2474 | "format modifiers change\"\ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2475 | plane:%d new_mode:%llu old_mode:%llu\n", |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2476 | i, new_mods[i], old_mods[i]); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 2477 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT | |
| 2478 | SDE_PLANE_DIRTY_RECTS; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 2479 | break; |
| 2480 | } |
| 2481 | } |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2482 | for (i = 0; i < ARRAY_SIZE(fb->pitches); i++) { |
Lloyd Atkinson | 3ab9ef7 | 2016-07-14 17:42:41 -0400 | [diff] [blame] | 2483 | if (new_pitches[i] != old_pitches[i]) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2484 | SDE_DEBUG_PLANE(psde, |
| 2485 | "pitches change plane:%d\"\ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2486 | old_pitches:%u new_pitches:%u\n", |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2487 | i, old_pitches[i], new_pitches[i]); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 2488 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
Lloyd Atkinson | 3ab9ef7 | 2016-07-14 17:42:41 -0400 | [diff] [blame] | 2489 | break; |
| 2490 | } |
| 2491 | } |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2492 | for (i = 0; i < ARRAY_SIZE(fb->offsets); i++) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2493 | if (new_offset[i] != old_offset[i]) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2494 | SDE_DEBUG_PLANE(psde, |
| 2495 | "offset change plane:%d\"\ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2496 | old_offset:%u new_offset:%u\n", |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2497 | i, old_offset[i], new_offset[i]); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 2498 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT | |
| 2499 | SDE_PLANE_DIRTY_RECTS; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2500 | break; |
| 2501 | } |
| 2502 | } |
Lloyd Atkinson | 3ab9ef7 | 2016-07-14 17:42:41 -0400 | [diff] [blame] | 2503 | } |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 2504 | } |
| 2505 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2506 | static int sde_plane_sspp_atomic_check(struct drm_plane *plane, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2507 | struct drm_plane_state *state) |
| 2508 | { |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 2509 | int ret = 0; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2510 | struct sde_plane *psde; |
| 2511 | struct sde_plane_state *pstate; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2512 | struct sde_plane_rot_state *rstate; |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 2513 | const struct sde_format *fmt; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2514 | struct sde_rect src, dst; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2515 | uint32_t deci_w, deci_h, src_deci_w, src_deci_h; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2516 | uint32_t max_upscale, max_downscale, min_src_size, max_linewidth; |
| 2517 | bool q16_data = true; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2518 | |
| 2519 | if (!plane || !state) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2520 | SDE_ERROR("invalid arg(s), plane %d state %d\n", |
| 2521 | plane != 0, state != 0); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2522 | ret = -EINVAL; |
| 2523 | goto exit; |
| 2524 | } |
| 2525 | |
| 2526 | psde = to_sde_plane(plane); |
| 2527 | pstate = to_sde_plane_state(state); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2528 | rstate = &pstate->rot; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2529 | |
| 2530 | if (!psde->pipe_sblk) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2531 | SDE_ERROR_PLANE(psde, "invalid catalog\n"); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2532 | ret = -EINVAL; |
| 2533 | goto exit; |
| 2534 | } |
| 2535 | |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 2536 | deci_w = sde_plane_get_property(pstate, PLANE_PROP_H_DECIMATE); |
| 2537 | deci_h = sde_plane_get_property(pstate, PLANE_PROP_V_DECIMATE); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2538 | |
| 2539 | /* src values are in Q16 fixed point, convert to integer */ |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2540 | POPULATE_RECT(&src, rstate->out_src_x, rstate->out_src_y, |
| 2541 | rstate->out_src_w, rstate->out_src_h, q16_data); |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2542 | POPULATE_RECT(&dst, state->crtc_x, state->crtc_y, state->crtc_w, |
| 2543 | state->crtc_h, !q16_data); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2544 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2545 | src_deci_w = DECIMATED_DIMENSION(src.w, deci_w); |
| 2546 | src_deci_h = DECIMATED_DIMENSION(src.h, deci_h); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2547 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2548 | max_upscale = psde->pipe_sblk->maxupscale; |
| 2549 | max_downscale = psde->pipe_sblk->maxdwnscale; |
| 2550 | max_linewidth = psde->pipe_sblk->maxlinewidth; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2551 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2552 | SDE_DEBUG_PLANE(psde, "check %d -> %d\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2553 | sde_plane_enabled(plane->state), sde_plane_enabled(state)); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2554 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2555 | if (!sde_plane_enabled(state)) |
| 2556 | goto modeset_update; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2557 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2558 | SDE_DEBUG( |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 2559 | "plane%d.%u sspp:%x/%dx%d/%4.4s/%llx/%dx%d+%d+%d crtc:%dx%d+%d+%d\n", |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2560 | plane->base.id, rstate->sequence_id, |
| 2561 | rstate->out_rotation, |
| 2562 | rstate->out_fb_width, rstate->out_fb_height, |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 2563 | (char *) &rstate->out_fb_pixel_format, |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2564 | rstate->out_fb_modifier[0], |
| 2565 | rstate->out_src_w >> 16, rstate->out_src_h >> 16, |
| 2566 | rstate->out_src_x >> 16, rstate->out_src_y >> 16, |
| 2567 | state->crtc_w, state->crtc_h, |
| 2568 | state->crtc_x, state->crtc_y); |
| 2569 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2570 | fmt = to_sde_format(msm_framebuffer_format(state->fb)); |
| 2571 | |
| 2572 | min_src_size = SDE_FORMAT_IS_YUV(fmt) ? 2 : 1; |
| 2573 | |
| 2574 | if (SDE_FORMAT_IS_YUV(fmt) && |
| 2575 | (!(psde->features & SDE_SSPP_SCALER) || |
abeykun | 1c312f6 | 2016-08-26 09:47:12 -0400 | [diff] [blame] | 2576 | !(psde->features & (BIT(SDE_SSPP_CSC) |
| 2577 | | BIT(SDE_SSPP_CSC_10BIT))))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2578 | SDE_ERROR_PLANE(psde, |
| 2579 | "plane doesn't have scaler/csc for yuv\n"); |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2580 | ret = -EINVAL; |
| 2581 | |
| 2582 | /* check src bounds */ |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2583 | } else if (rstate->out_fb_width > MAX_IMG_WIDTH || |
| 2584 | rstate->out_fb_height > MAX_IMG_HEIGHT || |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2585 | src.w < min_src_size || src.h < min_src_size || |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2586 | CHECK_LAYER_BOUNDS(src.x, src.w, rstate->out_fb_width) || |
| 2587 | CHECK_LAYER_BOUNDS(src.y, src.h, rstate->out_fb_height)) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2588 | SDE_ERROR_PLANE(psde, "invalid source %u, %u, %ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2589 | src.x, src.y, src.w, src.h); |
| 2590 | ret = -E2BIG; |
| 2591 | |
| 2592 | /* valid yuv image */ |
| 2593 | } else if (SDE_FORMAT_IS_YUV(fmt) && ((src.x & 0x1) || (src.y & 0x1) || |
| 2594 | (src.w & 0x1) || (src.h & 0x1))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2595 | SDE_ERROR_PLANE(psde, "invalid yuv source %u, %u, %ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2596 | src.x, src.y, src.w, src.h); |
| 2597 | ret = -EINVAL; |
| 2598 | |
| 2599 | /* min dst support */ |
| 2600 | } else if (dst.w < 0x1 || dst.h < 0x1) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2601 | SDE_ERROR_PLANE(psde, "invalid dest rect %u, %u, %ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2602 | dst.x, dst.y, dst.w, dst.h); |
| 2603 | ret = -EINVAL; |
| 2604 | |
| 2605 | /* decimation validation */ |
| 2606 | } else if (deci_w || deci_h) { |
| 2607 | if ((deci_w > psde->pipe_sblk->maxhdeciexp) || |
| 2608 | (deci_h > psde->pipe_sblk->maxvdeciexp)) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2609 | SDE_ERROR_PLANE(psde, |
| 2610 | "too much decimation requested\n"); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2611 | ret = -EINVAL; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2612 | } else if (fmt->fetch_mode != SDE_FETCH_LINEAR) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2613 | SDE_ERROR_PLANE(psde, |
| 2614 | "decimation requires linear fetch\n"); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2615 | ret = -EINVAL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2616 | } |
| 2617 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2618 | } else if (!(psde->features & SDE_SSPP_SCALER) && |
| 2619 | ((src.w != dst.w) || (src.h != dst.h))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2620 | SDE_ERROR_PLANE(psde, |
| 2621 | "pipe doesn't support scaling %ux%u->%ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2622 | src.w, src.h, dst.w, dst.h); |
| 2623 | ret = -EINVAL; |
| 2624 | |
| 2625 | /* check decimated source width */ |
| 2626 | } else if (src_deci_w > max_linewidth) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2627 | SDE_ERROR_PLANE(psde, |
| 2628 | "invalid src w:%u, deci w:%u, line w:%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2629 | src.w, src_deci_w, max_linewidth); |
| 2630 | ret = -E2BIG; |
| 2631 | |
| 2632 | /* check max scaler capability */ |
| 2633 | } else if (((src_deci_w * max_upscale) < dst.w) || |
| 2634 | ((src_deci_h * max_upscale) < dst.h) || |
| 2635 | ((dst.w * max_downscale) < src_deci_w) || |
| 2636 | ((dst.h * max_downscale) < src_deci_h)) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2637 | SDE_ERROR_PLANE(psde, |
| 2638 | "too much scaling requested %ux%u->%ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2639 | src_deci_w, src_deci_h, dst.w, dst.h); |
| 2640 | ret = -E2BIG; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 2641 | } |
| 2642 | |
Veera Sundaram Sankaran | 02dd6ac | 2016-12-22 15:08:29 -0800 | [diff] [blame] | 2643 | /* check excl rect configs */ |
| 2644 | if (pstate->excl_rect.w && pstate->excl_rect.h) { |
| 2645 | struct sde_rect intersect; |
| 2646 | |
| 2647 | /* |
| 2648 | * Check exclusion rect against src rect. |
Dhaval Patel | a8d6bc6 | 2017-05-10 17:40:18 -0700 | [diff] [blame] | 2649 | * it must intersect with source rect. |
Veera Sundaram Sankaran | 02dd6ac | 2016-12-22 15:08:29 -0800 | [diff] [blame] | 2650 | */ |
Lloyd Atkinson | e0e11e2 | 2017-01-17 12:08:48 -0500 | [diff] [blame] | 2651 | sde_kms_rect_intersect(&src, &pstate->excl_rect, &intersect); |
Dhaval Patel | a8d6bc6 | 2017-05-10 17:40:18 -0700 | [diff] [blame] | 2652 | if (intersect.w != pstate->excl_rect.w || |
| 2653 | intersect.h != pstate->excl_rect.h || |
| 2654 | SDE_FORMAT_IS_YUV(fmt)) { |
Veera Sundaram Sankaran | 02dd6ac | 2016-12-22 15:08:29 -0800 | [diff] [blame] | 2655 | SDE_ERROR_PLANE(psde, |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 2656 | "invalid excl_rect:{%d,%d,%d,%d} src:{%d,%d,%d,%d}, fmt: %4.4s\n", |
Veera Sundaram Sankaran | 02dd6ac | 2016-12-22 15:08:29 -0800 | [diff] [blame] | 2657 | pstate->excl_rect.x, pstate->excl_rect.y, |
| 2658 | pstate->excl_rect.w, pstate->excl_rect.h, |
| 2659 | src.x, src.y, src.w, src.h, |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 2660 | (char *)&fmt->base.pixel_format); |
Veera Sundaram Sankaran | 02dd6ac | 2016-12-22 15:08:29 -0800 | [diff] [blame] | 2661 | ret = -EINVAL; |
| 2662 | } |
| 2663 | } |
| 2664 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 2665 | modeset_update: |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 2666 | if (!ret) |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 2667 | _sde_plane_sspp_atomic_check_mode_changed(psde, |
| 2668 | state, plane->state); |
| 2669 | exit: |
| 2670 | return ret; |
| 2671 | } |
| 2672 | |
| 2673 | static int sde_plane_atomic_check(struct drm_plane *plane, |
| 2674 | struct drm_plane_state *state) |
| 2675 | { |
| 2676 | int ret = 0; |
| 2677 | struct sde_plane *psde; |
| 2678 | struct sde_plane_state *pstate; |
| 2679 | |
| 2680 | if (!plane || !state) { |
| 2681 | SDE_ERROR("invalid arg(s), plane %d state %d\n", |
| 2682 | plane != 0, state != 0); |
| 2683 | ret = -EINVAL; |
| 2684 | goto exit; |
| 2685 | } |
| 2686 | |
| 2687 | psde = to_sde_plane(plane); |
| 2688 | pstate = to_sde_plane_state(state); |
| 2689 | |
| 2690 | SDE_DEBUG_PLANE(psde, "\n"); |
| 2691 | |
| 2692 | ret = sde_plane_rot_atomic_check(plane, state); |
| 2693 | if (ret) |
| 2694 | goto exit; |
| 2695 | |
| 2696 | ret = sde_plane_sspp_atomic_check(plane, state); |
| 2697 | |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2698 | exit: |
| 2699 | return ret; |
| 2700 | } |
| 2701 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 2702 | /** |
| 2703 | * sde_plane_flush - final plane operations before commit flush |
| 2704 | * @plane: Pointer to drm plane structure |
| 2705 | */ |
| 2706 | void sde_plane_flush(struct drm_plane *plane) |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2707 | { |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 2708 | struct sde_plane *psde; |
| 2709 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2710 | if (!plane) { |
| 2711 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 2712 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2713 | } |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 2714 | |
| 2715 | psde = to_sde_plane(plane); |
| 2716 | |
| 2717 | /* |
| 2718 | * These updates have to be done immediately before the plane flush |
| 2719 | * timing, and may not be moved to the atomic_update/mode_set functions. |
| 2720 | */ |
| 2721 | if (psde->is_error) |
Clarence Ip | 3bf8d87 | 2017-02-16 15:25:38 -0500 | [diff] [blame] | 2722 | /* force white frame with 100% alpha pipe output on error */ |
| 2723 | _sde_plane_color_fill(psde, 0xFFFFFF, 0xFF); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 2724 | else if (psde->color_fill & SDE_PLANE_COLOR_FILL_FLAG) |
| 2725 | /* force 100% alpha */ |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 2726 | _sde_plane_color_fill(psde, psde->color_fill, 0xFF); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 2727 | else if (psde->pipe_hw && psde->csc_ptr && psde->pipe_hw->ops.setup_csc) |
| 2728 | psde->pipe_hw->ops.setup_csc(psde->pipe_hw, psde->csc_ptr); |
| 2729 | |
Clarence Ip | 5690279 | 2017-03-17 15:22:07 -0400 | [diff] [blame] | 2730 | /* force black color fill during suspend */ |
| 2731 | if (msm_is_suspend_state(plane->dev) && suspend_blank) |
| 2732 | _sde_plane_color_fill(psde, 0x0, 0x0); |
| 2733 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 2734 | /* flag h/w flush complete */ |
| 2735 | if (plane->state) |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 2736 | to_sde_plane_state(plane->state)->pending = false; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2737 | } |
| 2738 | |
Jeykumar Sankaran | e964dc7 | 2017-05-10 19:26:43 -0700 | [diff] [blame^] | 2739 | static int sde_plane_sspp_atomic_update(struct drm_plane *plane, |
| 2740 | struct drm_plane_state *old_state) |
| 2741 | { |
| 2742 | uint32_t nplanes, src_flags; |
| 2743 | struct sde_plane *psde; |
| 2744 | struct drm_plane_state *state; |
| 2745 | struct sde_plane_state *pstate; |
| 2746 | struct sde_plane_state *old_pstate; |
| 2747 | struct sde_plane_rot_state *rstate; |
| 2748 | const struct sde_format *fmt; |
| 2749 | struct drm_crtc *crtc; |
| 2750 | struct drm_framebuffer *fb; |
| 2751 | struct sde_rect src, dst; |
| 2752 | const struct sde_rect *crtc_roi; |
| 2753 | bool q16_data = true; |
| 2754 | int idx; |
| 2755 | |
| 2756 | if (!plane) { |
| 2757 | SDE_ERROR("invalid plane\n"); |
| 2758 | return -EINVAL; |
| 2759 | } else if (!plane->state) { |
| 2760 | SDE_ERROR("invalid plane state\n"); |
| 2761 | return -EINVAL; |
| 2762 | } else if (!old_state) { |
| 2763 | SDE_ERROR("invalid old state\n"); |
| 2764 | return -EINVAL; |
| 2765 | } |
| 2766 | |
| 2767 | psde = to_sde_plane(plane); |
| 2768 | state = plane->state; |
| 2769 | |
| 2770 | pstate = to_sde_plane_state(state); |
| 2771 | rstate = &pstate->rot; |
| 2772 | |
| 2773 | old_pstate = to_sde_plane_state(old_state); |
| 2774 | |
| 2775 | crtc = state->crtc; |
| 2776 | fb = rstate->out_fb; |
| 2777 | if (!crtc || !fb) { |
| 2778 | SDE_ERROR_PLANE(psde, "invalid crtc %d or fb %d\n", |
| 2779 | crtc != 0, fb != 0); |
| 2780 | return -EINVAL; |
| 2781 | } |
| 2782 | fmt = to_sde_format(msm_framebuffer_format(fb)); |
| 2783 | nplanes = fmt->num_planes; |
| 2784 | |
| 2785 | SDE_DEBUG( |
| 2786 | "plane%d.%d sspp:%dx%d/%4.4s/%llx/%dx%d+%d+%d/%x crtc:%dx%d+%d+%d\n", |
| 2787 | plane->base.id, rstate->sequence_id, |
| 2788 | rstate->out_fb_width, rstate->out_fb_height, |
| 2789 | (char *) &rstate->out_fb_pixel_format, |
| 2790 | rstate->out_fb_modifier[0], |
| 2791 | rstate->out_src_w >> 16, rstate->out_src_h >> 16, |
| 2792 | rstate->out_src_x >> 16, rstate->out_src_y >> 16, |
| 2793 | rstate->out_rotation, |
| 2794 | state->crtc_w, state->crtc_h, |
| 2795 | state->crtc_x, state->crtc_y); |
| 2796 | |
| 2797 | /* force reprogramming of all the parameters, if the flag is set */ |
| 2798 | if (psde->revalidate) { |
| 2799 | SDE_DEBUG("plane:%d - reconfigure all the parameters\n", |
| 2800 | plane->base.id); |
| 2801 | pstate->dirty = SDE_PLANE_DIRTY_ALL; |
| 2802 | psde->revalidate = false; |
| 2803 | } |
| 2804 | |
| 2805 | /* determine what needs to be refreshed */ |
| 2806 | while ((idx = msm_property_pop_dirty(&psde->property_info)) >= 0) { |
| 2807 | switch (idx) { |
| 2808 | case PLANE_PROP_SCALER_V1: |
| 2809 | case PLANE_PROP_SCALER_V2: |
| 2810 | case PLANE_PROP_H_DECIMATE: |
| 2811 | case PLANE_PROP_V_DECIMATE: |
| 2812 | case PLANE_PROP_SRC_CONFIG: |
| 2813 | case PLANE_PROP_ZPOS: |
| 2814 | case PLANE_PROP_EXCL_RECT_V1: |
| 2815 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
| 2816 | break; |
| 2817 | case PLANE_PROP_CSC_V1: |
| 2818 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT; |
| 2819 | break; |
| 2820 | case PLANE_PROP_COLOR_FILL: |
| 2821 | /* potentially need to refresh everything */ |
| 2822 | pstate->dirty = SDE_PLANE_DIRTY_ALL; |
| 2823 | break; |
| 2824 | case PLANE_PROP_ROTATION: |
| 2825 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT; |
| 2826 | break; |
| 2827 | case PLANE_PROP_INFO: |
| 2828 | case PLANE_PROP_ALPHA: |
| 2829 | case PLANE_PROP_INPUT_FENCE: |
| 2830 | case PLANE_PROP_BLEND_OP: |
| 2831 | /* no special action required */ |
| 2832 | break; |
| 2833 | case PLANE_PROP_ROT_DST_X: |
| 2834 | case PLANE_PROP_ROT_DST_Y: |
| 2835 | case PLANE_PROP_ROT_DST_W: |
| 2836 | case PLANE_PROP_ROT_DST_H: |
| 2837 | /* handled by rotator atomic update */ |
| 2838 | break; |
| 2839 | default: |
| 2840 | /* unknown property, refresh everything */ |
| 2841 | pstate->dirty |= SDE_PLANE_DIRTY_ALL; |
| 2842 | SDE_ERROR("executing full mode set, prp_idx %d\n", idx); |
| 2843 | break; |
| 2844 | } |
| 2845 | } |
| 2846 | |
| 2847 | /** |
| 2848 | * since plane_atomic_check is invoked before crtc_atomic_check |
| 2849 | * in the commit sequence, all the parameters for updating the |
| 2850 | * plane dirty flag will not be available during |
| 2851 | * plane_atomic_check as some features params are updated |
| 2852 | * in crtc_atomic_check (eg.:sDMA). So check for mode_change |
| 2853 | * before sspp update. |
| 2854 | */ |
| 2855 | _sde_plane_sspp_atomic_check_mode_changed(psde, state, |
| 2856 | old_state); |
| 2857 | |
| 2858 | /* re-program the output rects always in the case of partial update */ |
| 2859 | sde_crtc_get_crtc_roi(crtc->state, &crtc_roi); |
| 2860 | if (!sde_kms_rect_is_null(crtc_roi)) |
| 2861 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
| 2862 | |
| 2863 | if (pstate->dirty & SDE_PLANE_DIRTY_RECTS) |
| 2864 | memset(&(psde->pipe_cfg), 0, sizeof(struct sde_hw_pipe_cfg)); |
| 2865 | |
| 2866 | _sde_plane_set_scanout(plane, pstate, &psde->pipe_cfg, fb); |
| 2867 | |
| 2868 | /* early out if nothing dirty */ |
| 2869 | if (!pstate->dirty) |
| 2870 | return 0; |
| 2871 | pstate->pending = true; |
| 2872 | |
| 2873 | psde->is_rt_pipe = (sde_crtc_get_client_type(crtc) != NRT_CLIENT); |
| 2874 | _sde_plane_set_qos_ctrl(plane, false, SDE_PLANE_QOS_PANIC_CTRL); |
| 2875 | |
| 2876 | /* update roi config */ |
| 2877 | if (pstate->dirty & SDE_PLANE_DIRTY_RECTS) { |
| 2878 | POPULATE_RECT(&src, rstate->out_src_x, rstate->out_src_y, |
| 2879 | rstate->out_src_w, rstate->out_src_h, q16_data); |
| 2880 | POPULATE_RECT(&dst, state->crtc_x, state->crtc_y, |
| 2881 | state->crtc_w, state->crtc_h, !q16_data); |
| 2882 | |
| 2883 | SDE_DEBUG_PLANE(psde, |
| 2884 | "FB[%u] %u,%u,%ux%u->crtc%u %d,%d,%ux%u, %4.4s ubwc %d\n", |
| 2885 | fb->base.id, src.x, src.y, src.w, src.h, |
| 2886 | crtc->base.id, dst.x, dst.y, dst.w, dst.h, |
| 2887 | (char *)&fmt->base.pixel_format, |
| 2888 | SDE_FORMAT_IS_UBWC(fmt)); |
| 2889 | |
| 2890 | if (sde_plane_get_property(pstate, PLANE_PROP_SRC_CONFIG) & |
| 2891 | BIT(SDE_DRM_DEINTERLACE)) { |
| 2892 | SDE_DEBUG_PLANE(psde, "deinterlace\n"); |
| 2893 | for (idx = 0; idx < SDE_MAX_PLANES; ++idx) |
| 2894 | psde->pipe_cfg.layout.plane_pitch[idx] <<= 1; |
| 2895 | src.h /= 2; |
| 2896 | src.y = DIV_ROUND_UP(src.y, 2); |
| 2897 | src.y &= ~0x1; |
| 2898 | } |
| 2899 | |
| 2900 | /* |
| 2901 | * adjust layer mixer position of the sspp in the presence |
| 2902 | * of a partial update to the active lm origin |
| 2903 | */ |
| 2904 | dst.x -= crtc_roi->x; |
| 2905 | dst.y -= crtc_roi->y; |
| 2906 | |
| 2907 | psde->pipe_cfg.src_rect = src; |
| 2908 | psde->pipe_cfg.dst_rect = dst; |
| 2909 | |
| 2910 | _sde_plane_setup_scaler(psde, fmt, pstate); |
| 2911 | |
| 2912 | /* check for color fill */ |
| 2913 | psde->color_fill = (uint32_t)sde_plane_get_property(pstate, |
| 2914 | PLANE_PROP_COLOR_FILL); |
| 2915 | if (psde->color_fill & SDE_PLANE_COLOR_FILL_FLAG) { |
| 2916 | /* skip remaining processing on color fill */ |
| 2917 | pstate->dirty = 0x0; |
| 2918 | } else if (psde->pipe_hw->ops.setup_rects) { |
| 2919 | psde->pipe_hw->ops.setup_rects(psde->pipe_hw, |
| 2920 | &psde->pipe_cfg, |
| 2921 | pstate->multirect_index); |
| 2922 | } |
| 2923 | |
| 2924 | if (psde->pipe_hw->ops.setup_pe) |
| 2925 | psde->pipe_hw->ops.setup_pe(psde->pipe_hw, |
| 2926 | &psde->pixel_ext); |
| 2927 | |
| 2928 | /** |
| 2929 | * when programmed in multirect mode, scalar block will be |
| 2930 | * bypassed. Still we need to update alpha and bitwidth |
| 2931 | * ONLY for RECT0 |
| 2932 | */ |
| 2933 | if (psde->pipe_hw->ops.setup_scaler && |
| 2934 | pstate->multirect_index != SDE_SSPP_RECT_1) |
| 2935 | psde->pipe_hw->ops.setup_scaler(psde->pipe_hw, |
| 2936 | &psde->pipe_cfg, &psde->pixel_ext, |
| 2937 | psde->scaler3_cfg); |
| 2938 | |
| 2939 | /* update excl rect */ |
| 2940 | if (psde->pipe_hw->ops.setup_excl_rect) |
| 2941 | psde->pipe_hw->ops.setup_excl_rect(psde->pipe_hw, |
| 2942 | &pstate->excl_rect, |
| 2943 | pstate->multirect_index); |
| 2944 | |
| 2945 | if (psde->pipe_hw->ops.setup_multirect) |
| 2946 | psde->pipe_hw->ops.setup_multirect( |
| 2947 | psde->pipe_hw, |
| 2948 | pstate->multirect_index, |
| 2949 | pstate->multirect_mode); |
| 2950 | } |
| 2951 | |
| 2952 | if ((pstate->dirty & SDE_PLANE_DIRTY_FORMAT) && |
| 2953 | psde->pipe_hw->ops.setup_format) { |
| 2954 | src_flags = 0x0; |
| 2955 | SDE_DEBUG_PLANE(psde, "rotation 0x%X\n", rstate->out_rotation); |
| 2956 | if (rstate->out_rotation & DRM_REFLECT_X) |
| 2957 | src_flags |= SDE_SSPP_FLIP_LR; |
| 2958 | if (rstate->out_rotation & DRM_REFLECT_Y) |
| 2959 | src_flags |= SDE_SSPP_FLIP_UD; |
| 2960 | |
| 2961 | /* update format */ |
| 2962 | psde->pipe_hw->ops.setup_format(psde->pipe_hw, fmt, src_flags, |
| 2963 | pstate->multirect_index); |
| 2964 | |
| 2965 | if (psde->pipe_hw->ops.setup_sys_cache) { |
| 2966 | if (rstate->out_sbuf) { |
| 2967 | if (rstate->nplane < 2) |
| 2968 | pstate->sc_cfg.op_mode = |
| 2969 | SDE_PIPE_SC_OP_MODE_INLINE_SINGLE; |
| 2970 | else if (rstate->out_xpos == 0) |
| 2971 | pstate->sc_cfg.op_mode = |
| 2972 | SDE_PIPE_SC_OP_MODE_INLINE_LEFT; |
| 2973 | else |
| 2974 | pstate->sc_cfg.op_mode = |
| 2975 | SDE_PIPE_SC_OP_MODE_INLINE_RIGHT; |
| 2976 | |
| 2977 | pstate->sc_cfg.rd_en = true; |
| 2978 | pstate->sc_cfg.rd_scid = |
| 2979 | rstate->rot_hw->caps->scid; |
| 2980 | pstate->sc_cfg.rd_noallocate = true; |
| 2981 | pstate->sc_cfg.rd_op_type = |
| 2982 | SDE_PIPE_SC_RD_OP_TYPE_CACHEABLE; |
| 2983 | } else { |
| 2984 | pstate->sc_cfg.op_mode = |
| 2985 | SDE_PIPE_SC_OP_MODE_OFFLINE; |
| 2986 | pstate->sc_cfg.rd_en = false; |
| 2987 | pstate->sc_cfg.rd_scid = 0; |
| 2988 | pstate->sc_cfg.rd_noallocate = false; |
| 2989 | pstate->sc_cfg.rd_op_type = |
| 2990 | SDE_PIPE_SC_RD_OP_TYPE_CACHEABLE; |
| 2991 | } |
| 2992 | |
| 2993 | psde->pipe_hw->ops.setup_sys_cache( |
| 2994 | psde->pipe_hw, &pstate->sc_cfg); |
| 2995 | } |
| 2996 | |
| 2997 | /* update csc */ |
| 2998 | if (SDE_FORMAT_IS_YUV(fmt)) |
| 2999 | _sde_plane_setup_csc(psde); |
| 3000 | else |
| 3001 | psde->csc_ptr = 0; |
| 3002 | } |
| 3003 | |
| 3004 | sde_color_process_plane_setup(plane); |
| 3005 | |
| 3006 | /* update sharpening */ |
| 3007 | if ((pstate->dirty & SDE_PLANE_DIRTY_SHARPEN) && |
| 3008 | psde->pipe_hw->ops.setup_sharpening) { |
| 3009 | psde->sharp_cfg.strength = SHARP_STRENGTH_DEFAULT; |
| 3010 | psde->sharp_cfg.edge_thr = SHARP_EDGE_THR_DEFAULT; |
| 3011 | psde->sharp_cfg.smooth_thr = SHARP_SMOOTH_THR_DEFAULT; |
| 3012 | psde->sharp_cfg.noise_thr = SHARP_NOISE_THR_DEFAULT; |
| 3013 | |
| 3014 | psde->pipe_hw->ops.setup_sharpening(psde->pipe_hw, |
| 3015 | &psde->sharp_cfg); |
| 3016 | } |
| 3017 | |
| 3018 | _sde_plane_set_qos_lut(plane, fb); |
| 3019 | _sde_plane_set_danger_lut(plane, fb); |
| 3020 | |
| 3021 | if (plane->type != DRM_PLANE_TYPE_CURSOR) { |
| 3022 | _sde_plane_set_qos_ctrl(plane, true, SDE_PLANE_QOS_PANIC_CTRL); |
| 3023 | _sde_plane_set_ot_limit(plane, crtc); |
| 3024 | } |
| 3025 | |
| 3026 | /* clear dirty */ |
| 3027 | pstate->dirty = 0x0; |
| 3028 | |
| 3029 | return 0; |
| 3030 | } |
| 3031 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3032 | static void sde_plane_atomic_update(struct drm_plane *plane, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 3033 | struct drm_plane_state *old_state) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 3034 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3035 | struct sde_plane *psde; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3036 | struct drm_plane_state *state; |
| 3037 | struct sde_plane_state *pstate; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 3038 | struct sde_plane_state *old_pstate; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3039 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3040 | if (!plane) { |
| 3041 | SDE_ERROR("invalid plane\n"); |
| 3042 | return; |
| 3043 | } else if (!plane->state) { |
| 3044 | SDE_ERROR("invalid plane state\n"); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3045 | return; |
| 3046 | } |
| 3047 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3048 | psde = to_sde_plane(plane); |
| 3049 | psde->is_error = false; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3050 | state = plane->state; |
| 3051 | pstate = to_sde_plane_state(state); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 3052 | old_pstate = to_sde_plane_state(old_state); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3053 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3054 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3055 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 3056 | sde_plane_rot_atomic_update(plane, old_state); |
| 3057 | |
| 3058 | if (!sde_plane_sspp_enabled(state)) { |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3059 | pstate->pending = true; |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 3060 | } else { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3061 | int ret; |
| 3062 | |
Jeykumar Sankaran | e964dc7 | 2017-05-10 19:26:43 -0700 | [diff] [blame^] | 3063 | ret = sde_plane_sspp_atomic_update(plane, old_state); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3064 | /* atomic_check should have ensured that this doesn't fail */ |
| 3065 | WARN_ON(ret < 0); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3066 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3067 | } |
| 3068 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 3069 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3070 | /* helper to install properties which are common to planes and crtcs */ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 3071 | static void _sde_plane_install_properties(struct drm_plane *plane, |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 3072 | struct sde_mdss_cfg *catalog, u32 master_plane_id) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3073 | { |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3074 | static const struct drm_prop_enum_list e_blend_op[] = { |
| 3075 | {SDE_DRM_BLEND_OP_NOT_DEFINED, "not_defined"}, |
| 3076 | {SDE_DRM_BLEND_OP_OPAQUE, "opaque"}, |
| 3077 | {SDE_DRM_BLEND_OP_PREMULTIPLIED, "premultiplied"}, |
| 3078 | {SDE_DRM_BLEND_OP_COVERAGE, "coverage"} |
| 3079 | }; |
| 3080 | static const struct drm_prop_enum_list e_src_config[] = { |
| 3081 | {SDE_DRM_DEINTERLACE, "deinterlace"} |
| 3082 | }; |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 3083 | const struct sde_format_extended *format_list; |
Jeykumar Sankaran | f55e65b | 2017-05-10 21:46:14 -0700 | [diff] [blame] | 3084 | struct sde_format_extended *virt_format_list = NULL; |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 3085 | struct sde_kms_info *info; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3086 | struct sde_plane *psde = to_sde_plane(plane); |
Clarence Ip | c47a069 | 2016-10-11 10:54:17 -0400 | [diff] [blame] | 3087 | int zpos_max = 255; |
| 3088 | int zpos_def = 0; |
Benet Clark | eb1b446 | 2016-06-27 14:43:06 -0700 | [diff] [blame] | 3089 | char feature_name[256]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3090 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3091 | if (!plane || !psde) { |
| 3092 | SDE_ERROR("invalid plane\n"); |
| 3093 | return; |
| 3094 | } else if (!psde->pipe_hw || !psde->pipe_sblk) { |
| 3095 | SDE_ERROR("invalid plane, pipe_hw %d pipe_sblk %d\n", |
| 3096 | psde->pipe_hw != 0, psde->pipe_sblk != 0); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3097 | return; |
Clarence Ip | c47a069 | 2016-10-11 10:54:17 -0400 | [diff] [blame] | 3098 | } else if (!catalog) { |
| 3099 | SDE_ERROR("invalid catalog\n"); |
| 3100 | return; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3101 | } |
| 3102 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 3103 | psde->catalog = catalog; |
| 3104 | |
Clarence Ip | c47a069 | 2016-10-11 10:54:17 -0400 | [diff] [blame] | 3105 | if (sde_is_custom_client()) { |
Clarence Ip | 649989a | 2016-10-21 14:28:34 -0400 | [diff] [blame] | 3106 | if (catalog->mixer_count && catalog->mixer && |
| 3107 | catalog->mixer[0].sblk->maxblendstages) { |
| 3108 | zpos_max = catalog->mixer[0].sblk->maxblendstages - 1; |
| 3109 | if (zpos_max > SDE_STAGE_MAX - SDE_STAGE_0 - 1) |
| 3110 | zpos_max = SDE_STAGE_MAX - SDE_STAGE_0 - 1; |
| 3111 | } |
Clarence Ip | c47a069 | 2016-10-11 10:54:17 -0400 | [diff] [blame] | 3112 | } else if (plane->type != DRM_PLANE_TYPE_PRIMARY) { |
| 3113 | /* reserve zpos == 0 for primary planes */ |
| 3114 | zpos_def = drm_plane_index(plane) + 1; |
| 3115 | } |
| 3116 | |
| 3117 | msm_property_install_range(&psde->property_info, "zpos", |
| 3118 | 0x0, 0, zpos_max, zpos_def, PLANE_PROP_ZPOS); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3119 | |
Lloyd Atkinson | 38ad8c9 | 2016-07-06 10:39:32 -0400 | [diff] [blame] | 3120 | msm_property_install_range(&psde->property_info, "alpha", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 3121 | 0x0, 0, 255, 255, PLANE_PROP_ALPHA); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3122 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 3123 | /* linux default file descriptor range on each process */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 3124 | msm_property_install_range(&psde->property_info, "input_fence", |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 3125 | 0x0, 0, INR_OPEN_MAX, 0, PLANE_PROP_INPUT_FENCE); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3126 | |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 3127 | if (!master_plane_id) { |
| 3128 | if (psde->pipe_sblk->maxhdeciexp) { |
| 3129 | msm_property_install_range(&psde->property_info, |
| 3130 | "h_decimate", 0x0, 0, |
| 3131 | psde->pipe_sblk->maxhdeciexp, 0, |
| 3132 | PLANE_PROP_H_DECIMATE); |
| 3133 | } |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 3134 | |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 3135 | if (psde->pipe_sblk->maxvdeciexp) { |
| 3136 | msm_property_install_range(&psde->property_info, |
| 3137 | "v_decimate", 0x0, 0, |
| 3138 | psde->pipe_sblk->maxvdeciexp, 0, |
| 3139 | PLANE_PROP_V_DECIMATE); |
| 3140 | } |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 3141 | |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 3142 | if (psde->features & BIT(SDE_SSPP_SCALER_QSEED3)) { |
| 3143 | msm_property_install_volatile_range( |
| 3144 | &psde->property_info, "scaler_v2", |
| 3145 | 0x0, 0, ~0, 0, PLANE_PROP_SCALER_V2); |
| 3146 | msm_property_install_blob(&psde->property_info, |
| 3147 | "lut_ed", 0, PLANE_PROP_SCALER_LUT_ED); |
| 3148 | msm_property_install_blob(&psde->property_info, |
| 3149 | "lut_cir", 0, |
| 3150 | PLANE_PROP_SCALER_LUT_CIR); |
| 3151 | msm_property_install_blob(&psde->property_info, |
| 3152 | "lut_sep", 0, |
| 3153 | PLANE_PROP_SCALER_LUT_SEP); |
| 3154 | } else if (psde->features & SDE_SSPP_SCALER) { |
| 3155 | msm_property_install_volatile_range( |
| 3156 | &psde->property_info, "scaler_v1", 0x0, |
| 3157 | 0, ~0, 0, PLANE_PROP_SCALER_V1); |
| 3158 | } |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 3159 | |
Dhaval Patel | 0aee097 | 2017-02-08 19:00:58 -0800 | [diff] [blame] | 3160 | if (psde->features & BIT(SDE_SSPP_CSC) || |
| 3161 | psde->features & BIT(SDE_SSPP_CSC_10BIT)) |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 3162 | msm_property_install_volatile_range( |
| 3163 | &psde->property_info, "csc_v1", 0x0, |
| 3164 | 0, ~0, 0, PLANE_PROP_CSC_V1); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 3165 | |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 3166 | if (psde->features & BIT(SDE_SSPP_HSIC)) { |
| 3167 | snprintf(feature_name, sizeof(feature_name), "%s%d", |
| 3168 | "SDE_SSPP_HUE_V", |
| 3169 | psde->pipe_sblk->hsic_blk.version >> 16); |
| 3170 | msm_property_install_range(&psde->property_info, |
| 3171 | feature_name, 0, 0, 0xFFFFFFFF, 0, |
| 3172 | PLANE_PROP_HUE_ADJUST); |
| 3173 | snprintf(feature_name, sizeof(feature_name), "%s%d", |
| 3174 | "SDE_SSPP_SATURATION_V", |
| 3175 | psde->pipe_sblk->hsic_blk.version >> 16); |
| 3176 | msm_property_install_range(&psde->property_info, |
| 3177 | feature_name, 0, 0, 0xFFFFFFFF, 0, |
| 3178 | PLANE_PROP_SATURATION_ADJUST); |
| 3179 | snprintf(feature_name, sizeof(feature_name), "%s%d", |
| 3180 | "SDE_SSPP_VALUE_V", |
| 3181 | psde->pipe_sblk->hsic_blk.version >> 16); |
| 3182 | msm_property_install_range(&psde->property_info, |
| 3183 | feature_name, 0, 0, 0xFFFFFFFF, 0, |
| 3184 | PLANE_PROP_VALUE_ADJUST); |
| 3185 | snprintf(feature_name, sizeof(feature_name), "%s%d", |
| 3186 | "SDE_SSPP_CONTRAST_V", |
| 3187 | psde->pipe_sblk->hsic_blk.version >> 16); |
| 3188 | msm_property_install_range(&psde->property_info, |
| 3189 | feature_name, 0, 0, 0xFFFFFFFF, 0, |
| 3190 | PLANE_PROP_CONTRAST_ADJUST); |
| 3191 | } |
Benet Clark | eb1b446 | 2016-06-27 14:43:06 -0700 | [diff] [blame] | 3192 | } |
| 3193 | |
Veera Sundaram Sankaran | 02dd6ac | 2016-12-22 15:08:29 -0800 | [diff] [blame] | 3194 | if (psde->features & BIT(SDE_SSPP_EXCL_RECT)) |
| 3195 | msm_property_install_volatile_range(&psde->property_info, |
| 3196 | "excl_rect_v1", 0x0, 0, ~0, 0, PLANE_PROP_EXCL_RECT_V1); |
| 3197 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 3198 | sde_plane_rot_install_properties(plane, catalog); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3199 | |
Lloyd Atkinson | 38ad8c9 | 2016-07-06 10:39:32 -0400 | [diff] [blame] | 3200 | msm_property_install_enum(&psde->property_info, "blend_op", 0x0, 0, |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 3201 | e_blend_op, ARRAY_SIZE(e_blend_op), PLANE_PROP_BLEND_OP); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 3202 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 3203 | msm_property_install_enum(&psde->property_info, "src_config", 0x0, 1, |
| 3204 | e_src_config, ARRAY_SIZE(e_src_config), PLANE_PROP_SRC_CONFIG); |
| 3205 | |
| 3206 | if (psde->pipe_hw->ops.setup_solidfill) |
| 3207 | msm_property_install_range(&psde->property_info, "color_fill", |
| 3208 | 0, 0, 0xFFFFFFFF, 0, PLANE_PROP_COLOR_FILL); |
| 3209 | |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 3210 | info = kzalloc(sizeof(struct sde_kms_info), GFP_KERNEL); |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3211 | if (!info) { |
| 3212 | SDE_ERROR("failed to allocate info memory\n"); |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 3213 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3214 | } |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 3215 | |
| 3216 | msm_property_install_blob(&psde->property_info, "capabilities", |
| 3217 | DRM_MODE_PROP_IMMUTABLE, PLANE_PROP_INFO); |
| 3218 | sde_kms_info_reset(info); |
| 3219 | |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 3220 | format_list = psde->pipe_sblk->format_list; |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 3221 | |
| 3222 | if (master_plane_id) { |
Jeykumar Sankaran | f55e65b | 2017-05-10 21:46:14 -0700 | [diff] [blame] | 3223 | int index, array_size; |
| 3224 | |
| 3225 | array_size = ARRAY_SIZE(plane_formats) |
| 3226 | + ARRAY_SIZE(rgb_10bit_formats); |
| 3227 | virt_format_list = kcalloc(array_size, |
| 3228 | sizeof(struct sde_format_extended), GFP_KERNEL); |
| 3229 | if (!virt_format_list) { |
| 3230 | SDE_ERROR( |
| 3231 | "failed to allocate virtual pipe format list\n"); |
| 3232 | return; |
| 3233 | } |
| 3234 | |
| 3235 | index = sde_copy_formats(virt_format_list, array_size, |
| 3236 | 0, plane_formats, ARRAY_SIZE(plane_formats)); |
| 3237 | sde_copy_formats(virt_format_list, array_size, |
| 3238 | index, rgb_10bit_formats, |
| 3239 | ARRAY_SIZE(rgb_10bit_formats)); |
| 3240 | |
| 3241 | format_list = virt_format_list; |
| 3242 | |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 3243 | sde_kms_info_add_keyint(info, "primary_smart_plane_id", |
Jeykumar Sankaran | f55e65b | 2017-05-10 21:46:14 -0700 | [diff] [blame] | 3244 | master_plane_id); |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 3245 | } |
| 3246 | |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 3247 | if (format_list) { |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 3248 | sde_kms_info_start(info, "pixel_formats"); |
| 3249 | while (format_list->fourcc_format) { |
| 3250 | sde_kms_info_append_format(info, |
| 3251 | format_list->fourcc_format, |
| 3252 | format_list->modifier); |
| 3253 | ++format_list; |
| 3254 | } |
| 3255 | sde_kms_info_stop(info); |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 3256 | } |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 3257 | |
| 3258 | sde_kms_info_add_keyint(info, "max_linewidth", |
| 3259 | psde->pipe_sblk->maxlinewidth); |
| 3260 | sde_kms_info_add_keyint(info, "max_upscale", |
| 3261 | psde->pipe_sblk->maxupscale); |
| 3262 | sde_kms_info_add_keyint(info, "max_downscale", |
| 3263 | psde->pipe_sblk->maxdwnscale); |
| 3264 | sde_kms_info_add_keyint(info, "max_horizontal_deci", |
| 3265 | psde->pipe_sblk->maxhdeciexp); |
| 3266 | sde_kms_info_add_keyint(info, "max_vertical_deci", |
| 3267 | psde->pipe_sblk->maxvdeciexp); |
Alan Kwong | 6259a38 | 2017-04-04 06:18:02 -0700 | [diff] [blame] | 3268 | sde_kms_info_add_keyint(info, "max_per_pipe_bw", |
| 3269 | psde->pipe_sblk->max_per_pipe_bw * 1000LL); |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 3270 | msm_property_set_blob(&psde->property_info, &psde->blob_info, |
| 3271 | info->data, info->len, PLANE_PROP_INFO); |
| 3272 | |
| 3273 | kfree(info); |
Jeykumar Sankaran | f55e65b | 2017-05-10 21:46:14 -0700 | [diff] [blame] | 3274 | kfree(virt_format_list); |
Benet Clark | d009b1d | 2016-06-27 14:45:59 -0700 | [diff] [blame] | 3275 | |
| 3276 | if (psde->features & BIT(SDE_SSPP_MEMCOLOR)) { |
| 3277 | snprintf(feature_name, sizeof(feature_name), "%s%d", |
| 3278 | "SDE_SSPP_SKIN_COLOR_V", |
| 3279 | psde->pipe_sblk->memcolor_blk.version >> 16); |
| 3280 | msm_property_install_blob(&psde->property_info, feature_name, 0, |
| 3281 | PLANE_PROP_SKIN_COLOR); |
| 3282 | snprintf(feature_name, sizeof(feature_name), "%s%d", |
| 3283 | "SDE_SSPP_SKY_COLOR_V", |
| 3284 | psde->pipe_sblk->memcolor_blk.version >> 16); |
| 3285 | msm_property_install_blob(&psde->property_info, feature_name, 0, |
| 3286 | PLANE_PROP_SKY_COLOR); |
| 3287 | snprintf(feature_name, sizeof(feature_name), "%s%d", |
| 3288 | "SDE_SSPP_FOLIAGE_COLOR_V", |
| 3289 | psde->pipe_sblk->memcolor_blk.version >> 16); |
| 3290 | msm_property_install_blob(&psde->property_info, feature_name, 0, |
| 3291 | PLANE_PROP_FOLIAGE_COLOR); |
| 3292 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3293 | } |
| 3294 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 3295 | static inline void _sde_plane_set_csc_v1(struct sde_plane *psde, void *usr_ptr) |
| 3296 | { |
| 3297 | struct sde_drm_csc_v1 csc_v1; |
| 3298 | int i; |
| 3299 | |
| 3300 | if (!psde) { |
| 3301 | SDE_ERROR("invalid plane\n"); |
| 3302 | return; |
| 3303 | } |
| 3304 | |
| 3305 | psde->csc_usr_ptr = NULL; |
| 3306 | if (!usr_ptr) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3307 | SDE_DEBUG_PLANE(psde, "csc data removed\n"); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 3308 | return; |
| 3309 | } |
| 3310 | |
| 3311 | if (copy_from_user(&csc_v1, usr_ptr, sizeof(csc_v1))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3312 | SDE_ERROR_PLANE(psde, "failed to copy csc data\n"); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 3313 | return; |
| 3314 | } |
| 3315 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 3316 | /* populate from user space */ |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 3317 | for (i = 0; i < SDE_CSC_MATRIX_COEFF_SIZE; ++i) |
| 3318 | psde->csc_cfg.csc_mv[i] = csc_v1.ctm_coeff[i] >> 16; |
| 3319 | for (i = 0; i < SDE_CSC_BIAS_SIZE; ++i) { |
| 3320 | psde->csc_cfg.csc_pre_bv[i] = csc_v1.pre_bias[i]; |
| 3321 | psde->csc_cfg.csc_post_bv[i] = csc_v1.post_bias[i]; |
| 3322 | } |
| 3323 | for (i = 0; i < SDE_CSC_CLAMP_SIZE; ++i) { |
| 3324 | psde->csc_cfg.csc_pre_lv[i] = csc_v1.pre_clamp[i]; |
| 3325 | psde->csc_cfg.csc_post_lv[i] = csc_v1.post_clamp[i]; |
| 3326 | } |
| 3327 | psde->csc_usr_ptr = &psde->csc_cfg; |
| 3328 | } |
| 3329 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 3330 | static inline void _sde_plane_set_scaler_v1(struct sde_plane *psde, void *usr) |
| 3331 | { |
| 3332 | struct sde_drm_scaler_v1 scale_v1; |
| 3333 | struct sde_hw_pixel_ext *pe; |
| 3334 | int i; |
| 3335 | |
| 3336 | if (!psde) { |
| 3337 | SDE_ERROR("invalid plane\n"); |
| 3338 | return; |
| 3339 | } |
| 3340 | |
| 3341 | psde->pixel_ext_usr = false; |
| 3342 | if (!usr) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3343 | SDE_DEBUG_PLANE(psde, "scale data removed\n"); |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 3344 | return; |
| 3345 | } |
| 3346 | |
| 3347 | if (copy_from_user(&scale_v1, usr, sizeof(scale_v1))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3348 | SDE_ERROR_PLANE(psde, "failed to copy scale data\n"); |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 3349 | return; |
| 3350 | } |
| 3351 | |
| 3352 | /* populate from user space */ |
| 3353 | pe = &(psde->pixel_ext); |
| 3354 | memset(pe, 0, sizeof(struct sde_hw_pixel_ext)); |
| 3355 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 3356 | pe->init_phase_x[i] = scale_v1.init_phase_x[i]; |
| 3357 | pe->phase_step_x[i] = scale_v1.phase_step_x[i]; |
| 3358 | pe->init_phase_y[i] = scale_v1.init_phase_y[i]; |
| 3359 | pe->phase_step_y[i] = scale_v1.phase_step_y[i]; |
| 3360 | |
| 3361 | pe->horz_filter[i] = scale_v1.horz_filter[i]; |
| 3362 | pe->vert_filter[i] = scale_v1.vert_filter[i]; |
| 3363 | } |
| 3364 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
abeykun | 4106012 | 2016-11-28 13:02:01 -0500 | [diff] [blame] | 3365 | pe->left_ftch[i] = scale_v1.pe.left_ftch[i]; |
| 3366 | pe->right_ftch[i] = scale_v1.pe.right_ftch[i]; |
| 3367 | pe->left_rpt[i] = scale_v1.pe.left_rpt[i]; |
| 3368 | pe->right_rpt[i] = scale_v1.pe.right_rpt[i]; |
| 3369 | pe->roi_w[i] = scale_v1.pe.num_ext_pxls_lr[i]; |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 3370 | |
abeykun | 4106012 | 2016-11-28 13:02:01 -0500 | [diff] [blame] | 3371 | pe->top_ftch[i] = scale_v1.pe.top_ftch[i]; |
| 3372 | pe->btm_ftch[i] = scale_v1.pe.btm_ftch[i]; |
| 3373 | pe->top_rpt[i] = scale_v1.pe.top_rpt[i]; |
| 3374 | pe->btm_rpt[i] = scale_v1.pe.btm_rpt[i]; |
| 3375 | pe->roi_h[i] = scale_v1.pe.num_ext_pxls_tb[i]; |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 3376 | } |
abeykun | 4106012 | 2016-11-28 13:02:01 -0500 | [diff] [blame] | 3377 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 3378 | psde->pixel_ext_usr = true; |
| 3379 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3380 | SDE_DEBUG_PLANE(psde, "user property data copied\n"); |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 3381 | } |
| 3382 | |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 3383 | static inline void _sde_plane_set_scaler_v2(struct sde_plane *psde, |
| 3384 | struct sde_plane_state *pstate, void *usr) |
| 3385 | { |
| 3386 | struct sde_drm_scaler_v2 scale_v2; |
| 3387 | struct sde_hw_pixel_ext *pe; |
| 3388 | int i; |
| 3389 | struct sde_hw_scaler3_cfg *cfg; |
| 3390 | |
| 3391 | if (!psde) { |
| 3392 | SDE_ERROR("invalid plane\n"); |
| 3393 | return; |
| 3394 | } |
| 3395 | |
| 3396 | cfg = psde->scaler3_cfg; |
| 3397 | psde->pixel_ext_usr = false; |
| 3398 | if (!usr) { |
| 3399 | SDE_DEBUG_PLANE(psde, "scale data removed\n"); |
| 3400 | return; |
| 3401 | } |
| 3402 | |
| 3403 | if (copy_from_user(&scale_v2, usr, sizeof(scale_v2))) { |
| 3404 | SDE_ERROR_PLANE(psde, "failed to copy scale data\n"); |
| 3405 | return; |
| 3406 | } |
| 3407 | |
| 3408 | /* populate from user space */ |
| 3409 | pe = &(psde->pixel_ext); |
| 3410 | memset(pe, 0, sizeof(struct sde_hw_pixel_ext)); |
| 3411 | cfg->enable = scale_v2.enable; |
| 3412 | cfg->dir_en = scale_v2.dir_en; |
| 3413 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 3414 | cfg->init_phase_x[i] = scale_v2.init_phase_x[i]; |
| 3415 | cfg->phase_step_x[i] = scale_v2.phase_step_x[i]; |
| 3416 | cfg->init_phase_y[i] = scale_v2.init_phase_y[i]; |
| 3417 | cfg->phase_step_y[i] = scale_v2.phase_step_y[i]; |
| 3418 | |
| 3419 | cfg->preload_x[i] = scale_v2.preload_x[i]; |
| 3420 | cfg->preload_y[i] = scale_v2.preload_y[i]; |
| 3421 | cfg->src_width[i] = scale_v2.src_width[i]; |
| 3422 | cfg->src_height[i] = scale_v2.src_height[i]; |
| 3423 | } |
| 3424 | cfg->dst_width = scale_v2.dst_width; |
| 3425 | cfg->dst_height = scale_v2.dst_height; |
| 3426 | |
| 3427 | cfg->y_rgb_filter_cfg = scale_v2.y_rgb_filter_cfg; |
| 3428 | cfg->uv_filter_cfg = scale_v2.uv_filter_cfg; |
| 3429 | cfg->alpha_filter_cfg = scale_v2.alpha_filter_cfg; |
| 3430 | cfg->blend_cfg = scale_v2.blend_cfg; |
| 3431 | |
| 3432 | cfg->lut_flag = scale_v2.lut_flag; |
| 3433 | cfg->dir_lut_idx = scale_v2.dir_lut_idx; |
| 3434 | cfg->y_rgb_cir_lut_idx = scale_v2.y_rgb_cir_lut_idx; |
| 3435 | cfg->uv_cir_lut_idx = scale_v2.uv_cir_lut_idx; |
| 3436 | cfg->y_rgb_sep_lut_idx = scale_v2.y_rgb_sep_lut_idx; |
| 3437 | cfg->uv_sep_lut_idx = scale_v2.uv_sep_lut_idx; |
| 3438 | |
| 3439 | cfg->de.enable = scale_v2.de.enable; |
| 3440 | cfg->de.sharpen_level1 = scale_v2.de.sharpen_level1; |
| 3441 | cfg->de.sharpen_level2 = scale_v2.de.sharpen_level2; |
| 3442 | cfg->de.clip = scale_v2.de.clip; |
| 3443 | cfg->de.limit = scale_v2.de.limit; |
| 3444 | cfg->de.thr_quiet = scale_v2.de.thr_quiet; |
| 3445 | cfg->de.thr_dieout = scale_v2.de.thr_dieout; |
| 3446 | cfg->de.thr_low = scale_v2.de.thr_low; |
| 3447 | cfg->de.thr_high = scale_v2.de.thr_high; |
| 3448 | cfg->de.prec_shift = scale_v2.de.prec_shift; |
| 3449 | for (i = 0; i < SDE_MAX_DE_CURVES; i++) { |
| 3450 | cfg->de.adjust_a[i] = scale_v2.de.adjust_a[i]; |
| 3451 | cfg->de.adjust_b[i] = scale_v2.de.adjust_b[i]; |
| 3452 | cfg->de.adjust_c[i] = scale_v2.de.adjust_c[i]; |
| 3453 | } |
| 3454 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
abeykun | 4106012 | 2016-11-28 13:02:01 -0500 | [diff] [blame] | 3455 | pe->left_ftch[i] = scale_v2.pe.left_ftch[i]; |
| 3456 | pe->right_ftch[i] = scale_v2.pe.right_ftch[i]; |
| 3457 | pe->left_rpt[i] = scale_v2.pe.left_rpt[i]; |
| 3458 | pe->right_rpt[i] = scale_v2.pe.right_rpt[i]; |
| 3459 | pe->roi_w[i] = scale_v2.pe.num_ext_pxls_lr[i]; |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 3460 | |
abeykun | 4106012 | 2016-11-28 13:02:01 -0500 | [diff] [blame] | 3461 | pe->top_ftch[i] = scale_v2.pe.top_ftch[i]; |
| 3462 | pe->btm_ftch[i] = scale_v2.pe.btm_ftch[i]; |
| 3463 | pe->top_rpt[i] = scale_v2.pe.top_rpt[i]; |
| 3464 | pe->btm_rpt[i] = scale_v2.pe.btm_rpt[i]; |
| 3465 | pe->roi_h[i] = scale_v2.pe.num_ext_pxls_tb[i]; |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 3466 | } |
| 3467 | psde->pixel_ext_usr = true; |
| 3468 | |
| 3469 | SDE_DEBUG_PLANE(psde, "user property data copied\n"); |
| 3470 | } |
| 3471 | |
Veera Sundaram Sankaran | 02dd6ac | 2016-12-22 15:08:29 -0800 | [diff] [blame] | 3472 | static void _sde_plane_set_excl_rect_v1(struct sde_plane *psde, |
| 3473 | struct sde_plane_state *pstate, void *usr_ptr) |
| 3474 | { |
| 3475 | struct drm_clip_rect excl_rect_v1; |
| 3476 | |
| 3477 | if (!psde) { |
| 3478 | SDE_ERROR("invalid plane\n"); |
| 3479 | return; |
| 3480 | } |
| 3481 | |
| 3482 | if (!usr_ptr) { |
| 3483 | SDE_DEBUG_PLANE(psde, "excl rect data removed\n"); |
| 3484 | return; |
| 3485 | } |
| 3486 | |
| 3487 | if (copy_from_user(&excl_rect_v1, usr_ptr, sizeof(excl_rect_v1))) { |
| 3488 | SDE_ERROR_PLANE(psde, "failed to copy excl rect data\n"); |
| 3489 | return; |
| 3490 | } |
| 3491 | |
| 3492 | /* populate from user space */ |
| 3493 | pstate->excl_rect.x = excl_rect_v1.x1; |
| 3494 | pstate->excl_rect.y = excl_rect_v1.y1; |
| 3495 | pstate->excl_rect.w = excl_rect_v1.x2 - excl_rect_v1.x1 + 1; |
| 3496 | pstate->excl_rect.h = excl_rect_v1.y2 - excl_rect_v1.y1 + 1; |
| 3497 | } |
| 3498 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3499 | static int sde_plane_atomic_set_property(struct drm_plane *plane, |
| 3500 | struct drm_plane_state *state, struct drm_property *property, |
| 3501 | uint64_t val) |
| 3502 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3503 | struct sde_plane *psde = plane ? to_sde_plane(plane) : NULL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3504 | struct sde_plane_state *pstate; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 3505 | int idx, ret = -EINVAL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3506 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3507 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3508 | |
| 3509 | if (!plane) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 3510 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3511 | } else if (!state) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3512 | SDE_ERROR_PLANE(psde, "invalid state\n"); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 3513 | } else { |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 3514 | pstate = to_sde_plane_state(state); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3515 | ret = msm_property_atomic_set(&psde->property_info, |
| 3516 | pstate->property_values, pstate->property_blobs, |
| 3517 | property, val); |
| 3518 | if (!ret) { |
| 3519 | idx = msm_property_index(&psde->property_info, |
| 3520 | property); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 3521 | switch (idx) { |
| 3522 | case PLANE_PROP_INPUT_FENCE: |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3523 | _sde_plane_set_input_fence(psde, pstate, val); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 3524 | break; |
| 3525 | case PLANE_PROP_CSC_V1: |
| 3526 | _sde_plane_set_csc_v1(psde, (void *)val); |
| 3527 | break; |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 3528 | case PLANE_PROP_SCALER_V1: |
| 3529 | _sde_plane_set_scaler_v1(psde, (void *)val); |
| 3530 | break; |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 3531 | case PLANE_PROP_SCALER_V2: |
| 3532 | _sde_plane_set_scaler_v2(psde, pstate, |
| 3533 | (void *)val); |
| 3534 | break; |
Veera Sundaram Sankaran | 02dd6ac | 2016-12-22 15:08:29 -0800 | [diff] [blame] | 3535 | case PLANE_PROP_EXCL_RECT_V1: |
| 3536 | _sde_plane_set_excl_rect_v1(psde, pstate, |
| 3537 | (void *)val); |
| 3538 | break; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 3539 | default: |
| 3540 | /* nothing to do */ |
| 3541 | break; |
| 3542 | } |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 3543 | } |
| 3544 | } |
| 3545 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 3546 | SDE_DEBUG_PLANE(psde, "%s[%d] <= 0x%llx ret=%d\n", |
| 3547 | property->name, property->base.id, val, ret); |
| 3548 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3549 | return ret; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3550 | } |
| 3551 | |
| 3552 | static int sde_plane_set_property(struct drm_plane *plane, |
| 3553 | struct drm_property *property, uint64_t val) |
| 3554 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3555 | SDE_DEBUG("\n"); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 3556 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3557 | return sde_plane_atomic_set_property(plane, |
| 3558 | plane->state, property, val); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3559 | } |
| 3560 | |
| 3561 | static int sde_plane_atomic_get_property(struct drm_plane *plane, |
| 3562 | const struct drm_plane_state *state, |
| 3563 | struct drm_property *property, uint64_t *val) |
| 3564 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3565 | struct sde_plane *psde = plane ? to_sde_plane(plane) : NULL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3566 | struct sde_plane_state *pstate; |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3567 | int ret = -EINVAL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3568 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3569 | if (!plane) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 3570 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3571 | } else if (!state) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 3572 | SDE_ERROR("invalid state\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3573 | } else { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3574 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 3575 | pstate = to_sde_plane_state(state); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 3576 | sde_plane_rot_install_caps(plane); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3577 | ret = msm_property_atomic_get(&psde->property_info, |
| 3578 | pstate->property_values, pstate->property_blobs, |
| 3579 | property, val); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 3580 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3581 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3582 | return ret; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 3583 | } |
| 3584 | |
| 3585 | static void sde_plane_destroy(struct drm_plane *plane) |
| 3586 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3587 | struct sde_plane *psde = plane ? to_sde_plane(plane) : NULL; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 3588 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3589 | SDE_DEBUG_PLANE(psde, "\n"); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 3590 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3591 | if (psde) { |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 3592 | _sde_plane_set_qos_ctrl(plane, false, SDE_PLANE_QOS_PANIC_CTRL); |
| 3593 | |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 3594 | if (psde->blob_info) |
| 3595 | drm_property_unreference_blob(psde->blob_info); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3596 | msm_property_destroy(&psde->property_info); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 3597 | mutex_destroy(&psde->lock); |
| 3598 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 3599 | drm_plane_helper_disable(plane); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3600 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 3601 | /* this will destroy the states as well */ |
| 3602 | drm_plane_cleanup(plane); |
| 3603 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 3604 | if (psde->pipe_hw) |
| 3605 | sde_hw_sspp_destroy(psde->pipe_hw); |
| 3606 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 3607 | kfree(psde); |
| 3608 | } |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 3609 | } |
| 3610 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3611 | static void sde_plane_destroy_state(struct drm_plane *plane, |
| 3612 | struct drm_plane_state *state) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 3613 | { |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3614 | struct sde_plane *psde; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 3615 | struct sde_plane_state *pstate; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 3616 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3617 | if (!plane || !state) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3618 | SDE_ERROR("invalid arg(s), plane %d state %d\n", |
| 3619 | plane != 0, state != 0); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3620 | return; |
| 3621 | } |
| 3622 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3623 | psde = to_sde_plane(plane); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 3624 | pstate = to_sde_plane_state(state); |
| 3625 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3626 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 3627 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 3628 | sde_plane_rot_destroy_state(plane, &pstate->base); |
| 3629 | |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 3630 | /* remove ref count for frame buffers */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3631 | if (state->fb) |
| 3632 | drm_framebuffer_unreference(state->fb); |
| 3633 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3634 | /* remove ref count for fence */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 3635 | if (pstate->input_fence) |
| 3636 | sde_sync_put(pstate->input_fence); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3637 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3638 | /* destroy value helper */ |
| 3639 | msm_property_destroy_state(&psde->property_info, pstate, |
| 3640 | pstate->property_values, pstate->property_blobs); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 3641 | } |
| 3642 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3643 | static struct drm_plane_state * |
| 3644 | sde_plane_duplicate_state(struct drm_plane *plane) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 3645 | { |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3646 | struct sde_plane *psde; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3647 | struct sde_plane_state *pstate; |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 3648 | struct sde_plane_state *old_state; |
Clarence Ip | 17e908b | 2016-09-29 15:58:00 -0400 | [diff] [blame] | 3649 | uint64_t input_fence_default; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3650 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3651 | if (!plane) { |
| 3652 | SDE_ERROR("invalid plane\n"); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3653 | return NULL; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3654 | } else if (!plane->state) { |
| 3655 | SDE_ERROR("invalid plane state\n"); |
| 3656 | return NULL; |
| 3657 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3658 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 3659 | old_state = to_sde_plane_state(plane->state); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3660 | psde = to_sde_plane(plane); |
| 3661 | pstate = msm_property_alloc_state(&psde->property_info); |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3662 | if (!pstate) { |
| 3663 | SDE_ERROR_PLANE(psde, "failed to allocate state\n"); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 3664 | return NULL; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3665 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3666 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3667 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3668 | |
| 3669 | /* duplicate value helper */ |
| 3670 | msm_property_duplicate_state(&psde->property_info, old_state, pstate, |
| 3671 | pstate->property_values, pstate->property_blobs); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3672 | |
Clarence Ip | 17e908b | 2016-09-29 15:58:00 -0400 | [diff] [blame] | 3673 | /* clear out any input fence */ |
| 3674 | pstate->input_fence = 0; |
| 3675 | input_fence_default = msm_property_get_default( |
| 3676 | &psde->property_info, PLANE_PROP_INPUT_FENCE); |
| 3677 | msm_property_set_property(&psde->property_info, pstate->property_values, |
| 3678 | PLANE_PROP_INPUT_FENCE, input_fence_default); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3679 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 3680 | pstate->dirty = 0x0; |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 3681 | pstate->pending = false; |
| 3682 | |
Alan Kwong | cdb2f28 | 2017-03-18 13:42:06 -0700 | [diff] [blame] | 3683 | __drm_atomic_helper_plane_duplicate_state(plane, &pstate->base); |
| 3684 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 3685 | sde_plane_rot_duplicate_state(plane, &pstate->base); |
| 3686 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 3687 | return &pstate->base; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3688 | } |
| 3689 | |
| 3690 | static void sde_plane_reset(struct drm_plane *plane) |
| 3691 | { |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3692 | struct sde_plane *psde; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3693 | struct sde_plane_state *pstate; |
| 3694 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3695 | if (!plane) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 3696 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3697 | return; |
| 3698 | } |
| 3699 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 3700 | psde = to_sde_plane(plane); |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3701 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 3702 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3703 | /* remove previous state, if present */ |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3704 | if (plane->state) { |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3705 | sde_plane_destroy_state(plane, plane->state); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3706 | plane->state = 0; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 3707 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3708 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3709 | pstate = msm_property_alloc_state(&psde->property_info); |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3710 | if (!pstate) { |
| 3711 | SDE_ERROR_PLANE(psde, "failed to allocate state\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3712 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 3713 | } |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 3714 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 3715 | /* reset value helper */ |
| 3716 | msm_property_reset_state(&psde->property_info, pstate, |
| 3717 | pstate->property_values, pstate->property_blobs); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3718 | |
| 3719 | pstate->base.plane = plane; |
| 3720 | |
| 3721 | plane->state = &pstate->base; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 3722 | } |
| 3723 | |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 3724 | #ifdef CONFIG_DEBUG_FS |
Alan Kwong | f0fd851 | 2016-10-24 21:39:26 -0400 | [diff] [blame] | 3725 | static ssize_t _sde_plane_danger_read(struct file *file, |
| 3726 | char __user *buff, size_t count, loff_t *ppos) |
| 3727 | { |
| 3728 | struct sde_kms *kms = file->private_data; |
| 3729 | struct sde_mdss_cfg *cfg = kms->catalog; |
| 3730 | int len = 0; |
| 3731 | char buf[40] = {'\0'}; |
| 3732 | |
| 3733 | if (!cfg) |
| 3734 | return -ENODEV; |
| 3735 | |
| 3736 | if (*ppos) |
| 3737 | return 0; /* the end */ |
| 3738 | |
| 3739 | len = snprintf(buf, sizeof(buf), "%d\n", !kms->has_danger_ctrl); |
| 3740 | if (len < 0 || len >= sizeof(buf)) |
| 3741 | return 0; |
| 3742 | |
| 3743 | if ((count < sizeof(buf)) || copy_to_user(buff, buf, len)) |
| 3744 | return -EFAULT; |
| 3745 | |
| 3746 | *ppos += len; /* increase offset */ |
| 3747 | |
| 3748 | return len; |
| 3749 | } |
| 3750 | |
| 3751 | static void _sde_plane_set_danger_state(struct sde_kms *kms, bool enable) |
| 3752 | { |
| 3753 | struct drm_plane *plane; |
| 3754 | |
| 3755 | drm_for_each_plane(plane, kms->dev) { |
| 3756 | if (plane->fb && plane->state) { |
| 3757 | sde_plane_danger_signal_ctrl(plane, enable); |
| 3758 | SDE_DEBUG("plane:%d img:%dx%d ", |
| 3759 | plane->base.id, plane->fb->width, |
| 3760 | plane->fb->height); |
| 3761 | SDE_DEBUG("src[%d,%d,%d,%d] dst[%d,%d,%d,%d]\n", |
| 3762 | plane->state->src_x >> 16, |
| 3763 | plane->state->src_y >> 16, |
| 3764 | plane->state->src_w >> 16, |
| 3765 | plane->state->src_h >> 16, |
| 3766 | plane->state->crtc_x, plane->state->crtc_y, |
| 3767 | plane->state->crtc_w, plane->state->crtc_h); |
| 3768 | } else { |
| 3769 | SDE_DEBUG("Inactive plane:%d\n", plane->base.id); |
| 3770 | } |
| 3771 | } |
| 3772 | } |
| 3773 | |
| 3774 | static ssize_t _sde_plane_danger_write(struct file *file, |
| 3775 | const char __user *user_buf, size_t count, loff_t *ppos) |
| 3776 | { |
| 3777 | struct sde_kms *kms = file->private_data; |
| 3778 | struct sde_mdss_cfg *cfg = kms->catalog; |
| 3779 | int disable_panic; |
| 3780 | char buf[10]; |
| 3781 | |
| 3782 | if (!cfg) |
| 3783 | return -EFAULT; |
| 3784 | |
| 3785 | if (count >= sizeof(buf)) |
| 3786 | return -EFAULT; |
| 3787 | |
| 3788 | if (copy_from_user(buf, user_buf, count)) |
| 3789 | return -EFAULT; |
| 3790 | |
| 3791 | buf[count] = 0; /* end of string */ |
| 3792 | |
| 3793 | if (kstrtoint(buf, 0, &disable_panic)) |
| 3794 | return -EFAULT; |
| 3795 | |
| 3796 | if (disable_panic) { |
| 3797 | /* Disable panic signal for all active pipes */ |
| 3798 | SDE_DEBUG("Disabling danger:\n"); |
| 3799 | _sde_plane_set_danger_state(kms, false); |
| 3800 | kms->has_danger_ctrl = false; |
| 3801 | } else { |
| 3802 | /* Enable panic signal for all active pipes */ |
| 3803 | SDE_DEBUG("Enabling danger:\n"); |
| 3804 | kms->has_danger_ctrl = true; |
| 3805 | _sde_plane_set_danger_state(kms, true); |
| 3806 | } |
| 3807 | |
| 3808 | return count; |
| 3809 | } |
| 3810 | |
| 3811 | static const struct file_operations sde_plane_danger_enable = { |
| 3812 | .open = simple_open, |
| 3813 | .read = _sde_plane_danger_read, |
| 3814 | .write = _sde_plane_danger_write, |
| 3815 | }; |
| 3816 | |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 3817 | static int _sde_plane_init_debugfs(struct drm_plane *plane) |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 3818 | { |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 3819 | struct sde_plane *psde; |
| 3820 | struct sde_kms *kms; |
| 3821 | struct msm_drm_private *priv; |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 3822 | const struct sde_sspp_sub_blks *sblk = 0; |
| 3823 | const struct sde_sspp_cfg *cfg = 0; |
| 3824 | |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 3825 | if (!plane || !plane->dev) { |
| 3826 | SDE_ERROR("invalid arguments\n"); |
| 3827 | return -EINVAL; |
| 3828 | } |
| 3829 | |
| 3830 | priv = plane->dev->dev_private; |
| 3831 | if (!priv || !priv->kms) { |
| 3832 | SDE_ERROR("invalid KMS reference\n"); |
| 3833 | return -EINVAL; |
| 3834 | } |
| 3835 | |
| 3836 | kms = to_sde_kms(priv->kms); |
| 3837 | psde = to_sde_plane(plane); |
| 3838 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 3839 | if (psde && psde->pipe_hw) |
| 3840 | cfg = psde->pipe_hw->cap; |
| 3841 | if (cfg) |
| 3842 | sblk = cfg->sblk; |
| 3843 | |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 3844 | if (!sblk) |
| 3845 | return 0; |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 3846 | |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 3847 | /* create overall sub-directory for the pipe */ |
| 3848 | psde->debugfs_root = |
| 3849 | debugfs_create_dir(psde->pipe_name, |
Lloyd Atkinson | 09e64bf | 2017-04-13 14:09:59 -0700 | [diff] [blame] | 3850 | plane->dev->primary->debugfs_root); |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 3851 | |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 3852 | if (!psde->debugfs_root) |
| 3853 | return -ENOMEM; |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 3854 | |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 3855 | /* don't error check these */ |
| 3856 | debugfs_create_x32("features", 0644, |
| 3857 | psde->debugfs_root, &psde->features); |
Alan Kwong | f0fd851 | 2016-10-24 21:39:26 -0400 | [diff] [blame] | 3858 | |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 3859 | /* add register dump support */ |
| 3860 | sde_debugfs_setup_regset32(&psde->debugfs_src, |
| 3861 | sblk->src_blk.base + cfg->base, |
| 3862 | sblk->src_blk.len, |
| 3863 | kms); |
| 3864 | sde_debugfs_create_regset32("src_blk", 0444, |
| 3865 | psde->debugfs_root, &psde->debugfs_src); |
Alan Kwong | f0fd851 | 2016-10-24 21:39:26 -0400 | [diff] [blame] | 3866 | |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 3867 | if (cfg->features & BIT(SDE_SSPP_SCALER_QSEED3) || |
| 3868 | cfg->features & BIT(SDE_SSPP_SCALER_QSEED2)) { |
| 3869 | sde_debugfs_setup_regset32(&psde->debugfs_scaler, |
| 3870 | sblk->scaler_blk.base + cfg->base, |
| 3871 | sblk->scaler_blk.len, |
| 3872 | kms); |
| 3873 | sde_debugfs_create_regset32("scaler_blk", 0444, |
| 3874 | psde->debugfs_root, |
| 3875 | &psde->debugfs_scaler); |
Clarence Ip | 716ab66 | 2017-03-20 06:51:24 -0700 | [diff] [blame] | 3876 | debugfs_create_bool("default_scaling", |
| 3877 | 0644, |
| 3878 | psde->debugfs_root, |
| 3879 | &psde->debugfs_default_scale); |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 3880 | } |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 3881 | |
| 3882 | if (cfg->features & BIT(SDE_SSPP_CSC) || |
| 3883 | cfg->features & BIT(SDE_SSPP_CSC_10BIT)) { |
| 3884 | sde_debugfs_setup_regset32(&psde->debugfs_csc, |
| 3885 | sblk->csc_blk.base + cfg->base, |
| 3886 | sblk->csc_blk.len, |
| 3887 | kms); |
| 3888 | sde_debugfs_create_regset32("csc_blk", 0444, |
| 3889 | psde->debugfs_root, &psde->debugfs_csc); |
| 3890 | } |
| 3891 | |
| 3892 | debugfs_create_u32("xin_id", |
| 3893 | 0444, |
| 3894 | psde->debugfs_root, |
| 3895 | (u32 *) &cfg->xin_id); |
| 3896 | debugfs_create_u32("clk_ctrl", |
| 3897 | 0444, |
| 3898 | psde->debugfs_root, |
| 3899 | (u32 *) &cfg->clk_ctrl); |
| 3900 | debugfs_create_x32("creq_vblank", |
| 3901 | 0644, |
| 3902 | psde->debugfs_root, |
| 3903 | (u32 *) &sblk->creq_vblank); |
| 3904 | debugfs_create_x32("danger_vblank", |
| 3905 | 0644, |
| 3906 | psde->debugfs_root, |
| 3907 | (u32 *) &sblk->danger_vblank); |
| 3908 | |
| 3909 | debugfs_create_file("disable_danger", |
| 3910 | 0644, |
| 3911 | psde->debugfs_root, |
| 3912 | kms, &sde_plane_danger_enable); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 3913 | debugfs_create_u32("sbuf_mode", |
| 3914 | 0644, |
| 3915 | psde->debugfs_root, &psde->sbuf_mode); |
| 3916 | debugfs_create_u32("sbuf_writeback", |
| 3917 | 0644, |
| 3918 | psde->debugfs_root, |
| 3919 | &psde->sbuf_writeback); |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 3920 | |
| 3921 | return 0; |
| 3922 | } |
| 3923 | |
| 3924 | static void _sde_plane_destroy_debugfs(struct drm_plane *plane) |
| 3925 | { |
| 3926 | struct sde_plane *psde; |
| 3927 | |
| 3928 | if (!plane) |
| 3929 | return; |
| 3930 | psde = to_sde_plane(plane); |
| 3931 | |
| 3932 | debugfs_remove_recursive(psde->debugfs_root); |
| 3933 | } |
| 3934 | #else |
| 3935 | static int _sde_plane_init_debugfs(struct drm_plane *plane) |
| 3936 | { |
| 3937 | return 0; |
| 3938 | } |
| 3939 | static void _sde_plane_destroy_debugfs(struct drm_plane *plane) |
| 3940 | { |
| 3941 | } |
| 3942 | #endif |
| 3943 | |
| 3944 | static int sde_plane_late_register(struct drm_plane *plane) |
| 3945 | { |
| 3946 | return _sde_plane_init_debugfs(plane); |
| 3947 | } |
| 3948 | |
| 3949 | static void sde_plane_early_unregister(struct drm_plane *plane) |
| 3950 | { |
| 3951 | _sde_plane_destroy_debugfs(plane); |
| 3952 | } |
| 3953 | |
| 3954 | static const struct drm_plane_funcs sde_plane_funcs = { |
| 3955 | .update_plane = drm_atomic_helper_update_plane, |
| 3956 | .disable_plane = drm_atomic_helper_disable_plane, |
| 3957 | .destroy = sde_plane_destroy, |
| 3958 | .set_property = sde_plane_set_property, |
| 3959 | .atomic_set_property = sde_plane_atomic_set_property, |
| 3960 | .atomic_get_property = sde_plane_atomic_get_property, |
| 3961 | .reset = sde_plane_reset, |
| 3962 | .atomic_duplicate_state = sde_plane_duplicate_state, |
| 3963 | .atomic_destroy_state = sde_plane_destroy_state, |
| 3964 | .late_register = sde_plane_late_register, |
| 3965 | .early_unregister = sde_plane_early_unregister, |
| 3966 | }; |
| 3967 | |
| 3968 | static const struct drm_plane_helper_funcs sde_plane_helper_funcs = { |
| 3969 | .prepare_fb = sde_plane_prepare_fb, |
| 3970 | .cleanup_fb = sde_plane_cleanup_fb, |
| 3971 | .atomic_check = sde_plane_atomic_check, |
| 3972 | .atomic_update = sde_plane_atomic_update, |
| 3973 | }; |
| 3974 | |
| 3975 | enum sde_sspp sde_plane_pipe(struct drm_plane *plane) |
| 3976 | { |
| 3977 | return plane ? to_sde_plane(plane)->pipe : SSPP_NONE; |
| 3978 | } |
| 3979 | |
| 3980 | bool is_sde_plane_virtual(struct drm_plane *plane) |
| 3981 | { |
| 3982 | return plane ? to_sde_plane(plane)->is_virtual : false; |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 3983 | } |
| 3984 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 3985 | /* initialize plane */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 3986 | struct drm_plane *sde_plane_init(struct drm_device *dev, |
Clarence Ip | 2bbf7b3 | 2016-09-23 15:07:16 -0400 | [diff] [blame] | 3987 | uint32_t pipe, bool primary_plane, |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 3988 | unsigned long possible_crtcs, u32 master_plane_id) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 3989 | { |
| 3990 | struct drm_plane *plane = NULL; |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 3991 | const struct sde_format_extended *format_list; |
Jeykumar Sankaran | f55e65b | 2017-05-10 21:46:14 -0700 | [diff] [blame] | 3992 | struct sde_format_extended *virt_format_list = NULL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3993 | struct sde_plane *psde; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 3994 | struct msm_drm_private *priv; |
| 3995 | struct sde_kms *kms; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 3996 | enum drm_plane_type type; |
Clarence Ip | c47a069 | 2016-10-11 10:54:17 -0400 | [diff] [blame] | 3997 | int ret = -EINVAL; |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 3998 | |
| 3999 | if (!dev) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 4000 | SDE_ERROR("[%u]device is NULL\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4001 | goto exit; |
| 4002 | } |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 4003 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 4004 | priv = dev->dev_private; |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 4005 | if (!priv) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 4006 | SDE_ERROR("[%u]private data is NULL\n", pipe); |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 4007 | goto exit; |
| 4008 | } |
| 4009 | |
| 4010 | if (!priv->kms) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 4011 | SDE_ERROR("[%u]invalid KMS reference\n", pipe); |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 4012 | goto exit; |
| 4013 | } |
| 4014 | kms = to_sde_kms(priv->kms); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 4015 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4016 | if (!kms->catalog) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 4017 | SDE_ERROR("[%u]invalid catalog reference\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4018 | goto exit; |
| 4019 | } |
| 4020 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 4021 | /* create and zero local structure */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 4022 | psde = kzalloc(sizeof(*psde), GFP_KERNEL); |
| 4023 | if (!psde) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 4024 | SDE_ERROR("[%u]failed to allocate local plane struct\n", pipe); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 4025 | ret = -ENOMEM; |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4026 | goto exit; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 4027 | } |
| 4028 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4029 | /* cache local stuff for later */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 4030 | plane = &psde->base; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 4031 | psde->pipe = pipe; |
Alan Kwong | 112a84f | 2016-05-24 20:49:21 -0400 | [diff] [blame] | 4032 | psde->mmu_id = kms->mmu_id[MSM_SMMU_DOMAIN_UNSECURE]; |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 4033 | psde->is_virtual = (master_plane_id != 0); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 4034 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4035 | /* initialize underlying h/w driver */ |
| 4036 | psde->pipe_hw = sde_hw_sspp_init(pipe, kms->mmio, kms->catalog); |
| 4037 | if (IS_ERR(psde->pipe_hw)) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 4038 | SDE_ERROR("[%u]SSPP init failed\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4039 | ret = PTR_ERR(psde->pipe_hw); |
| 4040 | goto clean_plane; |
| 4041 | } else if (!psde->pipe_hw->cap || !psde->pipe_hw->cap->sblk) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 4042 | SDE_ERROR("[%u]SSPP init returned invalid cfg\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4043 | goto clean_sspp; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 4044 | } |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4045 | |
| 4046 | /* cache features mask for later */ |
| 4047 | psde->features = psde->pipe_hw->cap->features; |
| 4048 | psde->pipe_sblk = psde->pipe_hw->cap->sblk; |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 4049 | if (!psde->pipe_sblk) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 4050 | SDE_ERROR("[%u]invalid sblk\n", pipe); |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 4051 | goto clean_sspp; |
| 4052 | } |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4053 | |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 4054 | if (psde->features & BIT(SDE_SSPP_SCALER_QSEED3)) { |
| 4055 | psde->scaler3_cfg = kzalloc(sizeof(struct sde_hw_scaler3_cfg), |
| 4056 | GFP_KERNEL); |
| 4057 | if (!psde->scaler3_cfg) { |
| 4058 | SDE_ERROR("[%u]failed to allocate scale struct\n", |
| 4059 | pipe); |
| 4060 | ret = -ENOMEM; |
| 4061 | goto clean_sspp; |
| 4062 | } |
| 4063 | } |
| 4064 | |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 4065 | format_list = psde->pipe_sblk->format_list; |
| 4066 | |
Jeykumar Sankaran | f55e65b | 2017-05-10 21:46:14 -0700 | [diff] [blame] | 4067 | if (master_plane_id) { |
| 4068 | int index, array_size; |
| 4069 | |
| 4070 | array_size = ARRAY_SIZE(plane_formats) |
| 4071 | + ARRAY_SIZE(rgb_10bit_formats); |
| 4072 | virt_format_list = kcalloc(array_size, |
| 4073 | sizeof(struct sde_format_extended), |
| 4074 | GFP_KERNEL); |
| 4075 | if (!virt_format_list) { |
| 4076 | SDE_ERROR( |
| 4077 | "failed to allocate virtual pipe format list\n"); |
| 4078 | goto clean_sspp; |
| 4079 | } |
| 4080 | |
| 4081 | index = sde_copy_formats(virt_format_list, array_size, |
| 4082 | 0, plane_formats, ARRAY_SIZE(plane_formats)); |
| 4083 | sde_copy_formats(virt_format_list, array_size, |
| 4084 | index, rgb_10bit_formats, |
| 4085 | ARRAY_SIZE(rgb_10bit_formats)); |
| 4086 | |
| 4087 | format_list = virt_format_list; |
| 4088 | } |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 4089 | |
Jeykumar Sankaran | 6d34314 | 2017-03-15 18:41:10 -0700 | [diff] [blame] | 4090 | psde->nformats = sde_populate_formats(format_list, |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 4091 | psde->formats, |
| 4092 | 0, |
| 4093 | ARRAY_SIZE(psde->formats)); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 4094 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4095 | if (!psde->nformats) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 4096 | SDE_ERROR("[%u]no valid formats for plane\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4097 | goto clean_sspp; |
| 4098 | } |
| 4099 | |
| 4100 | if (psde->features & BIT(SDE_SSPP_CURSOR)) |
| 4101 | type = DRM_PLANE_TYPE_CURSOR; |
| 4102 | else if (primary_plane) |
| 4103 | type = DRM_PLANE_TYPE_PRIMARY; |
| 4104 | else |
| 4105 | type = DRM_PLANE_TYPE_OVERLAY; |
Dhaval Patel | 04c7e8e | 2016-09-26 20:14:31 -0700 | [diff] [blame] | 4106 | ret = drm_universal_plane_init(dev, plane, 0xff, &sde_plane_funcs, |
| 4107 | psde->formats, psde->nformats, |
| 4108 | type, NULL); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 4109 | if (ret) |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4110 | goto clean_sspp; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 4111 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4112 | /* success! finalize initialization */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 4113 | drm_plane_helper_add(plane, &sde_plane_helper_funcs); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 4114 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 4115 | msm_property_init(&psde->property_info, &plane->base, dev, |
| 4116 | priv->plane_property, psde->property_data, |
| 4117 | PLANE_PROP_COUNT, PLANE_PROP_BLOBCOUNT, |
| 4118 | sizeof(struct sde_plane_state)); |
| 4119 | |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 4120 | _sde_plane_install_properties(plane, kms->catalog, master_plane_id); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 4121 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 4122 | /* save user friendly pipe name for later */ |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 4123 | snprintf(psde->pipe_name, SDE_NAME_SIZE, "plane%u", plane->base.id); |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 4124 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 4125 | mutex_init(&psde->lock); |
| 4126 | |
Dhaval Patel | 82c8dbc | 2017-02-18 23:15:10 -0800 | [diff] [blame] | 4127 | SDE_DEBUG("%s created for pipe %u\n", psde->pipe_name, pipe); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 4128 | return plane; |
| 4129 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4130 | clean_sspp: |
| 4131 | if (psde && psde->pipe_hw) |
| 4132 | sde_hw_sspp_destroy(psde->pipe_hw); |
abeykun | 48f407a | 2016-08-25 12:06:44 -0400 | [diff] [blame] | 4133 | |
| 4134 | if (psde && psde->scaler3_cfg) |
| 4135 | kfree(psde->scaler3_cfg); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 4136 | clean_plane: |
| 4137 | kfree(psde); |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 4138 | exit: |
Jeykumar Sankaran | f55e65b | 2017-05-10 21:46:14 -0700 | [diff] [blame] | 4139 | kfree(virt_format_list); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 4140 | return ERR_PTR(ret); |
| 4141 | } |