mirror of
				https://github.com/Ysurac/openmptcprouter.git
				synced 2025-03-09 15:40:20 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			166 lines
		
	
	
	
		
			5.3 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			166 lines
		
	
	
	
		
			5.3 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
From a4750f850182ab7dbe25d519b385e592e1d5b353 Mon Sep 17 00:00:00 2001
 | 
						|
From: Dave Stevenson <dave.stevenson@raspberrypi.org>
 | 
						|
Date: Wed, 19 Jun 2019 03:55:50 +0100
 | 
						|
Subject: [PATCH 685/692] video/bcm2708_fb: Revert cma allocation attempt
 | 
						|
 | 
						|
"4600e91 Pulled in the multi frame buffer support from the Pi3 repo"
 | 
						|
pulled back in the code for allocating the framebuffer from the CMA
 | 
						|
heap.
 | 
						|
Revert it again.
 | 
						|
 | 
						|
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
 | 
						|
---
 | 
						|
 drivers/video/fbdev/bcm2708_fb.c           | 101 +++------------------
 | 
						|
 include/soc/bcm2835/raspberrypi-firmware.h |   1 -
 | 
						|
 2 files changed, 13 insertions(+), 89 deletions(-)
 | 
						|
 | 
						|
diff --git a/drivers/video/fbdev/bcm2708_fb.c b/drivers/video/fbdev/bcm2708_fb.c
 | 
						|
index 540567fe21a8..2b7d5ebc7611 100644
 | 
						|
--- a/drivers/video/fbdev/bcm2708_fb.c
 | 
						|
+++ b/drivers/video/fbdev/bcm2708_fb.c
 | 
						|
@@ -112,9 +112,6 @@ struct bcm2708_fb {
 | 
						|
 	struct vc4_display_settings_t display_settings;
 | 
						|
 	struct debugfs_regset32 screeninfo_regset;
 | 
						|
 	struct bcm2708_fb_dev *fbdev;
 | 
						|
-	unsigned int image_size;
 | 
						|
-	dma_addr_t dma_addr;
 | 
						|
-	void *cpuaddr;
 | 
						|
 };
 | 
						|
 
 | 
						|
 #define MAX_FRAMEBUFFERS 3
 | 
						|
@@ -377,12 +374,12 @@ static int bcm2708_fb_set_par(struct fb_info *info)
 | 
						|
 			.xoffset = info->var.xoffset,
 | 
						|
 			.yoffset = info->var.yoffset,
 | 
						|
 		.tag5 = { RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE, 8, 0 },
 | 
						|
-			/* base and screen_size will be initialised later */
 | 
						|
-		.tag6 = { RPI_FIRMWARE_FRAMEBUFFER_SET_PITCH, 4, 0 },
 | 
						|
-			/* pitch will be initialised later */
 | 
						|
+			.base = 0,
 | 
						|
+			.screen_size = 0,
 | 
						|
+		.tag6 = { RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH, 4, 0 },
 | 
						|
+			.pitch = 0,
 | 
						|
 	};
 | 
						|
-	int ret, image_size;
 | 
						|
-
 | 
						|
+	int ret;
 | 
						|
 
 | 
						|
 	print_debug("%s(%p) %dx%d (%dx%d), %d, %d (display %d)\n", __func__,
 | 
						|
 		    info,
 | 
						|
@@ -397,76 +394,12 @@ static int bcm2708_fb_set_par(struct fb_info *info)
 | 
						|
 	 */
 | 
						|
 	set_display_num(fb);
 | 
						|
 
 | 
						|
-	/* Try allocating our own buffer. We can specify all the parameters */
 | 
						|
-	image_size = ((info->var.xres * info->var.yres) *
 | 
						|
-		      info->var.bits_per_pixel) >> 3;
 | 
						|
-
 | 
						|
-	if (!fb->fbdev->disable_arm_alloc &&
 | 
						|
-	    (image_size != fb->image_size || !fb->dma_addr)) {
 | 
						|
-		if (fb->dma_addr) {
 | 
						|
-			dma_free_coherent(info->device, fb->image_size,
 | 
						|
-					  fb->cpuaddr, fb->dma_addr);
 | 
						|
-			fb->image_size = 0;
 | 
						|
-			fb->cpuaddr = NULL;
 | 
						|
-			fb->dma_addr = 0;
 | 
						|
-		}
 | 
						|
-
 | 
						|
-		fb->cpuaddr = dma_alloc_coherent(info->device, image_size,
 | 
						|
-						 &fb->dma_addr, GFP_KERNEL);
 | 
						|
-
 | 
						|
-		if (!fb->cpuaddr) {
 | 
						|
-			fb->dma_addr = 0;
 | 
						|
-			fb->fbdev->disable_arm_alloc = true;
 | 
						|
-		} else {
 | 
						|
-			fb->image_size = image_size;
 | 
						|
-		}
 | 
						|
-	}
 | 
						|
-
 | 
						|
-	if (fb->cpuaddr) {
 | 
						|
-		fbinfo.base = fb->dma_addr;
 | 
						|
-		fbinfo.screen_size = image_size;
 | 
						|
-		fbinfo.pitch = (info->var.xres * info->var.bits_per_pixel) >> 3;
 | 
						|
-
 | 
						|
-		ret = rpi_firmware_property_list(fb->fbdev->fw, &fbinfo,
 | 
						|
-						 sizeof(fbinfo));
 | 
						|
-		if (ret || fbinfo.base != fb->dma_addr) {
 | 
						|
-			/* Firmware either failed, or assigned a different base
 | 
						|
-			 * address (ie it doesn't support being passed an FB
 | 
						|
-			 * allocation).
 | 
						|
-			 * Destroy the allocation, and don't try again.
 | 
						|
-			 */
 | 
						|
-			dma_free_coherent(info->device, fb->image_size,
 | 
						|
-					  fb->cpuaddr, fb->dma_addr);
 | 
						|
-			fb->image_size = 0;
 | 
						|
-			fb->cpuaddr = NULL;
 | 
						|
-			fb->dma_addr = 0;
 | 
						|
-			fb->fbdev->disable_arm_alloc = true;
 | 
						|
-		}
 | 
						|
-	} else {
 | 
						|
-		/* Our allocation failed - drop into the old scheme of
 | 
						|
-		 * allocation by the VPU.
 | 
						|
-		 */
 | 
						|
-		ret = -ENOMEM;
 | 
						|
-	}
 | 
						|
-
 | 
						|
+	ret = rpi_firmware_property_list(fb->fbdev->fw, &fbinfo,
 | 
						|
+					 sizeof(fbinfo));
 | 
						|
 	if (ret) {
 | 
						|
-		/* Old scheme:
 | 
						|
-		 * - FRAMEBUFFER_ALLOCATE passes 0 for base and screen_size.
 | 
						|
-		 * - GET_PITCH instead of SET_PITCH.
 | 
						|
-		 */
 | 
						|
-		fbinfo.base = 0;
 | 
						|
-		fbinfo.screen_size = 0;
 | 
						|
-		fbinfo.tag6.tag = RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH;
 | 
						|
-		fbinfo.pitch = 0;
 | 
						|
-
 | 
						|
-		ret = rpi_firmware_property_list(fb->fbdev->fw, &fbinfo,
 | 
						|
-						 sizeof(fbinfo));
 | 
						|
-		if (ret) {
 | 
						|
-			dev_err(info->device,
 | 
						|
-				"Failed to allocate GPU framebuffer (%d)\n",
 | 
						|
-				ret);
 | 
						|
-			return ret;
 | 
						|
-		}
 | 
						|
+		dev_err(info->device,
 | 
						|
+			"Failed to allocate GPU framebuffer (%d)\n", ret);
 | 
						|
+		return ret;
 | 
						|
 	}
 | 
						|
 
 | 
						|
 	if (info->var.bits_per_pixel <= 8)
 | 
						|
@@ -481,17 +414,9 @@ static int bcm2708_fb_set_par(struct fb_info *info)
 | 
						|
 	fb->fb.fix.smem_start = fbinfo.base;
 | 
						|
 	fb->fb.fix.smem_len = fbinfo.pitch * fbinfo.yres_virtual;
 | 
						|
 	fb->fb.screen_size = fbinfo.screen_size;
 | 
						|
-
 | 
						|
-	if (!fb->dma_addr) {
 | 
						|
-		if (fb->fb.screen_base)
 | 
						|
-			iounmap(fb->fb.screen_base);
 | 
						|
-
 | 
						|
-		fb->fb.screen_base = ioremap_wc(fbinfo.base,
 | 
						|
-						fb->fb.screen_size);
 | 
						|
-	} else {
 | 
						|
-		fb->fb.screen_base = fb->cpuaddr;
 | 
						|
-	}
 | 
						|
-
 | 
						|
+	if (fb->fb.screen_base)
 | 
						|
+		iounmap(fb->fb.screen_base);
 | 
						|
+	fb->fb.screen_base = ioremap_wc(fbinfo.base, fb->fb.screen_size);
 | 
						|
 	if (!fb->fb.screen_base) {
 | 
						|
 		/* the console may currently be locked */
 | 
						|
 		console_trylock();
 | 
						|
diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm2835/raspberrypi-firmware.h
 | 
						|
index 10252aa519d3..1ef454bd48b1 100644
 | 
						|
--- a/include/soc/bcm2835/raspberrypi-firmware.h
 | 
						|
+++ b/include/soc/bcm2835/raspberrypi-firmware.h
 | 
						|
@@ -138,7 +138,6 @@ enum rpi_firmware_property_tag {
 | 
						|
 	RPI_FIRMWARE_FRAMEBUFFER_SET_DEPTH =                  0x00048005,
 | 
						|
 	RPI_FIRMWARE_FRAMEBUFFER_SET_PIXEL_ORDER =            0x00048006,
 | 
						|
 	RPI_FIRMWARE_FRAMEBUFFER_SET_ALPHA_MODE =             0x00048007,
 | 
						|
-	RPI_FIRMWARE_FRAMEBUFFER_SET_PITCH =                  0x00048008,
 | 
						|
 	RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_OFFSET =         0x00048009,
 | 
						|
 	RPI_FIRMWARE_FRAMEBUFFER_SET_OVERSCAN =               0x0004800a,
 | 
						|
 	RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE =                0x0004800b,
 | 
						|
-- 
 | 
						|
2.19.1
 | 
						|
 |