X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Farm%2Fsa11xx-uda1341.c;h=59916802c914d2856f1e1c16acb76292fdfc5e2e;hb=918425d07b2fe2087ee7dabf90e69a17e914649c;hp=d198e939a216321b3fb433b6ca0ecd39eb721125;hpb=86090fcac5e27b630656fe3d963a6b80e26dac44;p=linux-2.6.git diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c index d198e939a..59916802c 100644 --- a/sound/arm/sa11xx-uda1341.c +++ b/sound/arm/sa11xx-uda1341.c @@ -21,7 +21,7 @@ * merged HAL layer (patches from Brian) */ -/* $Id: sa11xx-uda1341.c,v 1.13 2004/03/02 15:32:35 perex Exp $ */ +/* $Id: sa11xx-uda1341.c,v 1.15 2004/05/03 17:36:50 tiwai Exp $ */ /*************************************************************************************************** * @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -112,7 +113,7 @@ MODULE_DEVICES("{{UDA1341,iPAQ H3600 UDA1341TS}}"); static char *id = NULL; /* ID for this card */ -MODULE_PARM(id, "s"); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for SA1100/SA1111 + UDA1341TS soundcard."); #define chip_t sa11xx_uda1341_t @@ -136,7 +137,6 @@ typedef struct audio_stream { }audio_stream_t; typedef struct snd_card_sa11xx_uda1341 { - struct pm_dev *pm_dev; snd_card_t *card; struct l3_client *uda1341; snd_pcm_t *pcm; @@ -867,12 +867,10 @@ static int __init snd_card_sa11xx_uda1341_pcm(sa11xx_uda1341_t *sa11xx_uda1341, #ifdef CONFIG_PM -static void snd_sa11xx_uda1341_suspend(sa11xx_uda1341_t *chip) +static int snd_sa11xx_uda1341_suspend(snd_card_t *card, unsigned int state) { - snd_card_t *card = chip->card; + sa11xx_uda1341_t *chip = snd_magic_cast(sa11x_uda1341_t, card->pm_private_data, return -EINVAL); - if (card->power_state == SNDRV_CTL_POWER_D3hot) - return; snd_pcm_suspend_all(chip->pcm); #ifdef HH_VERSION sa1100_dma_sleep(chip->s[SNDRV_PCM_STREAM_PLAYBACK].dmach); @@ -883,14 +881,13 @@ static void snd_sa11xx_uda1341_suspend(sa11xx_uda1341_t *chip) l3_command(chip->uda1341, CMD_SUSPEND, NULL); sa11xx_uda1341_audio_shutdown(chip); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + return 0; } -static void snd_sa11xx_uda1341_resume(sa11xx_uda1341_t *chip) +static int snd_sa11xx_uda1341_resume(snd_card_t *card, unsigned int state) { - snd_card_t *card = chip->card; + sa11xx_uda1341_t *chip = snd_magic_cast(sa11x_uda1341_t, card->pm_private_data, return -EINVAL); - if (card->power_state == SNDRV_CTL_POWER_D0) - return; sa11xx_uda1341_audio_init(chip); l3_command(chip->uda1341, CMD_RESUME, NULL); #ifdef HH_VERSION @@ -900,50 +897,14 @@ static void snd_sa11xx_uda1341_resume(sa11xx_uda1341_t *chip) //FIXME #endif snd_power_change_state(card, SNDRV_CTL_POWER_D0); -} - -static int sa11xx_uda1341_pm_callback(struct pm_dev *pm_dev, pm_request_t req, void *data) -{ - sa11xx_uda1341_t *chip = pm_dev->data; - - switch (req) { - case PM_SUSPEND: /* enter D1-D3 */ - snd_sa11xx_uda1341_suspend(chip); - break; - case PM_RESUME: /* enter D0 */ - snd_sa11xx_uda1341_resume(chip); - break; - } return 0; } - -static int sa11xx_uda1341_set_power_state(snd_card_t *card, unsigned int power_state) -{ - sa11xx_uda1341_t *chip = snd_magic_cast(sa11xx_uda1341_t, card->power_state_private_data, return); - - switch (power_state) { - case SNDRV_CTL_POWER_D0: - case SNDRV_CTL_POWER_D1: - case SNDRV_CTL_POWER_D2: - snd_sa11xx_uda1341_resume(chip); - break; - case SNDRV_CTL_POWER_D3hot: - case SNDRV_CTL_POWER_D3cold: - snd_sa11xx_uda1341_suspend(chip); - break; - default: - return -EINVAL; - } - return 0; -} - #endif /* COMFIG_PM */ void snd_sa11xx_uda1341_free(snd_card_t *card) { sa11xx_uda1341_t *chip = snd_magic_cast(sa11xx_uda1341_t, card->private_data, return); - pm_unregister(chip->pm_dev); audio_dma_free(&chip->s[SNDRV_PCM_STREAM_PLAYBACK]); audio_dma_free(&chip->s[SNDRV_PCM_STREAM_CAPTURE]); sa11xx_uda1341 = NULL; @@ -984,15 +945,10 @@ static int __init sa11xx_uda1341_init(void) if ((err = snd_card_sa11xx_uda1341_pcm(sa11xx_uda1341, 0)) < 0) goto nodev; - -#ifdef CONFIG_PM - card->power_state_private_data = sa11xx_uda1341; - card->set_power_state = sa11xx_uda1341_set_power_state; - sa11xx_uda1341->pm_dev = pm_register(PM_SYS_DEV, 0, sa11xx_uda1341_pm_callback); - if (sa11xx_uda1341->pm_dev) - sa11xx_uda1341->pm_dev->data = sa11xx_uda1341; -#endif - + snd_card_set_dev_pm_callback(card, PM_SYS_DEV, + snd_sa11xx_uda1341_suspend, snd_sa11_uda1341_resume, + sa11xx_uda1341); + strcpy(card->driver, "UDA1341"); strcpy(card->shortname, "H3600 UDA1341TS"); sprintf(card->longname, "Compaq iPAQ H3600 with Philips UDA1341TS");