]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/gpu/drm/ast/ast_fb.c
drm/ast: Replace mapping code with drm_gem_vram_{kmap/kunmap}()
[linux.git] / drivers / gpu / drm / ast / ast_fb.c
index 2c9f8dd9733a404354085db8d5347df2eefc300d..505e602855c0672d1628598d75ccf441f65e4a7d 100644 (file)
@@ -49,17 +49,18 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
 {
        int i;
        struct drm_gem_object *obj;
-       struct ast_bo *bo;
+       struct drm_gem_vram_object *gbo;
        int src_offset, dst_offset;
        int bpp = afbdev->afb.base.format->cpp[0];
        int ret = -EBUSY;
+       u8 *dst;
        bool unmap = false;
        bool store_for_later = false;
        int x2, y2;
        unsigned long flags;
 
        obj = afbdev->afb.obj;
-       bo = gem_to_ast_bo(obj);
+       gbo = drm_gem_vram_of_gem(obj);
 
        /*
         * try and reserve the BO, if we fail with busy
@@ -67,7 +68,7 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
         * store up the damage until later.
         */
        if (drm_can_sleep())
-               ret = ast_bo_reserve(bo, true);
+               ret = drm_gem_vram_reserve(gbo, true);
        if (ret) {
                if (ret != -EBUSY)
                        return;
@@ -101,25 +102,32 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
        afbdev->x2 = afbdev->y2 = 0;
        spin_unlock_irqrestore(&afbdev->dirty_lock, flags);
 
-       if (!bo->kmap.virtual) {
-               ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
-               if (ret) {
+       dst = drm_gem_vram_kmap(gbo, false, NULL);
+       if (IS_ERR(dst)) {
+               DRM_ERROR("failed to kmap fb updates\n");
+               goto out;
+       } else if (!dst) {
+               dst = drm_gem_vram_kmap(gbo, true, NULL);
+               if (IS_ERR(dst)) {
                        DRM_ERROR("failed to kmap fb updates\n");
-                       ast_bo_unreserve(bo);
-                       return;
+                       goto out;
                }
                unmap = true;
        }
+
        for (i = y; i <= y2; i++) {
                /* assume equal stride for now */
-               src_offset = dst_offset = i * afbdev->afb.base.pitches[0] + (x * bpp);
-               memcpy_toio(bo->kmap.virtual + src_offset, afbdev->sysram + src_offset, (x2 - x + 1) * bpp);
-
+               src_offset = dst_offset =
+                       i * afbdev->afb.base.pitches[0] + (x * bpp);
+               memcpy_toio(dst + dst_offset, afbdev->sysram + src_offset,
+                           (x2 - x + 1) * bpp);
        }
+
        if (unmap)
-               ttm_bo_kunmap(&bo->kmap);
+               drm_gem_vram_kunmap(gbo);
 
-       ast_bo_unreserve(bo);
+out:
+       drm_gem_vram_unreserve(gbo);
 }
 
 static void ast_fillrect(struct fb_info *info,
@@ -217,8 +225,6 @@ static int astfb_create(struct drm_fb_helper *helper,
                ret = PTR_ERR(info);
                goto out;
        }
-       info->par = afbdev;
-
        ret = ast_framebuffer_init(dev, &afbdev->afb, &mode_cmd, gobj);
        if (ret)
                goto out;
@@ -229,15 +235,12 @@ static int astfb_create(struct drm_fb_helper *helper,
        fb = &afbdev->afb.base;
        afbdev->helper.fb = fb;
 
-       strcpy(info->fix.id, "astdrmfb");
-
        info->fbops = &astfb_ops;
 
        info->apertures->ranges[0].base = pci_resource_start(dev->pdev, 0);
        info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0);
 
-       drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
-       drm_fb_helper_fill_var(info, &afbdev->helper, sizes->fb_width, sizes->fb_height);
+       drm_fb_helper_fill_info(info, &afbdev->helper, sizes);
 
        info->screen_base = sysram;
        info->screen_size = size;