Lines Matching defs:widget

66 static zx_status_t ParseAWPcmSizeRate(AudioWidgetState& widget, const CodecResponse& resp) {
67 auto& afg = *widget.afg_;
68 const auto& caps = widget.caps_;
70 widget.pcm_size_rate_ = caps.format_override()
77 static zx_status_t ParseAWPcmFormats(AudioWidgetState& widget, const CodecResponse& resp) {
78 auto& afg = *widget.afg_;
79 const auto& caps = widget.caps_;
81 widget.pcm_formats_ = caps.format_override()
88 static zx_status_t ParseAWInputAmpCaps(AudioWidgetState& widget, const CodecResponse& resp) {
89 auto& afg = *widget.afg_;
90 const auto& caps = widget.caps_;
93 widget.input_amp_caps_ = caps.amp_param_override()
101 static zx_status_t ParseAWOutputAmpCaps(AudioWidgetState& widget, const CodecResponse& resp) {
102 auto& afg = *widget.afg_;
103 const auto& caps = widget.caps_;
106 widget.output_amp_caps_ = caps.amp_param_override()
114 static zx_status_t ParseAWConnectionListLen(AudioWidgetState& widget, const CodecResponse& resp) {
115 const auto& caps = widget.caps_;
118 widget.long_form_conn_list_ = ((resp.data & 0x80) != 0);
119 widget.conn_list_len_ = resp.data & 0x7f;
121 if (widget.conn_list_len_) {
123 widget.conn_list_.reset(
124 new (&ac) AudioWidgetState::ConnListEntry[widget.conn_list_len_]);
130 widget.long_form_conn_list_ = false;
131 widget.conn_list_len_ = 0;
137 static zx_status_t ParseAWProcessingCaps(AudioWidgetState& widget, const CodecResponse& resp) {
138 const auto& caps = widget.caps_;
141 widget.can_bypass_processing_ = (resp.data & 0x1) != 0;
142 widget.processing_coefficient_count_ = ((resp.data >> 8) & 0xFF);
148 static zx_status_t ParseAWPinCaps(AudioWidgetState& widget, const CodecResponse& resp) {
149 widget.pin_caps_ = resp.data;
153 static zx_status_t ParseAWVolumeKnobCaps(AudioWidgetState& widget, const CodecResponse& resp) {
154 widget.vol_knob_is_delta_ = (resp.data & 0x80) != 0;
155 widget.vol_knob_steps_ = (resp.data & 0x7f);
159 static zx_status_t ParseAWStreamChan(AudioWidgetState& widget, const CodecResponse& resp) {
161 widget.stream_tag_ = static_cast<uint8_t>((resp.data >> 4) & 0xF);
162 widget.stream_chan_ = static_cast<uint8_t>(resp.data & 0xF);
166 static zx_status_t ParseAWConfigDefaults(AudioWidgetState& widget, const CodecResponse& resp) {
167 widget.cfg_defaults_.raw_data_ = resp.data;
171 static zx_status_t ParseAWPinWidgetCtrl(AudioWidgetState& widget, const CodecResponse& resp) {
172 widget.pin_widget_ctrl_.raw_data_ = static_cast<uint8_t>(resp.data & 0xFF);
554 "Failed to audio widget type (nid %hu) for function "
568 zx_status_t IntelHDACodec::ReadAudioWidgetState(AudioWidgetState& widget) {
571 switch (widget.caps_.type()) {
573 RUN_COMMAND_LIST(widget, widget.nid_, FETCH_AUDIO_INPUT_CAPS,
574 "Failed to fetch INPUT_CAPS for audio widget (nid %hu)",
575 widget.nid_);
579 RUN_COMMAND_LIST(widget, widget.nid_, FETCH_AUDIO_OUTPUT_CAPS,
580 "Failed to fetch OUTPUT_CAPS for audio widget (nid %hu)",
581 widget.nid_);
585 if (widget.caps_.digital()) {
586 RUN_COMMAND_LIST(widget, widget.nid_, FETCH_DIGITAL_PIN_COMPLEX_CAPS,
587 "Failed to fetch DIGITAL_PIN_COMPLEX_CAPS for audio widget "
588 "(nid %hu)", widget.nid_);
590 RUN_COMMAND_LIST(widget, widget.nid_, FETCH_NON_DIGITAL_PIN_COMPLEX_CAPS,
591 "Failed to fetch NON_DIGITAL_PIN_COMPLEX_CAPS for audio widget "
592 "(nid %hu)", widget.nid_);
597 RUN_COMMAND_LIST(widget, widget.nid_, FETCH_MIXER_CAPS,
598 "Failed to fetch MIXER_CAPS for audio widget (nid %hu)",
599 widget.nid_);
603 RUN_COMMAND_LIST(widget, widget.nid_, FETCH_SELECTOR_CAPS,
604 "Failed to fetch SELECTOR_CAPS for audio widget (nid %hu)",
605 widget.nid_);
609 RUN_COMMAND_LIST(widget, widget.nid_, FETCH_POWER_CAPS,
610 "Failed to fetch POWER_CAPS for audio widget (nid %hu)",
611 widget.nid_);
615 RUN_COMMAND_LIST(widget, widget.nid_, FETCH_VOLUME_KNOB_CAPS,
616 "Failed to fetch VOLUME_KNOB_CAPS for audio widget (nid %hu)",
617 widget.nid_);
626 printf("Unrecognized audio widget type (%u) at nid %hu\n",
627 static_cast<uint32_t>(widget.caps_.type()), widget.nid_);
631 // If this widget has a connection list, read it now.
632 if (widget.caps_.has_conn_list()) {
633 res = ReadConnList(widget);
638 // If this widget has power management capabilities, read the caps and the
640 if (widget.caps_.has_power_ctl()) {
641 RUN_COMMAND_LIST(widget.power_, widget.nid_, FETCH_POWER_STATE,
642 "Failed to fetch Power caps/state for audio widget (nid %hu)",
643 widget.nid_);
651 if (widget.power_.supported_states_ == 0) {
652 ZX_DEBUG_ASSERT(widget.afg_ != nullptr);
653 widget.power_.supported_states_ = widget.afg_->power_.supported_states_;
657 // If this is an input or output converter widget, read the currently configured format.
658 if ((widget.caps_.type() == AudioWidgetCaps::Type::INPUT) ||
659 (widget.caps_.type() == AudioWidgetCaps::Type::OUTPUT)) {
662 res = DoCodecCmd(widget.nid_, GET_CONVERTER_FORMAT, &resp);
665 widget.nid_, res);
669 widget.cur_format_.raw_data_ = static_cast<uint16_t>(resp.data & 0xFFFF);
675 if ((widget.caps_.type() == AudioWidgetCaps::Type::PIN_COMPLEX) &&
676 (widget.pin_caps_ & AW_PIN_CAPS_FLAG_CAN_PRESENCE_DETECT) &&
677 (!widget.cfg_defaults_.jack_detect_override())) {
683 if (widget.pin_caps_ & AW_PIN_CAPS_FLAG_TRIGGER_REQUIRED) {
685 widget.nid_);
691 res = DoCodecCmd(widget.nid_, GET_PIN_SENSE, &resp);
694 widget.nid_, res);
698 widget.pin_sense_.raw_data_ = resp.data;
699 widget.pin_sense_valid_ = true;
707 // 3) Any widget capable of swapping L/R channels
708 if (widget.caps_.can_lr_swap() ||
709 (widget.pin_caps_ & AW_PIN_CAPS_FLAG_BALANCED_IO) ||
710 (widget.pin_caps_ & AW_PIN_CAPS_FLAG_CAN_EAPD)) {
712 res = DoCodecCmd(widget.nid_, GET_EAPD_BTL_ENABLE, &resp);
715 widget.nid_, res);
719 widget.eapd_state_.raw_data_ = resp.data;
722 // If this widget has an input or output amplifier, read its current state.
727 if (widget.caps_.input_amp_present()) {
730 if (widget.caps_.type() == AudioWidgetCaps::Type::MIXER) {
731 for (uint8_t i = 0; i < widget.conn_list_len_; ++i) {
732 res = ReadAmpState(widget.nid_, true, i,
733 widget.input_amp_caps_,
734 &widget.conn_list_[i].amp_state_);
739 res = ReadAmpState(widget.nid_, true, 0,
740 widget.input_amp_caps_, &widget.input_amp_state_);
746 if (widget.caps_.output_amp_present()) {
747 res = ReadAmpState(widget.nid_, false, 0,
748 widget.output_amp_caps_, &widget.output_amp_state_);
753 // If this widget can send unsolicited responses, query the current state of
755 if (widget.caps_.can_send_unsol()) {
756 RUN_COMMAND_LIST(widget.unsol_resp_ctrl_, widget.nid_,
759 widget.nid_);
768 zx_status_t IntelHDACodec::ReadConnList(AudioWidgetState& widget) {
772 ZX_DEBUG_ASSERT(widget.conn_list_len_ > 0);
773 ZX_DEBUG_ASSERT(widget.conn_list_ != nullptr);
776 while (i < widget.conn_list_len_) {
777 res = DoCodecCmd(widget.nid_, GET_CONNECTION_LIST_ENTRY(static_cast<uint8_t>(i)), &resp);
780 i, widget.nid_, res);
785 // connection widget.conn_list_ entries.
786 if (widget.long_form_conn_list_) {
787 for (size_t j = 0; (j < 2) && (i < widget.conn_list_len_); j++, i++) {
789 widget.conn_list_[i].range_ = (raw & 0x8000u) != 0;
790 widget.conn_list_[i].nid_ = (raw & 0x7FFFu);
794 for (size_t j = 0; (j < 4) && (i < widget.conn_list_len_); j++, i++) {
796 widget.conn_list_[i].range_ = (raw & 0x80u) != 0;
797 widget.conn_list_[i].nid_ = (raw & 0x7Fu);
803 // Sanity check the widget.conn_list_.
804 for (i = 0; i < widget.conn_list_len_; ++i) {
805 if (widget.conn_list_[i].range_ && (!i || widget.conn_list_[i-1].range_)) {
806 printf("Invalid connection widget.conn_list_ entry [nid, ndx] = [%hu, %zu]. "
807 "Range end may not be the first entry in the connection widget.conn_list_, "
809 widget.nid_, i);
817 // same as the first entry in the list, or this is a mixer widget in which
819 if (widget.caps_.type() != AudioWidgetCaps::Type::MIXER) {
820 if (widget.conn_list_len_ == 1) {
821 widget.connected_nid_ = widget.conn_list_[0].nid_;
822 widget.connected_nid_ndx_ = 0;
825 res = DoCodecCmd(widget.nid_, GET_CONNECTION_SELECT_CONTROL, &resp);
828 widget.nid_, res);
832 widget.connected_nid_ndx_ = static_cast<uint8_t>(resp.data & 0xFF);
833 widget.connected_nid_ = (widget.connected_nid_ndx_ < widget.conn_list_len_)
834 ? widget.conn_list_[widget.connected_nid_ndx_].nid_
838 widget.connected_nid_ = 0;
839 widget.connected_nid_ndx_ = 0;