···636636 3stack-digout 3-jack in back, a HP out and a SPDIF out637637 5stack 5-jack in back, 2-jack in front638638 5stack-digout 5-jack in back, 2-jack in front, a SPDIF out639639+ 6stack 6-jack in back, 2-jack in front640640+ 6stack-digout 6-jack with a SPDIF out639641 w810 3-jack640642 z71v 3-jack (HP shared SPDIF)641643 asus 3-jack642644 uniwill 3-jack643645 F1734 2-jack646646+ test for testing/debugging purpose, almost all controls can be647647+ adjusted. Appearing only when compiled with648648+ $CONFIG_SND_DEBUG=y644649645650 CMI9880646651 minimal 3-jack in back···1059105410601055 The power-management is supported.1061105610571057+ Module snd-pxa2xx-ac97 (on arm only)10581058+ ------------------------------------10591059+10601060+ Module for AC97 driver for the Intel PXA2xx chip10611061+10621062+ For ARM architecture only.10631063+10621064 Module snd-rme3210631065 ----------------10641066···11821170 -------------------------------------1183117111841172 Module for CS4231 sound chips found on Sparcs.11731173+11741174+ Module supports up to 8 cards.11751175+11761176+ Module snd-sun-dbri (on sparc only)11771177+ -----------------------------------11781178+11791179+ Module for DBRI sound chips found on Sparcs.1185118011861181 Module supports up to 8 cards.11871182···13901371 Module snd-vxpocket13911372 -------------------1392137313931393- Module for Digigram VX-Pocket VX2 PCMCIA card.13741374+ Module for Digigram VX-Pocket VX2 and 440 PCMCIA cards.1394137513951376 ibl - Capture IBL size. (default = 0, minimum size)13961377···1399138014001381 To activate the driver via the card manager, you'll need to set14011382 up /etc/pcmcia/vxpocket.conf. See the sound/pcmcia/vx/vxpocket.c.14021402-14031403- When the driver is compiled as a module and the hotplug firmware14041404- is supported, the firmware data is loaded via hotplug automatically.14051405- Install the necessary firmware files in alsa-firmware package.14061406- When no hotplug fw loader is available, you need to load the14071407- firmware via vxloader utility in alsa-tools package.14081408-14091409- About capture IBL, see the description of snd-vx222 module.14101410-14111411- Note: the driver is build only when CONFIG_ISA is set.14121412-14131413- Module snd-vxp44014141414- -----------------14151415-14161416- Module for Digigram VX-Pocket 440 PCMCIA card.14171417-14181418- ibl - Capture IBL size. (default = 0, minimum size)14191419-14201420- Module supports up to 8 cards. The module is compiled only when14211421- PCMCIA is supported on kernel.14221422-14231423- To activate the driver via the card manager, you'll need to set14241424- up /etc/pcmcia/vxp440.conf. See the sound/pcmcia/vx/vxp440.c.1425138314261384 When the driver is compiled as a module and the hotplug firmware14271385 is supported, the firmware data is loaded via hotplug automatically.
+20-17
include/sound/core.h
···126126 struct snd_monitor_file *next;127127};128128129129-struct snd_shutdown_f_ops; /* define it later */129129+struct snd_shutdown_f_ops; /* define it later in init.c */130130131131/* main structure for soundcard */132132133133struct _snd_card {134134- int number; /* number of soundcard (index to snd_cards) */134134+ int number; /* number of soundcard (index to135135+ snd_cards) */135136136137 char id[16]; /* id string of this card */137138 char driver[16]; /* driver name */138139 char shortname[32]; /* short name of this soundcard */139140 char longname[80]; /* name of this soundcard */140141 char mixername[80]; /* mixer name */141141- char components[80]; /* card components delimited with space */142142-142142+ char components[80]; /* card components delimited with143143+ space */143144 struct module *module; /* top-level module */144145145146 void *private_data; /* private data for soundcard */146146- void (*private_free) (snd_card_t *card); /* callback for freeing of private data */147147-147147+ void (*private_free) (snd_card_t *card); /* callback for freeing of148148+ private data */148149 struct list_head devices; /* devices */149150150151 unsigned int last_numid; /* last used numeric ID */···161160 struct proc_dir_entry *proc_root_link; /* number link to real id */162161163162 struct snd_monitor_file *files; /* all files associated to this card */164164- struct snd_shutdown_f_ops *s_f_ops; /* file operations in the shutdown state */163163+ struct snd_shutdown_f_ops *s_f_ops; /* file operations in the shutdown164164+ state */165165 spinlock_t files_lock; /* lock the files for this card */166166 int shutdown; /* this card is going down */167167 wait_queue_head_t shutdown_sleep;···198196 up(&card->power_lock);199197}200198201201-int snd_power_wait(snd_card_t *card, unsigned int power_state, struct file *file);202202-203199static inline unsigned int snd_power_get_state(snd_card_t *card)204200{205201 return card->power_state;···208208 card->power_state = state;209209 wake_up(&card->power_sleep);210210}211211+212212+/* init.c */213213+int snd_power_wait(snd_card_t *card, unsigned int power_state, struct file *file);214214+211215int snd_card_set_pm_callback(snd_card_t *card,212216 int (*suspend)(snd_card_t *, pm_message_t),213217 int (*resume)(snd_card_t *),···242238243239#endif /* CONFIG_PM */244240245245-/* device.c */246246-247241struct _snd_minor {248242 struct list_head list; /* list of all minors per card */249243 int number; /* minor number */250244 int device; /* device number */251245 const char *comment; /* for /proc/asound/devices */252246 struct file_operations *f_ops; /* file operations */253253- char name[0]; /* device name (keep at the end of structure) */247247+ char name[0]; /* device name (keep at the end of248248+ structure) */254249};255250256251typedef struct _snd_minor snd_minor_t;···290287void snd_memory_done(void);291288int snd_memory_info_init(void);292289int snd_memory_info_done(void);293293-void *snd_hidden_kmalloc(size_t size, int flags);294294-void *snd_hidden_kcalloc(size_t n, size_t size, int flags);290290+void *snd_hidden_kmalloc(size_t size, unsigned int __nocast flags);291291+void *snd_hidden_kcalloc(size_t n, size_t size, unsigned int __nocast flags);295292void snd_hidden_kfree(const void *obj);296293void *snd_hidden_vmalloc(unsigned long size);297294void snd_hidden_vfree(void *obj);298298-char *snd_hidden_kstrdup(const char *s, int flags);295295+char *snd_hidden_kstrdup(const char *s, unsigned int __nocast flags);299296#define kmalloc(size, flags) snd_hidden_kmalloc(size, flags)300297#define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)301298#define kfree(obj) snd_hidden_kfree(obj)···414411 printk(fmt ,##args)415412#endif416413/**417417- * snd_assert - run-time assersion macro414414+ * snd_assert - run-time assertion macro418415 * @expr: expression419416 * @args...: the action420417 *···430427 }\431428} while (0)432429/**433433- * snd_runtime_check - run-time assersion macro430430+ * snd_runtime_check - run-time assertion macro434431 * @expr: expression435432 * @args...: the action436433 *
···2020 select SND_PCM2121 select SND_AC97_CODEC22222323-endmenu2323+config SND_PXA2XX_PCM2424+ tristate2525+ select SND_PCM24262727+config SND_PXA2XX_AC972828+ tristate "AC97 driver for the Intel PXA2xx chip"2929+ depends on ARCH_PXA && SND3030+ select SND_PXA2XX_PCM3131+ select SND_AC97_CODEC3232+ help3333+ Say Y or M if you want to support any AC97 codec attached to3434+ the PXA2xx AC97 interface.3535+3636+endmenu
···11+/*22+ * linux/sound/pxa2xx-ac97.c -- AC97 support for the Intel PXA2xx chip.33+ *44+ * Author: Nicolas Pitre55+ * Created: Dec 02, 200466+ * Copyright: MontaVista Software Inc.77+ *88+ * This program is free software; you can redistribute it and/or modify99+ * it under the terms of the GNU General Public License version 2 as1010+ * published by the Free Software Foundation.1111+ */1212+1313+#include <linux/init.h>1414+#include <linux/module.h>1515+#include <linux/kernel.h>1616+#include <linux/device.h>1717+#include <linux/interrupt.h>1818+#include <linux/wait.h>1919+#include <linux/delay.h>2020+2121+#include <sound/driver.h>2222+#include <sound/core.h>2323+#include <sound/pcm.h>2424+#include <sound/ac97_codec.h>2525+#include <sound/initval.h>2626+2727+#include <asm/irq.h>2828+#include <asm/semaphore.h>2929+#include <asm/hardware.h>3030+#include <asm/arch/pxa-regs.h>3131+#include <asm/arch/audio.h>3232+3333+#include "pxa2xx-pcm.h"3434+3535+3636+static DECLARE_MUTEX(car_mutex);3737+static DECLARE_WAIT_QUEUE_HEAD(gsr_wq);3838+static volatile long gsr_bits;3939+4040+static unsigned short pxa2xx_ac97_read(ac97_t *ac97, unsigned short reg)4141+{4242+ unsigned short val = -1;4343+ volatile u32 *reg_addr;4444+4545+ down(&car_mutex);4646+ if (CAR & CAR_CAIP) {4747+ printk(KERN_CRIT"%s: CAR_CAIP already set\n", __FUNCTION__);4848+ goto out;4949+ }5050+5151+ /* set up primary or secondary codec space */5252+ reg_addr = (ac97->num & 1) ? &SAC_REG_BASE : &PAC_REG_BASE;5353+ reg_addr += (reg >> 1);5454+5555+ /* start read access across the ac97 link */5656+ gsr_bits = 0;5757+ val = *reg_addr;5858+ if (reg == AC97_GPIO_STATUS)5959+ goto out;6060+ wait_event_timeout(gsr_wq, gsr_bits & GSR_SDONE, 1);6161+ if (!gsr_bits & GSR_SDONE) {6262+ printk(KERN_ERR "%s: read error (ac97_reg=%d GSR=%#lx)\n",6363+ __FUNCTION__, reg, gsr_bits);6464+ val = -1;6565+ goto out;6666+ }6767+6868+ /* valid data now */6969+ gsr_bits = 0;7070+ val = *reg_addr; 7171+ /* but we've just started another cycle... */7272+ wait_event_timeout(gsr_wq, gsr_bits & GSR_SDONE, 1);7373+7474+out: up(&car_mutex);7575+ return val;7676+}7777+7878+static void pxa2xx_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val)7979+{8080+ volatile u32 *reg_addr;8181+8282+ down(&car_mutex);8383+8484+ if (CAR & CAR_CAIP) {8585+ printk(KERN_CRIT "%s: CAR_CAIP already set\n", __FUNCTION__);8686+ goto out;8787+ }8888+8989+ /* set up primary or secondary codec space */9090+ reg_addr = (ac97->num & 1) ? &SAC_REG_BASE : &PAC_REG_BASE;9191+ reg_addr += (reg >> 1);9292+ gsr_bits = 0;9393+ *reg_addr = val;9494+ wait_event_timeout(gsr_wq, gsr_bits & GSR_CDONE, 1);9595+ if (!gsr_bits & GSR_SDONE)9696+ printk(KERN_ERR "%s: write error (ac97_reg=%d GSR=%#lx)\n",9797+ __FUNCTION__, reg, gsr_bits);9898+9999+out: up(&car_mutex);100100+}101101+102102+static void pxa2xx_ac97_reset(ac97_t *ac97)103103+{104104+ /* First, try cold reset */105105+ GCR &= GCR_COLD_RST; /* clear everything but nCRST */106106+ GCR &= ~GCR_COLD_RST; /* then assert nCRST */107107+108108+ gsr_bits = 0;109109+#ifdef CONFIG_PXA27x110110+ /* PXA27x Developers Manual section 13.5.2.2.1 */111111+ pxa_set_cken(1 << 31, 1);112112+ udelay(5);113113+ pxa_set_cken(1 << 31, 0);114114+ GCR = GCR_COLD_RST;115115+ udelay(50);116116+#else117117+ GCR = GCR_COLD_RST;118118+ GCR |= GCR_CDONE_IE|GCR_SDONE_IE;119119+ wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);120120+#endif121121+122122+ if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) {123123+ printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n",124124+ __FUNCTION__, gsr_bits);125125+126126+ /* let's try warm reset */127127+ gsr_bits = 0;128128+#ifdef CONFIG_PXA27x129129+ /* warm reset broken on Bulverde,130130+ so manually keep AC97 reset high */131131+ pxa_gpio_mode(113 | GPIO_OUT | GPIO_DFLT_HIGH); 132132+ udelay(10);133133+ GCR |= GCR_WARM_RST;134134+ pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);135135+ udelay(50);136136+#else137137+ GCR |= GCR_WARM_RST|GCR_PRIRDY_IEN|GCR_SECRDY_IEN;;138138+ wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);139139+#endif 140140+141141+ if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)))142142+ printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n",143143+ __FUNCTION__, gsr_bits);144144+ }145145+146146+ GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);147147+ GCR |= GCR_SDONE_IE|GCR_CDONE_IE;148148+}149149+150150+static irqreturn_t pxa2xx_ac97_irq(int irq, void *dev_id, struct pt_regs *regs)151151+{152152+ long status;153153+154154+ status = GSR;155155+ if (status) {156156+ GSR = status;157157+ gsr_bits |= status;158158+ wake_up(&gsr_wq);159159+160160+#ifdef CONFIG_PXA27x161161+ /* Although we don't use those we still need to clear them162162+ since they tend to spuriously trigger when MMC is used163163+ (hardware bug? go figure)... */164164+ MISR = MISR_EOC;165165+ PISR = PISR_EOC;166166+ MCSR = MCSR_EOC;167167+#endif168168+169169+ return IRQ_HANDLED;170170+ }171171+172172+ return IRQ_NONE;173173+}174174+175175+static ac97_bus_ops_t pxa2xx_ac97_ops = {176176+ .read = pxa2xx_ac97_read,177177+ .write = pxa2xx_ac97_write,178178+ .reset = pxa2xx_ac97_reset,179179+};180180+181181+static pxa2xx_pcm_dma_params_t pxa2xx_ac97_pcm_out = {182182+ .name = "AC97 PCM out",183183+ .dev_addr = __PREG(PCDR),184184+ .drcmr = &DRCMRTXPCDR,185185+ .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG |186186+ DCMD_BURST32 | DCMD_WIDTH4,187187+};188188+189189+static pxa2xx_pcm_dma_params_t pxa2xx_ac97_pcm_in = {190190+ .name = "AC97 PCM in",191191+ .dev_addr = __PREG(PCDR),192192+ .drcmr = &DRCMRRXPCDR,193193+ .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC |194194+ DCMD_BURST32 | DCMD_WIDTH4,195195+};196196+197197+static snd_pcm_t *pxa2xx_ac97_pcm;198198+static ac97_t *pxa2xx_ac97_ac97;199199+200200+static int pxa2xx_ac97_pcm_startup(snd_pcm_substream_t *substream)201201+{202202+ snd_pcm_runtime_t *runtime = substream->runtime;203203+ pxa2xx_audio_ops_t *platform_ops;204204+ int r;205205+206206+ runtime->hw.channels_min = 2;207207+ runtime->hw.channels_max = 2;208208+209209+ r = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?210210+ AC97_RATES_FRONT_DAC : AC97_RATES_ADC;211211+ runtime->hw.rates = pxa2xx_ac97_ac97->rates[r];212212+ snd_pcm_limit_hw_rates(runtime);213213+214214+ platform_ops = substream->pcm->card->dev->platform_data;215215+ if (platform_ops && platform_ops->startup)216216+ return platform_ops->startup(substream, platform_ops->priv);217217+ else218218+ return 0;219219+}220220+221221+static void pxa2xx_ac97_pcm_shutdown(snd_pcm_substream_t *substream)222222+{223223+ pxa2xx_audio_ops_t *platform_ops;224224+225225+ platform_ops = substream->pcm->card->dev->platform_data;226226+ if (platform_ops && platform_ops->shutdown)227227+ platform_ops->shutdown(substream, platform_ops->priv);228228+}229229+230230+static int pxa2xx_ac97_pcm_prepare(snd_pcm_substream_t *substream)231231+{232232+ snd_pcm_runtime_t *runtime = substream->runtime;233233+ int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?234234+ AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE;235235+ return snd_ac97_set_rate(pxa2xx_ac97_ac97, reg, runtime->rate);236236+}237237+238238+static pxa2xx_pcm_client_t pxa2xx_ac97_pcm_client = {239239+ .playback_params = &pxa2xx_ac97_pcm_out,240240+ .capture_params = &pxa2xx_ac97_pcm_in,241241+ .startup = pxa2xx_ac97_pcm_startup,242242+ .shutdown = pxa2xx_ac97_pcm_shutdown,243243+ .prepare = pxa2xx_ac97_pcm_prepare,244244+};245245+246246+#ifdef CONFIG_PM247247+248248+static int pxa2xx_ac97_do_suspend(snd_card_t *card, unsigned int state)249249+{250250+ if (card->power_state != SNDRV_CTL_POWER_D3cold) {251251+ pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data;252252+ snd_pcm_suspend_all(pxa2xx_ac97_pcm);253253+ snd_ac97_suspend(pxa2xx_ac97_ac97);254254+ snd_power_change_state(card, SNDRV_CTL_POWER_D3cold);255255+ if (platform_ops && platform_ops->suspend)256256+ platform_ops->suspend(platform_ops->priv);257257+ GCR |= GCR_ACLINK_OFF;258258+ pxa_set_cken(CKEN2_AC97, 0);259259+ }260260+261261+ return 0;262262+}263263+264264+static int pxa2xx_ac97_do_resume(snd_card_t *card, unsigned int state)265265+{266266+ if (card->power_state != SNDRV_CTL_POWER_D0) {267267+ pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data;268268+ pxa_set_cken(CKEN2_AC97, 1);269269+ if (platform_ops && platform_ops->resume)270270+ platform_ops->resume(platform_ops->priv);271271+ snd_ac97_resume(pxa2xx_ac97_ac97);272272+ snd_power_change_state(card, SNDRV_CTL_POWER_D0);273273+ }274274+275275+ return 0;276276+}277277+278278+static int pxa2xx_ac97_suspend(struct device *_dev, u32 state, u32 level)279279+{280280+ snd_card_t *card = dev_get_drvdata(_dev);281281+ int ret = 0;282282+283283+ if (card && level == SUSPEND_DISABLE)284284+ ret = pxa2xx_ac97_do_suspend(card, SNDRV_CTL_POWER_D3cold);285285+286286+ return ret;287287+}288288+289289+static int pxa2xx_ac97_resume(struct device *_dev, u32 level)290290+{291291+ snd_card_t *card = dev_get_drvdata(_dev);292292+ int ret = 0;293293+294294+ if (card && level == RESUME_ENABLE)295295+ ret = pxa2xx_ac97_do_resume(card, SNDRV_CTL_POWER_D0);296296+297297+ return ret;298298+}299299+300300+#else301301+#define pxa2xx_ac97_suspend NULL302302+#define pxa2xx_ac97_resume NULL303303+#endif304304+305305+static int pxa2xx_ac97_probe(struct device *dev)306306+{307307+ snd_card_t *card;308308+ ac97_bus_t *ac97_bus;309309+ ac97_template_t ac97_template;310310+ int ret;311311+312312+ ret = -ENOMEM;313313+ card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,314314+ THIS_MODULE, 0);315315+ if (!card)316316+ goto err;317317+318318+ card->dev = dev;319319+ strncpy(card->driver, dev->driver->name, sizeof(card->driver));320320+321321+ ret = pxa2xx_pcm_new(card, &pxa2xx_ac97_pcm_client, &pxa2xx_ac97_pcm);322322+ if (ret)323323+ goto err;324324+325325+ ret = request_irq(IRQ_AC97, pxa2xx_ac97_irq, 0, "AC97", NULL);326326+ if (ret < 0)327327+ goto err;328328+329329+ pxa_gpio_mode(GPIO31_SYNC_AC97_MD);330330+ pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD);331331+ pxa_gpio_mode(GPIO28_BITCLK_AC97_MD);332332+ pxa_gpio_mode(GPIO29_SDATA_IN_AC97_MD);333333+#ifdef CONFIG_PXA27x334334+ /* Use GPIO 113 as AC97 Reset on Bulverde */335335+ pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);336336+#endif337337+ pxa_set_cken(CKEN2_AC97, 1);338338+339339+ ret = snd_ac97_bus(card, 0, &pxa2xx_ac97_ops, NULL, &ac97_bus);340340+ if (ret)341341+ goto err;342342+ memset(&ac97_template, 0, sizeof(ac97_template));343343+ ret = snd_ac97_mixer(ac97_bus, &ac97_template, &pxa2xx_ac97_ac97);344344+ if (ret)345345+ goto err;346346+347347+ snprintf(card->shortname, sizeof(card->shortname),348348+ "%s", snd_ac97_get_short_name(pxa2xx_ac97_ac97));349349+ snprintf(card->longname, sizeof(card->longname),350350+ "%s (%s)", dev->driver->name, card->mixername);351351+352352+ snd_card_set_pm_callback(card, pxa2xx_ac97_do_suspend,353353+ pxa2xx_ac97_do_resume, NULL);354354+ ret = snd_card_register(card);355355+ if (ret == 0) {356356+ dev_set_drvdata(dev, card);357357+ return 0;358358+ }359359+360360+ err:361361+ if (card)362362+ snd_card_free(card);363363+ if (CKEN & CKEN2_AC97) {364364+ GCR |= GCR_ACLINK_OFF;365365+ free_irq(IRQ_AC97, NULL);366366+ pxa_set_cken(CKEN2_AC97, 0);367367+ }368368+ return ret;369369+}370370+371371+static int pxa2xx_ac97_remove(struct device *dev)372372+{373373+ snd_card_t *card = dev_get_drvdata(dev);374374+375375+ if (card) {376376+ snd_card_free(card);377377+ dev_set_drvdata(dev, NULL);378378+ GCR |= GCR_ACLINK_OFF;379379+ free_irq(IRQ_AC97, NULL);380380+ pxa_set_cken(CKEN2_AC97, 0);381381+ }382382+383383+ return 0;384384+}385385+386386+static struct device_driver pxa2xx_ac97_driver = {387387+ .name = "pxa2xx-ac97",388388+ .bus = &platform_bus_type,389389+ .probe = pxa2xx_ac97_probe,390390+ .remove = pxa2xx_ac97_remove,391391+ .suspend = pxa2xx_ac97_suspend,392392+ .resume = pxa2xx_ac97_resume,393393+};394394+395395+static int __init pxa2xx_ac97_init(void)396396+{397397+ return driver_register(&pxa2xx_ac97_driver);398398+}399399+400400+static void __exit pxa2xx_ac97_exit(void)401401+{402402+ driver_unregister(&pxa2xx_ac97_driver);403403+}404404+405405+module_init(pxa2xx_ac97_init);406406+module_exit(pxa2xx_ac97_exit);407407+408408+MODULE_AUTHOR("Nicolas Pitre");409409+MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip");410410+MODULE_LICENSE("GPL");
+367
sound/arm/pxa2xx-pcm.c
···11+/*22+ * linux/sound/arm/pxa2xx-pcm.c -- ALSA PCM interface for the Intel PXA2xx chip33+ *44+ * Author: Nicolas Pitre55+ * Created: Nov 30, 200466+ * Copyright: (C) 2004 MontaVista Software, Inc.77+ *88+ * This program is free software; you can redistribute it and/or modify99+ * it under the terms of the GNU General Public License version 2 as1010+ * published by the Free Software Foundation.1111+ */1212+1313+#include <linux/module.h>1414+#include <linux/init.h>1515+#include <linux/device.h>1616+#include <linux/slab.h>1717+#include <linux/dma-mapping.h>1818+1919+#include <sound/driver.h>2020+#include <sound/core.h>2121+#include <sound/pcm.h>2222+#include <sound/pcm_params.h>2323+2424+#include <asm/dma.h>2525+#include <asm/hardware.h>2626+#include <asm/arch/pxa-regs.h>2727+2828+#include "pxa2xx-pcm.h"2929+3030+3131+static const snd_pcm_hardware_t pxa2xx_pcm_hardware = {3232+ .info = SNDRV_PCM_INFO_MMAP |3333+ SNDRV_PCM_INFO_MMAP_VALID |3434+ SNDRV_PCM_INFO_INTERLEAVED |3535+ SNDRV_PCM_INFO_PAUSE,3636+ .formats = SNDRV_PCM_FMTBIT_S16_LE,3737+ .period_bytes_min = 32,3838+ .period_bytes_max = 8192 - 32,3939+ .periods_min = 1,4040+ .periods_max = PAGE_SIZE/sizeof(pxa_dma_desc),4141+ .buffer_bytes_max = 128 * 1024,4242+ .fifo_size = 32,4343+};4444+4545+struct pxa2xx_runtime_data {4646+ int dma_ch;4747+ pxa2xx_pcm_dma_params_t *params;4848+ pxa_dma_desc *dma_desc_array;4949+ dma_addr_t dma_desc_array_phys;5050+};5151+5252+static int pxa2xx_pcm_hw_params(snd_pcm_substream_t *substream,5353+ snd_pcm_hw_params_t *params)5454+{5555+ snd_pcm_runtime_t *runtime = substream->runtime;5656+ struct pxa2xx_runtime_data *rtd = runtime->private_data;5757+ size_t totsize = params_buffer_bytes(params);5858+ size_t period = params_period_bytes(params);5959+ pxa_dma_desc *dma_desc;6060+ dma_addr_t dma_buff_phys, next_desc_phys;6161+6262+ snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);6363+ runtime->dma_bytes = totsize;6464+6565+ dma_desc = rtd->dma_desc_array;6666+ next_desc_phys = rtd->dma_desc_array_phys;6767+ dma_buff_phys = runtime->dma_addr;6868+ do {6969+ next_desc_phys += sizeof(pxa_dma_desc);7070+ dma_desc->ddadr = next_desc_phys;7171+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {7272+ dma_desc->dsadr = dma_buff_phys;7373+ dma_desc->dtadr = rtd->params->dev_addr;7474+ } else {7575+ dma_desc->dsadr = rtd->params->dev_addr;7676+ dma_desc->dtadr = dma_buff_phys;7777+ }7878+ if (period > totsize)7979+ period = totsize;8080+ dma_desc->dcmd = rtd->params->dcmd | period | DCMD_ENDIRQEN;8181+ dma_desc++;8282+ dma_buff_phys += period;8383+ } while (totsize -= period);8484+ dma_desc[-1].ddadr = rtd->dma_desc_array_phys;8585+8686+ return 0;8787+}8888+8989+static int pxa2xx_pcm_hw_free(snd_pcm_substream_t *substream)9090+{9191+ struct pxa2xx_runtime_data *rtd = substream->runtime->private_data;9292+9393+ *rtd->params->drcmr = 0;9494+ snd_pcm_set_runtime_buffer(substream, NULL);9595+ return 0;9696+}9797+9898+static int pxa2xx_pcm_prepare(snd_pcm_substream_t *substream)9999+{100100+ pxa2xx_pcm_client_t *client = substream->private_data;101101+ snd_pcm_runtime_t *runtime = substream->runtime;102102+ struct pxa2xx_runtime_data *rtd = runtime->private_data;103103+104104+ DCSR(rtd->dma_ch) &= ~DCSR_RUN;105105+ DCSR(rtd->dma_ch) = 0;106106+ DCMD(rtd->dma_ch) = 0;107107+ *rtd->params->drcmr = rtd->dma_ch | DRCMR_MAPVLD;108108+109109+ return client->prepare(substream);110110+}111111+112112+static int pxa2xx_pcm_trigger(snd_pcm_substream_t *substream, int cmd)113113+{114114+ struct pxa2xx_runtime_data *rtd = substream->runtime->private_data;115115+ int ret = 0;116116+117117+ switch (cmd) {118118+ case SNDRV_PCM_TRIGGER_START:119119+ DDADR(rtd->dma_ch) = rtd->dma_desc_array_phys;120120+ DCSR(rtd->dma_ch) = DCSR_RUN;121121+ break;122122+123123+ case SNDRV_PCM_TRIGGER_STOP:124124+ case SNDRV_PCM_TRIGGER_SUSPEND:125125+ case SNDRV_PCM_TRIGGER_PAUSE_PUSH:126126+ DCSR(rtd->dma_ch) &= ~DCSR_RUN;127127+ break;128128+129129+ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:130130+ DCSR(rtd->dma_ch) |= DCSR_RUN;131131+ break;132132+133133+ default:134134+ ret = -EINVAL;135135+ }136136+137137+ return ret;138138+}139139+140140+static void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id, struct pt_regs *regs)141141+{142142+ snd_pcm_substream_t *substream = dev_id;143143+ struct pxa2xx_runtime_data *rtd = substream->runtime->private_data;144144+ int dcsr;145145+146146+ dcsr = DCSR(dma_ch);147147+ DCSR(dma_ch) = dcsr & ~DCSR_STOPIRQEN;148148+149149+ if (dcsr & DCSR_ENDINTR) {150150+ snd_pcm_period_elapsed(substream);151151+ } else {152152+ printk( KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n",153153+ rtd->params->name, dma_ch, dcsr );154154+ snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);155155+ }156156+}157157+158158+static snd_pcm_uframes_t pxa2xx_pcm_pointer(snd_pcm_substream_t *substream)159159+{160160+ snd_pcm_runtime_t *runtime = substream->runtime;161161+ struct pxa2xx_runtime_data *rtd = runtime->private_data;162162+ dma_addr_t ptr = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?163163+ DSADR(rtd->dma_ch) : DTADR(rtd->dma_ch);164164+ snd_pcm_uframes_t x = bytes_to_frames(runtime, ptr - runtime->dma_addr);165165+ if (x == runtime->buffer_size)166166+ x = 0;167167+ return x;168168+}169169+170170+static int171171+pxa2xx_pcm_hw_rule_mult32(snd_pcm_hw_params_t *params, snd_pcm_hw_rule_t *rule)172172+{173173+ snd_interval_t *i = hw_param_interval(params, rule->var);174174+ int changed = 0;175175+176176+ if (i->min & 31) {177177+ i->min = (i->min & ~31) + 32;178178+ i->openmin = 0;179179+ changed = 1;180180+ }181181+182182+ if (i->max & 31) {183183+ i->max &= ~31;184184+ i->openmax = 0;185185+ changed = 1;186186+ }187187+188188+ return changed;189189+}190190+191191+static int pxa2xx_pcm_open(snd_pcm_substream_t *substream)192192+{193193+ pxa2xx_pcm_client_t *client = substream->private_data;194194+ snd_pcm_runtime_t *runtime = substream->runtime;195195+ struct pxa2xx_runtime_data *rtd;196196+ int ret;197197+198198+ runtime->hw = pxa2xx_pcm_hardware;199199+200200+ /*201201+ * For mysterious reasons (and despite what the manual says)202202+ * playback samples are lost if the DMA count is not a multiple203203+ * of the DMA burst size. Let's add a rule to enforce that.204204+ */205205+ ret = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,206206+ pxa2xx_pcm_hw_rule_mult32, NULL,207207+ SNDRV_PCM_HW_PARAM_PERIOD_BYTES, -1);208208+ if (ret)209209+ goto out;210210+ ret = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,211211+ pxa2xx_pcm_hw_rule_mult32, NULL,212212+ SNDRV_PCM_HW_PARAM_BUFFER_BYTES, -1);213213+ if (ret)214214+ goto out;215215+216216+ ret = -ENOMEM;217217+ rtd = kmalloc(sizeof(*rtd), GFP_KERNEL);218218+ if (!rtd)219219+ goto out;220220+ rtd->dma_desc_array =221221+ dma_alloc_writecombine(substream->pcm->card->dev, PAGE_SIZE,222222+ &rtd->dma_desc_array_phys, GFP_KERNEL);223223+ if (!rtd->dma_desc_array)224224+ goto err1;225225+226226+ rtd->params = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?227227+ client->playback_params : client->capture_params;228228+ ret = pxa_request_dma(rtd->params->name, DMA_PRIO_LOW,229229+ pxa2xx_pcm_dma_irq, substream);230230+ if (ret < 0)231231+ goto err2;232232+ rtd->dma_ch = ret;233233+234234+ runtime->private_data = rtd;235235+ ret = client->startup(substream);236236+ if (!ret)237237+ goto out;238238+239239+ pxa_free_dma(rtd->dma_ch);240240+ err2:241241+ dma_free_writecombine(substream->pcm->card->dev, PAGE_SIZE,242242+ rtd->dma_desc_array, rtd->dma_desc_array_phys);243243+ err1:244244+ kfree(rtd);245245+ out:246246+ return ret;247247+}248248+249249+static int pxa2xx_pcm_close(snd_pcm_substream_t *substream)250250+{251251+ pxa2xx_pcm_client_t *client = substream->private_data;252252+ struct pxa2xx_runtime_data *rtd = substream->runtime->private_data;253253+254254+ pxa_free_dma(rtd->dma_ch);255255+ client->shutdown(substream);256256+ dma_free_writecombine(substream->pcm->card->dev, PAGE_SIZE,257257+ rtd->dma_desc_array, rtd->dma_desc_array_phys);258258+ kfree(rtd);259259+ return 0;260260+}261261+262262+static int263263+pxa2xx_pcm_mmap(snd_pcm_substream_t *substream, struct vm_area_struct *vma)264264+{265265+ snd_pcm_runtime_t *runtime = substream->runtime;266266+ return dma_mmap_writecombine(substream->pcm->card->dev, vma,267267+ runtime->dma_area,268268+ runtime->dma_addr,269269+ runtime->dma_bytes);270270+}271271+272272+static snd_pcm_ops_t pxa2xx_pcm_ops = {273273+ .open = pxa2xx_pcm_open,274274+ .close = pxa2xx_pcm_close,275275+ .ioctl = snd_pcm_lib_ioctl,276276+ .hw_params = pxa2xx_pcm_hw_params,277277+ .hw_free = pxa2xx_pcm_hw_free,278278+ .prepare = pxa2xx_pcm_prepare,279279+ .trigger = pxa2xx_pcm_trigger,280280+ .pointer = pxa2xx_pcm_pointer,281281+ .mmap = pxa2xx_pcm_mmap,282282+};283283+284284+static int pxa2xx_pcm_preallocate_dma_buffer(snd_pcm_t *pcm, int stream)285285+{286286+ snd_pcm_substream_t *substream = pcm->streams[stream].substream;287287+ struct snd_dma_buffer *buf = &substream->dma_buffer;288288+ size_t size = pxa2xx_pcm_hardware.buffer_bytes_max;289289+ buf->dev.type = SNDRV_DMA_TYPE_DEV;290290+ buf->dev.dev = pcm->card->dev;291291+ buf->private_data = NULL;292292+ buf->area = dma_alloc_writecombine(pcm->card->dev, size,293293+ &buf->addr, GFP_KERNEL);294294+ if (!buf->area)295295+ return -ENOMEM;296296+ buf->bytes = size;297297+ return 0;298298+}299299+300300+static void pxa2xx_pcm_free_dma_buffers(snd_pcm_t *pcm)301301+{302302+ snd_pcm_substream_t *substream;303303+ struct snd_dma_buffer *buf;304304+ int stream;305305+306306+ for (stream = 0; stream < 2; stream++) {307307+ substream = pcm->streams[stream].substream;308308+ if (!substream)309309+ continue;310310+ buf = &substream->dma_buffer;311311+ if (!buf->area)312312+ continue;313313+ dma_free_writecombine(pcm->card->dev, buf->bytes,314314+ buf->area, buf->addr);315315+ buf->area = NULL;316316+ }317317+}318318+319319+static u64 pxa2xx_pcm_dmamask = 0xffffffff;320320+321321+int pxa2xx_pcm_new(snd_card_t *card, pxa2xx_pcm_client_t *client, snd_pcm_t **rpcm)322322+{323323+ snd_pcm_t *pcm;324324+ int play = client->playback_params ? 1 : 0;325325+ int capt = client->capture_params ? 1 : 0;326326+ int ret;327327+328328+ ret = snd_pcm_new(card, "PXA2xx-PCM", 0, play, capt, &pcm);329329+ if (ret)330330+ goto out;331331+332332+ pcm->private_data = client;333333+ pcm->private_free = pxa2xx_pcm_free_dma_buffers;334334+335335+ if (!card->dev->dma_mask)336336+ card->dev->dma_mask = &pxa2xx_pcm_dmamask;337337+ if (!card->dev->coherent_dma_mask)338338+ card->dev->coherent_dma_mask = 0xffffffff;339339+340340+ if (play) {341341+ int stream = SNDRV_PCM_STREAM_PLAYBACK;342342+ snd_pcm_set_ops(pcm, stream, &pxa2xx_pcm_ops);343343+ ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, stream);344344+ if (ret)345345+ goto out;346346+ }347347+ if (capt) {348348+ int stream = SNDRV_PCM_STREAM_CAPTURE;349349+ snd_pcm_set_ops(pcm, stream, &pxa2xx_pcm_ops);350350+ ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, stream);351351+ if (ret)352352+ goto out;353353+ }354354+355355+ if (rpcm)356356+ *rpcm = pcm;357357+ ret = 0;358358+359359+ out:360360+ return ret;361361+}362362+363363+EXPORT_SYMBOL(pxa2xx_pcm_new);364364+365365+MODULE_AUTHOR("Nicolas Pitre");366366+MODULE_DESCRIPTION("Intel PXA2xx PCM DMA module");367367+MODULE_LICENSE("GPL");
+29
sound/arm/pxa2xx-pcm.h
···11+/*22+ * linux/sound/arm/pxa2xx-pcm.h -- ALSA PCM interface for the Intel PXA2xx chip33+ *44+ * Author: Nicolas Pitre55+ * Created: Nov 30, 200466+ * Copyright: MontaVista Software, Inc.77+ *88+ * This program is free software; you can redistribute it and/or modify99+ * it under the terms of the GNU General Public License version 2 as1010+ * published by the Free Software Foundation.1111+ */1212+1313+typedef struct {1414+ char *name; /* stream identifier */1515+ u32 dcmd; /* DMA descriptor dcmd field */1616+ volatile u32 *drcmr; /* the DMA request channel to use */1717+ u32 dev_addr; /* device physical address for DMA */1818+} pxa2xx_pcm_dma_params_t;1919+2020+typedef struct {2121+ pxa2xx_pcm_dma_params_t *playback_params;2222+ pxa2xx_pcm_dma_params_t *capture_params;2323+ int (*startup)(snd_pcm_substream_t *);2424+ void (*shutdown)(snd_pcm_substream_t *);2525+ int (*prepare)(snd_pcm_substream_t *);2626+} pxa2xx_pcm_client_t;2727+2828+extern int pxa2xx_pcm_new(snd_card_t *, pxa2xx_pcm_client_t *, snd_pcm_t **);2929+
+9-6
sound/core/device.c
···2828/**2929 * snd_device_new - create an ALSA device component3030 * @card: the card instance3131- * @type: the device type, SNDRV_DEV_TYPE_XXX3131+ * @type: the device type, SNDRV_DEV_XXX3232 * @device_data: the data pointer of this device3333 * @ops: the operator table3434 *···4646{4747 snd_device_t *dev;48484949- snd_assert(card != NULL && device_data != NULL && ops != NULL, return -ENXIO);4949+ snd_assert(card != NULL, return -ENXIO);5050+ snd_assert(device_data != NULL, return -ENXIO);5151+ snd_assert(ops != NULL, return -ENXIO);5052 dev = kcalloc(1, sizeof(*dev), GFP_KERNEL);5153 if (dev == NULL)5254 return -ENOMEM;···104102}105103106104/**107107- * snd_device_free - disconnect the device105105+ * snd_device_disconnect - disconnect the device108106 * @card: the card instance109107 * @device_data: the data pointer to disconnect110108 *···120118{121119 struct list_head *list;122120 snd_device_t *dev;123123-121121+124122 snd_assert(card != NULL, return -ENXIO);125123 snd_assert(device_data != NULL, return -ENXIO);126124 list_for_each(list, &card->devices) {···156154 struct list_head *list;157155 snd_device_t *dev;158156 int err;159159-160160- snd_assert(card != NULL && device_data != NULL, return -ENXIO);157157+158158+ snd_assert(card != NULL, return -ENXIO);159159+ snd_assert(device_data != NULL, return -ENXIO);161160 list_for_each(list, &card->devices) {162161 dev = snd_device(list);163162 if (dev->device_data != device_data)
+3-2
sound/core/info.c
···702702}703703704704/**705705- * snd_info_get_line - parse a string token705705+ * snd_info_get_str - parse a string token706706 * @dest: the buffer to store the string token707707 * @src: the original string708708 * @len: the max. length of token - 1···939939{940940 struct proc_dir_entry *root;941941942942- snd_assert(entry != NULL && entry->p != NULL, return -ENXIO);942942+ snd_assert(entry != NULL, return -ENXIO);943943+ snd_assert(entry->p != NULL, return -ENXIO);943944 root = entry->parent == NULL ? snd_proc_root : entry->parent->p;944945 snd_assert(root, return -ENXIO);945946 down(&info_mutex);
···367367 ac97->regs[reg] = value;368368 ac97->bus->ops->write(ac97, reg, value);369369 }370370+ set_bit(reg, ac97->reg_accessed);370371 up(&ac97->reg_mutex);371372 return change;372373}···411410 ac97->regs[reg] = new;412411 ac97->bus->ops->write(ac97, reg, new);413412 }413413+ set_bit(reg, ac97->reg_accessed);414414 return change;415415}416416···10781076 for (i = 0 ; i < ARRAY_SIZE(cbit); i++) {10791077 unsigned short val;10801078 snd_ac97_write(ac97, reg, 0x8080 | cbit[i] | (cbit[i] << 8));10791079+ /* Do the read twice due to buffers on some ac97 codecs.10801080+ * e.g. The STAC9704 returns exactly what you wrote the the register10811081+ * if you read it immediately. This causes the detect routine to fail.10821082+ */10831083+ val = snd_ac97_read(ac97, reg);10811084 val = snd_ac97_read(ac97, reg);10821085 if (! *lo_max && (val & 0x7f) == cbit[i])10831086 *lo_max = max[i];···22312224 */22322225void snd_ac97_resume(ac97_t *ac97)22332226{22342234- int i;22272227+ unsigned long end_time;2235222822362229 if (ac97->bus->ops->reset) {22372230 ac97->bus->ops->reset(ac97);···22492242 snd_ac97_write(ac97, AC97_POWERDOWN, ac97->regs[AC97_POWERDOWN]);22502243 if (ac97_is_audio(ac97)) {22512244 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8101);22522252- for (i = HZ/10; i >= 0; i--) {22452245+ end_time = jiffies + msecs_to_jiffies(100);22462246+ do {22532247 if (snd_ac97_read(ac97, AC97_MASTER) == 0x8101)22542248 break;22552249 set_current_state(TASK_UNINTERRUPTIBLE);22562250 schedule_timeout(1);22572257- }22512251+ } while (time_after_eq(end_time, jiffies));22582252 /* FIXME: extra delay */22592253 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8000);22602260- if (snd_ac97_read(ac97, AC97_MASTER) != 0x8000) {22612261- set_current_state(TASK_UNINTERRUPTIBLE);22622262- schedule_timeout(HZ/4);22632263- }22542254+ if (snd_ac97_read(ac97, AC97_MASTER) != 0x8000)22552255+ msleep(250);22642256 } else {22652265- for (i = HZ/10; i >= 0; i--) {22572257+ end_time = jiffies + msecs_to_jiffies(100);22582258+ do {22662259 unsigned short val = snd_ac97_read(ac97, AC97_EXTENDED_MID);22672260 if (val != 0xffff && (val & 1) != 0)22682261 break;22692262 set_current_state(TASK_UNINTERRUPTIBLE);22702263 schedule_timeout(1);22712271- }22642264+ } while (time_after_eq(end_time, jiffies));22722265 }22732266__reset_ready:22742267
+3
sound/pci/ac97/ac97_patch.c
···15281528 },15291529 AC97_SURROUND_JACK_MODE_CTL,15301530 AC97_CHANNEL_MODE_CTL,15311531+15321532+ AC97_SINGLE("Headphone Jack Sense", AC97_AD_JACK_SPDIF, 10, 1, 0),15331533+ AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0),15311534};1532153515331536static int patch_ad1888_specific(ac97_t *ac97)
+2-2
sound/pci/ali5451/ali5451.c
···399399 unsigned long end_time;400400 unsigned int res;401401402402- end_time = jiffies + 10 * (HZ >> 2);402402+ end_time = jiffies + 10 * msecs_to_jiffies(250);403403 do {404404 res = snd_ali_5451_peek(codec,port);405405 if (! (res & 0x8000))···422422 dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER);423423 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);424424425425- end_time = jiffies + 10 * (HZ >> 2);425425+ end_time = jiffies + 10 * msecs_to_jiffies(250);426426 do {427427 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);428428 if (dwChk2 != dwChk1)
···408408 int err;409409 err = snd_via82xx_codec_ready(chip, ac97->num);410410 /* here we need to wait fairly for long time.. */411411- set_current_state(TASK_UNINTERRUPTIBLE);412412- schedule_timeout(HZ/2);411411+ msleep(500);413412}414413415414static void snd_via82xx_codec_write(ac97_t *ac97,···922923static int snd_via82xx_chip_init(via82xx_t *chip)923924{924925 unsigned int val;925925- int max_count;926926+ unsigned long end_time;926927 unsigned char pval;927928928929 pci_read_config_byte(chip->pci, VIA_MC97_CTRL, &pval);···961962 }962963963964 /* wait until codec ready */964964- max_count = ((3 * HZ) / 4) + 1;965965+ end_time = jiffies + msecs_to_jiffies(750);965966 do {966967 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);967968 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */968969 break;969970 set_current_state(TASK_UNINTERRUPTIBLE);970971 schedule_timeout(1);971971- } while (--max_count > 0);972972+ } while (time_before(jiffies, end_time));972973973974 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)974975 snd_printk("AC'97 codec is not ready [0x%x]\n", val);···976977 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |977978 VIA_REG_AC97_SECONDARY_VALID |978979 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));979979- max_count = ((3 * HZ) / 4) + 1;980980+ end_time = jiffies + msecs_to_jiffies(750);980981 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |981982 VIA_REG_AC97_SECONDARY_VALID |982983 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));···987988 }988989 set_current_state(TASK_INTERRUPTIBLE);989990 schedule_timeout(1);990990- } while (--max_count > 0);991991+ } while (time_before(jiffies, end_time));991992 /* This is ok, the most of motherboards have only one codec */992993993994 __ac97_ok2:
+3-3
sound/pci/ymfpci/ymfpci_main.c
···84848585static int snd_ymfpci_codec_ready(ymfpci_t *chip, int secondary)8686{8787- signed long end_time;8787+ unsigned long end_time;8888 u32 reg = secondary ? YDSXGR_SECSTATUSADR : YDSXGR_PRISTATUSADR;89899090- end_time = (jiffies + ((3 * HZ) / 4)) + 1;9090+ end_time = jiffies + msecs_to_jiffies(750);9191 do {9292 if ((snd_ymfpci_readw(chip, reg) & 0x8000) == 0)9393 return 0;9494 set_current_state(TASK_UNINTERRUPTIBLE);9595 schedule_timeout(1);9696- } while (end_time - (signed long)jiffies >= 0);9696+ } while (time_before(jiffies, end_time));9797 snd_printk("codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_ymfpci_readw(chip, reg));9898 return -EBUSY;9999}
+2-13
sound/pcmcia/Kconfig
···88 depends on SND && PCMCIA && ISA99 select SND_VX_LIB1010 help1111- Say Y here to include support for Digigram VXpocket1212- soundcards.1111+ Say Y here to include support for Digigram VXpocket and1212+ VXpocket 440 soundcards.13131414 To compile this driver as a module, choose M here: the module1515 will be called snd-vxpocket.1616-1717-config SND_VXP4401818- tristate "Digigram VXpocket 440"1919- depends on SND && PCMCIA && ISA2020- select SND_VX_LIB2121- help2222- Say Y here to include support for Digigram VXpocket 4402323- soundcards.2424-2525- To compile this driver as a module, choose M here: the module2626- will be called snd-vxp440.27162817config SND_PDAUDIOCF2918 tristate "Sound Core PDAudioCF"
···77 tristate "Sun AMD7930"88 depends on SBUS && SND99 select SND_PCM1010+ help1111+ Say Y here to include support for AMD7930 sound device on Sun.10121111-# dep_tristate 'Sun DBRI' CONFIG_SND_SUN_DBRI $CONFIG_SND1313+ To compile this driver as a module, choose M here: the module1414+ will be called snd-sun-amd7930.1515+1216config SND_SUN_CS42311317 tristate "Sun CS4231"1418 depends on SND1519 select SND_PCM2020+ help2121+ Say Y here to include support for CS4231 sound device on Sun.2222+2323+ To compile this driver as a module, choose M here: the module2424+ will be called snd-sun-cs4231.2525+2626+config SND_SUN_DBRI2727+ tristate "Sun DBRI"2828+ depends on SND && SBUS2929+ select SND_PCM3030+ help3131+ Say Y here to include support for DBRI sound device on Sun.3232+3333+ To compile this driver as a module, choose M here: the module3434+ will be called snd-sun-dbri.16351736endmenu1818-
···232232 if (err)233233 return err;234234 if (dsp->index == 1) {235235- set_current_state(TASK_UNINTERRUPTIBLE);236236- schedule_timeout(HZ/4); // give the device some time 235235+ msleep(250); // give the device some time237236 err = usX2Y_AsyncSeq04_init(priv);238237 if (err) {239238 snd_printk("usX2Y_AsyncSeq04_init error \n");
+2-4
sound/usb/usx2y/usx2yhwdeppcm.c
···5050 Currently rawusb dma pcm buffer transport (this file) is only available to snd-usb-usx2y. 5151*/52525353+#include <linux/delay.h>5354#include "usbusx2yaudio.c"54555556#if defined(USX2Y_NRPACKS_VARIABLE) || (!defined(USX2Y_NRPACKS_VARIABLE) && USX2Y_NRPACKS == 1)···521520 usX2Y->hwdep_pcm_shm->playback_iso_start = -1;522521 if (atomic_read(&subs->state) < state_PREPARED) {523522 while (usX2Y_iso_frames_per_buffer(runtime, usX2Y) > usX2Y->hwdep_pcm_shm->captured_iso_frames) {524524- signed long timeout;525523 snd_printd("Wait: iso_frames_per_buffer=%i,captured_iso_frames=%i\n", usX2Y_iso_frames_per_buffer(runtime, usX2Y), usX2Y->hwdep_pcm_shm->captured_iso_frames);526526- set_current_state(TASK_INTERRUPTIBLE);527527- timeout = schedule_timeout(HZ/100 + 1);528528- if (signal_pending(current)) {524524+ if (msleep_interruptible(10)) {529525 err = -ERESTARTSYS;530526 goto up_prepare_mutex;531527 }