mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-24 02:01:36 +03:00
ASoC: tegra-alt: Fix restoration of mixer controls
When using the ALSA 'alsactl' tool to save and restore mixer settings the following type of errors are observed ... alsactl: set_control:1461: Cannot write control '2:0:0:ADMAIF1 Channels:0' : Invalid argument ... alsactl: set_control:1461: Cannot write control '2:0:0:AMX1 Output Channels:0' : Invalid argument ... alsactl: set_control:1461: Cannot write control '2:0:0:RX1 Channels:0' : Invalid argument ... alsactl: set_control:1461: Cannot write control '2:0:0:TX1 Channels:0' : Invalid argument ... alsactl: set_control:1461: Cannot write control '2:0:0:TX5 Channels:0' : Invalid argument ... alsactl: set_control:1461: Cannot write control '2:0:0:SFC1 Channels:0' : Invalid argument ... alsactl: set_control:1461: Cannot write control '2:0:0:MVC1 Bits:0' : Invalid argument These are just a few examples but these errors are seen for all instances of the devices. The problem is that the 'put' handler for the above mixer controls treats '0' as an invalid setting and so if the default value is '0', then when we try to restore the setting to '0' it fails because this is consider an 'invalid argument'. However, '0' is not a invalid argument, it simply means that we are not overriding this setting from userspace. Furthermore, if someone happens to set an of the above mixer controls to a non-zero value, then it is not possible to set it back to '0' again. Fix this by allowing userspace to set the above mixer controls to '0'. Bug 2058979 Change-Id: Icd543c2ea956cb0690238d9a1f184c144a572029 Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1675098 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Bibek Basu <bbasu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* tegra210_admaif_alt.c - Tegra ADMAIF driver
|
||||
*
|
||||
* Copyright (c) 2014-2017 NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -570,7 +570,7 @@ static int tegra_admaif_put_format(struct snd_kcontrol *kcontrol,
|
||||
char buf[50];
|
||||
|
||||
if (strstr(kcontrol->id.name, "Channels")) {
|
||||
if (value > 0 && value <= 16)
|
||||
if (value >= 0 && value <= 16)
|
||||
admaif->override_channels[mc->reg] = value;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* tegra210_amx_alt.c - Tegra210 AMX driver
|
||||
*
|
||||
* Copyright (c) 2014-2017 NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -574,12 +574,12 @@ static int tegra210_amx_put_channels(struct snd_kcontrol *kcontrol,
|
||||
|
||||
snprintf(buf, 50, "Input%d Channels", reg);
|
||||
if (strstr(kcontrol->id.name, buf)) {
|
||||
if (value > 0 && value <= 16)
|
||||
if (value >= 0 && value <= 16)
|
||||
amx->input_channels[reg - 1] = value;
|
||||
else
|
||||
return -EINVAL;
|
||||
} else if (strstr(kcontrol->id.name, "Output Channels")) {
|
||||
if (value > 0 && value <= 16)
|
||||
if (value >= 0 && value <= 16)
|
||||
amx->output_channels = value;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* tegra210_mixer_alt.c - Tegra210 MIXER driver
|
||||
*
|
||||
* Copyright (c) 2014-2017 NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -155,7 +155,7 @@ static int tegra210_mixer_put_format(struct snd_kcontrol *kcontrol,
|
||||
int value = ucontrol->value.integer.value[0];
|
||||
|
||||
if (strstr(kcontrol->id.name, "Channels")) {
|
||||
if (value > 0 && value <= 8)
|
||||
if (value >= 0 && value <= 8)
|
||||
mixer->channels_via_control[mc->reg - 1] = value;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* tegra210_mvc_alt.c - Tegra210 MVC driver
|
||||
*
|
||||
* Copyright (c) 2014-2017 NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -304,6 +304,8 @@ static int tegra210_mvc_put_audio_bits(struct snd_kcontrol *kcontrol,
|
||||
val = ucontrol->value.integer.value[0];
|
||||
if ((val >= 8) && (val <= 32) && (val%4 == 0))
|
||||
mvc->audio_bits = val/4 - 1;
|
||||
else if (val == 0)
|
||||
mvc->audio_bits = 0;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* tegra210_sfc_alt.c - Tegra210 SFC driver
|
||||
*
|
||||
* Copyright (c) 2014-2017 NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2014-2018 NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -499,7 +499,7 @@ static int tegra210_sfc_put_format(struct snd_kcontrol *kcontrol,
|
||||
else if (strstr(kcontrol->id.name, "output"))
|
||||
sfc->format_out = value;
|
||||
else if (strstr(kcontrol->id.name, "Channels")) {
|
||||
if (value > 0 && value <= 2)
|
||||
if (value >= 0 && value <= 2)
|
||||
sfc->channels_via_control = value;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
Reference in New Issue
Block a user