diff options
Diffstat (limited to 'snd-pcxhr-dkms/src/pcxhr_mix22.c')
-rw-r--r-- | snd-pcxhr-dkms/src/pcxhr_mix22.c | 75 |
1 files changed, 32 insertions, 43 deletions
diff --git a/snd-pcxhr-dkms/src/pcxhr_mix22.c b/snd-pcxhr-dkms/src/pcxhr_mix22.c index 7548cee..57972ff 100644 --- a/snd-pcxhr-dkms/src/pcxhr_mix22.c +++ b/snd-pcxhr-dkms/src/pcxhr_mix22.c @@ -1,27 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Driver for Digigram pcxhr compatible soundcards * * mixer interface for stereo cards * * Copyright (c) 2004 by Digigram <alsa@digigram.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/delay.h> #include <linux/io.h> +#include <linux/pci.h> #include <sound/core.h> #include <sound/control.h> #include <sound/tlv.h> @@ -62,7 +50,6 @@ #define AKM_LEFT_LEVEL_CMD 0xA600 #define AKM_RIGHT_LEVEL_CMD 0xA700 - /* values for PCHR_XLX_STATUS register - READ */ #define PCXHR_STAT_SRC_LOCK 0x01 #define PCXHR_STAT_LEVEL_IN 0x02 @@ -277,9 +264,9 @@ static void hr222_write_to_codec(struct pcxhr_mgr *mgr, unsigned short toWrite) unsigned short bit_mask = 0x8000; - snd_printdd("%s() CALLED\n", __FUNCTION__); + dev_dbg(&mgr->pci->dev, "%s() CALLED\n", __FUNCTION__); - snd_printdd("%s() to write : 0x%x\n", __FUNCTION__, toWrite); + dev_dbg(&mgr->pci->dev, "%s() to write : 0x%x\n", __FUNCTION__, toWrite); /* activate access to codec registers */ PCXHR_INPB(mgr, PCXHR_DSP, PCXHR_XLX_HIFREQ); @@ -303,9 +290,6 @@ static inline unsigned int pcxhr_ti_is_valid_output_gain_level (const int level) // Return the TI DAC gain value from the given level value. static unsigned int pcxhr_ti_gain_level_to_register_value(const unsigned int level) { - - snd_printdd("%s() : level:%u\n",__FUNCTION__,level); - if (level == 0) return PCXHR_PCM1796_MUTE_OUTPUT_GAIN_VALUE; @@ -353,7 +337,8 @@ static int hr222_set_akm_hw_playback_level(struct pcxhr_mgr *mgr, { unsigned short cmd; - snd_printdd("%s(channel:%d, level:%d) CALLED\n", __FUNCTION__, channel_id, level); + dev_dbg(&mgr->pci->dev, + "%s(channel:%d, level:%d) CALLED\n", __FUNCTION__, channel_id, level); if (channel_id > 1 || level < 0 || @@ -372,6 +357,7 @@ static int hr222_set_akm_hw_playback_level(struct pcxhr_mgr *mgr, return 0; } + static int hr222_set_hw_capture_level(struct pcxhr_mgr *mgr, int level_l, int level_r, int level_mic) { @@ -409,14 +395,14 @@ static void hr222_micro_boost(struct pcxhr_mgr *mgr, int level) PCXHR_OUTPB(mgr, PCXHR_DSP, PCXHR_XLX_SELMIC, mgr->xlx_selmic); - snd_printdd("hr222_micro_boost : set %x\n", boost_mask); + dev_dbg(&mgr->pci->dev, "hr222_micro_boost : set %x\n", boost_mask); } static int hr222_ti_sub_init (struct pcxhr_mgr *mgr) { - snd_printdd("%s() CALLED\n", __FUNCTION__); + dev_dbg(&mgr->pci->dev, "%s() CALLED\n", __FUNCTION__); //set the PCM1796 specific values mgr->pcm1796_operation_reg_value = PCXHR_PCM1796_OPER_RESET_VALUE; @@ -430,7 +416,7 @@ static int hr222_ti_sub_init (struct pcxhr_mgr *mgr) static int hr222_akm_sub_init (struct pcxhr_mgr *mgr) { - snd_printdd("%s() CALLED\n", __FUNCTION__); + dev_dbg(&mgr->pci->dev, "%s() CALLED\n", __FUNCTION__); /* config AKM */ hr222_write_to_codec(mgr, AKM_POWER_CONTROL_CMD); hr222_write_to_codec(mgr, AKM_CLOCK_INF_55K_CMD); @@ -450,7 +436,8 @@ int hr222_sub_init(struct pcxhr_mgr *mgr) reg = PCXHR_INPB(mgr, PCXHR_DSP, PCXHR_XLX_STATUS); if (reg & PCXHR_STAT_MIC_CAPS) mgr->board_has_mic = 1; /* microphone available */ - snd_printdd("MIC input available = %d\n", mgr->board_has_mic); + dev_dbg(&mgr->pci->dev, + "MIC input available = %d\n", mgr->board_has_mic); /* reset codec */ PCXHR_OUTPB(mgr, PCXHR_DSP, PCXHR_DSP_RESET, @@ -468,14 +455,17 @@ int hr222_sub_init(struct pcxhr_mgr *mgr) PCXHR_TI_CODECS_SETTLING_TIME_MS : PCXHR_AKM_CODECS_SETTLING_TIME_MS); - snd_printdd("init board %s\n", pcxhr_is_board_revision (mgr, PCXHR_BOARD_REVISION_7) ? "IE7" : "IE5"); + dev_dbg(&mgr->pci->dev, "init board %s\n", + pcxhr_is_board_revision (mgr, PCXHR_BOARD_REVISION_7) ? "IE7" : "IE5"); pcxhr_is_board_revision (mgr, PCXHR_BOARD_REVISION_7) ? hr222_ti_sub_init(mgr) : hr222_akm_sub_init(mgr); /* init micro boost */ hr222_micro_boost(mgr, 0); + return 0; } + /* calc PLL register */ /* TODO : there is a very similar fct in pcxhr.c */ static int hr222_compute_pll_freq_register(unsigned int freq, @@ -621,17 +611,15 @@ int hr222_sub_set_clock(struct pcxhr_mgr *mgr, mgr->sample_rate_real = realfreq; mgr->cur_clock_type = mgr->use_clock_type; - + if (changed) *changed = 1; - - snd_printdd("set_clock to %dHz (realfreq=%d pllreg=%x)\n", - rate, realfreq, pllreg); + dev_dbg(&mgr->pci->dev, "set_clock to %dHz (realfreq=%d pllreg=%x)\n", + rate, realfreq, pllreg); return 0; } - int hr222_get_external_clock(struct pcxhr_mgr *mgr, enum pcxhr_clock_type clock_type, int *sample_rate) @@ -653,13 +641,15 @@ int hr222_get_external_clock(struct pcxhr_mgr *mgr, reg = PCXHR_STAT_FREQ_UER1_MASK; } else { - snd_printdd("get_external_clock : type %d not supported\n", + dev_dbg(&mgr->pci->dev, + "get_external_clock : type %d not supported\n", clock_type); return -EINVAL; /* other clocks not supported */ } if ((PCXHR_INPB(mgr, PCXHR_DSP, PCXHR_XLX_CSUER) & mask) != mask) { - snd_printdd("get_external_clock(%d) = 0 Hz\n", clock_type); + dev_dbg(&mgr->pci->dev, + "get_external_clock(%d) = 0 Hz\n", clock_type); *sample_rate = 0; return 0; /* no external clock locked */ } @@ -717,7 +707,7 @@ int hr222_get_external_clock(struct pcxhr_mgr *mgr, else rate = 0; - snd_printdd("External clock is at %d Hz (measured %d Hz)\n", + dev_dbg(&mgr->pci->dev, "External clock is at %d Hz (measured %d Hz)\n", rate, calc_rate); *sample_rate = rate; return 0; @@ -750,7 +740,6 @@ int hr222_write_gpo(struct pcxhr_mgr *mgr, int value) return 0; } - int hr222_manage_timecode(struct pcxhr_mgr *mgr, int enable) { if (enable) @@ -762,12 +751,12 @@ int hr222_manage_timecode(struct pcxhr_mgr *mgr, int enable) return 0; } - int hr222_update_analog_audio_level(struct snd_pcxhr *chip, int is_capture, int channel) { - snd_printdd("hr222_update_analog_audio_level(%s chan=%d)\n", - is_capture ? "capture" : "playback", channel); + dev_dbg(chip->card->dev, + "hr222_update_analog_audio_level(%s chan=%d)\n", + snd_pcm_direction_name(is_capture), channel); if (is_capture) { int level_l, level_r, level_mic; /* we have to update all levels */ @@ -869,7 +858,7 @@ int hr222_iec958_capture_byte(struct snd_pcxhr *chip, if (PCXHR_INPB(chip->mgr, PCXHR_DSP, PCXHR_XLX_CSUER) & mask) temp |= 1; } - snd_printdd("read iec958 AES %d byte %d = 0x%x\n", + dev_dbg(chip->card->dev, "read iec958 AES %d byte %d = 0x%x\n", chip->chip_idx, aes_idx, temp); *aes_bits = temp; return 0; @@ -908,7 +897,7 @@ static void hr222_phantom_power(struct pcxhr_mgr *mgr, int power) PCXHR_OUTPB(mgr, PCXHR_DSP, PCXHR_XLX_SELMIC, mgr->xlx_selmic); - snd_printdd("hr222_phantom_power : set %d\n", power); + dev_dbg(&mgr->pci->dev, "hr222_phantom_power : set %d\n", power); } @@ -951,7 +940,7 @@ static int hr222_mic_vol_put(struct snd_kcontrol *kcontrol, return changed; } -static struct snd_kcontrol_new hr222_control_mic_level = { +static const struct snd_kcontrol_new hr222_control_mic_level = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ), @@ -1001,7 +990,7 @@ static int hr222_mic_boost_put(struct snd_kcontrol *kcontrol, return changed; } -static struct snd_kcontrol_new hr222_control_mic_boost = { +static const struct snd_kcontrol_new hr222_control_mic_boost = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ), @@ -1043,7 +1032,7 @@ static int hr222_phantom_power_put(struct snd_kcontrol *kcontrol, return changed; } -static struct snd_kcontrol_new hr222_phantom_power_switch = { +static const struct snd_kcontrol_new hr222_phantom_power_switch = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Phantom Power Switch", .info = hr222_phantom_power_info, |