aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/pci/atiixp_modem.c40
-rw-r--r--sound/pci/intel8x0m.c76
-rw-r--r--sound/pci/via82xx_modem.c28
3 files changed, 25 insertions, 119 deletions
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index 9220aae632b0..a6b4b8d589fd 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -463,6 +463,11 @@ static unsigned short snd_atiixp_ac97_read(ac97_t *ac97, unsigned short reg)
463static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) 463static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val)
464{ 464{
465 atiixp_t *chip = ac97->private_data; 465 atiixp_t *chip = ac97->private_data;
466 if (reg == AC97_GPIO_STATUS) {
467 atiixp_write(chip, MODEM_OUT_GPIO,
468 (val << ATI_REG_MODEM_OUT_GPIO_DATA_SHIFT) | ATI_REG_MODEM_OUT_GPIO_EN);
469 return;
470 }
466 snd_atiixp_codec_write(chip, ac97->num, reg, val); 471 snd_atiixp_codec_write(chip, ac97->num, reg, val);
467} 472}
468 473
@@ -663,44 +668,33 @@ static int snd_atiixp_pcm_trigger(snd_pcm_substream_t *substream, int cmd)
663{ 668{
664 atiixp_t *chip = snd_pcm_substream_chip(substream); 669 atiixp_t *chip = snd_pcm_substream_chip(substream);
665 atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data; 670 atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data;
666 unsigned int reg = 0; 671 int err = 0;
667 int i;
668 672
669 snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL); 673 snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL);
670 674
671 if (cmd != SNDRV_PCM_TRIGGER_START && cmd != SNDRV_PCM_TRIGGER_STOP)
672 return -EINVAL;
673
674 spin_lock(&chip->reg_lock); 675 spin_lock(&chip->reg_lock);
675 676 switch(cmd) {
676 /* hook off/on: via GPIO_OUT */ 677 case SNDRV_PCM_TRIGGER_START:
677 for (i = 0; i < NUM_ATI_CODECS; i++) {
678 if (chip->ac97[i]) {
679 reg = snd_ac97_read(chip->ac97[i], AC97_GPIO_STATUS);
680 break;
681 }
682 }
683 if(cmd == SNDRV_PCM_TRIGGER_START)
684 reg |= AC97_GPIO_LINE1_OH;
685 else
686 reg &= ~AC97_GPIO_LINE1_OH;
687 reg = (reg << ATI_REG_MODEM_OUT_GPIO_DATA_SHIFT) | ATI_REG_MODEM_OUT_GPIO_EN ;
688 atiixp_write(chip, MODEM_OUT_GPIO, reg);
689
690 if (cmd == SNDRV_PCM_TRIGGER_START) {
691 dma->ops->enable_transfer(chip, 1); 678 dma->ops->enable_transfer(chip, 1);
692 dma->running = 1; 679 dma->running = 1;
693 } else { 680 break;
681 case SNDRV_PCM_TRIGGER_STOP:
694 dma->ops->enable_transfer(chip, 0); 682 dma->ops->enable_transfer(chip, 0);
695 dma->running = 0; 683 dma->running = 0;
684 break;
685 default:
686 err = -EINVAL;
687 break;
696 } 688 }
689 if (! err) {
697 snd_atiixp_check_bus_busy(chip); 690 snd_atiixp_check_bus_busy(chip);
698 if (cmd == SNDRV_PCM_TRIGGER_STOP) { 691 if (cmd == SNDRV_PCM_TRIGGER_STOP) {
699 dma->ops->flush_dma(chip); 692 dma->ops->flush_dma(chip);
700 snd_atiixp_check_bus_busy(chip); 693 snd_atiixp_check_bus_busy(chip);
701 } 694 }
695 }
702 spin_unlock(&chip->reg_lock); 696 spin_unlock(&chip->reg_lock);
703 return 0; 697 return err;
704} 698}
705 699
706 700
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index f655cf914060..bb758c77d211 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -35,7 +35,6 @@
35#include <sound/pcm.h> 35#include <sound/pcm.h>
36#include <sound/ac97_codec.h> 36#include <sound/ac97_codec.h>
37#include <sound/info.h> 37#include <sound/info.h>
38#include <sound/control.h>
39#include <sound/initval.h> 38#include <sound/initval.h>
40 39
41MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 40MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
@@ -292,60 +291,9 @@ static struct pci_device_id snd_intel8x0m_ids[] = {
292#endif 291#endif
293 { 0, } 292 { 0, }
294}; 293};
295static int snd_intel8x0m_switch_default_get(snd_kcontrol_t *kcontrol,
296 snd_ctl_elem_value_t *ucontrol);
297static int snd_intel8x0m_switch_default_put(snd_kcontrol_t *kcontrol,
298 snd_ctl_elem_value_t *ucontrol);
299static int snd_intel8x0m_switch_default_info(snd_kcontrol_t *kcontrol,
300 snd_ctl_elem_info_t *uinfo);
301
302#define PRIVATE_VALUE_INITIALIZER(r,m) (((r) & 0xffff) << 16 | ((m) & 0xffff))
303#define PRIVATE_VALUE_MASK(control) ((control)->private_value & 0xffff)
304#define PRIVATE_VALUE_REG(control) (((control)->private_value >> 16) & 0xffff)
305
306static snd_kcontrol_new_t snd_intel8x0m_mixer_switches[] __devinitdata = {
307 { .name = "Off-hook Switch",
308 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
309 .info = snd_intel8x0m_switch_default_info,
310 .get = snd_intel8x0m_switch_default_get,
311 .put = snd_intel8x0m_switch_default_put,
312 .private_value = PRIVATE_VALUE_INITIALIZER(AC97_GPIO_STATUS,AC97_GPIO_LINE1_OH)
313 }
314};
315 294
316MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids); 295MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids);
317 296
318static int snd_intel8x0m_switch_default_info(snd_kcontrol_t *kcontrol,
319 snd_ctl_elem_info_t *uinfo)
320{
321 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
322 uinfo->count = 1;
323 uinfo->value.integer.min = 0;
324 uinfo->value.integer.max = 1;
325 return 0;
326}
327
328static int snd_intel8x0m_switch_default_get(snd_kcontrol_t *kcontrol,
329 snd_ctl_elem_value_t *ucontrol)
330{
331 unsigned short mask = PRIVATE_VALUE_MASK(kcontrol);
332 unsigned short reg = PRIVATE_VALUE_REG(kcontrol);
333 intel8x0_t *chip = snd_kcontrol_chip(kcontrol);
334 unsigned int status;
335 status = snd_ac97_read(chip->ac97, reg) & mask ? 1 : 0;
336 ucontrol->value.integer.value[0] = status;
337 return 0;
338}
339static int snd_intel8x0m_switch_default_put(snd_kcontrol_t *kcontrol,
340 snd_ctl_elem_value_t *ucontrol)
341{
342 unsigned short mask = PRIVATE_VALUE_MASK(kcontrol);
343 unsigned short reg = PRIVATE_VALUE_REG(kcontrol);
344 intel8x0_t *chip = snd_kcontrol_chip(kcontrol);
345 unsigned short new_status = ucontrol->value.integer.value[0] ? mask : ~mask;
346 return snd_ac97_update_bits(chip->ac97, reg,
347 mask, new_status);
348}
349/* 297/*
350 * Lowlevel I/O - busmaster 298 * Lowlevel I/O - busmaster
351 */ 299 */
@@ -700,21 +648,6 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(snd_pcm_substream_t * substrea
700 return bytes_to_frames(substream->runtime, ptr); 648 return bytes_to_frames(substream->runtime, ptr);
701} 649}
702 650
703static int snd_intel8x0m_pcm_trigger(snd_pcm_substream_t *substream, int cmd)
704{
705 /* hook off/on on start/stop */
706 /* Moved this to mixer control */
707 switch (cmd) {
708 case SNDRV_PCM_TRIGGER_START:
709 break;
710 case SNDRV_PCM_TRIGGER_STOP:
711 break;
712 default:
713 return -EINVAL;
714 }
715 return snd_intel8x0_pcm_trigger(substream,cmd);
716}
717
718static int snd_intel8x0m_pcm_prepare(snd_pcm_substream_t * substream) 651static int snd_intel8x0m_pcm_prepare(snd_pcm_substream_t * substream)
719{ 652{
720 intel8x0_t *chip = snd_pcm_substream_chip(substream); 653 intel8x0_t *chip = snd_pcm_substream_chip(substream);
@@ -810,7 +743,7 @@ static snd_pcm_ops_t snd_intel8x0m_playback_ops = {
810 .hw_params = snd_intel8x0_hw_params, 743 .hw_params = snd_intel8x0_hw_params,
811 .hw_free = snd_intel8x0_hw_free, 744 .hw_free = snd_intel8x0_hw_free,
812 .prepare = snd_intel8x0m_pcm_prepare, 745 .prepare = snd_intel8x0m_pcm_prepare,
813 .trigger = snd_intel8x0m_pcm_trigger, 746 .trigger = snd_intel8x0_pcm_trigger,
814 .pointer = snd_intel8x0_pcm_pointer, 747 .pointer = snd_intel8x0_pcm_pointer,
815}; 748};
816 749
@@ -821,7 +754,7 @@ static snd_pcm_ops_t snd_intel8x0m_capture_ops = {
821 .hw_params = snd_intel8x0_hw_params, 754 .hw_params = snd_intel8x0_hw_params,
822 .hw_free = snd_intel8x0_hw_free, 755 .hw_free = snd_intel8x0_hw_free,
823 .prepare = snd_intel8x0m_pcm_prepare, 756 .prepare = snd_intel8x0m_pcm_prepare,
824 .trigger = snd_intel8x0m_pcm_trigger, 757 .trigger = snd_intel8x0_pcm_trigger,
825 .pointer = snd_intel8x0_pcm_pointer, 758 .pointer = snd_intel8x0_pcm_pointer,
826}; 759};
827 760
@@ -949,7 +882,6 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock)
949 ac97_t *x97; 882 ac97_t *x97;
950 int err; 883 int err;
951 unsigned int glob_sta = 0; 884 unsigned int glob_sta = 0;
952 unsigned int idx;
953 static ac97_bus_ops_t ops = { 885 static ac97_bus_ops_t ops = {
954 .write = snd_intel8x0_codec_write, 886 .write = snd_intel8x0_codec_write,
955 .read = snd_intel8x0_codec_read, 887 .read = snd_intel8x0_codec_read,
@@ -985,10 +917,6 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock)
985 chip->ichd[ICHD_MDMIN].ac97 = x97; 917 chip->ichd[ICHD_MDMIN].ac97 = x97;
986 chip->ichd[ICHD_MDMOUT].ac97 = x97; 918 chip->ichd[ICHD_MDMOUT].ac97 = x97;
987 } 919 }
988 for (idx = 0; idx < ARRAY_SIZE(snd_intel8x0m_mixer_switches); idx++) {
989 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_intel8x0m_mixer_switches[idx], chip))) < 0)
990 goto __err;
991 }
992 920
993 chip->in_ac97_init = 0; 921 chip->in_ac97_init = 0;
994 return 0; 922 return 0;
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 276ce5299684..e10fceb3ede9 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -420,7 +420,10 @@ static void snd_via82xx_codec_write(ac97_t *ac97,
420{ 420{
421 via82xx_t *chip = ac97->private_data; 421 via82xx_t *chip = ac97->private_data;
422 unsigned int xval; 422 unsigned int xval;
423 423 if(reg == AC97_GPIO_STATUS) {
424 outl(val, VIAREG(chip, GPI_STATUS));
425 return;
426 }
424 xval = !ac97->num ? VIA_REG_AC97_CODEC_ID_PRIMARY : VIA_REG_AC97_CODEC_ID_SECONDARY; 427 xval = !ac97->num ? VIA_REG_AC97_CODEC_ID_PRIMARY : VIA_REG_AC97_CODEC_ID_SECONDARY;
425 xval <<= VIA_REG_AC97_CODEC_ID_SHIFT; 428 xval <<= VIA_REG_AC97_CODEC_ID_SHIFT;
426 xval |= reg << VIA_REG_AC97_CMD_SHIFT; 429 xval |= reg << VIA_REG_AC97_CMD_SHIFT;
@@ -544,25 +547,6 @@ static int snd_via82xx_pcm_trigger(snd_pcm_substream_t * substream, int cmd)
544 return 0; 547 return 0;
545} 548}
546 549
547static int snd_via82xx_modem_pcm_trigger(snd_pcm_substream_t * substream, int cmd)
548{
549 via82xx_t *chip = snd_pcm_substream_chip(substream);
550 unsigned int val = 0;
551 switch (cmd) {
552 case SNDRV_PCM_TRIGGER_START:
553 val = snd_ac97_read(chip->ac97, AC97_GPIO_STATUS);
554 outl(val|AC97_GPIO_LINE1_OH, VIAREG(chip, GPI_STATUS));
555 break;
556 case SNDRV_PCM_TRIGGER_STOP:
557 val = snd_ac97_read(chip->ac97, AC97_GPIO_STATUS);
558 outl(val&~AC97_GPIO_LINE1_OH, VIAREG(chip, GPI_STATUS));
559 break;
560 default:
561 break;
562 }
563 return snd_via82xx_pcm_trigger(substream, cmd);
564}
565
566/* 550/*
567 * pointer callbacks 551 * pointer callbacks
568 */ 552 */
@@ -806,7 +790,7 @@ static snd_pcm_ops_t snd_via686_playback_ops = {
806 .hw_params = snd_via82xx_hw_params, 790 .hw_params = snd_via82xx_hw_params,
807 .hw_free = snd_via82xx_hw_free, 791 .hw_free = snd_via82xx_hw_free,
808 .prepare = snd_via82xx_pcm_prepare, 792 .prepare = snd_via82xx_pcm_prepare,
809 .trigger = snd_via82xx_modem_pcm_trigger, 793 .trigger = snd_via82xx_pcm_trigger,
810 .pointer = snd_via686_pcm_pointer, 794 .pointer = snd_via686_pcm_pointer,
811 .page = snd_pcm_sgbuf_ops_page, 795 .page = snd_pcm_sgbuf_ops_page,
812}; 796};
@@ -819,7 +803,7 @@ static snd_pcm_ops_t snd_via686_capture_ops = {
819 .hw_params = snd_via82xx_hw_params, 803 .hw_params = snd_via82xx_hw_params,
820 .hw_free = snd_via82xx_hw_free, 804 .hw_free = snd_via82xx_hw_free,
821 .prepare = snd_via82xx_pcm_prepare, 805 .prepare = snd_via82xx_pcm_prepare,
822 .trigger = snd_via82xx_modem_pcm_trigger, 806 .trigger = snd_via82xx_pcm_trigger,
823 .pointer = snd_via686_pcm_pointer, 807 .pointer = snd_via686_pcm_pointer,
824 .page = snd_pcm_sgbuf_ops_page, 808 .page = snd_pcm_sgbuf_ops_page,
825}; 809};