Subversion Repositories Kolibri OS

Rev

Rev 1182 | Rev 1222 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1182 Rev 1221
Line 40... Line 40...
40
#include "drm_fb_helper.h"
40
#include "drm_fb_helper.h"
Line 41... Line 41...
41
 
41
 
42
#include 
42
#include 
Line 43... Line 43...
43
#include "radeon_object.h"
43
#include "radeon_object.h"
Line 44... Line 44...
44
 
44
 
45
struct fb_info *framebuffer_alloc(size_t size);
45
struct fb_info *framebuffer_alloc(size_t size, void *dev);
46
 
46
 
47
struct radeon_fb_device {
47
struct radeon_fb_device {
Line 58... Line 58...
58
//	.fb_fillrect = cfb_fillrect,
58
//	.fb_fillrect = cfb_fillrect,
59
//	.fb_copyarea = cfb_copyarea,
59
//	.fb_copyarea = cfb_copyarea,
60
//	.fb_imageblit = cfb_imageblit,
60
//	.fb_imageblit = cfb_imageblit,
61
//	.fb_pan_display = drm_fb_helper_pan_display,
61
//	.fb_pan_display = drm_fb_helper_pan_display,
62
	.fb_blank = drm_fb_helper_blank,
62
	.fb_blank = drm_fb_helper_blank,
-
 
63
	.fb_setcmap = drm_fb_helper_setcmap,
63
};
64
};
Line 64... Line 65...
64
 
65
 
65
/**
66
/**
66
 * Curretly it is assumed that the old framebuffer is reused.
67
 * Curretly it is assumed that the old framebuffer is reused.
Line 126... Line 127...
126
	return aligned;
127
	return aligned;
127
}
128
}
Line 128... Line 129...
128
 
129
 
129
static struct drm_fb_helper_funcs radeon_fb_helper_funcs = {
130
static struct drm_fb_helper_funcs radeon_fb_helper_funcs = {
-
 
131
	.gamma_set = radeon_crtc_fb_gamma_set,
130
	.gamma_set = radeon_crtc_fb_gamma_set,
132
	.gamma_get = radeon_crtc_fb_gamma_get,
Line 131... Line 133...
131
};
133
};
132
 
134
 
133
int radeonfb_create(struct drm_device *dev,
135
int radeonfb_create(struct drm_device *dev,
-
 
136
		    uint32_t fb_width, uint32_t fb_height,
134
		    uint32_t fb_width, uint32_t fb_height,
137
		    uint32_t surface_width, uint32_t surface_height,
135
		    uint32_t surface_width, uint32_t surface_height,
138
		    uint32_t surface_depth, uint32_t surface_bpp,
136
		    struct drm_framebuffer **fb_p)
139
		    struct drm_framebuffer **fb_p)
137
{
140
{
138
	struct radeon_device *rdev = dev->dev_private;
141
	struct radeon_device *rdev = dev->dev_private;
139
	struct fb_info *info;
142
	struct fb_info *info;
140
	struct radeon_fb_device *rfbdev;
143
	struct radeon_fb_device *rfbdev;
141
	struct drm_framebuffer *fb = NULL;
144
	struct drm_framebuffer *fb = NULL;
142
	struct radeon_framebuffer *rfb;
145
	struct radeon_framebuffer *rfb;
143
	struct drm_mode_fb_cmd mode_cmd;
146
	struct drm_mode_fb_cmd mode_cmd;
144
	struct drm_gem_object *gobj = NULL;
147
	struct drm_gem_object *gobj = NULL;
145
	struct radeon_object *robj = NULL;
148
	struct radeon_object *robj = NULL;
146
//   struct device *device = &rdev->pdev->dev;
149
    void   *device = NULL; //&rdev->pdev->dev;
147
	int size, aligned_size, ret;
150
	int size, aligned_size, ret;
148
	u64 fb_gpuaddr;
151
	u64 fb_gpuaddr;
149
	void *fbptr = NULL;
152
	void *fbptr = NULL;
150
	unsigned long tmp;
153
	unsigned long tmp;
-
 
154
	bool fb_tiled = false; /* useful for testing */
Line 151... Line 155...
151
	bool fb_tiled = false; /* useful for testing */
155
	u32 tiling_flags = 0;
152
	u32 tiling_flags = 0;
156
	int crtc_count;
-
 
157
 
-
 
158
    mode_cmd.width  = surface_width;
-
 
159
	mode_cmd.height = surface_height;
-
 
160
 
-
 
161
	/* avivo can't scanout real 24bpp */
153
 
162
	if ((surface_bpp == 24) && ASIC_IS_AVIVO(rdev))
154
    mode_cmd.width  = surface_width;
163
		surface_bpp = 32;
155
	mode_cmd.height = surface_height;
164
 
156
	mode_cmd.bpp = 32;
165
	mode_cmd.bpp = 32;
Line 157... Line 166...
157
	/* need to align pitch with crtc limits */
166
	/* need to align pitch with crtc limits */
158
	mode_cmd.pitch = radeon_align_pitch(rdev, mode_cmd.width, mode_cmd.bpp, fb_tiled) * ((mode_cmd.bpp + 1) / 8);
167
	mode_cmd.pitch = radeon_align_pitch(rdev, mode_cmd.width, mode_cmd.bpp, fb_tiled) * ((mode_cmd.bpp + 1) / 8);
Line 159... Line 168...
159
	mode_cmd.depth = 24;
168
	mode_cmd.depth = surface_depth;
160
 
169
 
161
	size = mode_cmd.pitch * mode_cmd.height;
170
	size = mode_cmd.pitch * mode_cmd.height;
162
	aligned_size = ALIGN(size, PAGE_SIZE);
171
	aligned_size = ALIGN(size, PAGE_SIZE);
163
 
-
 
164
    ret = radeon_gem_fb_object_create(rdev, aligned_size, 0,
172
 
165
			RADEON_GEM_DOMAIN_VRAM,
173
    ret = radeon_gem_fb_object_create(rdev, aligned_size, 0,
166
            false, 0,
174
			RADEON_GEM_DOMAIN_VRAM,
167
			false, &gobj);
175
            false, 0,
168
 
176
			false, &gobj);
Line 193... Line 201...
193
	*fb_p = fb;
201
	*fb_p = fb;
194
	rfb = to_radeon_framebuffer(fb);
202
	rfb = to_radeon_framebuffer(fb);
195
	rdev->fbdev_rfb = rfb;
203
	rdev->fbdev_rfb = rfb;
196
	rdev->fbdev_robj = robj;
204
	rdev->fbdev_robj = robj;
Line 197... Line 205...
197
 
205
 
198
	info = framebuffer_alloc(sizeof(struct radeon_fb_device));
206
	info = framebuffer_alloc(sizeof(struct radeon_fb_device), device);
199
	if (info == NULL) {
207
	if (info == NULL) {
200
		ret = -ENOMEM;
208
		ret = -ENOMEM;
201
		goto out_unref;
209
		goto out_unref;
Line 202... Line 210...
202
	}
210
	}
203
 
211
 
204
	rdev->fbdev_info = info;
212
	rdev->fbdev_info = info;
205
	rfbdev = info->par;
213
	rfbdev = info->par;
-
 
214
	rfbdev->helper.funcs = &radeon_fb_helper_funcs;
-
 
215
	rfbdev->helper.dev = dev;
-
 
216
	if (rdev->flags & RADEON_SINGLE_CRTC)
-
 
217
		crtc_count = 1;
206
	rfbdev->helper.funcs = &radeon_fb_helper_funcs;
218
	else
207
	rfbdev->helper.dev = dev;
219
		crtc_count = 2;
208
	ret = drm_fb_helper_init_crtc_count(&rfbdev->helper, 2,
220
	ret = drm_fb_helper_init_crtc_count(&rfbdev->helper, crtc_count,
209
					    RADEONFB_CONN_LIMIT);
221
					    RADEONFB_CONN_LIMIT);
Line 210... Line 222...
210
	if (ret)
222
	if (ret)
Line 218... Line 230...
218
 
230
 
Line 219... Line 231...
219
    fbptr = (void*)0xFE000000; // LFB_BASE
231
    fbptr = (void*)0xFE000000; // LFB_BASE
Line 220... Line 232...
220
 
232
 
Line 221... Line 233...
221
	strcpy(info->fix.id, "radeondrmfb");
233
	strcpy(info->fix.id, "radeondrmfb");
222
 
234
 
Line 223... Line 235...
223
	drm_fb_helper_fill_fix(info, fb->pitch);
235
	drm_fb_helper_fill_fix(info, fb->pitch, fb->depth);
Line 279... Line 291...
279
	return ret;
291
	return ret;
280
}
292
}
Line 281... Line 293...
281
 
293
 
282
int radeonfb_probe(struct drm_device *dev)
294
int radeonfb_probe(struct drm_device *dev)
283
{
-
 
284
	int ret;
295
{
285
	ret = drm_fb_helper_single_fb_probe(dev, &radeonfb_create);
-
 
286
	return ret;
296
	return drm_fb_helper_single_fb_probe(dev, 32, &radeonfb_create);
287
}
-
 
Line 288... Line 297...
288
EXPORT_SYMBOL(radeonfb_probe);
297
}
289
 
298
 
290
int radeonfb_remove(struct drm_device *dev, struct drm_framebuffer *fb)
299
int radeonfb_remove(struct drm_device *dev, struct drm_framebuffer *fb)
291
{
300
{
Line 399... Line 408...
399
    *obj = gobj;
408
    *obj = gobj;
400
    return 0;
409
    return 0;
401
}
410
}
Line 402... Line 411...
402
 
411
 
403
 
412
 
404
struct fb_info *framebuffer_alloc(size_t size)
413
struct fb_info *framebuffer_alloc(size_t size, void *dev)
405
{
414
{
406
#define BYTES_PER_LONG (BITS_PER_LONG/8)
415
#define BYTES_PER_LONG (BITS_PER_LONG/8)
407
#define PADDING (BYTES_PER_LONG - (sizeof(struct fb_info) % BYTES_PER_LONG))
416
#define PADDING (BYTES_PER_LONG - (sizeof(struct fb_info) % BYTES_PER_LONG))
Line 444... Line 453...
444
{
453
{
445
    struct drm_connector *connector;
454
    struct drm_connector *connector;
Line 446... Line 455...
446
 
455
 
Line -... Line 456...
-
 
456
    bool ret = false;
-
 
457
 
447
    bool ret = false;
458
    ENTER();
448
 
459
 
449
    list_for_each_entry(connector, &dev->mode_config.connector_list, head)
460
    list_for_each_entry(connector, &dev->mode_config.connector_list, head)
Line 450... Line 461...
450
    {
461
    {
Line 463... Line 474...
463
        crtc = encoder->crtc;
474
        crtc = encoder->crtc;
Line 464... Line 475...
464
 
475
 
465
        if(crtc == NULL)
476
        if(crtc == NULL)
Line 466... Line 477...
466
            continue;
477
            continue;
467
 
478
 
468
 
479
/*
469
        list_for_each_entry(mode, &connector->modes, head)
480
        list_for_each_entry(mode, &connector->modes, head)
470
        {
481
        {
471
            if (mode->type & DRM_MODE_TYPE_PREFERRED);
482
            if (mode->type & DRM_MODE_TYPE_PREFERRED);
Line 472... Line -...
472
                break;
-
 
473
        };
483
                break;
474
 
484
        };
Line 475... Line 485...
475
/*
485
 
476
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
486
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
Line 534... Line 544...
534
                else
544
                else
535
                {
545
                {
536
                    DRM_ERROR("failed to set mode %d_%d on crtc %p\n",
546
                    DRM_ERROR("failed to set mode %d_%d on crtc %p\n",
537
                               fb->width, fb->height, crtc);
547
                               fb->width, fb->height, crtc);
538
                };
548
                };
-
 
549
 
-
 
550
                LEAVE();
-
 
551
 
-
 
552
                return ret;
539
            };
553
            };
540
        }
554
        }
541
    };
555
    };
542
 
556
    LEAVE();
543
    return ret;
557
    return ret;
544
};
558
};