2 * Copyright 2007-8 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
23 * Authors: Dave Airlie
27 #include <drm/amdgpu_drm.h>
29 #include "amdgpu_i2c.h"
31 #include "amdgpu_connectors.h"
32 #include "amdgpu_display.h"
33 #include <asm/div64.h>
35 #include <linux/pci.h>
36 #include <linux/pm_runtime.h>
37 #include <drm/drm_crtc_helper.h>
38 #include <drm/drm_edid.h>
39 #include <drm/drm_gem_framebuffer_helper.h>
40 #include <drm/drm_fb_helper.h>
41 #include <drm/drm_fourcc.h>
42 #include <drm/drm_vblank.h>
44 static void amdgpu_display_flip_callback(struct dma_fence *f,
45 struct dma_fence_cb *cb)
47 struct amdgpu_flip_work *work =
48 container_of(cb, struct amdgpu_flip_work, cb);
51 schedule_work(&work->flip_work.work);
54 static bool amdgpu_display_flip_handle_fence(struct amdgpu_flip_work *work,
57 struct dma_fence *fence= *f;
64 if (!dma_fence_add_callback(fence, &work->cb,
65 amdgpu_display_flip_callback))
72 static void amdgpu_display_flip_work_func(struct work_struct *__work)
74 struct delayed_work *delayed_work =
75 container_of(__work, struct delayed_work, work);
76 struct amdgpu_flip_work *work =
77 container_of(delayed_work, struct amdgpu_flip_work, flip_work);
78 struct amdgpu_device *adev = work->adev;
79 struct amdgpu_crtc *amdgpu_crtc = adev->mode_info.crtcs[work->crtc_id];
81 struct drm_crtc *crtc = &amdgpu_crtc->base;
86 if (amdgpu_display_flip_handle_fence(work, &work->excl))
89 for (i = 0; i < work->shared_count; ++i)
90 if (amdgpu_display_flip_handle_fence(work, &work->shared[i]))
93 /* Wait until we're out of the vertical blank period before the one
94 * targeted by the flip
96 if (amdgpu_crtc->enabled &&
97 (amdgpu_display_get_crtc_scanoutpos(adev_to_drm(adev), work->crtc_id, 0,
98 &vpos, &hpos, NULL, NULL,
100 & (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK)) ==
101 (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK) &&
102 (int)(work->target_vblank -
103 amdgpu_get_vblank_counter_kms(crtc)) > 0) {
104 schedule_delayed_work(&work->flip_work, usecs_to_jiffies(1000));
108 /* We borrow the event spin lock for protecting flip_status */
109 spin_lock_irqsave(&crtc->dev->event_lock, flags);
111 /* Do the flip (mmio) */
112 adev->mode_info.funcs->page_flip(adev, work->crtc_id, work->base, work->async);
114 /* Set the flip status */
115 amdgpu_crtc->pflip_status = AMDGPU_FLIP_SUBMITTED;
116 spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
119 DRM_DEBUG_DRIVER("crtc:%d[%p], pflip_stat:AMDGPU_FLIP_SUBMITTED, work: %p,\n",
120 amdgpu_crtc->crtc_id, amdgpu_crtc, work);
125 * Handle unpin events outside the interrupt handler proper.
127 static void amdgpu_display_unpin_work_func(struct work_struct *__work)
129 struct amdgpu_flip_work *work =
130 container_of(__work, struct amdgpu_flip_work, unpin_work);
133 /* unpin of the old buffer */
134 r = amdgpu_bo_reserve(work->old_abo, true);
135 if (likely(r == 0)) {
136 amdgpu_bo_unpin(work->old_abo);
137 amdgpu_bo_unreserve(work->old_abo);
139 DRM_ERROR("failed to reserve buffer after flip\n");
141 amdgpu_bo_unref(&work->old_abo);
146 int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,
147 struct drm_framebuffer *fb,
148 struct drm_pending_vblank_event *event,
149 uint32_t page_flip_flags, uint32_t target,
150 struct drm_modeset_acquire_ctx *ctx)
152 struct drm_device *dev = crtc->dev;
153 struct amdgpu_device *adev = drm_to_adev(dev);
154 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
155 struct drm_gem_object *obj;
156 struct amdgpu_flip_work *work;
157 struct amdgpu_bo *new_abo;
162 work = kzalloc(sizeof *work, GFP_KERNEL);
166 INIT_DELAYED_WORK(&work->flip_work, amdgpu_display_flip_work_func);
167 INIT_WORK(&work->unpin_work, amdgpu_display_unpin_work_func);
171 work->crtc_id = amdgpu_crtc->crtc_id;
172 work->async = (page_flip_flags & DRM_MODE_PAGE_FLIP_ASYNC) != 0;
174 /* schedule unpin of the old buffer */
175 obj = crtc->primary->fb->obj[0];
177 /* take a reference to the old object */
178 work->old_abo = gem_to_amdgpu_bo(obj);
179 amdgpu_bo_ref(work->old_abo);
182 new_abo = gem_to_amdgpu_bo(obj);
184 /* pin the new buffer */
185 r = amdgpu_bo_reserve(new_abo, false);
186 if (unlikely(r != 0)) {
187 DRM_ERROR("failed to reserve new abo buffer before flip\n");
191 if (!adev->enable_virtual_display) {
192 r = amdgpu_bo_pin(new_abo,
193 amdgpu_display_supported_domains(adev, new_abo->flags));
194 if (unlikely(r != 0)) {
195 DRM_ERROR("failed to pin new abo buffer before flip\n");
200 r = amdgpu_ttm_alloc_gart(&new_abo->tbo);
201 if (unlikely(r != 0)) {
202 DRM_ERROR("%p bind failed\n", new_abo);
206 r = dma_resv_get_fences_rcu(new_abo->tbo.base.resv, &work->excl,
209 if (unlikely(r != 0)) {
210 DRM_ERROR("failed to get fences for buffer\n");
214 amdgpu_bo_get_tiling_flags(new_abo, &tiling_flags);
215 amdgpu_bo_unreserve(new_abo);
217 if (!adev->enable_virtual_display)
218 work->base = amdgpu_bo_gpu_offset(new_abo);
219 work->target_vblank = target - (uint32_t)drm_crtc_vblank_count(crtc) +
220 amdgpu_get_vblank_counter_kms(crtc);
222 /* we borrow the event spin lock for protecting flip_wrok */
223 spin_lock_irqsave(&crtc->dev->event_lock, flags);
224 if (amdgpu_crtc->pflip_status != AMDGPU_FLIP_NONE) {
225 DRM_DEBUG_DRIVER("flip queue: crtc already busy\n");
226 spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
231 amdgpu_crtc->pflip_status = AMDGPU_FLIP_PENDING;
232 amdgpu_crtc->pflip_works = work;
235 DRM_DEBUG_DRIVER("crtc:%d[%p], pflip_stat:AMDGPU_FLIP_PENDING, work: %p,\n",
236 amdgpu_crtc->crtc_id, amdgpu_crtc, work);
238 crtc->primary->fb = fb;
239 spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
240 amdgpu_display_flip_work_func(&work->flip_work.work);
244 if (unlikely(amdgpu_bo_reserve(new_abo, false) != 0)) {
245 DRM_ERROR("failed to reserve new abo in error path\n");
249 if (!adev->enable_virtual_display)
250 amdgpu_bo_unpin(new_abo);
253 amdgpu_bo_unreserve(new_abo);
256 amdgpu_bo_unref(&work->old_abo);
257 dma_fence_put(work->excl);
258 for (i = 0; i < work->shared_count; ++i)
259 dma_fence_put(work->shared[i]);
266 int amdgpu_display_crtc_set_config(struct drm_mode_set *set,
267 struct drm_modeset_acquire_ctx *ctx)
269 struct drm_device *dev;
270 struct amdgpu_device *adev;
271 struct drm_crtc *crtc;
275 if (!set || !set->crtc)
278 dev = set->crtc->dev;
280 ret = pm_runtime_get_sync(dev->dev);
284 ret = drm_crtc_helper_set_config(set, ctx);
286 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
290 pm_runtime_mark_last_busy(dev->dev);
292 adev = drm_to_adev(dev);
293 /* if we have active crtcs and we don't have a power ref,
294 take the current one */
295 if (active && !adev->have_disp_power_ref) {
296 adev->have_disp_power_ref = true;
299 /* if we have no active crtcs, then drop the power ref
301 if (!active && adev->have_disp_power_ref) {
302 pm_runtime_put_autosuspend(dev->dev);
303 adev->have_disp_power_ref = false;
307 /* drop the power reference we got coming in here */
308 pm_runtime_put_autosuspend(dev->dev);
312 static const char *encoder_names[41] = {
332 "INTERNAL_KLDSCP_TMDS1",
333 "INTERNAL_KLDSCP_DVO1",
334 "INTERNAL_KLDSCP_DAC1",
335 "INTERNAL_KLDSCP_DAC2",
344 "INTERNAL_KLDSCP_LVTMA",
356 static const char *hpd_names[6] = {
365 void amdgpu_display_print_display_setup(struct drm_device *dev)
367 struct drm_connector *connector;
368 struct amdgpu_connector *amdgpu_connector;
369 struct drm_encoder *encoder;
370 struct amdgpu_encoder *amdgpu_encoder;
371 struct drm_connector_list_iter iter;
375 drm_connector_list_iter_begin(dev, &iter);
376 DRM_INFO("AMDGPU Display Connectors\n");
377 drm_for_each_connector_iter(connector, &iter) {
378 amdgpu_connector = to_amdgpu_connector(connector);
379 DRM_INFO("Connector %d:\n", i);
380 DRM_INFO(" %s\n", connector->name);
381 if (amdgpu_connector->hpd.hpd != AMDGPU_HPD_NONE)
382 DRM_INFO(" %s\n", hpd_names[amdgpu_connector->hpd.hpd]);
383 if (amdgpu_connector->ddc_bus) {
384 DRM_INFO(" DDC: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
385 amdgpu_connector->ddc_bus->rec.mask_clk_reg,
386 amdgpu_connector->ddc_bus->rec.mask_data_reg,
387 amdgpu_connector->ddc_bus->rec.a_clk_reg,
388 amdgpu_connector->ddc_bus->rec.a_data_reg,
389 amdgpu_connector->ddc_bus->rec.en_clk_reg,
390 amdgpu_connector->ddc_bus->rec.en_data_reg,
391 amdgpu_connector->ddc_bus->rec.y_clk_reg,
392 amdgpu_connector->ddc_bus->rec.y_data_reg);
393 if (amdgpu_connector->router.ddc_valid)
394 DRM_INFO(" DDC Router 0x%x/0x%x\n",
395 amdgpu_connector->router.ddc_mux_control_pin,
396 amdgpu_connector->router.ddc_mux_state);
397 if (amdgpu_connector->router.cd_valid)
398 DRM_INFO(" Clock/Data Router 0x%x/0x%x\n",
399 amdgpu_connector->router.cd_mux_control_pin,
400 amdgpu_connector->router.cd_mux_state);
402 if (connector->connector_type == DRM_MODE_CONNECTOR_VGA ||
403 connector->connector_type == DRM_MODE_CONNECTOR_DVII ||
404 connector->connector_type == DRM_MODE_CONNECTOR_DVID ||
405 connector->connector_type == DRM_MODE_CONNECTOR_DVIA ||
406 connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
407 connector->connector_type == DRM_MODE_CONNECTOR_HDMIB)
410 DRM_INFO(" Encoders:\n");
411 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
412 amdgpu_encoder = to_amdgpu_encoder(encoder);
413 devices = amdgpu_encoder->devices & amdgpu_connector->devices;
415 if (devices & ATOM_DEVICE_CRT1_SUPPORT)
416 DRM_INFO(" CRT1: %s\n", encoder_names[amdgpu_encoder->encoder_id]);
417 if (devices & ATOM_DEVICE_CRT2_SUPPORT)
418 DRM_INFO(" CRT2: %s\n", encoder_names[amdgpu_encoder->encoder_id]);
419 if (devices & ATOM_DEVICE_LCD1_SUPPORT)
420 DRM_INFO(" LCD1: %s\n", encoder_names[amdgpu_encoder->encoder_id]);
421 if (devices & ATOM_DEVICE_DFP1_SUPPORT)
422 DRM_INFO(" DFP1: %s\n", encoder_names[amdgpu_encoder->encoder_id]);
423 if (devices & ATOM_DEVICE_DFP2_SUPPORT)
424 DRM_INFO(" DFP2: %s\n", encoder_names[amdgpu_encoder->encoder_id]);
425 if (devices & ATOM_DEVICE_DFP3_SUPPORT)
426 DRM_INFO(" DFP3: %s\n", encoder_names[amdgpu_encoder->encoder_id]);
427 if (devices & ATOM_DEVICE_DFP4_SUPPORT)
428 DRM_INFO(" DFP4: %s\n", encoder_names[amdgpu_encoder->encoder_id]);
429 if (devices & ATOM_DEVICE_DFP5_SUPPORT)
430 DRM_INFO(" DFP5: %s\n", encoder_names[amdgpu_encoder->encoder_id]);
431 if (devices & ATOM_DEVICE_DFP6_SUPPORT)
432 DRM_INFO(" DFP6: %s\n", encoder_names[amdgpu_encoder->encoder_id]);
433 if (devices & ATOM_DEVICE_TV1_SUPPORT)
434 DRM_INFO(" TV1: %s\n", encoder_names[amdgpu_encoder->encoder_id]);
435 if (devices & ATOM_DEVICE_CV_SUPPORT)
436 DRM_INFO(" CV: %s\n", encoder_names[amdgpu_encoder->encoder_id]);
441 drm_connector_list_iter_end(&iter);
444 bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
450 struct i2c_msg msgs[] = {
465 /* on hw with routers, select right port */
466 if (amdgpu_connector->router.ddc_valid)
467 amdgpu_i2c_router_select_ddc_port(amdgpu_connector);
470 ret = i2c_transfer(&amdgpu_connector->ddc_bus->aux.ddc, msgs, 2);
472 ret = i2c_transfer(&amdgpu_connector->ddc_bus->adapter, msgs, 2);
476 /* Couldn't find an accessible DDC on this connector */
478 /* Probe also for valid EDID header
479 * EDID header starts with:
480 * 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00.
481 * Only the first 6 bytes must be valid as
482 * drm_edid_block_valid() can fix the last 2 bytes */
483 if (drm_edid_header_is_valid(buf) < 6) {
484 /* Couldn't find an accessible EDID on this
491 static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
492 .destroy = drm_gem_fb_destroy,
493 .create_handle = drm_gem_fb_create_handle,
496 uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
499 uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM;
501 #if defined(CONFIG_DRM_AMD_DC)
503 * if amdgpu_bo_support_uswc returns false it means that USWC mappings
504 * is not supported for this board. But this mapping is required
505 * to avoid hang caused by placement of scanout BO in GTT on certain
506 * APUs. So force the BO placement to VRAM in case this architecture
507 * will not allow USWC mappings.
508 * Also, don't allow GTT domain if the BO doesn't have USWC flag set.
510 if ((bo_flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) &&
511 amdgpu_bo_support_uswc(bo_flags) &&
512 amdgpu_device_asic_has_dc_support(adev->asic_type)) {
513 switch (adev->asic_type) {
516 domain |= AMDGPU_GEM_DOMAIN_GTT;
519 /* enable S/G on PCO and RV2 */
520 if ((adev->apu_flags & AMD_APU_IS_RAVEN2) ||
521 (adev->apu_flags & AMD_APU_IS_PICASSO))
522 domain |= AMDGPU_GEM_DOMAIN_GTT;
526 domain |= AMDGPU_GEM_DOMAIN_GTT;
538 static const struct drm_format_info dcc_formats[] = {
539 { .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 2,
540 .cpp = { 4, 0, }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1, },
541 { .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 2,
542 .cpp = { 4, 0, }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1, },
543 { .format = DRM_FORMAT_ARGB8888, .depth = 32, .num_planes = 2,
544 .cpp = { 4, 0, }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1,
545 .has_alpha = true, },
546 { .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 2,
547 .cpp = { 4, 0, }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1,
548 .has_alpha = true, },
549 { .format = DRM_FORMAT_BGRA8888, .depth = 32, .num_planes = 2,
550 .cpp = { 4, 0, }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1,
551 .has_alpha = true, },
552 { .format = DRM_FORMAT_XRGB2101010, .depth = 30, .num_planes = 2,
553 .cpp = { 4, 0, }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1, },
554 { .format = DRM_FORMAT_XBGR2101010, .depth = 30, .num_planes = 2,
555 .cpp = { 4, 0, }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1, },
556 { .format = DRM_FORMAT_ARGB2101010, .depth = 30, .num_planes = 2,
557 .cpp = { 4, 0, }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1,
558 .has_alpha = true, },
559 { .format = DRM_FORMAT_ABGR2101010, .depth = 30, .num_planes = 2,
560 .cpp = { 4, 0, }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1,
561 .has_alpha = true, },
562 { .format = DRM_FORMAT_RGB565, .depth = 16, .num_planes = 2,
563 .cpp = { 2, 0, }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1, },
566 static const struct drm_format_info dcc_retile_formats[] = {
567 { .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 3,
568 .cpp = { 4, 0, 0 }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1, },
569 { .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 3,
570 .cpp = { 4, 0, 0 }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1, },
571 { .format = DRM_FORMAT_ARGB8888, .depth = 32, .num_planes = 3,
572 .cpp = { 4, 0, 0 }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1,
573 .has_alpha = true, },
574 { .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 3,
575 .cpp = { 4, 0, 0 }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1,
576 .has_alpha = true, },
577 { .format = DRM_FORMAT_BGRA8888, .depth = 32, .num_planes = 3,
578 .cpp = { 4, 0, 0 }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1,
579 .has_alpha = true, },
580 { .format = DRM_FORMAT_XRGB2101010, .depth = 30, .num_planes = 3,
581 .cpp = { 4, 0, 0 }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1, },
582 { .format = DRM_FORMAT_XBGR2101010, .depth = 30, .num_planes = 3,
583 .cpp = { 4, 0, 0 }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1, },
584 { .format = DRM_FORMAT_ARGB2101010, .depth = 30, .num_planes = 3,
585 .cpp = { 4, 0, 0 }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1,
586 .has_alpha = true, },
587 { .format = DRM_FORMAT_ABGR2101010, .depth = 30, .num_planes = 3,
588 .cpp = { 4, 0, 0 }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1,
589 .has_alpha = true, },
590 { .format = DRM_FORMAT_RGB565, .depth = 16, .num_planes = 3,
591 .cpp = { 2, 0, 0 }, .block_w = {1, 1, 1}, .block_h = {1, 1, 1}, .hsub = 1, .vsub = 1, },
594 static const struct drm_format_info *
595 lookup_format_info(const struct drm_format_info formats[],
596 int num_formats, u32 format)
600 for (i = 0; i < num_formats; i++) {
601 if (formats[i].format == format)
608 const struct drm_format_info *
609 amdgpu_lookup_format_info(u32 format, uint64_t modifier)
611 if (!IS_AMD_FMT_MOD(modifier))
614 if (AMD_FMT_MOD_GET(DCC_RETILE, modifier))
615 return lookup_format_info(dcc_retile_formats,
616 ARRAY_SIZE(dcc_retile_formats),
619 if (AMD_FMT_MOD_GET(DCC, modifier))
620 return lookup_format_info(dcc_formats, ARRAY_SIZE(dcc_formats),
623 /* returning NULL will cause the default format structs to be used. */
629 * Tries to extract the renderable DCC offset from the opaque metadata attached
633 extract_render_dcc_offset(struct amdgpu_device *adev,
634 struct drm_gem_object *obj,
637 struct amdgpu_bo *rbo;
639 uint32_t metadata[10]; /* Something that fits a descriptor + header. */
642 rbo = gem_to_amdgpu_bo(obj);
643 r = amdgpu_bo_reserve(rbo, false);
646 /* Don't show error message when returning -ERESTARTSYS */
647 if (r != -ERESTARTSYS)
648 DRM_ERROR("Unable to reserve buffer: %d\n", r);
652 r = amdgpu_bo_get_metadata(rbo, metadata, sizeof(metadata), &size, NULL);
653 amdgpu_bo_unreserve(rbo);
659 * The first word is the metadata version, and we need space for at least
660 * the version + pci vendor+device id + 8 words for a descriptor.
662 if (size < 40 || metadata[0] != 1)
665 if (adev->family >= AMDGPU_FAMILY_NV) {
666 /* resource word 6/7 META_DATA_ADDRESS{_LO} */
667 *offset = ((u64)metadata[9] << 16u) |
668 ((metadata[8] & 0xFF000000u) >> 16);
670 /* resource word 5/7 META_DATA_ADDRESS */
671 *offset = ((u64)metadata[9] << 8u) |
672 ((u64)(metadata[7] & 0x1FE0000u) << 23);
678 static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)
680 struct amdgpu_device *adev = drm_to_adev(afb->base.dev);
681 uint64_t modifier = 0;
683 if (!afb->tiling_flags || !AMDGPU_TILING_GET(afb->tiling_flags, SWIZZLE_MODE)) {
684 modifier = DRM_FORMAT_MOD_LINEAR;
686 int swizzle = AMDGPU_TILING_GET(afb->tiling_flags, SWIZZLE_MODE);
687 bool has_xor = swizzle >= 16;
690 int pipe_xor_bits = 0;
691 int bank_xor_bits = 0;
694 int pipes = ilog2(adev->gfx.config.gb_addr_config_fields.num_pipes);
695 uint32_t dcc_offset = AMDGPU_TILING_GET(afb->tiling_flags, DCC_OFFSET_256B);
697 switch (swizzle >> 2) {
702 case 5: /* 4KiB _X */
703 block_size_bits = 12;
706 case 4: /* 64 KiB _T */
707 case 6: /* 64 KiB _X */
708 block_size_bits = 16;
711 /* RESERVED or VAR */
715 if (adev->asic_type >= CHIP_SIENNA_CICHLID)
716 version = AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS;
717 else if (adev->family == AMDGPU_FAMILY_NV)
718 version = AMD_FMT_MOD_TILE_VER_GFX10;
720 version = AMD_FMT_MOD_TILE_VER_GFX9;
722 switch (swizzle & 3) {
723 case 0: /* Z microtiling */
725 case 1: /* S microtiling */
727 version = AMD_FMT_MOD_TILE_VER_GFX9;
730 if (!has_xor && afb->base.format->cpp[0] != 4)
731 version = AMD_FMT_MOD_TILE_VER_GFX9;
739 case AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS:
740 pipe_xor_bits = min(block_size_bits - 8, pipes);
741 packers = min(block_size_bits - 8 - pipe_xor_bits,
742 ilog2(adev->gfx.config.gb_addr_config_fields.num_pkrs));
744 case AMD_FMT_MOD_TILE_VER_GFX10:
745 pipe_xor_bits = min(block_size_bits - 8, pipes);
747 case AMD_FMT_MOD_TILE_VER_GFX9:
748 rb = ilog2(adev->gfx.config.gb_addr_config_fields.num_se) +
749 ilog2(adev->gfx.config.gb_addr_config_fields.num_rb_per_se);
750 pipe_xor_bits = min(block_size_bits - 8, pipes +
751 ilog2(adev->gfx.config.gb_addr_config_fields.num_se));
752 bank_xor_bits = min(block_size_bits - 8 - pipe_xor_bits,
753 ilog2(adev->gfx.config.gb_addr_config_fields.num_banks));
758 modifier = AMD_FMT_MOD |
759 AMD_FMT_MOD_SET(TILE, AMDGPU_TILING_GET(afb->tiling_flags, SWIZZLE_MODE)) |
760 AMD_FMT_MOD_SET(TILE_VERSION, version) |
761 AMD_FMT_MOD_SET(PIPE_XOR_BITS, pipe_xor_bits) |
762 AMD_FMT_MOD_SET(BANK_XOR_BITS, bank_xor_bits) |
763 AMD_FMT_MOD_SET(PACKERS, packers);
765 if (dcc_offset != 0) {
766 bool dcc_i64b = AMDGPU_TILING_GET(afb->tiling_flags, DCC_INDEPENDENT_64B) != 0;
767 bool dcc_i128b = version >= AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS;
768 const struct drm_format_info *format_info;
769 u64 render_dcc_offset;
771 /* Enable constant encode on RAVEN2 and later. */
772 bool dcc_constant_encode = adev->asic_type > CHIP_RAVEN ||
773 (adev->asic_type == CHIP_RAVEN &&
774 adev->external_rev_id >= 0x81);
776 int max_cblock_size = dcc_i64b ? AMD_FMT_MOD_DCC_BLOCK_64B :
777 dcc_i128b ? AMD_FMT_MOD_DCC_BLOCK_128B :
778 AMD_FMT_MOD_DCC_BLOCK_256B;
780 modifier |= AMD_FMT_MOD_SET(DCC, 1) |
781 AMD_FMT_MOD_SET(DCC_CONSTANT_ENCODE, dcc_constant_encode) |
782 AMD_FMT_MOD_SET(DCC_INDEPENDENT_64B, dcc_i64b) |
783 AMD_FMT_MOD_SET(DCC_INDEPENDENT_128B, dcc_i128b) |
784 AMD_FMT_MOD_SET(DCC_MAX_COMPRESSED_BLOCK, max_cblock_size);
786 afb->base.offsets[1] = dcc_offset * 256 + afb->base.offsets[0];
787 afb->base.pitches[1] =
788 AMDGPU_TILING_GET(afb->tiling_flags, DCC_PITCH_MAX) + 1;
791 * If the userspace driver uses retiling the tiling flags do not contain
792 * info on the renderable DCC buffer. Luckily the opaque metadata contains
793 * the info so we can try to extract it. The kernel does not use this info
794 * but we should convert it to a modifier plane for getfb2, so the
795 * userspace driver that gets it doesn't have to juggle around another DCC
798 if (extract_render_dcc_offset(adev, afb->base.obj[0],
799 &render_dcc_offset) == 0 &&
800 render_dcc_offset != 0 &&
801 render_dcc_offset != afb->base.offsets[1] &&
802 render_dcc_offset < UINT_MAX) {
803 uint32_t dcc_block_bits; /* of base surface data */
805 modifier |= AMD_FMT_MOD_SET(DCC_RETILE, 1);
806 afb->base.offsets[2] = render_dcc_offset;
808 if (adev->family >= AMDGPU_FAMILY_NV) {
811 if (adev->asic_type >= CHIP_SIENNA_CICHLID &&
812 pipes == packers && pipes > 1)
815 dcc_block_bits = max(20, 16 + pipes + extra_pipe);
817 modifier |= AMD_FMT_MOD_SET(RB, rb) |
818 AMD_FMT_MOD_SET(PIPE, pipes);
819 dcc_block_bits = max(20, 18 + rb);
822 dcc_block_bits -= ilog2(afb->base.format->cpp[0]);
823 afb->base.pitches[2] = ALIGN(afb->base.width,
824 1u << ((dcc_block_bits + 1) / 2));
826 format_info = amdgpu_lookup_format_info(afb->base.format->format,
831 afb->base.format = format_info;
835 afb->base.modifier = modifier;
836 afb->base.flags |= DRM_MODE_FB_MODIFIERS;
840 static int amdgpu_display_get_fb_info(const struct amdgpu_framebuffer *amdgpu_fb,
841 uint64_t *tiling_flags, bool *tmz_surface)
843 struct amdgpu_bo *rbo;
848 *tmz_surface = false;
852 rbo = gem_to_amdgpu_bo(amdgpu_fb->base.obj[0]);
853 r = amdgpu_bo_reserve(rbo, false);
856 /* Don't show error message when returning -ERESTARTSYS */
857 if (r != -ERESTARTSYS)
858 DRM_ERROR("Unable to reserve buffer: %d\n", r);
863 amdgpu_bo_get_tiling_flags(rbo, tiling_flags);
866 *tmz_surface = amdgpu_bo_encrypted(rbo);
868 amdgpu_bo_unreserve(rbo);
873 int amdgpu_display_framebuffer_init(struct drm_device *dev,
874 struct amdgpu_framebuffer *rfb,
875 const struct drm_mode_fb_cmd2 *mode_cmd,
876 struct drm_gem_object *obj)
879 rfb->base.obj[0] = obj;
880 drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
881 ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
886 * This needs to happen before modifier conversion as that might change
887 * the number of planes.
889 for (i = 1; i < rfb->base.format->num_planes; ++i) {
890 if (mode_cmd->handles[i] != mode_cmd->handles[0]) {
891 drm_dbg_kms(dev, "Plane 0 and %d have different BOs: %u vs. %u\n",
892 i, mode_cmd->handles[0], mode_cmd->handles[i]);
898 ret = amdgpu_display_get_fb_info(rfb, &rfb->tiling_flags, &rfb->tmz_surface);
902 if (dev->mode_config.allow_fb_modifiers &&
903 !(rfb->base.flags & DRM_MODE_FB_MODIFIERS)) {
904 ret = convert_tiling_flags_to_modifier(rfb);
906 drm_dbg_kms(dev, "Failed to convert tiling flags 0x%llX to a modifier",
912 for (i = 1; i < rfb->base.format->num_planes; ++i) {
913 rfb->base.obj[i] = rfb->base.obj[0];
914 drm_gem_object_get(rfb->base.obj[i]);
920 rfb->base.obj[0] = NULL;
924 struct drm_framebuffer *
925 amdgpu_display_user_framebuffer_create(struct drm_device *dev,
926 struct drm_file *file_priv,
927 const struct drm_mode_fb_cmd2 *mode_cmd)
929 struct drm_gem_object *obj;
930 struct amdgpu_framebuffer *amdgpu_fb;
933 obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
935 drm_dbg_kms(dev, "No GEM object associated to handle 0x%08X, "
936 "can't create framebuffer\n", mode_cmd->handles[0]);
937 return ERR_PTR(-ENOENT);
940 /* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
941 if (obj->import_attach) {
942 drm_dbg_kms(dev, "Cannot create framebuffer from imported dma_buf\n");
943 return ERR_PTR(-EINVAL);
946 amdgpu_fb = kzalloc(sizeof(*amdgpu_fb), GFP_KERNEL);
947 if (amdgpu_fb == NULL) {
948 drm_gem_object_put(obj);
949 return ERR_PTR(-ENOMEM);
952 ret = amdgpu_display_framebuffer_init(dev, amdgpu_fb, mode_cmd, obj);
955 drm_gem_object_put(obj);
959 return &amdgpu_fb->base;
962 const struct drm_mode_config_funcs amdgpu_mode_funcs = {
963 .fb_create = amdgpu_display_user_framebuffer_create,
964 .output_poll_changed = drm_fb_helper_output_poll_changed,
967 static const struct drm_prop_enum_list amdgpu_underscan_enum_list[] =
968 { { UNDERSCAN_OFF, "off" },
969 { UNDERSCAN_ON, "on" },
970 { UNDERSCAN_AUTO, "auto" },
973 static const struct drm_prop_enum_list amdgpu_audio_enum_list[] =
974 { { AMDGPU_AUDIO_DISABLE, "off" },
975 { AMDGPU_AUDIO_ENABLE, "on" },
976 { AMDGPU_AUDIO_AUTO, "auto" },
979 /* XXX support different dither options? spatial, temporal, both, etc. */
980 static const struct drm_prop_enum_list amdgpu_dither_enum_list[] =
981 { { AMDGPU_FMT_DITHER_DISABLE, "off" },
982 { AMDGPU_FMT_DITHER_ENABLE, "on" },
985 int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
989 adev->mode_info.coherent_mode_property =
990 drm_property_create_range(adev_to_drm(adev), 0, "coherent", 0, 1);
991 if (!adev->mode_info.coherent_mode_property)
994 adev->mode_info.load_detect_property =
995 drm_property_create_range(adev_to_drm(adev), 0, "load detection", 0, 1);
996 if (!adev->mode_info.load_detect_property)
999 drm_mode_create_scaling_mode_property(adev_to_drm(adev));
1001 sz = ARRAY_SIZE(amdgpu_underscan_enum_list);
1002 adev->mode_info.underscan_property =
1003 drm_property_create_enum(adev_to_drm(adev), 0,
1005 amdgpu_underscan_enum_list, sz);
1007 adev->mode_info.underscan_hborder_property =
1008 drm_property_create_range(adev_to_drm(adev), 0,
1009 "underscan hborder", 0, 128);
1010 if (!adev->mode_info.underscan_hborder_property)
1013 adev->mode_info.underscan_vborder_property =
1014 drm_property_create_range(adev_to_drm(adev), 0,
1015 "underscan vborder", 0, 128);
1016 if (!adev->mode_info.underscan_vborder_property)
1019 sz = ARRAY_SIZE(amdgpu_audio_enum_list);
1020 adev->mode_info.audio_property =
1021 drm_property_create_enum(adev_to_drm(adev), 0,
1023 amdgpu_audio_enum_list, sz);
1025 sz = ARRAY_SIZE(amdgpu_dither_enum_list);
1026 adev->mode_info.dither_property =
1027 drm_property_create_enum(adev_to_drm(adev), 0,
1029 amdgpu_dither_enum_list, sz);
1031 if (amdgpu_device_has_dc_support(adev)) {
1032 adev->mode_info.abm_level_property =
1033 drm_property_create_range(adev_to_drm(adev), 0,
1035 if (!adev->mode_info.abm_level_property)
1042 void amdgpu_display_update_priority(struct amdgpu_device *adev)
1044 /* adjustment options for the display watermarks */
1045 if ((amdgpu_disp_priority == 0) || (amdgpu_disp_priority > 2))
1046 adev->mode_info.disp_priority = 0;
1048 adev->mode_info.disp_priority = amdgpu_disp_priority;
1052 static bool amdgpu_display_is_hdtv_mode(const struct drm_display_mode *mode)
1054 /* try and guess if this is a tv or a monitor */
1055 if ((mode->vdisplay == 480 && mode->hdisplay == 720) || /* 480p */
1056 (mode->vdisplay == 576) || /* 576p */
1057 (mode->vdisplay == 720) || /* 720p */
1058 (mode->vdisplay == 1080)) /* 1080p */
1064 bool amdgpu_display_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
1065 const struct drm_display_mode *mode,
1066 struct drm_display_mode *adjusted_mode)
1068 struct drm_device *dev = crtc->dev;
1069 struct drm_encoder *encoder;
1070 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
1071 struct amdgpu_encoder *amdgpu_encoder;
1072 struct drm_connector *connector;
1073 u32 src_v = 1, dst_v = 1;
1074 u32 src_h = 1, dst_h = 1;
1076 amdgpu_crtc->h_border = 0;
1077 amdgpu_crtc->v_border = 0;
1079 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
1080 if (encoder->crtc != crtc)
1082 amdgpu_encoder = to_amdgpu_encoder(encoder);
1083 connector = amdgpu_get_connector_for_encoder(encoder);
1086 if (amdgpu_encoder->rmx_type == RMX_OFF)
1087 amdgpu_crtc->rmx_type = RMX_OFF;
1088 else if (mode->hdisplay < amdgpu_encoder->native_mode.hdisplay ||
1089 mode->vdisplay < amdgpu_encoder->native_mode.vdisplay)
1090 amdgpu_crtc->rmx_type = amdgpu_encoder->rmx_type;
1092 amdgpu_crtc->rmx_type = RMX_OFF;
1093 /* copy native mode */
1094 memcpy(&amdgpu_crtc->native_mode,
1095 &amdgpu_encoder->native_mode,
1096 sizeof(struct drm_display_mode));
1097 src_v = crtc->mode.vdisplay;
1098 dst_v = amdgpu_crtc->native_mode.vdisplay;
1099 src_h = crtc->mode.hdisplay;
1100 dst_h = amdgpu_crtc->native_mode.hdisplay;
1102 /* fix up for overscan on hdmi */
1103 if ((!(mode->flags & DRM_MODE_FLAG_INTERLACE)) &&
1104 ((amdgpu_encoder->underscan_type == UNDERSCAN_ON) ||
1105 ((amdgpu_encoder->underscan_type == UNDERSCAN_AUTO) &&
1106 drm_detect_hdmi_monitor(amdgpu_connector_edid(connector)) &&
1107 amdgpu_display_is_hdtv_mode(mode)))) {
1108 if (amdgpu_encoder->underscan_hborder != 0)
1109 amdgpu_crtc->h_border = amdgpu_encoder->underscan_hborder;
1111 amdgpu_crtc->h_border = (mode->hdisplay >> 5) + 16;
1112 if (amdgpu_encoder->underscan_vborder != 0)
1113 amdgpu_crtc->v_border = amdgpu_encoder->underscan_vborder;
1115 amdgpu_crtc->v_border = (mode->vdisplay >> 5) + 16;
1116 amdgpu_crtc->rmx_type = RMX_FULL;
1117 src_v = crtc->mode.vdisplay;
1118 dst_v = crtc->mode.vdisplay - (amdgpu_crtc->v_border * 2);
1119 src_h = crtc->mode.hdisplay;
1120 dst_h = crtc->mode.hdisplay - (amdgpu_crtc->h_border * 2);
1123 if (amdgpu_crtc->rmx_type != RMX_OFF) {
1125 a.full = dfixed_const(src_v);
1126 b.full = dfixed_const(dst_v);
1127 amdgpu_crtc->vsc.full = dfixed_div(a, b);
1128 a.full = dfixed_const(src_h);
1129 b.full = dfixed_const(dst_h);
1130 amdgpu_crtc->hsc.full = dfixed_div(a, b);
1132 amdgpu_crtc->vsc.full = dfixed_const(1);
1133 amdgpu_crtc->hsc.full = dfixed_const(1);
1139 * Retrieve current video scanout position of crtc on a given gpu, and
1140 * an optional accurate timestamp of when query happened.
1142 * \param dev Device to query.
1143 * \param pipe Crtc to query.
1144 * \param flags Flags from caller (DRM_CALLED_FROM_VBLIRQ or 0).
1145 * For driver internal use only also supports these flags:
1147 * USE_REAL_VBLANKSTART to use the real start of vblank instead
1148 * of a fudged earlier start of vblank.
1150 * GET_DISTANCE_TO_VBLANKSTART to return distance to the
1151 * fudged earlier start of vblank in *vpos and the distance
1152 * to true start of vblank in *hpos.
1154 * \param *vpos Location where vertical scanout position should be stored.
1155 * \param *hpos Location where horizontal scanout position should go.
1156 * \param *stime Target location for timestamp taken immediately before
1157 * scanout position query. Can be NULL to skip timestamp.
1158 * \param *etime Target location for timestamp taken immediately after
1159 * scanout position query. Can be NULL to skip timestamp.
1161 * Returns vpos as a positive number while in active scanout area.
1162 * Returns vpos as a negative number inside vblank, counting the number
1163 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
1164 * until start of active scanout / end of vblank."
1166 * \return Flags, or'ed together as follows:
1168 * DRM_SCANOUTPOS_VALID = Query successful.
1169 * DRM_SCANOUTPOS_INVBL = Inside vblank.
1170 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
1171 * this flag means that returned position may be offset by a constant but
1172 * unknown small number of scanlines wrt. real scanout position.
1175 int amdgpu_display_get_crtc_scanoutpos(struct drm_device *dev,
1176 unsigned int pipe, unsigned int flags, int *vpos,
1177 int *hpos, ktime_t *stime, ktime_t *etime,
1178 const struct drm_display_mode *mode)
1180 u32 vbl = 0, position = 0;
1181 int vbl_start, vbl_end, vtotal, ret = 0;
1184 struct amdgpu_device *adev = drm_to_adev(dev);
1186 /* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
1188 /* Get optional system timestamp before query. */
1190 *stime = ktime_get();
1192 if (amdgpu_display_page_flip_get_scanoutpos(adev, pipe, &vbl, &position) == 0)
1193 ret |= DRM_SCANOUTPOS_VALID;
1195 /* Get optional system timestamp after query. */
1197 *etime = ktime_get();
1199 /* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */
1201 /* Decode into vertical and horizontal scanout position. */
1202 *vpos = position & 0x1fff;
1203 *hpos = (position >> 16) & 0x1fff;
1205 /* Valid vblank area boundaries from gpu retrieved? */
1208 ret |= DRM_SCANOUTPOS_ACCURATE;
1209 vbl_start = vbl & 0x1fff;
1210 vbl_end = (vbl >> 16) & 0x1fff;
1213 /* No: Fake something reasonable which gives at least ok results. */
1214 vbl_start = mode->crtc_vdisplay;
1218 /* Called from driver internal vblank counter query code? */
1219 if (flags & GET_DISTANCE_TO_VBLANKSTART) {
1220 /* Caller wants distance from real vbl_start in *hpos */
1221 *hpos = *vpos - vbl_start;
1224 /* Fudge vblank to start a few scanlines earlier to handle the
1225 * problem that vblank irqs fire a few scanlines before start
1226 * of vblank. Some driver internal callers need the true vblank
1227 * start to be used and signal this via the USE_REAL_VBLANKSTART flag.
1229 * The cause of the "early" vblank irq is that the irq is triggered
1230 * by the line buffer logic when the line buffer read position enters
1231 * the vblank, whereas our crtc scanout position naturally lags the
1232 * line buffer read position.
1234 if (!(flags & USE_REAL_VBLANKSTART))
1235 vbl_start -= adev->mode_info.crtcs[pipe]->lb_vblank_lead_lines;
1237 /* Test scanout position against vblank region. */
1238 if ((*vpos < vbl_start) && (*vpos >= vbl_end))
1243 ret |= DRM_SCANOUTPOS_IN_VBLANK;
1245 /* Called from driver internal vblank counter query code? */
1246 if (flags & GET_DISTANCE_TO_VBLANKSTART) {
1247 /* Caller wants distance from fudged earlier vbl_start */
1252 /* Check if inside vblank area and apply corrective offsets:
1253 * vpos will then be >=0 in video scanout area, but negative
1254 * within vblank area, counting down the number of lines until
1258 /* Inside "upper part" of vblank area? Apply corrective offset if so: */
1259 if (in_vbl && (*vpos >= vbl_start)) {
1260 vtotal = mode->crtc_vtotal;
1262 /* With variable refresh rate displays the vpos can exceed
1263 * the vtotal value. Clamp to 0 to return -vbl_end instead
1264 * of guessing the remaining number of lines until scanout.
1266 *vpos = (*vpos < vtotal) ? (*vpos - vtotal) : 0;
1269 /* Correct for shifted end of vbl at vbl_end. */
1270 *vpos = *vpos - vbl_end;
1275 int amdgpu_display_crtc_idx_to_irq_type(struct amdgpu_device *adev, int crtc)
1277 if (crtc < 0 || crtc >= adev->mode_info.num_crtc)
1278 return AMDGPU_CRTC_IRQ_NONE;
1282 return AMDGPU_CRTC_IRQ_VBLANK1;
1284 return AMDGPU_CRTC_IRQ_VBLANK2;
1286 return AMDGPU_CRTC_IRQ_VBLANK3;
1288 return AMDGPU_CRTC_IRQ_VBLANK4;
1290 return AMDGPU_CRTC_IRQ_VBLANK5;
1292 return AMDGPU_CRTC_IRQ_VBLANK6;
1294 return AMDGPU_CRTC_IRQ_NONE;
1298 bool amdgpu_crtc_get_scanout_position(struct drm_crtc *crtc,
1299 bool in_vblank_irq, int *vpos,
1300 int *hpos, ktime_t *stime, ktime_t *etime,
1301 const struct drm_display_mode *mode)
1303 struct drm_device *dev = crtc->dev;
1304 unsigned int pipe = crtc->index;
1306 return amdgpu_display_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
1307 stime, etime, mode);