diff options
Diffstat (limited to 'drivers/gpu')
| -rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 110 |
1 files changed, 30 insertions, 80 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 138ef22078d9..805ef2f408a7 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
| @@ -1771,12 +1771,11 @@ int drm_mode_getresources(struct drm_device *dev, void *data, | |||
| 1771 | int crtc_count = 0; | 1771 | int crtc_count = 0; |
| 1772 | int fb_count = 0; | 1772 | int fb_count = 0; |
| 1773 | int encoder_count = 0; | 1773 | int encoder_count = 0; |
| 1774 | int copied = 0, i; | 1774 | int copied = 0; |
| 1775 | uint32_t __user *fb_id; | 1775 | uint32_t __user *fb_id; |
| 1776 | uint32_t __user *crtc_id; | 1776 | uint32_t __user *crtc_id; |
| 1777 | uint32_t __user *connector_id; | 1777 | uint32_t __user *connector_id; |
| 1778 | uint32_t __user *encoder_id; | 1778 | uint32_t __user *encoder_id; |
| 1779 | struct drm_mode_group *mode_group; | ||
| 1780 | 1779 | ||
| 1781 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) | 1780 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
| 1782 | return -EINVAL; | 1781 | return -EINVAL; |
| @@ -1809,27 +1808,14 @@ int drm_mode_getresources(struct drm_device *dev, void *data, | |||
| 1809 | /* mode_config.mutex protects the connector list against e.g. DP MST | 1808 | /* mode_config.mutex protects the connector list against e.g. DP MST |
| 1810 | * connector hot-adding. CRTC/Plane lists are invariant. */ | 1809 | * connector hot-adding. CRTC/Plane lists are invariant. */ |
| 1811 | mutex_lock(&dev->mode_config.mutex); | 1810 | mutex_lock(&dev->mode_config.mutex); |
| 1812 | if (!drm_is_primary_client(file_priv)) { | 1811 | drm_for_each_crtc(crtc, dev) |
| 1813 | struct drm_connector *connector; | 1812 | crtc_count++; |
| 1814 | struct drm_encoder *encoder; | ||
| 1815 | struct drm_crtc *crtc; | ||
| 1816 | |||
| 1817 | mode_group = NULL; | ||
| 1818 | drm_for_each_crtc(crtc, dev) | ||
| 1819 | crtc_count++; | ||
| 1820 | |||
| 1821 | drm_for_each_connector(connector, dev) | ||
| 1822 | connector_count++; | ||
| 1823 | 1813 | ||
| 1824 | drm_for_each_encoder(encoder, dev) | 1814 | drm_for_each_connector(connector, dev) |
| 1825 | encoder_count++; | 1815 | connector_count++; |
| 1826 | } else { | ||
| 1827 | 1816 | ||
| 1828 | mode_group = &file_priv->master->minor->mode_group; | 1817 | drm_for_each_encoder(encoder, dev) |
| 1829 | crtc_count = mode_group->num_crtcs; | 1818 | encoder_count++; |
| 1830 | connector_count = mode_group->num_connectors; | ||
| 1831 | encoder_count = mode_group->num_encoders; | ||
| 1832 | } | ||
| 1833 | 1819 | ||
| 1834 | card_res->max_height = dev->mode_config.max_height; | 1820 | card_res->max_height = dev->mode_config.max_height; |
| 1835 | card_res->min_height = dev->mode_config.min_height; | 1821 | card_res->min_height = dev->mode_config.min_height; |
| @@ -1840,24 +1826,13 @@ int drm_mode_getresources(struct drm_device *dev, void *data, | |||
| 1840 | if (card_res->count_crtcs >= crtc_count) { | 1826 | if (card_res->count_crtcs >= crtc_count) { |
| 1841 | copied = 0; | 1827 | copied = 0; |
| 1842 | crtc_id = (uint32_t __user *)(unsigned long)card_res->crtc_id_ptr; | 1828 | crtc_id = (uint32_t __user *)(unsigned long)card_res->crtc_id_ptr; |
| 1843 | if (!mode_group) { | 1829 | drm_for_each_crtc(crtc, dev) { |
| 1844 | drm_for_each_crtc(crtc, dev) { | 1830 | DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id); |
| 1845 | DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id); | 1831 | if (put_user(crtc->base.id, crtc_id + copied)) { |
| 1846 | if (put_user(crtc->base.id, crtc_id + copied)) { | 1832 | ret = -EFAULT; |
| 1847 | ret = -EFAULT; | 1833 | goto out; |
| 1848 | goto out; | ||
| 1849 | } | ||
| 1850 | copied++; | ||
| 1851 | } | ||
| 1852 | } else { | ||
| 1853 | for (i = 0; i < mode_group->num_crtcs; i++) { | ||
| 1854 | if (put_user(mode_group->id_list[i], | ||
| 1855 | crtc_id + copied)) { | ||
| 1856 | ret = -EFAULT; | ||
| 1857 | goto out; | ||
| 1858 | } | ||
| 1859 | copied++; | ||
| 1860 | } | 1834 | } |
| 1835 | copied++; | ||
| 1861 | } | 1836 | } |
| 1862 | } | 1837 | } |
| 1863 | card_res->count_crtcs = crtc_count; | 1838 | card_res->count_crtcs = crtc_count; |
| @@ -1866,27 +1841,15 @@ int drm_mode_getresources(struct drm_device *dev, void *data, | |||
| 1866 | if (card_res->count_encoders >= encoder_count) { | 1841 | if (card_res->count_encoders >= encoder_count) { |
| 1867 | copied = 0; | 1842 | copied = 0; |
| 1868 | encoder_id = (uint32_t __user *)(unsigned long)card_res->encoder_id_ptr; | 1843 | encoder_id = (uint32_t __user *)(unsigned long)card_res->encoder_id_ptr; |
| 1869 | if (!mode_group) { | 1844 | drm_for_each_encoder(encoder, dev) { |
| 1870 | drm_for_each_encoder(encoder, dev) { | 1845 | DRM_DEBUG_KMS("[ENCODER:%d:%s]\n", encoder->base.id, |
| 1871 | DRM_DEBUG_KMS("[ENCODER:%d:%s]\n", encoder->base.id, | 1846 | encoder->name); |
| 1872 | encoder->name); | 1847 | if (put_user(encoder->base.id, encoder_id + |
| 1873 | if (put_user(encoder->base.id, encoder_id + | 1848 | copied)) { |
| 1874 | copied)) { | 1849 | ret = -EFAULT; |
| 1875 | ret = -EFAULT; | 1850 | goto out; |
| 1876 | goto out; | ||
| 1877 | } | ||
| 1878 | copied++; | ||
| 1879 | } | ||
| 1880 | } else { | ||
| 1881 | for (i = mode_group->num_crtcs; i < mode_group->num_crtcs + mode_group->num_encoders; i++) { | ||
| 1882 | if (put_user(mode_group->id_list[i], | ||
| 1883 | encoder_id + copied)) { | ||
| 1884 | ret = -EFAULT; | ||
| 1885 | goto out; | ||
| 1886 | } | ||
| 1887 | copied++; | ||
| 1888 | } | 1851 | } |
| 1889 | 1852 | copied++; | |
| 1890 | } | 1853 | } |
| 1891 | } | 1854 | } |
| 1892 | card_res->count_encoders = encoder_count; | 1855 | card_res->count_encoders = encoder_count; |
| @@ -1895,29 +1858,16 @@ int drm_mode_getresources(struct drm_device *dev, void *data, | |||
| 1895 | if (card_res->count_connectors >= connector_count) { | 1858 | if (card_res->count_connectors >= connector_count) { |
| 1896 | copied = 0; | 1859 | copied = 0; |
| 1897 | connector_id = (uint32_t __user *)(unsigned long)card_res->connector_id_ptr; | 1860 | connector_id = (uint32_t __user *)(unsigned long)card_res->connector_id_ptr; |
| 1898 | if (!mode_group) { | 1861 | drm_for_each_connector(connector, dev) { |
| 1899 | drm_for_each_connector(connector, dev) { | 1862 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
| 1900 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", | 1863 | connector->base.id, |
| 1901 | connector->base.id, | 1864 | connector->name); |
| 1902 | connector->name); | 1865 | if (put_user(connector->base.id, |
| 1903 | if (put_user(connector->base.id, | 1866 | connector_id + copied)) { |
| 1904 | connector_id + copied)) { | 1867 | ret = -EFAULT; |
| 1905 | ret = -EFAULT; | 1868 | goto out; |
| 1906 | goto out; | ||
| 1907 | } | ||
| 1908 | copied++; | ||
| 1909 | } | ||
| 1910 | } else { | ||
| 1911 | int start = mode_group->num_crtcs + | ||
| 1912 | mode_group->num_encoders; | ||
| 1913 | for (i = start; i < start + mode_group->num_connectors; i++) { | ||
| 1914 | if (put_user(mode_group->id_list[i], | ||
| 1915 | connector_id + copied)) { | ||
| 1916 | ret = -EFAULT; | ||
| 1917 | goto out; | ||
| 1918 | } | ||
| 1919 | copied++; | ||
| 1920 | } | 1869 | } |
| 1870 | copied++; | ||
| 1921 | } | 1871 | } |
| 1922 | } | 1872 | } |
| 1923 | card_res->count_connectors = connector_count; | 1873 | card_res->count_connectors = connector_count; |
