| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. |
|---|
| 2 | | - * |
|---|
| 3 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 4 | | - * it under the terms of the GNU General Public License version 2 and |
|---|
| 5 | | - * only version 2 as published by the Free Software Foundation. |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 8 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 9 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 10 | | - * GNU General Public License for more details. |
|---|
| 11 | 3 | */ |
|---|
| 12 | 4 | |
|---|
| 13 | 5 | #define pr_fmt(fmt) "[drm:%s:%d] " fmt, __func__, __LINE__ |
|---|
| .. | .. |
|---|
| 18 | 10 | #include "dpu_trace.h" |
|---|
| 19 | 11 | |
|---|
| 20 | 12 | #define DPU_DEBUG_VIDENC(e, fmt, ...) DPU_DEBUG("enc%d intf%d " fmt, \ |
|---|
| 21 | | - (e) && (e)->base.parent ? \ |
|---|
| 22 | | - (e)->base.parent->base.id : -1, \ |
|---|
| 13 | + (e) && (e)->parent ? \ |
|---|
| 14 | + (e)->parent->base.id : -1, \ |
|---|
| 23 | 15 | (e) && (e)->hw_intf ? \ |
|---|
| 24 | 16 | (e)->hw_intf->idx - INTF_0 : -1, ##__VA_ARGS__) |
|---|
| 25 | 17 | |
|---|
| 26 | 18 | #define DPU_ERROR_VIDENC(e, fmt, ...) DPU_ERROR("enc%d intf%d " fmt, \ |
|---|
| 27 | | - (e) && (e)->base.parent ? \ |
|---|
| 28 | | - (e)->base.parent->base.id : -1, \ |
|---|
| 19 | + (e) && (e)->parent ? \ |
|---|
| 20 | + (e)->parent->base.id : -1, \ |
|---|
| 29 | 21 | (e) && (e)->hw_intf ? \ |
|---|
| 30 | 22 | (e)->hw_intf->idx - INTF_0 : -1, ##__VA_ARGS__) |
|---|
| 31 | 23 | |
|---|
| .. | .. |
|---|
| 44 | 36 | } |
|---|
| 45 | 37 | |
|---|
| 46 | 38 | static void drm_mode_to_intf_timing_params( |
|---|
| 47 | | - const struct dpu_encoder_phys_vid *vid_enc, |
|---|
| 39 | + const struct dpu_encoder_phys *phys_enc, |
|---|
| 48 | 40 | const struct drm_display_mode *mode, |
|---|
| 49 | 41 | struct intf_timing_params *timing) |
|---|
| 50 | 42 | { |
|---|
| .. | .. |
|---|
| 92 | 84 | timing->hsync_skew = mode->hskew; |
|---|
| 93 | 85 | |
|---|
| 94 | 86 | /* DSI controller cannot handle active-low sync signals. */ |
|---|
| 95 | | - if (vid_enc->hw_intf->cap->type == INTF_DSI) { |
|---|
| 87 | + if (phys_enc->hw_intf->cap->type == INTF_DSI) { |
|---|
| 96 | 88 | timing->hsync_polarity = 0; |
|---|
| 97 | 89 | timing->vsync_polarity = 0; |
|---|
| 98 | 90 | } |
|---|
| .. | .. |
|---|
| 108 | 100 | * display_v_end -= mode->hsync_start - mode->hdisplay; |
|---|
| 109 | 101 | * } |
|---|
| 110 | 102 | */ |
|---|
| 103 | + /* for DP/EDP, Shift timings to align it to bottom right */ |
|---|
| 104 | + if ((phys_enc->hw_intf->cap->type == INTF_DP) || |
|---|
| 105 | + (phys_enc->hw_intf->cap->type == INTF_EDP)) { |
|---|
| 106 | + timing->h_back_porch += timing->h_front_porch; |
|---|
| 107 | + timing->h_front_porch = 0; |
|---|
| 108 | + timing->v_back_porch += timing->v_front_porch; |
|---|
| 109 | + timing->v_front_porch = 0; |
|---|
| 110 | + } |
|---|
| 111 | 111 | } |
|---|
| 112 | 112 | |
|---|
| 113 | | -static inline u32 get_horizontal_total(const struct intf_timing_params *timing) |
|---|
| 113 | +static u32 get_horizontal_total(const struct intf_timing_params *timing) |
|---|
| 114 | 114 | { |
|---|
| 115 | 115 | u32 active = timing->xres; |
|---|
| 116 | 116 | u32 inactive = |
|---|
| .. | .. |
|---|
| 119 | 119 | return active + inactive; |
|---|
| 120 | 120 | } |
|---|
| 121 | 121 | |
|---|
| 122 | | -static inline u32 get_vertical_total(const struct intf_timing_params *timing) |
|---|
| 122 | +static u32 get_vertical_total(const struct intf_timing_params *timing) |
|---|
| 123 | 123 | { |
|---|
| 124 | 124 | u32 active = timing->yres; |
|---|
| 125 | 125 | u32 inactive = |
|---|
| .. | .. |
|---|
| 143 | 143 | * lines based on the chip worst case latencies. |
|---|
| 144 | 144 | */ |
|---|
| 145 | 145 | static u32 programmable_fetch_get_num_lines( |
|---|
| 146 | | - struct dpu_encoder_phys_vid *vid_enc, |
|---|
| 146 | + struct dpu_encoder_phys *phys_enc, |
|---|
| 147 | 147 | const struct intf_timing_params *timing) |
|---|
| 148 | 148 | { |
|---|
| 149 | 149 | u32 worst_case_needed_lines = |
|---|
| 150 | | - vid_enc->hw_intf->cap->prog_fetch_lines_worst_case; |
|---|
| 150 | + phys_enc->hw_intf->cap->prog_fetch_lines_worst_case; |
|---|
| 151 | 151 | u32 start_of_frame_lines = |
|---|
| 152 | 152 | timing->v_back_porch + timing->vsync_pulse_width; |
|---|
| 153 | 153 | u32 needed_vfp_lines = worst_case_needed_lines - start_of_frame_lines; |
|---|
| .. | .. |
|---|
| 155 | 155 | |
|---|
| 156 | 156 | /* Fetch must be outside active lines, otherwise undefined. */ |
|---|
| 157 | 157 | if (start_of_frame_lines >= worst_case_needed_lines) { |
|---|
| 158 | | - DPU_DEBUG_VIDENC(vid_enc, |
|---|
| 158 | + DPU_DEBUG_VIDENC(phys_enc, |
|---|
| 159 | 159 | "prog fetch is not needed, large vbp+vsw\n"); |
|---|
| 160 | 160 | actual_vfp_lines = 0; |
|---|
| 161 | 161 | } else if (timing->v_front_porch < needed_vfp_lines) { |
|---|
| 162 | 162 | /* Warn fetch needed, but not enough porch in panel config */ |
|---|
| 163 | 163 | pr_warn_once |
|---|
| 164 | 164 | ("low vbp+vfp may lead to perf issues in some cases\n"); |
|---|
| 165 | | - DPU_DEBUG_VIDENC(vid_enc, |
|---|
| 165 | + DPU_DEBUG_VIDENC(phys_enc, |
|---|
| 166 | 166 | "less vfp than fetch req, using entire vfp\n"); |
|---|
| 167 | 167 | actual_vfp_lines = timing->v_front_porch; |
|---|
| 168 | 168 | } else { |
|---|
| 169 | | - DPU_DEBUG_VIDENC(vid_enc, "room in vfp for needed prefetch\n"); |
|---|
| 169 | + DPU_DEBUG_VIDENC(phys_enc, "room in vfp for needed prefetch\n"); |
|---|
| 170 | 170 | actual_vfp_lines = needed_vfp_lines; |
|---|
| 171 | 171 | } |
|---|
| 172 | 172 | |
|---|
| 173 | | - DPU_DEBUG_VIDENC(vid_enc, |
|---|
| 173 | + DPU_DEBUG_VIDENC(phys_enc, |
|---|
| 174 | 174 | "v_front_porch %u v_back_porch %u vsync_pulse_width %u\n", |
|---|
| 175 | 175 | timing->v_front_porch, timing->v_back_porch, |
|---|
| 176 | 176 | timing->vsync_pulse_width); |
|---|
| 177 | | - DPU_DEBUG_VIDENC(vid_enc, |
|---|
| 177 | + DPU_DEBUG_VIDENC(phys_enc, |
|---|
| 178 | 178 | "wc_lines %u needed_vfp_lines %u actual_vfp_lines %u\n", |
|---|
| 179 | 179 | worst_case_needed_lines, needed_vfp_lines, actual_vfp_lines); |
|---|
| 180 | 180 | |
|---|
| .. | .. |
|---|
| 194 | 194 | static void programmable_fetch_config(struct dpu_encoder_phys *phys_enc, |
|---|
| 195 | 195 | const struct intf_timing_params *timing) |
|---|
| 196 | 196 | { |
|---|
| 197 | | - struct dpu_encoder_phys_vid *vid_enc = |
|---|
| 198 | | - to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 199 | 197 | struct intf_prog_fetch f = { 0 }; |
|---|
| 200 | 198 | u32 vfp_fetch_lines = 0; |
|---|
| 201 | 199 | u32 horiz_total = 0; |
|---|
| .. | .. |
|---|
| 203 | 201 | u32 vfp_fetch_start_vsync_counter = 0; |
|---|
| 204 | 202 | unsigned long lock_flags; |
|---|
| 205 | 203 | |
|---|
| 206 | | - if (WARN_ON_ONCE(!vid_enc->hw_intf->ops.setup_prg_fetch)) |
|---|
| 204 | + if (WARN_ON_ONCE(!phys_enc->hw_intf->ops.setup_prg_fetch)) |
|---|
| 207 | 205 | return; |
|---|
| 208 | 206 | |
|---|
| 209 | | - vfp_fetch_lines = programmable_fetch_get_num_lines(vid_enc, timing); |
|---|
| 207 | + vfp_fetch_lines = programmable_fetch_get_num_lines(phys_enc, timing); |
|---|
| 210 | 208 | if (vfp_fetch_lines) { |
|---|
| 211 | 209 | vert_total = get_vertical_total(timing); |
|---|
| 212 | 210 | horiz_total = get_horizontal_total(timing); |
|---|
| .. | .. |
|---|
| 216 | 214 | f.fetch_start = vfp_fetch_start_vsync_counter; |
|---|
| 217 | 215 | } |
|---|
| 218 | 216 | |
|---|
| 219 | | - DPU_DEBUG_VIDENC(vid_enc, |
|---|
| 217 | + DPU_DEBUG_VIDENC(phys_enc, |
|---|
| 220 | 218 | "vfp_fetch_lines %u vfp_fetch_start_vsync_counter %u\n", |
|---|
| 221 | 219 | vfp_fetch_lines, vfp_fetch_start_vsync_counter); |
|---|
| 222 | 220 | |
|---|
| 223 | 221 | spin_lock_irqsave(phys_enc->enc_spinlock, lock_flags); |
|---|
| 224 | | - vid_enc->hw_intf->ops.setup_prg_fetch(vid_enc->hw_intf, &f); |
|---|
| 222 | + phys_enc->hw_intf->ops.setup_prg_fetch(phys_enc->hw_intf, &f); |
|---|
| 225 | 223 | spin_unlock_irqrestore(phys_enc->enc_spinlock, lock_flags); |
|---|
| 226 | 224 | } |
|---|
| 227 | 225 | |
|---|
| .. | .. |
|---|
| 230 | 228 | const struct drm_display_mode *mode, |
|---|
| 231 | 229 | struct drm_display_mode *adj_mode) |
|---|
| 232 | 230 | { |
|---|
| 233 | | - if (phys_enc) |
|---|
| 234 | | - DPU_DEBUG_VIDENC(to_dpu_encoder_phys_vid(phys_enc), "\n"); |
|---|
| 231 | + DPU_DEBUG_VIDENC(phys_enc, "\n"); |
|---|
| 235 | 232 | |
|---|
| 236 | 233 | /* |
|---|
| 237 | 234 | * Modifying mode has consequences when the mode comes back to us |
|---|
| .. | .. |
|---|
| 242 | 239 | static void dpu_encoder_phys_vid_setup_timing_engine( |
|---|
| 243 | 240 | struct dpu_encoder_phys *phys_enc) |
|---|
| 244 | 241 | { |
|---|
| 245 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 246 | 242 | struct drm_display_mode mode; |
|---|
| 247 | 243 | struct intf_timing_params timing_params = { 0 }; |
|---|
| 248 | 244 | const struct dpu_format *fmt = NULL; |
|---|
| .. | .. |
|---|
| 250 | 246 | unsigned long lock_flags; |
|---|
| 251 | 247 | struct dpu_hw_intf_cfg intf_cfg = { 0 }; |
|---|
| 252 | 248 | |
|---|
| 253 | | - if (!phys_enc || !phys_enc->hw_ctl->ops.setup_intf_cfg) { |
|---|
| 254 | | - DPU_ERROR("invalid encoder %d\n", phys_enc != 0); |
|---|
| 249 | + if (!phys_enc->hw_ctl->ops.setup_intf_cfg) { |
|---|
| 250 | + DPU_ERROR("invalid encoder %d\n", phys_enc != NULL); |
|---|
| 255 | 251 | return; |
|---|
| 256 | 252 | } |
|---|
| 257 | 253 | |
|---|
| 258 | 254 | mode = phys_enc->cached_mode; |
|---|
| 259 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 260 | | - if (!vid_enc->hw_intf->ops.setup_timing_gen) { |
|---|
| 255 | + if (!phys_enc->hw_intf->ops.setup_timing_gen) { |
|---|
| 261 | 256 | DPU_ERROR("timing engine setup is not supported\n"); |
|---|
| 262 | 257 | return; |
|---|
| 263 | 258 | } |
|---|
| 264 | 259 | |
|---|
| 265 | | - DPU_DEBUG_VIDENC(vid_enc, "enabling mode:\n"); |
|---|
| 260 | + DPU_DEBUG_VIDENC(phys_enc, "enabling mode:\n"); |
|---|
| 266 | 261 | drm_mode_debug_printmodeline(&mode); |
|---|
| 267 | 262 | |
|---|
| 268 | 263 | if (phys_enc->split_role != ENC_ROLE_SOLO) { |
|---|
| .. | .. |
|---|
| 271 | 266 | mode.hsync_start >>= 1; |
|---|
| 272 | 267 | mode.hsync_end >>= 1; |
|---|
| 273 | 268 | |
|---|
| 274 | | - DPU_DEBUG_VIDENC(vid_enc, |
|---|
| 269 | + DPU_DEBUG_VIDENC(phys_enc, |
|---|
| 275 | 270 | "split_role %d, halve horizontal %d %d %d %d\n", |
|---|
| 276 | 271 | phys_enc->split_role, |
|---|
| 277 | 272 | mode.hdisplay, mode.htotal, |
|---|
| 278 | 273 | mode.hsync_start, mode.hsync_end); |
|---|
| 279 | 274 | } |
|---|
| 280 | 275 | |
|---|
| 281 | | - drm_mode_to_intf_timing_params(vid_enc, &mode, &timing_params); |
|---|
| 276 | + drm_mode_to_intf_timing_params(phys_enc, &mode, &timing_params); |
|---|
| 282 | 277 | |
|---|
| 283 | 278 | fmt = dpu_get_dpu_format(fmt_fourcc); |
|---|
| 284 | | - DPU_DEBUG_VIDENC(vid_enc, "fmt_fourcc 0x%X\n", fmt_fourcc); |
|---|
| 279 | + DPU_DEBUG_VIDENC(phys_enc, "fmt_fourcc 0x%X\n", fmt_fourcc); |
|---|
| 285 | 280 | |
|---|
| 286 | | - intf_cfg.intf = vid_enc->hw_intf->idx; |
|---|
| 281 | + intf_cfg.intf = phys_enc->hw_intf->idx; |
|---|
| 287 | 282 | intf_cfg.intf_mode_sel = DPU_CTL_MODE_SEL_VID; |
|---|
| 288 | 283 | intf_cfg.stream_sel = 0; /* Don't care value for video mode */ |
|---|
| 289 | 284 | intf_cfg.mode_3d = dpu_encoder_helper_get_3d_blend_mode(phys_enc); |
|---|
| 290 | 285 | |
|---|
| 291 | 286 | spin_lock_irqsave(phys_enc->enc_spinlock, lock_flags); |
|---|
| 292 | | - vid_enc->hw_intf->ops.setup_timing_gen(vid_enc->hw_intf, |
|---|
| 287 | + phys_enc->hw_intf->ops.setup_timing_gen(phys_enc->hw_intf, |
|---|
| 293 | 288 | &timing_params, fmt); |
|---|
| 294 | 289 | phys_enc->hw_ctl->ops.setup_intf_cfg(phys_enc->hw_ctl, &intf_cfg); |
|---|
| 290 | + |
|---|
| 291 | + /* setup which pp blk will connect to this intf */ |
|---|
| 292 | + if (phys_enc->hw_intf->ops.bind_pingpong_blk) |
|---|
| 293 | + phys_enc->hw_intf->ops.bind_pingpong_blk( |
|---|
| 294 | + phys_enc->hw_intf, |
|---|
| 295 | + true, |
|---|
| 296 | + phys_enc->hw_pp->idx); |
|---|
| 297 | + |
|---|
| 295 | 298 | spin_unlock_irqrestore(phys_enc->enc_spinlock, lock_flags); |
|---|
| 296 | 299 | |
|---|
| 297 | 300 | programmable_fetch_config(phys_enc, &timing_params); |
|---|
| 298 | | - |
|---|
| 299 | | - vid_enc->timing_params = timing_params; |
|---|
| 300 | 301 | } |
|---|
| 301 | 302 | |
|---|
| 302 | 303 | static void dpu_encoder_phys_vid_vblank_irq(void *arg, int irq_idx) |
|---|
| .. | .. |
|---|
| 305 | 306 | struct dpu_hw_ctl *hw_ctl; |
|---|
| 306 | 307 | unsigned long lock_flags; |
|---|
| 307 | 308 | u32 flush_register = 0; |
|---|
| 308 | | - int new_cnt = -1, old_cnt = -1; |
|---|
| 309 | | - |
|---|
| 310 | | - if (!phys_enc) |
|---|
| 311 | | - return; |
|---|
| 312 | 309 | |
|---|
| 313 | 310 | hw_ctl = phys_enc->hw_ctl; |
|---|
| 314 | | - if (!hw_ctl) |
|---|
| 315 | | - return; |
|---|
| 316 | 311 | |
|---|
| 317 | 312 | DPU_ATRACE_BEGIN("vblank_irq"); |
|---|
| 318 | 313 | |
|---|
| .. | .. |
|---|
| 320 | 315 | phys_enc->parent_ops->handle_vblank_virt(phys_enc->parent, |
|---|
| 321 | 316 | phys_enc); |
|---|
| 322 | 317 | |
|---|
| 323 | | - old_cnt = atomic_read(&phys_enc->pending_kickoff_cnt); |
|---|
| 318 | + atomic_read(&phys_enc->pending_kickoff_cnt); |
|---|
| 324 | 319 | |
|---|
| 325 | 320 | /* |
|---|
| 326 | 321 | * only decrement the pending flush count if we've actually flushed |
|---|
| .. | .. |
|---|
| 328 | 323 | * so we need to double-check with hw that it accepted the flush bits |
|---|
| 329 | 324 | */ |
|---|
| 330 | 325 | spin_lock_irqsave(phys_enc->enc_spinlock, lock_flags); |
|---|
| 331 | | - if (hw_ctl && hw_ctl->ops.get_flush_register) |
|---|
| 326 | + if (hw_ctl->ops.get_flush_register) |
|---|
| 332 | 327 | flush_register = hw_ctl->ops.get_flush_register(hw_ctl); |
|---|
| 333 | 328 | |
|---|
| 334 | 329 | if (!(flush_register & hw_ctl->ops.get_pending_flush(hw_ctl))) |
|---|
| 335 | | - new_cnt = atomic_add_unless(&phys_enc->pending_kickoff_cnt, |
|---|
| 336 | | - -1, 0); |
|---|
| 330 | + atomic_add_unless(&phys_enc->pending_kickoff_cnt, -1, 0); |
|---|
| 337 | 331 | spin_unlock_irqrestore(phys_enc->enc_spinlock, lock_flags); |
|---|
| 338 | 332 | |
|---|
| 339 | 333 | /* Signal any waiting atomic commit thread */ |
|---|
| 340 | 334 | wake_up_all(&phys_enc->pending_kickoff_wq); |
|---|
| 335 | + |
|---|
| 336 | + phys_enc->parent_ops->handle_frame_done(phys_enc->parent, phys_enc, |
|---|
| 337 | + DPU_ENCODER_FRAME_EVENT_DONE); |
|---|
| 338 | + |
|---|
| 341 | 339 | DPU_ATRACE_END("vblank_irq"); |
|---|
| 342 | 340 | } |
|---|
| 343 | 341 | |
|---|
| .. | .. |
|---|
| 345 | 343 | { |
|---|
| 346 | 344 | struct dpu_encoder_phys *phys_enc = arg; |
|---|
| 347 | 345 | |
|---|
| 348 | | - if (!phys_enc) |
|---|
| 349 | | - return; |
|---|
| 350 | | - |
|---|
| 351 | 346 | if (phys_enc->parent_ops->handle_underrun_virt) |
|---|
| 352 | 347 | phys_enc->parent_ops->handle_underrun_virt(phys_enc->parent, |
|---|
| 353 | 348 | phys_enc); |
|---|
| 354 | 349 | } |
|---|
| 355 | 350 | |
|---|
| 356 | | -static bool _dpu_encoder_phys_is_dual_ctl(struct dpu_encoder_phys *phys_enc) |
|---|
| 357 | | -{ |
|---|
| 358 | | - if (!phys_enc) |
|---|
| 359 | | - return false; |
|---|
| 360 | | - |
|---|
| 361 | | - if (phys_enc->topology_name == DPU_RM_TOPOLOGY_DUALPIPE) |
|---|
| 362 | | - return true; |
|---|
| 363 | | - |
|---|
| 364 | | - return false; |
|---|
| 365 | | -} |
|---|
| 366 | | - |
|---|
| 367 | 351 | static bool dpu_encoder_phys_vid_needs_single_flush( |
|---|
| 368 | 352 | struct dpu_encoder_phys *phys_enc) |
|---|
| 369 | 353 | { |
|---|
| 370 | | - return (phys_enc && _dpu_encoder_phys_is_dual_ctl(phys_enc)); |
|---|
| 354 | + return phys_enc->split_role != ENC_ROLE_SOLO; |
|---|
| 371 | 355 | } |
|---|
| 372 | 356 | |
|---|
| 373 | 357 | static void _dpu_encoder_phys_vid_setup_irq_hw_idx( |
|---|
| .. | .. |
|---|
| 395 | 379 | struct drm_display_mode *mode, |
|---|
| 396 | 380 | struct drm_display_mode *adj_mode) |
|---|
| 397 | 381 | { |
|---|
| 398 | | - struct dpu_rm *rm; |
|---|
| 399 | | - struct dpu_rm_hw_iter iter; |
|---|
| 400 | | - int i, instance; |
|---|
| 401 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 402 | | - |
|---|
| 403 | | - if (!phys_enc || !phys_enc->dpu_kms) { |
|---|
| 404 | | - DPU_ERROR("invalid encoder/kms\n"); |
|---|
| 405 | | - return; |
|---|
| 406 | | - } |
|---|
| 407 | | - |
|---|
| 408 | | - rm = &phys_enc->dpu_kms->rm; |
|---|
| 409 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 410 | | - |
|---|
| 411 | 382 | if (adj_mode) { |
|---|
| 412 | 383 | phys_enc->cached_mode = *adj_mode; |
|---|
| 413 | 384 | drm_mode_debug_printmodeline(adj_mode); |
|---|
| 414 | | - DPU_DEBUG_VIDENC(vid_enc, "caching mode:\n"); |
|---|
| 415 | | - } |
|---|
| 416 | | - |
|---|
| 417 | | - instance = phys_enc->split_role == ENC_ROLE_SLAVE ? 1 : 0; |
|---|
| 418 | | - |
|---|
| 419 | | - /* Retrieve previously allocated HW Resources. Shouldn't fail */ |
|---|
| 420 | | - dpu_rm_init_hw_iter(&iter, phys_enc->parent->base.id, DPU_HW_BLK_CTL); |
|---|
| 421 | | - for (i = 0; i <= instance; i++) { |
|---|
| 422 | | - if (dpu_rm_get_hw(rm, &iter)) |
|---|
| 423 | | - phys_enc->hw_ctl = (struct dpu_hw_ctl *)iter.hw; |
|---|
| 424 | | - } |
|---|
| 425 | | - if (IS_ERR_OR_NULL(phys_enc->hw_ctl)) { |
|---|
| 426 | | - DPU_ERROR_VIDENC(vid_enc, "failed to init ctl, %ld\n", |
|---|
| 427 | | - PTR_ERR(phys_enc->hw_ctl)); |
|---|
| 428 | | - phys_enc->hw_ctl = NULL; |
|---|
| 429 | | - return; |
|---|
| 385 | + DPU_DEBUG_VIDENC(phys_enc, "caching mode:\n"); |
|---|
| 430 | 386 | } |
|---|
| 431 | 387 | |
|---|
| 432 | 388 | _dpu_encoder_phys_vid_setup_irq_hw_idx(phys_enc); |
|---|
| .. | .. |
|---|
| 437 | 393 | bool enable) |
|---|
| 438 | 394 | { |
|---|
| 439 | 395 | int ret = 0; |
|---|
| 440 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 441 | 396 | int refcount; |
|---|
| 442 | 397 | |
|---|
| 443 | | - if (!phys_enc) { |
|---|
| 444 | | - DPU_ERROR("invalid encoder\n"); |
|---|
| 445 | | - return -EINVAL; |
|---|
| 446 | | - } |
|---|
| 447 | | - |
|---|
| 448 | 398 | refcount = atomic_read(&phys_enc->vblank_refcount); |
|---|
| 449 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 450 | 399 | |
|---|
| 451 | 400 | /* Slave encoders don't report vblank */ |
|---|
| 452 | 401 | if (!dpu_encoder_phys_vid_is_master(phys_enc)) |
|---|
| .. | .. |
|---|
| 471 | 420 | if (ret) { |
|---|
| 472 | 421 | DRM_ERROR("failed: id:%u intf:%d ret:%d enable:%d refcnt:%d\n", |
|---|
| 473 | 422 | DRMID(phys_enc->parent), |
|---|
| 474 | | - vid_enc->hw_intf->idx - INTF_0, ret, enable, |
|---|
| 423 | + phys_enc->hw_intf->idx - INTF_0, ret, enable, |
|---|
| 475 | 424 | refcount); |
|---|
| 476 | 425 | } |
|---|
| 477 | 426 | return ret; |
|---|
| .. | .. |
|---|
| 479 | 428 | |
|---|
| 480 | 429 | static void dpu_encoder_phys_vid_enable(struct dpu_encoder_phys *phys_enc) |
|---|
| 481 | 430 | { |
|---|
| 482 | | - struct msm_drm_private *priv; |
|---|
| 483 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 484 | | - struct dpu_hw_intf *intf; |
|---|
| 485 | 431 | struct dpu_hw_ctl *ctl; |
|---|
| 486 | 432 | u32 flush_mask = 0; |
|---|
| 433 | + u32 intf_flush_mask = 0; |
|---|
| 487 | 434 | |
|---|
| 488 | | - if (!phys_enc || !phys_enc->parent || !phys_enc->parent->dev || |
|---|
| 489 | | - !phys_enc->parent->dev->dev_private) { |
|---|
| 490 | | - DPU_ERROR("invalid encoder/device\n"); |
|---|
| 491 | | - return; |
|---|
| 492 | | - } |
|---|
| 493 | | - priv = phys_enc->parent->dev->dev_private; |
|---|
| 494 | | - |
|---|
| 495 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 496 | | - intf = vid_enc->hw_intf; |
|---|
| 497 | 435 | ctl = phys_enc->hw_ctl; |
|---|
| 498 | | - if (!vid_enc->hw_intf || !phys_enc->hw_ctl) { |
|---|
| 499 | | - DPU_ERROR("invalid hw_intf %d hw_ctl %d\n", |
|---|
| 500 | | - vid_enc->hw_intf != 0, phys_enc->hw_ctl != 0); |
|---|
| 501 | | - return; |
|---|
| 502 | | - } |
|---|
| 503 | 436 | |
|---|
| 504 | | - DPU_DEBUG_VIDENC(vid_enc, "\n"); |
|---|
| 437 | + DPU_DEBUG_VIDENC(phys_enc, "\n"); |
|---|
| 505 | 438 | |
|---|
| 506 | | - if (WARN_ON(!vid_enc->hw_intf->ops.enable_timing)) |
|---|
| 439 | + if (WARN_ON(!phys_enc->hw_intf->ops.enable_timing)) |
|---|
| 507 | 440 | return; |
|---|
| 508 | 441 | |
|---|
| 509 | | - dpu_encoder_helper_split_config(phys_enc, vid_enc->hw_intf->idx); |
|---|
| 442 | + dpu_encoder_helper_split_config(phys_enc, phys_enc->hw_intf->idx); |
|---|
| 510 | 443 | |
|---|
| 511 | 444 | dpu_encoder_phys_vid_setup_timing_engine(phys_enc); |
|---|
| 512 | 445 | |
|---|
| .. | .. |
|---|
| 519 | 452 | !dpu_encoder_phys_vid_is_master(phys_enc)) |
|---|
| 520 | 453 | goto skip_flush; |
|---|
| 521 | 454 | |
|---|
| 522 | | - ctl->ops.get_bitmask_intf(ctl, &flush_mask, intf->idx); |
|---|
| 455 | + ctl->ops.get_bitmask_intf(ctl, &flush_mask, phys_enc->hw_intf->idx); |
|---|
| 523 | 456 | ctl->ops.update_pending_flush(ctl, flush_mask); |
|---|
| 524 | 457 | |
|---|
| 458 | + if (ctl->ops.get_bitmask_active_intf) |
|---|
| 459 | + ctl->ops.get_bitmask_active_intf(ctl, &intf_flush_mask, |
|---|
| 460 | + phys_enc->hw_intf->idx); |
|---|
| 461 | + |
|---|
| 462 | + if (ctl->ops.update_pending_intf_flush) |
|---|
| 463 | + ctl->ops.update_pending_intf_flush(ctl, intf_flush_mask); |
|---|
| 464 | + |
|---|
| 525 | 465 | skip_flush: |
|---|
| 526 | | - DPU_DEBUG_VIDENC(vid_enc, "update pending flush ctl %d flush_mask %x\n", |
|---|
| 527 | | - ctl->idx - CTL_0, flush_mask); |
|---|
| 466 | + DPU_DEBUG_VIDENC(phys_enc, |
|---|
| 467 | + "update pending flush ctl %d flush_mask 0%x intf_mask 0x%x\n", |
|---|
| 468 | + ctl->idx - CTL_0, flush_mask, intf_flush_mask); |
|---|
| 469 | + |
|---|
| 528 | 470 | |
|---|
| 529 | 471 | /* ctl_flush & timing engine enable will be triggered by framework */ |
|---|
| 530 | 472 | if (phys_enc->enable_state == DPU_ENC_DISABLED) |
|---|
| .. | .. |
|---|
| 533 | 475 | |
|---|
| 534 | 476 | static void dpu_encoder_phys_vid_destroy(struct dpu_encoder_phys *phys_enc) |
|---|
| 535 | 477 | { |
|---|
| 536 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 537 | | - |
|---|
| 538 | | - if (!phys_enc) { |
|---|
| 539 | | - DPU_ERROR("invalid encoder\n"); |
|---|
| 540 | | - return; |
|---|
| 541 | | - } |
|---|
| 542 | | - |
|---|
| 543 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 544 | | - DPU_DEBUG_VIDENC(vid_enc, "\n"); |
|---|
| 545 | | - kfree(vid_enc); |
|---|
| 478 | + DPU_DEBUG_VIDENC(phys_enc, "\n"); |
|---|
| 479 | + kfree(phys_enc); |
|---|
| 546 | 480 | } |
|---|
| 547 | 481 | |
|---|
| 548 | 482 | static void dpu_encoder_phys_vid_get_hw_resources( |
|---|
| 549 | 483 | struct dpu_encoder_phys *phys_enc, |
|---|
| 550 | | - struct dpu_encoder_hw_resources *hw_res, |
|---|
| 551 | | - struct drm_connector_state *conn_state) |
|---|
| 484 | + struct dpu_encoder_hw_resources *hw_res) |
|---|
| 552 | 485 | { |
|---|
| 553 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 554 | | - |
|---|
| 555 | | - if (!phys_enc || !hw_res) { |
|---|
| 556 | | - DPU_ERROR("invalid arg(s), enc %d hw_res %d conn_state %d\n", |
|---|
| 557 | | - phys_enc != 0, hw_res != 0, conn_state != 0); |
|---|
| 558 | | - return; |
|---|
| 559 | | - } |
|---|
| 560 | | - |
|---|
| 561 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 562 | | - if (!vid_enc->hw_intf) { |
|---|
| 563 | | - DPU_ERROR("invalid arg(s), hw_intf\n"); |
|---|
| 564 | | - return; |
|---|
| 565 | | - } |
|---|
| 566 | | - |
|---|
| 567 | | - DPU_DEBUG_VIDENC(vid_enc, "\n"); |
|---|
| 568 | | - hw_res->intfs[vid_enc->hw_intf->idx - INTF_0] = INTF_MODE_VIDEO; |
|---|
| 486 | + hw_res->intfs[phys_enc->intf_idx - INTF_0] = INTF_MODE_VIDEO; |
|---|
| 569 | 487 | } |
|---|
| 570 | 488 | |
|---|
| 571 | | -static int _dpu_encoder_phys_vid_wait_for_vblank( |
|---|
| 572 | | - struct dpu_encoder_phys *phys_enc, bool notify) |
|---|
| 489 | +static int dpu_encoder_phys_vid_wait_for_vblank( |
|---|
| 490 | + struct dpu_encoder_phys *phys_enc) |
|---|
| 573 | 491 | { |
|---|
| 574 | 492 | struct dpu_encoder_wait_info wait_info; |
|---|
| 575 | 493 | int ret; |
|---|
| 576 | | - |
|---|
| 577 | | - if (!phys_enc) { |
|---|
| 578 | | - pr_err("invalid encoder\n"); |
|---|
| 579 | | - return -EINVAL; |
|---|
| 580 | | - } |
|---|
| 581 | 494 | |
|---|
| 582 | 495 | wait_info.wq = &phys_enc->pending_kickoff_wq; |
|---|
| 583 | 496 | wait_info.atomic_cnt = &phys_enc->pending_kickoff_cnt; |
|---|
| 584 | 497 | wait_info.timeout_ms = KICKOFF_TIMEOUT_MS; |
|---|
| 585 | 498 | |
|---|
| 586 | 499 | if (!dpu_encoder_phys_vid_is_master(phys_enc)) { |
|---|
| 587 | | - if (notify && phys_enc->parent_ops->handle_frame_done) |
|---|
| 588 | | - phys_enc->parent_ops->handle_frame_done( |
|---|
| 589 | | - phys_enc->parent, phys_enc, |
|---|
| 590 | | - DPU_ENCODER_FRAME_EVENT_DONE); |
|---|
| 591 | 500 | return 0; |
|---|
| 592 | 501 | } |
|---|
| 593 | 502 | |
|---|
| .. | .. |
|---|
| 597 | 506 | |
|---|
| 598 | 507 | if (ret == -ETIMEDOUT) { |
|---|
| 599 | 508 | dpu_encoder_helper_report_irq_timeout(phys_enc, INTR_IDX_VSYNC); |
|---|
| 600 | | - } else if (!ret && notify && phys_enc->parent_ops->handle_frame_done) |
|---|
| 601 | | - phys_enc->parent_ops->handle_frame_done( |
|---|
| 602 | | - phys_enc->parent, phys_enc, |
|---|
| 603 | | - DPU_ENCODER_FRAME_EVENT_DONE); |
|---|
| 509 | + } |
|---|
| 604 | 510 | |
|---|
| 605 | 511 | return ret; |
|---|
| 606 | 512 | } |
|---|
| 607 | 513 | |
|---|
| 608 | | -static int dpu_encoder_phys_vid_wait_for_vblank( |
|---|
| 514 | +static int dpu_encoder_phys_vid_wait_for_commit_done( |
|---|
| 609 | 515 | struct dpu_encoder_phys *phys_enc) |
|---|
| 610 | 516 | { |
|---|
| 611 | | - return _dpu_encoder_phys_vid_wait_for_vblank(phys_enc, true); |
|---|
| 517 | + struct dpu_hw_ctl *hw_ctl = phys_enc->hw_ctl; |
|---|
| 518 | + int ret; |
|---|
| 519 | + |
|---|
| 520 | + if (!hw_ctl) |
|---|
| 521 | + return 0; |
|---|
| 522 | + |
|---|
| 523 | + ret = wait_event_timeout(phys_enc->pending_kickoff_wq, |
|---|
| 524 | + (hw_ctl->ops.get_flush_register(hw_ctl) == 0), |
|---|
| 525 | + msecs_to_jiffies(50)); |
|---|
| 526 | + if (ret <= 0) { |
|---|
| 527 | + DPU_ERROR("vblank timeout\n"); |
|---|
| 528 | + return -ETIMEDOUT; |
|---|
| 529 | + } |
|---|
| 530 | + |
|---|
| 531 | + return 0; |
|---|
| 612 | 532 | } |
|---|
| 613 | 533 | |
|---|
| 614 | 534 | static void dpu_encoder_phys_vid_prepare_for_kickoff( |
|---|
| 615 | | - struct dpu_encoder_phys *phys_enc, |
|---|
| 616 | | - struct dpu_encoder_kickoff_params *params) |
|---|
| 535 | + struct dpu_encoder_phys *phys_enc) |
|---|
| 617 | 536 | { |
|---|
| 618 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 619 | 537 | struct dpu_hw_ctl *ctl; |
|---|
| 620 | 538 | int rc; |
|---|
| 621 | 539 | |
|---|
| 622 | | - if (!phys_enc || !params) { |
|---|
| 623 | | - DPU_ERROR("invalid encoder/parameters\n"); |
|---|
| 624 | | - return; |
|---|
| 625 | | - } |
|---|
| 626 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 627 | | - |
|---|
| 628 | 540 | ctl = phys_enc->hw_ctl; |
|---|
| 629 | | - if (!ctl || !ctl->ops.wait_reset_status) |
|---|
| 541 | + if (!ctl->ops.wait_reset_status) |
|---|
| 630 | 542 | return; |
|---|
| 631 | 543 | |
|---|
| 632 | 544 | /* |
|---|
| .. | .. |
|---|
| 635 | 547 | */ |
|---|
| 636 | 548 | rc = ctl->ops.wait_reset_status(ctl); |
|---|
| 637 | 549 | if (rc) { |
|---|
| 638 | | - DPU_ERROR_VIDENC(vid_enc, "ctl %d reset failure: %d\n", |
|---|
| 550 | + DPU_ERROR_VIDENC(phys_enc, "ctl %d reset failure: %d\n", |
|---|
| 639 | 551 | ctl->idx, rc); |
|---|
| 640 | 552 | dpu_encoder_helper_unregister_irq(phys_enc, INTR_IDX_VSYNC); |
|---|
| 641 | | - dpu_dbg_dump(false, __func__, true, true); |
|---|
| 642 | 553 | } |
|---|
| 643 | 554 | } |
|---|
| 644 | 555 | |
|---|
| 645 | 556 | static void dpu_encoder_phys_vid_disable(struct dpu_encoder_phys *phys_enc) |
|---|
| 646 | 557 | { |
|---|
| 647 | | - struct msm_drm_private *priv; |
|---|
| 648 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 649 | 558 | unsigned long lock_flags; |
|---|
| 650 | 559 | int ret; |
|---|
| 651 | 560 | |
|---|
| 652 | | - if (!phys_enc || !phys_enc->parent || !phys_enc->parent->dev || |
|---|
| 653 | | - !phys_enc->parent->dev->dev_private) { |
|---|
| 561 | + if (!phys_enc->parent || !phys_enc->parent->dev) { |
|---|
| 654 | 562 | DPU_ERROR("invalid encoder/device\n"); |
|---|
| 655 | 563 | return; |
|---|
| 656 | 564 | } |
|---|
| 657 | | - priv = phys_enc->parent->dev->dev_private; |
|---|
| 658 | 565 | |
|---|
| 659 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 660 | | - if (!vid_enc->hw_intf || !phys_enc->hw_ctl) { |
|---|
| 566 | + if (!phys_enc->hw_intf) { |
|---|
| 661 | 567 | DPU_ERROR("invalid hw_intf %d hw_ctl %d\n", |
|---|
| 662 | | - vid_enc->hw_intf != 0, phys_enc->hw_ctl != 0); |
|---|
| 568 | + phys_enc->hw_intf != NULL, phys_enc->hw_ctl != NULL); |
|---|
| 663 | 569 | return; |
|---|
| 664 | 570 | } |
|---|
| 665 | 571 | |
|---|
| 666 | | - DPU_DEBUG_VIDENC(vid_enc, "\n"); |
|---|
| 667 | | - |
|---|
| 668 | | - if (WARN_ON(!vid_enc->hw_intf->ops.enable_timing)) |
|---|
| 572 | + if (WARN_ON(!phys_enc->hw_intf->ops.enable_timing)) |
|---|
| 669 | 573 | return; |
|---|
| 670 | 574 | |
|---|
| 671 | 575 | if (phys_enc->enable_state == DPU_ENC_DISABLED) { |
|---|
| .. | .. |
|---|
| 674 | 578 | } |
|---|
| 675 | 579 | |
|---|
| 676 | 580 | spin_lock_irqsave(phys_enc->enc_spinlock, lock_flags); |
|---|
| 677 | | - vid_enc->hw_intf->ops.enable_timing(vid_enc->hw_intf, 0); |
|---|
| 581 | + phys_enc->hw_intf->ops.enable_timing(phys_enc->hw_intf, 0); |
|---|
| 678 | 582 | if (dpu_encoder_phys_vid_is_master(phys_enc)) |
|---|
| 679 | 583 | dpu_encoder_phys_inc_pending(phys_enc); |
|---|
| 680 | 584 | spin_unlock_irqrestore(phys_enc->enc_spinlock, lock_flags); |
|---|
| .. | .. |
|---|
| 688 | 592 | * scanout buffer) don't latch properly.. |
|---|
| 689 | 593 | */ |
|---|
| 690 | 594 | if (dpu_encoder_phys_vid_is_master(phys_enc)) { |
|---|
| 691 | | - ret = _dpu_encoder_phys_vid_wait_for_vblank(phys_enc, false); |
|---|
| 595 | + ret = dpu_encoder_phys_vid_wait_for_vblank(phys_enc); |
|---|
| 692 | 596 | if (ret) { |
|---|
| 693 | 597 | atomic_set(&phys_enc->pending_kickoff_cnt, 0); |
|---|
| 694 | 598 | DRM_ERROR("wait disable failed: id:%u intf:%d ret:%d\n", |
|---|
| 695 | 599 | DRMID(phys_enc->parent), |
|---|
| 696 | | - vid_enc->hw_intf->idx - INTF_0, ret); |
|---|
| 600 | + phys_enc->hw_intf->idx - INTF_0, ret); |
|---|
| 697 | 601 | } |
|---|
| 698 | 602 | } |
|---|
| 699 | 603 | |
|---|
| .. | .. |
|---|
| 704 | 608 | struct dpu_encoder_phys *phys_enc) |
|---|
| 705 | 609 | { |
|---|
| 706 | 610 | unsigned long lock_flags; |
|---|
| 707 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 708 | | - |
|---|
| 709 | | - if (!phys_enc) { |
|---|
| 710 | | - DPU_ERROR("invalid encoder\n"); |
|---|
| 711 | | - return; |
|---|
| 712 | | - } |
|---|
| 713 | | - |
|---|
| 714 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 715 | | - DPU_DEBUG_VIDENC(vid_enc, "enable_state %d\n", phys_enc->enable_state); |
|---|
| 716 | 611 | |
|---|
| 717 | 612 | /* |
|---|
| 718 | 613 | * Video mode must flush CTL before enabling timing engine |
|---|
| .. | .. |
|---|
| 720 | 615 | */ |
|---|
| 721 | 616 | if (phys_enc->enable_state == DPU_ENC_ENABLING) { |
|---|
| 722 | 617 | trace_dpu_enc_phys_vid_post_kickoff(DRMID(phys_enc->parent), |
|---|
| 723 | | - vid_enc->hw_intf->idx - INTF_0); |
|---|
| 618 | + phys_enc->hw_intf->idx - INTF_0); |
|---|
| 724 | 619 | spin_lock_irqsave(phys_enc->enc_spinlock, lock_flags); |
|---|
| 725 | | - vid_enc->hw_intf->ops.enable_timing(vid_enc->hw_intf, 1); |
|---|
| 620 | + phys_enc->hw_intf->ops.enable_timing(phys_enc->hw_intf, 1); |
|---|
| 726 | 621 | spin_unlock_irqrestore(phys_enc->enc_spinlock, lock_flags); |
|---|
| 727 | 622 | phys_enc->enable_state = DPU_ENC_ENABLED; |
|---|
| 728 | 623 | } |
|---|
| .. | .. |
|---|
| 731 | 626 | static void dpu_encoder_phys_vid_irq_control(struct dpu_encoder_phys *phys_enc, |
|---|
| 732 | 627 | bool enable) |
|---|
| 733 | 628 | { |
|---|
| 734 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 735 | 629 | int ret; |
|---|
| 736 | 630 | |
|---|
| 737 | | - if (!phys_enc) |
|---|
| 738 | | - return; |
|---|
| 739 | | - |
|---|
| 740 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 741 | | - |
|---|
| 742 | 631 | trace_dpu_enc_phys_vid_irq_ctrl(DRMID(phys_enc->parent), |
|---|
| 743 | | - vid_enc->hw_intf->idx - INTF_0, |
|---|
| 632 | + phys_enc->hw_intf->idx - INTF_0, |
|---|
| 744 | 633 | enable, |
|---|
| 745 | 634 | atomic_read(&phys_enc->vblank_refcount)); |
|---|
| 746 | 635 | |
|---|
| .. | .. |
|---|
| 756 | 645 | } |
|---|
| 757 | 646 | } |
|---|
| 758 | 647 | |
|---|
| 759 | | -static void dpu_encoder_phys_vid_setup_misr(struct dpu_encoder_phys *phys_enc, |
|---|
| 760 | | - bool enable, u32 frame_count) |
|---|
| 761 | | -{ |
|---|
| 762 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 763 | | - |
|---|
| 764 | | - if (!phys_enc) |
|---|
| 765 | | - return; |
|---|
| 766 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 767 | | - |
|---|
| 768 | | - if (vid_enc->hw_intf && vid_enc->hw_intf->ops.setup_misr) |
|---|
| 769 | | - vid_enc->hw_intf->ops.setup_misr(vid_enc->hw_intf, |
|---|
| 770 | | - enable, frame_count); |
|---|
| 771 | | -} |
|---|
| 772 | | - |
|---|
| 773 | | -static u32 dpu_encoder_phys_vid_collect_misr(struct dpu_encoder_phys *phys_enc) |
|---|
| 774 | | -{ |
|---|
| 775 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 776 | | - |
|---|
| 777 | | - if (!phys_enc) |
|---|
| 778 | | - return 0; |
|---|
| 779 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 780 | | - |
|---|
| 781 | | - return vid_enc->hw_intf && vid_enc->hw_intf->ops.collect_misr ? |
|---|
| 782 | | - vid_enc->hw_intf->ops.collect_misr(vid_enc->hw_intf) : 0; |
|---|
| 783 | | -} |
|---|
| 784 | | - |
|---|
| 785 | 648 | static int dpu_encoder_phys_vid_get_line_count( |
|---|
| 786 | 649 | struct dpu_encoder_phys *phys_enc) |
|---|
| 787 | 650 | { |
|---|
| 788 | | - struct dpu_encoder_phys_vid *vid_enc; |
|---|
| 789 | | - |
|---|
| 790 | | - if (!phys_enc) |
|---|
| 791 | | - return -EINVAL; |
|---|
| 792 | | - |
|---|
| 793 | 651 | if (!dpu_encoder_phys_vid_is_master(phys_enc)) |
|---|
| 794 | 652 | return -EINVAL; |
|---|
| 795 | 653 | |
|---|
| 796 | | - vid_enc = to_dpu_encoder_phys_vid(phys_enc); |
|---|
| 797 | | - if (!vid_enc->hw_intf || !vid_enc->hw_intf->ops.get_line_count) |
|---|
| 654 | + if (!phys_enc->hw_intf || !phys_enc->hw_intf->ops.get_line_count) |
|---|
| 798 | 655 | return -EINVAL; |
|---|
| 799 | 656 | |
|---|
| 800 | | - return vid_enc->hw_intf->ops.get_line_count(vid_enc->hw_intf); |
|---|
| 657 | + return phys_enc->hw_intf->ops.get_line_count(phys_enc->hw_intf); |
|---|
| 801 | 658 | } |
|---|
| 802 | 659 | |
|---|
| 803 | 660 | static void dpu_encoder_phys_vid_init_ops(struct dpu_encoder_phys_ops *ops) |
|---|
| .. | .. |
|---|
| 810 | 667 | ops->destroy = dpu_encoder_phys_vid_destroy; |
|---|
| 811 | 668 | ops->get_hw_resources = dpu_encoder_phys_vid_get_hw_resources; |
|---|
| 812 | 669 | ops->control_vblank_irq = dpu_encoder_phys_vid_control_vblank_irq; |
|---|
| 813 | | - ops->wait_for_commit_done = dpu_encoder_phys_vid_wait_for_vblank; |
|---|
| 670 | + ops->wait_for_commit_done = dpu_encoder_phys_vid_wait_for_commit_done; |
|---|
| 814 | 671 | ops->wait_for_vblank = dpu_encoder_phys_vid_wait_for_vblank; |
|---|
| 815 | 672 | ops->wait_for_tx_complete = dpu_encoder_phys_vid_wait_for_vblank; |
|---|
| 816 | 673 | ops->irq_control = dpu_encoder_phys_vid_irq_control; |
|---|
| 817 | 674 | ops->prepare_for_kickoff = dpu_encoder_phys_vid_prepare_for_kickoff; |
|---|
| 818 | 675 | ops->handle_post_kickoff = dpu_encoder_phys_vid_handle_post_kickoff; |
|---|
| 819 | 676 | ops->needs_single_flush = dpu_encoder_phys_vid_needs_single_flush; |
|---|
| 820 | | - ops->setup_misr = dpu_encoder_phys_vid_setup_misr; |
|---|
| 821 | | - ops->collect_misr = dpu_encoder_phys_vid_collect_misr; |
|---|
| 822 | | - ops->hw_reset = dpu_encoder_helper_hw_reset; |
|---|
| 823 | 677 | ops->get_line_count = dpu_encoder_phys_vid_get_line_count; |
|---|
| 824 | 678 | } |
|---|
| 825 | 679 | |
|---|
| .. | .. |
|---|
| 827 | 681 | struct dpu_enc_phys_init_params *p) |
|---|
| 828 | 682 | { |
|---|
| 829 | 683 | struct dpu_encoder_phys *phys_enc = NULL; |
|---|
| 830 | | - struct dpu_encoder_phys_vid *vid_enc = NULL; |
|---|
| 831 | | - struct dpu_rm_hw_iter iter; |
|---|
| 832 | | - struct dpu_hw_mdp *hw_mdp; |
|---|
| 833 | 684 | struct dpu_encoder_irq *irq; |
|---|
| 834 | 685 | int i, ret = 0; |
|---|
| 835 | 686 | |
|---|
| .. | .. |
|---|
| 838 | 689 | goto fail; |
|---|
| 839 | 690 | } |
|---|
| 840 | 691 | |
|---|
| 841 | | - vid_enc = kzalloc(sizeof(*vid_enc), GFP_KERNEL); |
|---|
| 842 | | - if (!vid_enc) { |
|---|
| 692 | + phys_enc = kzalloc(sizeof(*phys_enc), GFP_KERNEL); |
|---|
| 693 | + if (!phys_enc) { |
|---|
| 843 | 694 | ret = -ENOMEM; |
|---|
| 844 | 695 | goto fail; |
|---|
| 845 | 696 | } |
|---|
| 846 | 697 | |
|---|
| 847 | | - phys_enc = &vid_enc->base; |
|---|
| 848 | | - |
|---|
| 849 | | - hw_mdp = dpu_rm_get_mdp(&p->dpu_kms->rm); |
|---|
| 850 | | - if (IS_ERR_OR_NULL(hw_mdp)) { |
|---|
| 851 | | - ret = PTR_ERR(hw_mdp); |
|---|
| 852 | | - DPU_ERROR("failed to get mdptop\n"); |
|---|
| 853 | | - goto fail; |
|---|
| 854 | | - } |
|---|
| 855 | | - phys_enc->hw_mdptop = hw_mdp; |
|---|
| 698 | + phys_enc->hw_mdptop = p->dpu_kms->hw_mdp; |
|---|
| 856 | 699 | phys_enc->intf_idx = p->intf_idx; |
|---|
| 857 | 700 | |
|---|
| 858 | | - /** |
|---|
| 859 | | - * hw_intf resource permanently assigned to this encoder |
|---|
| 860 | | - * Other resources allocated at atomic commit time by use case |
|---|
| 861 | | - */ |
|---|
| 862 | | - dpu_rm_init_hw_iter(&iter, 0, DPU_HW_BLK_INTF); |
|---|
| 863 | | - while (dpu_rm_get_hw(&p->dpu_kms->rm, &iter)) { |
|---|
| 864 | | - struct dpu_hw_intf *hw_intf = (struct dpu_hw_intf *)iter.hw; |
|---|
| 865 | | - |
|---|
| 866 | | - if (hw_intf->idx == p->intf_idx) { |
|---|
| 867 | | - vid_enc->hw_intf = hw_intf; |
|---|
| 868 | | - break; |
|---|
| 869 | | - } |
|---|
| 870 | | - } |
|---|
| 871 | | - |
|---|
| 872 | | - if (!vid_enc->hw_intf) { |
|---|
| 873 | | - ret = -EINVAL; |
|---|
| 874 | | - DPU_ERROR("failed to get hw_intf\n"); |
|---|
| 875 | | - goto fail; |
|---|
| 876 | | - } |
|---|
| 877 | | - |
|---|
| 878 | | - DPU_DEBUG_VIDENC(vid_enc, "\n"); |
|---|
| 701 | + DPU_DEBUG_VIDENC(phys_enc, "\n"); |
|---|
| 879 | 702 | |
|---|
| 880 | 703 | dpu_encoder_phys_vid_init_ops(&phys_enc->ops); |
|---|
| 881 | 704 | phys_enc->parent = p->parent; |
|---|
| .. | .. |
|---|
| 909 | 732 | init_waitqueue_head(&phys_enc->pending_kickoff_wq); |
|---|
| 910 | 733 | phys_enc->enable_state = DPU_ENC_DISABLED; |
|---|
| 911 | 734 | |
|---|
| 912 | | - DPU_DEBUG_VIDENC(vid_enc, "created intf idx:%d\n", p->intf_idx); |
|---|
| 735 | + DPU_DEBUG_VIDENC(phys_enc, "created intf idx:%d\n", p->intf_idx); |
|---|
| 913 | 736 | |
|---|
| 914 | 737 | return phys_enc; |
|---|
| 915 | 738 | |
|---|
| 916 | 739 | fail: |
|---|
| 917 | 740 | DPU_ERROR("failed to create encoder\n"); |
|---|
| 918 | | - if (vid_enc) |
|---|
| 741 | + if (phys_enc) |
|---|
| 919 | 742 | dpu_encoder_phys_vid_destroy(phys_enc); |
|---|
| 920 | 743 | |
|---|
| 921 | 744 | return ERR_PTR(ret); |
|---|