| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: drm_crtc.c,v 1.7 2018/08/27 06:52:24 riastradh Exp $ */ | | 1 | /* $NetBSD: drm_crtc.c,v 1.8 2018/08/27 06:55:13 riastradh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2006-2008 Intel Corporation | | 4 | * Copyright (c) 2006-2008 Intel Corporation |
5 | * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> | | 5 | * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> |
6 | * Copyright (c) 2008 Red Hat Inc. | | 6 | * Copyright (c) 2008 Red Hat Inc. |
7 | * | | 7 | * |
8 | * DRM core CRTC related functions | | 8 | * DRM core CRTC related functions |
9 | * | | 9 | * |
10 | * Permission to use, copy, modify, distribute, and sell this software and its | | 10 | * Permission to use, copy, modify, distribute, and sell this software and its |
11 | * documentation for any purpose is hereby granted without fee, provided that | | 11 | * documentation for any purpose is hereby granted without fee, provided that |
12 | * the above copyright notice appear in all copies and that both that copyright | | 12 | * the above copyright notice appear in all copies and that both that copyright |
13 | * notice and this permission notice appear in supporting documentation, and | | 13 | * notice and this permission notice appear in supporting documentation, and |
14 | * that the name of the copyright holders not be used in advertising or | | 14 | * that the name of the copyright holders not be used in advertising or |
| @@ -22,27 +22,27 @@ | | | @@ -22,27 +22,27 @@ |
22 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR | | 22 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
23 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | | 23 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
24 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | | 24 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
25 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | | 25 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
26 | * OF THIS SOFTWARE. | | 26 | * OF THIS SOFTWARE. |
27 | * | | 27 | * |
28 | * Authors: | | 28 | * Authors: |
29 | * Keith Packard | | 29 | * Keith Packard |
30 | * Eric Anholt <eric@anholt.net> | | 30 | * Eric Anholt <eric@anholt.net> |
31 | * Dave Airlie <airlied@linux.ie> | | 31 | * Dave Airlie <airlied@linux.ie> |
32 | * Jesse Barnes <jesse.barnes@intel.com> | | 32 | * Jesse Barnes <jesse.barnes@intel.com> |
33 | */ | | 33 | */ |
34 | #include <sys/cdefs.h> | | 34 | #include <sys/cdefs.h> |
35 | __KERNEL_RCSID(0, "$NetBSD: drm_crtc.c,v 1.7 2018/08/27 06:52:24 riastradh Exp $"); | | 35 | __KERNEL_RCSID(0, "$NetBSD: drm_crtc.c,v 1.8 2018/08/27 06:55:13 riastradh Exp $"); |
36 | | | 36 | |
37 | #include <linux/err.h> | | 37 | #include <linux/err.h> |
38 | #include <linux/spinlock.h> | | 38 | #include <linux/spinlock.h> |
39 | #include <linux/ctype.h> | | 39 | #include <linux/ctype.h> |
40 | #include <linux/list.h> | | 40 | #include <linux/list.h> |
41 | #include <linux/slab.h> | | 41 | #include <linux/slab.h> |
42 | #include <linux/export.h> | | 42 | #include <linux/export.h> |
43 | #include <linux/errno.h> | | 43 | #include <linux/errno.h> |
44 | #include <asm/bug.h> | | 44 | #include <asm/bug.h> |
45 | #include <drm/drmP.h> | | 45 | #include <drm/drmP.h> |
46 | #include <drm/drm_crtc.h> | | 46 | #include <drm/drm_crtc.h> |
47 | #include <drm/drm_edid.h> | | 47 | #include <drm/drm_edid.h> |
48 | #include <drm/drm_fourcc.h> | | 48 | #include <drm/drm_fourcc.h> |
| @@ -1025,27 +1025,29 @@ unsigned int drm_connector_index(struct | | | @@ -1025,27 +1025,29 @@ unsigned int drm_connector_index(struct |
1025 | EXPORT_SYMBOL(drm_connector_index); | | 1025 | EXPORT_SYMBOL(drm_connector_index); |
1026 | | | 1026 | |
1027 | /** | | 1027 | /** |
1028 | * drm_connector_register - register a connector | | 1028 | * drm_connector_register - register a connector |
1029 | * @connector: the connector to register | | 1029 | * @connector: the connector to register |
1030 | * | | 1030 | * |
1031 | * Register userspace interfaces for a connector | | 1031 | * Register userspace interfaces for a connector |
1032 | * | | 1032 | * |
1033 | * Returns: | | 1033 | * Returns: |
1034 | * Zero on success, error code on failure. | | 1034 | * Zero on success, error code on failure. |
1035 | */ | | 1035 | */ |
1036 | int drm_connector_register(struct drm_connector *connector) | | 1036 | int drm_connector_register(struct drm_connector *connector) |
1037 | { | | 1037 | { |
| | | 1038 | #ifndef __NetBSD__ /* XXX sysfs, debugfs */ |
1038 | int ret; | | 1039 | int ret; |
| | | 1040 | #endif |
1039 | | | 1041 | |
1040 | drm_mode_object_register(connector->dev, &connector->base); | | 1042 | drm_mode_object_register(connector->dev, &connector->base); |
1041 | | | 1043 | |
1042 | #ifndef __NetBSD__ /* XXX sysfs, debugfs */ | | 1044 | #ifndef __NetBSD__ /* XXX sysfs, debugfs */ |
1043 | ret = drm_sysfs_connector_add(connector); | | 1045 | ret = drm_sysfs_connector_add(connector); |
1044 | if (ret) | | 1046 | if (ret) |
1045 | return ret; | | 1047 | return ret; |
1046 | | | 1048 | |
1047 | ret = drm_debugfs_connector_add(connector); | | 1049 | ret = drm_debugfs_connector_add(connector); |
1048 | if (ret) { | | 1050 | if (ret) { |
1049 | drm_sysfs_connector_remove(connector); | | 1051 | drm_sysfs_connector_remove(connector); |
1050 | return ret; | | 1052 | return ret; |
1051 | } | | 1053 | } |
| @@ -3051,26 +3053,27 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format) | | | @@ -3051,26 +3053,27 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format) |
3051 | * original addfb ioctl which only supported RGB formats. | | 3053 | * original addfb ioctl which only supported RGB formats. |
3052 | * | | 3054 | * |
3053 | * Called by the user via ioctl. | | 3055 | * Called by the user via ioctl. |
3054 | * | | 3056 | * |
3055 | * Returns: | | 3057 | * Returns: |
3056 | * Zero on success, negative errno on failure. | | 3058 | * Zero on success, negative errno on failure. |
3057 | */ | | 3059 | */ |
3058 | int drm_mode_addfb(struct drm_device *dev, | | 3060 | int drm_mode_addfb(struct drm_device *dev, |
3059 | void *data, struct drm_file *file_priv) | | 3061 | void *data, struct drm_file *file_priv) |
3060 | { | | 3062 | { |
3061 | struct drm_mode_fb_cmd *or = data; | | 3063 | struct drm_mode_fb_cmd *or = data; |
3062 | static const struct drm_mode_fb_cmd2 zero_fbcmd; | | 3064 | static const struct drm_mode_fb_cmd2 zero_fbcmd; |
3063 | struct drm_mode_fb_cmd2 r = zero_fbcmd; | | 3065 | struct drm_mode_fb_cmd2 r = zero_fbcmd; |
| | | 3066 | int ret; |
3064 | | | 3067 | |
3065 | /* convert to new format and call new ioctl */ | | 3068 | /* convert to new format and call new ioctl */ |
3066 | r.fb_id = or->fb_id; | | 3069 | r.fb_id = or->fb_id; |
3067 | r.width = or->width; | | 3070 | r.width = or->width; |
3068 | r.height = or->height; | | 3071 | r.height = or->height; |
3069 | r.pitches[0] = or->pitch; | | 3072 | r.pitches[0] = or->pitch; |
3070 | r.pixel_format = drm_mode_legacy_fb_format(or->bpp, or->depth); | | 3073 | r.pixel_format = drm_mode_legacy_fb_format(or->bpp, or->depth); |
3071 | r.handles[0] = or->handle; | | 3074 | r.handles[0] = or->handle; |
3072 | | | 3075 | |
3073 | ret = drm_mode_addfb2(dev, &r, file_priv); | | 3076 | ret = drm_mode_addfb2(dev, &r, file_priv); |
3074 | if (ret) | | 3077 | if (ret) |
3075 | return ret; | | 3078 | return ret; |
3076 | | | 3079 | |
| @@ -3189,27 +3192,27 @@ static int framebuffer_check(const struc | | | @@ -3189,27 +3192,27 @@ static int framebuffer_check(const struc |
3189 | | | 3192 | |
3190 | if ((uint64_t) width * cpp > UINT_MAX) | | 3193 | if ((uint64_t) width * cpp > UINT_MAX) |
3191 | return -ERANGE; | | 3194 | return -ERANGE; |
3192 | | | 3195 | |
3193 | if ((uint64_t) height * r->pitches[i] + r->offsets[i] > UINT_MAX) | | 3196 | if ((uint64_t) height * r->pitches[i] + r->offsets[i] > UINT_MAX) |
3194 | return -ERANGE; | | 3197 | return -ERANGE; |
3195 | | | 3198 | |
3196 | if (r->pitches[i] < width * cpp) { | | 3199 | if (r->pitches[i] < width * cpp) { |
3197 | DRM_DEBUG_KMS("bad pitch %u for plane %d\n", r->pitches[i], i); | | 3200 | DRM_DEBUG_KMS("bad pitch %u for plane %d\n", r->pitches[i], i); |
3198 | return -EINVAL; | | 3201 | return -EINVAL; |
3199 | } | | 3202 | } |
3200 | | | 3203 | |
3201 | if (r->modifier[i] && !(r->flags & DRM_MODE_FB_MODIFIERS)) { | | 3204 | if (r->modifier[i] && !(r->flags & DRM_MODE_FB_MODIFIERS)) { |
3202 | DRM_DEBUG_KMS("bad fb modifier %llu for plane %d\n", | | 3205 | DRM_DEBUG_KMS("bad fb modifier %"PRIu64" for plane %d\n", |
3203 | r->modifier[i], i); | | 3206 | r->modifier[i], i); |
3204 | return -EINVAL; | | 3207 | return -EINVAL; |
3205 | } | | 3208 | } |
3206 | | | 3209 | |
3207 | /* modifier specific checks: */ | | 3210 | /* modifier specific checks: */ |
3208 | switch (r->modifier[i]) { | | 3211 | switch (r->modifier[i]) { |
3209 | case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE: | | 3212 | case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE: |
3210 | /* NOTE: the pitch restriction may be lifted later if it turns | | 3213 | /* NOTE: the pitch restriction may be lifted later if it turns |
3211 | * out that no hw has this restriction: | | 3214 | * out that no hw has this restriction: |
3212 | */ | | 3215 | */ |
3213 | if (r->pixel_format != DRM_FORMAT_NV12 || | | 3216 | if (r->pixel_format != DRM_FORMAT_NV12 || |
3214 | width % 128 || height % 32 || | | 3217 | width % 128 || height % 32 || |
3215 | r->pitches[i] % 128) { | | 3218 | r->pitches[i] % 128) { |