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 const 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 const 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 const 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 const 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 const unsigned int au8830_channels
[3] = {
119 static const 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 dev_err(chip
->card
->dev
, "Vortex: pcm page alloc failed!\n");
234 pr_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
, chip
);
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 dev_info(chip
->card
->dev
, "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 dev_info(chip
->card
->dev
, "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 current_ptr
= bytes_to_frames(substream
->runtime
, current_ptr
);
436 if (current_ptr
>= substream
->runtime
->buffer_size
)
442 static const struct snd_pcm_ops snd_vortex_playback_ops
= {
443 .open
= snd_vortex_pcm_open
,
444 .close
= snd_vortex_pcm_close
,
445 .ioctl
= snd_pcm_lib_ioctl
,
446 .hw_params
= snd_vortex_pcm_hw_params
,
447 .hw_free
= snd_vortex_pcm_hw_free
,
448 .prepare
= snd_vortex_pcm_prepare
,
449 .trigger
= snd_vortex_pcm_trigger
,
450 .pointer
= snd_vortex_pcm_pointer
,
451 .page
= snd_pcm_sgbuf_ops_page
,
455 * definitions of capture are omitted here...
458 static char *vortex_pcm_prettyname
[VORTEX_PCM_LAST
] = {
465 static char *vortex_pcm_name
[VORTEX_PCM_LAST
] = {
475 static int snd_vortex_spdif_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
477 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_IEC958
;
482 static int snd_vortex_spdif_mask_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
484 ucontrol
->value
.iec958
.status
[0] = 0xff;
485 ucontrol
->value
.iec958
.status
[1] = 0xff;
486 ucontrol
->value
.iec958
.status
[2] = 0xff;
487 ucontrol
->value
.iec958
.status
[3] = IEC958_AES3_CON_FS
;
491 static int snd_vortex_spdif_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
493 vortex_t
*vortex
= snd_kcontrol_chip(kcontrol
);
494 ucontrol
->value
.iec958
.status
[0] = 0x00;
495 ucontrol
->value
.iec958
.status
[1] = IEC958_AES1_CON_ORIGINAL
|IEC958_AES1_CON_DIGDIGCONV_ID
;
496 ucontrol
->value
.iec958
.status
[2] = 0x00;
497 switch (vortex
->spdif_sr
) {
498 case 32000: ucontrol
->value
.iec958
.status
[3] = IEC958_AES3_CON_FS_32000
; break;
499 case 44100: ucontrol
->value
.iec958
.status
[3] = IEC958_AES3_CON_FS_44100
; break;
500 case 48000: ucontrol
->value
.iec958
.status
[3] = IEC958_AES3_CON_FS_48000
; break;
505 static int snd_vortex_spdif_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
507 vortex_t
*vortex
= snd_kcontrol_chip(kcontrol
);
508 int spdif_sr
= 48000;
509 switch (ucontrol
->value
.iec958
.status
[3] & IEC958_AES3_CON_FS
) {
510 case IEC958_AES3_CON_FS_32000
: spdif_sr
= 32000; break;
511 case IEC958_AES3_CON_FS_44100
: spdif_sr
= 44100; break;
512 case IEC958_AES3_CON_FS_48000
: spdif_sr
= 48000; break;
514 if (spdif_sr
== vortex
->spdif_sr
)
516 vortex
->spdif_sr
= spdif_sr
;
517 vortex_spdif_init(vortex
, vortex
->spdif_sr
, 1);
522 static struct snd_kcontrol_new snd_vortex_mixer_spdif
[] = {
524 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
525 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,DEFAULT
),
526 .info
= snd_vortex_spdif_info
,
527 .get
= snd_vortex_spdif_get
,
528 .put
= snd_vortex_spdif_put
,
531 .access
= SNDRV_CTL_ELEM_ACCESS_READ
,
532 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
533 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,CON_MASK
),
534 .info
= snd_vortex_spdif_info
,
535 .get
= snd_vortex_spdif_mask_get
539 /* subdevice PCM Volume control */
541 static int snd_vortex_pcm_vol_info(struct snd_kcontrol
*kcontrol
,
542 struct snd_ctl_elem_info
*uinfo
)
544 vortex_t
*vortex
= snd_kcontrol_chip(kcontrol
);
545 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
546 uinfo
->count
= (VORTEX_IS_QUAD(vortex
) ? 4 : 2);
547 uinfo
->value
.integer
.min
= -128;
548 uinfo
->value
.integer
.max
= 32;
552 static int snd_vortex_pcm_vol_get(struct snd_kcontrol
*kcontrol
,
553 struct snd_ctl_elem_value
*ucontrol
)
556 vortex_t
*vortex
= snd_kcontrol_chip(kcontrol
);
557 int subdev
= kcontrol
->id
.subdevice
;
558 struct pcm_vol
*p
= &vortex
->pcm_vol
[subdev
];
559 int max_chn
= (VORTEX_IS_QUAD(vortex
) ? 4 : 2);
560 for (i
= 0; i
< max_chn
; i
++)
561 ucontrol
->value
.integer
.value
[i
] = p
->vol
[i
];
565 static int snd_vortex_pcm_vol_put(struct snd_kcontrol
*kcontrol
,
566 struct snd_ctl_elem_value
*ucontrol
)
572 vortex_t
*vortex
= snd_kcontrol_chip(kcontrol
);
573 int subdev
= kcontrol
->id
.subdevice
;
574 struct pcm_vol
*p
= &vortex
->pcm_vol
[subdev
];
575 int max_chn
= (VORTEX_IS_QUAD(vortex
) ? 4 : 2);
576 for (i
= 0; i
< max_chn
; i
++) {
577 if (p
->vol
[i
] != ucontrol
->value
.integer
.value
[i
]) {
578 p
->vol
[i
] = ucontrol
->value
.integer
.value
[i
];
580 switch (vortex
->dma_adb
[p
->dma
].nr_ch
) {
586 mixin
= p
->mixin
[(i
< 2) ? i
: (i
- 2)];
593 vortex_mix_setinputvolumebyte(vortex
,
594 vortex
->mixplayb
[i
], mixin
, vol
);
602 static const DECLARE_TLV_DB_MINMAX(vortex_pcm_vol_db_scale
, -9600, 2400);
604 static const struct snd_kcontrol_new snd_vortex_pcm_vol
= {
605 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
606 .name
= "PCM Playback Volume",
607 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
608 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
609 SNDRV_CTL_ELEM_ACCESS_INACTIVE
,
610 .info
= snd_vortex_pcm_vol_info
,
611 .get
= snd_vortex_pcm_vol_get
,
612 .put
= snd_vortex_pcm_vol_put
,
613 .tlv
= { .p
= vortex_pcm_vol_db_scale
},
616 /* create a pcm device */
617 static int snd_vortex_new_pcm(vortex_t
*chip
, int idx
, int nr
)
620 struct snd_kcontrol
*kctl
;
624 if (!chip
|| idx
< 0 || idx
>= VORTEX_PCM_LAST
)
627 /* idx indicates which kind of PCM device. ADB, SPDIF, I2S and A3D share the
628 * same dma engine. WT uses it own separate dma engine which can't capture. */
629 if (idx
== VORTEX_PCM_ADB
)
633 err
= snd_pcm_new(chip
->card
, vortex_pcm_prettyname
[idx
], idx
, nr
,
637 snprintf(pcm
->name
, sizeof(pcm
->name
),
638 "%s %s", CARD_NAME_SHORT
, vortex_pcm_name
[idx
]);
639 chip
->pcm
[idx
] = pcm
;
640 // This is an evil hack, but it saves a lot of duplicated code.
641 VORTEX_PCM_TYPE(pcm
) = idx
;
642 pcm
->private_data
= chip
;
644 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
645 &snd_vortex_playback_ops
);
646 if (idx
== VORTEX_PCM_ADB
)
647 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
,
648 &snd_vortex_playback_ops
);
650 /* pre-allocation of Scatter-Gather buffers */
652 snd_pcm_lib_preallocate_pages_for_all(pcm
, SNDRV_DMA_TYPE_DEV_SG
,
653 snd_dma_pci_data(chip
->pci_dev
),
656 switch (VORTEX_PCM_TYPE(pcm
)) {
658 err
= snd_pcm_add_chmap_ctls(pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
660 VORTEX_IS_QUAD(chip
) ? 4 : 2,
664 err
= snd_pcm_add_chmap_ctls(pcm
, SNDRV_PCM_STREAM_CAPTURE
,
665 snd_pcm_std_chmaps
, 2, 0, NULL
);
671 err
= snd_pcm_add_chmap_ctls(pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
672 snd_pcm_std_chmaps
, 1, 0, NULL
);
679 if (VORTEX_PCM_TYPE(pcm
) == VORTEX_PCM_SPDIF
) {
680 for (i
= 0; i
< ARRAY_SIZE(snd_vortex_mixer_spdif
); i
++) {
681 kctl
= snd_ctl_new1(&snd_vortex_mixer_spdif
[i
], chip
);
684 if ((err
= snd_ctl_add(chip
->card
, kctl
)) < 0)
688 if (VORTEX_PCM_TYPE(pcm
) == VORTEX_PCM_ADB
) {
689 for (i
= 0; i
< NR_PCM
; i
++) {
690 chip
->pcm_vol
[i
].active
= 0;
691 chip
->pcm_vol
[i
].dma
= -1;
692 kctl
= snd_ctl_new1(&snd_vortex_pcm_vol
, chip
);
695 chip
->pcm_vol
[i
].kctl
= kctl
;
697 kctl
->id
.subdevice
= i
;
698 err
= snd_ctl_add(chip
->card
, kctl
);