diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-17 11:19:50 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:28:47 -0500 |
commit | 2b3f558727244efb6edb0866952331f537da13a4 (patch) | |
tree | 9aa637edbfc15af42fc4a11a7d8620afaed600c4 /sound/arm | |
parent | 792a6c51875c9d3b4a7b9af553b7fd18e8d84684 (diff) |
[ALSA] Use platform_device
Modules: SA11xx UDA1341 driver
Rewrite the probe/remove with platform_device.
Fix PM support, too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/arm')
-rw-r--r-- | sound/arm/sa11xx-uda1341.c | 78 |
1 files changed, 57 insertions, 21 deletions
diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c index 785726e627d0..3c342c1a7c80 100644 --- a/sound/arm/sa11xx-uda1341.c +++ b/sound/arm/sa11xx-uda1341.c | |||
@@ -21,7 +21,7 @@ | |||
21 | * merged HAL layer (patches from Brian) | 21 | * merged HAL layer (patches from Brian) |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* $Id: sa11xx-uda1341.c,v 1.25 2005/11/17 15:10:58 tiwai Exp $ */ | 24 | /* $Id: sa11xx-uda1341.c,v 1.26 2005/11/17 17:19:50 tiwai Exp $ */ |
25 | 25 | ||
26 | /*************************************************************************************************** | 26 | /*************************************************************************************************** |
27 | * | 27 | * |
@@ -64,6 +64,8 @@ | |||
64 | #include <linux/module.h> | 64 | #include <linux/module.h> |
65 | #include <linux/moduleparam.h> | 65 | #include <linux/moduleparam.h> |
66 | #include <linux/init.h> | 66 | #include <linux/init.h> |
67 | #include <linux/err.h> | ||
68 | #include <linux/platform_device.h> | ||
67 | #include <linux/errno.h> | 69 | #include <linux/errno.h> |
68 | #include <linux/ioctl.h> | 70 | #include <linux/ioctl.h> |
69 | #include <linux/delay.h> | 71 | #include <linux/delay.h> |
@@ -860,12 +862,15 @@ static int __init snd_card_sa11xx_uda1341_pcm(struct sa11xx_uda1341 *sa11xx_uda1 | |||
860 | 862 | ||
861 | #ifdef CONFIG_PM | 863 | #ifdef CONFIG_PM |
862 | 864 | ||
863 | static int snd_sa11xx_uda1341_suspend(struct snd_card *card, pm_message_t state) | 865 | static int snd_sa11xx_uda1341_suspend(struct platform_device *devptr, |
866 | pm_message_t state) | ||
864 | { | 867 | { |
865 | struct sa11xx_uda1341 *chip = card->pm_private_data; | 868 | struct snd_card *card = platform_get_drvdata(devptr); |
869 | struct sa11xx_uda1341 *chip = card->private_data; | ||
866 | 870 | ||
871 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
867 | snd_pcm_suspend_all(chip->pcm); | 872 | snd_pcm_suspend_all(chip->pcm); |
868 | #ifdef HH_VERSION | 873 | #ifdef HH_VERSION |
869 | sa1100_dma_sleep(chip->s[SNDRV_PCM_STREAM_PLAYBACK].dmach); | 874 | sa1100_dma_sleep(chip->s[SNDRV_PCM_STREAM_PLAYBACK].dmach); |
870 | sa1100_dma_sleep(chip->s[SNDRV_PCM_STREAM_CAPTURE].dmach); | 875 | sa1100_dma_sleep(chip->s[SNDRV_PCM_STREAM_CAPTURE].dmach); |
871 | #else | 876 | #else |
@@ -873,12 +878,14 @@ static int snd_sa11xx_uda1341_suspend(struct snd_card *card, pm_message_t state) | |||
873 | #endif | 878 | #endif |
874 | l3_command(chip->uda1341, CMD_SUSPEND, NULL); | 879 | l3_command(chip->uda1341, CMD_SUSPEND, NULL); |
875 | sa11xx_uda1341_audio_shutdown(chip); | 880 | sa11xx_uda1341_audio_shutdown(chip); |
881 | |||
876 | return 0; | 882 | return 0; |
877 | } | 883 | } |
878 | 884 | ||
879 | static int snd_sa11xx_uda1341_resume(struct snd_card *card) | 885 | static int snd_sa11xx_uda1341_resume(struct platform_device *devptr) |
880 | { | 886 | { |
881 | struct sa11xx_uda1341 *chip = card->pm_private_data; | 887 | struct snd_card *card = platform_get_drvdata(devptr); |
888 | struct sa11xx_uda1341 *chip = card->private_data; | ||
882 | 889 | ||
883 | sa11xx_uda1341_audio_init(chip); | 890 | sa11xx_uda1341_audio_init(chip); |
884 | l3_command(chip->uda1341, CMD_RESUME, NULL); | 891 | l3_command(chip->uda1341, CMD_RESUME, NULL); |
@@ -888,6 +895,7 @@ static int snd_sa11xx_uda1341_resume(struct snd_card *card) | |||
888 | #else | 895 | #else |
889 | //FIXME | 896 | //FIXME |
890 | #endif | 897 | #endif |
898 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
891 | return 0; | 899 | return 0; |
892 | } | 900 | } |
893 | #endif /* COMFIG_PM */ | 901 | #endif /* COMFIG_PM */ |
@@ -900,27 +908,22 @@ void snd_sa11xx_uda1341_free(struct snd_card *card) | |||
900 | audio_dma_free(&chip->s[SNDRV_PCM_STREAM_CAPTURE]); | 908 | audio_dma_free(&chip->s[SNDRV_PCM_STREAM_CAPTURE]); |
901 | } | 909 | } |
902 | 910 | ||
903 | static struct snd_card *sa11xx_uda1341_card; | 911 | static int __init sa11xx_uda1341_probe(struct platform_device *devptr) |
904 | |||
905 | static int __init sa11xx_uda1341_init(void) | ||
906 | { | 912 | { |
907 | int err; | 913 | int err; |
908 | struct snd_card *card; | 914 | struct snd_card *card; |
909 | struct sa11xx_uda1341 *chip; | 915 | struct sa11xx_uda1341 *chip; |
910 | 916 | ||
911 | if (!machine_is_h3xxx()) | ||
912 | return -ENODEV; | ||
913 | |||
914 | /* register the soundcard */ | 917 | /* register the soundcard */ |
915 | card = snd_card_new(-1, id, THIS_MODULE, sizeof(struct sa11xx_uda1341)); | 918 | card = snd_card_new(-1, id, THIS_MODULE, sizeof(struct sa11xx_uda1341)); |
916 | if (card == NULL) | 919 | if (card == NULL) |
917 | return -ENOMEM; | 920 | return -ENOMEM; |
918 | 921 | ||
919 | card->private_free = snd_sa11xx_uda1341_free; | ||
920 | chip = card->private_data; | 922 | chip = card->private_data; |
921 | spin_lock_init(&chip->s[0].dma_lock); | 923 | spin_lock_init(&chip->s[0].dma_lock); |
922 | spin_lock_init(&chip->s[1].dma_lock); | 924 | spin_lock_init(&chip->s[1].dma_lock); |
923 | 925 | ||
926 | card->private_free = snd_sa11xx_uda1341_free; | ||
924 | chip->card = card; | 927 | chip->card = card; |
925 | chip->samplerate = AUDIO_RATE_DEFAULT; | 928 | chip->samplerate = AUDIO_RATE_DEFAULT; |
926 | 929 | ||
@@ -932,20 +935,15 @@ static int __init sa11xx_uda1341_init(void) | |||
932 | if ((err = snd_card_sa11xx_uda1341_pcm(chip, 0)) < 0) | 935 | if ((err = snd_card_sa11xx_uda1341_pcm(chip, 0)) < 0) |
933 | goto nodev; | 936 | goto nodev; |
934 | 937 | ||
935 | snd_card_set_generic_pm_callback(card, | ||
936 | snd_sa11xx_uda1341_suspend, snd_sa11_uda1341_resume, | ||
937 | chip); | ||
938 | |||
939 | strcpy(card->driver, "UDA1341"); | 938 | strcpy(card->driver, "UDA1341"); |
940 | strcpy(card->shortname, "H3600 UDA1341TS"); | 939 | strcpy(card->shortname, "H3600 UDA1341TS"); |
941 | sprintf(card->longname, "Compaq iPAQ H3600 with Philips UDA1341TS"); | 940 | sprintf(card->longname, "Compaq iPAQ H3600 with Philips UDA1341TS"); |
942 | 941 | ||
943 | if ((err = snd_card_set_generic_dev(card)) < 0) | 942 | snd_card_set_dev(card, &devptr->dev); |
944 | goto nodev; | ||
945 | 943 | ||
946 | if ((err = snd_card_register(card)) == 0) { | 944 | if ((err = snd_card_register(card)) == 0) { |
947 | printk( KERN_INFO "iPAQ audio support initialized\n" ); | 945 | printk( KERN_INFO "iPAQ audio support initialized\n" ); |
948 | sa11xx_uda1341_card = card; | 946 | platform_set_drvdata(devptr, card); |
949 | return 0; | 947 | return 0; |
950 | } | 948 | } |
951 | 949 | ||
@@ -954,9 +952,47 @@ static int __init sa11xx_uda1341_init(void) | |||
954 | return err; | 952 | return err; |
955 | } | 953 | } |
956 | 954 | ||
955 | static int __devexit sa11xx_uda1341_remove(struct platform_device *devptr) | ||
956 | { | ||
957 | snd_card_free(platform_get_drvdata(devptr)); | ||
958 | platform_set_drvdata(devptr, NULL); | ||
959 | return 0; | ||
960 | } | ||
961 | |||
962 | #define SA11XX_UDA1341_DRIVER "sa11xx_uda1341" | ||
963 | |||
964 | static struct platform_driver sa11xx_uda1341_driver = { | ||
965 | .probe = sa11xx_uda1341_probe, | ||
966 | .remove = __devexit_p(sa11xx_uda1341_remove), | ||
967 | #ifdef CONFIG_PM | ||
968 | .suspend = snd_sa11xx_uda1341_suspend, | ||
969 | .resume = snd_sa11xx_uda1341_resume, | ||
970 | #endif | ||
971 | .driver = { | ||
972 | .name = SA11XX_UDA1341_DRIVER, | ||
973 | }, | ||
974 | }; | ||
975 | |||
976 | static int __init sa11xx_uda1341_init(void) | ||
977 | { | ||
978 | int err; | ||
979 | struct platform_device *device; | ||
980 | |||
981 | if (!machine_is_h3xxx()) | ||
982 | return -ENODEV; | ||
983 | if ((err = platform_driver_register(&sa11xx_uda1341_driver)) < 0) | ||
984 | return err; | ||
985 | device = platform_device_register_simple(SA11XX_UDA1341_DRIVER, -1, NULL, 0); | ||
986 | if (IS_ERR(device)) { | ||
987 | platform_driver_unregister(&sa11xx_uda1341_driver); | ||
988 | return PTR_ERR(device); | ||
989 | } | ||
990 | return 0; | ||
991 | } | ||
992 | |||
957 | static void __exit sa11xx_uda1341_exit(void) | 993 | static void __exit sa11xx_uda1341_exit(void) |
958 | { | 994 | { |
959 | snd_card_free(sa11xx_uda1341_card); | 995 | platform_driver_unregister(&sa11xx_uda1341_driver); |
960 | } | 996 | } |
961 | 997 | ||
962 | module_init(sa11xx_uda1341_init); | 998 | module_init(sa11xx_uda1341_init); |