diff options
author | Dave Airlie <airlied@redhat.com> | 2009-10-04 19:58:02 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-10-04 20:00:59 -0400 |
commit | 068143d38804825d59d951a192cfadd2e22f457d (patch) | |
tree | 87acefe03fe5a97577e90f89c79909aad5ba2a5e /drivers/gpu/drm/drm_fb_helper.c | |
parent | dfee5614e4d83a32cef9193a8b19bc1d8900f93d (diff) |
drm/fb: add setcmap and fix 8-bit support.
This adds support for the setcmap api and fixes the 8bpp
support at least on radeon hardware. It adds a new load_lut
hook which can be called once the color map is setup.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_fb_helper.c')
-rw-r--r-- | drivers/gpu/drm/drm_fb_helper.c | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 819ddcbfcce5..3746bd2f0f08 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c | |||
@@ -454,6 +454,48 @@ out_free: | |||
454 | } | 454 | } |
455 | EXPORT_SYMBOL(drm_fb_helper_init_crtc_count); | 455 | EXPORT_SYMBOL(drm_fb_helper_init_crtc_count); |
456 | 456 | ||
457 | int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info) | ||
458 | { | ||
459 | struct drm_fb_helper *fb_helper = info->par; | ||
460 | struct drm_device *dev = fb_helper->dev; | ||
461 | u16 *red, *green, *blue, *transp; | ||
462 | struct drm_crtc *crtc; | ||
463 | int i, rc = 0; | ||
464 | int start; | ||
465 | |||
466 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | ||
467 | struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; | ||
468 | for (i = 0; i < fb_helper->crtc_count; i++) { | ||
469 | if (crtc->base.id == fb_helper->crtc_info[i].crtc_id) | ||
470 | break; | ||
471 | } | ||
472 | if (i == fb_helper->crtc_count) | ||
473 | continue; | ||
474 | |||
475 | red = cmap->red; | ||
476 | green = cmap->green; | ||
477 | blue = cmap->blue; | ||
478 | transp = cmap->transp; | ||
479 | start = cmap->start; | ||
480 | |||
481 | for (i = 0; i < cmap->len; i++) { | ||
482 | u16 hred, hgreen, hblue, htransp = 0xffff; | ||
483 | |||
484 | hred = *red++; | ||
485 | hgreen = *green++; | ||
486 | hblue = *blue++; | ||
487 | |||
488 | if (transp) | ||
489 | htransp = *transp++; | ||
490 | |||
491 | fb_helper->funcs->gamma_set(crtc, hred, hgreen, hblue, start++); | ||
492 | } | ||
493 | crtc_funcs->load_lut(crtc); | ||
494 | } | ||
495 | return rc; | ||
496 | } | ||
497 | EXPORT_SYMBOL(drm_fb_helper_setcmap); | ||
498 | |||
457 | int drm_fb_helper_setcolreg(unsigned regno, | 499 | int drm_fb_helper_setcolreg(unsigned regno, |
458 | unsigned red, | 500 | unsigned red, |
459 | unsigned green, | 501 | unsigned green, |
@@ -485,20 +527,21 @@ int drm_fb_helper_setcolreg(unsigned regno, | |||
485 | } | 527 | } |
486 | 528 | ||
487 | if (regno < 16) { | 529 | if (regno < 16) { |
530 | u32 *pal = fb->pseudo_palette; | ||
488 | switch (fb->depth) { | 531 | switch (fb->depth) { |
489 | case 15: | 532 | case 15: |
490 | fb->pseudo_palette[regno] = ((red & 0xf800) >> 1) | | 533 | pal[regno] = ((red & 0xf800) >> 1) | |
491 | ((green & 0xf800) >> 6) | | 534 | ((green & 0xf800) >> 6) | |
492 | ((blue & 0xf800) >> 11); | 535 | ((blue & 0xf800) >> 11); |
493 | break; | 536 | break; |
494 | case 16: | 537 | case 16: |
495 | fb->pseudo_palette[regno] = (red & 0xf800) | | 538 | pal[regno] = (red & 0xf800) | |
496 | ((green & 0xfc00) >> 5) | | 539 | ((green & 0xfc00) >> 5) | |
497 | ((blue & 0xf800) >> 11); | 540 | ((blue & 0xf800) >> 11); |
498 | break; | 541 | break; |
499 | case 24: | 542 | case 24: |
500 | case 32: | 543 | case 32: |
501 | fb->pseudo_palette[regno] = | 544 | pal[regno] = |
502 | (((red >> 8) & 0xff) << info->var.red.offset) | | 545 | (((red >> 8) & 0xff) << info->var.red.offset) | |
503 | (((green >> 8) & 0xff) << info->var.green.offset) | | 546 | (((green >> 8) & 0xff) << info->var.green.offset) | |
504 | (((blue >> 8) & 0xff) << info->var.blue.offset); | 547 | (((blue >> 8) & 0xff) << info->var.blue.offset); |
@@ -851,10 +894,12 @@ void drm_fb_helper_free(struct drm_fb_helper *helper) | |||
851 | } | 894 | } |
852 | EXPORT_SYMBOL(drm_fb_helper_free); | 895 | EXPORT_SYMBOL(drm_fb_helper_free); |
853 | 896 | ||
854 | void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch) | 897 | void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, |
898 | uint32_t depth) | ||
855 | { | 899 | { |
856 | info->fix.type = FB_TYPE_PACKED_PIXELS; | 900 | info->fix.type = FB_TYPE_PACKED_PIXELS; |
857 | info->fix.visual = FB_VISUAL_TRUECOLOR; | 901 | info->fix.visual = depth == 8 ? FB_VISUAL_PSEUDOCOLOR : |
902 | FB_VISUAL_TRUECOLOR; | ||
858 | info->fix.type_aux = 0; | 903 | info->fix.type_aux = 0; |
859 | info->fix.xpanstep = 1; /* doing it in hw */ | 904 | info->fix.xpanstep = 1; /* doing it in hw */ |
860 | info->fix.ypanstep = 1; /* doing it in hw */ | 905 | info->fix.ypanstep = 1; /* doing it in hw */ |