Rev 1404 | Rev 1630 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1404 | Rev 1412 | ||
---|---|---|---|
Line 1794... | Line 1794... | ||
1794 | out: |
1794 | out: |
1795 | mutex_unlock(&dev->mode_config.mutex); |
1795 | mutex_unlock(&dev->mode_config.mutex); |
1796 | return ret; |
1796 | return ret; |
1797 | } |
1797 | } |
Line -... | Line 1798... | ||
- | 1798 | ||
- | 1799 | int drm_mode_dirtyfb_ioctl(struct drm_device *dev, |
|
- | 1800 | void *data, struct drm_file *file_priv) |
|
- | 1801 | { |
|
- | 1802 | struct drm_clip_rect __user *clips_ptr; |
|
- | 1803 | struct drm_clip_rect *clips = NULL; |
|
- | 1804 | struct drm_mode_fb_dirty_cmd *r = data; |
|
- | 1805 | struct drm_mode_object *obj; |
|
- | 1806 | struct drm_framebuffer *fb; |
|
- | 1807 | unsigned flags; |
|
- | 1808 | int num_clips; |
|
- | 1809 | int ret = 0; |
|
- | 1810 | ||
- | 1811 | mutex_lock(&dev->mode_config.mutex); |
|
- | 1812 | obj = drm_mode_object_find(dev, r->fb_id, DRM_MODE_OBJECT_FB); |
|
- | 1813 | if (!obj) { |
|
- | 1814 | DRM_ERROR("invalid framebuffer id\n"); |
|
- | 1815 | ret = -EINVAL; |
|
- | 1816 | goto out_err1; |
|
- | 1817 | } |
|
- | 1818 | fb = obj_to_fb(obj); |
|
- | 1819 | ||
- | 1820 | num_clips = r->num_clips; |
|
- | 1821 | clips_ptr = (struct drm_clip_rect *)(unsigned long)r->clips_ptr; |
|
- | 1822 | ||
- | 1823 | if (!num_clips != !clips_ptr) { |
|
- | 1824 | ret = -EINVAL; |
|
- | 1825 | goto out_err1; |
|
- | 1826 | } |
|
- | 1827 | ||
- | 1828 | flags = DRM_MODE_FB_DIRTY_FLAGS & r->flags; |
|
- | 1829 | ||
- | 1830 | /* If userspace annotates copy, clips must come in pairs */ |
|
- | 1831 | if (flags & DRM_MODE_FB_DIRTY_ANNOTATE_COPY && (num_clips % 2)) { |
|
- | 1832 | ret = -EINVAL; |
|
- | 1833 | goto out_err1; |
|
- | 1834 | } |
|
- | 1835 | ||
- | 1836 | if (num_clips && clips_ptr) { |
|
- | 1837 | clips = kzalloc(num_clips * sizeof(*clips), GFP_KERNEL); |
|
- | 1838 | if (!clips) { |
|
- | 1839 | ret = -ENOMEM; |
|
- | 1840 | goto out_err1; |
|
- | 1841 | } |
|
- | 1842 | ||
- | 1843 | ret = copy_from_user(clips, clips_ptr, |
|
- | 1844 | num_clips * sizeof(*clips)); |
|
- | 1845 | if (ret) |
|
- | 1846 | goto out_err2; |
|
- | 1847 | } |
|
- | 1848 | ||
- | 1849 | if (fb->funcs->dirty) { |
|
- | 1850 | ret = fb->funcs->dirty(fb, flags, r->color, clips, num_clips); |
|
- | 1851 | } else { |
|
- | 1852 | ret = -ENOSYS; |
|
- | 1853 | goto out_err2; |
|
- | 1854 | } |
|
- | 1855 | ||
- | 1856 | out_err2: |
|
- | 1857 | kfree(clips); |
|
- | 1858 | out_err1: |
|
- | 1859 | mutex_unlock(&dev->mode_config.mutex); |
|
- | 1860 | return ret; |
|
- | 1861 | } |
|
- | 1862 | ||
1798 | 1863 | ||
1799 | /** |
1864 | /** |
1800 | * drm_fb_release - remove and free the FBs on this file |
1865 | * drm_fb_release - remove and free the FBs on this file |
1801 | * @filp: file * from the ioctl |
1866 | * @filp: file * from the ioctl |
1802 | * |
1867 | * |