drm: Make the CRTC gamma_set operation optional
[GitHub/LineageOS/android_kernel_samsung_universal7580.git] / drivers / gpu / drm / drm_fb_helper.c
index 7740dd26f00706d3b2059f475d10399f8f66d068..5683b7fdd7466a16a5d1c4df0477c734fed7b0d4 100644 (file)
@@ -136,6 +136,9 @@ static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)
 {
        uint16_t *r_base, *g_base, *b_base;
 
+       if (crtc->funcs->gamma_set == NULL)
+               return;
+
        r_base = crtc->gamma_store;
        g_base = r_base + crtc->gamma_size;
        b_base = g_base + crtc->gamma_size;
@@ -383,7 +386,6 @@ int drm_fb_helper_init(struct drm_device *dev,
                       int crtc_count, int max_conn_count)
 {
        struct drm_crtc *crtc;
-       int ret = 0;
        int i;
 
        fb_helper->dev = dev;
@@ -408,10 +410,8 @@ int drm_fb_helper_init(struct drm_device *dev,
                                sizeof(struct drm_connector *),
                                GFP_KERNEL);
 
-               if (!fb_helper->crtc_info[i].mode_set.connectors) {
-                       ret = -ENOMEM;
+               if (!fb_helper->crtc_info[i].mode_set.connectors)
                        goto out_free;
-               }
                fb_helper->crtc_info[i].mode_set.num_connectors = 0;
        }
 
@@ -559,9 +559,13 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
                return -EINVAL;
 
        /* Need to resize the fb object !!! */
-       if (var->bits_per_pixel > fb->bits_per_pixel || var->xres > fb->width || var->yres > fb->height) {
+       if (var->bits_per_pixel > fb->bits_per_pixel ||
+           var->xres > fb->width || var->yres > fb->height ||
+           var->xres_virtual > fb->width || var->yres_virtual > fb->height) {
                DRM_DEBUG("fb userspace requested width/height/bpp is greater than current fb "
-                         "object %dx%d-%d > %dx%d-%d\n", var->xres, var->yres, var->bits_per_pixel,
+                         "request %dx%d-%d (virtual %dx%d) > %dx%d-%d\n",
+                         var->xres, var->yres, var->bits_per_pixel,
+                         var->xres_virtual, var->yres_virtual,
                          fb->width, fb->height, fb->bits_per_pixel);
                return -EINVAL;
        }
@@ -1079,7 +1083,7 @@ static bool drm_target_cloned(struct drm_fb_helper *fb_helper,
 
        /* try and find a 1024x768 mode on each connector */
        can_clone = true;
-       dmt_mode = drm_mode_find_dmt(fb_helper->dev, 1024, 768, 60);
+       dmt_mode = drm_mode_find_dmt(fb_helper->dev, 1024, 768, 60, false);
 
        for (i = 0; i < fb_helper->connector_count; i++) {