Lines Matching refs:overlay
231 alloc_request(struct intel_overlay *overlay, void (*fn)(struct intel_overlay *)) in alloc_request() argument
236 overlay->flip_complete = fn; in alloc_request()
238 rq = i915_request_create(overlay->context); in alloc_request()
242 err = i915_active_add_request(&overlay->last_flip, rq); in alloc_request()
252 static int intel_overlay_on(struct intel_overlay *overlay) in intel_overlay_on() argument
254 struct drm_i915_private *dev_priv = overlay->i915; in intel_overlay_on()
258 drm_WARN_ON(&dev_priv->drm, overlay->active); in intel_overlay_on()
260 rq = alloc_request(overlay, NULL); in intel_overlay_on()
270 overlay->active = true; in intel_overlay_on()
276 *cs++ = overlay->flip_addr | OFC_UPDATE; in intel_overlay_on()
283 return i915_active_wait(&overlay->last_flip); in intel_overlay_on()
286 static void intel_overlay_flip_prepare(struct intel_overlay *overlay, in intel_overlay_flip_prepare() argument
289 enum pipe pipe = overlay->crtc->pipe; in intel_overlay_flip_prepare()
292 drm_WARN_ON(&overlay->i915->drm, overlay->old_vma); in intel_overlay_flip_prepare()
297 intel_frontbuffer_track(overlay->frontbuffer, frontbuffer, in intel_overlay_flip_prepare()
300 if (overlay->frontbuffer) in intel_overlay_flip_prepare()
301 intel_frontbuffer_put(overlay->frontbuffer); in intel_overlay_flip_prepare()
302 overlay->frontbuffer = frontbuffer; in intel_overlay_flip_prepare()
304 intel_frontbuffer_flip_prepare(overlay->i915, in intel_overlay_flip_prepare()
307 overlay->old_vma = overlay->vma; in intel_overlay_flip_prepare()
309 overlay->vma = i915_vma_get(vma); in intel_overlay_flip_prepare()
311 overlay->vma = NULL; in intel_overlay_flip_prepare()
315 static int intel_overlay_continue(struct intel_overlay *overlay, in intel_overlay_continue() argument
319 struct drm_i915_private *dev_priv = overlay->i915; in intel_overlay_continue()
321 u32 flip_addr = overlay->flip_addr; in intel_overlay_continue()
324 drm_WARN_ON(&dev_priv->drm, !overlay->active); in intel_overlay_continue()
334 rq = alloc_request(overlay, NULL); in intel_overlay_continue()
348 intel_overlay_flip_prepare(overlay, vma); in intel_overlay_continue()
354 static void intel_overlay_release_old_vma(struct intel_overlay *overlay) in intel_overlay_release_old_vma() argument
358 vma = fetch_and_zero(&overlay->old_vma); in intel_overlay_release_old_vma()
359 if (drm_WARN_ON(&overlay->i915->drm, !vma)) in intel_overlay_release_old_vma()
362 intel_frontbuffer_flip_complete(overlay->i915, in intel_overlay_release_old_vma()
363 INTEL_FRONTBUFFER_OVERLAY(overlay->crtc->pipe)); in intel_overlay_release_old_vma()
370 intel_overlay_release_old_vid_tail(struct intel_overlay *overlay) in intel_overlay_release_old_vid_tail() argument
372 intel_overlay_release_old_vma(overlay); in intel_overlay_release_old_vid_tail()
375 static void intel_overlay_off_tail(struct intel_overlay *overlay) in intel_overlay_off_tail() argument
377 struct drm_i915_private *dev_priv = overlay->i915; in intel_overlay_off_tail()
379 intel_overlay_release_old_vma(overlay); in intel_overlay_off_tail()
381 overlay->crtc->overlay = NULL; in intel_overlay_off_tail()
382 overlay->crtc = NULL; in intel_overlay_off_tail()
383 overlay->active = false; in intel_overlay_off_tail()
391 struct intel_overlay *overlay = in intel_overlay_last_flip_retire() local
392 container_of(active, typeof(*overlay), last_flip); in intel_overlay_last_flip_retire()
394 if (overlay->flip_complete) in intel_overlay_last_flip_retire()
395 overlay->flip_complete(overlay); in intel_overlay_last_flip_retire()
399 static int intel_overlay_off(struct intel_overlay *overlay) in intel_overlay_off() argument
402 u32 *cs, flip_addr = overlay->flip_addr; in intel_overlay_off()
404 drm_WARN_ON(&overlay->i915->drm, !overlay->active); in intel_overlay_off()
412 rq = alloc_request(overlay, intel_overlay_off_tail); in intel_overlay_off()
434 intel_overlay_flip_prepare(overlay, NULL); in intel_overlay_off()
437 return i915_active_wait(&overlay->last_flip); in intel_overlay_off()
442 static int intel_overlay_recover_from_interrupt(struct intel_overlay *overlay) in intel_overlay_recover_from_interrupt() argument
444 return i915_active_wait(&overlay->last_flip); in intel_overlay_recover_from_interrupt()
451 static int intel_overlay_release_old_vid(struct intel_overlay *overlay) in intel_overlay_release_old_vid() argument
453 struct drm_i915_private *dev_priv = overlay->i915; in intel_overlay_release_old_vid()
461 if (!overlay->old_vma) in intel_overlay_release_old_vid()
465 intel_overlay_release_old_vid_tail(overlay); in intel_overlay_release_old_vid()
469 rq = alloc_request(overlay, intel_overlay_release_old_vid_tail); in intel_overlay_release_old_vid()
485 return i915_active_wait(&overlay->last_flip); in intel_overlay_release_old_vid()
490 struct intel_overlay *overlay = dev_priv->display.overlay; in intel_overlay_reset() local
492 if (!overlay) in intel_overlay_reset()
495 overlay->old_xscale = 0; in intel_overlay_reset()
496 overlay->old_yscale = 0; in intel_overlay_reset()
497 overlay->crtc = NULL; in intel_overlay_reset()
498 overlay->active = false; in intel_overlay_reset()
613 static bool update_scaling_factors(struct intel_overlay *overlay, in update_scaling_factors() argument
648 if (xscale != overlay->old_xscale || yscale != overlay->old_yscale) in update_scaling_factors()
650 overlay->old_xscale = xscale; in update_scaling_factors()
651 overlay->old_yscale = yscale; in update_scaling_factors()
673 static void update_colorkey(struct intel_overlay *overlay, in update_colorkey() argument
677 to_intel_plane_state(overlay->crtc->base.primary->state); in update_colorkey()
678 u32 key = overlay->color_key; in update_colorkey()
682 if (overlay->color_key_enabled) in update_colorkey()
786 static int intel_overlay_do_put_image(struct intel_overlay *overlay, in intel_overlay_do_put_image() argument
790 struct overlay_registers __iomem *regs = overlay->regs; in intel_overlay_do_put_image()
791 struct drm_i915_private *dev_priv = overlay->i915; in intel_overlay_do_put_image()
793 enum pipe pipe = overlay->crtc->pipe; in intel_overlay_do_put_image()
801 ret = intel_overlay_release_old_vid(overlay); in intel_overlay_do_put_image()
815 if (!overlay->active) { in intel_overlay_do_put_image()
817 overlay->crtc->config; in intel_overlay_do_put_image()
831 ret = intel_overlay_on(overlay); in intel_overlay_do_put_image()
878 scale_changed = update_scaling_factors(overlay, regs, params); in intel_overlay_do_put_image()
880 update_colorkey(overlay, regs); in intel_overlay_do_put_image()
884 ret = intel_overlay_continue(overlay, vma, scale_changed); in intel_overlay_do_put_image()
898 int intel_overlay_switch_off(struct intel_overlay *overlay) in intel_overlay_switch_off() argument
900 struct drm_i915_private *dev_priv = overlay->i915; in intel_overlay_switch_off()
906 ret = intel_overlay_recover_from_interrupt(overlay); in intel_overlay_switch_off()
910 if (!overlay->active) in intel_overlay_switch_off()
913 ret = intel_overlay_release_old_vid(overlay); in intel_overlay_switch_off()
917 iowrite32(0, &overlay->regs->OCMD); in intel_overlay_switch_off()
919 return intel_overlay_off(overlay); in intel_overlay_switch_off()
922 static int check_overlay_possible_on_crtc(struct intel_overlay *overlay, in check_overlay_possible_on_crtc() argument
935 static void update_pfit_vscale_ratio(struct intel_overlay *overlay) in update_pfit_vscale_ratio() argument
937 struct drm_i915_private *dev_priv = overlay->i915; in update_pfit_vscale_ratio()
955 overlay->pfit_vscale_ratio = ratio; in update_pfit_vscale_ratio()
958 static int check_overlay_dst(struct intel_overlay *overlay, in check_overlay_dst() argument
962 overlay->crtc->config; in check_overlay_dst()
1110 struct intel_overlay *overlay; in intel_overlay_put_image_ioctl() local
1116 overlay = dev_priv->display.overlay; in intel_overlay_put_image_ioctl()
1117 if (!overlay) { in intel_overlay_put_image_ioctl()
1124 ret = intel_overlay_switch_off(overlay); in intel_overlay_put_image_ioctl()
1148 ret = intel_overlay_recover_from_interrupt(overlay); in intel_overlay_put_image_ioctl()
1152 if (overlay->crtc != crtc) { in intel_overlay_put_image_ioctl()
1153 ret = intel_overlay_switch_off(overlay); in intel_overlay_put_image_ioctl()
1157 ret = check_overlay_possible_on_crtc(overlay, crtc); in intel_overlay_put_image_ioctl()
1161 overlay->crtc = crtc; in intel_overlay_put_image_ioctl()
1162 crtc->overlay = overlay; in intel_overlay_put_image_ioctl()
1167 overlay->pfit_active = true; in intel_overlay_put_image_ioctl()
1168 update_pfit_vscale_ratio(overlay); in intel_overlay_put_image_ioctl()
1170 overlay->pfit_active = false; in intel_overlay_put_image_ioctl()
1173 ret = check_overlay_dst(overlay, params); in intel_overlay_put_image_ioctl()
1177 if (overlay->pfit_active) { in intel_overlay_put_image_ioctl()
1179 overlay->pfit_vscale_ratio); in intel_overlay_put_image_ioctl()
1182 overlay->pfit_vscale_ratio) + 1; in intel_overlay_put_image_ioctl()
1200 ret = intel_overlay_do_put_image(overlay, new_bo, params); in intel_overlay_put_image_ioctl()
1216 static void update_reg_attrs(struct intel_overlay *overlay, in update_reg_attrs() argument
1219 iowrite32((overlay->contrast << 18) | (overlay->brightness & 0xff), in update_reg_attrs()
1221 iowrite32(overlay->saturation, ®s->OCLRC1); in update_reg_attrs()
1273 struct intel_overlay *overlay; in intel_overlay_attrs_ioctl() local
1276 overlay = dev_priv->display.overlay; in intel_overlay_attrs_ioctl()
1277 if (!overlay) { in intel_overlay_attrs_ioctl()
1286 attrs->color_key = overlay->color_key; in intel_overlay_attrs_ioctl()
1287 attrs->brightness = overlay->brightness; in intel_overlay_attrs_ioctl()
1288 attrs->contrast = overlay->contrast; in intel_overlay_attrs_ioctl()
1289 attrs->saturation = overlay->saturation; in intel_overlay_attrs_ioctl()
1307 overlay->color_key = attrs->color_key; in intel_overlay_attrs_ioctl()
1308 overlay->brightness = attrs->brightness; in intel_overlay_attrs_ioctl()
1309 overlay->contrast = attrs->contrast; in intel_overlay_attrs_ioctl()
1310 overlay->saturation = attrs->saturation; in intel_overlay_attrs_ioctl()
1312 update_reg_attrs(overlay, overlay->regs); in intel_overlay_attrs_ioctl()
1318 if (overlay->active) { in intel_overlay_attrs_ioctl()
1335 overlay->color_key_enabled = (attrs->flags & I915_OVERLAY_DISABLE_DEST_COLORKEY) == 0; in intel_overlay_attrs_ioctl()
1344 static int get_registers(struct intel_overlay *overlay, bool use_phys) in get_registers() argument
1346 struct drm_i915_private *i915 = overlay->i915; in get_registers()
1364 overlay->flip_addr = sg_dma_address(obj->mm.pages->sgl); in get_registers()
1366 overlay->flip_addr = i915_ggtt_offset(vma); in get_registers()
1367 overlay->regs = i915_vma_pin_iomap(vma); in get_registers()
1370 if (IS_ERR(overlay->regs)) { in get_registers()
1371 err = PTR_ERR(overlay->regs); in get_registers()
1375 overlay->reg_bo = obj; in get_registers()
1385 struct intel_overlay *overlay; in intel_overlay_setup() local
1396 overlay = kzalloc(sizeof(*overlay), GFP_KERNEL); in intel_overlay_setup()
1397 if (!overlay) in intel_overlay_setup()
1400 overlay->i915 = dev_priv; in intel_overlay_setup()
1401 overlay->context = engine->kernel_context; in intel_overlay_setup()
1402 overlay->color_key = 0x0101fe; in intel_overlay_setup()
1403 overlay->color_key_enabled = true; in intel_overlay_setup()
1404 overlay->brightness = -19; in intel_overlay_setup()
1405 overlay->contrast = 75; in intel_overlay_setup()
1406 overlay->saturation = 146; in intel_overlay_setup()
1408 i915_active_init(&overlay->last_flip, in intel_overlay_setup()
1411 ret = get_registers(overlay, OVERLAY_NEEDS_PHYSICAL(dev_priv)); in intel_overlay_setup()
1415 memset_io(overlay->regs, 0, sizeof(struct overlay_registers)); in intel_overlay_setup()
1416 update_polyphase_filter(overlay->regs); in intel_overlay_setup()
1417 update_reg_attrs(overlay, overlay->regs); in intel_overlay_setup()
1419 dev_priv->display.overlay = overlay; in intel_overlay_setup()
1424 kfree(overlay); in intel_overlay_setup()
1429 struct intel_overlay *overlay; in intel_overlay_cleanup() local
1431 overlay = fetch_and_zero(&dev_priv->display.overlay); in intel_overlay_cleanup()
1432 if (!overlay) in intel_overlay_cleanup()
1440 drm_WARN_ON(&dev_priv->drm, overlay->active); in intel_overlay_cleanup()
1442 i915_gem_object_put(overlay->reg_bo); in intel_overlay_cleanup()
1443 i915_active_fini(&overlay->last_flip); in intel_overlay_cleanup()
1445 kfree(overlay); in intel_overlay_cleanup()
1460 struct intel_overlay *overlay = dev_priv->display.overlay; in intel_overlay_capture_error_state() local
1463 if (!overlay || !overlay->active) in intel_overlay_capture_error_state()
1472 error->base = overlay->flip_addr; in intel_overlay_capture_error_state()
1474 memcpy_fromio(&error->regs, overlay->regs, sizeof(error->regs)); in intel_overlay_capture_error_state()