aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.4/950-0185-staging-mmal-vchiq-If-the-VPU-returns-an-error-don-t.patch
blob: 60550ede00afb052b838d8213d39fc28d5a3910e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
From 8bf13b2aedef0e0ef2250dd612f453e1a923a2d7 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.org>
Date: Wed, 13 Feb 2019 12:51:03 +0000
Subject: [PATCH] staging: mmal-vchiq: If the VPU returns an error,
 don't negate it

There is an enum for the errors that the VPU can return.
port_parameter_get was negating that value, but also using -EINVAL
from the Linux error codes.
Pass the VPU error code as positive values. Should the function
need to pass a Linux failure, then return that as negative.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
---
 drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
@@ -1400,7 +1400,8 @@ static int port_parameter_get(struct vch
 		goto release_msg;
 	}
 
-	ret = -rmsg->u.port_parameter_get_reply.status;
+	ret = rmsg->u.port_parameter_get_reply.status;
+
 	/* port_parameter_get_reply.size includes the header,
 	 * whilst *value_size doesn't.
 	 */
/ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
From 21dace2c687d45819cb0dfc4f32f005da82d9197 Mon Sep 17 00:00:00 2001
From: gtrainavicius <gtrainavicius@users.noreply.github.com>
Date: Tue, 28 Jan 2020 14:16:37 +0200
Subject: [PATCH] pisound: Added reading Pisound board hardware
 revision and exposing it (#3425)

pisound: Added reading Pisound board hardware revision and exposing it in kernel log and sysfs file:

/sys/kernel/pisound/hw_version

Signed-off-by: Giedrius <giedrius@blokas.io>
---
 sound/soc/bcm/pisound.c | 86 ++++++++++++++++++++++++++++-------------
 1 file changed, 59 insertions(+), 27 deletions(-)

--- a/sound/soc/bcm/pisound.c
+++ b/sound/soc/bcm/pisound.c
@@ -51,7 +51,8 @@ static void pisnd_spi_set_callback(pisnd
 
 static const char *pisnd_spi_get_serial(void);
 static const char *pisnd_spi_get_id(void);
-static const char *pisnd_spi_get_version(void);
+static const char *pisnd_spi_get_fw_version(void);
+static const char *pisnd_spi_get_hw_version(void);
 
 static int pisnd_midi_init(struct snd_card *card);
 static void pisnd_midi_uninit(void);
@@ -222,7 +223,9 @@ static pisnd_spi_recv_cb g_recvCallback;
 
 static char g_serial_num[11];
 static char g_id[25];
-static char g_version[5];
+enum { MAX_VERSION_STR_LEN = 6 };
+static char g_fw_version[MAX_VERSION_STR_LEN];
+static char g_hw_version[MAX_VERSION_STR_LEN];
 
 static uint8_t g_ledFlashDuration;
 static bool    g_ledFlashDurationChanged;
@@ -558,7 +561,8 @@ static int spi_read_info(void)
 	char *p;
 
 	memset(g_serial_num, 0, sizeof(g_serial_num));
-	memset(g_version, 0, sizeof(g_version));
+	memset(g_fw_version, 0, sizeof(g_fw_version));
+	strcpy(g_hw_version, "1.0"); // Assume 1.0 hw version.
 	memset(g_id, 0, sizeof(g_id));
 
 	tmp = spi_transfer16(0);
@@ -581,12 +585,28 @@ static int spi_read_info(void)
 				return -EINVAL;
 
 			snprintf(
-				g_version,
-				sizeof(g_version),
+				g_fw_version,
+				MAX_VERSION_STR_LEN,
 				"%x.%02x",
 				buffer[0],
 				buffer[1]
 				);
+
+			g_fw_version[MAX_VERSION_STR_LEN-1] = '\0';
+			break;
+		case 3:
+			if (n != 2)
+				return -EINVAL;
+
+			snprintf(
+				g_hw_version,
+				MAX_VERSION_STR_LEN,
+				"%x.%x",
+				buffer[0],
+				buffer[1]
+			);
+
+			g_hw_version[MAX_VERSION_STR_LEN-1] = '\0';
 			break;
 		case 1:
 			if (n >= sizeof(g_serial_num))
@@ -596,12 +616,14 @@ static int spi_read_info(void)
 			break;
 		case 2:
 			{
-				if (n >= sizeof(g_id))
+				if (n*2 >= sizeof(g_id))
 					return -EINVAL;
 
 				p = g_id;
 				for (j = 0; j < n; ++j)
 					p += sprintf(p, "%02x", buffer[j]);
+
+				*p = '\0';
 			}
 			break;
 		default:
@@ -619,7 +641,8 @@ static int pisnd_spi_init(struct device
 
 	memset(g_serial_num, 0, sizeof(g_serial_num));
 	memset(g_id, 0, sizeof(g_id));
-	memset(g_version, 0, sizeof(g_version));
+	memset(g_fw_version, 0, sizeof(g_fw_version));
+	memset(g_hw_version, 0, sizeof(g_hw_version));
 
 	spi = pisnd_spi_find_device();
 
@@ -729,26 +752,22 @@ static void pisnd_spi_set_callback(pisnd
 
 static const char *pisnd_spi_get_serial(void)
 {
-	if (strlen(g_serial_num))
-		return g_serial_num;
-
-	return "";
+	return g_serial_num;
 }
 
 static const char *pisnd_spi_get_id(void)
 {
-	if (strlen(g_id))
-		return g_id;
-
-	return "";
+	return g_id;
 }
 
-static const char *pisnd_spi_get_version(void)
+static const char *pisnd_spi_get_fw_version(void)
 {
-	if (strlen(g_version))
-		return g_version;
+	return g_fw_version;
+}
 
-	return "";
+static const char *pisnd_spi_get_hw_version(void)
+{
+	return g_hw_version;
 }
 
 static const struct of_device_id pisound_of_match[] = {
@@ -1056,13 +1075,22 @@ static ssize_t pisnd_id_show(
 	return sprintf(buf, "%s\n", pisnd_spi_get_id());
 }
 
-static ssize_t pisnd_version_show(
+static ssize_t pisnd_fw_version_show(
 	struct kobject *kobj,
 	struct kobj_attribute *attr,
 	char *buf
 	)
 {
-	return sprintf(buf, "%s\n", pisnd_spi_get_version());
+	return sprintf(buf, "%s\n", pisnd_spi_get_fw_version());
+}
+
+static ssize_t pisnd_hw_version_show(
+	struct kobject *kobj,
+	struct kobj_attribute *attr,
+	char *buf
+)
+{
+	return sprintf(buf, "%s\n", pisnd_spi_get_hw_version());
 }
 
 static ssize_t pisnd_led_store(
@@ -1087,15 +1115,18 @@ static struct kobj_attribute pisnd_seria
 	__ATTR(serial, 0444, pisnd_serial_show, NULL);
 static struct kobj_attribute pisnd_id_attribute =
 	__ATTR(id, 0444, pisnd_id_show, NULL);
-static struct kobj_attribute pisnd_version_attribute =
-	__ATTR(version, 0444, pisnd_version_show, NULL);
+static struct kobj_attribute pisnd_fw_version_attribute =
+	__ATTR(version, 0444, pisnd_fw_version_show, NULL);
+static struct kobj_attribute pisnd_hw_version_attribute =
+__ATTR(hw_version, 0444, pisnd_hw_version_show, NULL);
 static struct kobj_attribute pisnd_led_attribute =
 	__ATTR(led, 0644, NULL, pisnd_led_store);
 
 static struct attribute *attrs[] = {
 	&pisnd_serial_attribute.attr,
 	&pisnd_id_attribute.attr,
-	&pisnd_version_attribute.attr,
+	&pisnd_fw_version_attribute.attr,
+	&pisnd_hw_version_attribute.attr,
 	&pisnd_led_attribute.attr,
 	NULL
 };
@@ -1114,9 +1145,10 @@ static int pisnd_probe(struct platform_d
 	}
 
 	printi("Detected Pisound card:\n");
-	printi("\tSerial:  %s\n", pisnd_spi_get_serial());
-	printi("\tVersion: %s\n", pisnd_spi_get_version());
-	printi("\tId:      %s\n", pisnd_spi_get_id());
+	printi("\tSerial:           %s\n", pisnd_spi_get_serial());
+	printi("\tFirmware Version: %s\n", pisnd_spi_get_fw_version());
+	printi("\tHardware Version: %s\n", pisnd_spi_get_hw_version());
+	printi("\tId:               %s\n", pisnd_spi_get_id());
 
 	pisnd_kobj = kobject_create_and_add("pisound", kernel_kobj);
 	if (!pisnd_kobj) {