28 #include <linux/module.h>
29 #include <linux/kernel.h>
30 #include <linux/errno.h>
31 #include <linux/string.h>
33 #include <linux/tty.h>
45 static void ast_dirty_update(
struct ast_fbdev *afbdev,
49 struct drm_gem_object *obj;
51 int src_offset, dst_offset;
52 int bpp = (afbdev->
afb.base.bits_per_pixel + 7)/8;
56 obj = afbdev->
afb.obj;
61 DRM_ERROR(
"failed to reserve fb bo\n");
65 if (!bo->
kmap.virtual) {
68 DRM_ERROR(
"failed to kmap fb updates\n");
74 for (i = y; i < y +
height; i++) {
76 src_offset = dst_offset = i * afbdev->
afb.base.pitches[0] + (x *
bpp);
91 ast_dirty_update(afbdev, rect->
dx, rect->
dy, rect->
width,
100 ast_dirty_update(afbdev, area->
dx, area->
dy, area->
width,
109 ast_dirty_update(afbdev, image->
dx, image->
dy, image->
width,
113 static struct fb_ops astfb_ops = {
117 .fb_fillrect = ast_fillrect,
118 .fb_copyarea = ast_copyarea,
119 .fb_imageblit = ast_imageblit,
127 static int astfb_create_object(
struct ast_fbdev *afbdev,
129 struct drm_gem_object **gobj_p)
134 struct drm_gem_object *gobj;
148 static int astfb_create(
struct ast_fbdev *afbdev,
158 struct drm_gem_object *gobj =
NULL;
169 ret = astfb_create_object(afbdev, &mode_cmd, &gobj);
171 DRM_ERROR(
"failed to create fbcon backing object %d\n", ret);
194 fb = &afbdev->
afb.base;
201 info->
fbops = &astfb_ops;
225 DRM_DEBUG_KMS(
"allocated %dx%d\n",
237 ast_crtc->
lut_r[regno] = red >> 8;
238 ast_crtc->
lut_g[regno] = green >> 8;
239 ast_crtc->
lut_b[regno] = blue >> 8;
246 *red = ast_crtc->
lut_r[regno] << 8;
247 *green = ast_crtc->
lut_g[regno] << 8;
248 *blue = ast_crtc->
lut_b[regno] << 8;
251 static int ast_find_or_create_single(
struct drm_fb_helper *helper,
259 ret = astfb_create(afbdev, sizes);
268 .gamma_set = ast_fb_gamma_set,
269 .gamma_get = ast_fb_gamma_get,
270 .fb_probe = ast_find_or_create_single,
273 static void ast_fbdev_destroy(
struct drm_device *dev,
278 if (afbdev->
helper.fbdev) {
279 info = afbdev->
helper.fbdev;
287 drm_gem_object_unreference_unlocked(afb->
obj);
307 afbdev->
helper.funcs = &ast_fb_helper_funcs;
327 ast_fbdev_destroy(dev, ast->
fbdev);