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

Lenovo patches #1442

Merged
merged 8 commits into from
Nov 27, 2019
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
4 changes: 4 additions & 0 deletions include/uapi/sound/sof/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,8 @@
/* for backward compatibility */
#define SOF_TKN_EFFECT_TYPE SOF_TKN_PROCESS_TYPE

/* Led control for mute switches */
#define SOF_TKN_MUTE_LED_USE 1300
#define SOF_TKN_MUTE_LED_DIRECTION 1301

#endif
34 changes: 34 additions & 0 deletions sound/soc/sof/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,39 @@
/* Mixer Controls */

#include <linux/pm_runtime.h>
#include <linux/leds.h>
#include "sof-priv.h"

static void update_mute_led(struct snd_sof_control *scontrol,
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
unsigned int temp = 0;
unsigned int mask;
int i;

mask = 1U << snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);

for (i = 0; i < scontrol->num_channels; i++) {
if (ucontrol->value.integer.value[i]) {
temp |= mask;
break;
}
}

if (temp == scontrol->led_ctl.led_value)
return;

scontrol->led_ctl.led_value = temp;

#if IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO)
if (!scontrol->led_ctl.direction)
ledtrig_audio_set(LED_AUDIO_MUTE, temp ? LED_OFF : LED_ON);
else
ledtrig_audio_set(LED_AUDIO_MICMUTE, temp ? LED_OFF : LED_ON);
#endif
}

static inline u32 mixer_to_ipc(unsigned int value, u32 *volume_map, int size)
{
if (value >= size)
Expand Down Expand Up @@ -112,6 +143,9 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
cdata->chanv[i].channel = i;
}

if (scontrol->led_ctl.use_led)
update_mute_led(scontrol, kcontrol, ucontrol);

/* notify DSP of mixer updates */
if (pm_runtime_active(sdev->dev))
snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol,
Expand Down
11 changes: 11 additions & 0 deletions sound/soc/sof/sof-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <sound/hdaudio.h>
#include <sound/soc.h>
#include <sound/control.h>

#include <sound/sof.h>
#include <sound/sof/stream.h> /* needs to be included before control.h */
Expand Down Expand Up @@ -296,10 +297,18 @@ struct snd_sof_pcm {
int hw_params_upon_resume[2]; /* set up hw_params upon resume */
};

struct snd_sof_led_control {
unsigned int use_led;
unsigned int direction;
unsigned int led_value;
};

/* ALSA SOF Kcontrol device */
struct snd_sof_control {
struct snd_sof_dev *sdev;
int comp_id;
int min_volume_step; /* min volume step for volume_table */
int max_volume_step; /* max volume step for volume_table */
int num_channels;
u32 readback_offset; /* offset to mmaped data if used */
struct sof_ipc_ctrl_data *control_data;
Expand All @@ -308,6 +317,8 @@ struct snd_sof_control {
u32 *volume_table; /* volume table computed from tlv data*/

struct list_head list; /* list in sdev control list */

struct snd_sof_led_control led_ctl;
};

/* ASoC SOF DAPM widget */
Expand Down
Loading