13 #include <linux/module.h>
21 static void mga_dirty_update(
struct mga_fbdev *mfbdev,
25 struct drm_gem_object *obj;
27 int src_offset, dst_offset;
28 int bpp = (mfbdev->
mfb.base.bits_per_pixel + 7)/8;
32 obj = mfbdev->
mfb.obj;
37 DRM_ERROR(
"failed to reserve fb bo\n");
41 if (!bo->
kmap.virtual) {
44 DRM_ERROR(
"failed to kmap fb updates\n");
50 for (i = y; i < y +
height; i++) {
52 src_offset = dst_offset = i * mfbdev->
mfb.base.pitches[0] + (x *
bpp);
67 mga_dirty_update(mfbdev, rect->
dx, rect->
dy, rect->
width,
76 mga_dirty_update(mfbdev, area->
dx, area->
dy, area->
width,
85 mga_dirty_update(mfbdev, image->
dx, image->
dy, image->
width,
90 static struct fb_ops mgag200fb_ops = {
94 .fb_fillrect = mga_fillrect,
95 .fb_copyarea = mga_copyarea,
96 .fb_imageblit = mga_imageblit,
102 static int mgag200fb_create_object(
struct mga_fbdev *afbdev,
104 struct drm_gem_object **gobj_p)
109 struct drm_gem_object *gobj;
123 static int mgag200fb_create(
struct mga_fbdev *mfbdev,
131 struct drm_gem_object *gobj =
NULL;
146 ret = mgag200fb_create_object(mfbdev, &mode_cmd, &gobj);
148 DRM_ERROR(
"failed to create fbcon backing object %d\n", ret);
170 fb = &mfbdev->
mfb.base;
178 DRM_ERROR(
"%s: can't allocate color map\n", info->
fix.id);
186 info->
fbops = &mgag200fb_ops;
194 info->
apertures->ranges[0].base = mdev->
dev->mode_config.fb_base;
195 info->
apertures->ranges[0].size = mdev->
mc.vram_size;
205 DRM_DEBUG_KMS(
"allocated %dx%d\n",
212 static int mga_fb_find_or_create_single(
struct drm_fb_helper *helper,
221 ret = mgag200fb_create(mfbdev, sizes);
229 static int mga_fbdev_destroy(
struct drm_device *dev,
235 if (mfbdev->
helper.fbdev) {
236 info = mfbdev->
helper.fbdev;
245 drm_gem_object_unreference_unlocked(mfb->
obj);
258 .fb_probe = mga_fb_find_or_create_single,
271 mfbdev->
helper.funcs = &mga_fb_helper_funcs;
290 mga_fbdev_destroy(mdev->
dev, mdev->
mfbdev);