summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2021-12-19 06:29:31 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2021-12-19 06:29:31 +0000
commit0aabea6847dc3e2fa82e925277ca2432cbb58943 (patch)
tree6d9f9db5983a6198abd6371f4aa5da8e427de92b /sys/dev/pci/drm
parent2c7fcdce7c2e94ea993ae6026a76d262dbf15557 (diff)
fix setting palette with 8bpp fb used on 8mb parts
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r--sys/dev/pci/drm/radeon/radeon_kms.c64
1 files changed, 39 insertions, 25 deletions
diff --git a/sys/dev/pci/drm/radeon/radeon_kms.c b/sys/dev/pci/drm/radeon/radeon_kms.c
index 72874bc2c67..e298bd83979 100644
--- a/sys/dev/pci/drm/radeon/radeon_kms.c
+++ b/sys/dev/pci/drm/radeon/radeon_kms.c
@@ -193,6 +193,7 @@ void radeondrm_enter_ddb(void *, void *);
#ifdef __sparc64__
void radeondrm_setcolor(void *, u_int, u_int8_t, u_int8_t, u_int8_t);
#endif
+void radeondrm_setpal(struct radeon_device *, struct rasops_info *);
struct wsscreen_descr radeondrm_stdscreen = {
"std",
@@ -303,36 +304,12 @@ radeondrm_doswitch(void *v)
{
struct rasops_info *ri = v;
struct radeon_device *rdev = ri->ri_hw;
-#ifndef __sparc64__
- struct drm_device *dev = rdev->ddev;
- struct drm_crtc *crtc;
- uint16_t *r_base, *g_base, *b_base;
- int i, ret = 0;
-#endif
rasops_show_screen(ri, rdev->switchcookie, 0, NULL, NULL);
#ifdef __sparc64__
fbwscons_setcolormap(&rdev->sf, radeondrm_setcolor);
#else
- for (i = 0; i < rdev->num_crtc; i++) {
- struct drm_modeset_acquire_ctx ctx;
- crtc = &rdev->mode_info.crtcs[i]->base;
-
- r_base = crtc->gamma_store;
- g_base = r_base + crtc->gamma_size;
- b_base = g_base + crtc->gamma_size;
-
- DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret);
-
- *r_base = rasops_cmap[3 * i] << 2;
- *g_base = rasops_cmap[(3 * i) + 1] << 2;
- *b_base = rasops_cmap[(3 * i) + 2] << 2;
-
- crtc->funcs->gamma_set(crtc, r_base, g_base, b_base,
- crtc->gamma_size, &ctx);
-
- DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
- }
+ radeondrm_setpal(rdev, ri);
#endif
drm_fb_helper_restore_fbdev_mode_unlocked((void *)rdev->mode_info.rfbdev);
@@ -373,6 +350,41 @@ radeondrm_setcolor(void *v, u_int index, u_int8_t r, u_int8_t g, u_int8_t b)
}
#endif
+void
+radeondrm_setpal(struct radeon_device *rdev, struct rasops_info *ri)
+{
+ struct drm_device *dev = rdev->ddev;
+ struct drm_crtc *crtc;
+ uint16_t *r_base, *g_base, *b_base;
+ int i, index, ret = 0;
+ const u_char *p;
+
+ if (ri->ri_depth != 8)
+ return;
+
+ for (i = 0; i < rdev->num_crtc; i++) {
+ struct drm_modeset_acquire_ctx ctx;
+ crtc = &rdev->mode_info.crtcs[i]->base;
+
+ r_base = crtc->gamma_store;
+ g_base = r_base + crtc->gamma_size;
+ b_base = g_base + crtc->gamma_size;
+
+ DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret);
+
+ p = rasops_cmap;
+ for (index = 0; index < 256; index++) {
+ r_base[index] = *p++ << 8;
+ g_base[index] = *p++ << 8;
+ b_base[index] = *p++ << 8;
+ }
+
+ crtc->funcs->gamma_set(crtc, NULL, NULL, NULL, 0, NULL);
+
+ DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
+ }
+}
+
#ifdef __linux__
/**
* radeon_driver_load_kms - Main load function for KMS.
@@ -798,6 +810,8 @@ radeondrm_attachhook(struct device *self)
#ifdef __sparc64__
fbwscons_setcolormap(&rdev->sf, radeondrm_setcolor);
+#else
+ radeondrm_setpal(rdev, ri);
#endif
#ifndef __sparc64__