drm: add an fb creation ioctl that takes a pixel format v5
[deliverable/linux.git] / drivers / gpu / drm / vmwgfx / vmwgfx_kms.c
index 03daefa73397fb98b31faca39bf522fe3ec178fa..1beaa3f8dac2f20f0fe0cb93eb162d422094c8b3 100644 (file)
@@ -990,7 +990,7 @@ out_err1:
 
 static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
                                                 struct drm_file *file_priv,
-                                                struct drm_mode_fb_cmd *mode_cmd)
+                                                struct drm_mode_fb_cmd2 *mode_cmd2)
 {
        struct vmw_private *dev_priv = vmw_priv(dev);
        struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
@@ -998,16 +998,24 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
        struct vmw_surface *surface = NULL;
        struct vmw_dma_buffer *bo = NULL;
        struct ttm_base_object *user_obj;
+       struct drm_mode_fb_cmd mode_cmd;
        u64 required_size;
        int ret;
 
+       mode_cmd.width = mode_cmd2->width;
+       mode_cmd.height = mode_cmd2->height;
+       mode_cmd.pitch = mode_cmd2->pitches[0];
+       mode_cmd.handle = mode_cmd2->handles[0];
+       drm_helper_get_fb_bpp_depth(mode_cmd2->pixel_format, &mode_cmd.depth,
+                                   &mode_cmd.bpp);
+
        /**
         * This code should be conditioned on Screen Objects not being used.
         * If screen objects are used, we can allocate a GMR to hold the
         * requested framebuffer.
         */
 
-       required_size = mode_cmd->pitch * mode_cmd->height;
+       required_size = mode_cmd.pitch * mode_cmd.height;
        if (unlikely(required_size > (u64) dev_priv->vram_size)) {
                DRM_ERROR("VRAM size is too small for requested mode.\n");
                return ERR_PTR(-ENOMEM);
@@ -1022,7 +1030,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
         * command stream using user-space handles.
         */
 
-       user_obj = ttm_base_object_lookup(tfile, mode_cmd->handle);
+       user_obj = ttm_base_object_lookup(tfile, mode_cmd.handle);
        if (unlikely(user_obj == NULL)) {
                DRM_ERROR("Could not locate requested kms frame buffer.\n");
                return ERR_PTR(-ENOENT);
@@ -1033,7 +1041,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
         */
 
        ret = vmw_user_surface_lookup_handle(dev_priv, tfile,
-                                            mode_cmd->handle, &surface);
+                                            mode_cmd.handle, &surface);
        if (ret)
                goto try_dmabuf;
 
@@ -1041,7 +1049,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
                goto err_not_scanout;
 
        ret = vmw_kms_new_framebuffer_surface(dev_priv, file_priv, surface,
-                                             &vfb, mode_cmd);
+                                             &vfb, &mode_cmd);
 
        /* vmw_user_surface_lookup takes one ref so does new_fb */
        vmw_surface_unreference(&surface);
@@ -1057,14 +1065,14 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
 try_dmabuf:
        DRM_INFO("%s: trying buffer\n", __func__);
 
-       ret = vmw_user_dmabuf_lookup(tfile, mode_cmd->handle, &bo);
+       ret = vmw_user_dmabuf_lookup(tfile, mode_cmd.handle, &bo);
        if (ret) {
                DRM_ERROR("failed to find buffer: %i\n", ret);
                return ERR_PTR(-ENOENT);
        }
 
        ret = vmw_kms_new_framebuffer_dmabuf(dev_priv, bo, &vfb,
-                                            mode_cmd);
+                                            &mode_cmd);
 
        /* vmw_user_dmabuf_lookup takes one ref so does new_fb */
        vmw_dmabuf_unreference(&bo);
This page took 0.031231 seconds and 5 git commands to generate.