Merge tag 'modules-for-v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu...
[linux-2.6-microblaze.git] / drivers / gpu / drm / drm_fb_helper.c
index 0b9f1ae..b9a6167 100644 (file)
@@ -946,11 +946,15 @@ static int setcmap_legacy(struct fb_cmap *cmap, struct fb_info *info)
        drm_modeset_lock_all(fb_helper->dev);
        drm_client_for_each_modeset(modeset, &fb_helper->client) {
                crtc = modeset->crtc;
-               if (!crtc->funcs->gamma_set || !crtc->gamma_size)
-                       return -EINVAL;
+               if (!crtc->funcs->gamma_set || !crtc->gamma_size) {
+                       ret = -EINVAL;
+                       goto out;
+               }
 
-               if (cmap->start + cmap->len > crtc->gamma_size)
-                       return -EINVAL;
+               if (cmap->start + cmap->len > crtc->gamma_size) {
+                       ret = -EINVAL;
+                       goto out;
+               }
 
                r = crtc->gamma_store;
                g = r + crtc->gamma_size;
@@ -963,8 +967,9 @@ static int setcmap_legacy(struct fb_cmap *cmap, struct fb_info *info)
                ret = crtc->funcs->gamma_set(crtc, r, g, b,
                                             crtc->gamma_size, NULL);
                if (ret)
-                       return ret;
+                       goto out;
        }
+out:
        drm_modeset_unlock_all(fb_helper->dev);
 
        return ret;
@@ -1054,6 +1059,11 @@ retry:
                        goto out_state;
                }
 
+               /*
+                * FIXME: This always uses gamma_lut. Some HW have only
+                * degamma_lut, in which case we should reset gamma_lut and set
+                * degamma_lut. See drm_crtc_legacy_gamma_set().
+                */
                replaced  = drm_property_replace_blob(&crtc_state->degamma_lut,
                                                      NULL);
                replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL);
@@ -2486,6 +2496,11 @@ void drm_fbdev_generic_setup(struct drm_device *dev,
                return;
        }
 
+       /*
+        * FIXME: This mixes up depth with bpp, which results in a glorious
+        * mess, resulting in some drivers picking wrong fbdev defaults and
+        * others wrong preferred_depth defaults.
+        */
        if (!preferred_bpp)
                preferred_bpp = dev->mode_config.preferred_depth;
        if (!preferred_bpp)