2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU Library General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * Vortex PCM ALSA driver.
20 * Supports ADB and WT DMA. Unfortunately, WT channels do not run yet.
21 * It remains stuck,and DMA transfers do not happen.
23 #include <sound/asoundef.h>
24 #include <linux/time.h>
25 #include <sound/core.h>
26 #include <sound/pcm.h>
27 #include <sound/pcm_params.h>
30 #define VORTEX_PCM_TYPE(x) (x->name[40])
32 /* hardware definition */
33 static struct snd_pcm_hardware snd_vortex_playback_hw_adb
= {
35 (SNDRV_PCM_INFO_MMAP
| /* SNDRV_PCM_INFO_RESUME | */
36 SNDRV_PCM_INFO_PAUSE
| SNDRV_PCM_INFO_INTERLEAVED
|
37 SNDRV_PCM_INFO_MMAP_VALID
),
39 SNDRV_PCM_FMTBIT_S16_LE
| SNDRV_PCM_FMTBIT_U8
|
40 SNDRV_PCM_FMTBIT_MU_LAW
| SNDRV_PCM_FMTBIT_A_LAW
,
41 .rates
= SNDRV_PCM_RATE_CONTINUOUS
,
46 .buffer_bytes_max
= 0x10000,
47 .period_bytes_min
= 0x20,
48 .period_bytes_max
= 0x1000,
54 static struct snd_pcm_hardware snd_vortex_playback_hw_a3d
= {
56 (SNDRV_PCM_INFO_MMAP
| /* SNDRV_PCM_INFO_RESUME | */
57 SNDRV_PCM_INFO_PAUSE
| SNDRV_PCM_INFO_INTERLEAVED
|
58 SNDRV_PCM_INFO_MMAP_VALID
),
60 SNDRV_PCM_FMTBIT_S16_LE
| SNDRV_PCM_FMTBIT_U8
|
61 SNDRV_PCM_FMTBIT_MU_LAW
| SNDRV_PCM_FMTBIT_A_LAW
,
62 .rates
= SNDRV_PCM_RATE_CONTINUOUS
,
67 .buffer_bytes_max
= 0x10000,
68 .period_bytes_min
= 0x100,
69 .period_bytes_max
= 0x1000,
74 static struct snd_pcm_hardware snd_vortex_playback_hw_spdif
= {
76 (SNDRV_PCM_INFO_MMAP
| /* SNDRV_PCM_INFO_RESUME | */
77 SNDRV_PCM_INFO_PAUSE
| SNDRV_PCM_INFO_INTERLEAVED
|
78 SNDRV_PCM_INFO_MMAP_VALID
),
80 SNDRV_PCM_FMTBIT_S16_LE
| SNDRV_PCM_FMTBIT_U8
|
81 SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE
| SNDRV_PCM_FMTBIT_MU_LAW
|
82 SNDRV_PCM_FMTBIT_A_LAW
,
84 SNDRV_PCM_RATE_32000
| SNDRV_PCM_RATE_44100
| SNDRV_PCM_RATE_48000
,
89 .buffer_bytes_max
= 0x10000,
90 .period_bytes_min
= 0x100,
91 .period_bytes_max
= 0x1000,
97 static struct snd_pcm_hardware snd_vortex_playback_hw_wt
= {
98 .info
= (SNDRV_PCM_INFO_MMAP
|
99 SNDRV_PCM_INFO_INTERLEAVED
|
100 SNDRV_PCM_INFO_BLOCK_TRANSFER
| SNDRV_PCM_INFO_MMAP_VALID
),
101 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
102 .rates
= SNDRV_PCM_RATE_8000_48000
| SNDRV_PCM_RATE_CONTINUOUS
, // SNDRV_PCM_RATE_48000,
107 .buffer_bytes_max
= 0x10000,
108 .period_bytes_min
= 0x0400,
109 .period_bytes_max
= 0x1000,
115 static unsigned int au8830_channels
[3] = {
119 static struct snd_pcm_hw_constraint_list hw_constraints_au8830_channels
= {
120 .count
= ARRAY_SIZE(au8830_channels
),
121 .list
= au8830_channels
,
126 static void vortex_notify_pcm_vol_change(struct snd_card
*card
,
127 struct snd_kcontrol
*kctl
, int activate
)
130 kctl
->vd
[0].access
&= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
132 kctl
->vd
[0].access
|= SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
133 snd_ctl_notify(card
, SNDRV_CTL_EVENT_MASK_VALUE
|
134 SNDRV_CTL_EVENT_MASK_INFO
, &(kctl
->id
));
138 static int snd_vortex_pcm_open(struct snd_pcm_substream
*substream
)
140 vortex_t
*vortex
= snd_pcm_substream_chip(substream
);
141 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
144 /* Force equal size periods */
146 snd_pcm_hw_constraint_integer(runtime
,
147 SNDRV_PCM_HW_PARAM_PERIODS
)) < 0)
149 /* Avoid PAGE_SIZE boundary to fall inside of a period. */
151 snd_pcm_hw_constraint_pow2(runtime
, 0,
152 SNDRV_PCM_HW_PARAM_PERIOD_BYTES
)) < 0)
155 snd_pcm_hw_constraint_step(runtime
, 0,
156 SNDRV_PCM_HW_PARAM_BUFFER_BYTES
, 64);
158 if (VORTEX_PCM_TYPE(substream
->pcm
) != VORTEX_PCM_WT
) {
160 if (VORTEX_PCM_TYPE(substream
->pcm
) == VORTEX_PCM_A3D
) {
161 runtime
->hw
= snd_vortex_playback_hw_a3d
;
164 if (VORTEX_PCM_TYPE(substream
->pcm
) == VORTEX_PCM_SPDIF
) {
165 runtime
->hw
= snd_vortex_playback_hw_spdif
;
166 switch (vortex
->spdif_sr
) {
168 runtime
->hw
.rates
= SNDRV_PCM_RATE_32000
;
171 runtime
->hw
.rates
= SNDRV_PCM_RATE_44100
;
174 runtime
->hw
.rates
= SNDRV_PCM_RATE_48000
;
178 if (VORTEX_PCM_TYPE(substream
->pcm
) == VORTEX_PCM_ADB
179 || VORTEX_PCM_TYPE(substream
->pcm
) == VORTEX_PCM_I2S
)
180 runtime
->hw
= snd_vortex_playback_hw_adb
;
182 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
&&
183 VORTEX_IS_QUAD(vortex
) &&
184 VORTEX_PCM_TYPE(substream
->pcm
) == VORTEX_PCM_ADB
) {
185 runtime
->hw
.channels_max
= 4;
186 snd_pcm_hw_constraint_list(runtime
, 0,
187 SNDRV_PCM_HW_PARAM_CHANNELS
,
188 &hw_constraints_au8830_channels
);
191 substream
->runtime
->private_data
= NULL
;
195 runtime
->hw
= snd_vortex_playback_hw_wt
;
196 substream
->runtime
->private_data
= NULL
;
203 static int snd_vortex_pcm_close(struct snd_pcm_substream
*substream
)
205 //vortex_t *chip = snd_pcm_substream_chip(substream);
206 stream_t
*stream
= (stream_t
*) substream
->runtime
->private_data
;
208 // the hardware-specific codes will be here
209 if (stream
!= NULL
) {
210 stream
->substream
= NULL
;
213 substream
->runtime
->private_data
= NULL
;
217 /* hw_params callback */
219 snd_vortex_pcm_hw_params(struct snd_pcm_substream
*substream
,
220 struct snd_pcm_hw_params
*hw_params
)
222 vortex_t
*chip
= snd_pcm_substream_chip(substream
);
223 stream_t
*stream
= (stream_t
*) (substream
->runtime
->private_data
);
226 // Alloc buffer memory.
228 snd_pcm_lib_malloc_pages(substream
, params_buffer_bytes(hw_params
));
230 printk(KERN_ERR
"Vortex: pcm page alloc failed!\n");
234 printk(KERN_INFO "Vortex: periods %d, period_bytes %d, channels = %d\n", params_periods(hw_params),
235 params_period_bytes(hw_params), params_channels(hw_params));
237 spin_lock_irq(&chip
->lock
);
238 // Make audio routes and config buffer DMA.
239 if (VORTEX_PCM_TYPE(substream
->pcm
) != VORTEX_PCM_WT
) {
240 int dma
, type
= VORTEX_PCM_TYPE(substream
->pcm
);
241 /* Dealloc any routes. */
243 vortex_adb_allocroute(chip
, stream
->dma
,
244 stream
->nr_ch
, stream
->dir
,
249 vortex_adb_allocroute(chip
, -1,
250 params_channels(hw_params
),
251 substream
->stream
, type
,
254 spin_unlock_irq(&chip
->lock
);
257 stream
= substream
->runtime
->private_data
= &chip
->dma_adb
[dma
];
258 stream
->substream
= substream
;
260 vortex_adbdma_setbuffers(chip
, dma
,
261 params_period_bytes(hw_params
),
262 params_periods(hw_params
));
263 if (VORTEX_PCM_TYPE(substream
->pcm
) == VORTEX_PCM_ADB
) {
264 chip
->pcm_vol
[substream
->number
].active
= 1;
265 vortex_notify_pcm_vol_change(chip
->card
,
266 chip
->pcm_vol
[substream
->number
].kctl
, 1);
271 /* if (stream != NULL)
272 vortex_wt_allocroute(chip, substream->number, 0); */
273 vortex_wt_allocroute(chip
, substream
->number
,
274 params_channels(hw_params
));
275 stream
= substream
->runtime
->private_data
=
276 &chip
->dma_wt
[substream
->number
];
277 stream
->dma
= substream
->number
;
278 stream
->substream
= substream
;
279 vortex_wtdma_setbuffers(chip
, substream
->number
,
280 params_period_bytes(hw_params
),
281 params_periods(hw_params
));
284 spin_unlock_irq(&chip
->lock
);
288 /* hw_free callback */
289 static int snd_vortex_pcm_hw_free(struct snd_pcm_substream
*substream
)
291 vortex_t
*chip
= snd_pcm_substream_chip(substream
);
292 stream_t
*stream
= (stream_t
*) (substream
->runtime
->private_data
);
294 spin_lock_irq(&chip
->lock
);
295 // Delete audio routes.
296 if (VORTEX_PCM_TYPE(substream
->pcm
) != VORTEX_PCM_WT
) {
297 if (stream
!= NULL
) {
298 if (VORTEX_PCM_TYPE(substream
->pcm
) == VORTEX_PCM_ADB
) {
299 chip
->pcm_vol
[substream
->number
].active
= 0;
300 vortex_notify_pcm_vol_change(chip
->card
,
301 chip
->pcm_vol
[substream
->number
].kctl
,
304 vortex_adb_allocroute(chip
, stream
->dma
,
305 stream
->nr_ch
, stream
->dir
,
313 vortex_wt_allocroute(chip
, stream
->dma
, 0);
316 substream
->runtime
->private_data
= NULL
;
317 spin_unlock_irq(&chip
->lock
);
319 return snd_pcm_lib_free_pages(substream
);
322 /* prepare callback */
323 static int snd_vortex_pcm_prepare(struct snd_pcm_substream
*substream
)
325 vortex_t
*chip
= snd_pcm_substream_chip(substream
);
326 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
327 stream_t
*stream
= (stream_t
*) substream
->runtime
->private_data
;
328 int dma
= stream
->dma
, fmt
, dir
;
330 // set up the hardware with the current configuration.
331 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
335 fmt
= vortex_alsafmt_aspfmt(runtime
->format
);
336 spin_lock_irq(&chip
->lock
);
337 if (VORTEX_PCM_TYPE(substream
->pcm
) != VORTEX_PCM_WT
) {
338 vortex_adbdma_setmode(chip
, dma
, 1, dir
, fmt
,
339 runtime
->channels
== 1 ? 0 : 1, 0);
340 vortex_adbdma_setstartbuffer(chip
, dma
, 0);
341 if (VORTEX_PCM_TYPE(substream
->pcm
) != VORTEX_PCM_SPDIF
)
342 vortex_adb_setsrc(chip
, dma
, runtime
->rate
, dir
);
346 vortex_wtdma_setmode(chip
, dma
, 1, fmt
, 0, 0);
347 // FIXME: Set rate (i guess using vortex_wt_writereg() somehow).
348 vortex_wtdma_setstartbuffer(chip
, dma
, 0);
351 spin_unlock_irq(&chip
->lock
);
355 /* trigger callback */
356 static int snd_vortex_pcm_trigger(struct snd_pcm_substream
*substream
, int cmd
)
358 vortex_t
*chip
= snd_pcm_substream_chip(substream
);
359 stream_t
*stream
= (stream_t
*) substream
->runtime
->private_data
;
360 int dma
= stream
->dma
;
362 spin_lock(&chip
->lock
);
364 case SNDRV_PCM_TRIGGER_START
:
365 // do something to start the PCM engine
366 //printk(KERN_INFO "vortex: start %d\n", dma);
367 stream
->fifo_enabled
= 1;
368 if (VORTEX_PCM_TYPE(substream
->pcm
) != VORTEX_PCM_WT
) {
369 vortex_adbdma_resetup(chip
, dma
);
370 vortex_adbdma_startfifo(chip
, dma
);
374 printk(KERN_INFO
"vortex: wt start %d\n", dma
);
375 vortex_wtdma_startfifo(chip
, dma
);
379 case SNDRV_PCM_TRIGGER_STOP
:
380 // do something to stop the PCM engine
381 //printk(KERN_INFO "vortex: stop %d\n", dma);
382 stream
->fifo_enabled
= 0;
383 if (VORTEX_PCM_TYPE(substream
->pcm
) != VORTEX_PCM_WT
)
384 vortex_adbdma_stopfifo(chip
, dma
);
387 printk(KERN_INFO
"vortex: wt stop %d\n", dma
);
388 vortex_wtdma_stopfifo(chip
, dma
);
392 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
393 //printk(KERN_INFO "vortex: pause %d\n", dma);
394 if (VORTEX_PCM_TYPE(substream
->pcm
) != VORTEX_PCM_WT
)
395 vortex_adbdma_pausefifo(chip
, dma
);
398 vortex_wtdma_pausefifo(chip
, dma
);
401 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
402 //printk(KERN_INFO "vortex: resume %d\n", dma);
403 if (VORTEX_PCM_TYPE(substream
->pcm
) != VORTEX_PCM_WT
)
404 vortex_adbdma_resumefifo(chip
, dma
);
407 vortex_wtdma_resumefifo(chip
, dma
);
411 spin_unlock(&chip
->lock
);
414 spin_unlock(&chip
->lock
);
418 /* pointer callback */
419 static snd_pcm_uframes_t
snd_vortex_pcm_pointer(struct snd_pcm_substream
*substream
)
421 vortex_t
*chip
= snd_pcm_substream_chip(substream
);
422 stream_t
*stream
= (stream_t
*) substream
->runtime
->private_data
;
423 int dma
= stream
->dma
;
424 snd_pcm_uframes_t current_ptr
= 0;
426 spin_lock(&chip
->lock
);
427 if (VORTEX_PCM_TYPE(substream
->pcm
) != VORTEX_PCM_WT
)
428 current_ptr
= vortex_adbdma_getlinearpos(chip
, dma
);
431 current_ptr
= vortex_wtdma_getlinearpos(chip
, dma
);
433 //printk(KERN_INFO "vortex: pointer = 0x%x\n", current_ptr);
434 spin_unlock(&chip
->lock
);
435 return (bytes_to_frames(substream
->runtime
, current_ptr
));
439 static struct snd_pcm_ops snd_vortex_playback_ops
= {
440 .open
= snd_vortex_pcm_open
,
441 .close
= snd_vortex_pcm_close
,
442 .ioctl
= snd_pcm_lib_ioctl
,
443 .hw_params
= snd_vortex_pcm_hw_params
,
444 .hw_free
= snd_vortex_pcm_hw_free
,
445 .prepare
= snd_vortex_pcm_prepare
,
446 .trigger
= snd_vortex_pcm_trigger
,
447 .pointer
= snd_vortex_pcm_pointer
,
448 .page
= snd_pcm_sgbuf_ops_page
,
452 * definitions of capture are omitted here...
455 static char *vortex_pcm_prettyname
[VORTEX_PCM_LAST
] = {
462 static char *vortex_pcm_name
[VORTEX_PCM_LAST
] = {
472 static int snd_vortex_spdif_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
474 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_IEC958
;
479 static int snd_vortex_spdif_mask_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
481 ucontrol
->value
.iec958
.status
[0] = 0xff;
482 ucontrol
->value
.iec958
.status
[1] = 0xff;
483 ucontrol
->value
.iec958
.status
[2] = 0xff;
484 ucontrol
->value
.iec958
.status
[3] = IEC958_AES3_CON_FS
;
488 static int snd_vortex_spdif_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
490 vortex_t
*vortex
= snd_kcontrol_chip(kcontrol
);
491 ucontrol
->value
.iec958
.status
[0] = 0x00;
492 ucontrol
->value
.iec958
.status
[1] = IEC958_AES1_CON_ORIGINAL
|IEC958_AES1_CON_DIGDIGCONV_ID
;
493 ucontrol
->value
.iec958
.status
[2] = 0x00;
494 switch (vortex
->spdif_sr
) {
495 case 32000: ucontrol
->value
.iec958
.status
[3] = IEC958_AES3_CON_FS_32000
; break;
496 case 44100: ucontrol
->value
.iec958
.status
[3] = IEC958_AES3_CON_FS_44100
; break;
497 case 48000: ucontrol
->value
.iec958
.status
[3] = IEC958_AES3_CON_FS_48000
; break;
502 static int snd_vortex_spdif_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
504 vortex_t
*vortex
= snd_kcontrol_chip(kcontrol
);
505 int spdif_sr
= 48000;
506 switch (ucontrol
->value
.iec958
.status
[3] & IEC958_AES3_CON_FS
) {
507 case IEC958_AES3_CON_FS_32000
: spdif_sr
= 32000; break;
508 case IEC958_AES3_CON_FS_44100
: spdif_sr
= 44100; break;
509 case IEC958_AES3_CON_FS_48000
: spdif_sr
= 48000; break;
511 if (spdif_sr
== vortex
->spdif_sr
)
513 vortex
->spdif_sr
= spdif_sr
;
514 vortex_spdif_init(vortex
, vortex
->spdif_sr
, 1);
519 static struct snd_kcontrol_new snd_vortex_mixer_spdif
[] = {
521 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
522 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,DEFAULT
),
523 .info
= snd_vortex_spdif_info
,
524 .get
= snd_vortex_spdif_get
,
525 .put
= snd_vortex_spdif_put
,
528 .access
= SNDRV_CTL_ELEM_ACCESS_READ
,
529 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
530 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,CON_MASK
),
531 .info
= snd_vortex_spdif_info
,
532 .get
= snd_vortex_spdif_mask_get
536 /* subdevice PCM Volume control */
538 static int snd_vortex_pcm_vol_info(struct snd_kcontrol
*kcontrol
,
539 struct snd_ctl_elem_info
*uinfo
)
541 vortex_t
*vortex
= snd_kcontrol_chip(kcontrol
);
542 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
543 uinfo
->count
= (VORTEX_IS_QUAD(vortex
) ? 4 : 2);
544 uinfo
->value
.integer
.min
= -128;
545 uinfo
->value
.integer
.max
= 32;
549 static int snd_vortex_pcm_vol_get(struct snd_kcontrol
*kcontrol
,
550 struct snd_ctl_elem_value
*ucontrol
)
553 vortex_t
*vortex
= snd_kcontrol_chip(kcontrol
);
554 int subdev
= kcontrol
->id
.subdevice
;
555 struct pcm_vol
*p
= &vortex
->pcm_vol
[subdev
];
556 int max_chn
= (VORTEX_IS_QUAD(vortex
) ? 4 : 2);
557 for (i
= 0; i
< max_chn
; i
++)
558 ucontrol
->value
.integer
.value
[i
] = p
->vol
[i
];
562 static int snd_vortex_pcm_vol_put(struct snd_kcontrol
*kcontrol
,
563 struct snd_ctl_elem_value
*ucontrol
)
569 vortex_t
*vortex
= snd_kcontrol_chip(kcontrol
);
570 int subdev
= kcontrol
->id
.subdevice
;
571 struct pcm_vol
*p
= &vortex
->pcm_vol
[subdev
];
572 int max_chn
= (VORTEX_IS_QUAD(vortex
) ? 4 : 2);
573 for (i
= 0; i
< max_chn
; i
++) {
574 if (p
->vol
[i
] != ucontrol
->value
.integer
.value
[i
]) {
575 p
->vol
[i
] = ucontrol
->value
.integer
.value
[i
];
577 switch (vortex
->dma_adb
[p
->dma
].nr_ch
) {
583 mixin
= p
->mixin
[(i
< 2) ? i
: (i
- 2)];
590 vortex_mix_setinputvolumebyte(vortex
,
591 vortex
->mixplayb
[i
], mixin
, vol
);
599 static const DECLARE_TLV_DB_MINMAX(vortex_pcm_vol_db_scale
, -9600, 2400);
601 static struct snd_kcontrol_new snd_vortex_pcm_vol
= {
602 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
603 .name
= "PCM Playback Volume",
604 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
605 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
606 SNDRV_CTL_ELEM_ACCESS_INACTIVE
,
607 .info
= snd_vortex_pcm_vol_info
,
608 .get
= snd_vortex_pcm_vol_get
,
609 .put
= snd_vortex_pcm_vol_put
,
610 .tlv
= { .p
= vortex_pcm_vol_db_scale
},
613 /* create a pcm device */
614 static int snd_vortex_new_pcm(vortex_t
*chip
, int idx
, int nr
)
617 struct snd_kcontrol
*kctl
;
621 if (!chip
|| idx
< 0 || idx
>= VORTEX_PCM_LAST
)
624 /* idx indicates which kind of PCM device. ADB, SPDIF, I2S and A3D share the
625 * same dma engine. WT uses it own separate dma engine which can't capture. */
626 if (idx
== VORTEX_PCM_ADB
)
630 err
= snd_pcm_new(chip
->card
, vortex_pcm_prettyname
[idx
], idx
, nr
,
634 snprintf(pcm
->name
, sizeof(pcm
->name
),
635 "%s %s", CARD_NAME_SHORT
, vortex_pcm_name
[idx
]);
636 chip
->pcm
[idx
] = pcm
;
637 // This is an evil hack, but it saves a lot of duplicated code.
638 VORTEX_PCM_TYPE(pcm
) = idx
;
639 pcm
->private_data
= chip
;
641 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
642 &snd_vortex_playback_ops
);
643 if (idx
== VORTEX_PCM_ADB
)
644 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
,
645 &snd_vortex_playback_ops
);
647 /* pre-allocation of Scatter-Gather buffers */
649 snd_pcm_lib_preallocate_pages_for_all(pcm
, SNDRV_DMA_TYPE_DEV_SG
,
650 snd_dma_pci_data(chip
->pci_dev
),
653 switch (VORTEX_PCM_TYPE(pcm
)) {
655 err
= snd_pcm_add_chmap_ctls(pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
657 VORTEX_IS_QUAD(chip
) ? 4 : 2,
661 err
= snd_pcm_add_chmap_ctls(pcm
, SNDRV_PCM_STREAM_CAPTURE
,
662 snd_pcm_std_chmaps
, 2, 0, NULL
);
668 err
= snd_pcm_add_chmap_ctls(pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
669 snd_pcm_std_chmaps
, 1, 0, NULL
);
676 if (VORTEX_PCM_TYPE(pcm
) == VORTEX_PCM_SPDIF
) {
677 for (i
= 0; i
< ARRAY_SIZE(snd_vortex_mixer_spdif
); i
++) {
678 kctl
= snd_ctl_new1(&snd_vortex_mixer_spdif
[i
], chip
);
681 if ((err
= snd_ctl_add(chip
->card
, kctl
)) < 0)
685 if (VORTEX_PCM_TYPE(pcm
) == VORTEX_PCM_ADB
) {
686 for (i
= 0; i
< NR_PCM
; i
++) {
687 chip
->pcm_vol
[i
].active
= 0;
688 chip
->pcm_vol
[i
].dma
= -1;
689 kctl
= snd_ctl_new1(&snd_vortex_pcm_vol
, chip
);
692 chip
->pcm_vol
[i
].kctl
= kctl
;
694 kctl
->id
.subdevice
= i
;
695 err
= snd_ctl_add(chip
->card
, kctl
);