.. | .. |
---|
23 | 23 | * Authors: Dave Airlie |
---|
24 | 24 | * Alex Deucher |
---|
25 | 25 | */ |
---|
26 | | -#include <drm/drmP.h> |
---|
27 | | -#include <drm/radeon_drm.h> |
---|
28 | | -#include "radeon.h" |
---|
29 | 26 | |
---|
30 | | -#include "atom.h" |
---|
| 27 | +#include <linux/pci.h> |
---|
| 28 | +#include <linux/pm_runtime.h> |
---|
| 29 | +#include <linux/gcd.h> |
---|
| 30 | + |
---|
31 | 31 | #include <asm/div64.h> |
---|
32 | 32 | |
---|
33 | | -#include <linux/pm_runtime.h> |
---|
34 | 33 | #include <drm/drm_crtc_helper.h> |
---|
35 | | -#include <drm/drm_gem_framebuffer_helper.h> |
---|
36 | | -#include <drm/drm_fb_helper.h> |
---|
37 | | -#include <drm/drm_plane_helper.h> |
---|
| 34 | +#include <drm/drm_device.h> |
---|
| 35 | +#include <drm/drm_drv.h> |
---|
38 | 36 | #include <drm/drm_edid.h> |
---|
| 37 | +#include <drm/drm_fb_helper.h> |
---|
| 38 | +#include <drm/drm_fourcc.h> |
---|
| 39 | +#include <drm/drm_gem_framebuffer_helper.h> |
---|
| 40 | +#include <drm/drm_plane_helper.h> |
---|
| 41 | +#include <drm/drm_probe_helper.h> |
---|
| 42 | +#include <drm/drm_vblank.h> |
---|
| 43 | +#include <drm/radeon_drm.h> |
---|
39 | 44 | |
---|
40 | | -#include <linux/gcd.h> |
---|
| 45 | +#include "atom.h" |
---|
| 46 | +#include "radeon.h" |
---|
| 47 | + |
---|
| 48 | +u32 radeon_get_vblank_counter_kms(struct drm_crtc *crtc); |
---|
| 49 | +int radeon_enable_vblank_kms(struct drm_crtc *crtc); |
---|
| 50 | +void radeon_disable_vblank_kms(struct drm_crtc *crtc); |
---|
41 | 51 | |
---|
42 | 52 | static void avivo_crtc_load_lut(struct drm_crtc *crtc) |
---|
43 | 53 | { |
---|
.. | .. |
---|
271 | 281 | } else |
---|
272 | 282 | DRM_ERROR("failed to reserve buffer after flip\n"); |
---|
273 | 283 | |
---|
274 | | - drm_gem_object_put_unlocked(&work->old_rbo->gem_base); |
---|
| 284 | + drm_gem_object_put(&work->old_rbo->tbo.base); |
---|
275 | 285 | kfree(work); |
---|
276 | 286 | } |
---|
277 | 287 | |
---|
.. | .. |
---|
454 | 464 | (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK) && |
---|
455 | 465 | (!ASIC_IS_AVIVO(rdev) || |
---|
456 | 466 | ((int) (work->target_vblank - |
---|
457 | | - dev->driver->get_vblank_counter(dev, work->crtc_id)) > 0))) |
---|
| 467 | + crtc->funcs->get_vblank_counter(crtc)) > 0))) |
---|
458 | 468 | usleep_range(1000, 2000); |
---|
459 | 469 | |
---|
460 | 470 | /* We borrow the event spin lock for protecting flip_status */ |
---|
.. | .. |
---|
529 | 539 | DRM_ERROR("failed to pin new rbo buffer before flip\n"); |
---|
530 | 540 | goto cleanup; |
---|
531 | 541 | } |
---|
532 | | - work->fence = dma_fence_get(reservation_object_get_excl(new_rbo->tbo.resv)); |
---|
| 542 | + work->fence = dma_fence_get(dma_resv_get_excl(new_rbo->tbo.base.resv)); |
---|
533 | 543 | radeon_bo_get_tiling_flags(new_rbo, &tiling_flags, NULL); |
---|
534 | 544 | radeon_bo_unreserve(new_rbo); |
---|
535 | 545 | |
---|
.. | .. |
---|
570 | 580 | } |
---|
571 | 581 | work->base = base; |
---|
572 | 582 | work->target_vblank = target - (uint32_t)drm_crtc_vblank_count(crtc) + |
---|
573 | | - dev->driver->get_vblank_counter(dev, work->crtc_id); |
---|
| 583 | + crtc->funcs->get_vblank_counter(crtc); |
---|
574 | 584 | |
---|
575 | 585 | /* We borrow the event spin lock for protecting flip_work */ |
---|
576 | 586 | spin_lock_irqsave(&crtc->dev->event_lock, flags); |
---|
.. | .. |
---|
603 | 613 | radeon_bo_unreserve(new_rbo); |
---|
604 | 614 | |
---|
605 | 615 | cleanup: |
---|
606 | | - drm_gem_object_put_unlocked(&work->old_rbo->gem_base); |
---|
| 616 | + drm_gem_object_put(&work->old_rbo->tbo.base); |
---|
607 | 617 | dma_fence_put(work->fence); |
---|
608 | 618 | kfree(work); |
---|
609 | 619 | return r; |
---|
.. | .. |
---|
664 | 674 | .set_config = radeon_crtc_set_config, |
---|
665 | 675 | .destroy = radeon_crtc_destroy, |
---|
666 | 676 | .page_flip_target = radeon_crtc_page_flip_target, |
---|
| 677 | + .get_vblank_counter = radeon_get_vblank_counter_kms, |
---|
| 678 | + .enable_vblank = radeon_enable_vblank_kms, |
---|
| 679 | + .disable_vblank = radeon_disable_vblank_kms, |
---|
| 680 | + .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp, |
---|
667 | 681 | }; |
---|
668 | 682 | |
---|
669 | 683 | static void radeon_crtc_init(struct drm_device *dev, int index) |
---|
670 | 684 | { |
---|
671 | 685 | struct radeon_device *rdev = dev->dev_private; |
---|
672 | 686 | struct radeon_crtc *radeon_crtc; |
---|
673 | | - int i; |
---|
674 | 687 | |
---|
675 | 688 | radeon_crtc = kzalloc(sizeof(struct radeon_crtc) + (RADEONFB_CONN_LIMIT * sizeof(struct drm_connector *)), GFP_KERNEL); |
---|
676 | 689 | if (radeon_crtc == NULL) |
---|
.. | .. |
---|
698 | 711 | radeon_crtc->mode_set.connectors = (struct drm_connector **)(radeon_crtc + 1); |
---|
699 | 712 | radeon_crtc->mode_set.num_connectors = 0; |
---|
700 | 713 | #endif |
---|
701 | | - |
---|
702 | | - for (i = 0; i < 256; i++) { |
---|
703 | | - radeon_crtc->lut_r[i] = i << 2; |
---|
704 | | - radeon_crtc->lut_g[i] = i << 2; |
---|
705 | | - radeon_crtc->lut_b[i] = i << 2; |
---|
706 | | - } |
---|
707 | 714 | |
---|
708 | 715 | if (rdev->is_atom_bios && (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom)) |
---|
709 | 716 | radeon_atombios_init_crtc(dev, radeon_crtc); |
---|
.. | .. |
---|
845 | 852 | if (rdev->bios) { |
---|
846 | 853 | if (rdev->is_atom_bios) { |
---|
847 | 854 | ret = radeon_get_atom_connector_info_from_supported_devices_table(dev); |
---|
848 | | - if (ret == false) |
---|
| 855 | + if (!ret) |
---|
849 | 856 | ret = radeon_get_atom_connector_info_from_object_table(dev); |
---|
850 | 857 | } else { |
---|
851 | 858 | ret = radeon_get_legacy_connector_info_from_bios(dev); |
---|
852 | | - if (ret == false) |
---|
| 859 | + if (!ret) |
---|
853 | 860 | ret = radeon_get_legacy_connector_info_from_table(dev); |
---|
854 | 861 | } |
---|
855 | 862 | } else { |
---|
.. | .. |
---|
1333 | 1340 | |
---|
1334 | 1341 | fb = kzalloc(sizeof(*fb), GFP_KERNEL); |
---|
1335 | 1342 | if (fb == NULL) { |
---|
1336 | | - drm_gem_object_put_unlocked(obj); |
---|
| 1343 | + drm_gem_object_put(obj); |
---|
1337 | 1344 | return ERR_PTR(-ENOMEM); |
---|
1338 | 1345 | } |
---|
1339 | 1346 | |
---|
1340 | 1347 | ret = radeon_framebuffer_init(dev, fb, mode_cmd, obj); |
---|
1341 | 1348 | if (ret) { |
---|
1342 | 1349 | kfree(fb); |
---|
1343 | | - drm_gem_object_put_unlocked(obj); |
---|
| 1350 | + drm_gem_object_put(obj); |
---|
1344 | 1351 | return ERR_PTR(ret); |
---|
1345 | 1352 | } |
---|
1346 | 1353 | |
---|
.. | .. |
---|
1651 | 1658 | if (rdev->mode_info.mode_config_initialized) { |
---|
1652 | 1659 | drm_kms_helper_poll_fini(rdev->ddev); |
---|
1653 | 1660 | radeon_hpd_fini(rdev); |
---|
1654 | | - drm_crtc_force_disable_all(rdev->ddev); |
---|
| 1661 | + drm_helper_force_disable_all(rdev->ddev); |
---|
1655 | 1662 | radeon_fbdev_fini(rdev); |
---|
1656 | 1663 | radeon_afmt_fini(rdev); |
---|
1657 | 1664 | drm_mode_config_cleanup(rdev->ddev); |
---|
.. | .. |
---|
1686 | 1693 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
---|
1687 | 1694 | struct radeon_encoder *radeon_encoder; |
---|
1688 | 1695 | struct drm_connector *connector; |
---|
1689 | | - struct radeon_connector *radeon_connector; |
---|
1690 | 1696 | bool first = true; |
---|
1691 | 1697 | u32 src_v = 1, dst_v = 1; |
---|
1692 | 1698 | u32 src_h = 1, dst_h = 1; |
---|
.. | .. |
---|
1699 | 1705 | continue; |
---|
1700 | 1706 | radeon_encoder = to_radeon_encoder(encoder); |
---|
1701 | 1707 | connector = radeon_get_connector_for_encoder(encoder); |
---|
1702 | | - radeon_connector = to_radeon_connector(connector); |
---|
1703 | 1708 | |
---|
1704 | 1709 | if (first) { |
---|
1705 | 1710 | /* set scaling */ |
---|
.. | .. |
---|
1818 | 1823 | struct radeon_device *rdev = dev->dev_private; |
---|
1819 | 1824 | |
---|
1820 | 1825 | /* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */ |
---|
1821 | | - preempt_disable_rt(); |
---|
1822 | 1826 | |
---|
1823 | 1827 | /* Get optional system timestamp before query. */ |
---|
1824 | 1828 | if (stime) |
---|
.. | .. |
---|
1911 | 1915 | *etime = ktime_get(); |
---|
1912 | 1916 | |
---|
1913 | 1917 | /* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */ |
---|
1914 | | - preempt_enable_rt(); |
---|
1915 | 1918 | |
---|
1916 | 1919 | /* Decode into vertical and horizontal scanout position. */ |
---|
1917 | 1920 | *vpos = position & 0x1fff; |
---|
.. | .. |
---|
1981 | 1984 | |
---|
1982 | 1985 | return ret; |
---|
1983 | 1986 | } |
---|
| 1987 | + |
---|
| 1988 | +bool |
---|
| 1989 | +radeon_get_crtc_scanout_position(struct drm_crtc *crtc, |
---|
| 1990 | + bool in_vblank_irq, int *vpos, int *hpos, |
---|
| 1991 | + ktime_t *stime, ktime_t *etime, |
---|
| 1992 | + const struct drm_display_mode *mode) |
---|
| 1993 | +{ |
---|
| 1994 | + struct drm_device *dev = crtc->dev; |
---|
| 1995 | + unsigned int pipe = crtc->index; |
---|
| 1996 | + |
---|
| 1997 | + return radeon_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos, |
---|
| 1998 | + stime, etime, mode); |
---|
| 1999 | +} |
---|