diff options
author | Eliot Blennerhassett <eblennerhassett@audioscience.com> | 2011-02-09 23:26:04 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-02-10 12:49:26 -0500 |
commit | ba94455c29c383713c360537b6323e3bd4c76434 (patch) | |
tree | c06d1f61e5f43ad17be64e7b5d9653979357ed72 /sound/pci/asihpi/asihpi.c | |
parent | deb21a233470537276ee39239441d1bf679223cd (diff) |
ALSA: asihpi - Remove unused subsys pointer from all HPI functions.
asihpi.c don't link playback and capture streams, there is too much
offset between them.
Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/asihpi/asihpi.c')
-rw-r--r-- | sound/pci/asihpi/asihpi.c | 429 |
1 files changed, 224 insertions, 205 deletions
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index 31d7295f5c71..8dda81aac433 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c | |||
@@ -97,13 +97,14 @@ static const int mixer_dump; | |||
97 | #define DEFAULT_SAMPLERATE 44100 | 97 | #define DEFAULT_SAMPLERATE 44100 |
98 | static int adapter_fs = DEFAULT_SAMPLERATE; | 98 | static int adapter_fs = DEFAULT_SAMPLERATE; |
99 | 99 | ||
100 | static struct hpi_hsubsys *ss; /* handle to HPI audio subsystem */ | ||
101 | |||
102 | /* defaults */ | 100 | /* defaults */ |
103 | #define PERIODS_MIN 2 | 101 | #define PERIODS_MIN 2 |
104 | #define PERIOD_BYTES_MIN 2048 | 102 | #define PERIOD_BYTES_MIN 2048 |
105 | #define BUFFER_BYTES_MAX (512 * 1024) | 103 | #define BUFFER_BYTES_MAX (512 * 1024) |
106 | 104 | ||
105 | /* convert stream to character */ | ||
106 | #define SCHR(s) ((s == SNDRV_PCM_STREAM_PLAYBACK) ? 'P' : 'C') | ||
107 | |||
107 | /*#define TIMER_MILLISECONDS 20 | 108 | /*#define TIMER_MILLISECONDS 20 |
108 | #define FORCE_TIMER_JIFFIES ((TIMER_MILLISECONDS * HZ + 999)/1000) | 109 | #define FORCE_TIMER_JIFFIES ((TIMER_MILLISECONDS * HZ + 999)/1000) |
109 | */ | 110 | */ |
@@ -149,8 +150,8 @@ struct snd_card_asihpi_pcm { | |||
149 | struct timer_list timer; | 150 | struct timer_list timer; |
150 | unsigned int respawn_timer; | 151 | unsigned int respawn_timer; |
151 | unsigned int hpi_buffer_attached; | 152 | unsigned int hpi_buffer_attached; |
152 | unsigned int pcm_size; | 153 | unsigned int buffer_bytes; |
153 | unsigned int pcm_count; | 154 | unsigned int period_bytes; |
154 | unsigned int bytes_per_sec; | 155 | unsigned int bytes_per_sec; |
155 | unsigned int pcm_buf_host_rw_ofs; /* Host R/W pos */ | 156 | unsigned int pcm_buf_host_rw_ofs; /* Host R/W pos */ |
156 | unsigned int pcm_buf_dma_ofs; /* DMA R/W offset in buffer */ | 157 | unsigned int pcm_buf_dma_ofs; /* DMA R/W offset in buffer */ |
@@ -165,7 +166,6 @@ struct snd_card_asihpi_pcm { | |||
165 | /* Functions to allow driver to give a buffer to HPI for busmastering */ | 166 | /* Functions to allow driver to give a buffer to HPI for busmastering */ |
166 | 167 | ||
167 | static u16 hpi_stream_host_buffer_attach( | 168 | static u16 hpi_stream_host_buffer_attach( |
168 | struct hpi_hsubsys *hS, | ||
169 | u32 h_stream, /* handle to outstream. */ | 169 | u32 h_stream, /* handle to outstream. */ |
170 | u32 size_in_bytes, /* size in bytes of bus mastering buffer */ | 170 | u32 size_in_bytes, /* size in bytes of bus mastering buffer */ |
171 | u32 pci_address | 171 | u32 pci_address |
@@ -192,10 +192,7 @@ static u16 hpi_stream_host_buffer_attach( | |||
192 | return hr.error; | 192 | return hr.error; |
193 | } | 193 | } |
194 | 194 | ||
195 | static u16 hpi_stream_host_buffer_detach( | 195 | static u16 hpi_stream_host_buffer_detach(u32 h_stream) |
196 | struct hpi_hsubsys *hS, | ||
197 | u32 h_stream | ||
198 | ) | ||
199 | { | 196 | { |
200 | struct hpi_message hm; | 197 | struct hpi_message hm; |
201 | struct hpi_response hr; | 198 | struct hpi_response hr; |
@@ -216,24 +213,23 @@ static u16 hpi_stream_host_buffer_detach( | |||
216 | return hr.error; | 213 | return hr.error; |
217 | } | 214 | } |
218 | 215 | ||
219 | static inline u16 hpi_stream_start(struct hpi_hsubsys *hS, u32 h_stream) | 216 | static inline u16 hpi_stream_start(u32 h_stream) |
220 | { | 217 | { |
221 | if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) | 218 | if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) |
222 | return hpi_outstream_start(hS, h_stream); | 219 | return hpi_outstream_start(h_stream); |
223 | else | 220 | else |
224 | return hpi_instream_start(hS, h_stream); | 221 | return hpi_instream_start(h_stream); |
225 | } | 222 | } |
226 | 223 | ||
227 | static inline u16 hpi_stream_stop(struct hpi_hsubsys *hS, u32 h_stream) | 224 | static inline u16 hpi_stream_stop(u32 h_stream) |
228 | { | 225 | { |
229 | if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) | 226 | if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) |
230 | return hpi_outstream_stop(hS, h_stream); | 227 | return hpi_outstream_stop(h_stream); |
231 | else | 228 | else |
232 | return hpi_instream_stop(hS, h_stream); | 229 | return hpi_instream_stop(h_stream); |
233 | } | 230 | } |
234 | 231 | ||
235 | static inline u16 hpi_stream_get_info_ex( | 232 | static inline u16 hpi_stream_get_info_ex( |
236 | struct hpi_hsubsys *hS, | ||
237 | u32 h_stream, | 233 | u32 h_stream, |
238 | u16 *pw_state, | 234 | u16 *pw_state, |
239 | u32 *pbuffer_size, | 235 | u32 *pbuffer_size, |
@@ -244,42 +240,41 @@ static inline u16 hpi_stream_get_info_ex( | |||
244 | { | 240 | { |
245 | u16 e; | 241 | u16 e; |
246 | if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) | 242 | if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) |
247 | e = hpi_outstream_get_info_ex(hS, h_stream, pw_state, | 243 | e = hpi_outstream_get_info_ex(h_stream, pw_state, |
248 | pbuffer_size, pdata_in_buffer, | 244 | pbuffer_size, pdata_in_buffer, |
249 | psample_count, pauxiliary_data); | 245 | psample_count, pauxiliary_data); |
250 | else | 246 | else |
251 | e = hpi_instream_get_info_ex(hS, h_stream, pw_state, | 247 | e = hpi_instream_get_info_ex(h_stream, pw_state, |
252 | pbuffer_size, pdata_in_buffer, | 248 | pbuffer_size, pdata_in_buffer, |
253 | psample_count, pauxiliary_data); | 249 | psample_count, pauxiliary_data); |
254 | return e; | 250 | return e; |
255 | } | 251 | } |
256 | 252 | ||
257 | static inline u16 hpi_stream_group_add(struct hpi_hsubsys *hS, | 253 | static inline u16 hpi_stream_group_add( |
258 | u32 h_master, | 254 | u32 h_master, |
259 | u32 h_stream) | 255 | u32 h_stream) |
260 | { | 256 | { |
261 | if (hpi_handle_object(h_master) == HPI_OBJ_OSTREAM) | 257 | if (hpi_handle_object(h_master) == HPI_OBJ_OSTREAM) |
262 | return hpi_outstream_group_add(hS, h_master, h_stream); | 258 | return hpi_outstream_group_add(h_master, h_stream); |
263 | else | 259 | else |
264 | return hpi_instream_group_add(hS, h_master, h_stream); | 260 | return hpi_instream_group_add(h_master, h_stream); |
265 | } | 261 | } |
266 | 262 | ||
267 | static inline u16 hpi_stream_group_reset(struct hpi_hsubsys *hS, | 263 | static inline u16 hpi_stream_group_reset(u32 h_stream) |
268 | u32 h_stream) | ||
269 | { | 264 | { |
270 | if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) | 265 | if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) |
271 | return hpi_outstream_group_reset(hS, h_stream); | 266 | return hpi_outstream_group_reset(h_stream); |
272 | else | 267 | else |
273 | return hpi_instream_group_reset(hS, h_stream); | 268 | return hpi_instream_group_reset(h_stream); |
274 | } | 269 | } |
275 | 270 | ||
276 | static inline u16 hpi_stream_group_get_map(struct hpi_hsubsys *hS, | 271 | static inline u16 hpi_stream_group_get_map( |
277 | u32 h_stream, u32 *mo, u32 *mi) | 272 | u32 h_stream, u32 *mo, u32 *mi) |
278 | { | 273 | { |
279 | if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) | 274 | if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) |
280 | return hpi_outstream_group_get_map(hS, h_stream, mo, mi); | 275 | return hpi_outstream_group_get_map(h_stream, mo, mi); |
281 | else | 276 | else |
282 | return hpi_instream_group_get_map(hS, h_stream, mo, mi); | 277 | return hpi_instream_group_get_map(h_stream, mo, mi); |
283 | } | 278 | } |
284 | 279 | ||
285 | static u16 handle_error(u16 err, int line, char *filename) | 280 | static u16 handle_error(u16 err, int line, char *filename) |
@@ -335,7 +330,7 @@ static snd_pcm_format_t hpi_to_alsa_formats[] = { | |||
335 | */ | 330 | */ |
336 | -1 | 331 | -1 |
337 | #else | 332 | #else |
338 | /* SNDRV_PCM_FORMAT_S24_3LE */ /* { HPI_FORMAT_PCM24_SIGNED 15 */ | 333 | /* SNDRV_PCM_FORMAT_S24_3LE */ /* HPI_FORMAT_PCM24_SIGNED 15 */ |
339 | #endif | 334 | #endif |
340 | }; | 335 | }; |
341 | 336 | ||
@@ -378,7 +373,7 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi, | |||
378 | } else { | 373 | } else { |
379 | /* on cards without SRC, | 374 | /* on cards without SRC, |
380 | valid rates are determined by sampleclock */ | 375 | valid rates are determined by sampleclock */ |
381 | err = hpi_mixer_get_control(ss, asihpi->h_mixer, | 376 | err = hpi_mixer_get_control(asihpi->h_mixer, |
382 | HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, | 377 | HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, |
383 | HPI_CONTROL_SAMPLECLOCK, &h_control); | 378 | HPI_CONTROL_SAMPLECLOCK, &h_control); |
384 | if (err) { | 379 | if (err) { |
@@ -387,7 +382,7 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi, | |||
387 | } | 382 | } |
388 | 383 | ||
389 | for (idx = 0; idx < 100; idx++) { | 384 | for (idx = 0; idx < 100; idx++) { |
390 | if (hpi_sample_clock_query_local_rate(ss, | 385 | if (hpi_sample_clock_query_local_rate( |
391 | h_control, idx, &sample_rate)) { | 386 | h_control, idx, &sample_rate)) { |
392 | if (!idx) | 387 | if (!idx) |
393 | snd_printk(KERN_ERR | 388 | snd_printk(KERN_ERR |
@@ -480,10 +475,10 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, | |||
480 | format, params_rate(params), 0, 0)); | 475 | format, params_rate(params), 0, 0)); |
481 | 476 | ||
482 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { | 477 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { |
483 | if (hpi_instream_reset(ss, dpcm->h_stream) != 0) | 478 | if (hpi_instream_reset(dpcm->h_stream) != 0) |
484 | return -EINVAL; | 479 | return -EINVAL; |
485 | 480 | ||
486 | if (hpi_instream_set_format(ss, | 481 | if (hpi_instream_set_format( |
487 | dpcm->h_stream, &dpcm->format) != 0) | 482 | dpcm->h_stream, &dpcm->format) != 0) |
488 | return -EINVAL; | 483 | return -EINVAL; |
489 | } | 484 | } |
@@ -491,10 +486,10 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, | |||
491 | dpcm->hpi_buffer_attached = 0; | 486 | dpcm->hpi_buffer_attached = 0; |
492 | if (card->support_mmap) { | 487 | if (card->support_mmap) { |
493 | 488 | ||
494 | err = hpi_stream_host_buffer_attach(ss, dpcm->h_stream, | 489 | err = hpi_stream_host_buffer_attach(dpcm->h_stream, |
495 | params_buffer_bytes(params), runtime->dma_addr); | 490 | params_buffer_bytes(params), runtime->dma_addr); |
496 | if (err == 0) { | 491 | if (err == 0) { |
497 | snd_printd(KERN_INFO | 492 | VPRINTK1(KERN_INFO |
498 | "stream_host_buffer_attach succeeded %u %lu\n", | 493 | "stream_host_buffer_attach succeeded %u %lu\n", |
499 | params_buffer_bytes(params), | 494 | params_buffer_bytes(params), |
500 | (unsigned long)runtime->dma_addr); | 495 | (unsigned long)runtime->dma_addr); |
@@ -505,11 +500,11 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, | |||
505 | return -ENOMEM; | 500 | return -ENOMEM; |
506 | } | 501 | } |
507 | 502 | ||
508 | err = hpi_stream_get_info_ex(ss, dpcm->h_stream, NULL, | 503 | err = hpi_stream_get_info_ex(dpcm->h_stream, NULL, |
509 | &dpcm->hpi_buffer_attached, | 504 | &dpcm->hpi_buffer_attached, |
510 | NULL, NULL, NULL); | 505 | NULL, NULL, NULL); |
511 | 506 | ||
512 | snd_printd(KERN_INFO "stream_host_buffer_attach status 0x%x\n", | 507 | VPRINTK1(KERN_INFO "stream_host_buffer_attach status 0x%x\n", |
513 | dpcm->hpi_buffer_attached); | 508 | dpcm->hpi_buffer_attached); |
514 | } | 509 | } |
515 | bytes_per_sec = params_rate(params) * params_channels(params); | 510 | bytes_per_sec = params_rate(params) * params_channels(params); |
@@ -520,10 +515,10 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, | |||
520 | return -EINVAL; | 515 | return -EINVAL; |
521 | 516 | ||
522 | dpcm->bytes_per_sec = bytes_per_sec; | 517 | dpcm->bytes_per_sec = bytes_per_sec; |
523 | dpcm->pcm_size = params_buffer_bytes(params); | 518 | dpcm->buffer_bytes = params_buffer_bytes(params); |
524 | dpcm->pcm_count = params_period_bytes(params); | 519 | dpcm->period_bytes = params_period_bytes(params); |
525 | snd_printd(KERN_INFO "pcm_size=%d, pcm_count=%d, bps=%d\n", | 520 | VPRINTK1(KERN_INFO "buffer_bytes=%d, period_bytes=%d, bps=%d\n", |
526 | dpcm->pcm_size, dpcm->pcm_count, bytes_per_sec); | 521 | dpcm->buffer_bytes, dpcm->period_bytes, bytes_per_sec); |
527 | 522 | ||
528 | return 0; | 523 | return 0; |
529 | } | 524 | } |
@@ -534,7 +529,7 @@ snd_card_asihpi_hw_free(struct snd_pcm_substream *substream) | |||
534 | struct snd_pcm_runtime *runtime = substream->runtime; | 529 | struct snd_pcm_runtime *runtime = substream->runtime; |
535 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; | 530 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; |
536 | if (dpcm->hpi_buffer_attached) | 531 | if (dpcm->hpi_buffer_attached) |
537 | hpi_stream_host_buffer_detach(ss, dpcm->h_stream); | 532 | hpi_stream_host_buffer_detach(dpcm->h_stream); |
538 | 533 | ||
539 | snd_pcm_lib_free_pages(substream); | 534 | snd_pcm_lib_free_pages(substream); |
540 | return 0; | 535 | return 0; |
@@ -553,7 +548,8 @@ static void snd_card_asihpi_pcm_timer_start(struct snd_pcm_substream * | |||
553 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; | 548 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; |
554 | int expiry; | 549 | int expiry; |
555 | 550 | ||
556 | expiry = HZ / 100;; //? (dpcm->pcm_count * HZ / dpcm->bytes_per_sec); | 551 | expiry = HZ / 200; |
552 | /*? (dpcm->period_bytes * HZ / dpcm->bytes_per_sec); */ | ||
557 | expiry = max(expiry, 1); /* don't let it be zero! */ | 553 | expiry = max(expiry, 1); /* don't let it be zero! */ |
558 | dpcm->timer.expires = jiffies + expiry; | 554 | dpcm->timer.expires = jiffies + expiry; |
559 | dpcm->respawn_timer = 1; | 555 | dpcm->respawn_timer = 1; |
@@ -577,8 +573,8 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
577 | struct snd_pcm_substream *s; | 573 | struct snd_pcm_substream *s; |
578 | u16 e; | 574 | u16 e; |
579 | 575 | ||
580 | snd_printd("Trigger %dstream %d\n", | 576 | VPRINTK1(KERN_INFO "%c%d trigger\n", |
581 | substream->stream, substream->number); | 577 | SCHR(substream->stream), substream->number); |
582 | switch (cmd) { | 578 | switch (cmd) { |
583 | case SNDRV_PCM_TRIGGER_START: | 579 | case SNDRV_PCM_TRIGGER_START: |
584 | snd_pcm_group_for_each_entry(s, substream) { | 580 | snd_pcm_group_for_each_entry(s, substream) { |
@@ -588,6 +584,10 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
588 | if (snd_pcm_substream_chip(s) != card) | 584 | if (snd_pcm_substream_chip(s) != card) |
589 | continue; | 585 | continue; |
590 | 586 | ||
587 | /* don't link Cap and Play */ | ||
588 | if (substream->stream != s->stream) | ||
589 | continue; | ||
590 | |||
591 | if ((s->stream == SNDRV_PCM_STREAM_PLAYBACK) && | 591 | if ((s->stream == SNDRV_PCM_STREAM_PLAYBACK) && |
592 | (card->support_mmap)) { | 592 | (card->support_mmap)) { |
593 | /* How do I know how much valid data is present | 593 | /* How do I know how much valid data is present |
@@ -596,10 +596,10 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
596 | * buffer is bigger it may contain even more | 596 | * buffer is bigger it may contain even more |
597 | * data?? | 597 | * data?? |
598 | */ | 598 | */ |
599 | unsigned int preload = ds->pcm_count * 1; | 599 | unsigned int preload = ds->period_bytes * 1; |
600 | VPRINTK2("Preload x%x\n", preload); | 600 | VPRINTK2(KERN_INFO "%d preload x%x\n", s->number, preload); |
601 | hpi_handle_error(hpi_outstream_write_buf( | 601 | hpi_handle_error(hpi_outstream_write_buf( |
602 | ss, ds->h_stream, | 602 | ds->h_stream, |
603 | &runtime->dma_area[0], | 603 | &runtime->dma_area[0], |
604 | preload, | 604 | preload, |
605 | &ds->format)); | 605 | &ds->format)); |
@@ -607,9 +607,10 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
607 | } | 607 | } |
608 | 608 | ||
609 | if (card->support_grouping) { | 609 | if (card->support_grouping) { |
610 | VPRINTK1("\t_group %dstream %d\n", s->stream, | 610 | VPRINTK1(KERN_INFO "\t%c%d group\n", |
611 | SCHR(s->stream), | ||
611 | s->number); | 612 | s->number); |
612 | e = hpi_stream_group_add(ss, | 613 | e = hpi_stream_group_add( |
613 | dpcm->h_stream, | 614 | dpcm->h_stream, |
614 | ds->h_stream); | 615 | ds->h_stream); |
615 | if (!e) { | 616 | if (!e) { |
@@ -621,10 +622,11 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
621 | } else | 622 | } else |
622 | break; | 623 | break; |
623 | } | 624 | } |
624 | snd_printd("Start\n"); | 625 | VPRINTK1(KERN_INFO "start\n"); |
625 | /* start the master stream */ | 626 | /* start the master stream */ |
626 | snd_card_asihpi_pcm_timer_start(substream); | 627 | snd_card_asihpi_pcm_timer_start(substream); |
627 | hpi_handle_error(hpi_stream_start(ss, dpcm->h_stream)); | 628 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) |
629 | hpi_handle_error(hpi_stream_start(dpcm->h_stream)); | ||
628 | break; | 630 | break; |
629 | 631 | ||
630 | case SNDRV_PCM_TRIGGER_STOP: | 632 | case SNDRV_PCM_TRIGGER_STOP: |
@@ -632,43 +634,46 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
632 | snd_pcm_group_for_each_entry(s, substream) { | 634 | snd_pcm_group_for_each_entry(s, substream) { |
633 | if (snd_pcm_substream_chip(s) != card) | 635 | if (snd_pcm_substream_chip(s) != card) |
634 | continue; | 636 | continue; |
637 | /* don't link Cap and Play */ | ||
638 | if (substream->stream != s->stream) | ||
639 | continue; | ||
635 | 640 | ||
636 | /*? workaround linked streams don't | 641 | /*? workaround linked streams don't |
637 | transition to SETUP 20070706*/ | 642 | transition to SETUP 20070706*/ |
638 | s->runtime->status->state = SNDRV_PCM_STATE_SETUP; | 643 | s->runtime->status->state = SNDRV_PCM_STATE_SETUP; |
639 | 644 | ||
640 | if (card->support_grouping) { | 645 | if (card->support_grouping) { |
641 | VPRINTK1("\t_group %dstream %d\n", s->stream, | 646 | VPRINTK1(KERN_INFO "\t%c%d group\n", |
647 | SCHR(s->stream), | ||
642 | s->number); | 648 | s->number); |
643 | snd_pcm_trigger_done(s, substream); | 649 | snd_pcm_trigger_done(s, substream); |
644 | } else | 650 | } else |
645 | break; | 651 | break; |
646 | } | 652 | } |
647 | snd_printd("Stop\n"); | 653 | VPRINTK1(KERN_INFO "stop\n"); |
648 | 654 | ||
649 | /* _prepare and _hwparams reset the stream */ | 655 | /* _prepare and _hwparams reset the stream */ |
650 | hpi_handle_error(hpi_stream_stop(ss, dpcm->h_stream)); | 656 | hpi_handle_error(hpi_stream_stop(dpcm->h_stream)); |
651 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 657 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
652 | hpi_handle_error( | 658 | hpi_handle_error( |
653 | hpi_outstream_reset(ss, dpcm->h_stream)); | 659 | hpi_outstream_reset(dpcm->h_stream)); |
654 | 660 | ||
655 | if (card->support_grouping) | 661 | if (card->support_grouping) |
656 | hpi_handle_error(hpi_stream_group_reset(ss, | 662 | hpi_handle_error(hpi_stream_group_reset(dpcm->h_stream)); |
657 | dpcm->h_stream)); | ||
658 | break; | 663 | break; |
659 | 664 | ||
660 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 665 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
661 | snd_printd("Pause release\n"); | 666 | VPRINTK1(KERN_INFO "pause release\n"); |
662 | hpi_handle_error(hpi_stream_start(ss, dpcm->h_stream)); | 667 | hpi_handle_error(hpi_stream_start(dpcm->h_stream)); |
663 | snd_card_asihpi_pcm_timer_start(substream); | 668 | snd_card_asihpi_pcm_timer_start(substream); |
664 | break; | 669 | break; |
665 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 670 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
666 | snd_printd("Pause\n"); | 671 | VPRINTK1(KERN_INFO "pause\n"); |
667 | snd_card_asihpi_pcm_timer_stop(substream); | 672 | snd_card_asihpi_pcm_timer_stop(substream); |
668 | hpi_handle_error(hpi_stream_stop(ss, dpcm->h_stream)); | 673 | hpi_handle_error(hpi_stream_stop(dpcm->h_stream)); |
669 | break; | 674 | break; |
670 | default: | 675 | default: |
671 | snd_printd("\tINVALID\n"); | 676 | snd_printd(KERN_ERR "\tINVALID\n"); |
672 | return -EINVAL; | 677 | return -EINVAL; |
673 | } | 678 | } |
674 | 679 | ||
@@ -683,19 +688,19 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
683 | pcm_buf_dma_ofs=get_buf_pos(s); | 688 | pcm_buf_dma_ofs=get_buf_pos(s); |
684 | for_each_linked_stream(s) { | 689 | for_each_linked_stream(s) { |
685 | pcm_buf_dma_ofs=get_buf_pos(s); | 690 | pcm_buf_dma_ofs=get_buf_pos(s); |
686 | min_buf_pos = modulo_min(min_buf_pos, pcm_buf_dma_ofs, pcm_size) | 691 | min_buf_pos = modulo_min(min_buf_pos, pcm_buf_dma_ofs, buffer_bytes) |
687 | new_data = min(new_data, calc_new_data(pcm_buf_dma_ofs,irq_pos) | 692 | new_data = min(new_data, calc_new_data(pcm_buf_dma_ofs,irq_pos) |
688 | } | 693 | } |
689 | timer.expires = jiffies + predict_next_period_ready(min_buf_pos); | 694 | timer.expires = jiffies + predict_next_period_ready(min_buf_pos); |
690 | for_each_linked_stream(s) { | 695 | for_each_linked_stream(s) { |
691 | s->pcm_buf_dma_ofs = min_buf_pos; | 696 | s->pcm_buf_dma_ofs = min_buf_pos; |
692 | if (new_data > pcm_count) { | 697 | if (new_data > period_bytes) { |
693 | if (mmap) { | 698 | if (mmap) { |
694 | irq_pos = (irq_pos + pcm_count) % pcm_size; | 699 | irq_pos = (irq_pos + period_bytes) % buffer_bytes; |
695 | if (playback) { | 700 | if (playback) { |
696 | write(pcm_count); | 701 | write(period_bytes); |
697 | } else { | 702 | } else { |
698 | read(pcm_count); | 703 | read(period_bytes); |
699 | } | 704 | } |
700 | } | 705 | } |
701 | snd_pcm_period_elapsed(s); | 706 | snd_pcm_period_elapsed(s); |
@@ -723,25 +728,34 @@ static inline unsigned int modulo_min(unsigned int a, unsigned int b, | |||
723 | static void snd_card_asihpi_timer_function(unsigned long data) | 728 | static void snd_card_asihpi_timer_function(unsigned long data) |
724 | { | 729 | { |
725 | struct snd_card_asihpi_pcm *dpcm = (struct snd_card_asihpi_pcm *)data; | 730 | struct snd_card_asihpi_pcm *dpcm = (struct snd_card_asihpi_pcm *)data; |
726 | struct snd_card_asihpi *card = snd_pcm_substream_chip(dpcm->substream); | 731 | struct snd_pcm_substream *substream = dpcm->substream; |
732 | struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); | ||
727 | struct snd_pcm_runtime *runtime; | 733 | struct snd_pcm_runtime *runtime; |
728 | struct snd_pcm_substream *s; | 734 | struct snd_pcm_substream *s; |
729 | unsigned int newdata = 0; | 735 | unsigned int newdata = 0; |
730 | unsigned int pcm_buf_dma_ofs, min_buf_pos = 0; | 736 | unsigned int pcm_buf_dma_ofs, min_buf_pos = 0; |
731 | unsigned int remdata, xfercount, next_jiffies; | 737 | unsigned int remdata, xfercount, next_jiffies; |
732 | int first = 1; | 738 | int first = 1; |
739 | int loops = 0; | ||
733 | u16 state; | 740 | u16 state; |
734 | u32 buffer_size, bytes_avail, samples_played, on_card_bytes; | 741 | u32 buffer_size, bytes_avail, samples_played, on_card_bytes; |
735 | 742 | ||
743 | VPRINTK1(KERN_INFO "%c%d snd_card_asihpi_timer_function\n", | ||
744 | SCHR(substream->stream), substream->number); | ||
745 | |||
736 | /* find minimum newdata and buffer pos in group */ | 746 | /* find minimum newdata and buffer pos in group */ |
737 | snd_pcm_group_for_each_entry(s, dpcm->substream) { | 747 | snd_pcm_group_for_each_entry(s, substream) { |
738 | struct snd_card_asihpi_pcm *ds = s->runtime->private_data; | 748 | struct snd_card_asihpi_pcm *ds = s->runtime->private_data; |
739 | runtime = s->runtime; | 749 | runtime = s->runtime; |
740 | 750 | ||
741 | if (snd_pcm_substream_chip(s) != card) | 751 | if (snd_pcm_substream_chip(s) != card) |
742 | continue; | 752 | continue; |
743 | 753 | ||
744 | hpi_handle_error(hpi_stream_get_info_ex(ss, | 754 | /* don't link Cap and Play */ |
755 | if (substream->stream != s->stream) | ||
756 | continue; | ||
757 | |||
758 | hpi_handle_error(hpi_stream_get_info_ex( | ||
745 | ds->h_stream, &state, | 759 | ds->h_stream, &state, |
746 | &buffer_size, &bytes_avail, | 760 | &buffer_size, &bytes_avail, |
747 | &samples_played, &on_card_bytes)); | 761 | &samples_played, &on_card_bytes)); |
@@ -749,86 +763,96 @@ static void snd_card_asihpi_timer_function(unsigned long data) | |||
749 | /* number of bytes in on-card buffer */ | 763 | /* number of bytes in on-card buffer */ |
750 | runtime->delay = on_card_bytes; | 764 | runtime->delay = on_card_bytes; |
751 | 765 | ||
752 | if (state == HPI_STATE_DRAINED) { | 766 | if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
753 | snd_printd(KERN_WARNING "outstream %d drained\n", | ||
754 | s->number); | ||
755 | //snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN); | ||
756 | //return; | ||
757 | } | ||
758 | |||
759 | if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
760 | pcm_buf_dma_ofs = ds->pcm_buf_host_rw_ofs - bytes_avail; | 767 | pcm_buf_dma_ofs = ds->pcm_buf_host_rw_ofs - bytes_avail; |
761 | else | 768 | if (state == HPI_STATE_STOPPED) { |
769 | if ((bytes_avail == 0) && | ||
770 | (on_card_bytes < ds->pcm_buf_host_rw_ofs)) { | ||
771 | hpi_handle_error(hpi_stream_start(ds->h_stream)); | ||
772 | VPRINTK1(KERN_INFO "P%d start\n", s->number); | ||
773 | } | ||
774 | } else if (state == HPI_STATE_DRAINED) { | ||
775 | VPRINTK1(KERN_WARNING "P%d drained\n", | ||
776 | s->number); | ||
777 | /*snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN); | ||
778 | continue; */ | ||
779 | } | ||
780 | } else | ||
762 | pcm_buf_dma_ofs = bytes_avail + ds->pcm_buf_host_rw_ofs; | 781 | pcm_buf_dma_ofs = bytes_avail + ds->pcm_buf_host_rw_ofs; |
763 | 782 | ||
764 | if (first) { | 783 | if (first) { |
765 | /* can't statically init min when wrap is involved */ | 784 | /* can't statically init min when wrap is involved */ |
766 | min_buf_pos = pcm_buf_dma_ofs; | 785 | min_buf_pos = pcm_buf_dma_ofs; |
767 | newdata = (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->pcm_size; | 786 | newdata = (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->buffer_bytes; |
768 | first = 0; | 787 | first = 0; |
769 | } else { | 788 | } else { |
770 | min_buf_pos = | 789 | min_buf_pos = |
771 | modulo_min(min_buf_pos, pcm_buf_dma_ofs, UINT_MAX+1L); | 790 | modulo_min(min_buf_pos, pcm_buf_dma_ofs, UINT_MAX+1L); |
772 | newdata = min( | 791 | newdata = min( |
773 | (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->pcm_size, | 792 | (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->buffer_bytes, |
774 | newdata); | 793 | newdata); |
775 | } | 794 | } |
776 | 795 | ||
777 | VPRINTK1("PB timer hw_ptr x%04lX, appl_ptr x%04lX\n", | 796 | VPRINTK1(KERN_INFO "PB timer hw_ptr x%04lX, appl_ptr x%04lX\n", |
778 | (unsigned long)frames_to_bytes(runtime, | 797 | (unsigned long)frames_to_bytes(runtime, |
779 | runtime->status->hw_ptr), | 798 | runtime->status->hw_ptr), |
780 | (unsigned long)frames_to_bytes(runtime, | 799 | (unsigned long)frames_to_bytes(runtime, |
781 | runtime->control->appl_ptr)); | 800 | runtime->control->appl_ptr)); |
782 | 801 | ||
783 | VPRINTK1("%d S=%d, irq=%04X, pos=x%04X, left=x%04X," | 802 | VPRINTK1(KERN_INFO "%d %c%d S=%d, rw=%04X, dma=x%04X, left=x%04X," |
784 | " aux=x%04X space=x%04X\n", s->number, | 803 | " aux=x%04X space=x%04X\n", |
804 | loops, SCHR(s->stream), s->number, | ||
785 | state, ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs, (int)bytes_avail, | 805 | state, ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs, (int)bytes_avail, |
786 | (int)on_card_bytes, buffer_size-bytes_avail); | 806 | (int)on_card_bytes, buffer_size-bytes_avail); |
807 | loops++; | ||
787 | } | 808 | } |
788 | pcm_buf_dma_ofs = min_buf_pos; | 809 | pcm_buf_dma_ofs = min_buf_pos; |
789 | 810 | ||
790 | remdata = newdata % dpcm->pcm_count; | 811 | remdata = newdata % dpcm->period_bytes; |
791 | xfercount = newdata - remdata; /* a multiple of pcm_count */ | 812 | xfercount = newdata - remdata; /* a multiple of period_bytes */ |
792 | /* come back when on_card_bytes has decreased enough to allow | 813 | /* come back when on_card_bytes has decreased enough to allow |
793 | write to happen, or when data has been consumed to make another | 814 | write to happen, or when data has been consumed to make another |
794 | period | 815 | period |
795 | */ | 816 | */ |
796 | if (xfercount && (on_card_bytes > dpcm->pcm_count)) | 817 | if (xfercount && (on_card_bytes > dpcm->period_bytes)) |
797 | next_jiffies = ((on_card_bytes - dpcm->pcm_count) * HZ / dpcm->bytes_per_sec); | 818 | next_jiffies = ((on_card_bytes - dpcm->period_bytes) * HZ / dpcm->bytes_per_sec); |
798 | else | 819 | else |
799 | next_jiffies = ((dpcm->pcm_count - remdata) * HZ / dpcm->bytes_per_sec); | 820 | next_jiffies = ((dpcm->period_bytes - remdata) * HZ / dpcm->bytes_per_sec); |
800 | 821 | ||
801 | next_jiffies = max(next_jiffies, 1U); | 822 | next_jiffies = max(next_jiffies, 1U); |
802 | dpcm->timer.expires = jiffies + next_jiffies; | 823 | dpcm->timer.expires = jiffies + next_jiffies; |
803 | VPRINTK1("jif %d buf pos x%04X newdata x%04X xfer x%04X\n", | 824 | VPRINTK1(KERN_INFO "jif %d buf pos x%04X newdata x%04X xfer x%04X\n", |
804 | next_jiffies, pcm_buf_dma_ofs, newdata, xfercount); | 825 | next_jiffies, pcm_buf_dma_ofs, newdata, xfercount); |
805 | 826 | ||
806 | 827 | snd_pcm_group_for_each_entry(s, substream) { | |
807 | snd_pcm_group_for_each_entry(s, dpcm->substream) { | ||
808 | struct snd_card_asihpi_pcm *ds = s->runtime->private_data; | 828 | struct snd_card_asihpi_pcm *ds = s->runtime->private_data; |
809 | 829 | ||
830 | /* don't link Cap and Play */ | ||
831 | if (substream->stream != s->stream) | ||
832 | continue; | ||
833 | |||
810 | ds->pcm_buf_dma_ofs = pcm_buf_dma_ofs; | 834 | ds->pcm_buf_dma_ofs = pcm_buf_dma_ofs; |
811 | 835 | ||
812 | if (xfercount && (on_card_bytes <= ds->pcm_count)) { | 836 | if (xfercount && (on_card_bytes <= ds->period_bytes)) { |
813 | if (card->support_mmap) { | 837 | if (card->support_mmap) { |
814 | if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 838 | if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
815 | VPRINTK2("Write OS%d x%04x\n", | 839 | VPRINTK2(KERN_INFO "P%d write x%04x\n", |
816 | s->number, | 840 | s->number, |
817 | ds->pcm_count); | 841 | ds->period_bytes); |
818 | hpi_handle_error( | 842 | hpi_handle_error( |
819 | hpi_outstream_write_buf( | 843 | hpi_outstream_write_buf( |
820 | ss, ds->h_stream, | 844 | ds->h_stream, |
821 | &s->runtime-> | 845 | &s->runtime-> |
822 | dma_area[0], | 846 | dma_area[0], |
823 | xfercount, | 847 | xfercount, |
824 | &ds->format)); | 848 | &ds->format)); |
825 | } else { | 849 | } else { |
826 | VPRINTK2("Read IS%d x%04x\n", | 850 | VPRINTK2(KERN_INFO "C%d read x%04x\n", |
827 | s->number, | 851 | s->number, |
828 | xfercount); | 852 | xfercount); |
829 | hpi_handle_error( | 853 | hpi_handle_error( |
830 | hpi_instream_read_buf( | 854 | hpi_instream_read_buf( |
831 | ss, ds->h_stream, | 855 | ds->h_stream, |
832 | NULL, xfercount)); | 856 | NULL, xfercount)); |
833 | } | 857 | } |
834 | ds->pcm_buf_host_rw_ofs = ds->pcm_buf_host_rw_ofs + xfercount; | 858 | ds->pcm_buf_host_rw_ofs = ds->pcm_buf_host_rw_ofs + xfercount; |
@@ -856,9 +880,9 @@ static int snd_card_asihpi_playback_prepare(struct snd_pcm_substream * | |||
856 | struct snd_pcm_runtime *runtime = substream->runtime; | 880 | struct snd_pcm_runtime *runtime = substream->runtime; |
857 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; | 881 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; |
858 | 882 | ||
859 | snd_printd(KERN_INFO "playback prepare %d\n", substream->number); | 883 | VPRINTK1(KERN_INFO "playback prepare %d\n", substream->number); |
860 | 884 | ||
861 | hpi_handle_error(hpi_outstream_reset(ss, dpcm->h_stream)); | 885 | hpi_handle_error(hpi_outstream_reset(dpcm->h_stream)); |
862 | dpcm->pcm_buf_host_rw_ofs = 0; | 886 | dpcm->pcm_buf_host_rw_ofs = 0; |
863 | dpcm->pcm_buf_dma_ofs = 0; | 887 | dpcm->pcm_buf_dma_ofs = 0; |
864 | dpcm->pcm_buf_elapsed_dma_ofs = 0; | 888 | dpcm->pcm_buf_elapsed_dma_ofs = 0; |
@@ -872,8 +896,8 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream) | |||
872 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; | 896 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; |
873 | snd_pcm_uframes_t ptr; | 897 | snd_pcm_uframes_t ptr; |
874 | 898 | ||
875 | ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->pcm_size); | 899 | ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); |
876 | //VPRINTK2("playback_pointer=x%04lx\n", (unsigned long)ptr); | 900 | /* VPRINTK2(KERN_INFO "playback_pointer=x%04lx\n", (unsigned long)ptr); */ |
877 | return ptr; | 901 | return ptr; |
878 | } | 902 | } |
879 | 903 | ||
@@ -890,12 +914,12 @@ static void snd_card_asihpi_playback_format(struct snd_card_asihpi *asihpi, | |||
890 | /* on cards without SRC, must query at valid rate, | 914 | /* on cards without SRC, must query at valid rate, |
891 | * maybe set by external sync | 915 | * maybe set by external sync |
892 | */ | 916 | */ |
893 | err = hpi_mixer_get_control(ss, asihpi->h_mixer, | 917 | err = hpi_mixer_get_control(asihpi->h_mixer, |
894 | HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, | 918 | HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, |
895 | HPI_CONTROL_SAMPLECLOCK, &h_control); | 919 | HPI_CONTROL_SAMPLECLOCK, &h_control); |
896 | 920 | ||
897 | if (!err) | 921 | if (!err) |
898 | err = hpi_sample_clock_get_sample_rate(ss, h_control, | 922 | err = hpi_sample_clock_get_sample_rate(h_control, |
899 | &sample_rate); | 923 | &sample_rate); |
900 | 924 | ||
901 | for (format = HPI_FORMAT_PCM8_UNSIGNED; | 925 | for (format = HPI_FORMAT_PCM8_UNSIGNED; |
@@ -903,7 +927,7 @@ static void snd_card_asihpi_playback_format(struct snd_card_asihpi *asihpi, | |||
903 | err = hpi_format_create(&hpi_format, | 927 | err = hpi_format_create(&hpi_format, |
904 | 2, format, sample_rate, 128000, 0); | 928 | 2, format, sample_rate, 128000, 0); |
905 | if (!err) | 929 | if (!err) |
906 | err = hpi_outstream_query_format(ss, h_stream, | 930 | err = hpi_outstream_query_format(h_stream, |
907 | &hpi_format); | 931 | &hpi_format); |
908 | if (!err && (hpi_to_alsa_formats[format] != -1)) | 932 | if (!err && (hpi_to_alsa_formats[format] != -1)) |
909 | pcmhw->formats |= | 933 | pcmhw->formats |= |
@@ -934,7 +958,7 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) | |||
934 | return -ENOMEM; | 958 | return -ENOMEM; |
935 | 959 | ||
936 | err = | 960 | err = |
937 | hpi_outstream_open(ss, card->adapter_index, | 961 | hpi_outstream_open(card->adapter_index, |
938 | substream->number, &dpcm->h_stream); | 962 | substream->number, &dpcm->h_stream); |
939 | hpi_handle_error(err); | 963 | hpi_handle_error(err); |
940 | if (err) | 964 | if (err) |
@@ -994,7 +1018,7 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) | |||
994 | 1018 | ||
995 | snd_pcm_set_sync(substream); | 1019 | snd_pcm_set_sync(substream); |
996 | 1020 | ||
997 | snd_printd(KERN_INFO "playback open\n"); | 1021 | VPRINTK1(KERN_INFO "playback open\n"); |
998 | 1022 | ||
999 | return 0; | 1023 | return 0; |
1000 | } | 1024 | } |
@@ -1004,8 +1028,8 @@ static int snd_card_asihpi_playback_close(struct snd_pcm_substream *substream) | |||
1004 | struct snd_pcm_runtime *runtime = substream->runtime; | 1028 | struct snd_pcm_runtime *runtime = substream->runtime; |
1005 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; | 1029 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; |
1006 | 1030 | ||
1007 | hpi_handle_error(hpi_outstream_close(ss, dpcm->h_stream)); | 1031 | hpi_handle_error(hpi_outstream_close(dpcm->h_stream)); |
1008 | snd_printd(KERN_INFO "playback close\n"); | 1032 | VPRINTK1(KERN_INFO "playback close\n"); |
1009 | 1033 | ||
1010 | return 0; | 1034 | return 0; |
1011 | } | 1035 | } |
@@ -1028,7 +1052,7 @@ static int snd_card_asihpi_playback_copy(struct snd_pcm_substream *substream, | |||
1028 | VPRINTK2(KERN_DEBUG "playback copy%d %u bytes\n", | 1052 | VPRINTK2(KERN_DEBUG "playback copy%d %u bytes\n", |
1029 | substream->number, len); | 1053 | substream->number, len); |
1030 | 1054 | ||
1031 | hpi_handle_error(hpi_outstream_write_buf(ss, dpcm->h_stream, | 1055 | hpi_handle_error(hpi_outstream_write_buf(dpcm->h_stream, |
1032 | runtime->dma_area, len, &dpcm->format)); | 1056 | runtime->dma_area, len, &dpcm->format)); |
1033 | 1057 | ||
1034 | dpcm->pcm_buf_host_rw_ofs = dpcm->pcm_buf_host_rw_ofs + len; | 1058 | dpcm->pcm_buf_host_rw_ofs = dpcm->pcm_buf_host_rw_ofs + len; |
@@ -1046,10 +1070,10 @@ static int snd_card_asihpi_playback_silence(struct snd_pcm_substream * | |||
1046 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; | 1070 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; |
1047 | 1071 | ||
1048 | len = frames_to_bytes(runtime, count); | 1072 | len = frames_to_bytes(runtime, count); |
1049 | snd_printd(KERN_INFO "playback silence %u bytes\n", len); | 1073 | VPRINTK1(KERN_INFO "playback silence %u bytes\n", len); |
1050 | 1074 | ||
1051 | memset(runtime->dma_area, 0, len); | 1075 | memset(runtime->dma_area, 0, len); |
1052 | hpi_handle_error(hpi_outstream_write_buf(ss, dpcm->h_stream, | 1076 | hpi_handle_error(hpi_outstream_write_buf(dpcm->h_stream, |
1053 | runtime->dma_area, len, &dpcm->format)); | 1077 | runtime->dma_area, len, &dpcm->format)); |
1054 | return 0; | 1078 | return 0; |
1055 | } | 1079 | } |
@@ -1085,13 +1109,13 @@ snd_card_asihpi_capture_pointer(struct snd_pcm_substream *substream) | |||
1085 | struct snd_pcm_runtime *runtime = substream->runtime; | 1109 | struct snd_pcm_runtime *runtime = substream->runtime; |
1086 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; | 1110 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; |
1087 | 1111 | ||
1088 | VPRINTK2("Capture pointer %d=%d\n", | 1112 | VPRINTK2(KERN_INFO "capture pointer %d=%d\n", |
1089 | substream->number, dpcm->pcm_buf_dma_ofs); | 1113 | substream->number, dpcm->pcm_buf_dma_ofs); |
1090 | /* NOTE Unlike playback can't use actual samples_played | 1114 | /* NOTE Unlike playback can't use actual samples_played |
1091 | for the capture position, because those samples aren't yet in | 1115 | for the capture position, because those samples aren't yet in |
1092 | the local buffer available for reading. | 1116 | the local buffer available for reading. |
1093 | */ | 1117 | */ |
1094 | return bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->pcm_size); | 1118 | return bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); |
1095 | } | 1119 | } |
1096 | 1120 | ||
1097 | static int snd_card_asihpi_capture_ioctl(struct snd_pcm_substream *substream, | 1121 | static int snd_card_asihpi_capture_ioctl(struct snd_pcm_substream *substream, |
@@ -1105,12 +1129,12 @@ static int snd_card_asihpi_capture_prepare(struct snd_pcm_substream *substream) | |||
1105 | struct snd_pcm_runtime *runtime = substream->runtime; | 1129 | struct snd_pcm_runtime *runtime = substream->runtime; |
1106 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; | 1130 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; |
1107 | 1131 | ||
1108 | hpi_handle_error(hpi_instream_reset(ss, dpcm->h_stream)); | 1132 | hpi_handle_error(hpi_instream_reset(dpcm->h_stream)); |
1109 | dpcm->pcm_buf_host_rw_ofs = 0; | 1133 | dpcm->pcm_buf_host_rw_ofs = 0; |
1110 | dpcm->pcm_buf_dma_ofs = 0; | 1134 | dpcm->pcm_buf_dma_ofs = 0; |
1111 | dpcm->pcm_buf_elapsed_dma_ofs = 0; | 1135 | dpcm->pcm_buf_elapsed_dma_ofs = 0; |
1112 | 1136 | ||
1113 | snd_printd("Capture Prepare %d\n", substream->number); | 1137 | VPRINTK1("Capture Prepare %d\n", substream->number); |
1114 | return 0; | 1138 | return 0; |
1115 | } | 1139 | } |
1116 | 1140 | ||
@@ -1128,12 +1152,12 @@ static void snd_card_asihpi_capture_format(struct snd_card_asihpi *asihpi, | |||
1128 | 1152 | ||
1129 | /* on cards without SRC, must query at valid rate, | 1153 | /* on cards without SRC, must query at valid rate, |
1130 | maybe set by external sync */ | 1154 | maybe set by external sync */ |
1131 | err = hpi_mixer_get_control(ss, asihpi->h_mixer, | 1155 | err = hpi_mixer_get_control(asihpi->h_mixer, |
1132 | HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, | 1156 | HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, |
1133 | HPI_CONTROL_SAMPLECLOCK, &h_control); | 1157 | HPI_CONTROL_SAMPLECLOCK, &h_control); |
1134 | 1158 | ||
1135 | if (!err) | 1159 | if (!err) |
1136 | err = hpi_sample_clock_get_sample_rate(ss, h_control, | 1160 | err = hpi_sample_clock_get_sample_rate(h_control, |
1137 | &sample_rate); | 1161 | &sample_rate); |
1138 | 1162 | ||
1139 | for (format = HPI_FORMAT_PCM8_UNSIGNED; | 1163 | for (format = HPI_FORMAT_PCM8_UNSIGNED; |
@@ -1142,7 +1166,7 @@ static void snd_card_asihpi_capture_format(struct snd_card_asihpi *asihpi, | |||
1142 | err = hpi_format_create(&hpi_format, 2, format, | 1166 | err = hpi_format_create(&hpi_format, 2, format, |
1143 | sample_rate, 128000, 0); | 1167 | sample_rate, 128000, 0); |
1144 | if (!err) | 1168 | if (!err) |
1145 | err = hpi_instream_query_format(ss, h_stream, | 1169 | err = hpi_instream_query_format(h_stream, |
1146 | &hpi_format); | 1170 | &hpi_format); |
1147 | if (!err) | 1171 | if (!err) |
1148 | pcmhw->formats |= | 1172 | pcmhw->formats |= |
@@ -1173,11 +1197,11 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) | |||
1173 | if (dpcm == NULL) | 1197 | if (dpcm == NULL) |
1174 | return -ENOMEM; | 1198 | return -ENOMEM; |
1175 | 1199 | ||
1176 | snd_printd("hpi_instream_open adapter %d stream %d\n", | 1200 | VPRINTK1("hpi_instream_open adapter %d stream %d\n", |
1177 | card->adapter_index, substream->number); | 1201 | card->adapter_index, substream->number); |
1178 | 1202 | ||
1179 | err = hpi_handle_error( | 1203 | err = hpi_handle_error( |
1180 | hpi_instream_open(ss, card->adapter_index, | 1204 | hpi_instream_open(card->adapter_index, |
1181 | substream->number, &dpcm->h_stream)); | 1205 | substream->number, &dpcm->h_stream)); |
1182 | if (err) | 1206 | if (err) |
1183 | kfree(dpcm); | 1207 | kfree(dpcm); |
@@ -1229,7 +1253,7 @@ static int snd_card_asihpi_capture_close(struct snd_pcm_substream *substream) | |||
1229 | { | 1253 | { |
1230 | struct snd_card_asihpi_pcm *dpcm = substream->runtime->private_data; | 1254 | struct snd_card_asihpi_pcm *dpcm = substream->runtime->private_data; |
1231 | 1255 | ||
1232 | hpi_handle_error(hpi_instream_close(ss, dpcm->h_stream)); | 1256 | hpi_handle_error(hpi_instream_close(dpcm->h_stream)); |
1233 | return 0; | 1257 | return 0; |
1234 | } | 1258 | } |
1235 | 1259 | ||
@@ -1243,8 +1267,8 @@ static int snd_card_asihpi_capture_copy(struct snd_pcm_substream *substream, | |||
1243 | 1267 | ||
1244 | len = frames_to_bytes(runtime, count); | 1268 | len = frames_to_bytes(runtime, count); |
1245 | 1269 | ||
1246 | VPRINTK2("Capture copy%d %d bytes\n", substream->number, len); | 1270 | VPRINTK2(KERN_INFO "capture copy%d %d bytes\n", substream->number, len); |
1247 | hpi_handle_error(hpi_instream_read_buf(ss, dpcm->h_stream, | 1271 | hpi_handle_error(hpi_instream_read_buf(dpcm->h_stream, |
1248 | runtime->dma_area, len)); | 1272 | runtime->dma_area, len)); |
1249 | 1273 | ||
1250 | dpcm->pcm_buf_host_rw_ofs = dpcm->pcm_buf_host_rw_ofs + len; | 1274 | dpcm->pcm_buf_host_rw_ofs = dpcm->pcm_buf_host_rw_ofs + len; |
@@ -1327,8 +1351,7 @@ struct hpi_control { | |||
1327 | char name[44]; /* copied to snd_ctl_elem_id.name[44]; */ | 1351 | char name[44]; /* copied to snd_ctl_elem_id.name[44]; */ |
1328 | }; | 1352 | }; |
1329 | 1353 | ||
1330 | static const char * const asihpi_tuner_band_names[] = | 1354 | static const char * const asihpi_tuner_band_names[] = { |
1331 | { | ||
1332 | "invalid", | 1355 | "invalid", |
1333 | "AM", | 1356 | "AM", |
1334 | "FM mono", | 1357 | "FM mono", |
@@ -1346,8 +1369,7 @@ compile_time_assert( | |||
1346 | (HPI_TUNER_BAND_LAST+1)), | 1369 | (HPI_TUNER_BAND_LAST+1)), |
1347 | assert_tuner_band_names_size); | 1370 | assert_tuner_band_names_size); |
1348 | 1371 | ||
1349 | static const char * const asihpi_src_names[] = | 1372 | static const char * const asihpi_src_names[] = { |
1350 | { | ||
1351 | "no source", | 1373 | "no source", |
1352 | "PCM", | 1374 | "PCM", |
1353 | "Line", | 1375 | "Line", |
@@ -1367,8 +1389,7 @@ compile_time_assert( | |||
1367 | (HPI_SOURCENODE_LAST_INDEX-HPI_SOURCENODE_NONE+1)), | 1389 | (HPI_SOURCENODE_LAST_INDEX-HPI_SOURCENODE_NONE+1)), |
1368 | assert_src_names_size); | 1390 | assert_src_names_size); |
1369 | 1391 | ||
1370 | static const char * const asihpi_dst_names[] = | 1392 | static const char * const asihpi_dst_names[] = { |
1371 | { | ||
1372 | "no destination", | 1393 | "no destination", |
1373 | "PCM", | 1394 | "PCM", |
1374 | "Line", | 1395 | "Line", |
@@ -1415,7 +1436,8 @@ static void asihpi_ctl_init(struct snd_kcontrol_new *snd_control, | |||
1415 | else if ((hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) && | 1436 | else if ((hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) && |
1416 | (!hpi_ctl->dst_node_type)) | 1437 | (!hpi_ctl->dst_node_type)) |
1417 | dir = "Capture "; /* On a source node that is not PCM playback */ | 1438 | dir = "Capture "; /* On a source node that is not PCM playback */ |
1418 | else if ((hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) && | 1439 | else if (hpi_ctl->src_node_type && |
1440 | (hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) && | ||
1419 | (hpi_ctl->dst_node_type)) | 1441 | (hpi_ctl->dst_node_type)) |
1420 | dir = "Monitor Playback "; /* Between an input and an output */ | 1442 | dir = "Monitor Playback "; /* Between an input and an output */ |
1421 | else | 1443 | else |
@@ -1439,7 +1461,8 @@ static void asihpi_ctl_init(struct snd_kcontrol_new *snd_control, | |||
1439 | hpi_ctl->src_node_index, | 1461 | hpi_ctl->src_node_index, |
1440 | dir, name); | 1462 | dir, name); |
1441 | } | 1463 | } |
1442 | // printk(KERN_INFO "adding %s %d to %d ", hpi_ctl->name, hpi_ctl->src_node_type, hpi_ctl->dst_node_type); | 1464 | /* printk(KERN_INFO "Adding %s %d to %d ", hpi_ctl->name, |
1465 | hpi_ctl->wSrcNodeType, hpi_ctl->wDstNodeType); */ | ||
1443 | } | 1466 | } |
1444 | 1467 | ||
1445 | /*------------------------------------------------------------ | 1468 | /*------------------------------------------------------------ |
@@ -1456,7 +1479,7 @@ static int snd_asihpi_volume_info(struct snd_kcontrol *kcontrol, | |||
1456 | short max_gain_mB; | 1479 | short max_gain_mB; |
1457 | short step_gain_mB; | 1480 | short step_gain_mB; |
1458 | 1481 | ||
1459 | err = hpi_volume_query_range(ss, h_control, | 1482 | err = hpi_volume_query_range(h_control, |
1460 | &min_gain_mB, &max_gain_mB, &step_gain_mB); | 1483 | &min_gain_mB, &max_gain_mB, &step_gain_mB); |
1461 | if (err) { | 1484 | if (err) { |
1462 | max_gain_mB = 0; | 1485 | max_gain_mB = 0; |
@@ -1478,7 +1501,7 @@ static int snd_asihpi_volume_get(struct snd_kcontrol *kcontrol, | |||
1478 | u32 h_control = kcontrol->private_value; | 1501 | u32 h_control = kcontrol->private_value; |
1479 | short an_gain_mB[HPI_MAX_CHANNELS]; | 1502 | short an_gain_mB[HPI_MAX_CHANNELS]; |
1480 | 1503 | ||
1481 | hpi_handle_error(hpi_volume_get_gain(ss, h_control, an_gain_mB)); | 1504 | hpi_handle_error(hpi_volume_get_gain(h_control, an_gain_mB)); |
1482 | ucontrol->value.integer.value[0] = an_gain_mB[0] / VOL_STEP_mB; | 1505 | ucontrol->value.integer.value[0] = an_gain_mB[0] / VOL_STEP_mB; |
1483 | ucontrol->value.integer.value[1] = an_gain_mB[1] / VOL_STEP_mB; | 1506 | ucontrol->value.integer.value[1] = an_gain_mB[1] / VOL_STEP_mB; |
1484 | 1507 | ||
@@ -1500,7 +1523,7 @@ static int snd_asihpi_volume_put(struct snd_kcontrol *kcontrol, | |||
1500 | asihpi->mixer_volume[addr][1] != right; | 1523 | asihpi->mixer_volume[addr][1] != right; |
1501 | */ | 1524 | */ |
1502 | change = 1; | 1525 | change = 1; |
1503 | hpi_handle_error(hpi_volume_set_gain(ss, h_control, an_gain_mB)); | 1526 | hpi_handle_error(hpi_volume_set_gain(h_control, an_gain_mB)); |
1504 | return change; | 1527 | return change; |
1505 | } | 1528 | } |
1506 | 1529 | ||
@@ -1536,7 +1559,7 @@ static int snd_asihpi_level_info(struct snd_kcontrol *kcontrol, | |||
1536 | short step_gain_mB; | 1559 | short step_gain_mB; |
1537 | 1560 | ||
1538 | err = | 1561 | err = |
1539 | hpi_level_query_range(ss, h_control, &min_gain_mB, | 1562 | hpi_level_query_range(h_control, &min_gain_mB, |
1540 | &max_gain_mB, &step_gain_mB); | 1563 | &max_gain_mB, &step_gain_mB); |
1541 | if (err) { | 1564 | if (err) { |
1542 | max_gain_mB = 2400; | 1565 | max_gain_mB = 2400; |
@@ -1558,7 +1581,7 @@ static int snd_asihpi_level_get(struct snd_kcontrol *kcontrol, | |||
1558 | u32 h_control = kcontrol->private_value; | 1581 | u32 h_control = kcontrol->private_value; |
1559 | short an_gain_mB[HPI_MAX_CHANNELS]; | 1582 | short an_gain_mB[HPI_MAX_CHANNELS]; |
1560 | 1583 | ||
1561 | hpi_handle_error(hpi_level_get_gain(ss, h_control, an_gain_mB)); | 1584 | hpi_handle_error(hpi_level_get_gain(h_control, an_gain_mB)); |
1562 | ucontrol->value.integer.value[0] = | 1585 | ucontrol->value.integer.value[0] = |
1563 | an_gain_mB[0] / HPI_UNITS_PER_dB; | 1586 | an_gain_mB[0] / HPI_UNITS_PER_dB; |
1564 | ucontrol->value.integer.value[1] = | 1587 | ucontrol->value.integer.value[1] = |
@@ -1582,7 +1605,7 @@ static int snd_asihpi_level_put(struct snd_kcontrol *kcontrol, | |||
1582 | asihpi->mixer_level[addr][1] != right; | 1605 | asihpi->mixer_level[addr][1] != right; |
1583 | */ | 1606 | */ |
1584 | change = 1; | 1607 | change = 1; |
1585 | hpi_handle_error(hpi_level_set_gain(ss, h_control, an_gain_mB)); | 1608 | hpi_handle_error(hpi_level_set_gain(h_control, an_gain_mB)); |
1586 | return change; | 1609 | return change; |
1587 | } | 1610 | } |
1588 | 1611 | ||
@@ -1611,12 +1634,8 @@ static int __devinit snd_asihpi_level_add(struct snd_card_asihpi *asihpi, | |||
1611 | ------------------------------------------------------------*/ | 1634 | ------------------------------------------------------------*/ |
1612 | 1635 | ||
1613 | /* AESEBU format */ | 1636 | /* AESEBU format */ |
1614 | static const char * const asihpi_aesebu_format_names[] = | 1637 | static const char * const asihpi_aesebu_format_names[] = { |
1615 | { | 1638 | "N/A", "S/PDIF", "AES/EBU" }; |
1616 | "N/A", | ||
1617 | "S/PDIF", | ||
1618 | "AES/EBU", | ||
1619 | }; | ||
1620 | 1639 | ||
1621 | static int snd_asihpi_aesebu_format_info(struct snd_kcontrol *kcontrol, | 1640 | static int snd_asihpi_aesebu_format_info(struct snd_kcontrol *kcontrol, |
1622 | struct snd_ctl_elem_info *uinfo) | 1641 | struct snd_ctl_elem_info *uinfo) |
@@ -1637,12 +1656,12 @@ static int snd_asihpi_aesebu_format_info(struct snd_kcontrol *kcontrol, | |||
1637 | 1656 | ||
1638 | static int snd_asihpi_aesebu_format_get(struct snd_kcontrol *kcontrol, | 1657 | static int snd_asihpi_aesebu_format_get(struct snd_kcontrol *kcontrol, |
1639 | struct snd_ctl_elem_value *ucontrol, | 1658 | struct snd_ctl_elem_value *ucontrol, |
1640 | u16 (*func)(const struct hpi_hsubsys *, u32, u16 *)) | 1659 | u16 (*func)(u32, u16 *)) |
1641 | { | 1660 | { |
1642 | u32 h_control = kcontrol->private_value; | 1661 | u32 h_control = kcontrol->private_value; |
1643 | u16 source, err; | 1662 | u16 source, err; |
1644 | 1663 | ||
1645 | err = func(ss, h_control, &source); | 1664 | err = func(h_control, &source); |
1646 | 1665 | ||
1647 | /* default to N/A */ | 1666 | /* default to N/A */ |
1648 | ucontrol->value.enumerated.item[0] = 0; | 1667 | ucontrol->value.enumerated.item[0] = 0; |
@@ -1659,7 +1678,7 @@ static int snd_asihpi_aesebu_format_get(struct snd_kcontrol *kcontrol, | |||
1659 | 1678 | ||
1660 | static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol, | 1679 | static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol, |
1661 | struct snd_ctl_elem_value *ucontrol, | 1680 | struct snd_ctl_elem_value *ucontrol, |
1662 | u16 (*func)(const struct hpi_hsubsys *, u32, u16)) | 1681 | u16 (*func)(u32, u16)) |
1663 | { | 1682 | { |
1664 | u32 h_control = kcontrol->private_value; | 1683 | u32 h_control = kcontrol->private_value; |
1665 | 1684 | ||
@@ -1671,7 +1690,7 @@ static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol, | |||
1671 | if (ucontrol->value.enumerated.item[0] == 2) | 1690 | if (ucontrol->value.enumerated.item[0] == 2) |
1672 | source = HPI_AESEBU_FORMAT_AESEBU; | 1691 | source = HPI_AESEBU_FORMAT_AESEBU; |
1673 | 1692 | ||
1674 | if (func(ss, h_control, source) != 0) | 1693 | if (func(h_control, source) != 0) |
1675 | return -EINVAL; | 1694 | return -EINVAL; |
1676 | 1695 | ||
1677 | return 1; | 1696 | return 1; |
@@ -1680,13 +1699,13 @@ static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol, | |||
1680 | static int snd_asihpi_aesebu_rx_format_get(struct snd_kcontrol *kcontrol, | 1699 | static int snd_asihpi_aesebu_rx_format_get(struct snd_kcontrol *kcontrol, |
1681 | struct snd_ctl_elem_value *ucontrol) { | 1700 | struct snd_ctl_elem_value *ucontrol) { |
1682 | return snd_asihpi_aesebu_format_get(kcontrol, ucontrol, | 1701 | return snd_asihpi_aesebu_format_get(kcontrol, ucontrol, |
1683 | HPI_AESEBU__receiver_get_format); | 1702 | hpi_aesebu_receiver_get_format); |
1684 | } | 1703 | } |
1685 | 1704 | ||
1686 | static int snd_asihpi_aesebu_rx_format_put(struct snd_kcontrol *kcontrol, | 1705 | static int snd_asihpi_aesebu_rx_format_put(struct snd_kcontrol *kcontrol, |
1687 | struct snd_ctl_elem_value *ucontrol) { | 1706 | struct snd_ctl_elem_value *ucontrol) { |
1688 | return snd_asihpi_aesebu_format_put(kcontrol, ucontrol, | 1707 | return snd_asihpi_aesebu_format_put(kcontrol, ucontrol, |
1689 | HPI_AESEBU__receiver_set_format); | 1708 | hpi_aesebu_receiver_set_format); |
1690 | } | 1709 | } |
1691 | 1710 | ||
1692 | static int snd_asihpi_aesebu_rxstatus_info(struct snd_kcontrol *kcontrol, | 1711 | static int snd_asihpi_aesebu_rxstatus_info(struct snd_kcontrol *kcontrol, |
@@ -1708,8 +1727,8 @@ static int snd_asihpi_aesebu_rxstatus_get(struct snd_kcontrol *kcontrol, | |||
1708 | u32 h_control = kcontrol->private_value; | 1727 | u32 h_control = kcontrol->private_value; |
1709 | u16 status; | 1728 | u16 status; |
1710 | 1729 | ||
1711 | hpi_handle_error(HPI_AESEBU__receiver_get_error_status( | 1730 | hpi_handle_error(hpi_aesebu_receiver_get_error_status( |
1712 | ss, h_control, &status)); | 1731 | h_control, &status)); |
1713 | ucontrol->value.integer.value[0] = status; | 1732 | ucontrol->value.integer.value[0] = status; |
1714 | return 0; | 1733 | return 0; |
1715 | } | 1734 | } |
@@ -1742,13 +1761,13 @@ static int __devinit snd_asihpi_aesebu_rx_add(struct snd_card_asihpi *asihpi, | |||
1742 | static int snd_asihpi_aesebu_tx_format_get(struct snd_kcontrol *kcontrol, | 1761 | static int snd_asihpi_aesebu_tx_format_get(struct snd_kcontrol *kcontrol, |
1743 | struct snd_ctl_elem_value *ucontrol) { | 1762 | struct snd_ctl_elem_value *ucontrol) { |
1744 | return snd_asihpi_aesebu_format_get(kcontrol, ucontrol, | 1763 | return snd_asihpi_aesebu_format_get(kcontrol, ucontrol, |
1745 | HPI_AESEBU__transmitter_get_format); | 1764 | hpi_aesebu_transmitter_get_format); |
1746 | } | 1765 | } |
1747 | 1766 | ||
1748 | static int snd_asihpi_aesebu_tx_format_put(struct snd_kcontrol *kcontrol, | 1767 | static int snd_asihpi_aesebu_tx_format_put(struct snd_kcontrol *kcontrol, |
1749 | struct snd_ctl_elem_value *ucontrol) { | 1768 | struct snd_ctl_elem_value *ucontrol) { |
1750 | return snd_asihpi_aesebu_format_put(kcontrol, ucontrol, | 1769 | return snd_asihpi_aesebu_format_put(kcontrol, ucontrol, |
1751 | HPI_AESEBU__transmitter_set_format); | 1770 | hpi_aesebu_transmitter_set_format); |
1752 | } | 1771 | } |
1753 | 1772 | ||
1754 | 1773 | ||
@@ -1782,7 +1801,7 @@ static int snd_asihpi_tuner_gain_info(struct snd_kcontrol *kcontrol, | |||
1782 | u16 gain_range[3]; | 1801 | u16 gain_range[3]; |
1783 | 1802 | ||
1784 | for (idx = 0; idx < 3; idx++) { | 1803 | for (idx = 0; idx < 3; idx++) { |
1785 | err = hpi_tuner_query_gain(ss, h_control, | 1804 | err = hpi_tuner_query_gain(h_control, |
1786 | idx, &gain_range[idx]); | 1805 | idx, &gain_range[idx]); |
1787 | if (err != 0) | 1806 | if (err != 0) |
1788 | return err; | 1807 | return err; |
@@ -1805,7 +1824,7 @@ static int snd_asihpi_tuner_gain_get(struct snd_kcontrol *kcontrol, | |||
1805 | u32 h_control = kcontrol->private_value; | 1824 | u32 h_control = kcontrol->private_value; |
1806 | short gain; | 1825 | short gain; |
1807 | 1826 | ||
1808 | hpi_handle_error(hpi_tuner_get_gain(ss, h_control, &gain)); | 1827 | hpi_handle_error(hpi_tuner_get_gain(h_control, &gain)); |
1809 | ucontrol->value.integer.value[0] = gain / HPI_UNITS_PER_dB; | 1828 | ucontrol->value.integer.value[0] = gain / HPI_UNITS_PER_dB; |
1810 | 1829 | ||
1811 | return 0; | 1830 | return 0; |
@@ -1821,7 +1840,7 @@ static int snd_asihpi_tuner_gain_put(struct snd_kcontrol *kcontrol, | |||
1821 | short gain; | 1840 | short gain; |
1822 | 1841 | ||
1823 | gain = (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB; | 1842 | gain = (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB; |
1824 | hpi_handle_error(hpi_tuner_set_gain(ss, h_control, gain)); | 1843 | hpi_handle_error(hpi_tuner_set_gain(h_control, gain)); |
1825 | 1844 | ||
1826 | return 1; | 1845 | return 1; |
1827 | } | 1846 | } |
@@ -1835,7 +1854,7 @@ static int asihpi_tuner_band_query(struct snd_kcontrol *kcontrol, | |||
1835 | u32 i; | 1854 | u32 i; |
1836 | 1855 | ||
1837 | for (i = 0; i < len; i++) { | 1856 | for (i = 0; i < len; i++) { |
1838 | err = hpi_tuner_query_band(ss, | 1857 | err = hpi_tuner_query_band( |
1839 | h_control, i, &band_list[i]); | 1858 | h_control, i, &band_list[i]); |
1840 | if (err != 0) | 1859 | if (err != 0) |
1841 | break; | 1860 | break; |
@@ -1891,7 +1910,7 @@ static int snd_asihpi_tuner_band_get(struct snd_kcontrol *kcontrol, | |||
1891 | num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands, | 1910 | num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands, |
1892 | HPI_TUNER_BAND_LAST); | 1911 | HPI_TUNER_BAND_LAST); |
1893 | 1912 | ||
1894 | hpi_handle_error(hpi_tuner_get_band(ss, h_control, &band)); | 1913 | hpi_handle_error(hpi_tuner_get_band(h_control, &band)); |
1895 | 1914 | ||
1896 | ucontrol->value.enumerated.item[0] = -1; | 1915 | ucontrol->value.enumerated.item[0] = -1; |
1897 | for (idx = 0; idx < HPI_TUNER_BAND_LAST; idx++) | 1916 | for (idx = 0; idx < HPI_TUNER_BAND_LAST; idx++) |
@@ -1918,7 +1937,7 @@ static int snd_asihpi_tuner_band_put(struct snd_kcontrol *kcontrol, | |||
1918 | HPI_TUNER_BAND_LAST); | 1937 | HPI_TUNER_BAND_LAST); |
1919 | 1938 | ||
1920 | band = tuner_bands[ucontrol->value.enumerated.item[0]]; | 1939 | band = tuner_bands[ucontrol->value.enumerated.item[0]]; |
1921 | hpi_handle_error(hpi_tuner_set_band(ss, h_control, band)); | 1940 | hpi_handle_error(hpi_tuner_set_band(h_control, band)); |
1922 | 1941 | ||
1923 | return 1; | 1942 | return 1; |
1924 | } | 1943 | } |
@@ -1943,7 +1962,7 @@ static int snd_asihpi_tuner_freq_info(struct snd_kcontrol *kcontrol, | |||
1943 | 1962 | ||
1944 | for (band_iter = 0; band_iter < num_bands; band_iter++) { | 1963 | for (band_iter = 0; band_iter < num_bands; band_iter++) { |
1945 | for (idx = 0; idx < 3; idx++) { | 1964 | for (idx = 0; idx < 3; idx++) { |
1946 | err = hpi_tuner_query_frequency(ss, h_control, | 1965 | err = hpi_tuner_query_frequency(h_control, |
1947 | idx, tuner_bands[band_iter], | 1966 | idx, tuner_bands[band_iter], |
1948 | &temp_freq_range[idx]); | 1967 | &temp_freq_range[idx]); |
1949 | if (err != 0) | 1968 | if (err != 0) |
@@ -1976,7 +1995,7 @@ static int snd_asihpi_tuner_freq_get(struct snd_kcontrol *kcontrol, | |||
1976 | u32 h_control = kcontrol->private_value; | 1995 | u32 h_control = kcontrol->private_value; |
1977 | u32 freq; | 1996 | u32 freq; |
1978 | 1997 | ||
1979 | hpi_handle_error(hpi_tuner_get_frequency(ss, h_control, &freq)); | 1998 | hpi_handle_error(hpi_tuner_get_frequency(h_control, &freq)); |
1980 | ucontrol->value.integer.value[0] = freq; | 1999 | ucontrol->value.integer.value[0] = freq; |
1981 | 2000 | ||
1982 | return 0; | 2001 | return 0; |
@@ -1989,7 +2008,7 @@ static int snd_asihpi_tuner_freq_put(struct snd_kcontrol *kcontrol, | |||
1989 | u32 freq; | 2008 | u32 freq; |
1990 | 2009 | ||
1991 | freq = ucontrol->value.integer.value[0]; | 2010 | freq = ucontrol->value.integer.value[0]; |
1992 | hpi_handle_error(hpi_tuner_set_frequency(ss, h_control, freq)); | 2011 | hpi_handle_error(hpi_tuner_set_frequency(h_control, freq)); |
1993 | 2012 | ||
1994 | return 1; | 2013 | return 1; |
1995 | } | 2014 | } |
@@ -2004,7 +2023,7 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi, | |||
2004 | snd_control.private_value = hpi_ctl->h_control; | 2023 | snd_control.private_value = hpi_ctl->h_control; |
2005 | snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; | 2024 | snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; |
2006 | 2025 | ||
2007 | if (!hpi_tuner_get_gain(ss, hpi_ctl->h_control, NULL)) { | 2026 | if (!hpi_tuner_get_gain(hpi_ctl->h_control, NULL)) { |
2008 | asihpi_ctl_init(&snd_control, hpi_ctl, "Gain"); | 2027 | asihpi_ctl_init(&snd_control, hpi_ctl, "Gain"); |
2009 | snd_control.info = snd_asihpi_tuner_gain_info; | 2028 | snd_control.info = snd_asihpi_tuner_gain_info; |
2010 | snd_control.get = snd_asihpi_tuner_gain_get; | 2029 | snd_control.get = snd_asihpi_tuner_gain_get; |
@@ -2073,7 +2092,7 @@ static int snd_asihpi_meter_get(struct snd_kcontrol *kcontrol, | |||
2073 | short an_gain_mB[HPI_MAX_CHANNELS], i; | 2092 | short an_gain_mB[HPI_MAX_CHANNELS], i; |
2074 | u16 err; | 2093 | u16 err; |
2075 | 2094 | ||
2076 | err = hpi_meter_get_peak(ss, h_control, an_gain_mB); | 2095 | err = hpi_meter_get_peak(h_control, an_gain_mB); |
2077 | 2096 | ||
2078 | for (i = 0; i < HPI_MAX_CHANNELS; i++) { | 2097 | for (i = 0; i < HPI_MAX_CHANNELS; i++) { |
2079 | if (err) { | 2098 | if (err) { |
@@ -2118,7 +2137,7 @@ static int snd_card_asihpi_mux_count_sources(struct snd_kcontrol *snd_control) | |||
2118 | struct hpi_control hpi_ctl; | 2137 | struct hpi_control hpi_ctl; |
2119 | int s, err; | 2138 | int s, err; |
2120 | for (s = 0; s < 32; s++) { | 2139 | for (s = 0; s < 32; s++) { |
2121 | err = hpi_multiplexer_query_source(ss, h_control, s, | 2140 | err = hpi_multiplexer_query_source(h_control, s, |
2122 | &hpi_ctl. | 2141 | &hpi_ctl. |
2123 | src_node_type, | 2142 | src_node_type, |
2124 | &hpi_ctl. | 2143 | &hpi_ctl. |
@@ -2146,7 +2165,7 @@ static int snd_asihpi_mux_info(struct snd_kcontrol *kcontrol, | |||
2146 | uinfo->value.enumerated.items - 1; | 2165 | uinfo->value.enumerated.items - 1; |
2147 | 2166 | ||
2148 | err = | 2167 | err = |
2149 | hpi_multiplexer_query_source(ss, h_control, | 2168 | hpi_multiplexer_query_source(h_control, |
2150 | uinfo->value.enumerated.item, | 2169 | uinfo->value.enumerated.item, |
2151 | &src_node_type, &src_node_index); | 2170 | &src_node_type, &src_node_index); |
2152 | 2171 | ||
@@ -2164,11 +2183,11 @@ static int snd_asihpi_mux_get(struct snd_kcontrol *kcontrol, | |||
2164 | u16 src_node_type, src_node_index; | 2183 | u16 src_node_type, src_node_index; |
2165 | int s; | 2184 | int s; |
2166 | 2185 | ||
2167 | hpi_handle_error(hpi_multiplexer_get_source(ss, h_control, | 2186 | hpi_handle_error(hpi_multiplexer_get_source(h_control, |
2168 | &source_type, &source_index)); | 2187 | &source_type, &source_index)); |
2169 | /* Should cache this search result! */ | 2188 | /* Should cache this search result! */ |
2170 | for (s = 0; s < 256; s++) { | 2189 | for (s = 0; s < 256; s++) { |
2171 | if (hpi_multiplexer_query_source(ss, h_control, s, | 2190 | if (hpi_multiplexer_query_source(h_control, s, |
2172 | &src_node_type, &src_node_index)) | 2191 | &src_node_type, &src_node_index)) |
2173 | break; | 2192 | break; |
2174 | 2193 | ||
@@ -2195,12 +2214,12 @@ static int snd_asihpi_mux_put(struct snd_kcontrol *kcontrol, | |||
2195 | 2214 | ||
2196 | change = 1; | 2215 | change = 1; |
2197 | 2216 | ||
2198 | e = hpi_multiplexer_query_source(ss, h_control, | 2217 | e = hpi_multiplexer_query_source(h_control, |
2199 | ucontrol->value.enumerated.item[0], | 2218 | ucontrol->value.enumerated.item[0], |
2200 | &source_type, &source_index); | 2219 | &source_type, &source_index); |
2201 | if (!e) | 2220 | if (!e) |
2202 | hpi_handle_error( | 2221 | hpi_handle_error( |
2203 | hpi_multiplexer_set_source(ss, h_control, | 2222 | hpi_multiplexer_set_source(h_control, |
2204 | source_type, source_index)); | 2223 | source_type, source_index)); |
2205 | return change; | 2224 | return change; |
2206 | } | 2225 | } |
@@ -2246,7 +2265,7 @@ static int snd_asihpi_cmode_info(struct snd_kcontrol *kcontrol, | |||
2246 | */ | 2265 | */ |
2247 | for (i = 0; i < HPI_CHANNEL_MODE_LAST; i++) | 2266 | for (i = 0; i < HPI_CHANNEL_MODE_LAST; i++) |
2248 | if (!hpi_channel_mode_query_mode( | 2267 | if (!hpi_channel_mode_query_mode( |
2249 | ss, h_control, i, &mode)) { | 2268 | h_control, i, &mode)) { |
2250 | mode_map[valid_modes] = mode; | 2269 | mode_map[valid_modes] = mode; |
2251 | valid_modes++; | 2270 | valid_modes++; |
2252 | } | 2271 | } |
@@ -2270,7 +2289,7 @@ static int snd_asihpi_cmode_get(struct snd_kcontrol *kcontrol, | |||
2270 | u32 h_control = kcontrol->private_value; | 2289 | u32 h_control = kcontrol->private_value; |
2271 | u16 mode; | 2290 | u16 mode; |
2272 | 2291 | ||
2273 | if (hpi_channel_mode_get(ss, h_control, &mode)) | 2292 | if (hpi_channel_mode_get(h_control, &mode)) |
2274 | mode = 1; | 2293 | mode = 1; |
2275 | 2294 | ||
2276 | ucontrol->value.enumerated.item[0] = mode - 1; | 2295 | ucontrol->value.enumerated.item[0] = mode - 1; |
@@ -2286,7 +2305,7 @@ static int snd_asihpi_cmode_put(struct snd_kcontrol *kcontrol, | |||
2286 | 2305 | ||
2287 | change = 1; | 2306 | change = 1; |
2288 | 2307 | ||
2289 | hpi_handle_error(hpi_channel_mode_set(ss, h_control, | 2308 | hpi_handle_error(hpi_channel_mode_set(h_control, |
2290 | ucontrol->value.enumerated.item[0] + 1)); | 2309 | ucontrol->value.enumerated.item[0] + 1)); |
2291 | return change; | 2310 | return change; |
2292 | } | 2311 | } |
@@ -2310,12 +2329,12 @@ static int __devinit snd_asihpi_cmode_add(struct snd_card_asihpi *asihpi, | |||
2310 | /*------------------------------------------------------------ | 2329 | /*------------------------------------------------------------ |
2311 | Sampleclock source controls | 2330 | Sampleclock source controls |
2312 | ------------------------------------------------------------*/ | 2331 | ------------------------------------------------------------*/ |
2313 | static char *sampleclock_sources[MAX_CLOCKSOURCES] = | 2332 | static char *sampleclock_sources[MAX_CLOCKSOURCES] = { |
2314 | { "N/A", "Local PLL", "Digital Sync", "Word External", "Word Header", | 2333 | "N/A", "Local PLL", "Digital Sync", "Word External", "Word Header", |
2315 | "SMPTE", "Digital1", "Auto", "Network", "Invalid", | 2334 | "SMPTE", "Digital1", "Auto", "Network", "Invalid", |
2316 | "Prev Module", | 2335 | "Prev Module", |
2317 | "Digital2", "Digital3", "Digital4", "Digital5", | 2336 | "Digital2", "Digital3", "Digital4", "Digital5", |
2318 | "Digital6", "Digital7", "Digital8"}; | 2337 | "Digital6", "Digital7", "Digital8"}; |
2319 | 2338 | ||
2320 | static int snd_asihpi_clksrc_info(struct snd_kcontrol *kcontrol, | 2339 | static int snd_asihpi_clksrc_info(struct snd_kcontrol *kcontrol, |
2321 | struct snd_ctl_elem_info *uinfo) | 2340 | struct snd_ctl_elem_info *uinfo) |
@@ -2347,11 +2366,11 @@ static int snd_asihpi_clksrc_get(struct snd_kcontrol *kcontrol, | |||
2347 | int i; | 2366 | int i; |
2348 | 2367 | ||
2349 | ucontrol->value.enumerated.item[0] = 0; | 2368 | ucontrol->value.enumerated.item[0] = 0; |
2350 | if (hpi_sample_clock_get_source(ss, h_control, &source)) | 2369 | if (hpi_sample_clock_get_source(h_control, &source)) |
2351 | source = 0; | 2370 | source = 0; |
2352 | 2371 | ||
2353 | if (source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) | 2372 | if (source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) |
2354 | if (hpi_sample_clock_get_source_index(ss, h_control, &srcindex)) | 2373 | if (hpi_sample_clock_get_source_index(h_control, &srcindex)) |
2355 | srcindex = 0; | 2374 | srcindex = 0; |
2356 | 2375 | ||
2357 | for (i = 0; i < clkcache->count; i++) | 2376 | for (i = 0; i < clkcache->count; i++) |
@@ -2378,11 +2397,11 @@ static int snd_asihpi_clksrc_put(struct snd_kcontrol *kcontrol, | |||
2378 | if (item >= clkcache->count) | 2397 | if (item >= clkcache->count) |
2379 | item = clkcache->count-1; | 2398 | item = clkcache->count-1; |
2380 | 2399 | ||
2381 | hpi_handle_error(hpi_sample_clock_set_source(ss, | 2400 | hpi_handle_error(hpi_sample_clock_set_source( |
2382 | h_control, clkcache->s[item].source)); | 2401 | h_control, clkcache->s[item].source)); |
2383 | 2402 | ||
2384 | if (clkcache->s[item].source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) | 2403 | if (clkcache->s[item].source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) |
2385 | hpi_handle_error(hpi_sample_clock_set_source_index(ss, | 2404 | hpi_handle_error(hpi_sample_clock_set_source_index( |
2386 | h_control, clkcache->s[item].index)); | 2405 | h_control, clkcache->s[item].index)); |
2387 | return change; | 2406 | return change; |
2388 | } | 2407 | } |
@@ -2410,7 +2429,7 @@ static int snd_asihpi_clklocal_get(struct snd_kcontrol *kcontrol, | |||
2410 | u32 rate; | 2429 | u32 rate; |
2411 | u16 e; | 2430 | u16 e; |
2412 | 2431 | ||
2413 | e = hpi_sample_clock_get_local_rate(ss, h_control, &rate); | 2432 | e = hpi_sample_clock_get_local_rate(h_control, &rate); |
2414 | if (!e) | 2433 | if (!e) |
2415 | ucontrol->value.integer.value[0] = rate; | 2434 | ucontrol->value.integer.value[0] = rate; |
2416 | else | 2435 | else |
@@ -2428,7 +2447,7 @@ static int snd_asihpi_clklocal_put(struct snd_kcontrol *kcontrol, | |||
2428 | asihpi->mixer_clkrate[addr][1] != right; | 2447 | asihpi->mixer_clkrate[addr][1] != right; |
2429 | */ | 2448 | */ |
2430 | change = 1; | 2449 | change = 1; |
2431 | hpi_handle_error(hpi_sample_clock_set_local_rate(ss, h_control, | 2450 | hpi_handle_error(hpi_sample_clock_set_local_rate(h_control, |
2432 | ucontrol->value.integer.value[0])); | 2451 | ucontrol->value.integer.value[0])); |
2433 | return change; | 2452 | return change; |
2434 | } | 2453 | } |
@@ -2452,7 +2471,7 @@ static int snd_asihpi_clkrate_get(struct snd_kcontrol *kcontrol, | |||
2452 | u32 rate; | 2471 | u32 rate; |
2453 | u16 e; | 2472 | u16 e; |
2454 | 2473 | ||
2455 | e = hpi_sample_clock_get_sample_rate(ss, h_control, &rate); | 2474 | e = hpi_sample_clock_get_sample_rate(h_control, &rate); |
2456 | if (!e) | 2475 | if (!e) |
2457 | ucontrol->value.integer.value[0] = rate; | 2476 | ucontrol->value.integer.value[0] = rate; |
2458 | else | 2477 | else |
@@ -2477,7 +2496,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, | |||
2477 | clkcache->has_local = 0; | 2496 | clkcache->has_local = 0; |
2478 | 2497 | ||
2479 | for (i = 0; i <= HPI_SAMPLECLOCK_SOURCE_LAST; i++) { | 2498 | for (i = 0; i <= HPI_SAMPLECLOCK_SOURCE_LAST; i++) { |
2480 | if (hpi_sample_clock_query_source(ss, hSC, | 2499 | if (hpi_sample_clock_query_source(hSC, |
2481 | i, &source)) | 2500 | i, &source)) |
2482 | break; | 2501 | break; |
2483 | clkcache->s[i].source = source; | 2502 | clkcache->s[i].source = source; |
@@ -2491,7 +2510,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, | |||
2491 | if (has_aes_in) | 2510 | if (has_aes_in) |
2492 | /* already will have picked up index 0 above */ | 2511 | /* already will have picked up index 0 above */ |
2493 | for (j = 1; j < 8; j++) { | 2512 | for (j = 1; j < 8; j++) { |
2494 | if (hpi_sample_clock_query_source_index(ss, hSC, | 2513 | if (hpi_sample_clock_query_source_index(hSC, |
2495 | j, HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT, | 2514 | j, HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT, |
2496 | &source)) | 2515 | &source)) |
2497 | break; | 2516 | break; |
@@ -2550,7 +2569,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) | |||
2550 | strcpy(card->mixername, "Asihpi Mixer"); | 2569 | strcpy(card->mixername, "Asihpi Mixer"); |
2551 | 2570 | ||
2552 | err = | 2571 | err = |
2553 | hpi_mixer_open(ss, asihpi->adapter_index, | 2572 | hpi_mixer_open(asihpi->adapter_index, |
2554 | &asihpi->h_mixer); | 2573 | &asihpi->h_mixer); |
2555 | hpi_handle_error(err); | 2574 | hpi_handle_error(err); |
2556 | if (err) | 2575 | if (err) |
@@ -2561,7 +2580,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) | |||
2561 | 2580 | ||
2562 | for (idx = 0; idx < 2000; idx++) { | 2581 | for (idx = 0; idx < 2000; idx++) { |
2563 | err = hpi_mixer_get_control_by_index( | 2582 | err = hpi_mixer_get_control_by_index( |
2564 | ss, asihpi->h_mixer, | 2583 | asihpi->h_mixer, |
2565 | idx, | 2584 | idx, |
2566 | &hpi_ctl.src_node_type, | 2585 | &hpi_ctl.src_node_type, |
2567 | &hpi_ctl.src_node_index, | 2586 | &hpi_ctl.src_node_index, |
@@ -2688,14 +2707,14 @@ snd_asihpi_proc_read(struct snd_info_entry *entry, | |||
2688 | version & 0x7, | 2707 | version & 0x7, |
2689 | ((version >> 13) * 100) + ((version >> 7) & 0x3f)); | 2708 | ((version >> 13) * 100) + ((version >> 7) & 0x3f)); |
2690 | 2709 | ||
2691 | err = hpi_mixer_get_control(ss, asihpi->h_mixer, | 2710 | err = hpi_mixer_get_control(asihpi->h_mixer, |
2692 | HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, | 2711 | HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, |
2693 | HPI_CONTROL_SAMPLECLOCK, &h_control); | 2712 | HPI_CONTROL_SAMPLECLOCK, &h_control); |
2694 | 2713 | ||
2695 | if (!err) { | 2714 | if (!err) { |
2696 | err = hpi_sample_clock_get_sample_rate(ss, | 2715 | err = hpi_sample_clock_get_sample_rate( |
2697 | h_control, &rate); | 2716 | h_control, &rate); |
2698 | err += hpi_sample_clock_get_source(ss, h_control, &source); | 2717 | err += hpi_sample_clock_get_source(h_control, &source); |
2699 | 2718 | ||
2700 | if (!err) | 2719 | if (!err) |
2701 | snd_iprintf(buffer, "sample_clock=%d_hz, source %s\n", | 2720 | snd_iprintf(buffer, "sample_clock=%d_hz, source %s\n", |
@@ -2825,7 +2844,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, | |||
2825 | asihpi->card = card; | 2844 | asihpi->card = card; |
2826 | asihpi->pci = hpi_card->pci; | 2845 | asihpi->pci = hpi_card->pci; |
2827 | asihpi->adapter_index = hpi_card->index; | 2846 | asihpi->adapter_index = hpi_card->index; |
2828 | hpi_handle_error(hpi_adapter_get_info(ss, | 2847 | hpi_handle_error(hpi_adapter_get_info( |
2829 | asihpi->adapter_index, | 2848 | asihpi->adapter_index, |
2830 | &asihpi->num_outstreams, | 2849 | &asihpi->num_outstreams, |
2831 | &asihpi->num_instreams, | 2850 | &asihpi->num_instreams, |
@@ -2847,33 +2866,33 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, | |||
2847 | if (pcm_substreams < asihpi->num_instreams) | 2866 | if (pcm_substreams < asihpi->num_instreams) |
2848 | pcm_substreams = asihpi->num_instreams; | 2867 | pcm_substreams = asihpi->num_instreams; |
2849 | 2868 | ||
2850 | err = hpi_adapter_get_property(ss, asihpi->adapter_index, | 2869 | err = hpi_adapter_get_property(asihpi->adapter_index, |
2851 | HPI_ADAPTER_PROPERTY_CAPS1, | 2870 | HPI_ADAPTER_PROPERTY_CAPS1, |
2852 | NULL, &asihpi->support_grouping); | 2871 | NULL, &asihpi->support_grouping); |
2853 | if (err) | 2872 | if (err) |
2854 | asihpi->support_grouping = 0; | 2873 | asihpi->support_grouping = 0; |
2855 | 2874 | ||
2856 | err = hpi_adapter_get_property(ss, asihpi->adapter_index, | 2875 | err = hpi_adapter_get_property(asihpi->adapter_index, |
2857 | HPI_ADAPTER_PROPERTY_CAPS2, | 2876 | HPI_ADAPTER_PROPERTY_CAPS2, |
2858 | &asihpi->support_mrx, NULL); | 2877 | &asihpi->support_mrx, NULL); |
2859 | if (err) | 2878 | if (err) |
2860 | asihpi->support_mrx = 0; | 2879 | asihpi->support_mrx = 0; |
2861 | 2880 | ||
2862 | err = hpi_adapter_get_property(ss, asihpi->adapter_index, | 2881 | err = hpi_adapter_get_property(asihpi->adapter_index, |
2863 | HPI_ADAPTER_PROPERTY_INTERVAL, | 2882 | HPI_ADAPTER_PROPERTY_INTERVAL, |
2864 | NULL, &asihpi->update_interval_frames); | 2883 | NULL, &asihpi->update_interval_frames); |
2865 | if (err) | 2884 | if (err) |
2866 | asihpi->update_interval_frames = 512; | 2885 | asihpi->update_interval_frames = 512; |
2867 | 2886 | ||
2868 | hpi_handle_error(hpi_instream_open(ss, asihpi->adapter_index, | 2887 | hpi_handle_error(hpi_instream_open(asihpi->adapter_index, |
2869 | 0, &h_stream)); | 2888 | 0, &h_stream)); |
2870 | 2889 | ||
2871 | err = hpi_instream_host_buffer_free(ss, h_stream); | 2890 | err = hpi_instream_host_buffer_free(h_stream); |
2872 | asihpi->support_mmap = (!err); | 2891 | asihpi->support_mmap = (!err); |
2873 | 2892 | ||
2874 | hpi_handle_error(hpi_instream_close(ss, h_stream)); | 2893 | hpi_handle_error(hpi_instream_close(h_stream)); |
2875 | 2894 | ||
2876 | err = hpi_adapter_get_property(ss, asihpi->adapter_index, | 2895 | err = hpi_adapter_get_property(asihpi->adapter_index, |
2877 | HPI_ADAPTER_PROPERTY_CURCHANNELS, | 2896 | HPI_ADAPTER_PROPERTY_CURCHANNELS, |
2878 | &asihpi->in_max_chans, &asihpi->out_max_chans); | 2897 | &asihpi->in_max_chans, &asihpi->out_max_chans); |
2879 | if (err) { | 2898 | if (err) { |
@@ -2899,13 +2918,13 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, | |||
2899 | goto __nodev; | 2918 | goto __nodev; |
2900 | } | 2919 | } |
2901 | 2920 | ||
2902 | err = hpi_mixer_get_control(ss, asihpi->h_mixer, | 2921 | err = hpi_mixer_get_control(asihpi->h_mixer, |
2903 | HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, | 2922 | HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, |
2904 | HPI_CONTROL_SAMPLECLOCK, &h_control); | 2923 | HPI_CONTROL_SAMPLECLOCK, &h_control); |
2905 | 2924 | ||
2906 | if (!err) | 2925 | if (!err) |
2907 | err = hpi_sample_clock_set_local_rate( | 2926 | err = hpi_sample_clock_set_local_rate( |
2908 | ss, h_control, adapter_fs); | 2927 | h_control, adapter_fs); |
2909 | 2928 | ||
2910 | snd_asihpi_proc_init(asihpi); | 2929 | snd_asihpi_proc_init(asihpi); |
2911 | 2930 | ||