diff options
Diffstat (limited to 'sound/pci')
64 files changed, 904 insertions, 572 deletions
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 6758c072000e..012a7ee849e8 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -218,11 +218,11 @@ static int snd_ac97_valid_reg(struct snd_ac97 *ac97, unsigned short reg) case AC97_ID_ST_AC97_ID4: if (reg == 0x08) return 0; - /* fall through */ + fallthrough; case AC97_ID_ST7597: if (reg == 0x22 || reg == 0x7a) return 1; - /* fall through */ + fallthrough; case AC97_ID_AK4540: case AC97_ID_AK4542: if (reg <= 0x1c || reg == 0x20 || reg == 0x26 || reg >= 0x7c) diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 45ef0f52ec55..1627a74baf3c 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -19,7 +19,7 @@ static struct snd_kcontrol *snd_ac97_find_mixer_ctl(struct snd_ac97 *ac97, const char *name); static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name, const unsigned int *tlv, - const char * const *slaves); + const char * const *followers); /* * Chip specific initialization @@ -1791,10 +1791,10 @@ static const struct snd_kcontrol_new snd_ac97_ad1981x_jack_sense[] = { AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0), }; -/* black list to avoid HP/Line jack-sense controls +/* deny list to avoid HP/Line jack-sense controls * (SS vendor << 16 | device) */ -static const unsigned int ad1981_jacks_blacklist[] = { +static const unsigned int ad1981_jacks_denylist[] = { 0x10140523, /* Thinkpad R40 */ 0x10140534, /* Thinkpad X31 */ 0x10140537, /* Thinkpad T41p */ @@ -1821,7 +1821,7 @@ static int check_list(struct snd_ac97 *ac97, const unsigned int *list) static int patch_ad1981a_specific(struct snd_ac97 * ac97) { - if (check_list(ac97, ad1981_jacks_blacklist)) + if (check_list(ac97, ad1981_jacks_denylist)) return 0; return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense, ARRAY_SIZE(snd_ac97_ad1981x_jack_sense)); @@ -1835,10 +1835,10 @@ static const struct snd_ac97_build_ops patch_ad1981a_build_ops = { #endif }; -/* white list to enable HP jack-sense bits +/* allow list to enable HP jack-sense bits * (SS vendor << 16 | device) */ -static const unsigned int ad1981_jacks_whitelist[] = { +static const unsigned int ad1981_jacks_allowlist[] = { 0x0e11005a, /* HP nc4000/4010 */ 0x103c0890, /* HP nc6000 */ 0x103c0938, /* HP nc4220 */ @@ -1853,7 +1853,7 @@ static const unsigned int ad1981_jacks_whitelist[] = { static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97) { - if (check_list(ac97, ad1981_jacks_whitelist)) + if (check_list(ac97, ad1981_jacks_allowlist)) /* enable headphone jack sense */ snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11); } @@ -1877,7 +1877,7 @@ static int patch_ad1981b_specific(struct snd_ac97 *ac97) if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0) return err; - if (check_list(ac97, ad1981_jacks_blacklist)) + if (check_list(ac97, ad1981_jacks_denylist)) return 0; return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense, ARRAY_SIZE(snd_ac97_ad1981x_jack_sense)); @@ -3373,7 +3373,7 @@ AC97_SINGLE("Downmix LFE and Center to Front", 0x5a, 12, 1, 0), AC97_SINGLE("Downmix Surround to Front", 0x5a, 11, 1, 0), }; -static const char * const slave_vols_vt1616[] = { +static const char * const follower_vols_vt1616[] = { "Front Playback Volume", "Surround Playback Volume", "Center Playback Volume", @@ -3381,7 +3381,7 @@ static const char * const slave_vols_vt1616[] = { NULL }; -static const char * const slave_sws_vt1616[] = { +static const char * const follower_sws_vt1616[] = { "Front Playback Switch", "Surround Playback Switch", "Center Playback Switch", @@ -3400,10 +3400,10 @@ static struct snd_kcontrol *snd_ac97_find_mixer_ctl(struct snd_ac97 *ac97, return snd_ctl_find_id(ac97->bus->card, &id); } -/* create a virtual master control and add slaves */ +/* create a virtual master control and add followers */ static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name, const unsigned int *tlv, - const char * const *slaves) + const char * const *followers) { struct snd_kcontrol *kctl; const char * const *s; @@ -3416,16 +3416,16 @@ static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name, if (err < 0) return err; - for (s = slaves; *s; s++) { + for (s = followers; *s; s++) { struct snd_kcontrol *sctl; sctl = snd_ac97_find_mixer_ctl(ac97, *s); if (!sctl) { dev_dbg(ac97->bus->card->dev, - "Cannot find slave %s, skipped\n", *s); + "Cannot find follower %s, skipped\n", *s); continue; } - err = snd_ctl_add_slave(kctl, sctl); + err = snd_ctl_add_follower(kctl, sctl); if (err < 0) return err; } @@ -3451,12 +3451,12 @@ static int patch_vt1616_specific(struct snd_ac97 * ac97) snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Front Playback"); err = snd_ac97_add_vmaster(ac97, "Master Playback Volume", - kctl->tlv.p, slave_vols_vt1616); + kctl->tlv.p, follower_vols_vt1616); if (err < 0) return err; err = snd_ac97_add_vmaster(ac97, "Master Playback Switch", - NULL, slave_sws_vt1616); + NULL, follower_sws_vt1616); if (err < 0) return err; diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index a9540c2c4a1a..023c35a2a951 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -1904,7 +1904,7 @@ static int snd_asihpi_tuner_band_get(struct snd_kcontrol *kcontrol, */ u16 band, idx; u16 tuner_bands[HPI_TUNER_BAND_LAST]; - u32 num_bands = 0; + __always_unused u32 num_bands; num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands, HPI_TUNER_BAND_LAST); @@ -1931,7 +1931,7 @@ static int snd_asihpi_tuner_band_put(struct snd_kcontrol *kcontrol, unsigned int idx; u16 band; u16 tuner_bands[HPI_TUNER_BAND_LAST]; - u32 num_bands = 0; + __always_unused u32 num_bands; num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands, HPI_TUNER_BAND_LAST); @@ -2161,7 +2161,6 @@ static int snd_card_asihpi_mux_count_sources(struct snd_kcontrol *snd_control) static int snd_asihpi_mux_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - int err; u16 src_node_type, src_node_index; u32 h_control = kcontrol->private_value; @@ -2174,10 +2173,9 @@ static int snd_asihpi_mux_info(struct snd_kcontrol *kcontrol, uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; - err = - hpi_multiplexer_query_source(h_control, - uinfo->value.enumerated.item, - &src_node_type, &src_node_index); + hpi_multiplexer_query_source(h_control, + uinfo->value.enumerated.item, + &src_node_type, &src_node_index); sprintf(uinfo->value.enumerated.name, "%s %d", asihpi_src_names[src_node_type - HPI_SOURCENODE_NONE], diff --git a/sound/pci/asihpi/hpi_internal.h b/sound/pci/asihpi/hpi_internal.h index ad912f9dac7e..6859d51389f5 100644 --- a/sound/pci/asihpi/hpi_internal.h +++ b/sound/pci/asihpi/hpi_internal.h @@ -53,7 +53,7 @@ If handle is invalid *pPhysicalAddr is set to zero and return 1 u16 hpios_locked_mem_get_phys_addr(struct consistent_dma_area *locked_mem_handle, u32 *p_physical_addr); -/** Get the CPU address of of memory represented by LockedMemHandle. +/** Get the CPU address of memory represented by LockedMemHandle. If handle is NULL *ppvVirtualAddr is set to NULL and return 1 */ diff --git a/sound/pci/asihpi/hpicmn.c b/sound/pci/asihpi/hpicmn.c index 968510bc2552..7d1abaedb46a 100644 --- a/sound/pci/asihpi/hpicmn.c +++ b/sound/pci/asihpi/hpicmn.c @@ -28,10 +28,12 @@ struct hpi_adapters_list { static struct hpi_adapters_list adapters; /** -* Given an HPI Message that was sent out and a response that was received, -* validate that the response has the correct fields filled in, -* i.e ObjectType, Function etc -**/ + * hpi_validate_response - Given an HPI Message that was sent out and + * a response that was received, validate that the response has the + * correct fields filled in, i.e ObjectType, Function etc + * @phm: message + * @phr: response + */ u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr) { if (phr->type != HPI_TYPE_RESPONSE) { @@ -106,10 +108,11 @@ void hpi_delete_adapter(struct hpi_adapter_obj *pao) } /** -* FindAdapter returns a pointer to the struct hpi_adapter_obj with -* index wAdapterIndex in an HPI_ADAPTERS_LIST structure. -* -*/ + * hpi_find_adapter - FindAdapter returns a pointer to the struct + * hpi_adapter_obj with index wAdapterIndex in an HPI_ADAPTERS_LIST + * structure. + * @adapter_index: value in [0, HPI_MAX_ADAPTERS[ + */ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index) { struct hpi_adapter_obj *pao = NULL; @@ -137,10 +140,9 @@ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index) } /** -* -* wipe an HPI_ADAPTERS_LIST structure. -* -**/ + * wipe_adapter_list - wipe an HPI_ADAPTERS_LIST structure. + * + */ static void wipe_adapter_list(void) { memset(&adapters, 0, sizeof(adapters)); diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 85d3b4e95489..a25d75455802 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -896,15 +896,15 @@ static int snd_atiixp_playback_prepare(struct snd_pcm_substream *substream) case 8: data |= ATI_REG_OUT_DMA_SLOT_BIT(10) | ATI_REG_OUT_DMA_SLOT_BIT(11); - /* fall through */ + fallthrough; case 6: data |= ATI_REG_OUT_DMA_SLOT_BIT(7) | ATI_REG_OUT_DMA_SLOT_BIT(8); - /* fall through */ + fallthrough; case 4: data |= ATI_REG_OUT_DMA_SLOT_BIT(6) | ATI_REG_OUT_DMA_SLOT_BIT(9); - /* fall through */ + fallthrough; default: data |= ATI_REG_OUT_DMA_SLOT_BIT(3) | ATI_REG_OUT_DMA_SLOT_BIT(4); diff --git a/sound/pci/au88x0/au88x0_a3ddata.c b/sound/pci/au88x0/au88x0_a3ddata.c index 18623cb6bc52..a5da3b3a546a 100644 --- a/sound/pci/au88x0/au88x0_a3ddata.c +++ b/sound/pci/au88x0/au88x0_a3ddata.c @@ -21,7 +21,7 @@ static const a3d_Hrtf_t A3dHrirZeros = { 0, 0, 0 }; -static const a3d_Hrtf_t A3dHrirImpulse = { +static __maybe_unused const a3d_Hrtf_t A3dHrirImpulse = { 0x7fff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -30,7 +30,7 @@ static const a3d_Hrtf_t A3dHrirImpulse = { 0, 0, 0 }; -static const a3d_Hrtf_t A3dHrirOnes = { +static __maybe_unused const a3d_Hrtf_t A3dHrirOnes = { 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, @@ -47,7 +47,7 @@ static const a3d_Hrtf_t A3dHrirOnes = { 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff }; -static const a3d_Hrtf_t A3dHrirSatTest = { +static __maybe_unused const a3d_Hrtf_t A3dHrirSatTest = { 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, @@ -59,7 +59,7 @@ static const a3d_Hrtf_t A3dHrirSatTest = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -static const a3d_Hrtf_t A3dHrirDImpulse = { +static __maybe_unused const a3d_Hrtf_t A3dHrirDImpulse = { 0, 0x7fff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c index f5512b72b3e0..5180f1bd1326 100644 --- a/sound/pci/au88x0/au88x0_core.c +++ b/sound/pci/au88x0/au88x0_core.c @@ -1103,7 +1103,7 @@ vortex_adbdma_setbuffers(vortex_t * vortex, int adbdma, hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFBASE + (adbdma << 4) + 0xc, snd_pcm_sgbuf_get_addr(dma->substream, psize * 3)); - /* fall through */ + fallthrough; /* 3 pages */ case 3: dma->cfg0 |= 0x12000000; @@ -1111,14 +1111,14 @@ vortex_adbdma_setbuffers(vortex_t * vortex, int adbdma, hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFBASE + (adbdma << 4) + 0x8, snd_pcm_sgbuf_get_addr(dma->substream, psize * 2)); - /* fall through */ + fallthrough; /* 2 pages */ case 2: dma->cfg0 |= 0x88000000 | 0x44000000 | 0x10000000 | (psize - 1); hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFBASE + (adbdma << 4) + 0x4, snd_pcm_sgbuf_get_addr(dma->substream, psize)); - /* fall through */ + fallthrough; /* 1 page */ case 1: dma->cfg0 |= 0x80000000 | 0x40000000 | ((psize - 1) << 0xc); @@ -1381,20 +1381,20 @@ vortex_wtdma_setbuffers(vortex_t * vortex, int wtdma, dma->cfg1 |= 0x88000000 | 0x44000000 | 0x30000000 | (psize-1); hwwrite(vortex->mmio, VORTEX_WTDMA_BUFBASE + (wtdma << 4) + 0xc, snd_pcm_sgbuf_get_addr(dma->substream, psize * 3)); - /* fall through */ + fallthrough; /* 3 pages */ case 3: dma->cfg0 |= 0x12000000; dma->cfg1 |= 0x80000000 | 0x40000000 | ((psize-1) << 0xc); hwwrite(vortex->mmio, VORTEX_WTDMA_BUFBASE + (wtdma << 4) + 0x8, snd_pcm_sgbuf_get_addr(dma->substream, psize * 2)); - /* fall through */ + fallthrough; /* 2 pages */ case 2: dma->cfg0 |= 0x88000000 | 0x44000000 | 0x10000000 | (psize-1); hwwrite(vortex->mmio, VORTEX_WTDMA_BUFBASE + (wtdma << 4) + 0x4, snd_pcm_sgbuf_get_addr(dma->substream, psize)); - /* fall through */ + fallthrough; /* 1 page */ case 1: dma->cfg0 |= 0x80000000 | 0x40000000 | ((psize-1) << 0xc); diff --git a/sound/pci/au88x0/au88x0_xtalk.c b/sound/pci/au88x0/au88x0_xtalk.c index 084fcbf8ae80..27859536d7c0 100644 --- a/sound/pci/au88x0/au88x0_xtalk.c +++ b/sound/pci/au88x0/au88x0_xtalk.c @@ -17,35 +17,35 @@ static short const sXtalkWideKLeftEq = 0x269C; static short const sXtalkWideKRightEq = 0x269C; static short const sXtalkWideKLeftXt = 0xF25E; -static short const sXtalkWideKRightXt = 0xF25E; +static __maybe_unused short const sXtalkWideKRightXt = 0xF25E; static short const sXtalkWideShiftLeftEq = 1; static short const sXtalkWideShiftRightEq = 1; static short const sXtalkWideShiftLeftXt = 0; -static short const sXtalkWideShiftRightXt = 0; +static __maybe_unused short const sXtalkWideShiftRightXt = 0; static unsigned short const wXtalkWideLeftDelay = 0xd; static unsigned short const wXtalkWideRightDelay = 0xd; static short const sXtalkNarrowKLeftEq = 0x468D; static short const sXtalkNarrowKRightEq = 0x468D; static short const sXtalkNarrowKLeftXt = 0xF82E; -static short const sXtalkNarrowKRightXt = 0xF82E; +static __maybe_unused short const sXtalkNarrowKRightXt = 0xF82E; static short const sXtalkNarrowShiftLeftEq = 0x3; static short const sXtalkNarrowShiftRightEq = 0x3; static short const sXtalkNarrowShiftLeftXt = 0; -static short const sXtalkNarrowShiftRightXt = 0; +static __maybe_unused short const sXtalkNarrowShiftRightXt = 0; static unsigned short const wXtalkNarrowLeftDelay = 0x7; static unsigned short const wXtalkNarrowRightDelay = 0x7; -static xtalk_gains_t const asXtalkGainsDefault = { +static __maybe_unused xtalk_gains_t const asXtalkGainsDefault = { 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000 }; -static xtalk_gains_t const asXtalkGainsTest = { +static __maybe_unused xtalk_gains_t const asXtalkGainsTest = { 0x7fff, 0x8000, 0x0000, 0x0000, 0x0001, 0xffff, 0x4000, 0xc000, 0x0002, 0xfffe }; -static xtalk_gains_t const asXtalkGains1Chan = { +static __maybe_unused xtalk_gains_t const asXtalkGains1Chan = { 0x7FFF, 0, 0, 0, 0, 0x7FFF, 0, 0, 0, 0, }; @@ -64,7 +64,7 @@ static xtalk_dline_t const alXtalkDlineZeros = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -static xtalk_dline_t const alXtalkDlineTest = { +static __maybe_unused xtalk_dline_t const alXtalkDlineTest = { 0x0000fc18, 0xfff03e8, 0x000186a0, 0xfffe7960, 1, 0xffffffff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -74,7 +74,7 @@ static xtalk_instate_t const asXtalkInStateZeros = { 0, 0, 0, 0 }; -static xtalk_instate_t const asXtalkInStateTest = { +static __maybe_unused xtalk_instate_t const asXtalkInStateTest = { 0x0080, 0xff80, 0x0001, 0xffff }; @@ -89,11 +89,11 @@ static xtalk_state_t const asXtalkOutStateZeros = { static short const sDiamondKLeftEq = 0x401d; static short const sDiamondKRightEq = 0x401d; static short const sDiamondKLeftXt = 0xF90E; -static short const sDiamondKRightXt = 0xF90E; +static __maybe_unused short const sDiamondKRightXt = 0xF90E; static short const sDiamondShiftLeftEq = 1; static short const sDiamondShiftRightEq = 1; static short const sDiamondShiftLeftXt = 0; -static short const sDiamondShiftRightXt = 0; +static __maybe_unused short const sDiamondShiftRightXt = 0; static unsigned short const wDiamondLeftDelay = 0xb; static unsigned short const wDiamondRightDelay = 0xb; @@ -118,7 +118,7 @@ static xtalk_coefs_t const asXtalkWideCoefsLeftXt = { {0x77dc, 0xc79e, 0xffb8, 0x000a, 0}, {0, 0, 0, 0, 0} }; -static xtalk_coefs_t const asXtalkWideCoefsRightXt = { +static __maybe_unused xtalk_coefs_t const asXtalkWideCoefsRightXt = { {0x55c6, 0xc97b, 0x005b, 0x0047, 0}, {0x6a60, 0xca20, 0xffc6, 0x0040, 0}, {0x6411, 0xd711, 0xfca1, 0x0190, 0}, @@ -149,7 +149,7 @@ static xtalk_coefs_t const asXtalkNarrowCoefsLeftXt = { {0, 0, 0, 0, 0} }; -static xtalk_coefs_t const asXtalkNarrowCoefsRightXt = { +static __maybe_unused xtalk_coefs_t const asXtalkNarrowCoefsRightXt = { {0x3CB2, 0xDF49, 0xF6EA, 0x095B, 0}, {0x6777, 0xC915, 0xFEAF, 0x00B1, 0}, {0x7762, 0xC7D9, 0x025B, 0xFDA6, 0}, @@ -172,7 +172,7 @@ static xtalk_coefs_t const asXtalkCoefsPipe = { {0, 0, 0x0FA0, 0, 0}, {0, 0, 0x1180, 0, 0}, }; -static xtalk_coefs_t const asXtalkCoefsNegPipe = { +static __maybe_unused xtalk_coefs_t const asXtalkCoefsNegPipe = { {0, 0, 0xF380, 0, 0}, {0, 0, 0xF380, 0, 0}, {0, 0, 0xF380, 0, 0}, @@ -180,7 +180,7 @@ static xtalk_coefs_t const asXtalkCoefsNegPipe = { {0, 0, 0xF200, 0, 0} }; -static xtalk_coefs_t const asXtalkCoefsNumTest = { +static __maybe_unused xtalk_coefs_t const asXtalkCoefsNumTest = { {0, 0, 0xF380, 0x8000, 0x6D60}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, @@ -188,7 +188,7 @@ static xtalk_coefs_t const asXtalkCoefsNumTest = { {0, 0, 0, 0, 0} }; -static xtalk_coefs_t const asXtalkCoefsDenTest = { +static __maybe_unused xtalk_coefs_t const asXtalkCoefsDenTest = { {0xC000, 0x2000, 0x4000, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, @@ -196,7 +196,7 @@ static xtalk_coefs_t const asXtalkCoefsDenTest = { {0, 0, 0, 0, 0} }; -static xtalk_state_t const asXtalkOutStateTest = { +static __maybe_unused xtalk_state_t const asXtalkOutStateTest = { {0x7FFF, 0x0004, 0xFFFC, 0}, {0xFE00, 0x0008, 0xFFF8, 0x4000}, {0x0200, 0x0010, 0xFFF0, 0xC000}, @@ -228,7 +228,7 @@ static xtalk_coefs_t const asDiamondCoefsLeftXt = { {0, 0, 0, 0, 0} }; -static xtalk_coefs_t const asDiamondCoefsRightXt = { +static __maybe_unused xtalk_coefs_t const asDiamondCoefsRightXt = { {0x3B50, 0xFE08, 0xF959, 0x0060, 0}, {0x9FCB, 0xD8F1, 0x00A2, 0x003A, 0}, {0, 0, 0, 0, 0}, diff --git a/sound/pci/aw2/aw2-saa7146.c b/sound/pci/aw2/aw2-saa7146.c index 4e64eb5d8f64..c84f1a45194f 100644 --- a/sound/pci/aw2/aw2-saa7146.c +++ b/sound/pci/aw2/aw2-saa7146.c @@ -330,7 +330,7 @@ void snd_aw2_saa7146_pcm_trigger_stop_capture(struct snd_aw2_saa7146 *chip, irqreturn_t snd_aw2_saa7146_interrupt(int irq, void *dev_id) { unsigned int isr; - unsigned int iicsta; + __always_unused unsigned int iicsta; struct snd_aw2_saa7146 *chip = dev_id; isr = READREG(ISR); diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 58167d8469e1..77c7030ebbfa 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -1232,7 +1232,7 @@ snd_azf3328_codec_setfmt(struct snd_azf3328_codec_data *codec, case AZF_FREQ_32000: freq = SOUNDFORMAT_FREQ_32000; break; default: snd_printk(KERN_WARNING "unknown bitrate %d, assuming 44.1kHz!\n", bitrate); - /* fall-through */ + fallthrough; case AZF_FREQ_44100: freq = SOUNDFORMAT_FREQ_44100; break; case AZF_FREQ_48000: freq = SOUNDFORMAT_FREQ_48000; break; case AZF_FREQ_66200: freq = SOUNDFORMAT_FREQ_SUSPECTED_66200; break; diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 6567504665b9..54cb223caa2f 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -30,7 +30,7 @@ static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ static int digital_rate[SNDRV_CARDS]; /* digital input rate */ -static bool load_all; /* allow to load the non-whitelisted cards */ +static bool load_all; /* allow to load cards not the allowlist */ module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for Bt87x soundcard"); @@ -41,7 +41,7 @@ MODULE_PARM_DESC(enable, "Enable Bt87x soundcard"); module_param_array(digital_rate, int, NULL, 0444); MODULE_PARM_DESC(digital_rate, "Digital input rate for Bt87x soundcard"); module_param(load_all, bool, 0444); -MODULE_PARM_DESC(load_all, "Allow to load the non-whitelisted cards"); +MODULE_PARM_DESC(load_all, "Allow to load cards not on the allowlist"); /* register offsets */ @@ -801,7 +801,7 @@ MODULE_DEVICE_TABLE(pci, snd_bt87x_ids); * (DVB cards use the audio function to transfer MPEG data) */ static struct { unsigned short subvendor, subdevice; -} blacklist[] = { +} denylist[] = { {0x0071, 0x0101}, /* Nebula Electronics DigiTV */ {0x11bd, 0x001c}, /* Pinnacle PCTV Sat */ {0x11bd, 0x0026}, /* Pinnacle PCTV SAT CI */ @@ -817,7 +817,7 @@ static struct { static struct pci_driver driver; -/* return the id of the card, or a negative value if it's blacklisted */ +/* return the id of the card, or a negative value if it's on the denylist */ static int snd_bt87x_detect_card(struct pci_dev *pci) { int i; @@ -827,9 +827,9 @@ static int snd_bt87x_detect_card(struct pci_dev *pci) if (supported && supported->driver_data > 0) return supported->driver_data; - for (i = 0; i < ARRAY_SIZE(blacklist); ++i) - if (blacklist[i].subvendor == pci->subsystem_vendor && - blacklist[i].subdevice == pci->subsystem_device) { + for (i = 0; i < ARRAY_SIZE(denylist); ++i) + if (denylist[i].subvendor == pci->subsystem_vendor && + denylist[i].subdevice == pci->subsystem_device) { dev_dbg(&pci->dev, "card %#04x-%#04x:%#04x has no audio\n", pci->device, pci->subsystem_vendor, pci->subsystem_device); diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 3b8ec673dc0a..c852c6a75b91 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -739,7 +739,7 @@ static int rename_ctl(struct snd_card *card, const char *src, const char *dst) static DECLARE_TLV_DB_SCALE(snd_ca0106_master_db_scale, -6375, 25, 1); -static const char * const slave_vols[] = { +static const char * const follower_vols[] = { "Analog Front Playback Volume", "Analog Rear Playback Volume", "Analog Center/LFE Playback Volume", @@ -752,7 +752,7 @@ static const char * const slave_vols[] = { NULL }; -static const char * const slave_sws[] = { +static const char * const follower_sws[] = { "Analog Front Playback Switch", "Analog Rear Playback Switch", "Analog Center/LFE Playback Switch", @@ -761,13 +761,13 @@ static const char * const slave_sws[] = { NULL }; -static void add_slaves(struct snd_card *card, - struct snd_kcontrol *master, const char * const *list) +static void add_followers(struct snd_card *card, + struct snd_kcontrol *master, const char * const *list) { for (; *list; list++) { - struct snd_kcontrol *slave = ctl_find(card, *list); - if (slave) - snd_ctl_add_slave(master, slave); + struct snd_kcontrol *follower = ctl_find(card, *list); + if (follower) + snd_ctl_add_follower(master, follower); } } @@ -852,7 +852,7 @@ int snd_ca0106_mixer(struct snd_ca0106 *emu) err = snd_ctl_add(card, vmaster); if (err < 0) return err; - add_slaves(card, vmaster, slave_vols); + add_followers(card, vmaster, follower_vols); if (emu->details->spi_dac) { vmaster = snd_ctl_make_virtual_master("Master Playback Switch", @@ -862,7 +862,7 @@ int snd_ca0106_mixer(struct snd_ca0106 *emu) err = snd_ctl_add(card, vmaster); if (err < 0) return err; - add_slaves(card, vmaster, slave_sws); + add_followers(card, vmaster, follower_sws); } strcpy(card->mixername, "CA0106"); diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index a080d63a9b45..4490dd7469d9 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -766,7 +766,7 @@ static void snd_cs46xx_set_capture_sample_rate(struct snd_cs46xx *chip, unsigned rate = 48000 / 9; /* - * We can not capture at at rate greater than the Input Rate (48000). + * We can not capture at a rate greater than the Input Rate (48000). * Return an error if an attempt is made to stray outside that limit. */ if (rate > 48000) diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c index 6b536fc23ca6..1f90ca723f4d 100644 --- a/sound/pci/cs46xx/dsp_spos_scb_lib.c +++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c @@ -1716,7 +1716,7 @@ int cs46xx_iec958_pre_open (struct snd_cs46xx *chip) struct dsp_spos_instance * ins = chip->dsp_spos_instance; if ( ins->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED ) { - /* remove AsynchFGTxSCB and and PCMSerialInput_II */ + /* remove AsynchFGTxSCB and PCMSerialInput_II */ cs46xx_dsp_disable_spdif_out (chip); /* save state */ diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index e56a230f6a9c..f8ac96cf38a4 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c @@ -1282,7 +1282,7 @@ static int atc_identify_card(struct ct_atc *atc, unsigned int ssid) if (p) { if (p->value < 0) { dev_err(atc->card->dev, - "Device %04x:%04x is black-listed\n", + "Device %04x:%04x is on the denylist\n", vendor_id, device_id); return -ENOENT; } @@ -1655,6 +1655,10 @@ static const struct ct_atc atc_preset = { * ct_atc_create - create and initialize a hardware manager * @card: corresponding alsa card object * @pci: corresponding kernel pci device object + * @rsr: reference sampling rate + * @msr: master sampling rate + * @chip_type: CHIPTYP enum values + * @ssid: vendor ID (upper 16 bits) and device ID (lower 16 bits) * @ratc: return created object address in it * * Creates and initializes a hardware manager. diff --git a/sound/pci/ctxfi/cthardware.c b/sound/pci/ctxfi/cthardware.c index 9b7e63f4a3a7..1d5064486217 100644 --- a/sound/pci/ctxfi/cthardware.c +++ b/sound/pci/ctxfi/cthardware.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/** +/* * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved. * * @File cthardware.c diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index 015c0d676897..108ab449c968 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/** +/* * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved. * * @File cthw20k1.c diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index ce44cbe6459f..fc1bc18caee9 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/** +/* * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved. * * @File cthw20k2.c diff --git a/sound/pci/ctxfi/ctimap.c b/sound/pci/ctxfi/ctimap.c index eb1825e13fc5..d5a53d2f5f15 100644 --- a/sound/pci/ctxfi/ctimap.c +++ b/sound/pci/ctxfi/ctimap.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/** +/* * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved. * * @File ctimap.c diff --git a/sound/pci/ctxfi/ctmixer.c b/sound/pci/ctxfi/ctmixer.c index 84514dc90d87..6797fde3d788 100644 --- a/sound/pci/ctxfi/ctmixer.c +++ b/sound/pci/ctxfi/ctmixer.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/** +/* * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved. * * @File ctmixer.c diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c index 6ee6a9675ca5..3f48ad0e27e7 100644 --- a/sound/pci/ctxfi/ctpcm.c +++ b/sound/pci/ctxfi/ctpcm.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/** +/* * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved. * * @File ctpcm.c diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 0941a7a17623..6aeb99aa2414 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -2,6 +2,7 @@ /* * ALSA driver for Echoaudio soundcards. * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it> + * Copyright (C) 2020 Mark Hills <mark@xwax.org> */ #include <linux/module.h> @@ -245,13 +246,20 @@ static int hw_rule_sample_rate(struct snd_pcm_hw_params *params, SNDRV_PCM_HW_PARAM_RATE); struct echoaudio *chip = rule->private; struct snd_interval fixed; + int err; + + mutex_lock(&chip->mode_mutex); - if (!chip->can_set_rate) { + if (chip->can_set_rate) { + err = 0; + } else { snd_interval_any(&fixed); fixed.min = fixed.max = chip->sample_rate; - return snd_interval_refine(rate, &fixed); + err = snd_interval_refine(rate, &fixed); } - return 0; + + mutex_unlock(&chip->mode_mutex); + return err; } @@ -322,7 +330,7 @@ static int pcm_open(struct snd_pcm_substream *substream, SNDRV_PCM_HW_PARAM_RATE, -1)) < 0) return err; - /* Finally allocate a page for the scatter-gather list */ + /* Allocate a page for the scatter-gather list */ if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev, PAGE_SIZE, &pipe->sgpage)) < 0) { @@ -330,6 +338,17 @@ static int pcm_open(struct snd_pcm_substream *substream, return err; } + /* + * Sole ownership required to set the rate + */ + + dev_dbg(chip->card->dev, "pcm_open opencount=%d can_set_rate=%d, rate_set=%d", + chip->opencount, chip->can_set_rate, chip->rate_set); + + chip->opencount++; + if (chip->opencount > 1 && chip->rate_set) + chip->can_set_rate = 0; + return 0; } @@ -353,12 +372,7 @@ static int pcm_analog_in_open(struct snd_pcm_substream *substream) hw_rule_capture_format_by_channels, NULL, SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0) return err; - atomic_inc(&chip->opencount); - if (atomic_read(&chip->opencount) > 1 && chip->rate_set) - chip->can_set_rate=0; - dev_dbg(chip->card->dev, "pcm_analog_in_open cs=%d oc=%d r=%d\n", - chip->can_set_rate, atomic_read(&chip->opencount), - chip->sample_rate); + return 0; } @@ -388,12 +402,7 @@ static int pcm_analog_out_open(struct snd_pcm_substream *substream) NULL, SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0) return err; - atomic_inc(&chip->opencount); - if (atomic_read(&chip->opencount) > 1 && chip->rate_set) - chip->can_set_rate=0; - dev_dbg(chip->card->dev, "pcm_analog_out_open cs=%d oc=%d r=%d\n", - chip->can_set_rate, atomic_read(&chip->opencount), - chip->sample_rate); + return 0; } @@ -429,10 +438,6 @@ static int pcm_digital_in_open(struct snd_pcm_substream *substream) SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0) goto din_exit; - atomic_inc(&chip->opencount); - if (atomic_read(&chip->opencount) > 1 && chip->rate_set) - chip->can_set_rate=0; - din_exit: mutex_unlock(&chip->mode_mutex); return err; @@ -471,9 +476,7 @@ static int pcm_digital_out_open(struct snd_pcm_substream *substream) NULL, SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0) goto dout_exit; - atomic_inc(&chip->opencount); - if (atomic_read(&chip->opencount) > 1 && chip->rate_set) - chip->can_set_rate=0; + dout_exit: mutex_unlock(&chip->mode_mutex); return err; @@ -488,23 +491,29 @@ dout_exit: static int pcm_close(struct snd_pcm_substream *substream) { struct echoaudio *chip = snd_pcm_substream_chip(substream); - int oc; /* Nothing to do here. Audio is already off and pipe will be * freed by its callback */ - atomic_dec(&chip->opencount); - oc = atomic_read(&chip->opencount); - dev_dbg(chip->card->dev, "pcm_close oc=%d cs=%d rs=%d\n", oc, - chip->can_set_rate, chip->rate_set); - if (oc < 2) + mutex_lock(&chip->mode_mutex); + + dev_dbg(chip->card->dev, "pcm_open opencount=%d can_set_rate=%d, rate_set=%d", + chip->opencount, chip->can_set_rate, chip->rate_set); + + chip->opencount--; + + switch (chip->opencount) { + case 1: chip->can_set_rate = 1; - if (oc == 0) + break; + + case 0: chip->rate_set = 0; - dev_dbg(chip->card->dev, "pcm_close2 oc=%d cs=%d rs=%d\n", oc, - chip->can_set_rate, chip->rate_set); + break; + } + mutex_unlock(&chip->mode_mutex); return 0; } @@ -582,7 +591,7 @@ static int init_engine(struct snd_pcm_substream *substream, /* This stuff is used by the irq handler, so it must be * initialized before chip->substream */ - chip->last_period[pipe_index] = 0; + pipe->last_period = 0; pipe->last_counter = 0; pipe->position = 0; smp_wmb(); @@ -690,7 +699,7 @@ static int pcm_prepare(struct snd_pcm_substream *substream) break; case SNDRV_PCM_FORMAT_S32_BE: format.data_are_bigendian = 1; - /* fall through */ + fallthrough; case SNDRV_PCM_FORMAT_S32_LE: format.bits_per_sample = 32; break; @@ -703,9 +712,22 @@ static int pcm_prepare(struct snd_pcm_substream *substream) if (snd_BUG_ON(pipe_index >= px_num(chip))) return -EINVAL; - if (snd_BUG_ON(!is_pipe_allocated(chip, pipe_index))) + + /* + * We passed checks we can do independently; now take + * exclusive control + */ + + spin_lock_irq(&chip->lock); + + if (snd_BUG_ON(!is_pipe_allocated(chip, pipe_index))) { + spin_unlock_irq(&chip->lock); return -EINVAL; + } + set_audio_format(chip, pipe_index, &format); + spin_unlock_irq(&chip->lock); + return 0; } @@ -738,11 +760,11 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd) pipe = chip->substream[i]->runtime->private_data; switch (pipe->state) { case PIPE_STATE_STOPPED: - chip->last_period[i] = 0; + pipe->last_period = 0; pipe->last_counter = 0; pipe->position = 0; *pipe->dma_counter = 0; - /* fall through */ + fallthrough; case PIPE_STATE_PAUSED: pipe->state = PIPE_STATE_STARTED; break; @@ -786,19 +808,26 @@ static snd_pcm_uframes_t pcm_pointer(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct audiopipe *pipe = runtime->private_data; - size_t cnt, bufsize, pos; + u32 counter, step; - cnt = le32_to_cpu(*pipe->dma_counter); - pipe->position += cnt - pipe->last_counter; - pipe->last_counter = cnt; - bufsize = substream->runtime->buffer_size; - pos = bytes_to_frames(substream->runtime, pipe->position); + /* + * IRQ handling runs concurrently. Do not share tracking of + * counter with it, which would race or require locking + */ - while (pos >= bufsize) { - pipe->position -= frames_to_bytes(substream->runtime, bufsize); - pos -= bufsize; - } - return pos; + counter = le32_to_cpu(*pipe->dma_counter); /* presumed atomic */ + + step = counter - pipe->last_counter; /* handles wrapping */ + pipe->last_counter = counter; + + /* counter doesn't neccessarily wrap on a multiple of + * buffer_size, so can't derive the position; must + * accumulate */ + + pipe->position += step; + pipe->position %= frames_to_bytes(runtime, runtime->buffer_size); /* wrap */ + + return bytes_to_frames(runtime, pipe->position); } @@ -1409,7 +1438,7 @@ static int snd_echo_digital_mode_put(struct snd_kcontrol *kcontrol, /* Do not allow the user to change the digital mode when a pcm device is open because it also changes the number of channels and the allowed sample rates */ - if (atomic_read(&chip->opencount)) { + if (chip->opencount) { changed = -EAGAIN; } else { changed = set_digital_mode(chip, dmode); @@ -1761,14 +1790,43 @@ static const struct snd_kcontrol_new snd_echo_channels_info = { /****************************************************************************** - IRQ Handler + IRQ Handling ******************************************************************************/ +/* Check if a period has elapsed since last interrupt + * + * Don't make any updates to state; PCM core handles this with the + * correct locks. + * + * \return true if a period has elapsed, otherwise false + */ +static bool period_has_elapsed(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct audiopipe *pipe = runtime->private_data; + u32 counter, step; + size_t period_bytes; + + if (pipe->state != PIPE_STATE_STARTED) + return false; + + period_bytes = frames_to_bytes(runtime, runtime->period_size); + + counter = le32_to_cpu(*pipe->dma_counter); /* presumed atomic */ + + step = counter - pipe->last_period; /* handles wrapping */ + step -= step % period_bytes; /* acknowledge whole periods only */ + + if (step == 0) + return false; /* haven't advanced a whole period yet */ + + pipe->last_period += step; /* used exclusively by us */ + return true; +} static irqreturn_t snd_echo_interrupt(int irq, void *dev_id) { struct echoaudio *chip = dev_id; - struct snd_pcm_substream *substream; - int period, ss, st; + int ss, st; spin_lock(&chip->lock); st = service_irq(chip); @@ -1779,17 +1837,13 @@ static irqreturn_t snd_echo_interrupt(int irq, void *dev_id) /* The hardware doesn't tell us which substream caused the irq, thus we have to check all running substreams. */ for (ss = 0; ss < DSP_MAXPIPES; ss++) { + struct snd_pcm_substream *substream; + substream = chip->substream[ss]; - if (substream && ((struct audiopipe *)substream->runtime-> - private_data)->state == PIPE_STATE_STARTED) { - period = pcm_pointer(substream) / - substream->runtime->period_size; - if (period != chip->last_period[ss]) { - chip->last_period[ss] = period; - spin_unlock(&chip->lock); - snd_pcm_period_elapsed(substream); - spin_lock(&chip->lock); - } + if (substream && period_has_elapsed(substream)) { + spin_unlock(&chip->lock); + snd_pcm_period_elapsed(substream); + spin_lock(&chip->lock); } } spin_unlock(&chip->lock); @@ -1874,7 +1928,7 @@ static int snd_echo_create(struct snd_card *card, chip->card = card; chip->pci = pci; chip->irq = -1; - atomic_set(&chip->opencount, 0); + chip->opencount = 0; mutex_init(&chip->mode_mutex); chip->can_set_rate = 1; } else { @@ -1955,7 +2009,8 @@ static int snd_echo_probe(struct pci_dev *pci, struct snd_card *card; struct echoaudio *chip; char *dsp; - int i, err; + __maybe_unused int i; + int err; if (dev >= SNDRV_CARDS) return -ENODEV; diff --git a/sound/pci/echoaudio/echoaudio.h b/sound/pci/echoaudio/echoaudio.h index be4d0489394a..30c640931f1e 100644 --- a/sound/pci/echoaudio/echoaudio.h +++ b/sound/pci/echoaudio/echoaudio.h @@ -298,7 +298,12 @@ struct audiopipe { * the current dma position * (lower 32 bits only) */ - u32 last_counter; /* The last position, which is used + u32 last_period; /* Counter position last time a + * period elapsed + */ + u32 last_counter; /* Used exclusively by pcm_pointer + * under PCM core locks. + * The last position, which is used * to compute... */ u32 position; /* ...the number of bytes tranferred @@ -332,11 +337,10 @@ struct audioformat { struct echoaudio { spinlock_t lock; struct snd_pcm_substream *substream[DSP_MAXPIPES]; - int last_period[DSP_MAXPIPES]; struct mutex mode_mutex; u16 num_digital_modes, digital_mode_list[6]; u16 num_clock_sources, clock_source_list[10]; - atomic_t opencount; + unsigned int opencount; /* protected by mode_mutex */ struct snd_kcontrol *clock_src_ctl; struct snd_pcm *analog_pcm, *digital_pcm; struct snd_card *card; @@ -353,8 +357,8 @@ struct echoaudio { struct timer_list timer; char tinuse; /* Timer in use */ char midi_full; /* MIDI output buffer is full */ - char can_set_rate; - char rate_set; + char can_set_rate; /* protected by mode_mutex */ + char rate_set; /* protected by mode_mutex */ /* This stuff is used mainly by the lowlevel code */ struct comm_page *comm_page; /* Virtual address of the memory diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c index f02f5b1568de..d10d0e460f0b 100644 --- a/sound/pci/echoaudio/echoaudio_dsp.c +++ b/sound/pci/echoaudio/echoaudio_dsp.c @@ -898,7 +898,7 @@ static int pause_transport(struct echoaudio *chip, u32 channel_mask) return 0; } - dev_warn(chip->card->dev, "pause_transport: No pipes to stop!\n"); + dev_dbg(chip->card->dev, "pause_transport: No pipes to stop!\n"); return 0; } @@ -924,7 +924,7 @@ static int stop_transport(struct echoaudio *chip, u32 channel_mask) return 0; } - dev_warn(chip->card->dev, "stop_transport: No pipes to stop!\n"); + dev_dbg(chip->card->dev, "stop_transport: No pipes to stop!\n"); return 0; } diff --git a/sound/pci/echoaudio/mona_dsp.c b/sound/pci/echoaudio/mona_dsp.c index dce9e57d01c4..f77db83dd73d 100644 --- a/sound/pci/echoaudio/mona_dsp.c +++ b/sound/pci/echoaudio/mona_dsp.c @@ -300,11 +300,6 @@ static int set_input_clock(struct echoaudio *chip, u16 clock) u32 control_reg, clocks_from_dsp; int err; - - /* Prevent two simultaneous calls to switch_asic() */ - if (atomic_read(&chip->opencount)) - return -EAGAIN; - /* Mask off the clock select bits */ control_reg = le32_to_cpu(chip->comm_page->control_register) & GML_CLOCK_CLEAR_MASK; diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 6ff581733a19..bd70e112ffd7 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -623,7 +623,7 @@ static int snd_emu10k1_ecard_init(struct snd_emu10k1 *emu) static int snd_emu10k1_cardbus_init(struct snd_emu10k1 *emu) { unsigned long special_port; - unsigned int value; + __always_unused unsigned int value; /* Special initialisation routine * before the rest of the IO-Ports become active. @@ -653,7 +653,7 @@ static int snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, int n, i; int reg; int value; - unsigned int write_post; + __always_unused unsigned int write_post; unsigned long flags; if (!fw_entry) diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index b3aa7bbe1067..89890f24509f 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -27,7 +27,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, const void __user *data, long count) { int offset; - int truesize, size, loopsize, blocksize; + int truesize, size, blocksize; + __maybe_unused int loopsize; int loopend, sampleend; unsigned int start_addr; struct snd_emu10k1 *emu; diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index b934c6ac52dd..b2ddabb99438 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -753,7 +753,7 @@ static int snd_emu10k1_playback_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_START: snd_emu10k1_playback_invalidate_cache(emu, 1, epcm->extra); /* do we need this? */ snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[0]); - /* fall through */ + fallthrough; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_RESUME: if (cmd == SNDRV_PCM_TRIGGER_PAUSE_RELEASE) @@ -902,8 +902,7 @@ static int snd_emu10k1_efx_playback_trigger(struct snd_pcm_substream *substream, snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[i]); } snd_emu10k1_playback_invalidate_cache(emu, 1, epcm->extra); - - /* fall through */ + fallthrough; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_RESUME: snd_emu10k1_playback_prepare_voice(emu, epcm->extra, 1, 1, NULL); diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index b4a0adf7451c..09704a78d799 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -1619,7 +1619,8 @@ static int snd_es1938_create(struct snd_card *card, static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id) { struct es1938 *chip = dev_id; - unsigned char status, audiostatus; + unsigned char status; + __always_unused unsigned char audiostatus; int handled = 0; status = inb(SLIO_REG(chip, IRQCONTROL)); diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index d26004b35a81..34332d008b27 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -2631,7 +2631,7 @@ struct ess_device_list { unsigned short vendor; /* subsystem vendor id */ }; -static const struct ess_device_list pm_whitelist[] = { +static const struct ess_device_list pm_allowlist[] = { { TYPE_MAESTRO2E, 0x0e11 }, /* Compaq Armada */ { TYPE_MAESTRO2E, 0x1028 }, { TYPE_MAESTRO2E, 0x103c }, @@ -2642,7 +2642,7 @@ static const struct ess_device_list pm_whitelist[] = { { TYPE_MAESTRO2, 0x125d }, /* a PCI card, e.g. SF64-PCE2 */ }; -static const struct ess_device_list mpu_blacklist[] = { +static const struct ess_device_list mpu_denylist[] = { { TYPE_MAESTRO2, 0x125d }, }; @@ -2724,12 +2724,12 @@ static int snd_es1968_create(struct snd_card *card, pci_set_master(pci); if (do_pm > 1) { - /* disable power-management if not on the whitelist */ + /* disable power-management if not on the allowlist */ unsigned short vend; pci_read_config_word(chip->pci, PCI_SUBSYSTEM_VENDOR_ID, &vend); - for (i = 0; i < (int)ARRAY_SIZE(pm_whitelist); i++) { - if (chip->type == pm_whitelist[i].type && - vend == pm_whitelist[i].vendor) { + for (i = 0; i < (int)ARRAY_SIZE(pm_allowlist); i++) { + if (chip->type == pm_allowlist[i].type && + vend == pm_allowlist[i].vendor) { do_pm = 1; break; } @@ -2848,12 +2848,12 @@ static int snd_es1968_probe(struct pci_dev *pci, } if (enable_mpu[dev] == 2) { - /* check the black list */ + /* check the deny list */ unsigned short vend; pci_read_config_word(chip->pci, PCI_SUBSYSTEM_VENDOR_ID, &vend); - for (i = 0; i < ARRAY_SIZE(mpu_blacklist); i++) { - if (chip->type == mpu_blacklist[i].type && - vend == mpu_blacklist[i].vendor) { + for (i = 0; i < ARRAY_SIZE(mpu_denylist); i++) { + if (chip->type == mpu_denylist[i].type && + vend == mpu_denylist[i].vendor) { enable_mpu[dev] = 0; break; } diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 181ebafa550a..0a95032fd297 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -144,6 +144,8 @@ MODULE_PARM_DESC(radio_nr, "Radio device numbers"); /** * struct fm801 - describes FM801 chip + * @dev: device for this chio + * @irq: irq number * @port: I/O port number * @multichannel: multichannel support * @secondary: secondary codec @@ -151,6 +153,31 @@ MODULE_PARM_DESC(radio_nr, "Radio device numbers"); * @tea575x_tuner: tuner access method & flags * @ply_ctrl: playback control * @cap_ctrl: capture control + * @ply_buffer: playback buffer + * @ply_buf: playback buffer index + * @ply_count: playback buffer count + * @ply_size: playback buffer size + * @ply_pos: playback position + * @cap_buffer: capture buffer + * @cap_buf: capture buffer index + * @cap_count: capture buffer count + * @cap_size: capture buffer size + * @cap_pos: capture position + * @ac97_bus: ac97 bus handle + * @ac97: ac97 handle + * @ac97_sec: ac97 secondary handle + * @card: ALSA card + * @pcm: PCM devices + * @rmidi: rmidi device + * @playback_substream: substream for playback + * @capture_substream: substream for capture + * @p_dma_size: playback DMA size + * @c_dma_size: capture DMA size + * @reg_lock: lock + * @proc_entry: /proc entry + * @v4l2_dev: v4l2 device + * @tea: tea575a structure + * @saved_regs: context saved during suspend */ struct fm801 { struct device *dev; diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index 7ba542e45a3d..90759391cbac 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig @@ -8,6 +8,9 @@ config SND_HDA select SND_JACK select SND_HDA_CORE +config SND_HDA_GENERIC_LEDS + bool + config SND_HDA_INTEL tristate "HD Audio PCI" depends on SND_PCI @@ -91,6 +94,7 @@ config SND_HDA_PATCH_LOADER config SND_HDA_CODEC_REALTEK tristate "Build Realtek HD-audio codec support" select SND_HDA_GENERIC + select SND_HDA_GENERIC_LEDS help Say Y or M here to include Realtek HD-audio codec support in snd-hda-intel driver, such as ALC880. @@ -111,6 +115,7 @@ comment "Set to Y if you want auto-loading the codec driver" config SND_HDA_CODEC_SIGMATEL tristate "Build IDT/Sigmatel HD-audio codec support" select SND_HDA_GENERIC + select SND_HDA_GENERIC_LEDS help Say Y or M here to include IDT (Sigmatel) HD-audio codec support in snd-hda-intel driver, such as STAC9200. @@ -155,6 +160,7 @@ comment "Set to Y if you want auto-loading the codec driver" config SND_HDA_CODEC_CONEXANT tristate "Build Conexant HD-audio codec support" select SND_HDA_GENERIC + select SND_HDA_GENERIC_LEDS help Say Y or M here to include Conexant HD-audio codec support in snd-hda-intel driver, such as CX20549. @@ -215,6 +221,10 @@ comment "Set to Y if you want auto-loading the codec driver" config SND_HDA_GENERIC tristate "Enable generic HD-audio codec parser" + select NEW_LEDS if SND_HDA_GENERIC_LEDS + select LEDS_CLASS if SND_HDA_GENERIC_LEDS + select LEDS_TRIGGERS if SND_HDA_GENERIC_LEDS + select LEDS_TRIGGER_AUDIO if SND_HDA_GENERIC_LEDS help Say Y or M here to enable the generic HD-audio codec parser in snd-hda-intel driver. @@ -230,6 +240,20 @@ config SND_HDA_POWER_SAVE_DEFAULT The default time-out value in seconds for HD-audio automatic power-save mode. 0 means to disable the power-save mode. +config SND_HDA_INTEL_HDMI_SILENT_STREAM + bool "Enable Silent Stream always for HDMI" + depends on SND_HDA_INTEL + help + Intel hardware has a feature called 'silent stream', that + keeps external HDMI receiver's analog circuitry powered on + avoiding 2-3 sec silence during playback start. This mechanism + relies on setting channel_id as 0xf, sending info packet and + preventing codec D3 entry (increasing platform static power + consumption when HDMI receiver is plugged-in). 2-3 sec silence + at the playback start is expected whenever there is format change. + (default is 2 channel format). + Say Y to enable Silent Stream feature. + endif endmenu diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index 841523f6b88d..53a2b89f8983 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c @@ -102,7 +102,7 @@ static int snd_hda_beep_event(struct input_dev *dev, unsigned int type, case SND_BELL: if (hz) hz = 1000; - /* fallthru */ + fallthrough; case SND_TONE: if (beep->linear_tone) beep->tone = beep_linear_tone(beep, hz); diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 803978d69e3c..e96a87f1b611 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -785,13 +785,14 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec) snd_array_free(&codec->spdif_out); snd_array_free(&codec->verbs); codec->preset = NULL; - codec->slave_dig_outs = NULL; + codec->follower_dig_outs = NULL; codec->spdif_status_reset = 0; snd_array_free(&codec->mixers); snd_array_free(&codec->nids); remove_conn_list(codec); snd_hdac_regmap_exit(&codec->core); } +EXPORT_SYMBOL_GPL(snd_hda_codec_cleanup_for_unbind); static unsigned int hda_set_power_state(struct hda_codec *codec, unsigned int power_state); @@ -1806,11 +1807,11 @@ int snd_hda_codec_reset(struct hda_codec *codec) return 0; } -typedef int (*map_slave_func_t)(struct hda_codec *, void *, struct snd_kcontrol *); +typedef int (*map_follower_func_t)(struct hda_codec *, void *, struct snd_kcontrol *); -/* apply the function to all matching slave ctls in the mixer list */ -static int map_slaves(struct hda_codec *codec, const char * const *slaves, - const char *suffix, map_slave_func_t func, void *data) +/* apply the function to all matching follower ctls in the mixer list */ +static int map_followers(struct hda_codec *codec, const char * const *followers, + const char *suffix, map_follower_func_t func, void *data) { struct hda_nid_item *items; const char * const *s; @@ -1821,7 +1822,7 @@ static int map_slaves(struct hda_codec *codec, const char * const *slaves, struct snd_kcontrol *sctl = items[i].kctl; if (!sctl || sctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER) continue; - for (s = slaves; *s; s++) { + for (s = followers; *s; s++) { char tmpname[sizeof(sctl->id.name)]; const char *name = *s; if (suffix) { @@ -1840,8 +1841,8 @@ static int map_slaves(struct hda_codec *codec, const char * const *slaves, return 0; } -static int check_slave_present(struct hda_codec *codec, - void *data, struct snd_kcontrol *sctl) +static int check_follower_present(struct hda_codec *codec, + void *data, struct snd_kcontrol *sctl) { return 1; } @@ -1860,17 +1861,17 @@ static int put_kctl_with_value(struct snd_kcontrol *kctl, int val) return 0; } -struct slave_init_arg { +struct follower_init_arg { struct hda_codec *codec; int step; }; -/* initialize the slave volume with 0dB via snd_ctl_apply_vmaster_slaves() */ -static int init_slave_0dB(struct snd_kcontrol *slave, - struct snd_kcontrol *kctl, - void *_arg) +/* initialize the follower volume with 0dB via snd_ctl_apply_vmaster_followers() */ +static int init_follower_0dB(struct snd_kcontrol *follower, + struct snd_kcontrol *kctl, + void *_arg) { - struct slave_init_arg *arg = _arg; + struct follower_init_arg *arg = _arg; int _tlv[4]; const int *tlv = NULL; int step; @@ -1879,7 +1880,7 @@ static int init_slave_0dB(struct snd_kcontrol *slave, if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { if (kctl->tlv.c != snd_hda_mixer_amp_tlv) { codec_err(arg->codec, - "Unexpected TLV callback for slave %s:%d\n", + "Unexpected TLV callback for follower %s:%d\n", kctl->id.name, kctl->id.index); return 0; /* ignore */ } @@ -1897,7 +1898,7 @@ static int init_slave_0dB(struct snd_kcontrol *slave, return 0; if (arg->step && arg->step != step) { codec_err(arg->codec, - "Mismatching dB step for vmaster slave (%d!=%d)\n", + "Mismatching dB step for vmaster follower (%d!=%d)\n", arg->step, step); return 0; } @@ -1905,49 +1906,49 @@ static int init_slave_0dB(struct snd_kcontrol *slave, arg->step = step; val = -tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] / step; if (val > 0) { - put_kctl_with_value(slave, val); + put_kctl_with_value(follower, val); return val; } return 0; } -/* unmute the slave via snd_ctl_apply_vmaster_slaves() */ -static int init_slave_unmute(struct snd_kcontrol *slave, - struct snd_kcontrol *kctl, - void *_arg) +/* unmute the follower via snd_ctl_apply_vmaster_followers() */ +static int init_follower_unmute(struct snd_kcontrol *follower, + struct snd_kcontrol *kctl, + void *_arg) { - return put_kctl_with_value(slave, 1); + return put_kctl_with_value(follower, 1); } -static int add_slave(struct hda_codec *codec, - void *data, struct snd_kcontrol *slave) +static int add_follower(struct hda_codec *codec, + void *data, struct snd_kcontrol *follower) { - return snd_ctl_add_slave(data, slave); + return snd_ctl_add_follower(data, follower); } /** - * __snd_hda_add_vmaster - create a virtual master control and add slaves + * __snd_hda_add_vmaster - create a virtual master control and add followers * @codec: HD-audio codec * @name: vmaster control name * @tlv: TLV data (optional) - * @slaves: slave control names (optional) - * @suffix: suffix string to each slave name (optional) - * @init_slave_vol: initialize slaves to unmute/0dB + * @followers: follower control names (optional) + * @suffix: suffix string to each follower name (optional) + * @init_follower_vol: initialize followers to unmute/0dB * @ctl_ret: store the vmaster kcontrol in return * * Create a virtual master control with the given name. The TLV data * must be either NULL or a valid data. * - * @slaves is a NULL-terminated array of strings, each of which is a - * slave control name. All controls with these names are assigned to + * @followers is a NULL-terminated array of strings, each of which is a + * follower control name. All controls with these names are assigned to * the new virtual master control. * * This function returns zero if successful or a negative error code. */ int __snd_hda_add_vmaster(struct hda_codec *codec, char *name, - unsigned int *tlv, const char * const *slaves, - const char *suffix, bool init_slave_vol, + unsigned int *tlv, const char * const *followers, + const char *suffix, bool init_follower_vol, struct snd_kcontrol **ctl_ret) { struct snd_kcontrol *kctl; @@ -1956,9 +1957,9 @@ int __snd_hda_add_vmaster(struct hda_codec *codec, char *name, if (ctl_ret) *ctl_ret = NULL; - err = map_slaves(codec, slaves, suffix, check_slave_present, NULL); + err = map_followers(codec, followers, suffix, check_follower_present, NULL); if (err != 1) { - codec_dbg(codec, "No slave found for %s\n", name); + codec_dbg(codec, "No follower found for %s\n", name); return 0; } kctl = snd_ctl_make_virtual_master(name, tlv); @@ -1968,20 +1969,20 @@ int __snd_hda_add_vmaster(struct hda_codec *codec, char *name, if (err < 0) return err; - err = map_slaves(codec, slaves, suffix, add_slave, kctl); + err = map_followers(codec, followers, suffix, add_follower, kctl); if (err < 0) return err; /* init with master mute & zero volume */ put_kctl_with_value(kctl, 0); - if (init_slave_vol) { - struct slave_init_arg arg = { + if (init_follower_vol) { + struct follower_init_arg arg = { .codec = codec, .step = 0, }; - snd_ctl_apply_vmaster_slaves(kctl, - tlv ? init_slave_0dB : init_slave_unmute, - &arg); + snd_ctl_apply_vmaster_followers(kctl, + tlv ? init_follower_0dB : init_follower_unmute, + &arg); } if (ctl_ret) @@ -2284,7 +2285,7 @@ static unsigned int convert_to_spdif_status(unsigned short val) return sbits; } -/* set digital convert verbs both for the given NID and its slaves */ +/* set digital convert verbs both for the given NID and its followers */ static void set_dig_out(struct hda_codec *codec, hda_nid_t nid, int mask, int val) { @@ -2292,7 +2293,7 @@ static void set_dig_out(struct hda_codec *codec, hda_nid_t nid, snd_hdac_regmap_update(&codec->core, nid, AC_VERB_SET_DIGI_CONVERT_1, mask, val); - d = codec->slave_dig_outs; + d = codec->follower_dig_outs; if (!d) return; for (; *d; d++) @@ -3186,7 +3187,7 @@ int snd_hda_codec_prepare(struct hda_codec *codec, EXPORT_SYMBOL_GPL(snd_hda_codec_prepare); /** - * snd_hda_codec_cleanup - Prepare a stream + * snd_hda_codec_cleanup - Clean up stream resources * @codec: the HDA codec * @hinfo: PCM information * @substream: PCM substream @@ -3427,7 +3428,7 @@ EXPORT_SYMBOL_GPL(snd_hda_set_power_save); * @nid: NID to check / update * * Check whether the given NID is in the amp list. If it's in the list, - * check the current AMP status, and update the the power-status according + * check the current AMP status, and update the power-status according * to the mute status. * * This function is supposed to be set or called from the check_power_status @@ -3588,9 +3589,9 @@ static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid, spdif->ctls & ~AC_DIG1_ENABLE & 0xff, -1); snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); - if (codec->slave_dig_outs) { + if (codec->follower_dig_outs) { const hda_nid_t *d; - for (d = codec->slave_dig_outs; *d; d++) + for (d = codec->follower_dig_outs; *d; d++) snd_hda_codec_setup_stream(codec, *d, stream_tag, 0, format); } @@ -3603,9 +3604,9 @@ static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid, static void cleanup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid) { snd_hda_codec_cleanup_stream(codec, nid); - if (codec->slave_dig_outs) { + if (codec->follower_dig_outs) { const hda_nid_t *d; - for (d = codec->slave_dig_outs; *d; d++) + for (d = codec->follower_dig_outs; *d; d++) snd_hda_codec_cleanup_stream(codec, *d); } } @@ -3687,7 +3688,7 @@ EXPORT_SYMBOL_GPL(snd_hda_multi_out_dig_close); * @hinfo: PCM information to assign * * Open analog outputs and set up the hw-constraints. - * If the digital outputs can be opened as slave, open the digital + * If the digital outputs can be opened as follower, open the digital * outputs, too. */ int snd_hda_multi_out_analog_open(struct hda_codec *codec, diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index 9765652a73d7..80016b7b6849 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -1202,15 +1202,8 @@ int azx_bus_init(struct azx *chip, const char *model) if (chip->driver_caps & AZX_DCAPS_4K_BDLE_BOUNDARY) bus->core.align_bdle_4k = true; - /* AMD chipsets often cause the communication stalls upon certain - * sequence like the pin-detection. It seems that forcing the synced - * access works around the stall. Grrr... - */ - if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) { - dev_dbg(chip->card->dev, "Enable sync_write for stable communication\n"); - bus->core.sync_write = 1; - bus->allow_bus_reset = 1; - } + /* enable sync_write flag for stable communication as default */ + bus->core.sync_write = 1; return 0; } diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h index a356fb0e5773..be63ead8161f 100644 --- a/sound/pci/hda/hda_controller.h +++ b/sound/pci/hda/hda_controller.h @@ -33,7 +33,7 @@ #define AZX_DCAPS_POSFIX_LPIB (1 << 16) /* Use LPIB as default */ #define AZX_DCAPS_AMD_WORKAROUND (1 << 17) /* AMD-specific workaround */ #define AZX_DCAPS_NO_64BIT (1 << 18) /* No 64bit address */ -#define AZX_DCAPS_SYNC_WRITE (1 << 19) /* sync each cmd write */ +/* 19 unused */ #define AZX_DCAPS_OLD_SSYNC (1 << 20) /* Old SSYNC reg for ICH */ #define AZX_DCAPS_NO_ALIGN_BUFSIZE (1 << 21) /* no buffer size alignment */ /* 22 unused */ diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index f4e9d9445e18..bbb17481159e 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -813,7 +813,7 @@ static void activate_amp_in(struct hda_codec *codec, struct nid_path *path, } } -/* sync power of each widget in the the given path */ +/* sync power of each widget in the given path */ static hda_nid_t path_power_update(struct hda_codec *codec, struct nid_path *path, bool allow_powerdown) @@ -3887,6 +3887,66 @@ static int parse_mic_boost(struct hda_codec *codec) return 0; } +#ifdef CONFIG_SND_HDA_GENERIC_LEDS +/* + * vmaster mute LED hook helpers + */ + +static int create_mute_led_cdev(struct hda_codec *codec, + int (*callback)(struct led_classdev *, + enum led_brightness), + bool micmute) +{ + struct led_classdev *cdev; + + cdev = devm_kzalloc(&codec->core.dev, sizeof(*cdev), GFP_KERNEL); + if (!cdev) + return -ENOMEM; + + cdev->name = micmute ? "hda::micmute" : "hda::mute"; + cdev->max_brightness = 1; + cdev->default_trigger = micmute ? "audio-micmute" : "audio-mute"; + cdev->brightness_set_blocking = callback; + cdev->brightness = ledtrig_audio_get(micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE); + cdev->flags = LED_CORE_SUSPENDRESUME; + + return devm_led_classdev_register(&codec->core.dev, cdev); +} + +static void vmaster_update_mute_led(void *private_data, int enabled) +{ + ledtrig_audio_set(LED_AUDIO_MUTE, enabled ? LED_OFF : LED_ON); +} + +/** + * snd_dha_gen_add_mute_led_cdev - Create a LED classdev and enable as vmaster mute LED + * @codec: the HDA codec + * @callback: the callback for LED classdev brightness_set_blocking + */ +int snd_hda_gen_add_mute_led_cdev(struct hda_codec *codec, + int (*callback)(struct led_classdev *, + enum led_brightness)) +{ + struct hda_gen_spec *spec = codec->spec; + int err; + + if (callback) { + err = create_mute_led_cdev(codec, callback, false); + if (err) { + codec_warn(codec, "failed to create a mute LED cdev\n"); + return err; + } + } + + if (spec->vmaster_mute.hook) + codec_err(codec, "vmaster hook already present before cdev!\n"); + + spec->vmaster_mute.hook = vmaster_update_mute_led; + spec->vmaster_mute_enum = 1; + return 0; +} +EXPORT_SYMBOL_GPL(snd_hda_gen_add_mute_led_cdev); + /* * mic mute LED hook helpers */ @@ -3921,8 +3981,8 @@ static void call_micmute_led_update(struct hda_codec *codec) if (val == spec->micmute_led.led_value) return; spec->micmute_led.led_value = val; - if (spec->micmute_led.update) - spec->micmute_led.update(codec); + ledtrig_audio_set(LED_AUDIO_MICMUTE, + spec->micmute_led.led_value ? LED_ON : LED_OFF); } static void update_micmute_led(struct hda_codec *codec, @@ -3994,20 +4054,8 @@ static const struct snd_kcontrol_new micmute_led_mode_ctl = { .put = micmute_led_mode_put, }; -/** - * snd_hda_gen_add_micmute_led - helper for setting up mic mute LED hook - * @codec: the HDA codec - * @hook: the callback for updating LED - * - * Called from the codec drivers for offering the mic mute LED controls. - * When established, it sets up cap_sync_hook and triggers the callback at - * each time when the capture mixer switch changes. The callback is supposed - * to update the LED accordingly. - * - * Returns 0 if the hook is established or a negative error code. - */ -int snd_hda_gen_add_micmute_led(struct hda_codec *codec, - void (*hook)(struct hda_codec *)) +/* Set up the capture sync hook for controlling the mic-mute LED */ +static int add_micmute_led_hook(struct hda_codec *codec) { struct hda_gen_spec *spec = codec->spec; @@ -4015,48 +4063,44 @@ int snd_hda_gen_add_micmute_led(struct hda_codec *codec, spec->micmute_led.capture = 0; spec->micmute_led.led_value = 0; spec->micmute_led.old_hook = spec->cap_sync_hook; - spec->micmute_led.update = hook; spec->cap_sync_hook = update_micmute_led; if (!snd_hda_gen_add_kctl(spec, NULL, &micmute_led_mode_ctl)) return -ENOMEM; return 0; } -EXPORT_SYMBOL_GPL(snd_hda_gen_add_micmute_led); - -#if IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO) -static void call_ledtrig_micmute(struct hda_codec *codec) -{ - struct hda_gen_spec *spec = codec->spec; - - ledtrig_audio_set(LED_AUDIO_MICMUTE, - spec->micmute_led.led_value ? LED_ON : LED_OFF); -} -#endif /** - * snd_hda_gen_fixup_micmute_led - A fixup for mic-mute LED trigger - * - * Pass this function to the quirk entry if another driver supports the - * audio mic-mute LED trigger. Then this will bind the mixer capture switch - * change with the LED. + * snd_dha_gen_add_micmute_led_cdev - Create a LED classdev and enable as mic-mute LED + * @codec: the HDA codec + * @callback: the callback for LED classdev brightness_set_blocking * - * Note that this fixup has to be called after other fixup that sets - * cap_sync_hook. Otherwise the chaining wouldn't work. + * Called from the codec drivers for offering the mic mute LED controls. + * This creates a LED classdev and sets up the cap_sync_hook that is called at + * each time when the capture mixer switch changes. * - * @codec: the HDA codec - * @fix: fixup pointer - * @action: only supports HDA_FIXUP_ACT_PROBE value + * When NULL is passed to @callback, no classdev is created but only the + * LED-trigger is set up. * + * Returns 0 or a negative error. */ -void snd_hda_gen_fixup_micmute_led(struct hda_codec *codec, - const struct hda_fixup *fix, int action) +int snd_hda_gen_add_micmute_led_cdev(struct hda_codec *codec, + int (*callback)(struct led_classdev *, + enum led_brightness)) { -#if IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO) - if (action == HDA_FIXUP_ACT_PROBE) - snd_hda_gen_add_micmute_led(codec, call_ledtrig_micmute); -#endif + int err; + + if (callback) { + err = create_mute_led_cdev(codec, callback, true); + if (err) { + codec_warn(codec, "failed to create a mic-mute LED cdev\n"); + return err; + } + } + + return add_micmute_led_hook(codec); } -EXPORT_SYMBOL_GPL(snd_hda_gen_fixup_micmute_led); +EXPORT_SYMBOL_GPL(snd_hda_gen_add_micmute_led_cdev); +#endif /* CONFIG_SND_HDA_GENERIC_LEDS */ /* * parse digital I/Os and set up NIDs in BIOS auto-parse mode @@ -4068,7 +4112,7 @@ static void parse_digital(struct hda_codec *codec) int i, nums; hda_nid_t dig_nid, pin; - /* support multiple SPDIFs; the secondary is set up as a slave */ + /* support multiple SPDIFs; the secondary is set up as a follower */ nums = 0; for (i = 0; i < spec->autocfg.dig_outs; i++) { pin = spec->autocfg.dig_out_pins[i]; @@ -4087,10 +4131,10 @@ static void parse_digital(struct hda_codec *codec) spec->multiout.dig_out_nid = dig_nid; spec->dig_out_type = spec->autocfg.dig_out_type[0]; } else { - spec->multiout.slave_dig_outs = spec->slave_dig_outs; - if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) + spec->multiout.follower_dig_outs = spec->follower_dig_outs; + if (nums >= ARRAY_SIZE(spec->follower_dig_outs) - 1) break; - spec->slave_dig_outs[nums - 1] = dig_nid; + spec->follower_dig_outs[nums - 1] = dig_nid; } nums++; } @@ -4545,7 +4589,7 @@ static void call_update_outputs(struct hda_codec *codec) else snd_hda_gen_update_outputs(codec); - /* sync the whole vmaster slaves to reflect the new auto-mute status */ + /* sync the whole vmaster followers to reflect the new auto-mute status */ if (spec->auto_mute_via_amp && !codec->bus->shutdown) snd_ctl_sync_vmaster(spec->vmaster_mute.sw_kctl, false); } @@ -5189,8 +5233,8 @@ EXPORT_SYMBOL_GPL(snd_hda_gen_parse_auto_config); * Build control elements */ -/* slave controls for virtual master */ -static const char * const slave_pfxs[] = { +/* follower controls for virtual master */ +static const char * const follower_pfxs[] = { "Front", "Surround", "Center", "LFE", "Side", "Headphone", "Speaker", "Mono", "Line Out", "CLFE", "Bass Speaker", "PCM", @@ -5242,7 +5286,7 @@ int snd_hda_gen_build_controls(struct hda_codec *codec) if (!spec->no_analog && !spec->suppress_vmaster && !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { err = snd_hda_add_vmaster(codec, "Master Playback Volume", - spec->vmaster_tlv, slave_pfxs, + spec->vmaster_tlv, follower_pfxs, "Playback Volume"); if (err < 0) return err; @@ -5250,7 +5294,7 @@ int snd_hda_gen_build_controls(struct hda_codec *codec) if (!spec->no_analog && !spec->suppress_vmaster && !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { err = __snd_hda_add_vmaster(codec, "Master Playback Switch", - NULL, slave_pfxs, + NULL, follower_pfxs, "Playback Switch", true, &spec->vmaster_mute.sw_kctl); if (err < 0) @@ -5765,7 +5809,7 @@ int snd_hda_gen_build_pcms(struct hda_codec *codec) spec->stream_name_digital); if (!info) return -ENOMEM; - codec->slave_dig_outs = spec->multiout.slave_dig_outs; + codec->follower_dig_outs = spec->multiout.follower_dig_outs; spec->pcm_rec[1] = info; if (spec->dig_out_type) info->pcm_type = spec->dig_out_type; diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h index fb9f1a90238b..a43f0bb77dae 100644 --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h @@ -8,6 +8,8 @@ #ifndef __SOUND_HDA_GENERIC_H #define __SOUND_HDA_GENERIC_H +#include <linux/leds.h> + /* table entry for multi-io paths */ struct hda_multi_io { hda_nid_t pin; /* multi-io widget pin NID */ @@ -86,7 +88,6 @@ struct hda_micmute_hook { unsigned int led_mode; unsigned int capture; unsigned int led_value; - void (*update)(struct hda_codec *codec); void (*old_hook)(struct hda_codec *codec, struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); @@ -115,7 +116,7 @@ struct hda_gen_spec { * dig_out_nid and hp_nid are optional */ hda_nid_t alt_dac_nid; - hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ + hda_nid_t follower_dig_outs[3]; /* optional - for auto-parsing */ int dig_out_type; /* capture */ @@ -353,9 +354,11 @@ unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec, void snd_hda_gen_stream_pm(struct hda_codec *codec, hda_nid_t nid, bool on); int snd_hda_gen_fix_pin_power(struct hda_codec *codec, hda_nid_t pin); -int snd_hda_gen_add_micmute_led(struct hda_codec *codec, - void (*hook)(struct hda_codec *)); -void snd_hda_gen_fixup_micmute_led(struct hda_codec *codec, - const struct hda_fixup *fix, int action); +int snd_hda_gen_add_mute_led_cdev(struct hda_codec *codec, + int (*callback)(struct led_classdev *, + enum led_brightness)); +int snd_hda_gen_add_micmute_led_cdev(struct hda_codec *codec, + int (*callback)(struct led_classdev *, + enum led_brightness)); #endif /* __SOUND_HDA_GENERIC_H */ diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 3fbba2e51e36..e34a4d5d047c 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -180,7 +180,7 @@ MODULE_PARM_DESC(power_save, "Automatic power-saving timeout " static bool pm_blacklist = true; module_param(pm_blacklist, bool, 0644); -MODULE_PARM_DESC(pm_blacklist, "Enable power-management blacklist"); +MODULE_PARM_DESC(pm_blacklist, "Enable power-management denylist"); /* reset the HD-audio controller in power save mode. * this may give more power-saving, but will take longer time to @@ -283,13 +283,12 @@ enum { /* quirks for old Intel chipsets */ #define AZX_DCAPS_INTEL_ICH \ - (AZX_DCAPS_OLD_SSYNC | AZX_DCAPS_NO_ALIGN_BUFSIZE |\ - AZX_DCAPS_SYNC_WRITE) + (AZX_DCAPS_OLD_SSYNC | AZX_DCAPS_NO_ALIGN_BUFSIZE) /* quirks for Intel PCH */ #define AZX_DCAPS_INTEL_PCH_BASE \ (AZX_DCAPS_NO_ALIGN_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY |\ - AZX_DCAPS_SNOOP_TYPE(SCH) | AZX_DCAPS_SYNC_WRITE) + AZX_DCAPS_SNOOP_TYPE(SCH)) /* PCH up to IVB; no runtime PM; bind with i915 gfx */ #define AZX_DCAPS_INTEL_PCH_NOPM \ @@ -305,13 +304,13 @@ enum { #define AZX_DCAPS_INTEL_HASWELL \ (/*AZX_DCAPS_ALIGN_BUFSIZE |*/ AZX_DCAPS_COUNT_LPIB_DELAY |\ AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_COMPONENT |\ - AZX_DCAPS_SNOOP_TYPE(SCH) | AZX_DCAPS_SYNC_WRITE) + AZX_DCAPS_SNOOP_TYPE(SCH)) /* Broadwell HDMI can't use position buffer reliably, force to use LPIB */ #define AZX_DCAPS_INTEL_BROADWELL \ (/*AZX_DCAPS_ALIGN_BUFSIZE |*/ AZX_DCAPS_POSFIX_LPIB |\ AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_COMPONENT |\ - AZX_DCAPS_SNOOP_TYPE(SCH) | AZX_DCAPS_SYNC_WRITE) + AZX_DCAPS_SNOOP_TYPE(SCH)) #define AZX_DCAPS_INTEL_BAYTRAIL \ (AZX_DCAPS_INTEL_PCH_BASE | AZX_DCAPS_I915_COMPONENT) @@ -322,19 +321,18 @@ enum { #define AZX_DCAPS_INTEL_SKYLAKE \ (AZX_DCAPS_INTEL_PCH_BASE | AZX_DCAPS_PM_RUNTIME |\ - AZX_DCAPS_SYNC_WRITE |\ AZX_DCAPS_SEPARATE_STREAM_TAG | AZX_DCAPS_I915_COMPONENT) #define AZX_DCAPS_INTEL_BROXTON AZX_DCAPS_INTEL_SKYLAKE /* quirks for ATI SB / AMD Hudson */ #define AZX_DCAPS_PRESET_ATI_SB \ - (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB |\ + (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_POSFIX_LPIB |\ AZX_DCAPS_SNOOP_TYPE(ATI)) /* quirks for ATI/AMD HDMI */ #define AZX_DCAPS_PRESET_ATI_HDMI \ - (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB|\ + (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_POSFIX_LPIB|\ AZX_DCAPS_NO_MSI64) /* quirks for ATI HDMI with snoop off */ @@ -343,7 +341,7 @@ enum { /* quirks for AMD SB */ #define AZX_DCAPS_PRESET_AMD_SB \ - (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_AMD_WORKAROUND |\ + (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_AMD_WORKAROUND |\ AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME) /* quirks for Nvidia */ @@ -1519,7 +1517,7 @@ static bool check_hdmi_disabled(struct pci_dev *pci) #endif /* SUPPORT_VGA_SWITCHEROO */ /* - * white/black-listing for position_fix + * allow/deny-listing for position_fix */ static const struct snd_pci_quirk position_fix_list[] = { SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB), @@ -1612,7 +1610,7 @@ static void assign_position_fix(struct azx *chip, int fix) } /* - * black-lists for probe_mask + * deny-lists for probe_mask */ static const struct snd_pci_quirk probe_mask_list[] = { /* Thinkpad often breaks the controller communication when accessing @@ -1660,9 +1658,9 @@ static void check_probe_mask(struct azx *chip, int dev) } /* - * white/black-list for enable_msi + * allow/deny-list for enable_msi */ -static const struct snd_pci_quirk msi_black_list[] = { +static const struct snd_pci_quirk msi_deny_list[] = { SND_PCI_QUIRK(0x103c, 0x2191, "HP", 0), /* AMD Hudson */ SND_PCI_QUIRK(0x103c, 0x2192, "HP", 0), /* AMD Hudson */ SND_PCI_QUIRK(0x103c, 0x21f7, "HP", 0), /* AMD Hudson */ @@ -1685,7 +1683,7 @@ static void check_msi(struct azx *chip) return; } chip->msi = 1; /* enable MSI as default */ - q = snd_pci_quirk_lookup(chip->pci, msi_black_list); + q = snd_pci_quirk_lookup(chip->pci, msi_deny_list); if (q) { dev_info(chip->card->dev, "msi for device %04x:%04x set to %d\n", @@ -2085,11 +2083,11 @@ static void pcm_mmap_prepare(struct snd_pcm_substream *substream, #endif } -/* Blacklist for skipping the whole probe: +/* Denylist for skipping the whole probe: * some HD-audio PCI entries are exposed without any codecs, and such devices * should be ignored from the beginning. */ -static const struct pci_device_id driver_blacklist[] = { +static const struct pci_device_id driver_denylist[] = { { PCI_DEVICE_SUB(0x1022, 0x1487, 0x1043, 0x874f) }, /* ASUS ROG Zenith II / Strix */ { PCI_DEVICE_SUB(0x1022, 0x1487, 0x1462, 0xcb59) }, /* MSI TRX40 Creator */ { PCI_DEVICE_SUB(0x1022, 0x1487, 0x1462, 0xcb60) }, /* MSI TRX40 */ @@ -2112,8 +2110,8 @@ static int azx_probe(struct pci_dev *pci, bool schedule_probe; int err; - if (pci_match_id(driver_blacklist, pci)) { - dev_info(&pci->dev, "Skipping the blacklisted device\n"); + if (pci_match_id(driver_denylist, pci)) { + dev_info(&pci->dev, "Skipping the device on the denylist\n"); return -ENODEV; } @@ -2203,7 +2201,7 @@ out_free: * So we keep a list of devices where we disable powersaving as its known * to causes problems on these devices. */ -static const struct snd_pci_quirk power_save_blacklist[] = { +static const struct snd_pci_quirk power_save_denylist[] = { /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0), /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ @@ -2249,9 +2247,9 @@ static void set_default_power_save(struct azx *chip) if (pm_blacklist) { const struct snd_pci_quirk *q; - q = snd_pci_quirk_lookup(chip->pci, power_save_blacklist); + q = snd_pci_quirk_lookup(chip->pci, power_save_denylist); if (q && val) { - dev_info(chip->card->dev, "device %04x:%04x is on the power_save blacklist, forcing power_save to 0\n", + dev_info(chip->card->dev, "device %04x:%04x is on the power_save denylist, forcing power_save to 0\n", q->subvendor, q->subdevice); val = 0; } @@ -2354,7 +2352,6 @@ static int azx_probe_continue(struct azx *chip) if (azx_has_pm_runtime(chip)) { pm_runtime_use_autosuspend(&pci->dev); - pm_runtime_allow(&pci->dev); pm_runtime_put_autosuspend(&pci->dev); } @@ -2748,6 +2745,8 @@ static const struct pci_device_id azx_ids[] = { .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_HDMI }, /* Zhaoxin */ { PCI_DEVICE(0x1d17, 0x3288), .driver_data = AZX_DRIVER_ZHAOXIN }, + /* Loongson */ + { PCI_DEVICE(0x0014, 0x7a07), .driver_data = AZX_DRIVER_GENERIC }, { 0, } }; MODULE_DEVICE_TABLE(pci, azx_ids); diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 3dca65d79b02..8c28b1022f49 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -129,11 +129,11 @@ void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir, struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec, const char *name); int __snd_hda_add_vmaster(struct hda_codec *codec, char *name, - unsigned int *tlv, const char * const *slaves, - const char *suffix, bool init_slave_vol, + unsigned int *tlv, const char * const *followers, + const char *suffix, bool init_follower_vol, struct snd_kcontrol **ctl_ret); -#define snd_hda_add_vmaster(codec, name, tlv, slaves, suffix) \ - __snd_hda_add_vmaster(codec, name, tlv, slaves, suffix, true, NULL) +#define snd_hda_add_vmaster(codec, name, tlv, followers, suffix) \ + __snd_hda_add_vmaster(codec, name, tlv, followers, suffix, true, NULL) int snd_hda_codec_reset(struct hda_codec *codec); void snd_hda_codec_register(struct hda_codec *codec); void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec); @@ -216,7 +216,7 @@ struct hda_multi_out { hda_nid_t hp_out_nid[HDA_MAX_OUTS]; /* DACs for multiple HPs */ hda_nid_t extra_out_nid[HDA_MAX_OUTS]; /* other (e.g. speaker) DACs */ hda_nid_t dig_out_nid; /* digital out audio widget */ - const hda_nid_t *slave_dig_outs; + const hda_nid_t *follower_dig_outs; int max_channels; /* currently supported analog channels */ int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */ int no_share_stream; /* don't share a stream with multiple pins */ diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c index 0cc5fad1af8a..c94553bcca88 100644 --- a/sound/pci/hda/hda_tegra.c +++ b/sound/pci/hda/hda_tegra.c @@ -308,6 +308,7 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev) return err; } bus->irq = irq_id; + bus->dma_stop_delay = 100; card->sync_irq = bus->irq; /* @@ -333,6 +334,8 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev) gcap = azx_readw(chip, GCAP); dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); + chip->align_buffer_size = 1; + /* read number of streams from GCAP register instead of using * hardcoded value */ @@ -443,6 +446,7 @@ static int hda_tegra_create(struct snd_card *card, if (err < 0) return err; + chip->bus.core.sync_write = 0; chip->bus.core.needs_damn_long_delay = 1; chip->bus.core.aligned_mmio = 1; diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 34fe753a46fb..b7dbf2e7f77a 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -1182,6 +1182,7 @@ static const struct snd_pci_quirk ca0132_quirks[] = { SND_PCI_QUIRK(0x1458, 0xA036, "Gigabyte GA-Z170X-Gaming 7", QUIRK_R3DI), SND_PCI_QUIRK(0x3842, 0x1038, "EVGA X99 Classified", QUIRK_R3DI), SND_PCI_QUIRK(0x1102, 0x0013, "Recon3D", QUIRK_R3D), + SND_PCI_QUIRK(0x1102, 0x0018, "Recon3D", QUIRK_R3D), SND_PCI_QUIRK(0x1102, 0x0051, "Sound Blaster AE-5", QUIRK_AE5), {} }; @@ -4671,7 +4672,7 @@ static int ca0132_alt_select_in(struct hda_codec *codec) tmp = FLOAT_ONE; break; case QUIRK_AE5: - ca0113_mmio_command_set(codec, 0x48, 0x28, 0x00); + ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00); tmp = FLOAT_THREE; break; default: @@ -4717,7 +4718,7 @@ static int ca0132_alt_select_in(struct hda_codec *codec) r3di_gpio_mic_set(codec, R3DI_REAR_MIC); break; case QUIRK_AE5: - ca0113_mmio_command_set(codec, 0x48, 0x28, 0x00); + ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00); break; default: break; @@ -4756,7 +4757,7 @@ static int ca0132_alt_select_in(struct hda_codec *codec) tmp = FLOAT_ONE; break; case QUIRK_AE5: - ca0113_mmio_command_set(codec, 0x48, 0x28, 0x3f); + ca0113_mmio_command_set(codec, 0x30, 0x28, 0x3f); tmp = FLOAT_THREE; break; default: @@ -5748,6 +5749,11 @@ static int ca0132_switch_get(struct snd_kcontrol *kcontrol, return 0; } + if (nid == ZXR_HEADPHONE_GAIN) { + *valp = spec->zxr_gain_set; + return 0; + } + return 0; } @@ -6245,10 +6251,10 @@ static int zxr_add_headphone_gain_switch(struct hda_codec *codec) } /* - * Need to create slave controls for the alternate codecs that have surround + * Need to create follower controls for the alternate codecs that have surround * capabilities. */ -static const char * const ca0132_alt_slave_pfxs[] = { +static const char * const ca0132_alt_follower_pfxs[] = { "Front", "Surround", "Center", "LFE", NULL, }; @@ -6376,15 +6382,15 @@ static int ca0132_build_controls(struct hda_codec *codec) if (err < 0) return err; } - /* Setup vmaster with surround slaves for desktop ca0132 devices */ + /* Setup vmaster with surround followers for desktop ca0132 devices */ if (ca0132_use_alt_functions(spec)) { snd_hda_set_vmaster_tlv(codec, spec->dacs[0], HDA_OUTPUT, spec->tlv); snd_hda_add_vmaster(codec, "Master Playback Volume", - spec->tlv, ca0132_alt_slave_pfxs, + spec->tlv, ca0132_alt_follower_pfxs, "Playback Volume"); err = __snd_hda_add_vmaster(codec, "Master Playback Switch", - NULL, ca0132_alt_slave_pfxs, + NULL, ca0132_alt_follower_pfxs, "Playback Switch", true, &spec->vmaster_mute.sw_kctl); if (err < 0) diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 396b5503038a..be5000dd1585 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -137,14 +137,16 @@ static void cx_auto_vmaster_hook(void *private_data, int enabled) } /* turn on/off EAPD according to Master switch (inversely!) for mute LED */ -static void cx_auto_vmaster_hook_mute_led(void *private_data, int enabled) +static int cx_auto_vmaster_mute_led(struct led_classdev *led_cdev, + enum led_brightness brightness) { - struct hda_codec *codec = private_data; + struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); struct conexant_spec *spec = codec->spec; snd_hda_codec_write(codec, spec->mute_led_eapd, 0, AC_VERB_SET_EAPD_BTLENABLE, - enabled ? 0x00 : 0x02); + brightness ? 0x02 : 0x00); + return 0; } static int cx_auto_init(struct hda_codec *codec) @@ -566,7 +568,7 @@ static void cxt_fixup_mute_led_eapd(struct hda_codec *codec, if (action == HDA_FIXUP_ACT_PRE_PROBE) { spec->mute_led_eapd = 0x1b; spec->dynamic_eapd = 1; - spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook_mute_led; + snd_hda_gen_add_mute_led_cdev(codec, cx_auto_vmaster_mute_led); } } @@ -631,21 +633,25 @@ static void cxt_update_gpio_led(struct hda_codec *codec, unsigned int mask, } /* turn on/off mute LED via GPIO per vmaster hook */ -static void cxt_fixup_gpio_mute_hook(void *private_data, int enabled) +static int cxt_gpio_mute_update(struct led_classdev *led_cdev, + enum led_brightness brightness) { - struct hda_codec *codec = private_data; + struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); struct conexant_spec *spec = codec->spec; - /* muted -> LED on */ - cxt_update_gpio_led(codec, spec->gpio_mute_led_mask, !enabled); + + cxt_update_gpio_led(codec, spec->gpio_mute_led_mask, brightness); + return 0; } /* turn on/off mic-mute LED via GPIO per capture hook */ -static void cxt_gpio_micmute_update(struct hda_codec *codec) +static int cxt_gpio_micmute_update(struct led_classdev *led_cdev, + enum led_brightness brightness) { + struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); struct conexant_spec *spec = codec->spec; - cxt_update_gpio_led(codec, spec->gpio_mic_led_mask, - spec->gen.micmute_led.led_value); + cxt_update_gpio_led(codec, spec->gpio_mic_led_mask, brightness); + return 0; } @@ -660,12 +666,12 @@ static void cxt_fixup_mute_led_gpio(struct hda_codec *codec, }; if (action == HDA_FIXUP_ACT_PRE_PROBE) { - spec->gen.vmaster_mute.hook = cxt_fixup_gpio_mute_hook; + snd_hda_gen_add_mute_led_cdev(codec, cxt_gpio_mute_update); spec->gpio_led = 0; spec->mute_led_polarity = 0; spec->gpio_mute_led_mask = 0x01; spec->gpio_mic_led_mask = 0x02; - snd_hda_gen_add_micmute_led(codec, cxt_gpio_micmute_update); + snd_hda_gen_add_micmute_led_cdev(codec, cxt_gpio_micmute_update); } snd_hda_add_verbs(codec, gpio_init); if (spec->gpio_led) @@ -988,8 +994,6 @@ static int patch_conexant_auto(struct hda_codec *codec) cx_auto_parse_eapd(codec); spec->gen.own_eapd_ctl = 1; - if (spec->dynamic_eapd) - spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; switch (codec->core.vendor_id) { case 0x14f15045: @@ -1014,7 +1018,7 @@ static int patch_conexant_auto(struct hda_codec *codec) break; case 0x14f150f2: codec->power_save_node = 1; - /* Fall through */ + fallthrough; default: codec->pin_amp_workaround = 1; snd_hda_pick_fixup(codec, cxt5066_fixup_models, @@ -1022,17 +1026,8 @@ static int patch_conexant_auto(struct hda_codec *codec) break; } - /* Show mute-led control only on HP laptops - * This is a sort of white-list: on HP laptops, EAPD corresponds - * only to the mute-LED without actualy amp function. Meanwhile, - * others may use EAPD really as an amp switch, so it might be - * not good to expose it blindly. - */ - switch (codec->core.subsystem_id >> 16) { - case 0x103c: - spec->gen.vmaster_mute_enum = 1; - break; - } + if (!spec->gen.vmaster_mute.hook && spec->dynamic_eapd) + spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index cd46247988e4..4bbd12d3b1b5 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -42,6 +42,11 @@ static bool enable_acomp = true; module_param(enable_acomp, bool, 0444); MODULE_PARM_DESC(enable_acomp, "Enable audio component binding (default=yes)"); +static bool enable_silent_stream = +IS_ENABLED(CONFIG_SND_HDA_INTEL_HDMI_SILENT_STREAM); +module_param(enable_silent_stream, bool, 0644); +MODULE_PARM_DESC(enable_silent_stream, "Enable Silent Stream for HDMI devices"); + struct hdmi_spec_per_cvt { hda_nid_t cvt_nid; int assigned; @@ -160,6 +165,7 @@ struct hdmi_spec { bool use_acomp_notifier; /* use eld_notify callback for hotplug */ bool acomp_registered; /* audio component registered in this driver */ + bool force_connect; /* force connectivity */ struct drm_audio_component_audio_ops drm_audio_ops; int (*port2pin)(struct hda_codec *, int); /* reverse port/pin mapping */ @@ -167,6 +173,7 @@ struct hdmi_spec { hda_nid_t vendor_nid; const int *port_map; int port_num; + bool send_silent_stream; /* Flag to enable silent stream feature */ }; #ifdef CONFIG_SND_HDA_COMPONENT @@ -1635,21 +1642,72 @@ static void hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin, snd_hda_power_down_pm(codec); } +static void silent_stream_enable(struct hda_codec *codec, + struct hdmi_spec_per_pin *per_pin) +{ + unsigned int newval, oldval; + + codec_dbg(codec, "hdmi: enabling silent stream for NID %d\n", + per_pin->pin_nid); + + mutex_lock(&per_pin->lock); + + if (!per_pin->channels) + per_pin->channels = 2; + + oldval = snd_hda_codec_read(codec, per_pin->pin_nid, 0, + AC_VERB_GET_CONV, 0); + newval = (oldval & 0xF0) | 0xF; + snd_hda_codec_write(codec, per_pin->pin_nid, 0, + AC_VERB_SET_CHANNEL_STREAMID, newval); + + hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); + + mutex_unlock(&per_pin->lock); +} + /* update ELD and jack state via audio component */ static void sync_eld_via_acomp(struct hda_codec *codec, struct hdmi_spec_per_pin *per_pin) { struct hdmi_spec *spec = codec->spec; struct hdmi_eld *eld = &spec->temp_eld; + bool monitor_prev, monitor_next; mutex_lock(&per_pin->lock); eld->monitor_present = false; + monitor_prev = per_pin->sink_eld.monitor_present; eld->eld_size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, per_pin->dev_id, &eld->monitor_present, eld->eld_buffer, ELD_MAX_SIZE); eld->eld_valid = (eld->eld_size > 0); update_eld(codec, per_pin, eld, 0); + monitor_next = per_pin->sink_eld.monitor_present; mutex_unlock(&per_pin->lock); + + /* + * Power-up will call hdmi_present_sense, so the PM calls + * have to be done without mutex held. + */ + + if (spec->send_silent_stream) { + int pm_ret; + + if (!monitor_prev && monitor_next) { + pm_ret = snd_hda_power_up_pm(codec); + if (pm_ret < 0) + codec_err(codec, + "Monitor plugged-in, Failed to power up codec ret=[%d]\n", + pm_ret); + silent_stream_enable(codec, per_pin); + } else if (monitor_prev && !monitor_next) { + pm_ret = snd_hda_power_down_pm(codec); + if (pm_ret < 0) + codec_err(codec, + "Monitor plugged-out, Failed to power down codec ret=[%d]\n", + pm_ret); + } + } } static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) @@ -1701,7 +1759,8 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) * all device entries on the same pin */ config = snd_hda_codec_get_pincfg(codec, pin_nid); - if (get_defcfg_connect(config) == AC_JACK_PORT_NONE) + if (get_defcfg_connect(config) == AC_JACK_PORT_NONE && + !spec->force_connect) return 0; /* @@ -1803,11 +1862,18 @@ static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) return 0; } +static const struct snd_pci_quirk force_connect_list[] = { + SND_PCI_QUIRK(0x103c, 0x871a, "HP", 1), + {} +}; + static int hdmi_parse_codec(struct hda_codec *codec) { + struct hdmi_spec *spec = codec->spec; hda_nid_t start_nid; unsigned int caps; int i, nodes; + const struct snd_pci_quirk *q; nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid); if (!start_nid || nodes < 0) { @@ -1815,6 +1881,11 @@ static int hdmi_parse_codec(struct hda_codec *codec) return -EINVAL; } + q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list); + + if (q && q->value) + spec->force_connect = true; + /* * hdmi_add_pin() assumes total amount of converters to * be known, so first discover all converters @@ -2802,6 +2873,13 @@ static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, spec->ops.setup_stream = i915_hsw_setup_stream; spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; + /* + * Enable silent stream feature, if it is enabled via + * module param or Kconfig option + */ + if (enable_silent_stream) + spec->send_silent_stream = true; + return parse_intel_hdmi(codec); } diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 29f5878f0c50..2477f3ed7237 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -67,6 +67,13 @@ struct alc_customize_define { unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ }; +struct alc_coef_led { + unsigned int idx; + unsigned int mask; + unsigned int on; + unsigned int off; +}; + struct alc_spec { struct hda_gen_spec gen; /* must be at head */ @@ -80,7 +87,7 @@ struct alc_spec { unsigned int gpio_data; bool gpio_write_delay; /* add a delay before writing gpio_data */ - /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */ + /* mute LED for HP laptops, see vref_mute_led_set() */ int mute_led_polarity; int micmute_led_polarity; hda_nid_t mute_led_nid; @@ -88,14 +95,8 @@ struct alc_spec { unsigned int gpio_mute_led_mask; unsigned int gpio_mic_led_mask; - unsigned int mute_led_coef_idx; - unsigned int mute_led_coefbit_mask; - unsigned int mute_led_coefbit_on; - unsigned int mute_led_coefbit_off; - unsigned int mic_led_coef_idx; - unsigned int mic_led_coefbit_mask; - unsigned int mic_led_coefbit_on; - unsigned int mic_led_coefbit_off; + struct alc_coef_led mute_led_coef; + struct alc_coef_led mic_led_coef; hda_nid_t headset_mic_pin; hda_nid_t headphone_mic_pin; @@ -287,6 +288,13 @@ static void alc_fixup_gpio4(struct hda_codec *codec, alc_fixup_gpio(codec, action, 0x04); } +static void alc_fixup_micmute_led(struct hda_codec *codec, + const struct hda_fixup *fix, int action) +{ + if (action == HDA_FIXUP_ACT_PROBE) + snd_hda_gen_add_micmute_led_cdev(codec, NULL); +} + /* * Fix hardware PLL issue * On some codecs, the analog PLL gating control must be off while @@ -374,7 +382,7 @@ static void alc_fill_eapd_coef(struct hda_codec *codec) case 0x10ec0295: case 0x10ec0299: alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000); - /* fallthrough */ + fallthrough; case 0x10ec0215: case 0x10ec0233: case 0x10ec0235: @@ -1070,7 +1078,7 @@ static int set_beep_amp(struct alc_spec *spec, hda_nid_t nid, return 0; } -static const struct snd_pci_quirk beep_white_list[] = { +static const struct snd_pci_quirk beep_allow_list[] = { SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1), SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1), SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), @@ -1080,7 +1088,7 @@ static const struct snd_pci_quirk beep_white_list[] = { SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), - /* blacklist -- no beep available */ + /* denylist -- no beep available */ SND_PCI_QUIRK(0x17aa, 0x309e, "Lenovo ThinkCentre M73", 0), SND_PCI_QUIRK(0x17aa, 0x30a3, "Lenovo ThinkCentre M93", 0), {} @@ -1090,7 +1098,7 @@ static inline int has_cdefine_beep(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; const struct snd_pci_quirk *q; - q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); + q = snd_pci_quirk_lookup(codec->bus->pci, beep_allow_list); if (q) return q->value; return spec->cdefine.enable_pcbeep; @@ -3982,25 +3990,34 @@ static void alc269_fixup_x101_headset_mic(struct hda_codec *codec, } } +static void alc_update_vref_led(struct hda_codec *codec, hda_nid_t pin, + bool polarity, bool on) +{ + unsigned int pinval; + + if (!pin) + return; + if (polarity) + on = !on; + pinval = snd_hda_codec_get_pin_target(codec, pin); + pinval &= ~AC_PINCTL_VREFEN; + pinval |= on ? AC_PINCTL_VREF_80 : AC_PINCTL_VREF_HIZ; + /* temporarily power up/down for setting VREF */ + snd_hda_power_up_pm(codec); + snd_hda_set_pin_ctl_cache(codec, pin, pinval); + snd_hda_power_down_pm(codec); +} /* update mute-LED according to the speaker mute state via mic VREF pin */ -static void alc269_fixup_mic_mute_hook(void *private_data, int enabled) +static int vref_mute_led_set(struct led_classdev *led_cdev, + enum led_brightness brightness) { - struct hda_codec *codec = private_data; + struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); struct alc_spec *spec = codec->spec; - unsigned int pinval; - if (spec->mute_led_polarity) - enabled = !enabled; - pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid); - pinval &= ~AC_PINCTL_VREFEN; - pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80; - if (spec->mute_led_nid) { - /* temporarily power up/down for setting VREF */ - snd_hda_power_up_pm(codec); - snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval); - snd_hda_power_down_pm(codec); - } + alc_update_vref_led(codec, spec->mute_led_nid, + spec->mute_led_polarity, brightness); + return 0; } /* Make sure the led works even in runtime suspend */ @@ -4038,8 +4055,7 @@ static void alc269_fixup_hp_mute_led(struct hda_codec *codec, break; spec->mute_led_polarity = pol; spec->mute_led_nid = pin - 0x0a + 0x18; - spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; - spec->gen.vmaster_mute_enum = 1; + snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set); codec->power_filter = led_power_filter; codec_dbg(codec, "Detected mute LED for %x:%d\n", spec->mute_led_nid, @@ -4057,8 +4073,7 @@ static void alc269_fixup_hp_mute_led_micx(struct hda_codec *codec, if (action == HDA_FIXUP_ACT_PRE_PROBE) { spec->mute_led_polarity = 0; spec->mute_led_nid = pin; - spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; - spec->gen.vmaster_mute_enum = 1; + snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set); codec->power_filter = led_power_filter; } } @@ -4091,26 +4106,18 @@ static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask, } /* turn on/off mute LED via GPIO per vmaster hook */ -static void alc_fixup_gpio_mute_hook(void *private_data, int enabled) +static int gpio_mute_led_set(struct led_classdev *led_cdev, + enum led_brightness brightness) { - struct hda_codec *codec = private_data; + struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); struct alc_spec *spec = codec->spec; alc_update_gpio_led(codec, spec->gpio_mute_led_mask, - spec->mute_led_polarity, enabled); + spec->mute_led_polarity, !brightness); + return 0; } /* turn on/off mic-mute LED via GPIO per capture hook */ -static void alc_gpio_micmute_update(struct hda_codec *codec) -{ - struct alc_spec *spec = codec->spec; - - alc_update_gpio_led(codec, spec->gpio_mic_led_mask, - spec->micmute_led_polarity, - spec->gen.micmute_led.led_value); -} - -#if IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO) static int micmute_led_set(struct led_classdev *led_cdev, enum led_brightness brightness) { @@ -4122,14 +4129,6 @@ static int micmute_led_set(struct led_classdev *led_cdev, return 0; } -static struct led_classdev micmute_led_cdev = { - .name = "hda::micmute", - .max_brightness = 1, - .brightness_set_blocking = micmute_led_set, - .default_trigger = "audio-micmute", -}; -#endif - /* setup mute and mic-mute GPIO bits, add hooks appropriately */ static void alc_fixup_hp_gpio_led(struct hda_codec *codec, int action, @@ -4137,9 +4136,6 @@ static void alc_fixup_hp_gpio_led(struct hda_codec *codec, unsigned int micmute_mask) { struct alc_spec *spec = codec->spec; -#if IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO) - int err; -#endif alc_fixup_gpio(codec, action, mute_mask | micmute_mask); @@ -4147,18 +4143,11 @@ static void alc_fixup_hp_gpio_led(struct hda_codec *codec, return; if (mute_mask) { spec->gpio_mute_led_mask = mute_mask; - spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook; + snd_hda_gen_add_mute_led_cdev(codec, gpio_mute_led_set); } if (micmute_mask) { spec->gpio_mic_led_mask = micmute_mask; - snd_hda_gen_add_micmute_led(codec, alc_gpio_micmute_update); - -#if IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO) - micmute_led_cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE); - err = devm_led_classdev_register(&codec->core.dev, &micmute_led_cdev); - if (err) - codec_warn(codec, "failed to register micmute LED\n"); -#endif + snd_hda_gen_add_micmute_led_cdev(codec, micmute_led_set); } } @@ -4184,21 +4173,16 @@ static void alc286_fixup_hp_gpio_led(struct hda_codec *codec, alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20); } -/* turn on/off mic-mute LED per capture hook */ -static void alc_cap_micmute_update(struct hda_codec *codec) +/* turn on/off mic-mute LED per capture hook via VREF change */ +static int vref_micmute_led_set(struct led_classdev *led_cdev, + enum led_brightness brightness) { + struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); struct alc_spec *spec = codec->spec; - unsigned int pinval; - if (!spec->cap_mute_led_nid) - return; - pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid); - pinval &= ~AC_PINCTL_VREFEN; - if (spec->gen.micmute_led.led_value) - pinval |= AC_PINCTL_VREF_80; - else - pinval |= AC_PINCTL_VREF_HIZ; - snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval); + alc_update_vref_led(codec, spec->cap_mute_led_nid, + spec->micmute_led_polarity, brightness); + return 0; } static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec, @@ -4214,7 +4198,7 @@ static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec, spec->gpio_mask |= 0x10; spec->gpio_dir |= 0x10; spec->cap_mute_led_nid = 0x18; - snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update); + snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set); codec->power_filter = led_power_filter; } } @@ -4227,25 +4211,32 @@ static void alc280_fixup_hp_gpio4(struct hda_codec *codec, alc_fixup_hp_gpio_led(codec, action, 0x08, 0); if (action == HDA_FIXUP_ACT_PRE_PROBE) { spec->cap_mute_led_nid = 0x18; - snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update); + snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set); codec->power_filter = led_power_filter; } } +static void alc_update_coef_led(struct hda_codec *codec, + struct alc_coef_led *led, + bool polarity, bool on) +{ + if (polarity) + on = !on; + /* temporarily power up/down for setting COEF bit */ + alc_update_coef_idx(codec, led->idx, led->mask, + on ? led->on : led->off); +} + /* update mute-LED according to the speaker mute state via COEF bit */ -static void alc_fixup_mute_led_coefbit_hook(void *private_data, int enabled) +static int coef_mute_led_set(struct led_classdev *led_cdev, + enum led_brightness brightness) { - struct hda_codec *codec = private_data; + struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); struct alc_spec *spec = codec->spec; - if (spec->mute_led_polarity) - enabled = !enabled; - - /* temporarily power up/down for setting COEF bit */ - enabled ? alc_update_coef_idx(codec, spec->mute_led_coef_idx, - spec->mute_led_coefbit_mask, spec->mute_led_coefbit_off) : - alc_update_coef_idx(codec, spec->mute_led_coef_idx, - spec->mute_led_coefbit_mask, spec->mute_led_coefbit_on); + alc_update_coef_led(codec, &spec->mute_led_coef, + spec->mute_led_polarity, brightness); + return 0; } static void alc285_fixup_hp_mute_led_coefbit(struct hda_codec *codec, @@ -4256,12 +4247,11 @@ static void alc285_fixup_hp_mute_led_coefbit(struct hda_codec *codec, if (action == HDA_FIXUP_ACT_PRE_PROBE) { spec->mute_led_polarity = 0; - spec->mute_led_coef_idx = 0x0b; - spec->mute_led_coefbit_mask = 1<<3; - spec->mute_led_coefbit_on = 1<<3; - spec->mute_led_coefbit_off = 0; - spec->gen.vmaster_mute.hook = alc_fixup_mute_led_coefbit_hook; - spec->gen.vmaster_mute_enum = 1; + spec->mute_led_coef.idx = 0x0b; + spec->mute_led_coef.mask = 1 << 3; + spec->mute_led_coef.on = 1 << 3; + spec->mute_led_coef.off = 0; + snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set); } } @@ -4273,26 +4263,24 @@ static void alc236_fixup_hp_mute_led_coefbit(struct hda_codec *codec, if (action == HDA_FIXUP_ACT_PRE_PROBE) { spec->mute_led_polarity = 0; - spec->mute_led_coef_idx = 0x34; - spec->mute_led_coefbit_mask = 1<<5; - spec->mute_led_coefbit_on = 0; - spec->mute_led_coefbit_off = 1<<5; - spec->gen.vmaster_mute.hook = alc_fixup_mute_led_coefbit_hook; - spec->gen.vmaster_mute_enum = 1; + spec->mute_led_coef.idx = 0x34; + spec->mute_led_coef.mask = 1 << 5; + spec->mute_led_coef.on = 0; + spec->mute_led_coef.off = 1 << 5; + snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set); } } /* turn on/off mic-mute LED per capture hook by coef bit */ -static void alc_hp_cap_micmute_update(struct hda_codec *codec) +static int coef_micmute_led_set(struct led_classdev *led_cdev, + enum led_brightness brightness) { + struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); struct alc_spec *spec = codec->spec; - if (spec->gen.micmute_led.led_value) - alc_update_coef_idx(codec, spec->mic_led_coef_idx, - spec->mic_led_coefbit_mask, spec->mic_led_coefbit_on); - else - alc_update_coef_idx(codec, spec->mic_led_coef_idx, - spec->mic_led_coefbit_mask, spec->mic_led_coefbit_off); + alc_update_coef_led(codec, &spec->mic_led_coef, + spec->micmute_led_polarity, brightness); + return 0; } static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec, @@ -4301,11 +4289,11 @@ static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec, struct alc_spec *spec = codec->spec; if (action == HDA_FIXUP_ACT_PRE_PROBE) { - spec->mic_led_coef_idx = 0x19; - spec->mic_led_coefbit_mask = 1<<13; - spec->mic_led_coefbit_on = 1<<13; - spec->mic_led_coefbit_off = 0; - snd_hda_gen_add_micmute_led(codec, alc_hp_cap_micmute_update); + spec->mic_led_coef.idx = 0x19; + spec->mic_led_coef.mask = 1 << 13; + spec->mic_led_coef.on = 1 << 13; + spec->mic_led_coef.off = 0; + snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set); } } @@ -4315,11 +4303,11 @@ static void alc236_fixup_hp_coef_micmute_led(struct hda_codec *codec, struct alc_spec *spec = codec->spec; if (action == HDA_FIXUP_ACT_PRE_PROBE) { - spec->mic_led_coef_idx = 0x35; - spec->mic_led_coefbit_mask = 3<<2; - spec->mic_led_coefbit_on = 2<<2; - spec->mic_led_coefbit_off = 1<<2; - snd_hda_gen_add_micmute_led(codec, alc_hp_cap_micmute_update); + spec->mic_led_coef.idx = 0x35; + spec->mic_led_coef.mask = 3 << 2; + spec->mic_led_coef.on = 2 << 2; + spec->mic_led_coef.off = 1 << 2; + snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set); } } @@ -4459,7 +4447,7 @@ static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec, alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1a); if (action == HDA_FIXUP_ACT_PRE_PROBE) { spec->cap_mute_led_nid = 0x18; - snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update); + snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set); } } @@ -4710,7 +4698,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, break; case 0x10ec0867: alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14); - /* fallthru */ + fallthrough; case 0x10ec0221: case 0x10ec0662: snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); @@ -6166,6 +6154,11 @@ enum { ALC289_FIXUP_ASUS_GA502, ALC256_FIXUP_ACER_MIC_NO_PRESENCE, ALC285_FIXUP_HP_GPIO_AMP_INIT, + ALC269_FIXUP_CZC_B20, + ALC269_FIXUP_CZC_TMI, + ALC269_FIXUP_CZC_L101, + ALC269_FIXUP_LEMOTE_A1802, + ALC269_FIXUP_LEMOTE_A190X, }; static const struct hda_fixup alc269_fixups[] = { @@ -6706,7 +6699,7 @@ static const struct hda_fixup alc269_fixups[] = { }, [ALC255_FIXUP_MIC_MUTE_LED] = { .type = HDA_FIXUP_FUNC, - .v.func = snd_hda_gen_fixup_micmute_led, + .v.func = alc_fixup_micmute_led, }, [ALC282_FIXUP_ASPIRE_V5_PINS] = { .type = HDA_FIXUP_PINS, @@ -6809,7 +6802,7 @@ static const struct hda_fixup alc269_fixups[] = { }, [ALC292_FIXUP_DELL_E7X] = { .type = HDA_FIXUP_FUNC, - .v.func = snd_hda_gen_fixup_micmute_led, + .v.func = alc_fixup_micmute_led, /* micmute fixup must be applied at last */ .chained_before = true, .chain_id = ALC292_FIXUP_DELL_E7X_AAMIX, @@ -7404,6 +7397,89 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC285_FIXUP_HP_GPIO_LED }, + [ALC269_FIXUP_CZC_B20] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl[]) { + { 0x12, 0x411111f0 }, + { 0x14, 0x90170110 }, /* speaker */ + { 0x15, 0x032f1020 }, /* HP out */ + { 0x17, 0x411111f0 }, + { 0x18, 0x03ab1040 }, /* mic */ + { 0x19, 0xb7a7013f }, + { 0x1a, 0x0181305f }, + { 0x1b, 0x411111f0 }, + { 0x1d, 0x411111f0 }, + { 0x1e, 0x411111f0 }, + { } + }, + .chain_id = ALC269_FIXUP_DMIC, + }, + [ALC269_FIXUP_CZC_TMI] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl[]) { + { 0x12, 0x4000c000 }, + { 0x14, 0x90170110 }, /* speaker */ + { 0x15, 0x0421401f }, /* HP out */ + { 0x17, 0x411111f0 }, + { 0x18, 0x04a19020 }, /* mic */ + { 0x19, 0x411111f0 }, + { 0x1a, 0x411111f0 }, + { 0x1b, 0x411111f0 }, + { 0x1d, 0x40448505 }, + { 0x1e, 0x411111f0 }, + { 0x20, 0x8000ffff }, + { } + }, + .chain_id = ALC269_FIXUP_DMIC, + }, + [ALC269_FIXUP_CZC_L101] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl[]) { + { 0x12, 0x40000000 }, + { 0x14, 0x01014010 }, /* speaker */ + { 0x15, 0x411111f0 }, /* HP out */ + { 0x16, 0x411111f0 }, + { 0x18, 0x01a19020 }, /* mic */ + { 0x19, 0x02a19021 }, + { 0x1a, 0x0181302f }, + { 0x1b, 0x0221401f }, + { 0x1c, 0x411111f0 }, + { 0x1d, 0x4044c601 }, + { 0x1e, 0x411111f0 }, + { } + }, + .chain_id = ALC269_FIXUP_DMIC, + }, + [ALC269_FIXUP_LEMOTE_A1802] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl[]) { + { 0x12, 0x40000000 }, + { 0x14, 0x90170110 }, /* speaker */ + { 0x17, 0x411111f0 }, + { 0x18, 0x03a19040 }, /* mic1 */ + { 0x19, 0x90a70130 }, /* mic2 */ + { 0x1a, 0x411111f0 }, + { 0x1b, 0x411111f0 }, + { 0x1d, 0x40489d2d }, + { 0x1e, 0x411111f0 }, + { 0x20, 0x0003ffff }, + { 0x21, 0x03214020 }, + { } + }, + .chain_id = ALC269_FIXUP_DMIC, + }, + [ALC269_FIXUP_LEMOTE_A190X] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl[]) { + { 0x14, 0x99130110 }, /* speaker */ + { 0x15, 0x0121401f }, /* HP out */ + { 0x18, 0x01a19c20 }, /* rear mic */ + { 0x19, 0x99a3092f }, /* front mic */ + { 0x1b, 0x0201401f }, /* front lineout */ + { } + }, + .chain_id = ALC269_FIXUP_DMIC, + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = { @@ -7693,9 +7769,14 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MACH-WX9", ALC256_FIXUP_HUAWEI_MACH_WX9_PINS), + SND_PCI_QUIRK(0x1b35, 0x1235, "CZC B20", ALC269_FIXUP_CZC_B20), + SND_PCI_QUIRK(0x1b35, 0x1236, "CZC TMI", ALC269_FIXUP_CZC_TMI), + SND_PCI_QUIRK(0x1b35, 0x1237, "CZC L101", ALC269_FIXUP_CZC_L101), SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */ SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC), SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE), + SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802), + SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X), #if 0 /* Below is a quirk table taken from the old code. @@ -8951,6 +9032,7 @@ enum { ALC662_FIXUP_LED_GPIO1, ALC662_FIXUP_IDEAPAD, ALC272_FIXUP_MARIO, + ALC662_FIXUP_CZC_ET26, ALC662_FIXUP_CZC_P10T, ALC662_FIXUP_SKU_IGNORE, ALC662_FIXUP_HP_RP5800, @@ -9020,6 +9102,25 @@ static const struct hda_fixup alc662_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = alc272_fixup_mario, }, + [ALC662_FIXUP_CZC_ET26] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl[]) { + {0x12, 0x403cc000}, + {0x14, 0x90170110}, /* speaker */ + {0x15, 0x411111f0}, + {0x16, 0x411111f0}, + {0x18, 0x01a19030}, /* mic */ + {0x19, 0x90a7013f}, /* int-mic */ + {0x1a, 0x01014020}, + {0x1b, 0x0121401f}, + {0x1c, 0x411111f0}, + {0x1d, 0x411111f0}, + {0x1e, 0x40478e35}, + {} + }, + .chained = true, + .chain_id = ALC662_FIXUP_SKU_IGNORE + }, [ALC662_FIXUP_CZC_P10T] = { .type = HDA_FIXUP_VERBS, .v.verbs = (const struct hda_verb[]) { @@ -9403,6 +9504,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = { SND_PCI_QUIRK(0x1849, 0x5892, "ASRock B150M", ALC892_FIXUP_ASROCK_MOBO), SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68), SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON), + SND_PCI_QUIRK(0x1b35, 0x1234, "CZC ET26", ALC662_FIXUP_CZC_ET26), SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), SND_PCI_QUIRK(0x1025, 0x0566, "Acer Aspire Ethos 8951G", ALC669_FIXUP_ACER_ASPIRE_ETHOS), diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index a608d0486ae4..c662431bf13a 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -320,15 +320,18 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, } /* hook for controlling mic-mute LED GPIO */ -static void stac_capture_led_update(struct hda_codec *codec) +static int stac_capture_led_update(struct led_classdev *led_cdev, + enum led_brightness brightness) { + struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); struct sigmatel_spec *spec = codec->spec; - if (spec->gen.micmute_led.led_value) + if (brightness) spec->gpio_data |= spec->mic_mute_led_gpio; else spec->gpio_data &= ~spec->mic_mute_led_gpio; stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data); + return 0; } static int stac_vrefout_set(struct hda_codec *codec, @@ -366,10 +369,9 @@ static unsigned int stac_vref_led_power_filter(struct hda_codec *codec, } /* update mute-LED accoring to the master switch */ -static void stac_update_led_status(struct hda_codec *codec, int enabled) +static void stac_update_led_status(struct hda_codec *codec, bool muted) { struct sigmatel_spec *spec = codec->spec; - int muted = !enabled; if (!spec->gpio_led) return; @@ -393,9 +395,13 @@ static void stac_update_led_status(struct hda_codec *codec, int enabled) } /* vmaster hook to update mute LED */ -static void stac_vmaster_hook(void *private_data, int val) +static int stac_vmaster_hook(struct led_classdev *led_cdev, + enum led_brightness brightness) { - stac_update_led_status(private_data, val); + struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); + + stac_update_led_status(codec, brightness); + return 0; } /* automute hook to handle GPIO mute and EAPD updates */ @@ -832,7 +838,7 @@ static int stac_auto_create_beep_ctls(struct hda_codec *codec, static const struct snd_kcontrol_new beep_vol_ctl = HDA_CODEC_VOLUME(NULL, 0, 0, 0); - /* check for mute support for the the amp */ + /* check for mute support for the amp */ if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { const struct snd_kcontrol_new *temp; if (spec->anabeep_nid == nid) @@ -3129,7 +3135,7 @@ static void fixup_hp_headphone(struct hda_codec *codec, hda_nid_t pin) unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, pin); /* It was changed in the BIOS to just satisfy MS DTM. - * Lets turn it back into slaved HP + * Lets turn it back into follower HP */ pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE)) | (AC_JACK_HP_OUT << AC_DEFCFG_DEVICE_SHIFT); @@ -4313,7 +4319,7 @@ static int stac_parse_auto_config(struct hda_codec *codec) #endif if (spec->gpio_led) - spec->gen.vmaster_mute.hook = stac_vmaster_hook; + snd_hda_gen_add_mute_led_cdev(codec, stac_vmaster_hook); if (spec->aloopback_ctl && snd_hda_get_bool_hint(codec, "loopback") == 1) { @@ -4636,7 +4642,7 @@ static void stac_setup_gpio(struct hda_codec *codec) spec->gpio_dir |= spec->mic_mute_led_gpio; spec->mic_enabled = 0; spec->gpio_data |= spec->mic_mute_led_gpio; - snd_hda_gen_add_micmute_led(codec, stac_capture_led_update); + snd_hda_gen_add_micmute_led_cdev(codec, stac_capture_led_update); } } diff --git a/sound/pci/hda/thinkpad_helper.c b/sound/pci/hda/thinkpad_helper.c index 4089feb8c68e..6698ae241efc 100644 --- a/sound/pci/hda/thinkpad_helper.c +++ b/sound/pci/hda/thinkpad_helper.c @@ -3,13 +3,11 @@ * to be included from codec driver */ -#if IS_ENABLED(CONFIG_THINKPAD_ACPI) && IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO) +#if IS_ENABLED(CONFIG_THINKPAD_ACPI) #include <linux/acpi.h> #include <linux/leds.h> -static void (*old_vmaster_hook)(void *, int); - static bool is_thinkpad(struct hda_codec *codec) { return (codec->core.subsystem_id >> 16 == 0x17aa) && @@ -17,25 +15,14 @@ static bool is_thinkpad(struct hda_codec *codec) acpi_dev_found("IBM0068")); } -static void update_tpacpi_mute_led(void *private_data, int enabled) -{ - if (old_vmaster_hook) - old_vmaster_hook(private_data, enabled); - - ledtrig_audio_set(LED_AUDIO_MUTE, enabled ? LED_OFF : LED_ON); -} - static void hda_fixup_thinkpad_acpi(struct hda_codec *codec, const struct hda_fixup *fix, int action) { - struct hda_gen_spec *spec = codec->spec; - if (action == HDA_FIXUP_ACT_PROBE) { if (!is_thinkpad(codec)) return; - old_vmaster_hook = spec->vmaster_mute.hook; - spec->vmaster_mute.hook = update_tpacpi_mute_led; - snd_hda_gen_fixup_micmute_led(codec, fix, action); + snd_hda_gen_add_mute_led_cdev(codec, NULL); + snd_hda_gen_add_micmute_led_cdev(codec, NULL); } } diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c index 81929063b2fa..1d2a0287284b 100644 --- a/sound/pci/ice1712/delta.c +++ b/sound/pci/ice1712/delta.c @@ -691,7 +691,7 @@ static int snd_ice1712_delta_init(struct snd_ice1712 *ice) break; case ICE1712_SUBDEVICE_DELTADIO2496: ice->gpio.set_pro_rate = delta_1010_set_rate_val; - /* fall thru */ + fallthrough; case ICE1712_SUBDEVICE_DELTA66: ice->spdif.ops.open = delta_open_spdif; ice->spdif.ops.setup_rate = delta_setup_spdif; diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c index 7be4eb42f05e..e57a55cebc5a 100644 --- a/sound/pci/ice1712/juli.c +++ b/sound/pci/ice1712/juli.c @@ -397,7 +397,7 @@ static const struct snd_kcontrol_new juli_mute_controls[] = { }, }; -static const char * const slave_vols[] = { +static const char * const follower_vols[] = { PCM_VOLUME, MONITOR_AN_IN_VOLUME, MONITOR_DIG_IN_VOLUME, @@ -418,16 +418,16 @@ static struct snd_kcontrol *ctl_find(struct snd_card *card, return snd_ctl_find_id(card, &sid); } -static void add_slaves(struct snd_card *card, - struct snd_kcontrol *master, - const char * const *list) +static void add_followers(struct snd_card *card, + struct snd_kcontrol *master, + const char * const *list) { for (; *list; list++) { - struct snd_kcontrol *slave = ctl_find(card, *list); - /* dev_dbg(card->dev, "add_slaves - %s\n", *list); */ - if (slave) { - /* dev_dbg(card->dev, "slave %s found\n", *list); */ - snd_ctl_add_slave(master, slave); + struct snd_kcontrol *follower = ctl_find(card, *list); + /* dev_dbg(card->dev, "add_followers - %s\n", *list); */ + if (follower) { + /* dev_dbg(card->dev, "follower %s found\n", *list); */ + snd_ctl_add_follower(master, follower); } } } @@ -454,7 +454,7 @@ static int juli_add_controls(struct snd_ice1712 *ice) juli_master_db_scale); if (!vmaster) return -ENOMEM; - add_slaves(ice->card, vmaster, slave_vols); + add_followers(ice->card, vmaster, follower_vols); err = snd_ctl_add(ice->card, vmaster); if (err < 0) return err; diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c index 8df14f63b10d..096ec76f5304 100644 --- a/sound/pci/ice1712/prodigy192.c +++ b/sound/pci/ice1712/prodigy192.c @@ -32,7 +32,7 @@ * Experimentally I found out that only a combination of * OCKS0=1, OCKS1=1 (128fs, 64fs output) and ice1724 - * VT1724_MT_I2S_MCLK_128X=0 (256fs input) yields correct - * sampling rate. That means the the FPGA doubles the + * sampling rate. That means that the FPGA doubles the * MCK01 rate. * * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de> diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c index 866596205710..0e3e04aa9faf 100644 --- a/sound/pci/ice1712/quartet.c +++ b/sound/pci/ice1712/quartet.c @@ -757,7 +757,7 @@ static const struct snd_kcontrol_new qtet_controls[] = { QTET_CONTROL("Output 3/4 to Monitor 1/2", sw, OUT34_MON12), }; -static const char * const slave_vols[] = { +static const char * const follower_vols[] = { PCM_12_PLAYBACK_VOLUME, PCM_34_PLAYBACK_VOLUME, NULL @@ -776,13 +776,13 @@ static struct snd_kcontrol *ctl_find(struct snd_card *card, return snd_ctl_find_id(card, &sid); } -static void add_slaves(struct snd_card *card, - struct snd_kcontrol *master, const char * const *list) +static void add_followers(struct snd_card *card, + struct snd_kcontrol *master, const char * const *list) { for (; *list; list++) { - struct snd_kcontrol *slave = ctl_find(card, *list); - if (slave) - snd_ctl_add_slave(master, slave); + struct snd_kcontrol *follower = ctl_find(card, *list); + if (follower) + snd_ctl_add_follower(master, follower); } } @@ -806,7 +806,7 @@ static int qtet_add_controls(struct snd_ice1712 *ice) qtet_master_db_scale); if (!vmaster) return -ENOMEM; - add_slaves(ice->card, vmaster, slave_vols); + add_followers(ice->card, vmaster, follower_vols); err = snd_ctl_add(ice->card, vmaster); if (err < 0) return err; diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 1781a1c081c3..3349e455a871 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -66,7 +66,7 @@ MODULE_PARM_DESC(index, "Index value for Intel i8x0 soundcard."); module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for Intel i8x0 soundcard."); module_param(ac97_clock, int, 0444); -MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = whitelist + auto-detect, 1 = force autodetect)."); +MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = allowlist + auto-detect, 1 = force autodetect)."); module_param(ac97_quirk, charp, 0444); MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); module_param(buggy_semaphore, bool, 0444); @@ -810,7 +810,7 @@ static int snd_intel8x0_pcm_trigger(struct snd_pcm_substream *substream, int cmd switch (cmd) { case SNDRV_PCM_TRIGGER_RESUME: ichdev->suspended = 0; - /* fall through */ + fallthrough; case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: val = ICH_IOCE | ICH_STARTBM; @@ -818,7 +818,7 @@ static int snd_intel8x0_pcm_trigger(struct snd_pcm_substream *substream, int cmd break; case SNDRV_PCM_TRIGGER_SUSPEND: ichdev->suspended = 1; - /* fall through */ + fallthrough; case SNDRV_PCM_TRIGGER_STOP: val = 0; break; @@ -852,7 +852,7 @@ static int snd_intel8x0_ali_trigger(struct snd_pcm_substream *substream, int cmd switch (cmd) { case SNDRV_PCM_TRIGGER_RESUME: ichdev->suspended = 0; - /* fall through */ + fallthrough; case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { @@ -869,7 +869,7 @@ static int snd_intel8x0_ali_trigger(struct snd_pcm_substream *substream, int cmd break; case SNDRV_PCM_TRIGGER_SUSPEND: ichdev->suspended = 1; - /* fall through */ + fallthrough; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: /* pause */ @@ -2792,7 +2792,7 @@ static int intel8x0_in_clock_list(struct intel8x0 *chip) wl = snd_pci_quirk_lookup(pci, intel8x0_clock_list); if (!wl) return 0; - dev_info(chip->card->dev, "white list rate for %04x:%04x is %i\n", + dev_info(chip->card->dev, "allow list rate for %04x:%04x is %i\n", pci->subsystem_vendor, pci->subsystem_device, wl->value); chip->ac97_bus->clock = wl->value; return 1; @@ -3138,7 +3138,7 @@ static const struct snd_pci_quirk spdif_aclink_defaults[] = { { } /* end */ }; -/* look up white/black list for SPDIF over ac-link */ +/* look up allow/deny list for SPDIF over ac-link */ static int check_default_spdif_aclink(struct pci_dev *pci) { const struct snd_pci_quirk *w; diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 65a887b217ee..2eddd9de9e6d 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -2149,7 +2149,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, { int err, rc; unsigned int i; - unsigned ioport_size, iomem_size, iomem2_size; + unsigned iomem_size; + __maybe_unused unsigned ioport_size; + __maybe_unused unsigned iomem2_size; struct snd_korg1212 * korg1212; const struct firmware *dsp_code; diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 7ba487443c7f..efff220b26ea 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -169,7 +169,7 @@ static int mixart_set_clock(struct mixart_mgr *mgr, case PIPE_RUNNING: if(rate != 0) break; - /* fall through */ + fallthrough; default: if(rate == 0) return 0; /* nothing to do */ diff --git a/sound/pci/mixart/mixart_core.c b/sound/pci/mixart/mixart_core.c index 048a2660d18d..0bdd33b0af65 100644 --- a/sound/pci/mixart/mixart_core.c +++ b/sound/pci/mixart/mixart_core.c @@ -527,7 +527,7 @@ irqreturn_t snd_mixart_threaded_irq(int irq, void *dev_id) dev_err(&mgr->pci->dev, "canceled notification %x !\n", msg); } - /* fall through */ + fallthrough; case MSG_TYPE_ANSWER: /* answer or notification to a message we are waiting for*/ mutex_lock(&mgr->msg_lock); diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index ebce4d259e06..975994623c2c 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -560,7 +560,7 @@ snd_nm256_playback_trigger(struct snd_pcm_substream *substream, int cmd) switch (cmd) { case SNDRV_PCM_TRIGGER_RESUME: s->suspended = 0; - /* fallthru */ + fallthrough; case SNDRV_PCM_TRIGGER_START: if (! s->running) { snd_nm256_playback_start(chip, s, substream); @@ -569,7 +569,7 @@ snd_nm256_playback_trigger(struct snd_pcm_substream *substream, int cmd) break; case SNDRV_PCM_TRIGGER_SUSPEND: s->suspended = 1; - /* fallthru */ + fallthrough; case SNDRV_PCM_TRIGGER_STOP: if (s->running) { snd_nm256_playback_stop(chip); @@ -1632,11 +1632,11 @@ __error: } -enum { NM_BLACKLISTED, NM_RESET_WORKAROUND, NM_RESET_WORKAROUND_2 }; +enum { NM_IGNORED, NM_RESET_WORKAROUND, NM_RESET_WORKAROUND_2 }; static const struct snd_pci_quirk nm256_quirks[] = { /* HP omnibook 4150 has cs4232 codec internally */ - SND_PCI_QUIRK(0x103c, 0x0007, "HP omnibook 4150", NM_BLACKLISTED), + SND_PCI_QUIRK(0x103c, 0x0007, "HP omnibook 4150", NM_IGNORED), /* Reset workarounds to avoid lock-ups */ SND_PCI_QUIRK(0x104d, 0x8041, "Sony PCG-F305", NM_RESET_WORKAROUND), SND_PCI_QUIRK(0x1028, 0x0080, "Dell Latitude LS", NM_RESET_WORKAROUND), @@ -1658,13 +1658,13 @@ static int snd_nm256_probe(struct pci_dev *pci, dev_dbg(&pci->dev, "Enabled quirk for %s.\n", snd_pci_quirk_name(q)); switch (q->value) { - case NM_BLACKLISTED: + case NM_IGNORED: dev_info(&pci->dev, - "The device is blacklisted. Loading stopped\n"); + "The device is on the denylist. Loading stopped\n"); return -ENODEV; case NM_RESET_WORKAROUND_2: reset_workaround_2 = 1; - /* Fall-through */ + fallthrough; case NM_RESET_WORKAROUND: reset_workaround = 1; break; diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index 75b25ecf83a9..b2a3fcfe31d4 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c @@ -137,7 +137,7 @@ static int oxygen_open(struct snd_pcm_substream *substream, SNDRV_PCM_RATE_64000); runtime->hw.rate_min = 44100; } - /* fall through */ + fallthrough; case PCM_A: case PCM_B: runtime->hw.fifo_size = 0; diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c index c3f8721624cd..b90421a1d909 100644 --- a/sound/pci/oxygen/xonar_dg.c +++ b/sound/pci/oxygen/xonar_dg.c @@ -29,7 +29,7 @@ * GPIO 4 <- headphone detect * GPIO 5 -> enable ADC analog circuit for the left channel * GPIO 6 -> enable ADC analog circuit for the right channel - * GPIO 7 -> switch green rear output jack between CS4245 and and the first + * GPIO 7 -> switch green rear output jack between CS4245 and the first * channel of CS4361 (mechanical relay) * GPIO 8 -> enable output to speakers * diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c index 0767276582ca..8aa92f3e5ee8 100644 --- a/sound/pci/oxygen/xonar_wm87x6.c +++ b/sound/pci/oxygen/xonar_wm87x6.c @@ -116,7 +116,8 @@ static void wm8776_write(struct oxygen *chip, else wm8776_write_i2c(chip, reg, value); if (reg < ARRAY_SIZE(data->wm8776_regs)) { - if (reg >= WM8776_HPLVOL && reg <= WM8776_DACMASTER) + /* reg >= WM8776_HPLVOL is always true */ + if (reg <= WM8776_DACMASTER) value &= ~WM8776_UPDATE; data->wm8776_regs[reg] = value; } @@ -144,7 +145,8 @@ static void wm8766_write(struct oxygen *chip, OXYGEN_SPI_CEN_LATCH_CLOCK_LO, (reg << 9) | value); if (reg < ARRAY_SIZE(data->wm8766_regs)) { - if ((reg >= WM8766_LDA1 && reg <= WM8766_RDA1) || + /* reg >= WM8766_LDA1 is always true */ + if (reg <= WM8766_RDA1 || (reg >= WM8766_LDA2 && reg <= WM8766_MASTDA)) value &= ~WM8766_UPDATE; data->wm8766_regs[reg] = value; diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index f7cda9062088..0fa49f4d15cf 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -3027,8 +3027,8 @@ static int hdspm_autosync_ref(struct hdspm *hdspm) unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister); unsigned int syncref = (status >> HDSPM_AES32_syncref_bit) & 0xF; - if ((syncref >= HDSPM_AES32_AUTOSYNC_FROM_WORD) && - (syncref <= HDSPM_AES32_AUTOSYNC_FROM_SYNC_IN)) { + /* syncref >= HDSPM_AES32_AUTOSYNC_FROM_WORD is always true */ + if (syncref <= HDSPM_AES32_AUTOSYNC_FROM_SYNC_IN) { return syncref; } return HDSPM_AES32_AUTOSYNC_FROM_NONE; diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 8b03e2dc503f..154d88ce8813 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -544,7 +544,7 @@ static int snd_via82xx_codec_valid(struct via82xx *chip, int secondary) static void snd_via82xx_codec_wait(struct snd_ac97 *ac97) { struct via82xx *chip = ac97->private_data; - int err; + __always_unused int err; err = snd_via82xx_codec_ready(chip, ac97->num); /* here we need to wait fairly for long time.. */ if (!nodelay) @@ -2419,7 +2419,7 @@ static const struct via823x_info via823x_cards[] = { * auto detection of DXS channel supports. */ -static const struct snd_pci_quirk dxs_whitelist[] = { +static const struct snd_pci_quirk dxs_allowlist[] = { SND_PCI_QUIRK(0x1005, 0x4710, "Avance Logic Mobo", VIA_DXS_ENABLE), SND_PCI_QUIRK(0x1019, 0x0996, "ESC Mobo", VIA_DXS_48K), SND_PCI_QUIRK(0x1019, 0x0a81, "ECS K7VTA3 v8.0", VIA_DXS_NO_VRA), @@ -2467,9 +2467,9 @@ static int check_dxs_list(struct pci_dev *pci, int revision) { const struct snd_pci_quirk *w; - w = snd_pci_quirk_lookup(pci, dxs_whitelist); + w = snd_pci_quirk_lookup(pci, dxs_allowlist); if (w) { - dev_dbg(&pci->dev, "DXS white list for %s found\n", + dev_dbg(&pci->dev, "DXS allow list for %s found\n", snd_pci_quirk_name(w)); return w->value; } diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 607b7100db1c..addfa196df21 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -398,7 +398,7 @@ static int snd_via82xx_codec_valid(struct via82xx_modem *chip, int secondary) static void snd_via82xx_codec_wait(struct snd_ac97 *ac97) { struct via82xx_modem *chip = ac97->private_data; - int err; + __always_unused int err; err = snd_via82xx_codec_ready(chip, ac97->num); /* here we need to wait fairly for long time.. */ msleep(500); diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index db7d76a3cfeb..cacc6a9d14c8 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -400,7 +400,7 @@ static int snd_ymfpci_playback_trigger(struct snd_pcm_substream *substream, kctl = chip->pcm_mixer[substream->number].ctl; kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; } - /* fall through */ + fallthrough; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_SUSPEND: chip->ctrl_playback[ypcm->voices[0]->number + 1] = 0; |