Skip to content

Commit

Permalink
Bubble up -1 option to the flag description.
Browse files Browse the repository at this point in the history
  • Loading branch information
hzeller committed Jul 29, 2024
1 parent c747d90 commit 631a5db
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ DEFINES+=$(USER_DEFINES)

DEFINES+=-DDEFAULT_HARDWARE='"$(HARDWARE_DESC)"'
INCDIR=../include
CFLAGS=-W -Wall -Wextra -Wno-unused-parameter -O3 -g -fPIC $(DEFINES)
CFLAGS=-W -Wall -Wextra -Wno-unused-parameter -O3 -g -fPIC $(DEFINES) -march=native

This comment has been minimized.

Copy link
@dkulp

dkulp Dec 4, 2024

This change prevents library from work on the older armv6 Pi's if it's compiled from an armv7 machine. Could this flag be stuck into an extra variable or something that can be overwritten?

This comment has been minimized.

Copy link
@hzeller

hzeller via email Dec 4, 2024

Author Owner

This comment has been minimized.

Copy link
@dkulp

dkulp Dec 4, 2024

There is already one at:
#1715

CXXFLAGS=$(CFLAGS) -fno-exceptions -std=c++11

all : $(TARGET).a $(TARGET).so.1
Expand Down
22 changes: 13 additions & 9 deletions lib/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

#include <vector>

#if __ARM_ARCH >= 7
#define LED_MATRIX_ALLOW_BARRIER_DELAY 1
#else
#define LED_MATRIX_ALLOW_BARRIER_DELAY 0
#endif

// Putting this in our namespace to not collide with other things called like
// this.
namespace rgb_matrix {
Expand Down Expand Up @@ -73,19 +79,17 @@ class GPIO {

private:
inline void delay() const {
switch(slowdown_) {
case -1:
#if __ARM_ARCH >= 7
#if LED_MATRIX_ALLOW_BARRIER_DELAY
if (slowdown_ == -1) {
asm volatile("dsb\tst");
return;
}
#endif
break;
case 0:
break;
default:
for (int n = 0; n < slowdown_; n++)
*gpio_clr_bits_low_ = 0;
for (int n = 0; n < slowdown_; n++) {
*gpio_clr_bits_low_ = 0;
}
}

inline gpio_bits_t ReadRegisters() const {
return (static_cast<gpio_bits_t>(*gpio_read_bits_low_)
#ifdef ENABLE_WIDE_GPIO_COMPUTE_MODULE
Expand Down
2 changes: 1 addition & 1 deletion lib/led-matrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ RGBMatrix *RGBMatrix::CreateFromOptions(const RGBMatrix::Options &options,

// For the Pi4, we might need 2, maybe up to 4. Let's open up to 5.
// on supproted architectures, -1 will emit memory barier (DSB ST) after GPIO write
if (runtime_options.gpio_slowdown < (__ARM_ARCH >= 7 ? -1 : 0)
if (runtime_options.gpio_slowdown < (LED_MATRIX_ALLOW_BARRIER_DELAY ? -1 : 0)
|| runtime_options.gpio_slowdown > 5) {
fprintf(stderr, "--led-slowdown-gpio=%d is outside usable range\n",
runtime_options.gpio_slowdown);
Expand Down
8 changes: 6 additions & 2 deletions lib/options-initialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,13 @@ void PrintMatrixFlags(FILE *out, const RGBMatrix::Options &d,
!d.disable_busy_waiting ? "no-" : "",
!d.disable_busy_waiting ? "Don't u" : "U");

fprintf(out, "\t--led-slowdown-gpio=<0..4>: "
fprintf(out,
"\t--led-slowdown-gpio=<%d..4>: "
"Slowdown GPIO. Needed for faster Pis/slower panels "
"(Default: %d (2 on Pi4, 1 other)).\n", r.gpio_slowdown);
"(Default: %d (2 on Pi4, 1 other)%s).\n",
(LED_MATRIX_ALLOW_BARRIER_DELAY ? -1 : 0), r.gpio_slowdown,
LED_MATRIX_ALLOW_BARRIER_DELAY ? "Use -1 for memory barrier approach"
: "");
if (r.daemon >= 0) {
const bool on = (r.daemon > 0);
fprintf(out,
Expand Down

0 comments on commit 631a5db

Please sign in to comment.