~mil/framebufferphone-devel

[f_audio] place global amixer scontrol variables inside function main() v1 PROPOSED

Bobby Hamblin: 1
 [f_audio] place global amixer scontrol variables inside function main()

 1 files changed, 5 insertions(+), 3 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~mil/framebufferphone-devel/patches/34468/mbox | git am -3
Learn more about email & git

[PATCH] [f_audio] place global amixer scontrol variables inside function main() Export this patch

Hello Miles,

This is the first of a few patches to ensure compatability across alpine
and arch linux by default. Currently, the three variables that determine
what amixer scontrol identifiers the script uses are placed inside the
devicepine64pinephone() function, which makes sense from a device
compatability perspective. However, these variables are undeclared in
every other function, which is why by moving them to main() the script
is able find and use them elsewhere. The f_audio script does not work
without this change, please let me know if they should be placed
somewhere other than main.

Thank you for your support in porting f_scripts, I'm looking forward to
the framebufferphone project being available on more platforms as it
matures. I apologize in advance if I mess up using git-send-email, it's
my first time using the tool.

Thanks,
Bobby

---
 scripts/f_audio | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/scripts/f_audio b/scripts/f_audio
index 26d4e31..6172a6f 100755
--- a/scripts/f_audio
+++ b/scripts/f_audio
@@ -41,13 +41,15 @@ devicepine64pinephone() {
  amixer set "AIF1 Slot 0 Digital DAC" unmute > /dev/null
  amixer set DAC "100%" > /dev/null
  amixer set DAC unmute > /dev/null
  GLOBAL_SPEAKER="Line Out"
  GLOBAL_HEADPHONE="Headphone"
  GLOBAL_EARPIECE="Earpiece"
}

main() {
  local RUN OPTS

  GLOBAL_SPEAKER="Line Out"
  GLOBAL_HEADPHONE="Headphone"
  GLOBAL_EARPIECE="Earpiece"

  env | grep -q "^$(basename "$0" | tr '[a-z]' '[A-Z]')=" || eval "$VAR"
  eval "$(grep deviceinfo_codename /etc/deviceinfo | cut -d= -f2 | tr -d \"- | xargs -ID echo deviceD)"
  OPTS="speaker headphone earpiece volup voldown"
-- 
2.37.1
Hi Bobby,
Thanks for sending! So 2 pieces of feedback:

1) Generally with git-send-email and patch based workflows the idea is
to keep the commit message as concise as possible. E.g. rather then the
full email with hello and signature etc. being in the commit message,
maybe the commit message could be just:
```
place global amixer scontrol variables inside function main()

Currently, the three variables that determine what amixer scontrol
identifiers the script uses are placed inside the devicepine64pinephone()
function, which makes sense from a device compatability perspective.
```
Then if there was more to say that's just administrative etc. you could send
as a reply to the mailing list in response to the patch after its sent.

2) As for the actual changeset, the idea behind the devicepine64pinephone
function is that it will only run on the Pinephone (on pmOS). This way 
arbitrary devices can be added for support since the
GLOBAL_{SPEAKER,HEADPHONE_EARPIECE} variables in the f_audio script are
device specific.

To expand support for Arch, from a quick glance Danctnix does have
/etc/machineinfo (1) does something similar which we can tap into. So
instead of what's currently in scripts for device-specific logic as:

eval "$(grep deviceinfo_codename /etc/deviceinfo | cut -d= -f2 | tr -d \"- | xargs -ID echo deviceD)"

we could instead use something like:

eval "$(
  grep -E 'deviceinfo_codename|PRETTY_HOSTNAME' /etc/deviceinfo /etc/machineinfo | 
  cut -d= -f2 | tr '[:upper:]' '[:lower:]' | tr -d ' \"-' |
  xargs -ID echo deviceD
)"

This way things would be pmOS & Arch compatible ootb and we'd retain
device-specific support.

--
Thanks for sending - I look forward to future patches and please ping me
if there's anything you need help on!

Miles

1) https://github.com/dreemurrs-embedded/Pine64-Arch/blob/master/PKGBUILDS/pine64/device-pine64-pinephone/PKGBUILD#L28