Commit 595b61cc authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/fbcon: make use of drm_fb_helper.fb

Transitional step towards properly refcounting the fbcon fb.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 9dec9280
...@@ -337,12 +337,11 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ...@@ -337,12 +337,11 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_device *device = &drm->device; struct nvif_device *device = &drm->device;
struct fb_info *info; struct fb_info *info;
struct drm_framebuffer *fb; struct nouveau_framebuffer *fb;
struct nouveau_framebuffer *nouveau_fb;
struct nouveau_channel *chan; struct nouveau_channel *chan;
struct nouveau_bo *nvbo; struct nouveau_bo *nvbo;
struct drm_mode_fb_cmd2 mode_cmd; struct drm_mode_fb_cmd2 mode_cmd;
int size, ret; int ret;
mode_cmd.width = sizes->surface_width; mode_cmd.width = sizes->surface_width;
mode_cmd.height = sizes->surface_height; mode_cmd.height = sizes->surface_height;
...@@ -353,16 +352,16 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ...@@ -353,16 +352,16 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
sizes->surface_depth); sizes->surface_depth);
size = mode_cmd.pitches[0] * mode_cmd.height; ret = nouveau_gem_new(dev, mode_cmd.pitches[0] * mode_cmd.height,
size = roundup(size, PAGE_SIZE); 0, NOUVEAU_GEM_DOMAIN_VRAM, 0, 0x0000, &nvbo);
ret = nouveau_gem_new(dev, size, 0, NOUVEAU_GEM_DOMAIN_VRAM,
0, 0x0000, &nvbo);
if (ret) { if (ret) {
NV_ERROR(drm, "failed to allocate framebuffer\n"); NV_ERROR(drm, "failed to allocate framebuffer\n");
goto out; goto out;
} }
nouveau_framebuffer_init(dev, &fbcon->fb, &mode_cmd, nvbo);
fb = &fbcon->fb;
ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_VRAM, false); ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_VRAM, false);
if (ret) { if (ret) {
NV_ERROR(drm, "failed to pin fb: %d\n", ret); NV_ERROR(drm, "failed to pin fb: %d\n", ret);
...@@ -377,8 +376,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ...@@ -377,8 +376,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
chan = nouveau_nofbaccel ? NULL : drm->channel; chan = nouveau_nofbaccel ? NULL : drm->channel;
if (chan && device->info.family >= NV_DEVICE_INFO_V0_TESLA) { if (chan && device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
ret = nouveau_bo_vma_add(nvbo, drm->client.vm, ret = nouveau_bo_vma_add(nvbo, drm->client.vm, &fb->vma);
&fbcon->nouveau_fb.vma);
if (ret) { if (ret) {
NV_ERROR(drm, "failed to map fb into chan: %d\n", ret); NV_ERROR(drm, "failed to map fb into chan: %d\n", ret);
chan = NULL; chan = NULL;
...@@ -394,13 +392,8 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ...@@ -394,13 +392,8 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
info->par = fbcon; info->par = fbcon;
nouveau_framebuffer_init(dev, &fbcon->nouveau_fb, &mode_cmd, nvbo);
nouveau_fb = &fbcon->nouveau_fb;
fb = &nouveau_fb->base;
/* setup helper */ /* setup helper */
fbcon->helper.fb = fb; fbcon->helper.fb = &fb->base;
strcpy(info->fix.id, "nouveaufb"); strcpy(info->fix.id, "nouveaufb");
if (!chan) if (!chan)
...@@ -411,14 +404,14 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ...@@ -411,14 +404,14 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
FBINFO_HWACCEL_IMAGEBLIT; FBINFO_HWACCEL_IMAGEBLIT;
info->flags |= FBINFO_CAN_FORCE_OUTPUT; info->flags |= FBINFO_CAN_FORCE_OUTPUT;
info->fbops = &nouveau_fbcon_sw_ops; info->fbops = &nouveau_fbcon_sw_ops;
info->fix.smem_start = nvbo->bo.mem.bus.base + info->fix.smem_start = fb->nvbo->bo.mem.bus.base +
nvbo->bo.mem.bus.offset; fb->nvbo->bo.mem.bus.offset;
info->fix.smem_len = size; info->fix.smem_len = fb->nvbo->bo.mem.num_pages << PAGE_SHIFT;
info->screen_base = nvbo_kmap_obj_iovirtual(nouveau_fb->nvbo); info->screen_base = nvbo_kmap_obj_iovirtual(fb->nvbo);
info->screen_size = size; info->screen_size = fb->nvbo->bo.mem.num_pages << PAGE_SHIFT;
drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth); drm_fb_helper_fill_fix(info, fb->base.pitches[0], fb->base.depth);
drm_fb_helper_fill_var(info, &fbcon->helper, sizes->fb_width, sizes->fb_height); drm_fb_helper_fill_var(info, &fbcon->helper, sizes->fb_width, sizes->fb_height);
/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
...@@ -429,20 +422,19 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ...@@ -429,20 +422,19 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
/* To allow resizeing without swapping buffers */ /* To allow resizeing without swapping buffers */
NV_INFO(drm, "allocated %dx%d fb: 0x%llx, bo %p\n", NV_INFO(drm, "allocated %dx%d fb: 0x%llx, bo %p\n",
nouveau_fb->base.width, nouveau_fb->base.height, fb->base.width, fb->base.height, fb->nvbo->bo.offset, nvbo);
nvbo->bo.offset, nvbo);
vga_switcheroo_client_fb_set(dev->pdev, info); vga_switcheroo_client_fb_set(dev->pdev, info);
return 0; return 0;
out_unlock: out_unlock:
if (chan) if (chan)
nouveau_bo_vma_del(nvbo, &fbcon->nouveau_fb.vma); nouveau_bo_vma_del(fb->nvbo, &fb->vma);
nouveau_bo_unmap(nvbo); nouveau_bo_unmap(fb->nvbo);
out_unpin: out_unpin:
nouveau_bo_unpin(nvbo); nouveau_bo_unpin(fb->nvbo);
out_unref: out_unref:
nouveau_bo_ref(NULL, &nvbo); nouveau_bo_ref(NULL, &fb->nvbo);
out: out:
return ret; return ret;
} }
...@@ -458,14 +450,14 @@ nouveau_fbcon_output_poll_changed(struct drm_device *dev) ...@@ -458,14 +450,14 @@ nouveau_fbcon_output_poll_changed(struct drm_device *dev)
static int static int
nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *fbcon) nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *fbcon)
{ {
struct nouveau_framebuffer *nouveau_fb = &fbcon->nouveau_fb; struct nouveau_framebuffer *nouveau_fb = nouveau_framebuffer(fbcon->helper.fb);
drm_fb_helper_unregister_fbi(&fbcon->helper); drm_fb_helper_unregister_fbi(&fbcon->helper);
drm_fb_helper_release_fbi(&fbcon->helper); drm_fb_helper_release_fbi(&fbcon->helper);
if (nouveau_fb->nvbo) { if (nouveau_fb->nvbo) {
nouveau_bo_unmap(nouveau_fb->nvbo);
nouveau_bo_vma_del(nouveau_fb->nvbo, &nouveau_fb->vma); nouveau_bo_vma_del(nouveau_fb->nvbo, &nouveau_fb->vma);
nouveau_bo_unmap(nouveau_fb->nvbo);
nouveau_bo_unpin(nouveau_fb->nvbo); nouveau_bo_unpin(nouveau_fb->nvbo);
drm_gem_object_unreference_unlocked(&nouveau_fb->nvbo->gem); drm_gem_object_unreference_unlocked(&nouveau_fb->nvbo->gem);
nouveau_fb->nvbo = NULL; nouveau_fb->nvbo = NULL;
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
struct nouveau_fbdev { struct nouveau_fbdev {
struct drm_fb_helper helper; struct drm_fb_helper helper;
struct nouveau_framebuffer nouveau_fb; struct nouveau_framebuffer fb;
unsigned int saved_flags; unsigned int saved_flags;
struct nvif_object surf2d; struct nvif_object surf2d;
struct nvif_object clip; struct nvif_object clip;
......
...@@ -148,7 +148,7 @@ int ...@@ -148,7 +148,7 @@ int
nv50_fbcon_accel_init(struct fb_info *info) nv50_fbcon_accel_init(struct fb_info *info)
{ {
struct nouveau_fbdev *nfbdev = info->par; struct nouveau_fbdev *nfbdev = info->par;
struct nouveau_framebuffer *fb = &nfbdev->nouveau_fb; struct nouveau_framebuffer *fb = nouveau_framebuffer(nfbdev->helper.fb);
struct drm_device *dev = nfbdev->helper.dev; struct drm_device *dev = nfbdev->helper.dev;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_channel *chan = drm->channel; struct nouveau_channel *chan = drm->channel;
......
...@@ -149,7 +149,7 @@ nvc0_fbcon_accel_init(struct fb_info *info) ...@@ -149,7 +149,7 @@ nvc0_fbcon_accel_init(struct fb_info *info)
{ {
struct nouveau_fbdev *nfbdev = info->par; struct nouveau_fbdev *nfbdev = info->par;
struct drm_device *dev = nfbdev->helper.dev; struct drm_device *dev = nfbdev->helper.dev;
struct nouveau_framebuffer *fb = &nfbdev->nouveau_fb; struct nouveau_framebuffer *fb = nouveau_framebuffer(nfbdev->helper.fb);
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_channel *chan = drm->channel; struct nouveau_channel *chan = drm->channel;
int ret, format; int ret, format;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment