1/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright © 2020 Intel Corporation
4 */
5
6#ifndef _INTEL_CRTC_H_
7#define _INTEL_CRTC_H_
8
9#include <linux/types.h>
10
11enum i9xx_plane_id;
12enum pipe;
13struct drm_device;
14struct drm_display_mode;
15struct drm_file;
16struct drm_pending_vblank_event;
17struct intel_atomic_state;
18struct intel_crtc;
19struct intel_crtc_state;
20struct intel_display;
21
22/*
23 * FIXME: We should instead only take spinlocks once for the entire update
24 * instead of once per mmio.
25 */
26#if IS_ENABLED(CONFIG_PROVE_LOCKING)
27#define VBLANK_EVASION_TIME_US 250
28#else
29#define VBLANK_EVASION_TIME_US 100
30#endif
31
32int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
33 int usecs);
34int intel_scanlines_to_usecs(const struct drm_display_mode *adjusted_mode,
35 int scanlines);
36void intel_crtc_arm_vblank_event(struct intel_crtc_state *crtc_state);
37void intel_crtc_prepare_vblank_event(struct intel_crtc_state *crtc_state,
38 struct drm_pending_vblank_event **event);
39u32 intel_crtc_max_vblank_count(const struct intel_crtc_state *crtc_state);
40int intel_crtc_init(struct intel_display *display, enum pipe pipe);
41int intel_crtc_get_pipe_from_crtc_id_ioctl(struct drm_device *dev, void *data,
42 struct drm_file *file_priv);
43struct intel_crtc_state *intel_crtc_state_alloc(struct intel_crtc *crtc);
44void intel_crtc_state_reset(struct intel_crtc_state *crtc_state,
45 struct intel_crtc *crtc);
46u32 intel_crtc_get_vblank_counter(struct intel_crtc *crtc);
47void intel_crtc_vblank_on(const struct intel_crtc_state *crtc_state);
48void intel_crtc_vblank_off(const struct intel_crtc_state *crtc_state);
49void intel_pipe_update_start(struct intel_atomic_state *state,
50 struct intel_crtc *crtc);
51void intel_pipe_update_end(struct intel_atomic_state *state,
52 struct intel_crtc *crtc);
53void intel_wait_for_vblank_workers(struct intel_atomic_state *state);
54struct intel_crtc *intel_first_crtc(struct intel_display *display);
55struct intel_crtc *intel_crtc_for_pipe(struct intel_display *display,
56 enum pipe pipe);
57void intel_wait_for_vblank_if_active(struct intel_display *display,
58 enum pipe pipe);
59void intel_crtc_wait_for_next_vblank(struct intel_crtc *crtc);
60
61#endif
62