Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1471ca9a authored by Marcin Slusarz's avatar Marcin Slusarz Committed by Dave Airlie
Browse files

fbdev: allow passing more than one aperture for handoff



It removes a hack from nouveau code which had to detect which
region to pass to kick vesafb/efifb.

Signed-off-by: default avatarMarcin Slusarz <marcin.slusarz@gmail.com>
Cc: Eric Anholt <eric@anholt.net>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Peter Jones <pjones@redhat.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 3da1f33e
Loading
Loading
Loading
Loading
+8 −3
Original line number Original line Diff line number Diff line
@@ -128,11 +128,16 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
	info->fbops = &intelfb_ops;
	info->fbops = &intelfb_ops;


	/* setup aperture base/size for vesafb takeover */
	/* setup aperture base/size for vesafb takeover */
	info->aperture_base = dev->mode_config.fb_base;
	info->apertures = alloc_apertures(1);
	if (!info->apertures) {
		ret = -ENOMEM;
		goto out_unpin;
	}
	info->apertures->ranges[0].base = dev->mode_config.fb_base;
	if (IS_I9XX(dev))
	if (IS_I9XX(dev))
		info->aperture_size = pci_resource_len(dev->pdev, 2);
		info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 2);
	else
	else
		info->aperture_size = pci_resource_len(dev->pdev, 0);
		info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0);


	info->fix.smem_start = dev->mode_config.fb_base + obj_priv->gtt_offset;
	info->fix.smem_start = dev->mode_config.fb_base + obj_priv->gtt_offset;
	info->fix.smem_len = size;
	info->fix.smem_len = size;
+25 −59
Original line number Original line Diff line number Diff line
@@ -152,44 +152,6 @@ static void nouveau_fbcon_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
	*blue = nv_crtc->lut.b[regno];
	*blue = nv_crtc->lut.b[regno];
}
}


#if defined(__i386__) || defined(__x86_64__)
static bool
nouveau_fbcon_has_vesafb_or_efifb(struct drm_device *dev)
{
	struct pci_dev *pdev = dev->pdev;
	int ramin;

	if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB &&
	    screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
		return false;

	if (screen_info.lfb_base < pci_resource_start(pdev, 1))
		goto not_fb;

	if (screen_info.lfb_base + screen_info.lfb_size >=
	    pci_resource_start(pdev, 1) + pci_resource_len(pdev, 1))
		goto not_fb;

	return true;
not_fb:
	ramin = 2;
	if (pci_resource_len(pdev, ramin) == 0) {
		ramin = 3;
		if (pci_resource_len(pdev, ramin) == 0)
			return false;
	}

	if (screen_info.lfb_base < pci_resource_start(pdev, ramin))
		return false;

	if (screen_info.lfb_base + screen_info.lfb_size >=
	    pci_resource_start(pdev, ramin) + pci_resource_len(pdev, ramin))
		return false;

	return true;
}
#endif

static void
static void
nouveau_fbcon_zfill(struct drm_device *dev, struct nouveau_fbdev *nfbdev)
nouveau_fbcon_zfill(struct drm_device *dev, struct nouveau_fbdev *nfbdev)
{
{
@@ -219,7 +181,9 @@ nouveau_fbcon_create(struct nouveau_fbdev *nfbdev,
	struct nouveau_framebuffer *nouveau_fb;
	struct nouveau_framebuffer *nouveau_fb;
	struct nouveau_bo *nvbo;
	struct nouveau_bo *nvbo;
	struct drm_mode_fb_cmd mode_cmd;
	struct drm_mode_fb_cmd mode_cmd;
	struct device *device = &dev->pdev->dev;
	struct pci_dev *pdev = dev->pdev;
	struct device *device = &pdev->dev;
	struct apertures_struct *aper;
	int size, ret;
	int size, ret;


	mode_cmd.width = sizes->surface_width;
	mode_cmd.width = sizes->surface_width;
@@ -299,28 +263,30 @@ nouveau_fbcon_create(struct nouveau_fbdev *nfbdev,
	drm_fb_helper_fill_var(info, &nfbdev->helper, sizes->fb_width, sizes->fb_height);
	drm_fb_helper_fill_var(info, &nfbdev->helper, sizes->fb_width, sizes->fb_height);


	/* FIXME: we really shouldn't expose mmio space at all */
	/* FIXME: we really shouldn't expose mmio space at all */
	info->fix.mmio_start = pci_resource_start(dev->pdev, 1);
	info->fix.mmio_start = pci_resource_start(pdev, 1);
	info->fix.mmio_len = pci_resource_len(dev->pdev, 1);
	info->fix.mmio_len = pci_resource_len(pdev, 1);


	/* Set aperture base/size for vesafb takeover */
	/* Set aperture base/size for vesafb takeover */
#if defined(__i386__) || defined(__x86_64__)
	aper = info->apertures = alloc_apertures(3);
	if (nouveau_fbcon_has_vesafb_or_efifb(dev)) {
	if (!info->apertures) {
		/* Some NVIDIA VBIOS' are stupid and decide to put the
		ret = -ENOMEM;
		 * framebuffer in the middle of the PRAMIN BAR for
		goto out_unref;
		 * whatever reason.  We need to know the exact lfb_base
	}
		 * to get vesafb kicked off, and the only reliable way

		 * we have left is to find out lfb_base the same way
	aper->ranges[0].base = pci_resource_start(pdev, 1);
		 * vesafb did.
	aper->ranges[0].size = pci_resource_len(pdev, 1);
		 */
	aper->count = 1;
		info->aperture_base = screen_info.lfb_base;

		info->aperture_size = screen_info.lfb_size;
	if (pci_resource_len(pdev, 2)) {
		if (screen_info.orig_video_isVGA == VIDEO_TYPE_VLFB)
		aper->ranges[aper->count].base = pci_resource_start(pdev, 2);
			info->aperture_size *= 65536;
		aper->ranges[aper->count].size = pci_resource_len(pdev, 2);
	} else
		aper->count++;
#endif
	}
	{

		info->aperture_base = info->fix.mmio_start;
	if (pci_resource_len(pdev, 3)) {
		info->aperture_size = info->fix.mmio_len;
		aper->ranges[aper->count].base = pci_resource_start(pdev, 3);
		aper->ranges[aper->count].size = pci_resource_len(pdev, 3);
		aper->count++;
	}
	}


	info->pixmap.size = 64*1024;
	info->pixmap.size = 64*1024;
+7 −2
Original line number Original line Diff line number Diff line
@@ -236,8 +236,13 @@ static int radeonfb_create(struct radeon_fbdev *rfbdev,
	drm_fb_helper_fill_var(info, &rfbdev->helper, sizes->fb_width, sizes->fb_height);
	drm_fb_helper_fill_var(info, &rfbdev->helper, sizes->fb_width, sizes->fb_height);


	/* setup aperture base/size for vesafb takeover */
	/* setup aperture base/size for vesafb takeover */
	info->aperture_base = rdev->ddev->mode_config.fb_base;
	info->apertures = alloc_apertures(1);
	info->aperture_size = rdev->mc.real_vram_size;
	if (!info->apertures) {
		ret = -ENOMEM;
		goto out_unref;
	}
	info->apertures->ranges[0].base = rdev->ddev->mode_config.fb_base;
	info->apertures->ranges[0].size = rdev->mc.real_vram_size;


	info->fix.mmio_start = 0;
	info->fix.mmio_start = 0;
	info->fix.mmio_len = 0;
	info->fix.mmio_len = 0;
+8 −2
Original line number Original line Diff line number Diff line
@@ -559,8 +559,13 @@ int vmw_fb_init(struct vmw_private *vmw_priv)
	info->pixmap.scan_align = 1;
	info->pixmap.scan_align = 1;
#endif
#endif


	info->aperture_base = vmw_priv->vram_start;
	info->apertures = alloc_apertures(1);
	info->aperture_size = vmw_priv->vram_size;
	if (!info->apertures) {
		ret = -ENOMEM;
		goto err_aper;
	}
	info->apertures->ranges[0].base = vmw_priv->vram_start;
	info->apertures->ranges[0].size = vmw_priv->vram_size;


	/*
	/*
	 * Dirty & Deferred IO
	 * Dirty & Deferred IO
@@ -580,6 +585,7 @@ int vmw_fb_init(struct vmw_private *vmw_priv)


err_defio:
err_defio:
	fb_deferred_io_cleanup(info);
	fb_deferred_io_cleanup(info);
err_aper:
	ttm_bo_kunmap(&par->map);
	ttm_bo_kunmap(&par->map);
err_unref:
err_unref:
	ttm_bo_unref((struct ttm_buffer_object **)&par->vmw_bo);
	ttm_bo_unref((struct ttm_buffer_object **)&par->vmw_bo);
+8 −3
Original line number Original line Diff line number Diff line
@@ -165,7 +165,7 @@ static void efifb_destroy(struct fb_info *info)
{
{
	if (info->screen_base)
	if (info->screen_base)
		iounmap(info->screen_base);
		iounmap(info->screen_base);
	release_mem_region(info->aperture_base, info->aperture_size);
	release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size);
	framebuffer_release(info);
	framebuffer_release(info);
}
}


@@ -289,8 +289,13 @@ static int __devinit efifb_probe(struct platform_device *dev)
	info->pseudo_palette = info->par;
	info->pseudo_palette = info->par;
	info->par = NULL;
	info->par = NULL;


	info->aperture_base = efifb_fix.smem_start;
	info->apertures = alloc_apertures(1);
	info->aperture_size = size_remap;
	if (!info->apertures) {
		err = -ENOMEM;
		goto err_release_fb;
	}
	info->apertures->ranges[0].base = efifb_fix.smem_start;
	info->apertures->ranges[0].size = size_remap;


	info->screen_base = ioremap(efifb_fix.smem_start, efifb_fix.smem_len);
	info->screen_base = ioremap(efifb_fix.smem_start, efifb_fix.smem_len);
	if (!info->screen_base) {
	if (!info->screen_base) {
Loading