Commit 9ac25594 authored by Jaya Kumar's avatar Jaya Kumar Committed by Jaroslav Kysela
Browse files

[ALSA] PM support for cs5535audio



Appended is my patch adding PM support to the cs5535audio driver.
I also added the ac97 quirk but it's not yet confirmed which
boards need to be in the quirk list. The patch also includes some
Kconfig and misc cleanup.

Signed-off-by: default avatarJaya Kumar <jayakumar.alsa@gmail.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 5e1b1518
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -216,14 +216,19 @@ config SND_CS46XX_NEW_DSP
	  This works better than the old code, so say Y.

config SND_CS5535AUDIO
	tristate "CS5535 Audio"
	tristate "CS5535/CS5536 Audio"
	depends on SND && X86 && !X86_64
	select SND_PCM
	select SND_AC97_CODEC
	help
	  Say Y here to include support for audio on CS5535 chips. It is
	  referred to as NS CS5535 IO or AMD CS5535 IO companion in
	  various literature.
	  various literature. This driver also supports the CS5536 audio
	  device. However, for both chips, on certain boards, you may
	  need to use ac97_quirk=hp_only if your board has physically 
	  mapped headphone out to master output. If that works for you,
	  send lspci -vvv output to the mailing list so that your board
	  can be identified in the quirks list.

	  To compile this driver as a module, choose M here: the module
	  will be called snd-cs5535audio.
+4 −0
Original line number Diff line number Diff line
@@ -4,5 +4,9 @@

snd-cs5535audio-objs := cs5535audio.o cs5535audio_pcm.o

ifdef CONFIG_PM
snd-cs5535audio-objs += cs5535audio_pm.o
endif

# Toplevel Module Dependency
obj-$(CONFIG_SND_CS5535AUDIO) += snd-cs5535audio.o
+26 −5
Original line number Diff line number Diff line
/*
 * Driver for audio on multifunction CS5535 companion device
 * Driver for audio on multifunction CS5535/6 companion device
 * Copyright (C) Jaya Kumar
 *
 * Based on Jaroslav Kysela and Takashi Iwai's examples.
@@ -40,16 +40,29 @@

#define DRIVER_NAME "cs5535audio"

static char *ac97_quirk;
module_param(ac97_quirk, charp, 0444);
MODULE_PARM_DESC(ac97_quirk, "AC'97 board specific workarounds.");

static struct ac97_quirk ac97_quirks[] __devinitdata = {
#if 0 /* Not yet confirmed if all 5536 boards are HP only */
	{
		.subvendor = PCI_VENDOR_ID_AMD, 
		.subdevice = PCI_DEVICE_ID_AMD_CS5536_AUDIO, 
		.name = "AMD RDK",     
		.type = AC97_TUNE_HP_ONLY
	},
#endif
	{}
};

static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;

static struct pci_device_id snd_cs5535audio_ids[] __devinitdata = {
	{ PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO,
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
	{ PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO,
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
	{ PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO) },
	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO) },
	{}
};

@@ -148,6 +161,8 @@ static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
		return err;
	}

	snd_ac97_tune_hardware(cs5535au->ac97, ac97_quirks, ac97_quirk);

	return 0;
}

@@ -347,6 +362,8 @@ static int __devinit snd_cs5535audio_probe(struct pci_dev *pci,
	if ((err = snd_cs5535audio_create(card, pci, &cs5535au)) < 0)
		goto probefail_out;

	card->private_data = cs5535au;

	if ((err = snd_cs5535audio_mixer(cs5535au)) < 0)
		goto probefail_out;

@@ -383,6 +400,10 @@ static struct pci_driver driver = {
	.id_table = snd_cs5535audio_ids,
	.probe = snd_cs5535audio_probe,
	.remove = __devexit_p(snd_cs5535audio_remove),
#ifdef CONFIG_PM
	.suspend = snd_cs5535audio_suspend,
	.resume = snd_cs5535audio_resume,
#endif
};

static int __init alsa_card_cs5535audio_init(void)
+8 −0
Original line number Diff line number Diff line
@@ -74,6 +74,8 @@
#define PRM_RDY_STS			0x00800000
#define ACC_CODEC_CNTL_WR_CMD		(~0x80000000)
#define ACC_CODEC_CNTL_RD_CMD		0x80000000
#define ACC_CODEC_CNTL_LNK_SHUTDOWN	0x00040000
#define ACC_CODEC_CNTL_LNK_WRM_RST	0x00020000
#define PRD_JMP				0x2000
#define PRD_EOP				0x4000
#define PRD_EOT				0x8000
@@ -88,6 +90,7 @@ struct cs5535audio_dma_ops {
	void (*disable_dma)(struct cs5535audio *cs5535au);
	void (*pause_dma)(struct cs5535audio *cs5535au);
	void (*setup_prd)(struct cs5535audio *cs5535au, u32 prd_addr);
	u32 (*read_prd)(struct cs5535audio *cs5535au);
	u32 (*read_dma_pntr)(struct cs5535audio *cs5535au);
};

@@ -103,11 +106,14 @@ struct cs5535audio_dma {
	struct snd_pcm_substream *substream;
	unsigned int buf_addr, buf_bytes;
	unsigned int period_bytes, periods;
	int suspended;
	u32 saved_prd;
};

struct cs5535audio {
	struct snd_card *card;
	struct snd_ac97 *ac97;
	struct snd_pcm *pcm;
	int irq;
	struct pci_dev *pci;
	unsigned long port;
@@ -117,6 +123,8 @@ struct cs5535audio {
	struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS];
};

int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state);
int snd_cs5535audio_resume(struct pci_dev *pci);
int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535audio);

#endif /* __SOUND_CS5535AUDIO_H */
+23 −1
Original line number Diff line number Diff line
@@ -43,7 +43,8 @@ static struct snd_pcm_hardware snd_cs5535audio_playback =
		 		SNDRV_PCM_INFO_BLOCK_TRANSFER |
		 		SNDRV_PCM_INFO_MMAP_VALID |
		 		SNDRV_PCM_INFO_PAUSE |
				SNDRV_PCM_INFO_SYNC_START
				SNDRV_PCM_INFO_SYNC_START |
				SNDRV_PCM_INFO_RESUME
				),
	.formats =		(
				SNDRV_PCM_FMTBIT_S16_LE
@@ -193,6 +194,11 @@ static void cs5535audio_playback_setup_prd(struct cs5535audio *cs5535au,
	cs_writel(cs5535au, ACC_BM0_PRD, prd_addr);
}

static u32 cs5535audio_playback_read_prd(struct cs5535audio *cs5535au)
{
	return cs_readl(cs5535au, ACC_BM0_PRD);
}

static u32 cs5535audio_playback_read_dma_pntr(struct cs5535audio *cs5535au)
{
	return cs_readl(cs5535au, ACC_BM0_PNTR);
@@ -219,6 +225,11 @@ static void cs5535audio_capture_setup_prd(struct cs5535audio *cs5535au,
	cs_writel(cs5535au, ACC_BM1_PRD, prd_addr);
}

static u32 cs5535audio_capture_read_prd(struct cs5535audio *cs5535au)
{
	return cs_readl(cs5535au, ACC_BM1_PRD);
}

static u32 cs5535audio_capture_read_dma_pntr(struct cs5535audio *cs5535au)
{
	return cs_readl(cs5535au, ACC_BM1_PNTR);
@@ -285,9 +296,17 @@ static int snd_cs5535audio_trigger(struct snd_pcm_substream *substream, int cmd)
	case SNDRV_PCM_TRIGGER_START:
		dma->ops->enable_dma(cs5535au);
		break;
	case SNDRV_PCM_TRIGGER_RESUME:
		dma->ops->enable_dma(cs5535au);
		dma->suspended = 0;
		break;
	case SNDRV_PCM_TRIGGER_STOP:
		dma->ops->disable_dma(cs5535au);
		break;
	case SNDRV_PCM_TRIGGER_SUSPEND:
		dma->ops->disable_dma(cs5535au);
		dma->suspended = 1;
		break;
	default:
		snd_printk(KERN_ERR "unhandled trigger\n");
		err = -EINVAL;
@@ -375,6 +394,7 @@ static struct cs5535audio_dma_ops snd_cs5535audio_playback_dma_ops = {
        .enable_dma = cs5535audio_playback_enable_dma,
        .disable_dma = cs5535audio_playback_disable_dma,
        .setup_prd = cs5535audio_playback_setup_prd,
        .read_prd = cs5535audio_playback_read_prd,
        .pause_dma = cs5535audio_playback_pause_dma,
        .read_dma_pntr = cs5535audio_playback_read_dma_pntr,
};
@@ -384,6 +404,7 @@ static struct cs5535audio_dma_ops snd_cs5535audio_capture_dma_ops = {
        .enable_dma = cs5535audio_capture_enable_dma,
        .disable_dma = cs5535audio_capture_disable_dma,
        .setup_prd = cs5535audio_capture_setup_prd,
        .read_prd = cs5535audio_capture_read_prd,
        .pause_dma = cs5535audio_capture_pause_dma,
        .read_dma_pntr = cs5535audio_capture_read_dma_pntr,
};
@@ -413,6 +434,7 @@ int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535au)
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
					snd_dma_pci_data(cs5535au->pci),
					64*1024, 128*1024);
	cs5535au->pcm = pcm;

	return 0;
}
Loading