drm: Check that the requested pixel format is valid
[deliverable/linux.git] / drivers / gpu / drm / i915 / intel_fb.c
index 96a45c4e9a16b9fb0ab8ae104c21ecc6f8055150..dc1db4ff4245ed316b14acc35394e62c9361bd3a 100644 (file)
@@ -65,7 +65,7 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct fb_info *info;
        struct drm_framebuffer *fb;
-       struct drm_mode_fb_cmd mode_cmd;
+       struct drm_mode_fb_cmd2 mode_cmd;
        struct drm_i915_gem_object *obj;
        struct device *device = &dev->pdev->dev;
        int size, ret;
@@ -77,11 +77,12 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
        mode_cmd.width = sizes->surface_width;
        mode_cmd.height = sizes->surface_height;
 
-       mode_cmd.bpp = sizes->surface_bpp;
-       mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 7) / 8), 64);
-       mode_cmd.depth = sizes->surface_depth;
+       mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((sizes->surface_bpp + 7) /
+                                                     8), 64);
+       mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
+                                                         sizes->surface_depth);
 
-       size = mode_cmd.pitch * mode_cmd.height;
+       size = mode_cmd.pitches[0] * mode_cmd.height;
        size = ALIGN(size, PAGE_SIZE);
        obj = i915_gem_alloc_object(dev, size);
        if (!obj) {
@@ -267,16 +268,10 @@ void intel_fb_output_poll_changed(struct drm_device *dev)
 
 void intel_fb_restore_mode(struct drm_device *dev)
 {
+       int ret;
        drm_i915_private_t *dev_priv = dev->dev_private;
-       int ret, i;
-
-       if (!dev_priv->fbdev)
-               return;
 
-       for (i = 0; i < dev_priv->fbdev->helper.crtc_count; i++) {
-               struct drm_mode_set *mode_set = &dev_priv->fbdev->helper.crtc_info[i].mode_set;
-               ret = drm_crtc_helper_set_config(mode_set);
-               if (ret)
-                       DRM_DEBUG("failed to restore crtc mode\n");
-       }
+       ret = drm_fb_helper_restore_fbdev_mode(&dev_priv->fbdev->helper);
+       if (ret)
+               DRM_DEBUG("failed to restore crtc mode\n");
 }
This page took 0.025023 seconds and 5 git commands to generate.