diff options
Diffstat (limited to 'drivers/gpu/drm/i915/intel_drv.h')
-rw-r--r-- | drivers/gpu/drm/i915/intel_drv.h | 111 |
1 files changed, 79 insertions, 32 deletions
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 089a42577ea3..55aeaf041749 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
@@ -69,39 +69,63 @@ | |||
69 | }) | 69 | }) |
70 | 70 | ||
71 | #define wait_for(COND, MS) _wait_for((COND), (MS) * 1000, 1000) | 71 | #define wait_for(COND, MS) _wait_for((COND), (MS) * 1000, 1000) |
72 | #define wait_for_us(COND, US) _wait_for((COND), (US), 1) | ||
73 | 72 | ||
74 | /* If CONFIG_PREEMPT_COUNT is disabled, in_atomic() always reports false. */ | 73 | /* If CONFIG_PREEMPT_COUNT is disabled, in_atomic() always reports false. */ |
75 | #if defined(CONFIG_DRM_I915_DEBUG) && defined(CONFIG_PREEMPT_COUNT) | 74 | #if defined(CONFIG_DRM_I915_DEBUG) && defined(CONFIG_PREEMPT_COUNT) |
76 | # define _WAIT_FOR_ATOMIC_CHECK WARN_ON_ONCE(!in_atomic()) | 75 | # define _WAIT_FOR_ATOMIC_CHECK(ATOMIC) WARN_ON_ONCE((ATOMIC) && !in_atomic()) |
77 | #else | 76 | #else |
78 | # define _WAIT_FOR_ATOMIC_CHECK do { } while (0) | 77 | # define _WAIT_FOR_ATOMIC_CHECK(ATOMIC) do { } while (0) |
79 | #endif | 78 | #endif |
80 | 79 | ||
81 | #define _wait_for_atomic(COND, US) ({ \ | 80 | #define _wait_for_atomic(COND, US, ATOMIC) \ |
82 | unsigned long end__; \ | 81 | ({ \ |
83 | int ret__ = 0; \ | 82 | int cpu, ret, timeout = (US) * 1000; \ |
84 | _WAIT_FOR_ATOMIC_CHECK; \ | 83 | u64 base; \ |
84 | _WAIT_FOR_ATOMIC_CHECK(ATOMIC); \ | ||
85 | BUILD_BUG_ON((US) > 50000); \ | 85 | BUILD_BUG_ON((US) > 50000); \ |
86 | end__ = (local_clock() >> 10) + (US) + 1; \ | 86 | if (!(ATOMIC)) { \ |
87 | while (!(COND)) { \ | 87 | preempt_disable(); \ |
88 | if (time_after((unsigned long)(local_clock() >> 10), end__)) { \ | 88 | cpu = smp_processor_id(); \ |
89 | /* Unlike the regular wait_for(), this atomic variant \ | 89 | } \ |
90 | * cannot be preempted (and we'll just ignore the issue\ | 90 | base = local_clock(); \ |
91 | * of irq interruptions) and so we know that no time \ | 91 | for (;;) { \ |
92 | * has passed since the last check of COND and can \ | 92 | u64 now = local_clock(); \ |
93 | * immediately report the timeout. \ | 93 | if (!(ATOMIC)) \ |
94 | */ \ | 94 | preempt_enable(); \ |
95 | ret__ = -ETIMEDOUT; \ | 95 | if (COND) { \ |
96 | ret = 0; \ | ||
97 | break; \ | ||
98 | } \ | ||
99 | if (now - base >= timeout) { \ | ||
100 | ret = -ETIMEDOUT; \ | ||
96 | break; \ | 101 | break; \ |
97 | } \ | 102 | } \ |
98 | cpu_relax(); \ | 103 | cpu_relax(); \ |
104 | if (!(ATOMIC)) { \ | ||
105 | preempt_disable(); \ | ||
106 | if (unlikely(cpu != smp_processor_id())) { \ | ||
107 | timeout -= now - base; \ | ||
108 | cpu = smp_processor_id(); \ | ||
109 | base = local_clock(); \ | ||
110 | } \ | ||
111 | } \ | ||
99 | } \ | 112 | } \ |
113 | ret; \ | ||
114 | }) | ||
115 | |||
116 | #define wait_for_us(COND, US) \ | ||
117 | ({ \ | ||
118 | int ret__; \ | ||
119 | BUILD_BUG_ON(!__builtin_constant_p(US)); \ | ||
120 | if ((US) > 10) \ | ||
121 | ret__ = _wait_for((COND), (US), 10); \ | ||
122 | else \ | ||
123 | ret__ = _wait_for_atomic((COND), (US), 0); \ | ||
100 | ret__; \ | 124 | ret__; \ |
101 | }) | 125 | }) |
102 | 126 | ||
103 | #define wait_for_atomic(COND, MS) _wait_for_atomic((COND), (MS) * 1000) | 127 | #define wait_for_atomic(COND, MS) _wait_for_atomic((COND), (MS) * 1000, 1) |
104 | #define wait_for_atomic_us(COND, US) _wait_for_atomic((COND), (US)) | 128 | #define wait_for_atomic_us(COND, US) _wait_for_atomic((COND), (US), 1) |
105 | 129 | ||
106 | #define KHz(x) (1000 * (x)) | 130 | #define KHz(x) (1000 * (x)) |
107 | #define MHz(x) KHz(1000 * (x)) | 131 | #define MHz(x) KHz(1000 * (x)) |
@@ -135,7 +159,7 @@ enum intel_output_type { | |||
135 | INTEL_OUTPUT_LVDS = 4, | 159 | INTEL_OUTPUT_LVDS = 4, |
136 | INTEL_OUTPUT_TVOUT = 5, | 160 | INTEL_OUTPUT_TVOUT = 5, |
137 | INTEL_OUTPUT_HDMI = 6, | 161 | INTEL_OUTPUT_HDMI = 6, |
138 | INTEL_OUTPUT_DISPLAYPORT = 7, | 162 | INTEL_OUTPUT_DP = 7, |
139 | INTEL_OUTPUT_EDP = 8, | 163 | INTEL_OUTPUT_EDP = 8, |
140 | INTEL_OUTPUT_DSI = 9, | 164 | INTEL_OUTPUT_DSI = 9, |
141 | INTEL_OUTPUT_UNKNOWN = 10, | 165 | INTEL_OUTPUT_UNKNOWN = 10, |
@@ -159,6 +183,7 @@ struct intel_framebuffer { | |||
159 | struct intel_fbdev { | 183 | struct intel_fbdev { |
160 | struct drm_fb_helper helper; | 184 | struct drm_fb_helper helper; |
161 | struct intel_framebuffer *fb; | 185 | struct intel_framebuffer *fb; |
186 | async_cookie_t cookie; | ||
162 | int preferred_bpp; | 187 | int preferred_bpp; |
163 | }; | 188 | }; |
164 | 189 | ||
@@ -497,12 +522,10 @@ struct intel_crtc_state { | |||
497 | */ | 522 | */ |
498 | bool limited_color_range; | 523 | bool limited_color_range; |
499 | 524 | ||
500 | /* DP has a bunch of special case unfortunately, so mark the pipe | 525 | /* Bitmask of encoder types (enum intel_output_type) |
501 | * accordingly. */ | 526 | * driven by the pipe. |
502 | bool has_dp_encoder; | 527 | */ |
503 | 528 | unsigned int output_types; | |
504 | /* DSI has special cases */ | ||
505 | bool has_dsi_encoder; | ||
506 | 529 | ||
507 | /* Whether we should send NULL infoframes. Required for audio. */ | 530 | /* Whether we should send NULL infoframes. Required for audio. */ |
508 | bool has_hdmi_sink; | 531 | bool has_hdmi_sink; |
@@ -861,6 +884,11 @@ struct intel_dp { | |||
861 | * this port. Only relevant on VLV/CHV. | 884 | * this port. Only relevant on VLV/CHV. |
862 | */ | 885 | */ |
863 | enum pipe pps_pipe; | 886 | enum pipe pps_pipe; |
887 | /* | ||
888 | * Set if the sequencer may be reset due to a power transition, | ||
889 | * requiring a reinitialization. Only relevant on BXT. | ||
890 | */ | ||
891 | bool pps_reset; | ||
864 | struct edp_power_seq pps_delays; | 892 | struct edp_power_seq pps_delays; |
865 | 893 | ||
866 | bool can_mst; /* this port supports mst */ | 894 | bool can_mst; /* this port supports mst */ |
@@ -957,14 +985,14 @@ vlv_pipe_to_channel(enum pipe pipe) | |||
957 | static inline struct drm_crtc * | 985 | static inline struct drm_crtc * |
958 | intel_get_crtc_for_pipe(struct drm_device *dev, int pipe) | 986 | intel_get_crtc_for_pipe(struct drm_device *dev, int pipe) |
959 | { | 987 | { |
960 | struct drm_i915_private *dev_priv = dev->dev_private; | 988 | struct drm_i915_private *dev_priv = to_i915(dev); |
961 | return dev_priv->pipe_to_crtc_mapping[pipe]; | 989 | return dev_priv->pipe_to_crtc_mapping[pipe]; |
962 | } | 990 | } |
963 | 991 | ||
964 | static inline struct drm_crtc * | 992 | static inline struct drm_crtc * |
965 | intel_get_crtc_for_plane(struct drm_device *dev, int plane) | 993 | intel_get_crtc_for_plane(struct drm_device *dev, int plane) |
966 | { | 994 | { |
967 | struct drm_i915_private *dev_priv = dev->dev_private; | 995 | struct drm_i915_private *dev_priv = to_i915(dev); |
968 | return dev_priv->plane_to_crtc_mapping[plane]; | 996 | return dev_priv->plane_to_crtc_mapping[plane]; |
969 | } | 997 | } |
970 | 998 | ||
@@ -1157,7 +1185,20 @@ int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data, | |||
1157 | struct drm_file *file_priv); | 1185 | struct drm_file *file_priv); |
1158 | enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv, | 1186 | enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv, |
1159 | enum pipe pipe); | 1187 | enum pipe pipe); |
1160 | bool intel_pipe_has_type(struct intel_crtc *crtc, enum intel_output_type type); | 1188 | static inline bool |
1189 | intel_crtc_has_type(const struct intel_crtc_state *crtc_state, | ||
1190 | enum intel_output_type type) | ||
1191 | { | ||
1192 | return crtc_state->output_types & (1 << type); | ||
1193 | } | ||
1194 | static inline bool | ||
1195 | intel_crtc_has_dp_encoder(const struct intel_crtc_state *crtc_state) | ||
1196 | { | ||
1197 | return crtc_state->output_types & | ||
1198 | ((1 << INTEL_OUTPUT_DP) | | ||
1199 | (1 << INTEL_OUTPUT_DP_MST) | | ||
1200 | (1 << INTEL_OUTPUT_EDP)); | ||
1201 | } | ||
1161 | static inline void | 1202 | static inline void |
1162 | intel_wait_for_vblank(struct drm_device *dev, int pipe) | 1203 | intel_wait_for_vblank(struct drm_device *dev, int pipe) |
1163 | { | 1204 | { |
@@ -1338,7 +1379,7 @@ void intel_dp_mst_resume(struct drm_device *dev); | |||
1338 | int intel_dp_max_link_rate(struct intel_dp *intel_dp); | 1379 | int intel_dp_max_link_rate(struct intel_dp *intel_dp); |
1339 | int intel_dp_rate_select(struct intel_dp *intel_dp, int rate); | 1380 | int intel_dp_rate_select(struct intel_dp *intel_dp, int rate); |
1340 | void intel_dp_hot_plug(struct intel_encoder *intel_encoder); | 1381 | void intel_dp_hot_plug(struct intel_encoder *intel_encoder); |
1341 | void vlv_power_sequencer_reset(struct drm_i915_private *dev_priv); | 1382 | void intel_power_sequencer_reset(struct drm_i915_private *dev_priv); |
1342 | uint32_t intel_dp_pack_aux(const uint8_t *src, int src_bytes); | 1383 | uint32_t intel_dp_pack_aux(const uint8_t *src, int src_bytes); |
1343 | void intel_plane_destroy(struct drm_plane *plane); | 1384 | void intel_plane_destroy(struct drm_plane *plane); |
1344 | void intel_edp_drrs_enable(struct intel_dp *intel_dp); | 1385 | void intel_edp_drrs_enable(struct intel_dp *intel_dp); |
@@ -1451,6 +1492,7 @@ void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable); | |||
1451 | 1492 | ||
1452 | /* intel_lvds.c */ | 1493 | /* intel_lvds.c */ |
1453 | void intel_lvds_init(struct drm_device *dev); | 1494 | void intel_lvds_init(struct drm_device *dev); |
1495 | struct intel_encoder *intel_get_lvds_encoder(struct drm_device *dev); | ||
1454 | bool intel_is_dual_link_lvds(struct drm_device *dev); | 1496 | bool intel_is_dual_link_lvds(struct drm_device *dev); |
1455 | 1497 | ||
1456 | 1498 | ||
@@ -1489,7 +1531,8 @@ void intel_gmch_panel_fitting(struct intel_crtc *crtc, | |||
1489 | int fitting_mode); | 1531 | int fitting_mode); |
1490 | void intel_panel_set_backlight_acpi(struct intel_connector *connector, | 1532 | void intel_panel_set_backlight_acpi(struct intel_connector *connector, |
1491 | u32 level, u32 max); | 1533 | u32 level, u32 max); |
1492 | int intel_panel_setup_backlight(struct drm_connector *connector, enum pipe pipe); | 1534 | int intel_panel_setup_backlight(struct drm_connector *connector, |
1535 | enum pipe pipe); | ||
1493 | void intel_panel_enable_backlight(struct intel_connector *connector); | 1536 | void intel_panel_enable_backlight(struct intel_connector *connector); |
1494 | void intel_panel_disable_backlight(struct intel_connector *connector); | 1537 | void intel_panel_disable_backlight(struct intel_connector *connector); |
1495 | void intel_panel_destroy_backlight(struct drm_connector *connector); | 1538 | void intel_panel_destroy_backlight(struct drm_connector *connector); |
@@ -1498,11 +1541,15 @@ extern struct drm_display_mode *intel_find_panel_downclock( | |||
1498 | struct drm_device *dev, | 1541 | struct drm_device *dev, |
1499 | struct drm_display_mode *fixed_mode, | 1542 | struct drm_display_mode *fixed_mode, |
1500 | struct drm_connector *connector); | 1543 | struct drm_connector *connector); |
1501 | void intel_backlight_register(struct drm_device *dev); | ||
1502 | 1544 | ||
1503 | #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE) | 1545 | #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE) |
1546 | int intel_backlight_device_register(struct intel_connector *connector); | ||
1504 | void intel_backlight_device_unregister(struct intel_connector *connector); | 1547 | void intel_backlight_device_unregister(struct intel_connector *connector); |
1505 | #else /* CONFIG_BACKLIGHT_CLASS_DEVICE */ | 1548 | #else /* CONFIG_BACKLIGHT_CLASS_DEVICE */ |
1549 | static int intel_backlight_device_register(struct intel_connector *connector) | ||
1550 | { | ||
1551 | return 0; | ||
1552 | } | ||
1506 | static inline void intel_backlight_device_unregister(struct intel_connector *connector) | 1553 | static inline void intel_backlight_device_unregister(struct intel_connector *connector) |
1507 | { | 1554 | { |
1508 | } | 1555 | } |