Commit a29211b9 authored by Jaroslav Kysela's avatar Jaroslav Kysela

ALSA CVS update - Takashi Iwai <tiwai@suse.de>

SA11xx UDA1341 driver,UDA1341
- clean up PM codes using the new PM callback functions.
parent 0f2c1fd4
......@@ -15,7 +15,7 @@
* features support
*/
/* $Id: uda1341.h,v 1.5 2003/04/19 13:34:32 perex Exp $ */
/* $Id: uda1341.h,v 1.6 2004/05/03 17:36:50 tiwai Exp $ */
#define UDA1341_ALSA_NAME "snd-uda1341"
......
......@@ -21,7 +21,7 @@
* merged HAL layer (patches from Brian)
*/
/* $Id: sa11xx-uda1341.c,v 1.14 2004/04/07 17:48:10 tiwai Exp $ */
/* $Id: sa11xx-uda1341.c,v 1.15 2004/05/03 17:36:50 tiwai Exp $ */
/***************************************************************************************************
*
......@@ -137,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;
......@@ -868,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);
......@@ -884,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
......@@ -901,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;
......@@ -985,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");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment