Changeset 0e4c5f0 in mainline
- Timestamp:
- 2015-03-18T18:34:40Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ac235711
- Parents:
- 795e2bf
- Location:
- uspace
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/wavplay/drec.c
r795e2bf r0e4c5f0 47 47 48 48 49 #define BUFFER_PARTS 249 #define BUFFER_PARTS 16 50 50 51 51 /** Recording format */ … … 103 103 printf("Recording terminated\n"); 104 104 record = false; 105 break; 105 106 case PCM_EVENT_FRAMES_CAPTURED: 106 107 printf("%" PRIun " frames\n", IPC_GET_ARG1(call)); 107 async_answer_0(callid, EOK);108 108 break; 109 109 default: … … 111 111 async_answer_0(callid, ENOTSUP); 112 112 continue; 113 113 } 114 115 if (!record) { 116 async_answer_0(callid, EOK); 117 break; 114 118 } 115 119 … … 156 160 printf("\n"); 157 161 audio_pcm_stop_capture(rec->device); 162 /* XXX Control returns even before we can be sure callbacks finished */ 163 printf("Delay before playback termination\n"); 164 async_usleep(1000000); 165 printf("Terminate playback\n"); 158 166 } 159 167 -
uspace/app/wavplay/main.c
r795e2bf r0e4c5f0 308 308 if (direct) { 309 309 drecord(device, file); 310 continue; 310 311 } else { 311 312 printf("Indirect recording is not supported " -
uspace/app/wavplay/wave.c
r795e2bf r0e4c5f0 116 116 *channels = uint16_t_le2host(header->channels); 117 117 if (format) { 118 const unsigned size = uint 32_t_le2host(header->sample_size);118 const unsigned size = uint16_t_le2host(header->sample_size); 119 119 switch (size) { 120 120 case 8: *format = PCM_SAMPLE_UINT8; break; … … 157 157 header->channels = host2uint32_t_le(format.channels); 158 158 header->sample_size = 159 host2uint 32_t_le(pcm_sample_format_size(format.sample_format));159 host2uint16_t_le(pcm_sample_format_size(format.sample_format) * 8); 160 160 } 161 161 /** -
uspace/drv/audio/hdaudio/codec.c
r795e2bf r0e4c5f0 437 437 } 438 438 439 if ((pcaps & BIT_V(uint32_t, pwc_input)) != 0) { 440 ddf_msg(LVL_NOTE, "PIN %d will enable input", aw); 441 pctl = pctl | BIT_V(uint8_t, pctl_in_enable); 442 } 443 439 444 if ((pcaps & BIT_V(uint32_t, pwc_hpd)) != 0) { 440 445 ddf_msg(LVL_NOTE, "PIN %d will enable headphone drive", aw); … … 503 508 codec->hda = hda; 504 509 codec->address = address; 510 codec->in_aw = -1; 505 511 506 512 rc = hda_get_subnc(codec, 0, &sfg, &nfg); … … 587 593 ddf_msg(LVL_NOTE, "Output widget %d: rates=0x%x formats=0x%x", 588 594 aw, rates, formats); 595 } else if (awtype == awt_audio_input) { 596 if (codec->in_aw < 0) { 597 ddf_msg(LVL_NOTE, "Selected input " 598 "widget %d\n", aw); 599 codec->in_aw = aw; 600 } else { 601 ddf_msg(LVL_NOTE, "Ignoring input " 602 "widget %d\n", aw); 603 } 604 605 rc = hda_get_supp_rates(codec, aw, &rates); 606 if (rc != EOK) 607 goto error; 608 609 rc = hda_get_supp_formats(codec, aw, &formats); 610 if (rc != EOK) 611 goto error; 612 613 ddf_msg(LVL_NOTE, "Input widget %d: rates=0x%x formats=0x%x", 614 aw, rates, formats); 589 615 } 590 616 … … 623 649 /* Configure converter */ 624 650 625 ddf_msg(LVL_NOTE, "Configure converter format");651 ddf_msg(LVL_NOTE, "Configure output converter format"); 626 652 rc = hda_set_converter_fmt(codec, out_aw, stream->fmt); 627 653 if (rc != EOK) 628 654 goto error; 629 655 630 ddf_msg(LVL_NOTE, "Configure converter stream, channel");656 ddf_msg(LVL_NOTE, "Configure output converter stream, channel"); 631 657 rc = hda_set_converter_ctl(codec, out_aw, stream->sid, 0); 632 658 if (rc != EOK) 633 659 goto error; 634 660 } 661 662 return EOK; 663 error: 664 return rc; 665 } 666 667 int hda_in_converter_setup(hda_codec_t *codec, hda_stream_t *stream) 668 { 669 int rc; 670 671 /* Configure converter */ 672 673 ddf_msg(LVL_NOTE, "Configure input converter format"); 674 rc = hda_set_converter_fmt(codec, codec->in_aw, stream->fmt); 675 if (rc != EOK) 676 goto error; 677 678 ddf_msg(LVL_NOTE, "Configure input converter stream, channel"); 679 rc = hda_set_converter_ctl(codec, codec->in_aw, stream->sid, 0); 680 if (rc != EOK) 681 goto error; 635 682 636 683 return EOK; -
uspace/drv/audio/hdaudio/codec.h
r795e2bf r0e4c5f0 47 47 int out_aw_num; 48 48 int out_aw_sel; 49 int in_aw; 49 50 } hda_codec_t; 50 51 … … 52 53 extern void hda_codec_fini(hda_codec_t *); 53 54 extern int hda_out_converter_setup(hda_codec_t *, hda_stream_t *); 55 extern int hda_in_converter_setup(hda_codec_t *, hda_stream_t *); 54 56 55 57 #endif -
uspace/drv/audio/hdaudio/hdactl.c
r795e2bf r0e4c5f0 562 562 ctl->bss = BIT_RANGE_EXTRACT(uint16_t, gcap_bss_h, gcap_bss_l, gcap); 563 563 ddf_msg(LVL_NOTE, "GCAP: 0x%x (64OK=%d)", gcap, ctl->ok64bit); 564 564 ddf_msg(LVL_NOTE, "iss: %d, oss: %d, bss: %d\n", 565 ctl->iss, ctl->oss, ctl->bss); 565 566 /* Give codecs enough time to enumerate themselves */ 566 567 async_usleep(codec_enum_wait_us); -
uspace/drv/audio/hdaudio/hdaudio.c
r795e2bf r0e4c5f0 385 385 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 386 386 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 387 } else if (hda->capturing) { 388 hda_pcm_event(hda, PCM_EVENT_FRAMES_CAPTURED); 389 hda_pcm_event(hda, PCM_EVENT_FRAMES_CAPTURED); 390 hda_pcm_event(hda, PCM_EVENT_FRAMES_CAPTURED); 391 hda_pcm_event(hda, PCM_EVENT_FRAMES_CAPTURED); 387 392 } 393 388 394 hda_unlock(hda); 389 395 } -
uspace/drv/audio/hdaudio/hdaudio.h
r795e2bf r0e4c5f0 55 55 struct hda_ctl *ctl; 56 56 struct hda_stream *pcm_stream; 57 struct hda_stream_buffers *pcm_buffers; 57 58 bool playing; 59 bool capturing; 58 60 } hda_t; 59 61 -
uspace/drv/audio/hdaudio/pcm_iface.c
r795e2bf r0e4c5f0 100 100 static unsigned hda_query_cap(ddf_fun_t *fun, audio_cap_t cap) 101 101 { 102 hda_t *hda = fun_to_hda(fun); 103 102 104 ddf_msg(LVL_NOTE, "hda_query_cap(%d)", cap); 103 105 switch (cap) { 104 106 case AUDIO_CAP_PLAYBACK: 105 107 case AUDIO_CAP_INTERRUPT: 108 /* XXX Only if we have an output converter */ 106 109 return 1; 110 case AUDIO_CAP_CAPTURE: 111 /* Yes if we have an input converter */ 112 return hda->ctl->codec->in_aw >= 0; 107 113 case AUDIO_CAP_BUFFER_POS: 108 case AUDIO_CAP_CAPTURE:109 114 return 0; 110 115 case AUDIO_CAP_MAX_BUFFER: … … 148 153 { 149 154 hda_t *hda = fun_to_hda(fun); 155 int rc; 150 156 151 157 hda_lock(hda); 152 158 153 159 ddf_msg(LVL_NOTE, "hda_get_buffer(): hda=%p", hda); 160 if (hda->pcm_buffers != NULL) { 161 hda_unlock(hda); 162 return EBUSY; 163 } 164 165 ddf_msg(LVL_NOTE, "hda_get_buffer() - allocate stream buffers"); 166 rc = hda_stream_buffers_alloc(hda, &hda->pcm_buffers); 167 if (rc != EOK) { 168 assert(rc == ENOMEM); 169 hda_unlock(hda); 170 return ENOMEM; 171 } 172 173 ddf_msg(LVL_NOTE, "hda_get_buffer() - fill info"); 174 /* XXX This is only one buffer */ 175 *buffer = hda->pcm_buffers->buf[0]; 176 *size = hda->pcm_buffers->bufsize * hda->pcm_buffers->nbuffers; 177 178 ddf_msg(LVL_NOTE, "hda_get_buffer() returing EOK, buffer=%p, size=%zu", 179 *buffer, *size); 180 181 hda_unlock(hda); 182 return EOK; 183 } 184 185 static int hda_get_buffer_position(ddf_fun_t *fun, size_t *pos) 186 { 187 ddf_msg(LVL_NOTE, "hda_get_buffer_position()"); 188 return ENOTSUP; 189 } 190 191 static int hda_set_event_session(ddf_fun_t *fun, async_sess_t *sess) 192 { 193 hda_t *hda = fun_to_hda(fun); 194 195 ddf_msg(LVL_NOTE, "hda_set_event_session()"); 196 hda_lock(hda); 197 hda->ev_sess = sess; 198 hda_unlock(hda); 199 200 return EOK; 201 } 202 203 static async_sess_t *hda_get_event_session(ddf_fun_t *fun) 204 { 205 hda_t *hda = fun_to_hda(fun); 206 async_sess_t *sess; 207 208 ddf_msg(LVL_NOTE, "hda_get_event_session()"); 209 210 hda_lock(hda); 211 sess = hda->ev_sess; 212 hda_unlock(hda); 213 214 return sess; 215 } 216 217 static int hda_release_buffer(ddf_fun_t *fun) 218 { 219 hda_t *hda = fun_to_hda(fun); 220 221 hda_lock(hda); 222 223 ddf_msg(LVL_NOTE, "hda_release_buffer()"); 224 if (hda->pcm_buffers == NULL) { 225 hda_unlock(hda); 226 return EINVAL; 227 } 228 229 hda_stream_buffers_free(hda->pcm_buffers); 230 231 hda_unlock(hda); 232 return EOK; 233 } 234 235 static int hda_start_playback(ddf_fun_t *fun, unsigned frames, 236 unsigned channels, unsigned rate, pcm_sample_format_t format) 237 { 238 hda_t *hda = fun_to_hda(fun); 239 int rc; 240 241 ddf_msg(LVL_NOTE, "hda_start_playback()"); 242 hda_lock(hda); 243 154 244 if (hda->pcm_stream != NULL) { 155 245 hda_unlock(hda); … … 162 252 fmt = (fmt_base_44khz << fmt_base) | (fmt_bits_16 << fmt_bits_l) | 1; 163 253 164 ddf_msg(LVL_NOTE, "hda_get_buffer() - create stream"); 165 hda->pcm_stream = hda_stream_create(hda, sdir_output, fmt); 254 ddf_msg(LVL_NOTE, "hda_start_playback() - create output stream"); 255 hda->pcm_stream = hda_stream_create(hda, sdir_output, hda->pcm_buffers, 256 fmt); 166 257 if (hda->pcm_stream == NULL) { 167 258 hda_unlock(hda); 168 259 return EIO; 169 260 } 170 171 ddf_msg(LVL_NOTE, "hda_get_buffer() - fill info");172 /* XXX This is only one buffer */173 *buffer = hda->pcm_stream->buf[0];174 *size = hda->pcm_stream->bufsize * hda->pcm_stream->nbuffers;175 176 ddf_msg(LVL_NOTE, "hda_get_buffer() retturing EOK, buffer=%p, size=%zu",177 *buffer, *size);178 179 hda_unlock(hda);180 return EOK;181 }182 183 static int hda_get_buffer_position(ddf_fun_t *fun, size_t *pos)184 {185 ddf_msg(LVL_NOTE, "hda_get_buffer_position()");186 return ENOTSUP;187 }188 189 static int hda_set_event_session(ddf_fun_t *fun, async_sess_t *sess)190 {191 hda_t *hda = fun_to_hda(fun);192 193 ddf_msg(LVL_NOTE, "hda_set_event_session()");194 hda_lock(hda);195 hda->ev_sess = sess;196 hda_unlock(hda);197 198 return EOK;199 }200 201 static async_sess_t *hda_get_event_session(ddf_fun_t *fun)202 {203 hda_t *hda = fun_to_hda(fun);204 async_sess_t *sess;205 206 ddf_msg(LVL_NOTE, "hda_get_event_session()");207 208 hda_lock(hda);209 sess = hda->ev_sess;210 hda_unlock(hda);211 212 return sess;213 }214 215 static int hda_release_buffer(ddf_fun_t *fun)216 {217 hda_t *hda = fun_to_hda(fun);218 219 hda_lock(hda);220 221 ddf_msg(LVL_NOTE, "hda_release_buffer()");222 if (hda->pcm_stream == NULL) {223 hda_unlock(hda);224 return EINVAL;225 }226 227 hda_stream_destroy(hda->pcm_stream);228 hda->pcm_stream = NULL;229 230 hda_unlock(hda);231 return EOK;232 }233 234 static int hda_start_playback(ddf_fun_t *fun, unsigned frames,235 unsigned channels, unsigned rate, pcm_sample_format_t format)236 {237 hda_t *hda = fun_to_hda(fun);238 int rc;239 240 ddf_msg(LVL_NOTE, "hda_start_playback()");241 hda_lock(hda);242 261 243 262 rc = hda_out_converter_setup(hda->ctl->codec, hda->pcm_stream); 244 263 if (rc != EOK) { 264 hda_stream_destroy(hda->pcm_stream); 265 hda->pcm_stream = NULL; 245 266 hda_unlock(hda); 246 267 return rc; 247 268 } 248 269 270 hda->playing = true; 249 271 hda_stream_start(hda->pcm_stream); 250 hda->playing = true;251 272 hda_unlock(hda); 252 273 return EOK; … … 262 283 hda_stream_reset(hda->pcm_stream); 263 284 hda->playing = false; 285 hda_stream_destroy(hda->pcm_stream); 286 hda->pcm_stream = NULL; 287 264 288 hda_unlock(hda); 265 289 … … 271 295 unsigned rate, pcm_sample_format_t format) 272 296 { 297 hda_t *hda = fun_to_hda(fun); 298 int rc; 299 273 300 ddf_msg(LVL_NOTE, "hda_start_capture()"); 274 return ENOTSUP; 301 hda_lock(hda); 302 303 if (hda->pcm_stream != NULL) { 304 hda_unlock(hda); 305 return EBUSY; 306 } 307 308 /* XXX Choose appropriate parameters */ 309 uint32_t fmt; 310 /* 48 kHz, 16-bits, 1 channel */ 311 fmt = (fmt_base_44khz << fmt_base) | (fmt_bits_16 << fmt_bits_l) | 1; 312 313 ddf_msg(LVL_NOTE, "hda_start_capture() - create input stream"); 314 hda->pcm_stream = hda_stream_create(hda, sdir_input, hda->pcm_buffers, 315 fmt); 316 if (hda->pcm_stream == NULL) { 317 hda_unlock(hda); 318 return EIO; 319 } 320 321 rc = hda_in_converter_setup(hda->ctl->codec, hda->pcm_stream); 322 if (rc != EOK) { 323 hda_stream_destroy(hda->pcm_stream); 324 hda->pcm_stream = NULL; 325 hda_unlock(hda); 326 return rc; 327 } 328 329 hda->capturing = true; 330 hda_stream_start(hda->pcm_stream); 331 hda_unlock(hda); 332 return EOK; 275 333 } 276 334 277 335 static int hda_stop_capture(ddf_fun_t *fun, bool immediate) 278 336 { 337 hda_t *hda = fun_to_hda(fun); 338 279 339 ddf_msg(LVL_NOTE, "hda_stop_capture()"); 280 return ENOTSUP; 340 hda_lock(hda); 341 hda_stream_stop(hda->pcm_stream); 342 hda_stream_reset(hda->pcm_stream); 343 hda->capturing = false; 344 hda_stream_destroy(hda->pcm_stream); 345 hda->pcm_stream = NULL; 346 hda_unlock(hda); 347 348 hda_pcm_event(hda, PCM_EVENT_CAPTURE_TERMINATED); 349 return EOK; 281 350 } 282 351 -
uspace/drv/audio/hdaudio/stream.c
r795e2bf r0e4c5f0 48 48 #include "stream.h" 49 49 50 static int hda_stream_buffers_alloc(hda_stream_t *stream)50 int hda_stream_buffers_alloc(hda_t *hda, hda_stream_buffers_t **rbufs) 51 51 { 52 52 void *bdl; 53 53 void *buffer; 54 54 uintptr_t buffer_phys; 55 hda_stream_buffers_t *bufs = NULL; 55 56 size_t i; 56 57 // size_t j, k; 57 58 int rc; 58 59 59 stream->nbuffers = 4; 60 stream->bufsize = 16384; 60 bufs = calloc(1, sizeof(hda_stream_buffers_t)); 61 if (bufs == NULL) { 62 rc = ENOMEM; 63 goto error; 64 } 65 66 bufs->nbuffers = 4; 67 bufs->bufsize = 16384; 61 68 62 69 /* … … 65 72 */ 66 73 bdl = AS_AREA_ANY; 67 rc = dmamem_map_anonymous( stream->nbuffers * sizeof(hda_buffer_desc_t),68 stream->hda->ctl->ok64bit ? 0 : DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE,69 0, & stream->bdl_phys, &bdl);74 rc = dmamem_map_anonymous(bufs->nbuffers * sizeof(hda_buffer_desc_t), 75 hda->ctl->ok64bit ? 0 : DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 76 0, &bufs->bdl_phys, &bdl); 70 77 if (rc != EOK) 71 78 goto error; 72 79 73 stream->bdl = bdl;80 bufs->bdl = bdl; 74 81 75 82 /* Allocate arrays of buffer pointers */ 76 83 77 stream->buf = calloc(stream->nbuffers, sizeof(void *));78 if ( stream->buf == NULL)79 goto error; 80 81 stream->buf_phys = calloc(stream->nbuffers, sizeof(uintptr_t));82 if ( stream->buf_phys == NULL)84 bufs->buf = calloc(bufs->nbuffers, sizeof(void *)); 85 if (bufs->buf == NULL) 86 goto error; 87 88 bufs->buf_phys = calloc(bufs->nbuffers, sizeof(uintptr_t)); 89 if (bufs->buf_phys == NULL) 83 90 goto error; 84 91 85 92 /* Allocate buffers */ 86 93 /* 87 for (i = 0; i < stream->nbuffers; i++) {94 for (i = 0; i < bufs->nbuffers; i++) { 88 95 buffer = AS_AREA_ANY; 89 rc = dmamem_map_anonymous( stream->bufsize,90 stream->hda->ctl->ok64bit ? 0 : DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE,96 rc = dmamem_map_anonymous(bufs->bufsize, 97 bufs->hda->ctl->ok64bit ? 0 : DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 91 98 0, &buffer_phys, &buffer); 92 99 if (rc != EOK) … … 96 103 (unsigned long long)buffer_phys, buffer); 97 104 98 stream->buf[i] = buffer;99 stream->buf_phys[i] = buffer_phys;105 bufs->buf[i] = buffer; 106 bufs->buf_phys[i] = buffer_phys; 100 107 101 108 k = 0; 102 for (j = 0; j < stream->bufsize / 2; j++) {103 int16_t *bp = stream->buf[i];109 for (j = 0; j < bufs->bufsize / 2; j++) { 110 int16_t *bp = bufs->buf[i]; 104 111 bp[j] = (k > 128) ? -100 : 100; 105 112 ++k; … … 111 118 /* audio_pcm_iface requires a single contiguous buffer */ 112 119 buffer = AS_AREA_ANY; 113 rc = dmamem_map_anonymous( stream->bufsize * stream->nbuffers,114 stream->hda->ctl->ok64bit ? 0 : DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE,120 rc = dmamem_map_anonymous(bufs->bufsize * bufs->nbuffers, 121 hda->ctl->ok64bit ? 0 : DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 115 122 0, &buffer_phys, &buffer); 116 123 if (rc != EOK) { … … 119 126 } 120 127 121 for (i = 0; i < stream->nbuffers; i++) {122 stream->buf[i] = buffer + i * stream->bufsize;123 stream->buf_phys[i] = buffer_phys + i * stream->bufsize;128 for (i = 0; i < bufs->nbuffers; i++) { 129 bufs->buf[i] = buffer + i * bufs->bufsize; 130 bufs->buf_phys[i] = buffer_phys + i * bufs->bufsize; 124 131 125 132 ddf_msg(LVL_NOTE, "Stream buf phys=0x%llx virt=%p", 126 (long long unsigned)(uintptr_t) stream->buf[i],127 (void *) stream->buf_phys[i]);133 (long long unsigned)(uintptr_t)bufs->buf[i], 134 (void *)bufs->buf_phys[i]); 128 135 /* k = 0; 129 for (j = 0; j < stream->bufsize / 2; j++) {130 int16_t *bp = stream->buf[i];136 for (j = 0; j < bufs->bufsize / 2; j++) { 137 int16_t *bp = bufs->buf[i]; 131 138 bp[j] = (k > 128) ? -10000 : 10000; 132 139 ++k; … … 138 145 139 146 /* Fill in BDL */ 140 for (i = 0; i < stream->nbuffers; i++) { 141 stream->bdl[i].address = host2uint64_t_le(stream->buf_phys[i]); 142 stream->bdl[i].length = host2uint32_t_le(stream->bufsize); 143 stream->bdl[i].flags = BIT_V(uint32_t, bdf_ioc); 144 } 145 147 for (i = 0; i < bufs->nbuffers; i++) { 148 bufs->bdl[i].address = host2uint64_t_le(bufs->buf_phys[i]); 149 bufs->bdl[i].length = host2uint32_t_le(bufs->bufsize); 150 bufs->bdl[i].flags = BIT_V(uint32_t, bdf_ioc); 151 } 152 153 *rbufs = bufs; 146 154 return EOK; 147 155 error: 156 hda_stream_buffers_free(bufs); 148 157 return ENOMEM; 149 158 } 150 159 160 void hda_stream_buffers_free(hda_stream_buffers_t *bufs) 161 { 162 if (bufs == NULL) 163 return; 164 165 /* XXX */ 166 free(bufs); 167 } 168 151 169 static void hda_stream_desc_configure(hda_stream_t *stream) 152 170 { 153 171 hda_sdesc_regs_t *sdregs; 172 hda_stream_buffers_t *bufs = stream->buffers; 154 173 uint8_t ctl1; 155 174 uint8_t ctl3; … … 161 180 hda_reg8_write(&sdregs->ctl3, ctl3); 162 181 hda_reg8_write(&sdregs->ctl1, ctl1); 163 hda_reg32_write(&sdregs->cbl, stream->nbuffers * stream->bufsize);164 hda_reg16_write(&sdregs->lvi, stream->nbuffers - 1);182 hda_reg32_write(&sdregs->cbl, bufs->nbuffers * bufs->bufsize); 183 hda_reg16_write(&sdregs->lvi, bufs->nbuffers - 1); 165 184 hda_reg16_write(&sdregs->fmt, stream->fmt); 166 hda_reg32_write(&sdregs->bdpl, LOWER32( stream->bdl_phys));167 hda_reg32_write(&sdregs->bdpu, UPPER32( stream->bdl_phys));185 hda_reg32_write(&sdregs->bdpl, LOWER32(bufs->bdl_phys)); 186 hda_reg32_write(&sdregs->bdpu, UPPER32(bufs->bdl_phys)); 168 187 } 169 188 … … 205 224 206 225 hda_stream_t *hda_stream_create(hda_t *hda, hda_stream_dir_t dir, 207 uint32_t fmt)226 hda_stream_buffers_t *bufs, uint32_t fmt) 208 227 { 209 228 hda_stream_t *stream; 210 int rc;229 uint8_t sdid; 211 230 212 231 stream = calloc(1, sizeof(hda_stream_t)); … … 214 233 return NULL; 215 234 235 sdid = 0; 236 237 switch (dir) { 238 case sdir_input: 239 sdid = 0; /* XXX Allocate - first input SDESC */ 240 break; 241 case sdir_output: 242 sdid = hda->ctl->iss; /* XXX Allocate - First output SDESC */ 243 break; 244 case sdir_bidi: 245 sdid = hda->ctl->iss + hda->ctl->oss; /* XXX Allocate - First bidi SDESC */ 246 break; 247 } 248 216 249 stream->hda = hda; 217 250 stream->dir = dir; 218 251 stream->sid = 1; /* XXX Allocate this */ 219 stream->sdid = hda->ctl->iss; /* XXX Allocate - First output SDESC */252 stream->sdid = sdid; 220 253 stream->fmt = fmt; 254 stream->buffers = bufs; 221 255 222 256 ddf_msg(LVL_NOTE, "snum=%d sdidx=%d", stream->sid, stream->sdid); 223 224 ddf_msg(LVL_NOTE, "Allocate buffers");225 rc = hda_stream_buffers_alloc(stream);226 if (rc != EOK)227 goto error;228 257 229 258 ddf_msg(LVL_NOTE, "Configure stream descriptor"); 230 259 hda_stream_desc_configure(stream); 231 260 return stream; 232 error:233 return NULL;234 261 } 235 262 -
uspace/drv/audio/hdaudio/stream.h
r795e2bf r0e4c5f0 48 48 } hda_stream_dir_t; 49 49 50 typedef struct hda_stream { 51 hda_t *hda; 52 /** Stream ID */ 53 uint8_t sid; 54 /** Stream descriptor index */ 55 uint8_t sdid; 56 /** Direction */ 57 hda_stream_dir_t dir; 50 typedef struct hda_stream_buffers { 58 51 /** Number of buffers */ 59 52 size_t nbuffers; … … 68 61 /** Physical addresses of buffers */ 69 62 uintptr_t *buf_phys; 63 } hda_stream_buffers_t; 64 65 typedef struct hda_stream { 66 hda_t *hda; 67 /** Stream ID */ 68 uint8_t sid; 69 /** Stream descriptor index */ 70 uint8_t sdid; 71 /** Direction */ 72 hda_stream_dir_t dir; 73 /** Buffers */ 74 hda_stream_buffers_t *buffers; 70 75 /** Stream format */ 71 76 uint32_t fmt; 72 77 } hda_stream_t; 73 78 74 extern hda_stream_t *hda_stream_create(hda_t *, hda_stream_dir_t, uint32_t); 79 extern int hda_stream_buffers_alloc(hda_t *, hda_stream_buffers_t **); 80 extern void hda_stream_buffers_free(hda_stream_buffers_t *); 81 extern hda_stream_t *hda_stream_create(hda_t *, hda_stream_dir_t, 82 hda_stream_buffers_t *, uint32_t); 75 83 extern void hda_stream_destroy(hda_stream_t *); 76 84 extern void hda_stream_start(hda_stream_t *);
Note:
See TracChangeset
for help on using the changeset viewer.