1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter.git synced 2025-03-09 15:40:20 +00:00

Try to support RPI4

This commit is contained in:
Ycarus (Yannick Chabanois) 2019-07-04 20:51:23 +02:00
parent d005750a48
commit fb31f0fe9a
16 changed files with 2920 additions and 118 deletions

View file

@ -0,0 +1,49 @@
From 211785e0ac722faad9af7a8d2d95f5cd34d3dda2 Mon Sep 17 00:00:00 2001
From: Mariusz Bialonczyk <manio@skyboo.net>
Date: Sat, 25 May 2019 10:45:38 +0200
Subject: [PATCH 679/692] w1: ds2805: rename w1_family struct, fixing c-p typo
commit 0e3743d870711ae4daf1e7170c8d9381564e244d upstream.
The ds2805 has a structure named: w1_family_2d, which surely
comes from a w1_ds2431 module. This commit fixes this name to
prevent confusion and mark a correct family name.
Signed-off-by: Mariusz Bialonczyk <manio@skyboo.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/w1/slaves/w1_ds2805.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/w1/slaves/w1_ds2805.c b/drivers/w1/slaves/w1_ds2805.c
index 29348d283a65..ab349604531a 100644
--- a/drivers/w1/slaves/w1_ds2805.c
+++ b/drivers/w1/slaves/w1_ds2805.c
@@ -288,7 +288,7 @@ static struct w1_family_ops w1_f0d_fops = {
.remove_slave = w1_f0d_remove_slave,
};
-static struct w1_family w1_family_2d = {
+static struct w1_family w1_family_0d = {
.fid = W1_EEPROM_DS2805,
.fops = &w1_f0d_fops,
};
@@ -296,13 +296,13 @@ static struct w1_family w1_family_2d = {
static int __init w1_f0d_init(void)
{
pr_info("%s()\n", __func__);
- return w1_register_family(&w1_family_2d);
+ return w1_register_family(&w1_family_0d);
}
static void __exit w1_f0d_fini(void)
{
pr_info("%s()\n", __func__);
- w1_unregister_family(&w1_family_2d);
+ w1_unregister_family(&w1_family_0d);
}
module_init(w1_f0d_init);
--
2.19.1

View file

@ -0,0 +1,69 @@
From 73493781df0ef080465193443dcd77acd08c235b Mon Sep 17 00:00:00 2001
From: Mariusz Bialonczyk <manio@skyboo.net>
Date: Mon, 20 May 2019 09:05:55 +0200
Subject: [PATCH 680/692] w1: ds2413: output_write() cosmetic fixes / simplify
commit ae2ee27aa985232f66421d7cd1c7f4b87c7dba7d upstream.
Make the output_write simpler.
Based on Jean-Francois Dagenais code from:
49695ac46861 ("w1: ds2408: reset on output_write retry with readback")
Signed-off-by: Mariusz Bialonczyk <manio@skyboo.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/w1/slaves/w1_ds2413.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/w1/slaves/w1_ds2413.c b/drivers/w1/slaves/w1_ds2413.c
index 492e3d010321..cd3763df69ac 100644
--- a/drivers/w1/slaves/w1_ds2413.c
+++ b/drivers/w1/slaves/w1_ds2413.c
@@ -69,6 +69,7 @@ static ssize_t output_write(struct file *filp, struct kobject *kobj,
struct w1_slave *sl = kobj_to_w1_slave(kobj);
u8 w1_buf[3];
unsigned int retries = W1_F3A_RETRIES;
+ ssize_t bytes_written = -EIO;
if (count != 1 || off != 0)
return -EFAULT;
@@ -78,7 +79,7 @@ static ssize_t output_write(struct file *filp, struct kobject *kobj,
dev_dbg(&sl->dev, "mutex locked");
if (w1_reset_select_slave(sl))
- goto error;
+ goto out;
/* according to the DS2413 datasheet the most significant 6 bits
should be set to "1"s, so do it now */
@@ -91,18 +92,20 @@ static ssize_t output_write(struct file *filp, struct kobject *kobj,
w1_write_block(sl->master, w1_buf, 3);
if (w1_read_8(sl->master) == W1_F3A_SUCCESS_CONFIRM_BYTE) {
- mutex_unlock(&sl->master->bus_mutex);
- dev_dbg(&sl->dev, "mutex unlocked, retries:%d", retries);
- return 1;
+ bytes_written = 1;
+ goto out;
}
if (w1_reset_resume_command(sl->master))
- goto error;
+ goto out; /* unrecoverable error */
+
+ dev_warn(&sl->dev, "PIO_ACCESS_WRITE error, retries left: %d\n", retries);
}
-error:
+out:
mutex_unlock(&sl->master->bus_mutex);
- dev_dbg(&sl->dev, "mutex unlocked in error, retries:%d", retries);
- return -EIO;
+ dev_dbg(&sl->dev, "%s, mutex unlocked, retries: %d\n",
+ (bytes_written > 0) ? "succeeded" : "error", retries);
+ return bytes_written;
}
static BIN_ATTR(output, S_IRUGO | S_IWUSR | S_IWGRP, NULL, output_write, 1);
--
2.19.1

View file

@ -0,0 +1,79 @@
From 55a3cf636741690dd12b9c57512a09ae999b5fc1 Mon Sep 17 00:00:00 2001
From: Mariusz Bialonczyk <manio@skyboo.net>
Date: Mon, 20 May 2019 09:05:56 +0200
Subject: [PATCH 681/692] w1: ds2413: add retry support to state_read()
commit c50d09a86172073f55ebac0b92ad5a75907d64e7 upstream.
The state_read() was calling PIO_ACCESS_READ once and bail out if it
failed for this first time.
This commit is improving this to trying more times before it give up,
similarly as the write call is currently doing.
Signed-off-by: Mariusz Bialonczyk <manio@skyboo.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/w1/slaves/w1_ds2413.c | 37 +++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/drivers/w1/slaves/w1_ds2413.c b/drivers/w1/slaves/w1_ds2413.c
index cd3763df69ac..d63778c70568 100644
--- a/drivers/w1/slaves/w1_ds2413.c
+++ b/drivers/w1/slaves/w1_ds2413.c
@@ -30,6 +30,9 @@ static ssize_t state_read(struct file *filp, struct kobject *kobj,
size_t count)
{
struct w1_slave *sl = kobj_to_w1_slave(kobj);
+ unsigned int retries = W1_F3A_RETRIES;
+ ssize_t bytes_read = -EIO;
+
dev_dbg(&sl->dev,
"Reading %s kobj: %p, off: %0#10x, count: %zu, buff addr: %p",
bin_attr->attr.name, kobj, (unsigned int)off, count, buf);
@@ -42,22 +45,30 @@ static ssize_t state_read(struct file *filp, struct kobject *kobj,
mutex_lock(&sl->master->bus_mutex);
dev_dbg(&sl->dev, "mutex locked");
- if (w1_reset_select_slave(sl)) {
- mutex_unlock(&sl->master->bus_mutex);
- return -EIO;
- }
+ if (w1_reset_select_slave(sl))
+ goto out;
- w1_write_8(sl->master, W1_F3A_FUNC_PIO_ACCESS_READ);
- *buf = w1_read_8(sl->master);
+ while (retries--) {
+ w1_write_8(sl->master, W1_F3A_FUNC_PIO_ACCESS_READ);
- mutex_unlock(&sl->master->bus_mutex);
- dev_dbg(&sl->dev, "mutex unlocked");
+ *buf = w1_read_8(sl->master);
+ /* check for correct complement */
+ if ((*buf & 0x0F) == ((~*buf >> 4) & 0x0F)) {
+ bytes_read = 1;
+ goto out;
+ }
- /* check for correct complement */
- if ((*buf & 0x0F) != ((~*buf >> 4) & 0x0F))
- return -EIO;
- else
- return 1;
+ if (w1_reset_resume_command(sl->master))
+ goto out; /* unrecoverable error */
+
+ dev_warn(&sl->dev, "PIO_ACCESS_READ error, retries left: %d\n", retries);
+ }
+
+out:
+ mutex_unlock(&sl->master->bus_mutex);
+ dev_dbg(&sl->dev, "%s, mutex unlocked, retries: %d\n",
+ (bytes_read > 0) ? "succeeded" : "error", retries);
+ return bytes_read;
}
static BIN_ATTR_RO(state, 1);
--
2.19.1

View file

@ -0,0 +1,61 @@
From eb7c93f1db6a1e2b83d197afe79ed35ed406e953 Mon Sep 17 00:00:00 2001
From: Mariusz Bialonczyk <manio@skyboo.net>
Date: Wed, 22 May 2019 12:40:53 +0200
Subject: [PATCH 682/692] w1: ds2413: when the slave is not responding during
read, select it again
commit 3856032a0628e6b94badb9131a706dda185e071d upstream.
The protocol is not allowing to obtain a byte of 0xff for PIO_ACCESS_READ
call. It is very likely that the slave was not addressed properly and
it is just not respoding (leaving the bus in logic high state) during
the read of sampled PIO value.
We cannot just call w1_reset_resume_command() because the problem will
persist, instead try selecting (addressing) the slave again.
Signed-off-by: Mariusz Bialonczyk <manio@skyboo.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/w1/slaves/w1_ds2413.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/w1/slaves/w1_ds2413.c b/drivers/w1/slaves/w1_ds2413.c
index d63778c70568..21f08ac8a4e0 100644
--- a/drivers/w1/slaves/w1_ds2413.c
+++ b/drivers/w1/slaves/w1_ds2413.c
@@ -24,6 +24,7 @@
#define W1_F3A_FUNC_PIO_ACCESS_READ 0xF5
#define W1_F3A_FUNC_PIO_ACCESS_WRITE 0x5A
#define W1_F3A_SUCCESS_CONFIRM_BYTE 0xAA
+#define W1_F3A_INVALID_PIO_STATE 0xFF
static ssize_t state_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, char *buf, loff_t off,
@@ -45,6 +46,7 @@ static ssize_t state_read(struct file *filp, struct kobject *kobj,
mutex_lock(&sl->master->bus_mutex);
dev_dbg(&sl->dev, "mutex locked");
+next:
if (w1_reset_select_slave(sl))
goto out;
@@ -52,10 +54,15 @@ static ssize_t state_read(struct file *filp, struct kobject *kobj,
w1_write_8(sl->master, W1_F3A_FUNC_PIO_ACCESS_READ);
*buf = w1_read_8(sl->master);
- /* check for correct complement */
if ((*buf & 0x0F) == ((~*buf >> 4) & 0x0F)) {
+ /* complement is correct */
bytes_read = 1;
goto out;
+ } else if (*buf == W1_F3A_INVALID_PIO_STATE) {
+ /* slave didn't respond, try to select it again */
+ dev_warn(&sl->dev, "slave device did not respond to PIO_ACCESS_READ, " \
+ "reselecting, retries left: %d\n", retries);
+ goto next;
}
if (w1_reset_resume_command(sl->master))
--
2.19.1

View file

@ -0,0 +1,53 @@
From 9590e9aa6b1bc7a5946d6dae8c217bbde806133c Mon Sep 17 00:00:00 2001
From: Mariusz Bialonczyk <manio@skyboo.net>
Date: Thu, 30 May 2019 09:51:25 +0200
Subject: [PATCH 683/692] w1: ds2413: fix state byte comparision
commit aacd152ecd7b18af5d2d96dea9e7284c1c93abea upstream.
This commit is fixing a smatch warning:
drivers/w1/slaves/w1_ds2413.c:61 state_read() warn: impossible condition '(*buf == 255) => ((-128)-127 == 255)'
by creating additional u8 variable for the bus reading and comparision
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 3856032a0628 ("w1: ds2413: when the slave is not responding during read, select it again")
Signed-off-by: Mariusz Bialonczyk <manio@skyboo.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/w1/slaves/w1_ds2413.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/w1/slaves/w1_ds2413.c b/drivers/w1/slaves/w1_ds2413.c
index 21f08ac8a4e0..3364ad276b15 100644
--- a/drivers/w1/slaves/w1_ds2413.c
+++ b/drivers/w1/slaves/w1_ds2413.c
@@ -33,6 +33,7 @@ static ssize_t state_read(struct file *filp, struct kobject *kobj,
struct w1_slave *sl = kobj_to_w1_slave(kobj);
unsigned int retries = W1_F3A_RETRIES;
ssize_t bytes_read = -EIO;
+ u8 state;
dev_dbg(&sl->dev,
"Reading %s kobj: %p, off: %0#10x, count: %zu, buff addr: %p",
@@ -53,12 +54,13 @@ static ssize_t state_read(struct file *filp, struct kobject *kobj,
while (retries--) {
w1_write_8(sl->master, W1_F3A_FUNC_PIO_ACCESS_READ);
- *buf = w1_read_8(sl->master);
- if ((*buf & 0x0F) == ((~*buf >> 4) & 0x0F)) {
+ state = w1_read_8(sl->master);
+ if ((state & 0x0F) == ((~state >> 4) & 0x0F)) {
/* complement is correct */
+ *buf = state;
bytes_read = 1;
goto out;
- } else if (*buf == W1_F3A_INVALID_PIO_STATE) {
+ } else if (state == W1_F3A_INVALID_PIO_STATE) {
/* slave didn't respond, try to select it again */
dev_warn(&sl->dev, "slave device did not respond to PIO_ACCESS_READ, " \
"reselecting, retries left: %d\n", retries);
--
2.19.1

View file

@ -0,0 +1,140 @@
From eb0360356344d8ba633e61936c794aa46a02397f Mon Sep 17 00:00:00 2001
From: Chris Miller <chris@mesl2.co.uk>
Date: Wed, 26 Jun 2019 10:40:30 +0100
Subject: [PATCH 684/692] drm: vc4_dsi: Fix DMA channel and memory leak in vc4
(#3012)
Signed-off-by: Chris G Miller <chris@creative-electronics.net>
---
drivers/gpu/drm/vc4/vc4_dsi.c | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
index 0c607eb33d7e..e79c436226e0 100644
--- a/drivers/gpu/drm/vc4/vc4_dsi.c
+++ b/drivers/gpu/drm/vc4/vc4_dsi.c
@@ -1536,9 +1536,11 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
/* DSI1 has a broken AXI slave that doesn't respond to writes
* from the ARM. It does handle writes from the DMA engine,
* so set up a channel for talking to it.
+ * Where possible managed resource providers are used, but the DMA channel
+ * must - if acquired - be explicitly released prior to taking an error exit path.
*/
if (dsi->port == 1) {
- dsi->reg_dma_mem = dma_alloc_coherent(dev, 4,
+ dsi->reg_dma_mem = dmam_alloc_coherent(dev, 4,
&dsi->reg_dma_paddr,
GFP_KERNEL);
if (!dsi->reg_dma_mem) {
@@ -1557,6 +1559,8 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
return ret;
}
+ /* From here on, any error exits must release the dma channel */
+
/* Get the physical address of the device's registers. The
* struct resource for the regs gives us the bus address
* instead.
@@ -1583,7 +1587,7 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
if (ret) {
if (ret != -EPROBE_DEFER)
dev_err(dev, "Failed to get interrupt: %d\n", ret);
- return ret;
+ goto rel_dma_exit;
}
dsi->escape_clock = devm_clk_get(dev, "escape");
@@ -1591,7 +1595,7 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
ret = PTR_ERR(dsi->escape_clock);
if (ret != -EPROBE_DEFER)
dev_err(dev, "Failed to get escape clock: %d\n", ret);
- return ret;
+ goto rel_dma_exit;
}
dsi->pll_phy_clock = devm_clk_get(dev, "phy");
@@ -1599,7 +1603,7 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
ret = PTR_ERR(dsi->pll_phy_clock);
if (ret != -EPROBE_DEFER)
dev_err(dev, "Failed to get phy clock: %d\n", ret);
- return ret;
+ goto rel_dma_exit;
}
dsi->pixel_clock = devm_clk_get(dev, "pixel");
@@ -1607,7 +1611,7 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
ret = PTR_ERR(dsi->pixel_clock);
if (ret != -EPROBE_DEFER)
dev_err(dev, "Failed to get pixel clock: %d\n", ret);
- return ret;
+ goto rel_dma_exit;
}
ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
@@ -1622,26 +1626,28 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
if (ret == -ENODEV)
return 0;
- return ret;
+ goto rel_dma_exit;
}
if (panel) {
dsi->bridge = devm_drm_panel_bridge_add(dev, panel,
DRM_MODE_CONNECTOR_DSI);
- if (IS_ERR(dsi->bridge))
- return PTR_ERR(dsi->bridge);
+ if (IS_ERR(dsi->bridge)){
+ ret = PTR_ERR(dsi->bridge);
+ goto rel_dma_exit;
+ }
}
/* The esc clock rate is supposed to always be 100Mhz. */
ret = clk_set_rate(dsi->escape_clock, 100 * 1000000);
if (ret) {
dev_err(dev, "Failed to set esc clock: %d\n", ret);
- return ret;
+ goto rel_dma_exit;
}
ret = vc4_dsi_init_phy_clocks(dsi);
if (ret)
- return ret;
+ goto rel_dma_exit;
if (dsi->port == 1)
vc4->dsi1 = dsi;
@@ -1653,7 +1659,7 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
ret = drm_bridge_attach(dsi->encoder, dsi->bridge, NULL);
if (ret) {
dev_err(dev, "bridge attach failed: %d\n", ret);
- return ret;
+ goto rel_dma_exit;
}
/* Disable the atomic helper calls into the bridge. We
* manually call the bridge pre_enable / enable / etc. calls
@@ -1665,6 +1671,11 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
pm_runtime_enable(dev);
return 0;
+
+rel_dma_exit:
+ dma_release_channel(dsi->reg_dma_chan);
+
+ return ret;
}
static void vc4_dsi_unbind(struct device *dev, struct device *master,
@@ -1679,6 +1690,8 @@ static void vc4_dsi_unbind(struct device *dev, struct device *master,
vc4_dsi_encoder_destroy(dsi->encoder);
+ dma_release_channel(dsi->reg_dma_chan);
+
if (dsi->port == 1)
vc4->dsi1 = NULL;
}
--
2.19.1

View file

@ -0,0 +1,166 @@
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

View file

@ -0,0 +1,117 @@
From 56a097ef7a765fb35d50ff9a4fcd305fb6f6c5e0 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.org>
Date: Mon, 24 Jun 2019 02:29:40 +0100
Subject: [PATCH 686/692] drm/vc4: Add support for color encoding on YUV planes
Adds signalling for BT601/709/2020, and limited/full range
(on BT601).
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
---
drivers/gpu/drm/vc4/vc4_firmware_kms.c | 32 +++++++++++++++++++++++++-
drivers/gpu/drm/vc4/vc_image_types.h | 28 ++++++++++++++++++++++
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vc4/vc4_firmware_kms.c b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
index b5959abecf1a..074766fc076e 100644
--- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
@@ -66,7 +66,7 @@ struct set_plane {
u8 alpha;
u8 num_planes;
u8 is_vu;
- u8 padding;
+ u8 color_encoding;
u32 planes[4]; /* DMA address of each plane */
@@ -454,6 +454,28 @@ static void vc4_plane_atomic_update(struct drm_plane *plane,
if (num_planes == 3 &&
(fb->offsets[2] - fb->offsets[1]) == fb->pitches[1])
mb->plane.vc_image_type = VC_IMAGE_YUV420_S;
+
+ switch (state->color_encoding) {
+ default:
+ case DRM_COLOR_YCBCR_BT601:
+ if (state->color_range == DRM_COLOR_YCBCR_LIMITED_RANGE)
+ mb->plane.color_encoding =
+ VC_IMAGE_YUVINFO_CSC_ITUR_BT601;
+ else
+ mb->plane.color_encoding =
+ VC_IMAGE_YUVINFO_CSC_JPEG_JFIF;
+ break;
+ case DRM_COLOR_YCBCR_BT709:
+ /* Currently no support for a full range BT709 */
+ mb->plane.color_encoding =
+ VC_IMAGE_YUVINFO_CSC_ITUR_BT709;
+ break;
+ case DRM_COLOR_YCBCR_BT2020:
+ /* Currently no support for a full range BT2020 */
+ mb->plane.color_encoding =
+ VC_IMAGE_YUVINFO_CSC_REC_2020;
+ break;
+ }
} else {
mb->plane.planes[1] = 0;
mb->plane.planes[2] = 0;
@@ -643,6 +665,14 @@ static struct drm_plane *vc4_fkms_plane_init(struct drm_device *dev,
drm_plane_create_alpha_property(plane);
drm_plane_create_rotation_property(plane, DRM_MODE_ROTATE_0,
SUPPORTED_ROTATIONS);
+ drm_plane_create_color_properties(plane,
+ BIT(DRM_COLOR_YCBCR_BT601) |
+ BIT(DRM_COLOR_YCBCR_BT709) |
+ BIT(DRM_COLOR_YCBCR_BT2020),
+ BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
+ BIT(DRM_COLOR_YCBCR_FULL_RANGE),
+ DRM_COLOR_YCBCR_BT709,
+ DRM_COLOR_YCBCR_LIMITED_RANGE);
/*
* Default frame buffer setup is with FB on -127, and raspistill etc
diff --git a/drivers/gpu/drm/vc4/vc_image_types.h b/drivers/gpu/drm/vc4/vc_image_types.h
index 669a70fdb891..0bdffe5dd1e9 100644
--- a/drivers/gpu/drm/vc4/vc_image_types.h
+++ b/drivers/gpu/drm/vc4/vc_image_types.h
@@ -4,6 +4,8 @@
*
* Values taken from vc_image_types.h released by Broadcom at
* https://github.com/raspberrypi/userland/blob/master/interface/vctypes/vc_image_types.h
+ * and vc_image_structs.h at
+ * https://github.com/raspberrypi/userland/blob/master/interface/vctypes/vc_image_structs.h
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -141,3 +143,29 @@ enum {
VC_IMAGE_MAX, /* bounds for error checking */
VC_IMAGE_FORCE_ENUM_16BIT = 0xffff,
};
+
+enum {
+ /* Unknown or unset - defaults to BT601 interstitial */
+ VC_IMAGE_YUVINFO_UNSPECIFIED = 0,
+
+ /* colour-space conversions data [4 bits] */
+
+ /* ITU-R BT.601-5 [SDTV] (compatible with VideoCore-II) */
+ VC_IMAGE_YUVINFO_CSC_ITUR_BT601 = 1,
+ /* ITU-R BT.709-3 [HDTV] */
+ VC_IMAGE_YUVINFO_CSC_ITUR_BT709 = 2,
+ /* JPEG JFIF */
+ VC_IMAGE_YUVINFO_CSC_JPEG_JFIF = 3,
+ /* Title 47 Code of Federal Regulations (2003) 73.682 (a) (20) */
+ VC_IMAGE_YUVINFO_CSC_FCC = 4,
+ /* Society of Motion Picture and Television Engineers 240M (1999) */
+ VC_IMAGE_YUVINFO_CSC_SMPTE_240M = 5,
+ /* ITU-R BT.470-2 System M */
+ VC_IMAGE_YUVINFO_CSC_ITUR_BT470_2_M = 6,
+ /* ITU-R BT.470-2 System B,G */
+ VC_IMAGE_YUVINFO_CSC_ITUR_BT470_2_BG = 7,
+ /* JPEG JFIF, but with 16..255 luma */
+ VC_IMAGE_YUVINFO_CSC_JPEG_JFIF_Y16_255 = 8,
+ /* Rec 2020 */
+ VC_IMAGE_YUVINFO_CSC_REC_2020 = 9,
+};
--
2.19.1

View file

@ -0,0 +1,33 @@
From dbb5d678f6a7c50d4026facf98b46c36555da084 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.org>
Date: Tue, 2 Jul 2019 17:13:05 +0100
Subject: [PATCH 689/692] arm: dts: Add coherent_pool=1M to Pi 4 bootargs
Downstream Raspberry Pi dts files add "coherent_pool=1M" to the kernel
command line to aid the dwc_otg driver, but this excluded Pi 4 which
uses a new XCHI interface instead. UAS also benefits from a larger
coherent_pool value, so replicate the addition in bcm2711-rpi-4-b.dts.
See: https://github.com/raspberrypi/linux/pull/3040
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
---
arch/arm/boot/dts/bcm2711-rpi-4-b.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
index 5addb6130fa7..9b5c4f8a4d17 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
@@ -14,7 +14,7 @@
};
chosen {
- bootargs = "8250.nr_uarts=1 cma=64M";
+ bootargs = "coherent_pool=1M 8250.nr_uarts=1 cma=64M";
};
aliases {
--
2.19.1