* Make response argument to hda_send_verbs able to handle NULL, in case we don't care for the response

* Minor tweaking to buffer handling, which seems to fix the "distorted audio" probs I was having :)



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21131 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ithamar R. Adema
2007-05-13 20:19:54 +00:00
parent 6ae0b57489
commit 551c7edafd
2 changed files with 13 additions and 8 deletions
@@ -323,7 +323,7 @@ hda_codec_audiofg_new(hda_codec* codec, uint32 afg_nid)
if (codec->afg_widgets[idx].type != WT_PIN_COMPLEX)
continue;
if (!codec->afg_widgets[idx].d.pin.output)
if (codec->afg_widgets[idx].d.pin.output)
continue;
if (codec->afg_widgets[idx].d.pin.device != PIN_DEV_HP_OUT &&
codec->afg_widgets[idx].d.pin.device != PIN_DEV_SPEAKER &&
@@ -338,26 +338,26 @@ hda_codec_audiofg_new(hda_codec* codec, uint32 afg_nid)
output_wid = hda_codec_afg_find_dac_path(codec, codec->afg_widgets[idx].inputs[iidx], 0);
if (output_wid) {
corb_t verb = MAKE_VERB(codec->addr,idx+codec->afg_wid_start,VID_SET_CONNSEL,iidx);
uint32 resp;
if (hda_send_verbs(codec, &verb, &resp, 1) == B_OK)
break;
if (hda_send_verbs(codec, &verb, NULL, 1) != B_OK)
dprintf("%s: Setting output selector failed!\n", __func__);
break;
}
}
}
if (output_wid) {
corb_t verb;
uint32 resp;
codec->playback_stream->pin_wid = idx + codec->afg_wid_start;
codec->playback_stream->io_wid = output_wid;
dprintf("%s: Found output PIN (%s) connected to output CONV wid:%ld\n",
__func__, defdev[codec->afg_widgets[idx].d.pin.device], output_wid);
/* FIXME: Force Pin Widget to unmute */
verb = MAKE_VERB(codec->addr, codec->playback_stream->pin_wid,
VID_SET_AMPGAINMUTE, (1 << 15) | (1 << 13) | (1 << 12));
hda_send_verbs(codec, &verb, &resp, 1);
hda_send_verbs(codec, &verb, NULL, 1);
break;
}
}
@@ -59,11 +59,16 @@ hda_stream_check_intr(hda_controller* ctrlr, hda_stream* s)
if (s->running) {
uint8 sts = OREG8(ctrlr,s->off,STS);
if (sts) {
int32 count;
OREG8(ctrlr,s->off,STS) = sts;
s->played_real_time = system_time();
s->played_frames_count += s->buffer_length;
release_sem_etc(s->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE);
get_sem_count(s->buffer_ready_sem, &count);
if (count <= 0)
release_sem_etc(s->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE);
}
}
@@ -219,7 +224,7 @@ hda_send_verbs(hda_codec* codec, corb_t* verbs, uint32* responses, int count)
REG16(codec->ctrlr,CORBWP) = (codec->ctrlr->corbwp += count);
rc = acquire_sem_etc(codec->response_sem, count, B_CAN_INTERRUPT | B_RELATIVE_TIMEOUT, 1000ULL * 50);
if (rc == B_OK)
if (rc == B_OK && responses != NULL)
memcpy(responses, codec->responses, count*sizeof(uint32));
return rc;