Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test-case/verify-kernel-boot-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ dmic_switch_present()
(set -x
# name= is hardcoded in /usr/share/alsa/ucm2/*
# This returns a non-zero error status on failure
amixer cget name='Dmic0 Capture Switch'
switch=$(aplay -l | head -2 | tail -1 | awk '{print $3}')
amixer -c "$switch" cget name='Dmic0 Capture Switch'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, doesn't this still select a fixed card?

E.g.

~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sofhdadsp [sof-hda-dsp], device 0: HDA Analog (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

... you'd get the same with "amixer -c 0" gets us.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Select a card using its name, such as "sofsoundwire", instead of selecting it using numbers

aplay -l | head -2 | tail -1 | awk '{print $3}'

sofsoundwire

Command shall be like: amixer -c "sofsoundwire" cget name='Dmic0 Capture Switch'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harajend But "head -2 | tail -1" will always pick the first card, so this is same as passing "amixer -c 0", right?

Copy link
Copy Markdown
Collaborator

@marc-hb marc-hb Jan 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awk is a "big boy" and can select lines itself. It's shorter AND more readable:

   switch=$(aplay -l |  awk 'NR == 2 {print $3}')

amixer -c 0 looks even better? I'm only simplifying code but I don't know if it is correct.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harajend But "head -2 | tail -1" will always pick the first card, so this is same as passing "amixer -c 0", right?

Yes, On functionality front both are same. Here I thought to pass "name/identifier" instead of "index number"

)
}

Expand Down