aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-07-27 10:52:19 -0400
committerJaroslav Kysela <perex@perex.cz>2007-10-16 09:58:09 -0400
commitd01ce99fc53271cd8ef0ef6b9a2790177fd410a1 (patch)
treed6723036b6bd896c120cf49dd049ddf182ec703d /sound/pci
parente2340465ec9587362a057524d3e2163377366771 (diff)
[ALSA] hda-intel - Coding style fixes
Fix codes to follow more to the standard kernel coding style. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_codec.h33
-rw-r--r--sound/pci/hda/hda_intel.c188
-rw-r--r--sound/pci/hda/hda_local.h99
-rw-r--r--sound/pci/hda/hda_proc.c27
4 files changed, 225 insertions, 122 deletions
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 56c26e7ccdf1..6809386109c8 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -199,7 +199,9 @@ enum {
199#define AC_AMPCAP_OFFSET_SHIFT 0 199#define AC_AMPCAP_OFFSET_SHIFT 0
200#define AC_AMPCAP_NUM_STEPS (0x7f<<8) /* number of steps */ 200#define AC_AMPCAP_NUM_STEPS (0x7f<<8) /* number of steps */
201#define AC_AMPCAP_NUM_STEPS_SHIFT 8 201#define AC_AMPCAP_NUM_STEPS_SHIFT 8
202#define AC_AMPCAP_STEP_SIZE (0x7f<<16) /* step size 0-32dB in 0.25dB */ 202#define AC_AMPCAP_STEP_SIZE (0x7f<<16) /* step size 0-32dB
203 * in 0.25dB
204 */
203#define AC_AMPCAP_STEP_SIZE_SHIFT 16 205#define AC_AMPCAP_STEP_SIZE_SHIFT 16
204#define AC_AMPCAP_MUTE (1<<31) /* mute capable */ 206#define AC_AMPCAP_MUTE (1<<31) /* mute capable */
205#define AC_AMPCAP_MUTE_SHIFT 31 207#define AC_AMPCAP_MUTE_SHIFT 31
@@ -436,7 +438,8 @@ struct hda_bus {
436 438
437 /* codec linked list */ 439 /* codec linked list */
438 struct list_head codec_list; 440 struct list_head codec_list;
439 struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1]; /* caddr -> codec */ 441 /* link caddr -> codec */
442 struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1];
440 443
441 struct mutex cmd_mutex; 444 struct mutex cmd_mutex;
442 445
@@ -499,7 +502,7 @@ struct hda_pcm_ops {
499 502
500/* PCM information for each substream */ 503/* PCM information for each substream */
501struct hda_pcm_stream { 504struct hda_pcm_stream {
502 unsigned int substreams; /* number of substreams, 0 = not exist */ 505 unsigned int substreams; /* number of substreams, 0 = not exist*/
503 unsigned int channels_min; /* min. number of channels */ 506 unsigned int channels_min; /* min. number of channels */
504 unsigned int channels_max; /* max. number of channels */ 507 unsigned int channels_max; /* max. number of channels */
505 hda_nid_t nid; /* default NID to query rates/formats/bps, or set up */ 508 hda_nid_t nid; /* default NID to query rates/formats/bps, or set up */
@@ -582,13 +585,17 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
582/* 585/*
583 * low level functions 586 * low level functions
584 */ 587 */
585unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, int direct, 588unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
589 int direct,
586 unsigned int verb, unsigned int parm); 590 unsigned int verb, unsigned int parm);
587int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct, 591int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct,
588 unsigned int verb, unsigned int parm); 592 unsigned int verb, unsigned int parm);
589#define snd_hda_param_read(codec, nid, param) snd_hda_codec_read(codec, nid, 0, AC_VERB_PARAMETERS, param) 593#define snd_hda_param_read(codec, nid, param) \
590int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *start_id); 594 snd_hda_codec_read(codec, nid, 0, AC_VERB_PARAMETERS, param)
591int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *conn_list, int max_conns); 595int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid,
596 hda_nid_t *start_id);
597int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
598 hda_nid_t *conn_list, int max_conns);
592 599
593struct hda_verb { 600struct hda_verb {
594 hda_nid_t nid; 601 hda_nid_t nid;
@@ -596,7 +603,8 @@ struct hda_verb {
596 u32 param; 603 u32 param;
597}; 604};
598 605
599void snd_hda_sequence_write(struct hda_codec *codec, const struct hda_verb *seq); 606void snd_hda_sequence_write(struct hda_codec *codec,
607 const struct hda_verb *seq);
600 608
601/* unsolicited event */ 609/* unsolicited event */
602int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex); 610int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex);
@@ -610,10 +618,13 @@ int snd_hda_build_controls(struct hda_bus *bus);
610 * PCM 618 * PCM
611 */ 619 */
612int snd_hda_build_pcms(struct hda_bus *bus); 620int snd_hda_build_pcms(struct hda_bus *bus);
613void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, 621void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
622 u32 stream_tag,
614 int channel_id, int format); 623 int channel_id, int format);
615unsigned int snd_hda_calc_stream_format(unsigned int rate, unsigned int channels, 624unsigned int snd_hda_calc_stream_format(unsigned int rate,
616 unsigned int format, unsigned int maxbps); 625 unsigned int channels,
626 unsigned int format,
627 unsigned int maxbps);
617int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, 628int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
618 u32 *ratesp, u64 *formatsp, unsigned int *bpsp); 629 u32 *ratesp, u64 *formatsp, unsigned int *bpsp);
619int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid, 630int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 92bc8b3fa2a0..ebb442dcc027 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * 2 *
3 * hda_intel.c - Implementation of primary alsa driver code base for Intel HD Audio. 3 * hda_intel.c - Implementation of primary alsa driver code base
4 * for Intel HD Audio.
4 * 5 *
5 * Copyright(c) 2004 Intel Corporation. All rights reserved. 6 * Copyright(c) 2004 Intel Corporation. All rights reserved.
6 * 7 *
@@ -64,11 +65,13 @@ MODULE_PARM_DESC(id, "ID string for Intel HD audio interface.");
64module_param(model, charp, 0444); 65module_param(model, charp, 0444);
65MODULE_PARM_DESC(model, "Use the given board model."); 66MODULE_PARM_DESC(model, "Use the given board model.");
66module_param(position_fix, int, 0444); 67module_param(position_fix, int, 0444);
67MODULE_PARM_DESC(position_fix, "Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size)."); 68MODULE_PARM_DESC(position_fix, "Fix DMA pointer "
69 "(0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size).");
68module_param(probe_mask, int, 0444); 70module_param(probe_mask, int, 0444);
69MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1)."); 71MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
70module_param(single_cmd, bool, 0444); 72module_param(single_cmd, bool, 0444);
71MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs (for debugging only)."); 73MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs "
74 "(for debugging only).");
72module_param(enable_msi, int, 0); 75module_param(enable_msi, int, 0);
73MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)"); 76MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)");
74 77
@@ -213,15 +216,16 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
213#define SD_INT_DESC_ERR 0x10 /* descriptor error interrupt */ 216#define SD_INT_DESC_ERR 0x10 /* descriptor error interrupt */
214#define SD_INT_FIFO_ERR 0x08 /* FIFO error interrupt */ 217#define SD_INT_FIFO_ERR 0x08 /* FIFO error interrupt */
215#define SD_INT_COMPLETE 0x04 /* completion interrupt */ 218#define SD_INT_COMPLETE 0x04 /* completion interrupt */
216#define SD_INT_MASK (SD_INT_DESC_ERR|SD_INT_FIFO_ERR|SD_INT_COMPLETE) 219#define SD_INT_MASK (SD_INT_DESC_ERR|SD_INT_FIFO_ERR|\
220 SD_INT_COMPLETE)
217 221
218/* SD_STS */ 222/* SD_STS */
219#define SD_STS_FIFO_READY 0x20 /* FIFO ready */ 223#define SD_STS_FIFO_READY 0x20 /* FIFO ready */
220 224
221/* INTCTL and INTSTS */ 225/* INTCTL and INTSTS */
222#define ICH6_INT_ALL_STREAM 0xff /* all stream interrupts */ 226#define ICH6_INT_ALL_STREAM 0xff /* all stream interrupts */
223#define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */ 227#define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */
224#define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */ 228#define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */
225 229
226/* GCTL unsolicited response enable bit */ 230/* GCTL unsolicited response enable bit */
227#define ICH6_GCTL_UREN (1<<8) 231#define ICH6_GCTL_UREN (1<<8)
@@ -257,22 +261,26 @@ enum {
257 */ 261 */
258 262
259struct azx_dev { 263struct azx_dev {
260 u32 *bdl; /* virtual address of the BDL */ 264 u32 *bdl; /* virtual address of the BDL */
261 dma_addr_t bdl_addr; /* physical address of the BDL */ 265 dma_addr_t bdl_addr; /* physical address of the BDL */
262 u32 *posbuf; /* position buffer pointer */ 266 u32 *posbuf; /* position buffer pointer */
263 267
264 unsigned int bufsize; /* size of the play buffer in bytes */ 268 unsigned int bufsize; /* size of the play buffer in bytes */
265 unsigned int fragsize; /* size of each period in bytes */ 269 unsigned int fragsize; /* size of each period in bytes */
266 unsigned int frags; /* number for period in the play buffer */ 270 unsigned int frags; /* number for period in the play buffer */
267 unsigned int fifo_size; /* FIFO size */ 271 unsigned int fifo_size; /* FIFO size */
268 272
269 void __iomem *sd_addr; /* stream descriptor pointer */ 273 void __iomem *sd_addr; /* stream descriptor pointer */
270 274
271 u32 sd_int_sta_mask; /* stream int status mask */ 275 u32 sd_int_sta_mask; /* stream int status mask */
272 276
273 /* pcm support */ 277 /* pcm support */
274 struct snd_pcm_substream *substream; /* assigned substream, set in PCM open */ 278 struct snd_pcm_substream *substream; /* assigned substream,
275 unsigned int format_val; /* format value to be set in the controller and the codec */ 279 * set in PCM open
280 */
281 unsigned int format_val; /* format value to be set in the
282 * controller and the codec
283 */
276 unsigned char stream_tag; /* assigned stream */ 284 unsigned char stream_tag; /* assigned stream */
277 unsigned char index; /* stream index */ 285 unsigned char index; /* stream index */
278 /* for sanity check of position buffer */ 286 /* for sanity check of position buffer */
@@ -418,7 +426,8 @@ static int azx_alloc_cmd_io(struct azx *chip)
418 int err; 426 int err;
419 427
420 /* single page (at least 4096 bytes) must suffice for both ringbuffes */ 428 /* single page (at least 4096 bytes) must suffice for both ringbuffes */
421 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 429 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
430 snd_dma_pci_data(chip->pci),
422 PAGE_SIZE, &chip->rb); 431 PAGE_SIZE, &chip->rb);
423 if (err < 0) { 432 if (err < 0) {
424 snd_printk(KERN_ERR SFX "cannot allocate CORB/RIRB\n"); 433 snd_printk(KERN_ERR SFX "cannot allocate CORB/RIRB\n");
@@ -531,7 +540,7 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
531 azx_update_rirb(chip); 540 azx_update_rirb(chip);
532 spin_unlock_irq(&chip->reg_lock); 541 spin_unlock_irq(&chip->reg_lock);
533 } 542 }
534 if (! chip->rirb.cmds) 543 if (!chip->rirb.cmds)
535 return chip->rirb.res; /* the last value */ 544 return chip->rirb.res; /* the last value */
536 schedule_timeout(1); 545 schedule_timeout(1);
537 } while (time_after_eq(timeout, jiffies)); 546 } while (time_after_eq(timeout, jiffies));
@@ -585,16 +594,19 @@ static int azx_single_send_cmd(struct hda_codec *codec, u32 val)
585 594
586 while (timeout--) { 595 while (timeout--) {
587 /* check ICB busy bit */ 596 /* check ICB busy bit */
588 if (! (azx_readw(chip, IRS) & ICH6_IRS_BUSY)) { 597 if (!((azx_readw(chip, IRS) & ICH6_IRS_BUSY))) {
589 /* Clear IRV valid bit */ 598 /* Clear IRV valid bit */
590 azx_writew(chip, IRS, azx_readw(chip, IRS) | ICH6_IRS_VALID); 599 azx_writew(chip, IRS, azx_readw(chip, IRS) |
600 ICH6_IRS_VALID);
591 azx_writel(chip, IC, val); 601 azx_writel(chip, IC, val);
592 azx_writew(chip, IRS, azx_readw(chip, IRS) | ICH6_IRS_BUSY); 602 azx_writew(chip, IRS, azx_readw(chip, IRS) |
603 ICH6_IRS_BUSY);
593 return 0; 604 return 0;
594 } 605 }
595 udelay(1); 606 udelay(1);
596 } 607 }
597 snd_printd(SFX "send_cmd timeout: IRS=0x%x, val=0x%x\n", azx_readw(chip, IRS), val); 608 snd_printd(SFX "send_cmd timeout: IRS=0x%x, val=0x%x\n",
609 azx_readw(chip, IRS), val);
598 return -EIO; 610 return -EIO;
599} 611}
600 612
@@ -610,7 +622,8 @@ static unsigned int azx_single_get_response(struct hda_codec *codec)
610 return azx_readl(chip, IR); 622 return azx_readl(chip, IR);
611 udelay(1); 623 udelay(1);
612 } 624 }
613 snd_printd(SFX "get_response timeout: IRS=0x%x\n", azx_readw(chip, IRS)); 625 snd_printd(SFX "get_response timeout: IRS=0x%x\n",
626 azx_readw(chip, IRS));
614 return (unsigned int)-1; 627 return (unsigned int)-1;
615} 628}
616 629
@@ -785,7 +798,8 @@ static void azx_init_chip(struct azx *chip)
785 798
786 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) 799 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
787 * TCSEL == Traffic Class Select Register, which sets PCI express QOS 800 * TCSEL == Traffic Class Select Register, which sets PCI express QOS
788 * Ensuring these bits are 0 clears playback static on some HD Audio codecs 801 * Ensuring these bits are 0 clears playback static on some HD Audio
802 * codecs
789 */ 803 */
790 pci_read_config_byte (chip->pci, ICH6_PCIREG_TCSEL, &reg); 804 pci_read_config_byte (chip->pci, ICH6_PCIREG_TCSEL, &reg);
791 pci_write_config_byte(chip->pci, ICH6_PCIREG_TCSEL, reg & 0xf8); 805 pci_write_config_byte(chip->pci, ICH6_PCIREG_TCSEL, reg & 0xf8);
@@ -808,10 +822,13 @@ static void azx_init_chip(struct azx *chip)
808 switch (chip->driver_type) { 822 switch (chip->driver_type) {
809 case AZX_DRIVER_ATI: 823 case AZX_DRIVER_ATI:
810 /* For ATI SB450 azalia HD audio, we need to enable snoop */ 824 /* For ATI SB450 azalia HD audio, we need to enable snoop */
811 pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 825 pci_read_config_byte(chip->pci,
826 ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
812 &reg); 827 &reg);
813 pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 828 pci_write_config_byte(chip->pci,
814 (reg & 0xf8) | ATI_SB450_HDAUDIO_ENABLE_SNOOP); 829 ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
830 (reg & 0xf8) |
831 ATI_SB450_HDAUDIO_ENABLE_SNOOP);
815 break; 832 break;
816 case AZX_DRIVER_NVIDIA: 833 case AZX_DRIVER_NVIDIA:
817 /* For NVIDIA HDA, enable snoop */ 834 /* For NVIDIA HDA, enable snoop */
@@ -857,7 +874,7 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id)
857 /* clear rirb int */ 874 /* clear rirb int */
858 status = azx_readb(chip, RIRBSTS); 875 status = azx_readb(chip, RIRBSTS);
859 if (status & RIRB_INT_MASK) { 876 if (status & RIRB_INT_MASK) {
860 if (! chip->single_cmd && (status & RIRB_INT_RESPONSE)) 877 if (!chip->single_cmd && (status & RIRB_INT_RESPONSE))
861 azx_update_rirb(chip); 878 azx_update_rirb(chip);
862 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); 879 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
863 } 880 }
@@ -911,9 +928,11 @@ static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
911 int timeout; 928 int timeout;
912 929
913 /* make sure the run bit is zero for SD */ 930 /* make sure the run bit is zero for SD */
914 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) & ~SD_CTL_DMA_START); 931 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) &
932 ~SD_CTL_DMA_START);
915 /* reset stream */ 933 /* reset stream */
916 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) | SD_CTL_STREAM_RESET); 934 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) |
935 SD_CTL_STREAM_RESET);
917 udelay(3); 936 udelay(3);
918 timeout = 300; 937 timeout = 300;
919 while (!((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) && 938 while (!((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) &&
@@ -931,7 +950,7 @@ static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
931 950
932 /* program the stream_tag */ 951 /* program the stream_tag */
933 azx_sd_writel(azx_dev, SD_CTL, 952 azx_sd_writel(azx_dev, SD_CTL,
934 (azx_sd_readl(azx_dev, SD_CTL) & ~SD_CTL_STREAM_TAG_MASK) | 953 (azx_sd_readl(azx_dev, SD_CTL) & ~SD_CTL_STREAM_TAG_MASK)|
935 (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT)); 954 (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT));
936 955
937 /* program the length of samples in cyclic buffer */ 956 /* program the length of samples in cyclic buffer */
@@ -951,11 +970,13 @@ static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
951 azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr)); 970 azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr));
952 971
953 /* enable the position buffer */ 972 /* enable the position buffer */
954 if (! (azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) 973 if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE))
955 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE); 974 azx_writel(chip, DPLBASE,
975 (u32)chip->posbuf.addr |ICH6_DPLBASE_ENABLE);
956 976
957 /* set the interrupt enable bits in the descriptor control register */ 977 /* set the interrupt enable bits in the descriptor control register */
958 azx_sd_writel(azx_dev, SD_CTL, azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK); 978 azx_sd_writel(azx_dev, SD_CTL,
979 azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK);
959 980
960 return 0; 981 return 0;
961} 982}
@@ -987,7 +1008,8 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model)
987 bus_temp.ops.command = azx_send_cmd; 1008 bus_temp.ops.command = azx_send_cmd;
988 bus_temp.ops.get_response = azx_get_response; 1009 bus_temp.ops.get_response = azx_get_response;
989 1010
990 if ((err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus)) < 0) 1011 err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus);
1012 if (err < 0)
991 return err; 1013 return err;
992 1014
993 codecs = audio_codecs = 0; 1015 codecs = audio_codecs = 0;
@@ -1038,7 +1060,7 @@ static inline struct azx_dev *azx_assign_device(struct azx *chip, int stream)
1038 nums = chip->capture_streams; 1060 nums = chip->capture_streams;
1039 } 1061 }
1040 for (i = 0; i < nums; i++, dev++) 1062 for (i = 0; i < nums; i++, dev++)
1041 if (! chip->azx_dev[dev].opened) { 1063 if (!chip->azx_dev[dev].opened) {
1042 chip->azx_dev[dev].opened = 1; 1064 chip->azx_dev[dev].opened = 1;
1043 return &chip->azx_dev[dev]; 1065 return &chip->azx_dev[dev];
1044 } 1066 }
@@ -1052,7 +1074,8 @@ static inline void azx_release_device(struct azx_dev *azx_dev)
1052} 1074}
1053 1075
1054static struct snd_pcm_hardware azx_pcm_hw = { 1076static struct snd_pcm_hardware azx_pcm_hw = {
1055 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1077 .info = (SNDRV_PCM_INFO_MMAP |
1078 SNDRV_PCM_INFO_INTERLEAVED |
1056 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1079 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1057 SNDRV_PCM_INFO_MMAP_VALID | 1080 SNDRV_PCM_INFO_MMAP_VALID |
1058 /* No full-resume yet implemented */ 1081 /* No full-resume yet implemented */
@@ -1105,7 +1128,8 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1105 128); 1128 128);
1106 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 1129 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
1107 128); 1130 128);
1108 if ((err = hinfo->ops.open(hinfo, apcm->codec, substream)) < 0) { 1131 err = hinfo->ops.open(hinfo, apcm->codec, substream);
1132 if (err < 0) {
1109 azx_release_device(azx_dev); 1133 azx_release_device(azx_dev);
1110 mutex_unlock(&chip->open_mutex); 1134 mutex_unlock(&chip->open_mutex);
1111 return err; 1135 return err;
@@ -1139,9 +1163,11 @@ static int azx_pcm_close(struct snd_pcm_substream *substream)
1139 return 0; 1163 return 0;
1140} 1164}
1141 1165
1142static int azx_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) 1166static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
1167 struct snd_pcm_hw_params *hw_params)
1143{ 1168{
1144 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1169 return snd_pcm_lib_malloc_pages(substream,
1170 params_buffer_bytes(hw_params));
1145} 1171}
1146 1172
1147static int azx_pcm_hw_free(struct snd_pcm_substream *substream) 1173static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
@@ -1175,13 +1201,15 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
1175 runtime->channels, 1201 runtime->channels,
1176 runtime->format, 1202 runtime->format,
1177 hinfo->maxbps); 1203 hinfo->maxbps);
1178 if (! azx_dev->format_val) { 1204 if (!azx_dev->format_val) {
1179 snd_printk(KERN_ERR SFX "invalid format_val, rate=%d, ch=%d, format=%d\n", 1205 snd_printk(KERN_ERR SFX
1206 "invalid format_val, rate=%d, ch=%d, format=%d\n",
1180 runtime->rate, runtime->channels, runtime->format); 1207 runtime->rate, runtime->channels, runtime->format);
1181 return -EINVAL; 1208 return -EINVAL;
1182 } 1209 }
1183 1210
1184 snd_printdd("azx_pcm_prepare: bufsize=0x%x, fragsize=0x%x, format=0x%x\n", 1211 snd_printdd("azx_pcm_prepare: bufsize=0x%x, fragsize=0x%x, "
1212 "format=0x%x\n",
1185 azx_dev->bufsize, azx_dev->fragsize, azx_dev->format_val); 1213 azx_dev->bufsize, azx_dev->fragsize, azx_dev->format_val);
1186 azx_setup_periods(azx_dev); 1214 azx_setup_periods(azx_dev);
1187 azx_setup_controller(chip, azx_dev); 1215 azx_setup_controller(chip, azx_dev);
@@ -1223,7 +1251,8 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1223 cmd == SNDRV_PCM_TRIGGER_SUSPEND || 1251 cmd == SNDRV_PCM_TRIGGER_SUSPEND ||
1224 cmd == SNDRV_PCM_TRIGGER_STOP) { 1252 cmd == SNDRV_PCM_TRIGGER_STOP) {
1225 int timeout = 5000; 1253 int timeout = 5000;
1226 while (azx_sd_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START && --timeout) 1254 while ((azx_sd_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START) &&
1255 --timeout)
1227 ; 1256 ;
1228 } 1257 }
1229 return err; 1258 return err;
@@ -1241,7 +1270,7 @@ static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)
1241 /* use the position buffer */ 1270 /* use the position buffer */
1242 pos = le32_to_cpu(*azx_dev->posbuf); 1271 pos = le32_to_cpu(*azx_dev->posbuf);
1243 if (chip->position_fix == POS_FIX_AUTO && 1272 if (chip->position_fix == POS_FIX_AUTO &&
1244 azx_dev->period_intr == 1 && ! pos) { 1273 azx_dev->period_intr == 1 && !pos) {
1245 printk(KERN_WARNING 1274 printk(KERN_WARNING
1246 "hda-intel: Invalid position buffer, " 1275 "hda-intel: Invalid position buffer, "
1247 "using LPIB read method instead.\n"); 1276 "using LPIB read method instead.\n");
@@ -1292,7 +1321,8 @@ static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
1292 snd_assert(cpcm->name, return -EINVAL); 1321 snd_assert(cpcm->name, return -EINVAL);
1293 1322
1294 err = snd_pcm_new(chip->card, cpcm->name, pcm_dev, 1323 err = snd_pcm_new(chip->card, cpcm->name, pcm_dev,
1295 cpcm->stream[0].substreams, cpcm->stream[1].substreams, 1324 cpcm->stream[0].substreams,
1325 cpcm->stream[1].substreams,
1296 &pcm); 1326 &pcm);
1297 if (err < 0) 1327 if (err < 0)
1298 return err; 1328 return err;
@@ -1327,7 +1357,8 @@ static int __devinit azx_pcm_create(struct azx *chip)
1327 int c, err; 1357 int c, err;
1328 int pcm_dev; 1358 int pcm_dev;
1329 1359
1330 if ((err = snd_hda_build_pcms(chip->bus)) < 0) 1360 err = snd_hda_build_pcms(chip->bus);
1361 if (err < 0)
1331 return err; 1362 return err;
1332 1363
1333 /* create audio PCMs */ 1364 /* create audio PCMs */
@@ -1338,10 +1369,12 @@ static int __devinit azx_pcm_create(struct azx *chip)
1338 if (codec->pcm_info[c].is_modem) 1369 if (codec->pcm_info[c].is_modem)
1339 continue; /* create later */ 1370 continue; /* create later */
1340 if (pcm_dev >= AZX_MAX_AUDIO_PCMS) { 1371 if (pcm_dev >= AZX_MAX_AUDIO_PCMS) {
1341 snd_printk(KERN_ERR SFX "Too many audio PCMs\n"); 1372 snd_printk(KERN_ERR SFX
1373 "Too many audio PCMs\n");
1342 return -EINVAL; 1374 return -EINVAL;
1343 } 1375 }
1344 err = create_codec_pcm(chip, codec, &codec->pcm_info[c], pcm_dev); 1376 err = create_codec_pcm(chip, codec,
1377 &codec->pcm_info[c], pcm_dev);
1345 if (err < 0) 1378 if (err < 0)
1346 return err; 1379 return err;
1347 pcm_dev++; 1380 pcm_dev++;
@@ -1353,13 +1386,15 @@ static int __devinit azx_pcm_create(struct azx *chip)
1353 list_for_each(p, &chip->bus->codec_list) { 1386 list_for_each(p, &chip->bus->codec_list) {
1354 codec = list_entry(p, struct hda_codec, list); 1387 codec = list_entry(p, struct hda_codec, list);
1355 for (c = 0; c < codec->num_pcms; c++) { 1388 for (c = 0; c < codec->num_pcms; c++) {
1356 if (! codec->pcm_info[c].is_modem) 1389 if (!codec->pcm_info[c].is_modem)
1357 continue; /* already created */ 1390 continue; /* already created */
1358 if (pcm_dev >= AZX_MAX_PCMS) { 1391 if (pcm_dev >= AZX_MAX_PCMS) {
1359 snd_printk(KERN_ERR SFX "Too many modem PCMs\n"); 1392 snd_printk(KERN_ERR SFX
1393 "Too many modem PCMs\n");
1360 return -EINVAL; 1394 return -EINVAL;
1361 } 1395 }
1362 err = create_codec_pcm(chip, codec, &codec->pcm_info[c], pcm_dev); 1396 err = create_codec_pcm(chip, codec,
1397 &codec->pcm_info[c], pcm_dev);
1363 if (err < 0) 1398 if (err < 0)
1364 return err; 1399 return err;
1365 chip->pcm[pcm_dev]->dev_class = SNDRV_PCM_CLASS_MODEM; 1400 chip->pcm[pcm_dev]->dev_class = SNDRV_PCM_CLASS_MODEM;
@@ -1386,7 +1421,8 @@ static int __devinit azx_init_stream(struct azx *chip)
1386 int i; 1421 int i;
1387 1422
1388 /* initialize each stream (aka device) 1423 /* initialize each stream (aka device)
1389 * assign the starting bdl address to each stream (device) and initialize 1424 * assign the starting bdl address to each stream (device)
1425 * and initialize
1390 */ 1426 */
1391 for (i = 0; i < chip->num_streams; i++) { 1427 for (i = 0; i < chip->num_streams; i++) {
1392 unsigned int off = sizeof(u32) * (i * AZX_MAX_FRAG * 4); 1428 unsigned int off = sizeof(u32) * (i * AZX_MAX_FRAG * 4);
@@ -1650,28 +1686,35 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1650 break; 1686 break;
1651 } 1687 }
1652 chip->num_streams = chip->playback_streams + chip->capture_streams; 1688 chip->num_streams = chip->playback_streams + chip->capture_streams;
1653 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), GFP_KERNEL); 1689 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev),
1690 GFP_KERNEL);
1654 if (!chip->azx_dev) { 1691 if (!chip->azx_dev) {
1655 snd_printk(KERN_ERR "cannot malloc azx_dev\n"); 1692 snd_printk(KERN_ERR "cannot malloc azx_dev\n");
1656 goto errout; 1693 goto errout;
1657 } 1694 }
1658 1695
1659 /* allocate memory for the BDL for each stream */ 1696 /* allocate memory for the BDL for each stream */
1660 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 1697 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
1661 BDL_SIZE, &chip->bdl)) < 0) { 1698 snd_dma_pci_data(chip->pci),
1699 BDL_SIZE, &chip->bdl);
1700 if (err < 0) {
1662 snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); 1701 snd_printk(KERN_ERR SFX "cannot allocate BDL\n");
1663 goto errout; 1702 goto errout;
1664 } 1703 }
1665 /* allocate memory for the position buffer */ 1704 /* allocate memory for the position buffer */
1666 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 1705 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
1667 chip->num_streams * 8, &chip->posbuf)) < 0) { 1706 snd_dma_pci_data(chip->pci),
1707 chip->num_streams * 8, &chip->posbuf);
1708 if (err < 0) {
1668 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); 1709 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n");
1669 goto errout; 1710 goto errout;
1670 } 1711 }
1671 /* allocate CORB/RIRB */ 1712 /* allocate CORB/RIRB */
1672 if (! chip->single_cmd) 1713 if (!chip->single_cmd) {
1673 if ((err = azx_alloc_cmd_io(chip)) < 0) 1714 err = azx_alloc_cmd_io(chip);
1715 if (err < 0)
1674 goto errout; 1716 goto errout;
1717 }
1675 1718
1676 /* initialize streams */ 1719 /* initialize streams */
1677 azx_init_stream(chip); 1720 azx_init_stream(chip);
@@ -1688,14 +1731,16 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1688 goto errout; 1731 goto errout;
1689 } 1732 }
1690 1733
1691 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) <0) { 1734 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
1735 if (err <0) {
1692 snd_printk(KERN_ERR SFX "Error creating device [card]!\n"); 1736 snd_printk(KERN_ERR SFX "Error creating device [card]!\n");
1693 goto errout; 1737 goto errout;
1694 } 1738 }
1695 1739
1696 strcpy(card->driver, "HDA-Intel"); 1740 strcpy(card->driver, "HDA-Intel");
1697 strcpy(card->shortname, driver_short_names[chip->driver_type]); 1741 strcpy(card->shortname, driver_short_names[chip->driver_type]);
1698 sprintf(card->longname, "%s at 0x%lx irq %i", card->shortname, chip->addr, chip->irq); 1742 sprintf(card->longname, "%s at 0x%lx irq %i",
1743 card->shortname, chip->addr, chip->irq);
1699 1744
1700 *rchip = chip; 1745 *rchip = chip;
1701 return 0; 1746 return 0;
@@ -1705,7 +1750,8 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1705 return err; 1750 return err;
1706} 1751}
1707 1752
1708static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) 1753static int __devinit azx_probe(struct pci_dev *pci,
1754 const struct pci_device_id *pci_id)
1709{ 1755{
1710 struct snd_card *card; 1756 struct snd_card *card;
1711 struct azx *chip; 1757 struct azx *chip;
@@ -1725,26 +1771,30 @@ static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id *
1725 card->private_data = chip; 1771 card->private_data = chip;
1726 1772
1727 /* create codec instances */ 1773 /* create codec instances */
1728 if ((err = azx_codec_create(chip, model)) < 0) { 1774 err = azx_codec_create(chip, model);
1775 if (err < 0) {
1729 snd_card_free(card); 1776 snd_card_free(card);
1730 return err; 1777 return err;
1731 } 1778 }
1732 1779
1733 /* create PCM streams */ 1780 /* create PCM streams */
1734 if ((err = azx_pcm_create(chip)) < 0) { 1781 err = azx_pcm_create(chip);
1782 if (err < 0) {
1735 snd_card_free(card); 1783 snd_card_free(card);
1736 return err; 1784 return err;
1737 } 1785 }
1738 1786
1739 /* create mixer controls */ 1787 /* create mixer controls */
1740 if ((err = azx_mixer_create(chip)) < 0) { 1788 err = azx_mixer_create(chip);
1789 if (err < 0) {
1741 snd_card_free(card); 1790 snd_card_free(card);
1742 return err; 1791 return err;
1743 } 1792 }
1744 1793
1745 snd_card_set_dev(card, &pci->dev); 1794 snd_card_set_dev(card, &pci->dev);
1746 1795
1747 if ((err = snd_card_register(card)) < 0) { 1796 err = snd_card_register(card);
1797 if (err < 0) {
1748 snd_card_free(card); 1798 snd_card_free(card);
1749 return err; 1799 return err;
1750 } 1800 }
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index f91ea5ec9f6d..c8d34a5b081f 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -26,7 +26,8 @@
26/* 26/*
27 * for mixer controls 27 * for mixer controls
28 */ 28 */
29#define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19)) 29#define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) \
30 ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19))
30/* mono volume with index (index=0,1,...) (channel=1,2) */ 31/* mono volume with index (index=0,1,...) (channel=1,2) */
31#define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ 32#define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
32 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ 33 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
@@ -64,13 +65,20 @@
64#define HDA_CODEC_MUTE(xname, nid, xindex, direction) \ 65#define HDA_CODEC_MUTE(xname, nid, xindex, direction) \
65 HDA_CODEC_MUTE_MONO(xname, nid, 3, xindex, direction) 66 HDA_CODEC_MUTE_MONO(xname, nid, 3, xindex, direction)
66 67
67int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); 68int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
68int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 69 struct snd_ctl_elem_info *uinfo);
69int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 70int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
70int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag, unsigned int size, unsigned int __user *tlv); 71 struct snd_ctl_elem_value *ucontrol);
71int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); 72int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
72int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 73 struct snd_ctl_elem_value *ucontrol);
73int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 74int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
75 unsigned int size, unsigned int __user *tlv);
76int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol,
77 struct snd_ctl_elem_info *uinfo);
78int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
79 struct snd_ctl_elem_value *ucontrol);
80int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
81 struct snd_ctl_elem_value *ucontrol);
74/* lowlevel accessor with caching; use carefully */ 82/* lowlevel accessor with caching; use carefully */
75int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, 83int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
76 int direction, int index); 84 int direction, int index);
@@ -86,10 +94,13 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
86 .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) } 94 .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) }
87 95
88/* stereo switch binding multiple inputs */ 96/* stereo switch binding multiple inputs */
89#define HDA_BIND_MUTE(xname,nid,indices,dir) HDA_BIND_MUTE_MONO(xname,nid,3,indices,dir) 97#define HDA_BIND_MUTE(xname,nid,indices,dir) \
98 HDA_BIND_MUTE_MONO(xname,nid,3,indices,dir)
90 99
91int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 100int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol,
92int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 101 struct snd_ctl_elem_value *ucontrol);
102int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
103 struct snd_ctl_elem_value *ucontrol);
93 104
94int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid); 105int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid);
95int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid); 106int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid);
@@ -107,8 +118,10 @@ struct hda_input_mux {
107 struct hda_input_mux_item items[HDA_MAX_NUM_INPUTS]; 118 struct hda_input_mux_item items[HDA_MAX_NUM_INPUTS];
108}; 119};
109 120
110int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem_info *uinfo); 121int snd_hda_input_mux_info(const struct hda_input_mux *imux,
111int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *imux, 122 struct snd_ctl_elem_info *uinfo);
123int snd_hda_input_mux_put(struct hda_codec *codec,
124 const struct hda_input_mux *imux,
112 struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, 125 struct snd_ctl_elem_value *ucontrol, hda_nid_t nid,
113 unsigned int *cur_val); 126 unsigned int *cur_val);
114 127
@@ -120,13 +133,19 @@ struct hda_channel_mode {
120 const struct hda_verb *sequence; 133 const struct hda_verb *sequence;
121}; 134};
122 135
123int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinfo, 136int snd_hda_ch_mode_info(struct hda_codec *codec,
124 const struct hda_channel_mode *chmode, int num_chmodes); 137 struct snd_ctl_elem_info *uinfo,
125int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 138 const struct hda_channel_mode *chmode,
126 const struct hda_channel_mode *chmode, int num_chmodes, 139 int num_chmodes);
140int snd_hda_ch_mode_get(struct hda_codec *codec,
141 struct snd_ctl_elem_value *ucontrol,
142 const struct hda_channel_mode *chmode,
143 int num_chmodes,
127 int max_channels); 144 int max_channels);
128int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 145int snd_hda_ch_mode_put(struct hda_codec *codec,
129 const struct hda_channel_mode *chmode, int num_chmodes, 146 struct snd_ctl_elem_value *ucontrol,
147 const struct hda_channel_mode *chmode,
148 int num_chmodes,
130 int *max_channelsp); 149 int *max_channelsp);
131 150
132/* 151/*
@@ -146,20 +165,25 @@ struct hda_multi_out {
146 int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */ 165 int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */
147}; 166};
148 167
149int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout); 168int snd_hda_multi_out_dig_open(struct hda_codec *codec,
150int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout); 169 struct hda_multi_out *mout);
170int snd_hda_multi_out_dig_close(struct hda_codec *codec,
171 struct hda_multi_out *mout);
151int snd_hda_multi_out_dig_prepare(struct hda_codec *codec, 172int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
152 struct hda_multi_out *mout, 173 struct hda_multi_out *mout,
153 unsigned int stream_tag, 174 unsigned int stream_tag,
154 unsigned int format, 175 unsigned int format,
155 struct snd_pcm_substream *substream); 176 struct snd_pcm_substream *substream);
156int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout, 177int snd_hda_multi_out_analog_open(struct hda_codec *codec,
178 struct hda_multi_out *mout,
157 struct snd_pcm_substream *substream); 179 struct snd_pcm_substream *substream);
158int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, 180int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
181 struct hda_multi_out *mout,
159 unsigned int stream_tag, 182 unsigned int stream_tag,
160 unsigned int format, 183 unsigned int format,
161 struct snd_pcm_substream *substream); 184 struct snd_pcm_substream *substream);
162int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_out *mout); 185int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
186 struct hda_multi_out *mout);
163 187
164/* 188/*
165 * generic codec parser 189 * generic codec parser
@@ -181,7 +205,8 @@ static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; }
181int snd_hda_check_board_config(struct hda_codec *codec, int num_configs, 205int snd_hda_check_board_config(struct hda_codec *codec, int num_configs,
182 const char **modelnames, 206 const char **modelnames,
183 const struct snd_pci_quirk *pci_list); 207 const struct snd_pci_quirk *pci_list);
184int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew); 208int snd_hda_add_new_ctls(struct hda_codec *codec,
209 struct snd_kcontrol_new *knew);
185 210
186/* 211/*
187 * power management 212 * power management
@@ -232,7 +257,9 @@ extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST];
232 257
233struct auto_pin_cfg { 258struct auto_pin_cfg {
234 int line_outs; 259 int line_outs;
235 hda_nid_t line_out_pins[5]; /* sorted in the order of Front/Surr/CLFE/Side */ 260 hda_nid_t line_out_pins[5]; /* sorted in the order of
261 * Front/Surr/CLFE/Side
262 */
236 int speaker_outs; 263 int speaker_outs;
237 hda_nid_t speaker_pins[5]; 264 hda_nid_t speaker_pins[5];
238 int hp_outs; 265 int hp_outs;
@@ -243,13 +270,19 @@ struct auto_pin_cfg {
243 hda_nid_t dig_in_pin; 270 hda_nid_t dig_in_pin;
244}; 271};
245 272
246#define get_defcfg_connect(cfg) ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) 273#define get_defcfg_connect(cfg) \
247#define get_defcfg_association(cfg) ((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT) 274 ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT)
248#define get_defcfg_location(cfg) ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) 275#define get_defcfg_association(cfg) \
249#define get_defcfg_sequence(cfg) (cfg & AC_DEFCFG_SEQUENCE) 276 ((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT)
250#define get_defcfg_device(cfg) ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) 277#define get_defcfg_location(cfg) \
251 278 ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT)
252int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg, 279#define get_defcfg_sequence(cfg) \
280 (cfg & AC_DEFCFG_SEQUENCE)
281#define get_defcfg_device(cfg) \
282 ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT)
283
284int snd_hda_parse_pin_def_config(struct hda_codec *codec,
285 struct auto_pin_cfg *cfg,
253 hda_nid_t *ignore_nids); 286 hda_nid_t *ignore_nids);
254 287
255/* amp values */ 288/* amp values */
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index ac15066fd300..ccd19180e541 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -58,7 +58,8 @@ static void print_amp_caps(struct snd_info_buffer *buffer,
58 snd_iprintf(buffer, "N/A\n"); 58 snd_iprintf(buffer, "N/A\n");
59 return; 59 return;
60 } 60 }
61 snd_iprintf(buffer, "ofs=0x%02x, nsteps=0x%02x, stepsize=0x%02x, mute=%x\n", 61 snd_iprintf(buffer, "ofs=0x%02x, nsteps=0x%02x, stepsize=0x%02x, "
62 "mute=%x\n",
62 caps & AC_AMPCAP_OFFSET, 63 caps & AC_AMPCAP_OFFSET,
63 (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT, 64 (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT,
64 (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT, 65 (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT,
@@ -76,11 +77,13 @@ static void print_amp_vals(struct snd_info_buffer *buffer,
76 for (i = 0; i < indices; i++) { 77 for (i = 0; i < indices; i++) {
77 snd_iprintf(buffer, " ["); 78 snd_iprintf(buffer, " [");
78 if (stereo) { 79 if (stereo) {
79 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, 80 val = snd_hda_codec_read(codec, nid, 0,
81 AC_VERB_GET_AMP_GAIN_MUTE,
80 AC_AMP_GET_LEFT | dir | i); 82 AC_AMP_GET_LEFT | dir | i);
81 snd_iprintf(buffer, "0x%02x ", val); 83 snd_iprintf(buffer, "0x%02x ", val);
82 } 84 }
83 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, 85 val = snd_hda_codec_read(codec, nid, 0,
86 AC_VERB_GET_AMP_GAIN_MUTE,
84 AC_AMP_GET_RIGHT | dir | i); 87 AC_AMP_GET_RIGHT | dir | i);
85 snd_iprintf(buffer, "0x%02x]", val); 88 snd_iprintf(buffer, "0x%02x]", val);
86 } 89 }
@@ -237,7 +240,8 @@ static void print_pin_caps(struct snd_info_buffer *buffer,
237} 240}
238 241
239 242
240static void print_codec_info(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 243static void print_codec_info(struct snd_info_entry *entry,
244 struct snd_info_buffer *buffer)
241{ 245{
242 struct hda_codec *codec = entry->private_data; 246 struct hda_codec *codec = entry->private_data;
243 char buf[32]; 247 char buf[32];
@@ -271,9 +275,11 @@ static void print_codec_info(struct snd_info_entry *entry, struct snd_info_buffe
271 return; 275 return;
272 } 276 }
273 for (i = 0; i < nodes; i++, nid++) { 277 for (i = 0; i < nodes; i++, nid++) {
274 unsigned int wid_caps = snd_hda_param_read(codec, nid, 278 unsigned int wid_caps =
275 AC_PAR_AUDIO_WIDGET_CAP); 279 snd_hda_param_read(codec, nid,
276 unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 280 AC_PAR_AUDIO_WIDGET_CAP);
281 unsigned int wid_type =
282 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
277 int conn_len = 0; 283 int conn_len = 0;
278 hda_nid_t conn[HDA_MAX_CONNECTIONS]; 284 hda_nid_t conn[HDA_MAX_CONNECTIONS];
279 285
@@ -313,7 +319,9 @@ static void print_codec_info(struct snd_info_entry *entry, struct snd_info_buffe
313 if (wid_type == AC_WID_PIN) { 319 if (wid_type == AC_WID_PIN) {
314 unsigned int pinctls; 320 unsigned int pinctls;
315 print_pin_caps(buffer, codec, nid); 321 print_pin_caps(buffer, codec, nid);
316 pinctls = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 322 pinctls = snd_hda_codec_read(codec, nid, 0,
323 AC_VERB_GET_PIN_WIDGET_CONTROL,
324 0);
317 snd_iprintf(buffer, " Pin-ctls: 0x%02x:", pinctls); 325 snd_iprintf(buffer, " Pin-ctls: 0x%02x:", pinctls);
318 if (pinctls & AC_PINCTL_IN_EN) 326 if (pinctls & AC_PINCTL_IN_EN)
319 snd_iprintf(buffer, " IN"); 327 snd_iprintf(buffer, " IN");
@@ -333,7 +341,8 @@ static void print_codec_info(struct snd_info_entry *entry, struct snd_info_buffe
333 if (wid_caps & AC_WCAP_POWER) 341 if (wid_caps & AC_WCAP_POWER)
334 snd_iprintf(buffer, " Power: 0x%x\n", 342 snd_iprintf(buffer, " Power: 0x%x\n",
335 snd_hda_codec_read(codec, nid, 0, 343 snd_hda_codec_read(codec, nid, 0,
336 AC_VERB_GET_POWER_STATE, 0)); 344 AC_VERB_GET_POWER_STATE,
345 0));
337 346
338 if (wid_caps & AC_WCAP_CONN_LIST) { 347 if (wid_caps & AC_WCAP_CONN_LIST) {
339 int c, curr = -1; 348 int c, curr = -1;