summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Hourihane <alanh@fairlite.demon.co.uk>2007-05-18 14:16:10 +0100
committerAlan Hourihane <alanh@fairlite.demon.co.uk>2007-05-18 14:16:10 +0100
commit0c33a2cd2ec81478403d39b1b92aaa4431e7cf0a (patch)
treeb452501935a7e2247bfc01188edba04a4efa31f8
parent3851600b3450697e20286b1937f3e51397f1965a (diff)
Move fbo creation to the specified fb driver which gives
it a chance to allocate the memory from whichever buffer it wants to.
-rw-r--r--linux-core/drm_crtc.c45
-rw-r--r--linux-core/drm_crtc.h4
-rw-r--r--linux-core/drm_fb.c3
-rw-r--r--linux-core/intel_drv.h4
-rw-r--r--linux-core/intel_fb.c39
5 files changed, 46 insertions, 49 deletions
diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c
index 7544eac4..1586eb1a 100644
--- a/linux-core/drm_crtc.c
+++ b/linux-core/drm_crtc.c
@@ -184,6 +184,7 @@ void drm_framebuffer_destroy(struct drm_framebuffer *fb)
kfree(fb);
}
+EXPORT_SYMBOL(drm_framebuffer_destroy);
/**
* drm_crtc_create - create a new CRTC object
@@ -820,10 +821,8 @@ static void drm_pick_crtcs (drm_device_t *dev)
break;
}
-
/* No preferred mode, let's select another which should pick
* the default 640x480 if nothing else is here.
- *
*/
if (!des_mode || !(des_mode->flags & DRM_MODE_TYPE_PREFERRED)) {
list_for_each_entry(des_mode, &output->modes, head) {
@@ -887,13 +886,7 @@ clone:
*/
bool drm_initial_config(drm_device_t *dev, bool can_grow)
{
- /* do a hardcoded initial configuration here */
- struct drm_display_mode *des_mode = NULL;
struct drm_output *output;
- struct drm_framebuffer *fb;
- drm_buffer_object_t *fbo;
- unsigned long size, bytes_per_pixel;
- int ret;
drm_crtc_probe_output_modes(dev, 2048, 2048);
@@ -905,42 +898,6 @@ bool drm_initial_config(drm_device_t *dev, bool can_grow)
if (!output->crtc || !output->crtc->desired_mode)
continue;
- fb = drm_framebuffer_create(dev);
- if (!fb) {
- DRM_ERROR("failed to allocate fb.\n");
- return true;
- }
- output->crtc->fb = fb;
- des_mode = output->crtc->desired_mode;
-
- if (des_mode->hdisplay > fb->width)
- fb->width = des_mode->hdisplay;
- if (des_mode->vdisplay > fb->height)
- fb->height = des_mode->vdisplay;
-
- /* FIXME: multiple depths */
- bytes_per_pixel = 4;
- fb->bits_per_pixel = 32;
- fb->pitch = fb->width * ((fb->bits_per_pixel + 1) / 8);
- fb->depth = 24;
- size = fb->width * fb->height * bytes_per_pixel;
- /* FIXME - what about resizeable objects ??? */
- ret = drm_buffer_object_create(dev, size, drm_bo_type_kernel,
- DRM_BO_FLAG_READ |
- DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_MEM_PRIV0 |
- DRM_BO_FLAG_NO_MOVE,
- 0, 0, 0,
- &fbo);
- if (ret) {
- printk(KERN_ERR "failed to allocate framebuffer\n");
- drm_framebuffer_destroy(fb);
- continue;
- }
- fb->offset = fbo->offset;
- fb->bo = fbo;
- printk("allocated %dx%d fb: 0x%08lx, bo %p\n", fb->width,
- fb->height, fbo->offset, fbo);
dev->driver->fb_probe(dev, output->crtc);
}
drm_disable_unused_functions(dev);
diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h
index fa143e6e..8dfd2e2b 100644
--- a/linux-core/drm_crtc.h
+++ b/linux-core/drm_crtc.h
@@ -521,8 +521,12 @@ extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev);
extern bool drm_initial_config(struct drm_device *dev, bool cangrow);
extern void drm_framebuffer_set_object(struct drm_device *dev,
unsigned long handle);
+extern struct drm_framebuffer *drm_framebuffer_create(struct drm_device *dev);
+extern void drm_framebuffer_destroy(struct drm_framebuffer *fb);
extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc);
extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
+extern bool drm_crtc_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,
+ int x, int y);
/* IOCTLs */
extern int drm_mode_getresources(struct inode *inode, struct file *filp,
diff --git a/linux-core/drm_fb.c b/linux-core/drm_fb.c
index 173864d0..1531e96c 100644
--- a/linux-core/drm_fb.c
+++ b/linux-core/drm_fb.c
@@ -418,9 +418,10 @@ int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
}
EXPORT_SYMBOL(drmfb_probe);
-int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb)
+int drmfb_remove(struct drm_device *dev, struct drm_crtc *crtc)
{
struct fb_info *info = fb->fbdev;
+ struct drm_framebuffer *fb = crtc->fb;
if (info) {
drm_mem_reg_iounmap(dev, &fb->bo->mem, fb->virtual_base);
diff --git a/linux-core/intel_drv.h b/linux-core/intel_drv.h
index 9205b99b..0a03e37b 100644
--- a/linux-core/intel_drv.h
+++ b/linux-core/intel_drv.h
@@ -76,7 +76,7 @@ extern struct drm_display_mode *intel_crtc_mode_get(drm_device_t *dev,
extern void intel_wait_for_vblank(drm_device_t *dev);
extern struct drm_crtc *intel_get_crtc_from_pipe(drm_device_t *dev, int pipe);
-extern int intelfb_probe(struct drm_device *dev, struct drm_framebuffer *fb);
-extern int intelfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
+extern int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc);
+extern int intelfb_remove(struct drm_device *dev, struct drm_crtc *crtc);
#endif /* __INTEL_DRV_H__ */
diff --git a/linux-core/intel_fb.c b/linux-core/intel_fb.c
index 3c865a2f..ceeefc8c 100644
--- a/linux-core/intel_fb.c
+++ b/linux-core/intel_fb.c
@@ -210,7 +210,6 @@ static int intelfb_set_par(struct fb_info *info)
struct drm_device *dev = par->dev;
struct drm_display_mode *drm_mode;
struct fb_var_screeninfo *var = &info->var;
- struct drm_output *output;
switch (var->bits_per_pixel) {
case 16:
@@ -444,8 +443,9 @@ int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
struct fb_info *info;
struct intelfb_par *par;
struct device *device = &dev->pdev->dev;
- struct drm_framebuffer *fb = crtc->fb;
+ struct drm_framebuffer *fb;
struct drm_display_mode *mode = crtc->desired_mode;
+ drm_buffer_object_t *fbo = NULL;
int ret;
info = framebuffer_alloc(sizeof(struct intelfb_par), device);
@@ -453,6 +453,41 @@ int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
return -EINVAL;
}
+ fb = drm_framebuffer_create(dev);
+ if (!fb) {
+ framebuffer_release(info);
+ DRM_ERROR("failed to allocate fb.\n");
+ return -EINVAL;
+ }
+ crtc->fb = fb;
+
+ fb->width = crtc->desired_mode->hdisplay;
+ fb->height = crtc->desired_mode->vdisplay;
+
+ fb->bits_per_pixel = 32;
+ fb->pitch = fb->width * ((fb->bits_per_pixel + 1) / 8);
+ fb->depth = 24;
+ ret = drm_buffer_object_create(dev,
+ fb->width * fb->height * 4,
+ drm_bo_type_kernel,
+ DRM_BO_FLAG_READ |
+ DRM_BO_FLAG_WRITE |
+ DRM_BO_FLAG_MEM_PRIV0 | /* FIXME! */
+ DRM_BO_FLAG_NO_MOVE,
+ 0, 0, 0,
+ &fbo);
+ if (ret || !fbo) {
+ printk(KERN_ERR "failed to allocate framebuffer\n");
+ drm_framebuffer_destroy(fb);
+ framebuffer_release(info);
+ return -EINVAL;
+ }
+ fb->offset = fbo->offset;
+ fb->bo = fbo;
+ printk("allocated %dx%d fb: 0x%08lx, bo %p\n", fb->width,
+ fb->height, fbo->offset, fbo);
+
+
fb->fbdev = info;
par = info->par;