summaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-04-01 10:02:18 +0200
committerTakashi Iwai <tiwai@suse.de>2008-04-24 12:00:30 +0200
commite97f79994ac715e4c8724b201bd3328463ec9314 (patch)
treea8cc01dc674185458964ee4636fabce8e71d3726 /sound/pci/oxygen
parent0c4cc4430f40089bb85557e309038faa458247f1 (diff)
downloadop-kernel-dev-e97f79994ac715e4c8724b201bd3328463ec9314.zip
op-kernel-dev-e97f79994ac715e4c8724b201bd3328463ec9314.tar.gz
[ALSA] oxygen: fix line-in recording selection (now for real)
On C-Media cards, the GPIO pin 0 of the CM9780 must be handled exactly like on Xonar cards, so move the Xonar code to the common mixer code. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/oxygen')
-rw-r--r--sound/pci/oxygen/oxygen.c33
-rw-r--r--sound/pci/oxygen/oxygen.h2
-rw-r--r--sound/pci/oxygen/oxygen_lib.c2
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c33
-rw-r--r--sound/pci/oxygen/virtuoso.c53
5 files changed, 31 insertions, 92 deletions
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index 511ef34..b3b7771 100644
--- a/sound/pci/oxygen/oxygen.c
+++ b/sound/pci/oxygen/oxygen.c
@@ -39,7 +39,6 @@
#include <sound/tlv.h>
#include "oxygen.h"
#include "ak4396.h"
-#include "cm9780.h"
#include "wm8785.h"
MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
@@ -79,8 +78,6 @@ MODULE_DEVICE_TABLE(pci, oxygen_ids);
#define GPIO_AK5385_DFS_DOUBLE 0x0001
#define GPIO_AK5385_DFS_QUAD 0x0002
-#define GPIO_LINE_MUTE CM9780_GPO0
-
struct generic_data {
u8 ak4396_ctl2;
};
@@ -145,23 +142,16 @@ static void wm8785_init(struct oxygen *chip)
snd_component_add(chip->card, "WM8785");
}
-static void cmi9780_init(struct oxygen *chip)
-{
- oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS, GPIO_LINE_MUTE);
-}
-
static void generic_init(struct oxygen *chip)
{
ak4396_init(chip);
wm8785_init(chip);
- cmi9780_init(chip);
}
static void meridian_init(struct oxygen *chip)
{
ak4396_init(chip);
ak5385_init(chip);
- cmi9780_init(chip);
}
static void generic_cleanup(struct oxygen *chip)
@@ -257,27 +247,6 @@ static void set_ak5385_params(struct oxygen *chip,
value, GPIO_AK5385_DFS_MASK);
}
-static void cmi9780_switch_hook(struct oxygen *chip, unsigned int codec,
- unsigned int reg, int mute)
-{
- if (codec != 0)
- return;
- switch (reg) {
- case AC97_LINE:
- oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
- mute ? GPIO_LINE_MUTE : 0,
- GPIO_LINE_MUTE);
- break;
- case AC97_MIC:
- case AC97_CD:
- case AC97_AUX:
- if (!mute)
- oxygen_ac97_set_bits(chip, 0, CM9780_GPIO_STATUS,
- GPIO_LINE_MUTE);
- break;
- }
-}
-
static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0);
static int ak4396_control_filter(struct snd_kcontrol_new *template)
@@ -301,7 +270,6 @@ static const struct oxygen_model model_generic = {
.set_adc_params = set_wm8785_params,
.update_dac_volume = update_ak4396_volume,
.update_dac_mute = update_ak4396_mute,
- .ac97_switch_hook = cmi9780_switch_hook,
.model_data_size = sizeof(struct generic_data),
.pcm_dev_cfg = PLAYBACK_0_TO_I2S |
PLAYBACK_1_TO_SPDIF |
@@ -327,7 +295,6 @@ static const struct oxygen_model model_meridian = {
.set_adc_params = set_ak5385_params,
.update_dac_volume = update_ak4396_volume,
.update_dac_mute = update_ak4396_mute,
- .ac97_switch_hook = cmi9780_switch_hook,
.model_data_size = sizeof(struct generic_data),
.pcm_dev_cfg = PLAYBACK_0_TO_I2S |
PLAYBACK_1_TO_SPDIF |
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h
index 5103482..2f25c8d 100644
--- a/sound/pci/oxygen/oxygen.h
+++ b/sound/pci/oxygen/oxygen.h
@@ -97,8 +97,6 @@ struct oxygen_model {
struct snd_pcm_hw_params *params);
void (*update_dac_volume)(struct oxygen *chip);
void (*update_dac_mute)(struct oxygen *chip);
- void (*ac97_switch_hook)(struct oxygen *chip, unsigned int codec,
- unsigned int reg, int mute);
void (*gpio_changed)(struct oxygen *chip);
size_t model_data_size;
unsigned int pcm_dev_cfg;
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index 858e6d4..4f3d9e5 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -360,6 +360,8 @@ static void oxygen_init(struct oxygen *chip)
oxygen_write_ac97(chip, 0, AC97_REC_GAIN, 0x8000);
oxygen_write_ac97(chip, 0, AC97_CENTER_LFE_MASTER, 0x8080);
oxygen_write_ac97(chip, 0, AC97_SURROUND_MASTER, 0x8080);
+ oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS,
+ CM9780_GPO0);
/* power down unused ADCs and DACs */
oxygen_ac97_set_bits(chip, 0, AC97_POWERDOWN,
AC97_PD_PR0 | AC97_PD_PR1);
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index 6b5ff6e..9a7c880 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -510,6 +510,19 @@ static int ac97_switch_get(struct snd_kcontrol *ctl,
return 0;
}
+static void mute_ac97_ctl(struct oxygen *chip, unsigned int control)
+{
+ unsigned int priv_idx = chip->controls[control]->private_value & 0xff;
+ u16 value;
+
+ value = oxygen_read_ac97(chip, 0, priv_idx);
+ if (!(value & 0x8000)) {
+ oxygen_write_ac97(chip, 0, priv_idx, value | 0x8000);
+ snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
+ &chip->controls[control]->id);
+ }
+}
+
static int ac97_switch_put(struct snd_kcontrol *ctl,
struct snd_ctl_elem_value *value)
{
@@ -531,9 +544,22 @@ static int ac97_switch_put(struct snd_kcontrol *ctl,
change = newreg != oldreg;
if (change) {
oxygen_write_ac97(chip, codec, index, newreg);
- if (bitnr == 15 && chip->model->ac97_switch_hook)
- chip->model->ac97_switch_hook(chip, codec, index,
- newreg & 0x8000);
+ if (index == AC97_LINE) {
+ oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
+ newreg & 0x8000 ?
+ CM9780_GPO0 : 0, CM9780_GPO0);
+ if (!(newreg & 0x8000)) {
+ mute_ac97_ctl(chip, CONTROL_MIC_CAPTURE_SWITCH);
+ mute_ac97_ctl(chip, CONTROL_CD_CAPTURE_SWITCH);
+ mute_ac97_ctl(chip, CONTROL_AUX_CAPTURE_SWITCH);
+ }
+ } else if ((index == AC97_MIC || index == AC97_CD ||
+ index == AC97_VIDEO || index == AC97_AUX) &&
+ bitnr == 15 && !(newreg & 0x8000)) {
+ mute_ac97_ctl(chip, CONTROL_LINE_CAPTURE_SWITCH);
+ oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
+ CM9780_GPO0, CM9780_GPO0);
+ }
}
mutex_unlock(&chip->mutex);
return change;
@@ -849,7 +875,6 @@ static const struct snd_kcontrol_new ac97_controls[] = {
AC97_VOLUME("Mic Capture Volume", 0, AC97_MIC),
AC97_SWITCH("Mic Capture Switch", 0, AC97_MIC, 15, 1),
AC97_SWITCH("Mic Boost (+20dB)", 0, AC97_MIC, 6, 0),
- AC97_VOLUME("Line Capture Volume", 0, AC97_LINE),
AC97_SWITCH("Line Capture Switch", 0, AC97_LINE, 15, 1),
AC97_VOLUME("CD Capture Volume", 0, AC97_CD),
AC97_SWITCH("CD Capture Switch", 0, AC97_CD, 15, 1),
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index fa79db6..2c3daf3 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -30,10 +30,6 @@
* GPIO 5 <- external power present (D2X only)
* GPIO 7 -> ALT
* GPIO 8 -> enable output to speakers
- *
- * CM9780:
- *
- * GPIO 0 -> enable AC'97 bypass (line in -> ADC)
*/
#include <linux/pci.h>
@@ -81,8 +77,6 @@ MODULE_DEVICE_TABLE(pci, xonar_ids);
#define GPIO_ALT 0x0080
#define GPIO_OUTPUT_ENABLE 0x0100
-#define GPIO_LINE_MUTE CM9780_GPO0
-
struct xonar_data {
u8 is_d2x;
u8 has_power;
@@ -134,7 +128,6 @@ static void xonar_init(struct oxygen *chip)
& GPIO_EXT_POWER);
}
oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC);
- oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS, GPIO_LINE_MUTE);
msleep(300);
oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_OUTPUT_ENABLE);
oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE);
@@ -219,49 +212,6 @@ static void xonar_gpio_changed(struct oxygen *chip)
}
}
-static void mute_ac97_ctl(struct oxygen *chip, unsigned int control)
-{
- unsigned int priv_idx = chip->controls[control]->private_value & 0xff;
- u16 value;
-
- value = oxygen_read_ac97(chip, 0, priv_idx);
- if (!(value & 0x8000)) {
- oxygen_write_ac97(chip, 0, priv_idx, value | 0x8000);
- snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
- &chip->controls[control]->id);
- }
-}
-
-static void xonar_ac97_switch_hook(struct oxygen *chip, unsigned int codec,
- unsigned int reg, int mute)
-{
- if (codec != 0)
- return;
- /* line-in is exclusive */
- switch (reg) {
- case AC97_LINE:
- oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
- mute ? GPIO_LINE_MUTE : 0,
- GPIO_LINE_MUTE);
- if (!mute) {
- mute_ac97_ctl(chip, CONTROL_MIC_CAPTURE_SWITCH);
- mute_ac97_ctl(chip, CONTROL_CD_CAPTURE_SWITCH);
- mute_ac97_ctl(chip, CONTROL_AUX_CAPTURE_SWITCH);
- }
- break;
- case AC97_MIC:
- case AC97_CD:
- case AC97_VIDEO:
- case AC97_AUX:
- if (!mute) {
- oxygen_ac97_set_bits(chip, 0, CM9780_GPIO_STATUS,
- GPIO_LINE_MUTE);
- mute_ac97_ctl(chip, CONTROL_LINE_CAPTURE_SWITCH);
- }
- break;
- }
-}
-
static int pcm1796_volume_info(struct snd_kcontrol *ctl,
struct snd_ctl_elem_info *info)
{
@@ -321,8 +271,6 @@ static int xonar_control_filter(struct snd_kcontrol_new *template)
} else if (!strncmp(template->name, "CD Capture ", 11)) {
/* CD in is actually connected to the video in pin */
template->private_value ^= AC97_CD ^ AC97_VIDEO;
- } else if (!strcmp(template->name, "Line Capture Volume")) {
- return 1; /* line-in bypasses the AC'97 mixer */
}
return 0;
}
@@ -345,7 +293,6 @@ static const struct oxygen_model model_xonar = {
.set_adc_params = set_cs5381_params,
.update_dac_volume = update_pcm1796_volume,
.update_dac_mute = update_pcm1796_mute,
- .ac97_switch_hook = xonar_ac97_switch_hook,
.gpio_changed = xonar_gpio_changed,
.model_data_size = sizeof(struct xonar_data),
.pcm_dev_cfg = PLAYBACK_0_TO_I2S |
OpenPOWER on IntegriCloud