diff options
author | Jakob Bornecrantz <jakob@vmware.com> | 2011-11-28 07:19:12 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-12-19 09:06:03 -0500 |
commit | e7ac9211f29f2fc2e7d11586a33267d2a26d3f2f (patch) | |
tree | 4222091180060cb99b55c586dec9a44de8cd71b9 /drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | |
parent | 551a6697d08f92a311d6adbf8d03af2bc7f9e2ee (diff) |
vmwgfx: Refactor kms code to use vmw_user_lookup_handle helper
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_kms.c')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 98 |
1 files changed, 37 insertions, 61 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index bee671624a98..ac24cfd431b5 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | |||
@@ -147,24 +147,21 @@ int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, | |||
147 | return -EINVAL; | 147 | return -EINVAL; |
148 | 148 | ||
149 | if (handle) { | 149 | if (handle) { |
150 | ret = vmw_user_surface_lookup_handle(dev_priv, tfile, | 150 | ret = vmw_user_lookup_handle(dev_priv, tfile, |
151 | handle, &surface); | 151 | handle, &surface, &dmabuf); |
152 | if (!ret) { | 152 | if (ret) { |
153 | if (!surface->snooper.image) { | 153 | DRM_ERROR("failed to find surface or dmabuf: %i\n", ret); |
154 | DRM_ERROR("surface not suitable for cursor\n"); | 154 | return -EINVAL; |
155 | vmw_surface_unreference(&surface); | ||
156 | return -EINVAL; | ||
157 | } | ||
158 | } else { | ||
159 | ret = vmw_user_dmabuf_lookup(tfile, | ||
160 | handle, &dmabuf); | ||
161 | if (ret) { | ||
162 | DRM_ERROR("failed to find surface or dmabuf: %i\n", ret); | ||
163 | return -EINVAL; | ||
164 | } | ||
165 | } | 155 | } |
166 | } | 156 | } |
167 | 157 | ||
158 | /* need to do this before taking down old image */ | ||
159 | if (surface && !surface->snooper.image) { | ||
160 | DRM_ERROR("surface not suitable for cursor\n"); | ||
161 | vmw_surface_unreference(&surface); | ||
162 | return -EINVAL; | ||
163 | } | ||
164 | |||
168 | /* takedown old cursor */ | 165 | /* takedown old cursor */ |
169 | if (du->cursor_surface) { | 166 | if (du->cursor_surface) { |
170 | du->cursor_surface->snooper.crtc = NULL; | 167 | du->cursor_surface->snooper.crtc = NULL; |
@@ -568,6 +565,10 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv, | |||
568 | * Sanity checks. | 565 | * Sanity checks. |
569 | */ | 566 | */ |
570 | 567 | ||
568 | /* Surface must be marked as a scanout. */ | ||
569 | if (unlikely(!surface->scanout)) | ||
570 | return -EINVAL; | ||
571 | |||
571 | if (unlikely(surface->mip_levels[0] != 1 || | 572 | if (unlikely(surface->mip_levels[0] != 1 || |
572 | surface->num_sizes != 1 || | 573 | surface->num_sizes != 1 || |
573 | surface->sizes[0].width < mode_cmd->width || | 574 | surface->sizes[0].width < mode_cmd->width || |
@@ -1045,46 +1046,29 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, | |||
1045 | return ERR_PTR(-ENOENT); | 1046 | return ERR_PTR(-ENOENT); |
1046 | } | 1047 | } |
1047 | 1048 | ||
1048 | /** | 1049 | /* returns either a dmabuf or surface */ |
1049 | * End conditioned code. | 1050 | ret = vmw_user_lookup_handle(dev_priv, tfile, |
1050 | */ | 1051 | mode_cmd->handle, |
1051 | 1052 | &surface, &bo); | |
1052 | ret = vmw_user_surface_lookup_handle(dev_priv, tfile, | ||
1053 | mode_cmd->handle, &surface); | ||
1054 | if (ret) | 1053 | if (ret) |
1055 | goto try_dmabuf; | 1054 | goto err_out; |
1056 | 1055 | ||
1057 | if (!surface->scanout) | 1056 | /* Create the new framebuffer depending one what we got back */ |
1058 | goto err_not_scanout; | 1057 | if (bo) |
1059 | 1058 | ret = vmw_kms_new_framebuffer_dmabuf(dev_priv, bo, &vfb, | |
1060 | ret = vmw_kms_new_framebuffer_surface(dev_priv, file_priv, surface, | 1059 | mode_cmd); |
1061 | &vfb, mode_cmd); | 1060 | else if (surface) |
1062 | 1061 | ret = vmw_kms_new_framebuffer_surface(dev_priv, file_priv, | |
1063 | /* vmw_user_surface_lookup takes one ref so does new_fb */ | 1062 | surface, &vfb, mode_cmd); |
1064 | vmw_surface_unreference(&surface); | 1063 | else |
1065 | 1064 | BUG(); | |
1066 | if (ret) { | ||
1067 | DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret); | ||
1068 | ttm_base_object_unref(&user_obj); | ||
1069 | return ERR_PTR(ret); | ||
1070 | } else | ||
1071 | vfb->user_obj = user_obj; | ||
1072 | return &vfb->base; | ||
1073 | |||
1074 | try_dmabuf: | ||
1075 | DRM_INFO("%s: trying buffer\n", __func__); | ||
1076 | |||
1077 | ret = vmw_user_dmabuf_lookup(tfile, mode_cmd->handle, &bo); | ||
1078 | if (ret) { | ||
1079 | DRM_ERROR("failed to find buffer: %i\n", ret); | ||
1080 | return ERR_PTR(-ENOENT); | ||
1081 | } | ||
1082 | |||
1083 | ret = vmw_kms_new_framebuffer_dmabuf(dev_priv, bo, &vfb, | ||
1084 | mode_cmd); | ||
1085 | 1065 | ||
1086 | /* vmw_user_dmabuf_lookup takes one ref so does new_fb */ | 1066 | err_out: |
1087 | vmw_dmabuf_unreference(&bo); | 1067 | /* vmw_user_lookup_handle takes one ref so does new_fb */ |
1068 | if (bo) | ||
1069 | vmw_dmabuf_unreference(&bo); | ||
1070 | if (surface) | ||
1071 | vmw_surface_unreference(&surface); | ||
1088 | 1072 | ||
1089 | if (ret) { | 1073 | if (ret) { |
1090 | DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret); | 1074 | DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret); |
@@ -1094,14 +1078,6 @@ try_dmabuf: | |||
1094 | vfb->user_obj = user_obj; | 1078 | vfb->user_obj = user_obj; |
1095 | 1079 | ||
1096 | return &vfb->base; | 1080 | return &vfb->base; |
1097 | |||
1098 | err_not_scanout: | ||
1099 | DRM_ERROR("surface not marked as scanout\n"); | ||
1100 | /* vmw_user_surface_lookup takes one ref */ | ||
1101 | vmw_surface_unreference(&surface); | ||
1102 | ttm_base_object_unref(&user_obj); | ||
1103 | |||
1104 | return ERR_PTR(-EINVAL); | ||
1105 | } | 1081 | } |
1106 | 1082 | ||
1107 | static struct drm_mode_config_funcs vmw_kms_funcs = { | 1083 | static struct drm_mode_config_funcs vmw_kms_funcs = { |