nv50/kms: get rid of nv50_fb_info

This commit is contained in:
Ben Skeggs 2009-02-04 08:42:55 +10:00
parent f16514cccc
commit af8a76bd22
5 changed files with 52 additions and 81 deletions

View file

@ -540,7 +540,6 @@ int nv50_kms_crtc_set_config(struct drm_mode_set *set)
struct nv50_output *output = NULL;
struct nv50_connector *connector = NULL;
struct drm_display_mode *mode = NULL;
struct nv50_fb_info fb_info;
bool blank = false;
bool switch_fb = false;
@ -741,18 +740,7 @@ int nv50_kms_crtc_set_config(struct drm_mode_set *set)
/* set framebuffer */
set->crtc->fb = set->fb;
/* set private framebuffer */
crtc = to_nv50_crtc(set->crtc);
fb_info.gem = nv50_framebuffer(set->fb)->gem;
fb_info.width = set->fb->width;
fb_info.height = set->fb->height;
fb_info.depth = set->fb->depth;
fb_info.bpp = set->fb->bits_per_pixel;
fb_info.pitch = set->fb->pitch;
fb_info.x = set->x;
fb_info.y = set->y;
rval = crtc->fb->bind(crtc, &fb_info);
rval = crtc->fb->bind(crtc, set->fb, set->x, set->y);
if (rval != 0) {
DRM_ERROR("fb_bind failed\n");
goto out;

View file

@ -29,36 +29,30 @@
#include "nv50_crtc.h"
#include "nv50_display.h"
static int nv50_fb_bind(struct nv50_crtc *crtc, struct nv50_fb_info *info)
static int nv50_fb_bind(struct nv50_crtc *crtc, struct drm_framebuffer *drm_fb,
int x, int y)
{
struct nv50_framebuffer *fb = to_nv50_framebuffer(drm_fb);
int rval = 0;
NV50_DEBUG("\n");
if (!crtc || !info) {
DRM_ERROR("crtc %p info %p\n",crtc, info);
if (!crtc || !drm_fb) {
DRM_ERROR("crtc %p drm_fb %p\n", crtc, drm_fb);
return -EINVAL;
}
if (!info->gem || !info->width || !info->height || !info->depth ||
!info->bpp || !info->pitch) {
DRM_ERROR("gem %p width %d height %d depth %d bpp %d pitch %d\n",
info->gem, info->width, info->height, info->depth,
info->bpp, info->pitch);
return -EINVAL;
}
crtc->fb->gem = fb->gem;
crtc->fb->width = drm_fb->width;
crtc->fb->height = drm_fb->height;
crtc->fb->gem = info->gem;
crtc->fb->width = info->width;
crtc->fb->height = info->height;
crtc->fb->x = x;
crtc->fb->y = y;
crtc->fb->y = info->x;
crtc->fb->x = info->y;
crtc->fb->depth = drm_fb->depth;
crtc->fb->bpp = drm_fb->bits_per_pixel;
crtc->fb->depth = info->depth;
crtc->fb->bpp = info->bpp;
crtc->fb->pitch = info->pitch;
crtc->fb->pitch = drm_fb->pitch;
/* update lut if needed */
if (crtc->fb->depth != crtc->lut->depth) {
@ -67,22 +61,22 @@ static int nv50_fb_bind(struct nv50_crtc *crtc, struct nv50_fb_info *info)
int i;
switch (crtc->fb->depth) {
case 15:
r_size = 32;
g_size = 32;
b_size = 32;
break;
case 16:
r_size = 32;
g_size = 64;
b_size = 32;
break;
case 24:
default:
r_size = 256;
g_size = 256;
b_size = 256;
break;
case 15:
r_size = 32;
g_size = 32;
b_size = 32;
break;
case 16:
r_size = 32;
g_size = 64;
b_size = 32;
break;
case 24:
default:
r_size = 256;
g_size = 256;
b_size = 256;
break;
}
r_val = kmalloc(r_size * sizeof(uint16_t), GFP_KERNEL);

View file

@ -31,14 +31,6 @@
struct nv50_crtc;
struct nv50_fb_info {
struct drm_gem_object *gem;
int width, height;
int bpp, depth;
int pitch;
int x,y;
};
struct nv50_fb {
struct drm_gem_object *gem;
int width, height;
@ -48,7 +40,8 @@ struct nv50_fb {
int x,y;
/* function points */
int (*bind) (struct nv50_crtc *crtc, struct nv50_fb_info *info);
int (*bind) (struct nv50_crtc *crtc, struct drm_framebuffer *drm_fb,
int x, int y);
};
struct nv50_framebuffer {
@ -57,11 +50,7 @@ struct nv50_framebuffer {
struct drm_bo_kmap_obj kmap;
};
static inline struct nv50_framebuffer *
nv50_framebuffer(struct drm_framebuffer *fb)
{
return (struct nv50_framebuffer *)fb;
}
#define to_nv50_framebuffer(x) container_of((x), struct nv50_framebuffer, base)
int nv50_fb_create(struct nv50_crtc *crtc);
int nv50_fb_destroy(struct nv50_crtc *crtc);

View file

@ -439,7 +439,7 @@ int nv50_fbcon_init(struct drm_device *dev)
struct nv50_fbcon_par *par;
struct device *device = &dev->pdev->dev;
struct drm_framebuffer *drm_fb;
struct nv50_framebuffer *nv50_fb;
struct nv50_framebuffer *fb;
struct nouveau_gem_object *ngem;
int ret;
@ -457,9 +457,9 @@ int nv50_fbcon_init(struct drm_device *dev)
DRM_ERROR("no drm_fb found\n");
return -EINVAL;
}
nv50_fb = nv50_framebuffer(drm_fb);
fb = to_nv50_framebuffer(drm_fb);
ngem = nouveau_gem_object(nv50_fb->gem);
ngem = nouveau_gem_object(fb->gem);
if (!ngem) {
DRM_ERROR("no buffer object for FB!\n");
return -EINVAL;
@ -494,13 +494,13 @@ int nv50_fbcon_init(struct drm_device *dev)
info->flags = FBINFO_DEFAULT;
ret = drm_bo_kmap(ngem->bo, 0, ngem->bo->mem.num_pages, &nv50_fb->kmap);
ret = drm_bo_kmap(ngem->bo, 0, ngem->bo->mem.num_pages, &fb->kmap);
if (ret) {
DRM_ERROR("Error mapping framebuffer: %d\n", ret);
return ret;
}
info->screen_base = nv50_fb->kmap.virtual;
info->screen_base = fb->kmap.virtual;
info->screen_size = info->fix.smem_len; /* FIXME */
info->pseudo_palette = drm_fb->pseudo_palette;
@ -581,7 +581,7 @@ int nv50_fbcon_init(struct drm_device *dev)
int nv50_fbcon_destroy(struct drm_device *dev)
{
struct drm_framebuffer *drm_fb;
struct nv50_framebuffer *nv50_fb;
struct nv50_framebuffer *fb;
struct fb_info *info;
list_for_each_entry(drm_fb, &dev->mode_config.fb_kernel_list, filp_head) {
@ -592,7 +592,7 @@ int nv50_fbcon_destroy(struct drm_device *dev)
DRM_ERROR("No framebuffer to destroy\n");
return -EINVAL;
}
nv50_fb = nv50_framebuffer(drm_fb);
fb = to_nv50_framebuffer(drm_fb);
info = drm_fb->fbdev;
if (!info) {
@ -602,11 +602,11 @@ int nv50_fbcon_destroy(struct drm_device *dev)
// unregister_framebuffer(info);
if (nv50_fb->kmap.virtual)
drm_bo_kunmap(&nv50_fb->kmap);
if (nv50_fb->gem) {
if (fb->kmap.virtual)
drm_bo_kunmap(&fb->kmap);
if (fb->gem) {
mutex_lock(&dev->struct_mutex);
drm_gem_object_unreference(nv50_fb->gem);
drm_gem_object_unreference(fb->gem);
mutex_unlock(&dev->struct_mutex);
}

View file

@ -72,23 +72,23 @@ void nv50_kms_mirror_routing(struct drm_device *dev)
* FB functions.
*/
static void nv50_kms_framebuffer_destroy(struct drm_framebuffer *fb)
static void nv50_kms_framebuffer_destroy(struct drm_framebuffer *drm_fb)
{
struct nv50_framebuffer *nv50_fb = nv50_framebuffer(fb);
struct nv50_framebuffer *fb = to_nv50_framebuffer(drm_fb);
drm_gem_object_unreference(nv50_fb->gem);
drm_framebuffer_cleanup(&nv50_fb->base);
kfree(nv50_fb);
drm_gem_object_unreference(fb->gem);
drm_framebuffer_cleanup(&fb->base);
kfree(fb);
}
static int
nv50_kms_framebuffer_create_handle(struct drm_framebuffer *fb,
nv50_kms_framebuffer_create_handle(struct drm_framebuffer *drm_fb,
struct drm_file *file_priv,
unsigned int *handle)
{
struct nv50_framebuffer *nv50_fb = nv50_framebuffer(fb);
struct nv50_framebuffer *fb = to_nv50_framebuffer(drm_fb);
return drm_gem_handle_create(file_priv, nv50_fb->gem, handle);
return drm_gem_handle_create(file_priv, fb->gem, handle);
}
static const struct drm_framebuffer_funcs nv50_kms_fb_funcs = {