Changeset 99cb9bf in mainline
- Timestamp:
- 2014-08-26T08:58:47Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 159c722d
- Parents:
- 93c3163
- Location:
- uspace/drv/audio/hdaudio
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/hdaudio/codec.c
r93c3163 r99cb9bf 259 259 codec->out_aw, rates, formats); 260 260 261 /* XXX Choose appropriate parameters */262 uint32_t fmt;263 /* 48 kHz, 16-bits, 1 channel */264 fmt = fmt_bits_16 << fmt_bits_l;265 266 /* Create stream */267 ddf_msg(LVL_NOTE, "Create stream");268 hda_stream_t *stream;269 stream = hda_stream_create(hda, sdir_output, fmt);270 if (stream == NULL)271 goto error;272 273 /* Configure converter */274 275 ddf_msg(LVL_NOTE, "Configure converter format");276 rc = hda_set_converter_fmt(codec, codec->out_aw, fmt);277 if (rc != EOK)278 goto error;279 280 ddf_msg(LVL_NOTE, "Configure converter stream, channel");281 rc = hda_set_converter_ctl(codec, codec->out_aw, stream->sid, 0);282 if (rc != EOK)283 goto error;284 285 ddf_msg(LVL_NOTE, "Start stream");286 hda_stream_start(stream);287 288 261 ddf_msg(LVL_NOTE, "Codec OK"); 289 262 return codec; … … 299 272 } 300 273 274 int hda_out_converter_setup(hda_codec_t *codec, uint8_t sid) 275 { 276 int rc; 277 278 /* XXX Choose appropriate parameters */ 279 uint32_t fmt; 280 /* 48 kHz, 16-bits, 1 channel */ 281 fmt = fmt_bits_16 << fmt_bits_l; 282 283 /* Configure converter */ 284 285 ddf_msg(LVL_NOTE, "Configure converter format"); 286 rc = hda_set_converter_fmt(codec, codec->out_aw, fmt); 287 if (rc != EOK) 288 goto error; 289 290 ddf_msg(LVL_NOTE, "Configure converter stream, channel"); 291 rc = hda_set_converter_ctl(codec, codec->out_aw, sid, 0); 292 if (rc != EOK) 293 goto error; 294 295 return EOK; 296 error: 297 return rc; 298 } 299 301 300 /** @} 302 301 */ -
uspace/drv/audio/hdaudio/codec.h
r93c3163 r99cb9bf 46 46 extern hda_codec_t *hda_codec_init(hda_t *, uint8_t); 47 47 extern void hda_codec_fini(hda_codec_t *); 48 extern int hda_out_converter_setup(hda_codec_t *, uint8_t); 48 49 49 50 #endif -
uspace/drv/audio/hdaudio/hdaudio.c
r93c3163 r99cb9bf 353 353 354 354 if (0) ddf_msg(LVL_NOTE, "## interrupt ##"); 355 // ddf_msg(LVL_NOTE, "interrupt arg4=0x%x", (int)IPC_GET_ARG4(*icall)); 355 356 hda_ctl_interrupt(hda->ctl); 356 357 } -
uspace/drv/audio/hdaudio/hdaudio.h
r93c3163 r99cb9bf 50 50 hda_regs_t *regs; 51 51 struct hda_ctl *ctl; 52 struct hda_stream *pcm_stream; 52 53 } hda_t; 53 54 -
uspace/drv/audio/hdaudio/pcm_iface.c
r93c3163 r99cb9bf 40 40 #include <stdbool.h> 41 41 42 #include "codec.h" 43 #include "hdactl.h" 44 #include "hdaudio.h" 45 #include "spec/fmt.h" 46 #include "stream.h" 47 42 48 static int hda_get_info_str(ddf_fun_t *, const char **); 43 49 static unsigned hda_query_cap(ddf_fun_t *, audio_cap_t); … … 74 80 }; 75 81 82 enum { 83 max_buffer_size = 65536 /* XXX this is completely arbitrary */ 84 }; 85 86 static hda_t *fun_to_hda(ddf_fun_t *fun) 87 { 88 return (hda_t *)ddf_dev_data_get(ddf_fun_get_dev(fun)); 89 } 90 76 91 static int hda_get_info_str(ddf_fun_t *fun, const char **name) 77 92 { 78 93 ddf_msg(LVL_NOTE, "hda_get_info_str()"); 79 return ENOTSUP; 94 if (name) 95 *name = "High Definition Audio"; 96 return EOK; 80 97 } 81 98 82 99 static unsigned hda_query_cap(ddf_fun_t *fun, audio_cap_t cap) 83 100 { 84 ddf_msg(LVL_NOTE, "hda_query_cap()"); 85 return ENOTSUP; 101 ddf_msg(LVL_NOTE, "hda_query_cap(%d)", cap); 102 switch (cap) { 103 case AUDIO_CAP_PLAYBACK: 104 case AUDIO_CAP_INTERRUPT: 105 return 1; 106 case AUDIO_CAP_BUFFER_POS: 107 case AUDIO_CAP_CAPTURE: 108 return 0; 109 case AUDIO_CAP_MAX_BUFFER: 110 return max_buffer_size; 111 case AUDIO_CAP_INTERRUPT_MIN_FRAMES: 112 return 128; 113 case AUDIO_CAP_INTERRUPT_MAX_FRAMES: 114 return 16384; 115 default: 116 return ENOTSUP; 117 } 86 118 } 87 119 … … 89 121 unsigned *rate, pcm_sample_format_t *format) 90 122 { 91 ddf_msg(LVL_NOTE, "hda_test_format()"); 92 return ENOTSUP; 123 int rc = EOK; 124 125 ddf_msg(LVL_NOTE, "hda_test_format(%u, %u, %d)\n", 126 *channels, *rate, *format); 127 128 if (*channels != 1) { 129 *channels = 1; 130 rc = ELIMIT; 131 } 132 133 if (*format != PCM_SAMPLE_SINT16_LE) { 134 *format = PCM_SAMPLE_SINT16_LE; 135 rc = ELIMIT; 136 } 137 138 if (*rate != 48000) { 139 *rate = 48000; 140 rc = ELIMIT; 141 } 142 143 return rc; 93 144 } 94 145 95 146 static int hda_get_buffer(ddf_fun_t *fun, void **buffer, size_t *size) 96 147 { 97 ddf_msg(LVL_NOTE, "hda_get_buffer()"); 98 return ENOTSUP; 148 hda_t *hda = fun_to_hda(fun); 149 150 ddf_msg(LVL_NOTE, "hda_get_buffer(): hda=%p", hda); 151 if (hda->pcm_stream != NULL) 152 return EBUSY; 153 154 /* XXX Choose appropriate parameters */ 155 uint32_t fmt; 156 /* 48 kHz, 16-bits, 1 channel */ 157 fmt = fmt_bits_16 << fmt_bits_l; 158 159 ddf_msg(LVL_NOTE, "hda_get_buffer() - create stream"); 160 hda->pcm_stream = hda_stream_create(hda, sdir_output, fmt); 161 if (hda->pcm_stream == NULL) 162 return EIO; 163 164 ddf_msg(LVL_NOTE, "hda_get_buffer() - fill info"); 165 /* XXX This is only one buffer */ 166 *buffer = hda->pcm_stream->buf[0]; 167 *size = hda->pcm_stream->bufsize; 168 169 ddf_msg(LVL_NOTE, "hda_get_buffer() retturing EOK, buffer=%p, size=%zu", 170 *buffer, *size); 171 return EOK; 99 172 } 100 173 … … 119 192 static int hda_release_buffer(ddf_fun_t *fun) 120 193 { 194 hda_t *hda = fun_to_hda(fun); 195 121 196 ddf_msg(LVL_NOTE, "hda_release_buffer()"); 122 return ENOTSUP; 197 if (hda->pcm_stream == NULL) 198 return EINVAL; 199 200 hda_stream_destroy(hda->pcm_stream); 201 hda->pcm_stream = NULL; 202 return EOK; 123 203 } 124 204 … … 126 206 unsigned channels, unsigned rate, pcm_sample_format_t format) 127 207 { 208 hda_t *hda = fun_to_hda(fun); 209 int rc; 210 128 211 ddf_msg(LVL_NOTE, "hda_start_playback()"); 129 return ENOTSUP; 212 213 rc = hda_out_converter_setup(hda->ctl->codec, hda->pcm_stream->sid); 214 if (rc != EOK) 215 return rc; 216 217 hda_stream_start(hda->pcm_stream); 218 return EOK; 130 219 } 131 220 -
uspace/drv/audio/hdaudio/stream.c
r93c3163 r99cb9bf 102 102 for (j = 0; j < stream->bufsize / 2; j++) { 103 103 int16_t *bp = stream->buf[i]; 104 bp[j] = (k > 128) ? -100 00 : 10000;104 bp[j] = (k > 128) ? -100 : 100; 105 105 ++k; 106 106 if (k >= 256)
Note:
See TracChangeset
for help on using the changeset viewer.