Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: wm8904: Fix audio input configuration #85736

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions drivers/audio/wm8904.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,17 @@ static int wm8904_in_update(
static int wm8904_in_volume_config(const struct device *dev, audio_channel_t channel, int volume)
{
const uint16_t val = WM8904_REGVAL_IN_VOL(0, volume);
const uint16_t mask = WM8904_REGMASK_IN_MUTE;
const uint16_t mask = WM8904_REGMASK_IN_VOLUME;

return wm8904_in_update(dev, channel, val, mask);
return wm8904_in_update(dev, channel, mask, val);
}

static int wm8904_in_mute_config(const struct device *dev, audio_channel_t channel, bool mute)
{
const uint16_t val = WM8904_REGVAL_IN_VOL(mute, 0);
const uint16_t mask = WM8904_REGMASK_IN_MUTE;

return wm8904_in_update(dev, channel, val, mask);
return wm8904_in_update(dev, channel, mask, val);
}

static int wm8904_route_input(const struct device *dev, audio_channel_t channel, uint32_t input)
Expand Down
2 changes: 1 addition & 1 deletion drivers/audio/wm8904.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
* [1:0] - x_MODE: Input mode
*/
#define WM8904_REGVAL_INSEL(cm, nin, pin, mode) \
(((cm) & 0b1) << 6) | (((nin) & 0b11) << 4)
(((cm) & 0b1) << 6) | (((nin) & 0b11) << 4) | (((pin) & 0b11) << 2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not directly related to your change of course, but binary literals should be avoided in Zephyr
https://docs.zephyrproject.org/latest/contribute/style/code.html

Copy link
Contributor Author

@VitekST VitekST Feb 18, 2025

Choose a reason for hiding this comment

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

@kartben Thanks, noted. I'm surprised that the PR introducing this driver went through, though: #75943

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the guideline is a SHOULD, not a MUST, but yeah...

#define WM8904_REGMASK_INSEL_CMENA 0b01000000
#define WM8904_REGMASK_INSEL_IP_SEL_N 0b00110000
#define WM8904_REGMASK_INSEL_IP_SEL_P 0b00001100
Expand Down
Loading