diff options
Diffstat (limited to 'drivers/gpu/drm/drm_irq.c')
-rw-r--r-- | drivers/gpu/drm/drm_irq.c | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 8c866cac62dd..677b37b0372b 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c | |||
@@ -724,43 +724,32 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants); | |||
724 | * active. Higher level code is expected to handle this. | 724 | * active. Higher level code is expected to handle this. |
725 | * | 725 | * |
726 | * Returns: | 726 | * Returns: |
727 | * Negative value on error, failure or if not supported in current | ||
728 | * video mode: | ||
729 | * | ||
730 | * -EINVAL Invalid CRTC. | ||
731 | * -EAGAIN Temporary unavailable, e.g., called before initial modeset. | ||
732 | * -ENOTSUPP Function not supported in current display mode. | ||
733 | * -EIO Failed, e.g., due to failed scanout position query. | ||
734 | * | ||
735 | * Returns or'ed positive status flags on success: | ||
736 | * | ||
737 | * DRM_VBLANKTIME_SCANOUTPOS_METHOD - Signal this method used for timestamping. | ||
738 | * DRM_VBLANKTIME_INVBL - Timestamp taken while scanout was in vblank interval. | ||
739 | * | 727 | * |
728 | * Returns true on success, and false on failure, i.e. when no accurate | ||
729 | * timestamp could be acquired. | ||
740 | */ | 730 | */ |
741 | int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, | 731 | bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, |
742 | unsigned int pipe, | 732 | unsigned int pipe, |
743 | int *max_error, | 733 | int *max_error, |
744 | struct timeval *vblank_time, | 734 | struct timeval *vblank_time, |
745 | unsigned flags, | 735 | unsigned flags, |
746 | const struct drm_display_mode *mode) | 736 | const struct drm_display_mode *mode) |
747 | { | 737 | { |
748 | struct timeval tv_etime; | 738 | struct timeval tv_etime; |
749 | ktime_t stime, etime; | 739 | ktime_t stime, etime; |
750 | unsigned int vbl_status; | 740 | unsigned int vbl_status; |
751 | int ret = DRM_VBLANKTIME_SCANOUTPOS_METHOD; | ||
752 | int vpos, hpos, i; | 741 | int vpos, hpos, i; |
753 | int delta_ns, duration_ns; | 742 | int delta_ns, duration_ns; |
754 | 743 | ||
755 | if (pipe >= dev->num_crtcs) { | 744 | if (pipe >= dev->num_crtcs) { |
756 | DRM_ERROR("Invalid crtc %u\n", pipe); | 745 | DRM_ERROR("Invalid crtc %u\n", pipe); |
757 | return -EINVAL; | 746 | return false; |
758 | } | 747 | } |
759 | 748 | ||
760 | /* Scanout position query not supported? Should not happen. */ | 749 | /* Scanout position query not supported? Should not happen. */ |
761 | if (!dev->driver->get_scanout_position) { | 750 | if (!dev->driver->get_scanout_position) { |
762 | DRM_ERROR("Called from driver w/o get_scanout_position()!?\n"); | 751 | DRM_ERROR("Called from driver w/o get_scanout_position()!?\n"); |
763 | return -EIO; | 752 | return false; |
764 | } | 753 | } |
765 | 754 | ||
766 | /* If mode timing undefined, just return as no-op: | 755 | /* If mode timing undefined, just return as no-op: |
@@ -768,7 +757,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, | |||
768 | */ | 757 | */ |
769 | if (mode->crtc_clock == 0) { | 758 | if (mode->crtc_clock == 0) { |
770 | DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe); | 759 | DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe); |
771 | return -EAGAIN; | 760 | return false; |
772 | } | 761 | } |
773 | 762 | ||
774 | /* Get current scanout position with system timestamp. | 763 | /* Get current scanout position with system timestamp. |
@@ -792,7 +781,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, | |||
792 | if (!(vbl_status & DRM_SCANOUTPOS_VALID)) { | 781 | if (!(vbl_status & DRM_SCANOUTPOS_VALID)) { |
793 | DRM_DEBUG("crtc %u : scanoutpos query failed [0x%x].\n", | 782 | DRM_DEBUG("crtc %u : scanoutpos query failed [0x%x].\n", |
794 | pipe, vbl_status); | 783 | pipe, vbl_status); |
795 | return -EIO; | 784 | return false; |
796 | } | 785 | } |
797 | 786 | ||
798 | /* Compute uncertainty in timestamp of scanout position query. */ | 787 | /* Compute uncertainty in timestamp of scanout position query. */ |
@@ -836,7 +825,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, | |||
836 | (long)vblank_time->tv_sec, (long)vblank_time->tv_usec, | 825 | (long)vblank_time->tv_sec, (long)vblank_time->tv_usec, |
837 | duration_ns/1000, i); | 826 | duration_ns/1000, i); |
838 | 827 | ||
839 | return ret; | 828 | return true; |
840 | } | 829 | } |
841 | EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos); | 830 | EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos); |
842 | 831 | ||
@@ -872,25 +861,23 @@ static bool | |||
872 | drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe, | 861 | drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe, |
873 | struct timeval *tvblank, unsigned flags) | 862 | struct timeval *tvblank, unsigned flags) |
874 | { | 863 | { |
875 | int ret; | 864 | bool ret = false; |
876 | 865 | ||
877 | /* Define requested maximum error on timestamps (nanoseconds). */ | 866 | /* Define requested maximum error on timestamps (nanoseconds). */ |
878 | int max_error = (int) drm_timestamp_precision * 1000; | 867 | int max_error = (int) drm_timestamp_precision * 1000; |
879 | 868 | ||
880 | /* Query driver if possible and precision timestamping enabled. */ | 869 | /* Query driver if possible and precision timestamping enabled. */ |
881 | if (dev->driver->get_vblank_timestamp && (max_error > 0)) { | 870 | if (dev->driver->get_vblank_timestamp && (max_error > 0)) |
882 | ret = dev->driver->get_vblank_timestamp(dev, pipe, &max_error, | 871 | ret = dev->driver->get_vblank_timestamp(dev, pipe, &max_error, |
883 | tvblank, flags); | 872 | tvblank, flags); |
884 | if (ret > 0) | ||
885 | return true; | ||
886 | } | ||
887 | 873 | ||
888 | /* GPU high precision timestamp query unsupported or failed. | 874 | /* GPU high precision timestamp query unsupported or failed. |
889 | * Return current monotonic/gettimeofday timestamp as best estimate. | 875 | * Return current monotonic/gettimeofday timestamp as best estimate. |
890 | */ | 876 | */ |
891 | *tvblank = get_drm_timestamp(); | 877 | if (!ret) |
878 | *tvblank = get_drm_timestamp(); | ||
892 | 879 | ||
893 | return false; | 880 | return ret; |
894 | } | 881 | } |
895 | 882 | ||
896 | /** | 883 | /** |