radeon, kdb, kms: Save and restore the LUT on atomic KMS enter/exit
authorJason Wessel <jason.wessel@windriver.com>
Sun, 26 Sep 2010 11:47:26 +0000 (06:47 -0500)
committerDave Airlie <airlied@redhat.com>
Wed, 6 Oct 2010 01:50:37 +0000 (11:50 +1000)
When changing VTs non-atomically the kernel works in conjunction with
the Xserver in user space and receives the LUT information from the
Xserver via a system call.  When changing modes atomically for kdb,
this information must be saved and restored without disturbing user
space as if nothing ever happened.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
CC: Jesse Barnes <jbarnes@virtuousgeek.org>
CC: David Airlie <airlied@linux.ie>
CC: dri-devel@lists.freedesktop.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/radeon/radeon_display.c
drivers/gpu/drm/radeon/radeon_legacy_crtc.c
drivers/gpu/drm/radeon/radeon_mode.h

index b92d2f2fcbed6a8bd472ce9f4b936aa82f309278..26935cf2c3b3a73cacf639b4c86c164607955ba0 100644 (file)
@@ -138,6 +138,38 @@ void radeon_crtc_load_lut(struct drm_crtc *crtc)
                legacy_crtc_load_lut(crtc);
 }
 
+void radeon_crtc_save_lut(struct drm_crtc *crtc)
+{
+       struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
+       int i;
+
+       if (!crtc->enabled)
+               return;
+
+       for (i = 0; i < 256; i++) {
+               radeon_crtc->lut_r_copy[i] = radeon_crtc->lut_r[i];
+               radeon_crtc->lut_g_copy[i] = radeon_crtc->lut_g[i];
+               radeon_crtc->lut_b_copy[i] = radeon_crtc->lut_b[i];
+       }
+}
+
+void radeon_crtc_restore_lut(struct drm_crtc *crtc)
+{
+       struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
+       int i;
+
+       if (!crtc->enabled)
+               return;
+
+       for (i = 0; i < 256; i++) {
+               radeon_crtc->lut_r[i] = radeon_crtc->lut_r_copy[i];
+               radeon_crtc->lut_g[i] = radeon_crtc->lut_g_copy[i];
+               radeon_crtc->lut_b[i] = radeon_crtc->lut_b_copy[i];
+       }
+
+       radeon_crtc_load_lut(crtc);
+}
+
 /** Sets the color ramps on behalf of fbcon */
 void radeon_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
                              u16 blue, int regno)
index 8752d3447b72a36e3305cb52d29113ccd2dcf567..42954785247f52cbbc1551246452d21ca5e295b1 100644 (file)
@@ -355,6 +355,11 @@ int radeon_crtc_set_base_atomic(struct drm_crtc *crtc,
                                struct drm_framebuffer *fb,
                                int x, int y, int enter)
 {
+       if (enter)
+               radeon_crtc_save_lut(crtc);
+       else
+               radeon_crtc_restore_lut(crtc);
+
        return radeon_crtc_do_set_base(crtc, fb, x, y, 1);
 }
 
index c4116d3d8d0650a60a8dfa9c14a4e6ba2d8c757e..2f78615f02aafcdff639170e6f7ab6b4c24e6afa 100644 (file)
@@ -267,6 +267,7 @@ struct radeon_crtc {
        struct drm_crtc base;
        int crtc_id;
        u16 lut_r[256], lut_g[256], lut_b[256];
+       u16 lut_r_copy[256], lut_g_copy[256], lut_b_copy[256];
        bool enabled;
        bool can_tile;
        uint32_t crtc_offset;
@@ -512,6 +513,8 @@ extern int atombios_get_encoder_mode(struct drm_encoder *encoder);
 extern void radeon_encoder_set_active_device(struct drm_encoder *encoder);
 
 extern void radeon_crtc_load_lut(struct drm_crtc *crtc);
+extern void radeon_crtc_save_lut(struct drm_crtc *crtc);
+extern void radeon_crtc_restore_lut(struct drm_crtc *crtc);
 extern int atombios_crtc_set_base(struct drm_crtc *crtc, int x, int y,
                                   struct drm_framebuffer *old_fb);
 extern int atombios_crtc_set_base_atomic(struct drm_crtc *crtc,