Commit 504901db authored by Deepak Rawat's avatar Deepak Rawat Committed by Roland Scheidegger

drm/vmwgfx: Refactor surface_define to use vmw_surface_metadata

Makes surface_define cleaner by sending vmw_surface_metadata instead of
all the arguments individually.

v2: fix uninitialized return value, error message
Signed-off-by: default avatarDeepak Rawat <drawat.floss@gmail.com>
Reviewed-by: default avatarBrian Paul <brianp@vmware.com>
Reviewed-by: default avatarThomas Hellström (VMware) <thomas_os@shipmail.org>
Reviewed-by: default avatarRoland Scheidegger <sroland@vmware.com>
Signed-off-by: default avatarRoland Scheidegger <sroland@vmware.com>
parent 26b82873
...@@ -1309,6 +1309,11 @@ extern int vmw_gb_surface_reference_ext_ioctl(struct drm_device *dev, ...@@ -1309,6 +1309,11 @@ extern int vmw_gb_surface_reference_ext_ioctl(struct drm_device *dev,
void *data, void *data,
struct drm_file *file_priv); struct drm_file *file_priv);
int vmw_gb_surface_define(struct vmw_private *dev_priv,
uint32_t user_accounting_size,
const struct vmw_surface_metadata *req,
struct vmw_surface **srf_out);
/* /*
* Shader management - vmwgfx_shader.c * Shader management - vmwgfx_shader.c
*/ */
......
...@@ -1144,8 +1144,8 @@ static int vmw_create_bo_proxy(struct drm_device *dev, ...@@ -1144,8 +1144,8 @@ static int vmw_create_bo_proxy(struct drm_device *dev,
struct vmw_buffer_object *bo_mob, struct vmw_buffer_object *bo_mob,
struct vmw_surface **srf_out) struct vmw_surface **srf_out)
{ {
struct vmw_surface_metadata metadata = {0};
uint32_t format; uint32_t format;
struct drm_vmw_size content_base_size = {0};
struct vmw_resource *res; struct vmw_resource *res;
unsigned int bytes_pp; unsigned int bytes_pp;
struct drm_format_name_buf format_name; struct drm_format_name_buf format_name;
...@@ -1175,22 +1175,15 @@ static int vmw_create_bo_proxy(struct drm_device *dev, ...@@ -1175,22 +1175,15 @@ static int vmw_create_bo_proxy(struct drm_device *dev,
return -EINVAL; return -EINVAL;
} }
content_base_size.width = mode_cmd->pitches[0] / bytes_pp; metadata.format = format;
content_base_size.height = mode_cmd->height; metadata.mip_levels[0] = 1;
content_base_size.depth = 1; metadata.num_sizes = 1;
metadata.base_size.width = mode_cmd->pitches[0] / bytes_pp;
ret = vmw_surface_gb_priv_define(dev, metadata.base_size.height = mode_cmd->height;
0, /* kernel visible only */ metadata.base_size.depth = 1;
0, /* flags */ metadata.scanout = true;
format,
true, /* can be a scanout buffer */ ret = vmw_gb_surface_define(vmw_priv(dev), 0, &metadata, srf_out);
1, /* num of mip levels */
0,
0,
content_base_size,
SVGA3D_MS_PATTERN_NONE,
SVGA3D_MS_QUALITY_NONE,
srf_out);
if (ret) { if (ret) {
DRM_ERROR("Failed to allocate proxy content buffer\n"); DRM_ERROR("Failed to allocate proxy content buffer\n");
return ret; return ret;
......
...@@ -1041,7 +1041,6 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane, ...@@ -1041,7 +1041,6 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,
struct vmw_plane_state *vps = vmw_plane_state_to_vps(new_state); struct vmw_plane_state *vps = vmw_plane_state_to_vps(new_state);
enum stdu_content_type new_content_type; enum stdu_content_type new_content_type;
struct vmw_framebuffer_surface *new_vfbs; struct vmw_framebuffer_surface *new_vfbs;
struct drm_crtc *crtc = new_state->crtc;
uint32_t hdisplay = new_state->crtc_w, vdisplay = new_state->crtc_h; uint32_t hdisplay = new_state->crtc_w, vdisplay = new_state->crtc_h;
int ret; int ret;
...@@ -1068,12 +1067,11 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane, ...@@ -1068,12 +1067,11 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,
new_content_type = SEPARATE_SURFACE; new_content_type = SEPARATE_SURFACE;
if (new_content_type != SAME_AS_DISPLAY) { if (new_content_type != SAME_AS_DISPLAY) {
struct vmw_surface content_srf; struct vmw_surface_metadata metadata = {0};
struct drm_vmw_size display_base_size = {0};
display_base_size.width = hdisplay; metadata.base_size.width = hdisplay;
display_base_size.height = vdisplay; metadata.base_size.height = vdisplay;
display_base_size.depth = 1; metadata.base_size.depth = 1;
/* /*
* If content buffer is a buffer object, then we have to * If content buffer is a buffer object, then we have to
...@@ -1083,15 +1081,15 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane, ...@@ -1083,15 +1081,15 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,
switch (new_fb->format->cpp[0]*8) { switch (new_fb->format->cpp[0]*8) {
case 32: case 32:
content_srf.metadata.format = SVGA3D_X8R8G8B8; metadata.format = SVGA3D_X8R8G8B8;
break; break;
case 16: case 16:
content_srf.metadata.format = SVGA3D_R5G6B5; metadata.format = SVGA3D_R5G6B5;
break; break;
case 8: case 8:
content_srf.metadata.format = SVGA3D_P8; metadata.format = SVGA3D_P8;
break; break;
default: default:
...@@ -1099,25 +1097,20 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane, ...@@ -1099,25 +1097,20 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,
return -EINVAL; return -EINVAL;
} }
content_srf.metadata.flags = 0; metadata.mip_levels[0] = 1;
content_srf.metadata.mip_levels[0] = 1; metadata.num_sizes = 1;
content_srf.metadata.multisample_count = 0; metadata.scanout = true;
content_srf.metadata.multisample_pattern =
SVGA3D_MS_PATTERN_NONE;
content_srf.metadata.quality_level =
SVGA3D_MS_QUALITY_NONE;
} else { } else {
content_srf = *new_vfbs->surface; metadata = new_vfbs->surface->metadata;
} }
if (vps->surf) { if (vps->surf) {
struct drm_vmw_size cur_base_size = struct drm_vmw_size cur_base_size =
vps->surf->metadata.base_size; vps->surf->metadata.base_size;
if (cur_base_size.width != display_base_size.width || if (cur_base_size.width != metadata.base_size.width ||
cur_base_size.height != display_base_size.height || cur_base_size.height != metadata.base_size.height ||
vps->surf->metadata.format != vps->surf->metadata.format != metadata.format) {
content_srf.metadata.format) {
WARN_ON(vps->pinned != 0); WARN_ON(vps->pinned != 0);
vmw_surface_unreference(&vps->surf); vmw_surface_unreference(&vps->surf);
} }
...@@ -1125,20 +1118,8 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane, ...@@ -1125,20 +1118,8 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,
} }
if (!vps->surf) { if (!vps->surf) {
ret = vmw_surface_gb_priv_define ret = vmw_gb_surface_define(dev_priv, 0, &metadata,
(crtc->dev, &vps->surf);
/* Kernel visible only */
0,
content_srf.metadata.flags,
content_srf.metadata.format,
true, /* a scanout buffer */
content_srf.metadata.mip_levels[0],
content_srf.metadata.multisample_count,
0,
display_base_size,
content_srf.metadata.multisample_pattern,
content_srf.metadata.quality_level,
&vps->surf);
if (ret != 0) { if (ret != 0) {
DRM_ERROR("Couldn't allocate STDU surface.\n"); DRM_ERROR("Couldn't allocate STDU surface.\n");
return ret; return ret;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment