Compare commits

..
Author SHA1 Message Date
Sicelo A. Mhlongo 8d63f5f14f linux-postmarketos-omap: test some bq* improvements
- bq27xxx - add VOLTAGE_MIN_DESIGN property
- bq27xxx - do not report bogus capacity values
- bq2415x - report events to userspace
2024-09-30 21:51:56 +02:00
6 changed files with 195 additions and 54 deletions

No files matched your search

@@ -4,7 +4,7 @@
pkgname=linux-postmarketos-omap
pkgver=6.10.6
pkgrel=1
pkgrel=2
pkgdesc="Mainline kernel fork for OMAP devices"
arch="armv7"
url="https://kernel.org/"
@@ -41,6 +41,9 @@ source="
0007-hsi-ssi_port-force-pio-path.patch
0008-n900-dts-volume-keys.patch
0009-ARM-dts-disable-twl-off-idle-configuration-for-N900.patch
bq27k-ENODATA-2.patch
bq27k-VOLTAGE_MIN.patch
bq24-CHANGED.patch
"
builddir="$srcdir/linux-$_kernver"
replaces="linux-samsung-espresso3g linux-nokia-n900"
@@ -81,4 +84,7 @@ f7d1a87088c65278a114125e732d5bebebb560a6245afb34e003083d808ef3f8c5f49ff231319535
c3af9715b3559c2d593f4fcfa078730722c7deeec132c5b83e085ff4d9815d85ef349384097c580efe1bbc37c60f42e18ef559f0abccfe236080670e4403fa77 0007-hsi-ssi_port-force-pio-path.patch
b98ce806b3d5a0122086e4c9670639174470ff6d29851c60258cc5d699ce9a479dbf4996b24299fc075d25e9fe8f6b1250fafdff742deea0ddeaf53d342a9d72 0008-n900-dts-volume-keys.patch
66abb5548910ad369608b08200f5835d5a8526c04cc3617221ef546f3e3d22cd944db91dc6727a5c26a102b24d8ef1306ea01254c9c382759afced91b31747ef 0009-ARM-dts-disable-twl-off-idle-configuration-for-N900.patch
9cba2e6b88e650a06576fd4f3f99ad0334e4938e970e1198eba78195280ec5f5315d8883960f062daee06e71cdcef3ff003de661c8b2afa0500695c2419d8808 bq27k-ENODATA-2.patch
0014534b6a43c3f79900bd29662de515b5a9407f7b4ca8493a96a34fa9167cca3e89cf76517dbd85770c0f43a86c7399bf6e0c07d54f4889288ccb2570348bbe bq27k-VOLTAGE_MIN.patch
b5e0ffad98155507c9be56a36190cb3959505909e3f41322a51d2caff9a1ae5d8311e395bdbdbdad66eaf4868e8c12201dd8a91f4d0fe96f3734d78b1a8b80c1 bq24-CHANGED.patch
"
@@ -0,0 +1,13 @@
diff --git a/drivers/power/supply/bq2415x_charger.c b/drivers/power/supply/bq2415x_charger.c
index 25e28dac900d..a9dc9b0abc03 100644
--- a/drivers/power/supply/bq2415x_charger.c
+++ b/drivers/power/supply/bq2415x_charger.c
@@ -835,6 +835,8 @@ static int bq2415x_notifier_call(struct notifier_block *nb,
if (!bq2415x_update_reported_mode(bq, prop.intval))
return NOTIFY_OK;
+ power_supply_changed(bq->charger);
+
/* if automode is not enabled do not tell about reported_mode */
if (bq->automode < 1)
return NOTIFY_OK;
@@ -0,0 +1,90 @@
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 750fda543308..2560104c85a9 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -1522,6 +1522,18 @@ static void bq27xxx_battery_settings(struct bq27xxx_device_info *di)
bq27xxx_battery_set_config(di, info);
}
+/*
+ * Returns true if reported battery capacity is inaccurate
+ */
+static bool bq27xxx_battery_capacity_inaccurate(struct bq27xxx_device_info *di,
+ u16 flags)
+{
+ if (di->opts & BQ27XXX_O_HAS_CI)
+ return (flags & BQ27000_FLAG_CI);
+ else
+ return false;
+}
+
/*
* Return the battery State-of-Charge
* Or < 0 if something fails.
@@ -1538,6 +1550,12 @@ static int bq27xxx_battery_read_soc(struct bq27xxx_device_info *di)
if (soc < 0)
dev_dbg(di->dev, "error reading State-of-Charge\n");
+ /* If CI flag is set, SoC value always reports zero, therefore hide it
+ * from userspace.
+ */
+ if (soc == 0 && bq27xxx_battery_capacity_inaccurate(di, di->cache.flags))
+ return -ENODATA;
+
return soc;
}
@@ -1562,6 +1580,12 @@ static int bq27xxx_battery_read_charge(struct bq27xxx_device_info *di, u8 reg,
else
charge *= 1000;
+ /* If CI flag is set, reported charge will always be zero since the chip
+ * calculates it from the value of SoC. Therefore hide it from userspace.
+ */
+ if (charge == 0 && bq27xxx_battery_capacity_inaccurate(di, di->cache.flags))
+ return -ENODATA;
+
val->intval = charge;
return 0;
@@ -1655,6 +1679,12 @@ static int bq27xxx_battery_read_energy(struct bq27xxx_device_info *di,
else
ae *= 1000;
+ /* If CI flag is set, reported energy will always be zero since the chip
+ * calculates it from the value of SoC. Therefore hide it from userspace.
+ */
+ if (ae == 0 && bq27xxx_battery_capacity_inaccurate(di, di->cache.flags))
+ return -ENODATA;
+
val->intval = ae;
return 0;
@@ -1720,7 +1750,7 @@ static int bq27xxx_battery_read_time(struct bq27xxx_device_info *di, u8 reg,
return tval;
}
- if (tval == 65535)
+ if (tval == 65535 || (tval == 0 && bq27xxx_battery_capacity_inaccurate(di, di->cache.flags)))
return -ENODATA;
val->intval = tval * 60;
@@ -1765,18 +1795,6 @@ static bool bq27xxx_battery_dead(struct bq27xxx_device_info *di, u16 flags)
return flags & (BQ27XXX_FLAG_SOC1 | BQ27XXX_FLAG_SOCF);
}
-/*
- * Returns true if reported battery capacity is inaccurate
- */
-static bool bq27xxx_battery_capacity_inaccurate(struct bq27xxx_device_info *di,
- u16 flags)
-{
- if (di->opts & BQ27XXX_O_HAS_CI)
- return (flags & BQ27000_FLAG_CI);
- else
- return false;
-}
-
static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di,
union power_supply_propval *val)
{
@@ -0,0 +1,84 @@
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 750fda543308..c7d06ef877b3 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -123,6 +123,7 @@ enum bq27xxx_reg_index {
BQ27XXX_DM_BLOCK, /* Data Block */
BQ27XXX_DM_DATA, /* Block Data */
BQ27XXX_DM_CKSUM, /* Block Data Checksum */
+ BQ27XXX_REG_SEDVF, /* End-of-discharge Voltage */
BQ27XXX_REG_MAX, /* sentinel */
};
@@ -159,6 +160,7 @@ static u8
[BQ27XXX_DM_BLOCK] = INVALID_REG_ADDR,
[BQ27XXX_DM_DATA] = INVALID_REG_ADDR,
[BQ27XXX_DM_CKSUM] = INVALID_REG_ADDR,
+ [BQ27XXX_REG_SEDVF] = 0x77,
},
bq27010_regs[BQ27XXX_REG_MAX] = {
[BQ27XXX_REG_CTRL] = 0x00,
@@ -184,6 +186,7 @@ static u8
[BQ27XXX_DM_BLOCK] = INVALID_REG_ADDR,
[BQ27XXX_DM_DATA] = INVALID_REG_ADDR,
[BQ27XXX_DM_CKSUM] = INVALID_REG_ADDR,
+ [BQ27XXX_REG_SEDVF] = 0x77,
},
bq2750x_regs[BQ27XXX_REG_MAX] = {
[BQ27XXX_REG_CTRL] = 0x00,
@@ -559,6 +562,7 @@ static enum power_supply_property bq27000_props[] = {
POWER_SUPPLY_PROP_POWER_AVG,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_MANUFACTURER,
+ POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
};
static enum power_supply_property bq27010_props[] = {
@@ -579,6 +583,7 @@ static enum power_supply_property bq27010_props[] = {
POWER_SUPPLY_PROP_CYCLE_COUNT,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_MANUFACTURER,
+ POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
};
#define bq2750x_props bq27510g3_props
@@ -2006,6 +2011,27 @@ static int bq27xxx_battery_voltage(struct bq27xxx_device_info *di,
return 0;
}
+/*
+ * Return the design minimum battery Voltage in millivolts
+ * Or < 0 if something fails.
+ */
+static int bq27xxx_battery_read_dmin_volt(struct bq27xxx_device_info *di,
+ union power_supply_propval *val)
+{
+ int volt;
+
+ volt = bq27xxx_read(di, BQ27XXX_REG_SEDVF, false);
+ if (volt < 0) {
+ dev_err(di->dev, "error reading design min voltage\n");
+ return volt;
+ }
+
+ /* SEDVF = Design EDVF / 8 - 256 */
+ val->intval = volt * 8000 + 2048000;
+
+ return 0;
+}
+
static int bq27xxx_simple_value(int value,
union power_supply_propval *val)
{
@@ -2086,8 +2112,10 @@ static int bq27xxx_battery_get_property(struct power_supply *psy,
* power_supply_battery_info visible in sysfs.
*/
case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
- case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
return -EINVAL;
+ case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
+ ret = bq27xxx_battery_read_dmin_volt(di, val);
+ break;
case POWER_SUPPLY_PROP_CYCLE_COUNT:
ret = bq27xxx_battery_read_cyct(di, val);
break;
@@ -1,50 +0,0 @@
From d3f0e40d49378a70405b975169ab444f4a565a17 Mon Sep 17 00:00:00 2001
From: Robert Mader <robert.mader@collabora.com>
Date: Thu, 26 Sep 2024 23:07:39 +0200
Subject: [PATCH 5/5] pipeline: simple: Increase buffer count to four
Which is not only what many other pipeline handlers use, but also a good
lower limit when dealing with DRM and similar APIs. Even Mesas EGL and
Vulkan WSI implementations use for the reason outlined in mesa commit
992a2dbba80aba35efe83202e1013bd6143f0dba:
> When the compositor is directly scanning out from the application's buffer it
> may end up holding on to three buffers. These are the one that is is currently
> scanning out from, one that has been given to DRM as the next buffer to flip
> to, and one that has been attached and will be given to DRM as soon as the
> previous flip completes. When we attach a fourth buffer to the compositor it
> should replace that third buffer so we should get a release event immediately
> after that. This patch therefore also changes the number of buffer slots to 4
> so that we can accomodate that situation.
Given the popularity of this buffer number the bump should be unlikely
to cause problems. At the same time it may help with performance or
even work around glitches.
The previous number was introduced in commit
a8964c28c80fb520ee3c7b10143371081d41405a without mentioning a specific
reason against the change at hand.
Signed-off-by: Robert Mader <robert.mader@collabora.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
src/libcamera/pipeline/simple/simple.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index 29320a26..b32f8b2c 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -1134,7 +1134,7 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()
cfg.frameSize = format.planes[0].size;
}
- cfg.bufferCount = 3;
+ cfg.bufferCount = 4;
}
return status;
--
2.46.2
+1 -3
View File
@@ -3,7 +3,7 @@
pkgname=libcamera
pkgver=9999
_pkgver=0.3.2
pkgrel=7
pkgrel=6
pkgdesc="Linux camera framework"
url="https://libcamera.org/"
arch="all"
@@ -46,7 +46,6 @@ source="https://gitlab.freedesktop.org/camera/libcamera/-/archive/v$_pkgver/libc
0002-libcamera-simple-Force-disable-softwareISP-for-milli.patch
0003-libcamera-simple-Enable-softISP-for-the-Pinephone.patch
0004-libcamera-simple-Skip-hwISP-formats-if-swISP-is-acti.patch
0005-pipeline-simple-Increase-buffer-count-to-four.patch
qcam.desktop
90-libcamera.rules
"
@@ -151,7 +150,6 @@ ac7df3e4509ae874199810057f4d8416da71720c15534578cc352608a8ae228dfa4814f9eb995d55
9b6da8bd11ff9d8400ed721fbbeb960ac8753c078fdd971d786a446a9f96fea19dfc55be2705dc44a152e11de996f88139c1d24637bffc257da5083d19fe80c9 0002-libcamera-simple-Force-disable-softwareISP-for-milli.patch
0fc6a1108c4e905d2d422a664622dc25ec459f13765b5711ad009d4df0fd0cceda8cd067a18e5e54eb2346b292481952161e72deb03d416ba80b300256c25e40 0003-libcamera-simple-Enable-softISP-for-the-Pinephone.patch
35c74746453f4c2e24a2185331afabcf64e3af01bec2462ec09940518cda0e91c4a1f33853b4b009e1f8352af3c606fbd4b4d3791ffbba0f610f19538380c4c8 0004-libcamera-simple-Skip-hwISP-formats-if-swISP-is-acti.patch
b3ba41f81f30979e9b2bd41f5068cd720a11cde2e2a2e31a875493ad9e299cb3dd7b81b5862bea71201001533c6bde18e3d025f65df23e73af3b9363857654a2 0005-pipeline-simple-Increase-buffer-count-to-four.patch
22167a4eceb6d1b40b0b7c45fdf116c71684f5340de7f767535cb8e160ad9d2ae0f00cb3d461f73a344520a48a4641cf46226841d78bee06bfbfd2a91337f754 qcam.desktop
cb4eb19eec766f1b8667a8b7c9d5f7d44a2dce79fddfdf3b6e3d1849066cebe79f82566bdcf6659c7ddf4faaf233d5adac10cda636935785e5305e2b7e9b34a9 90-libcamera.rules
"