Changeset 57a2208 in mainline for uspace/drv/audio
- Timestamp:
- 2014-09-09T22:10:03Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c4f67c8
- Parents:
- b14e9749
- Location:
- uspace/drv/audio/hdaudio
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/hdaudio/hdactl.c
rb14e9749 r57a2208 595 595 } 596 596 597 async_usleep(5*1000*1000);598 597 ddf_msg(LVL_NOTE, "intsts=0x%x", hda_reg32_read(&hda->regs->intsts)); 599 598 ddf_msg(LVL_NOTE, "sdesc[%d].sts=0x%x", -
uspace/drv/audio/hdaudio/hdaudio.c
rb14e9749 r57a2208 172 172 } 173 173 174 fibril_mutex_initialize(&hda->lock); 175 174 176 ddf_msg(LVL_NOTE, "create parent sess"); 175 177 hda->parent_sess = ddf_dev_parent_sess_create(dev, … … 373 375 if (0) ddf_msg(LVL_NOTE, "## interrupt ##"); 374 376 // ddf_msg(LVL_NOTE, "interrupt arg4=0x%x", (int)IPC_GET_ARG4(*icall)); 377 hda_ctl_interrupt(hda->ctl); 378 375 379 if (IPC_GET_ARG3(*icall) != 0) { 376 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 377 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 378 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 379 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 380 /* hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 381 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 382 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 383 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED);*/ 384 } 385 hda_ctl_interrupt(hda->ctl); 380 /* Buffer completed */ 381 hda_lock(hda); 382 if (hda->playing) { 383 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 384 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 385 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 386 hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED); 387 } 388 hda_unlock(hda); 389 } 390 } 391 392 void hda_lock(hda_t *hda) 393 { 394 fibril_mutex_lock(&hda->lock); 395 } 396 397 void hda_unlock(hda_t *hda) 398 { 399 fibril_mutex_unlock(&hda->lock); 386 400 } 387 401 -
uspace/drv/audio/hdaudio/hdaudio.h
rb14e9749 r57a2208 38 38 #include <async.h> 39 39 #include <ddf/driver.h> 40 #include <fibril_synch.h> 41 #include <stdbool.h> 40 42 #include <stdint.h> 41 43 … … 44 46 /** High Definition Audio driver instance */ 45 47 typedef struct hda { 48 fibril_mutex_t lock; 46 49 async_sess_t *parent_sess; 47 50 async_sess_t *ev_sess; … … 52 55 struct hda_ctl *ctl; 53 56 struct hda_stream *pcm_stream; 57 bool playing; 54 58 } hda_t; 59 60 extern void hda_lock(hda_t *); 61 extern void hda_unlock(hda_t *); 55 62 56 63 #endif -
uspace/drv/audio/hdaudio/pcm_iface.c
rb14e9749 r57a2208 149 149 hda_t *hda = fun_to_hda(fun); 150 150 151 hda_lock(hda); 152 151 153 ddf_msg(LVL_NOTE, "hda_get_buffer(): hda=%p", hda); 152 if (hda->pcm_stream != NULL) 154 if (hda->pcm_stream != NULL) { 155 hda_unlock(hda); 153 156 return EBUSY; 157 } 154 158 155 159 /* XXX Choose appropriate parameters */ … … 160 164 ddf_msg(LVL_NOTE, "hda_get_buffer() - create stream"); 161 165 hda->pcm_stream = hda_stream_create(hda, sdir_output, fmt); 162 if (hda->pcm_stream == NULL) 166 if (hda->pcm_stream == NULL) { 167 hda_unlock(hda); 163 168 return EIO; 169 } 164 170 165 171 ddf_msg(LVL_NOTE, "hda_get_buffer() - fill info"); … … 170 176 ddf_msg(LVL_NOTE, "hda_get_buffer() retturing EOK, buffer=%p, size=%zu", 171 177 *buffer, *size); 178 179 hda_unlock(hda); 172 180 return EOK; 173 181 } … … 184 192 185 193 ddf_msg(LVL_NOTE, "hda_set_event_session()"); 194 hda_lock(hda); 186 195 hda->ev_sess = sess; 196 hda_unlock(hda); 197 187 198 return EOK; 188 199 } … … 191 202 { 192 203 hda_t *hda = fun_to_hda(fun); 204 async_sess_t *sess; 193 205 194 206 ddf_msg(LVL_NOTE, "hda_get_event_session()"); 195 return hda->ev_sess; 207 208 hda_lock(hda); 209 sess = hda->ev_sess; 210 hda_unlock(hda); 211 212 return sess; 196 213 } 197 214 … … 200 217 hda_t *hda = fun_to_hda(fun); 201 218 219 hda_lock(hda); 220 202 221 ddf_msg(LVL_NOTE, "hda_release_buffer()"); 203 if (hda->pcm_stream == NULL) 222 if (hda->pcm_stream == NULL) { 223 hda_unlock(hda); 204 224 return EINVAL; 225 } 205 226 206 227 hda_stream_destroy(hda->pcm_stream); 207 228 hda->pcm_stream = NULL; 229 230 hda_unlock(hda); 208 231 return EOK; 209 232 } … … 216 239 217 240 ddf_msg(LVL_NOTE, "hda_start_playback()"); 241 hda_lock(hda); 218 242 219 243 rc = hda_out_converter_setup(hda->ctl->codec, hda->pcm_stream); 220 if (rc != EOK) 244 if (rc != EOK) { 245 hda_unlock(hda); 221 246 return rc; 222 223 async_usleep(1000*1000); 247 } 248 224 249 hda_stream_start(hda->pcm_stream); 250 hda->playing = true; 251 hda_unlock(hda); 225 252 return EOK; 226 253 } … … 231 258 232 259 ddf_msg(LVL_NOTE, "hda_stop_playback()"); 260 hda_lock(hda); 233 261 hda_stream_stop(hda->pcm_stream); 234 262 hda_stream_reset(hda->pcm_stream); 263 hda->playing = false; 264 hda_unlock(hda); 235 265 236 266 hda_pcm_event(hda, PCM_EVENT_PLAYBACK_TERMINATED); -
uspace/drv/audio/hdaudio/stream.c
rb14e9749 r57a2208 109 109 } 110 110 */ 111 // async_usleep(1000*1000);112 111 /* audio_pcm_iface requires a single contiguous buffer */ 113 112 buffer = AS_AREA_ANY;
Note:
See TracChangeset
for help on using the changeset viewer.