Lines Matching full:inst
127 struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_aics_state() local
129 LOG_DBG("gain %d, mute %u, gain_mode %u, counter %u", inst->srv.state.gain, in read_aics_state()
130 inst->srv.state.mute, inst->srv.state.gain_mode, inst->srv.state.change_counter); in read_aics_state()
132 return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->srv.state, in read_aics_state()
133 sizeof(inst->srv.state)); in read_aics_state()
140 struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_aics_gain_settings() local
142 LOG_DBG("units %u, min %d, max %d", inst->srv.gain_settings.units, in read_aics_gain_settings()
143 inst->srv.gain_settings.minimum, inst->srv.gain_settings.maximum); in read_aics_gain_settings()
146 &inst->srv.gain_settings, in read_aics_gain_settings()
147 sizeof(inst->srv.gain_settings)); in read_aics_gain_settings()
153 struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_type() local
155 LOG_DBG("%u", inst->srv.type); in read_type()
157 return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->srv.type, in read_type()
158 sizeof(inst->srv.type)); in read_type()
171 struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_input_status() local
173 LOG_DBG("%u", inst->srv.status); in read_input_status()
175 return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->srv.status, in read_input_status()
176 sizeof(inst->srv.status)); in read_input_status()
193 static void notify_work_reschedule(struct bt_aics *inst, enum bt_aics_notify notify, in notify_work_reschedule() argument
198 atomic_set_bit(inst->srv.notify, notify); in notify_work_reschedule()
200 err = k_work_reschedule(&inst->srv.notify_work, K_NO_WAIT); in notify_work_reschedule()
207 static void notify(struct bt_aics *inst, enum bt_aics_notify notify, const struct bt_uuid *uuid, in notify() argument
212 err = bt_gatt_notify_uuid(NULL, uuid, inst->srv.service_p->attrs, data, len); in notify()
214 notify_work_reschedule(inst, notify, K_USEC(BT_AUDIO_NOTIFY_RETRY_DELAY_US)); in notify()
223 struct bt_aics *inst = CONTAINER_OF(d_work, struct bt_aics, srv.notify_work); in notify_work_handler() local
225 if (atomic_test_and_clear_bit(inst->srv.notify, AICS_NOTIFY_STATE)) { in notify_work_handler()
226 notify(inst, AICS_NOTIFY_STATE, BT_UUID_AICS_STATE, &inst->srv.state, in notify_work_handler()
227 sizeof(inst->srv.state)); in notify_work_handler()
230 if (atomic_test_and_clear_bit(inst->srv.notify, AICS_NOTIFY_DESCRIPTION)) { in notify_work_handler()
231 notify(inst, AICS_NOTIFY_DESCRIPTION, BT_UUID_AICS_DESCRIPTION, in notify_work_handler()
232 &inst->srv.description, strlen(inst->srv.description)); in notify_work_handler()
235 if (atomic_test_and_clear_bit(inst->srv.notify, AICS_NOTIFY_STATUS)) { in notify_work_handler()
236 notify(inst, AICS_NOTIFY_STATUS, BT_UUID_AICS_INPUT_STATUS, &inst->srv.status, in notify_work_handler()
237 sizeof(inst->srv.status)); in notify_work_handler()
241 static void value_changed(struct bt_aics *inst, enum bt_aics_notify notify) in value_changed() argument
243 notify_work_reschedule(inst, notify, K_NO_WAIT); in value_changed()
254 struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); in write_aics_control() local
279 if (cp->cp.counter != inst->srv.state.change_counter) { in write_aics_control()
286 if (cp->gain_setting < inst->srv.gain_settings.minimum || in write_aics_control()
287 cp->gain_setting > inst->srv.gain_settings.maximum) { in write_aics_control()
290 if (BT_AICS_INPUT_MODE_SETTABLE(inst->srv.state.gain_mode) && in write_aics_control()
291 inst->srv.state.gain != cp->gain_setting) { in write_aics_control()
292 inst->srv.state.gain = cp->gain_setting; in write_aics_control()
298 if (inst->srv.state.mute == BT_AICS_STATE_MUTE_DISABLED) { in write_aics_control()
301 if (inst->srv.state.mute != BT_AICS_STATE_UNMUTED) { in write_aics_control()
302 inst->srv.state.mute = BT_AICS_STATE_UNMUTED; in write_aics_control()
308 if (inst->srv.state.mute == BT_AICS_STATE_MUTE_DISABLED) { in write_aics_control()
311 if (inst->srv.state.mute != BT_AICS_STATE_MUTED) { in write_aics_control()
312 inst->srv.state.mute = BT_AICS_STATE_MUTED; in write_aics_control()
318 if (BT_AICS_INPUT_MODE_IMMUTABLE(inst->srv.state.gain_mode)) { in write_aics_control()
321 if (inst->srv.state.gain_mode != BT_AICS_MODE_MANUAL) { in write_aics_control()
322 inst->srv.state.gain_mode = BT_AICS_MODE_MANUAL; in write_aics_control()
328 if (BT_AICS_INPUT_MODE_IMMUTABLE(inst->srv.state.gain_mode)) { in write_aics_control()
331 if (inst->srv.state.gain_mode != BT_AICS_MODE_AUTO) { in write_aics_control()
332 inst->srv.state.gain_mode = BT_AICS_MODE_AUTO; in write_aics_control()
341 inst->srv.state.change_counter++; in write_aics_control()
344 inst->srv.state.gain, inst->srv.state.mute, inst->srv.state.gain_mode, in write_aics_control()
345 inst->srv.state.change_counter); in write_aics_control()
347 value_changed(inst, AICS_NOTIFY_STATE); in write_aics_control()
349 if (inst->srv.cb && inst->srv.cb->state) { in write_aics_control()
350 inst->srv.cb->state(inst, 0, inst->srv.state.gain, in write_aics_control()
351 inst->srv.state.mute, in write_aics_control()
352 inst->srv.state.gain_mode); in write_aics_control()
354 LOG_DBG("Callback not registered for instance %p", inst); in write_aics_control()
374 struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); in write_description() local
376 if (len >= sizeof(inst->srv.description)) { in write_description()
378 sizeof(inst->srv.description) - 1); in write_description()
380 len = (uint16_t)sizeof(inst->srv.description) - 1; in write_description()
383 if (memcmp(buf, inst->srv.description, len)) { in write_description()
384 memcpy(inst->srv.description, buf, len); in write_description()
385 inst->srv.description[len] = '\0'; in write_description()
387 value_changed(inst, AICS_NOTIFY_DESCRIPTION); in write_description()
389 if (inst->srv.cb && inst->srv.cb->description) { in write_description()
390 inst->srv.cb->description(inst, 0, in write_description()
391 inst->srv.description); in write_description()
393 LOG_DBG("Callback not registered for instance %p", inst); in write_description()
397 LOG_DBG("%s", inst->srv.description); in write_description()
402 static int aics_write(struct bt_aics *inst, in aics_write() argument
410 .user_data = inst, in aics_write()
430 struct bt_aics *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_description() local
432 LOG_DBG("%s", inst->srv.description); in read_description()
435 &inst->srv.description, strlen(inst->srv.description)); in read_description()
582 int bt_aics_deactivate(struct bt_aics *inst) in bt_aics_deactivate() argument
584 CHECKIF(!inst) { in bt_aics_deactivate()
589 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_deactivate()
593 if (inst->srv.status == BT_AICS_STATUS_ACTIVE) { in bt_aics_deactivate()
594 inst->srv.status = BT_AICS_STATUS_INACTIVE; in bt_aics_deactivate()
595 LOG_DBG("Instance %p: Status was set to inactive", inst); in bt_aics_deactivate()
597 value_changed(inst, AICS_NOTIFY_STATUS); in bt_aics_deactivate()
599 if (inst->srv.cb && inst->srv.cb->status) { in bt_aics_deactivate()
600 inst->srv.cb->status(inst, 0, inst->srv.status); in bt_aics_deactivate()
602 LOG_DBG("Callback not registered for instance %p", inst); in bt_aics_deactivate()
609 int bt_aics_activate(struct bt_aics *inst) in bt_aics_activate() argument
611 CHECKIF(!inst) { in bt_aics_activate()
616 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_activate()
620 if (inst->srv.status == BT_AICS_STATUS_INACTIVE) { in bt_aics_activate()
621 inst->srv.status = BT_AICS_STATUS_ACTIVE; in bt_aics_activate()
622 LOG_DBG("Instance %p: Status was set to active", inst); in bt_aics_activate()
624 value_changed(inst, AICS_NOTIFY_STATUS); in bt_aics_activate()
626 if (inst->srv.cb && inst->srv.cb->status) { in bt_aics_activate()
627 inst->srv.cb->status(inst, 0, inst->srv.status); in bt_aics_activate()
629 LOG_DBG("Callback not registered for instance %p", inst); in bt_aics_activate()
637 int bt_aics_gain_set_manual_only(struct bt_aics *inst) in bt_aics_gain_set_manual_only() argument
639 CHECKIF(!inst) { in bt_aics_gain_set_manual_only()
644 inst->srv.state.gain_mode = BT_AICS_MODE_MANUAL_ONLY; in bt_aics_gain_set_manual_only()
646 value_changed(inst, AICS_NOTIFY_STATE); in bt_aics_gain_set_manual_only()
651 int bt_aics_gain_set_auto_only(struct bt_aics *inst) in bt_aics_gain_set_auto_only() argument
653 CHECKIF(!inst) { in bt_aics_gain_set_auto_only()
658 inst->srv.state.gain_mode = BT_AICS_MODE_AUTO_ONLY; in bt_aics_gain_set_auto_only()
660 value_changed(inst, AICS_NOTIFY_STATE); in bt_aics_gain_set_auto_only()
665 int bt_aics_state_get(struct bt_aics *inst) in bt_aics_state_get() argument
667 CHECKIF(!inst) { in bt_aics_state_get()
672 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_state_get()
673 return bt_aics_client_state_get(inst); in bt_aics_state_get()
674 } else if (IS_ENABLED(CONFIG_BT_AICS) && !inst->client_instance) { in bt_aics_state_get()
675 if (inst->srv.cb && inst->srv.cb->state) { in bt_aics_state_get()
676 inst->srv.cb->state(inst, 0, inst->srv.state.gain, in bt_aics_state_get()
677 inst->srv.state.mute, in bt_aics_state_get()
678 inst->srv.state.gain_mode); in bt_aics_state_get()
680 LOG_DBG("Callback not registered for instance %p", inst); in bt_aics_state_get()
688 int bt_aics_gain_setting_get(struct bt_aics *inst) in bt_aics_gain_setting_get() argument
690 CHECKIF(!inst) { in bt_aics_gain_setting_get()
695 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_gain_setting_get()
696 return bt_aics_client_gain_setting_get(inst); in bt_aics_gain_setting_get()
697 } else if (IS_ENABLED(CONFIG_BT_AICS) && !inst->client_instance) { in bt_aics_gain_setting_get()
698 if (inst->srv.cb && inst->srv.cb->gain_setting) { in bt_aics_gain_setting_get()
699 inst->srv.cb->gain_setting(inst, 0, in bt_aics_gain_setting_get()
700 inst->srv.gain_settings.units, in bt_aics_gain_setting_get()
701 inst->srv.gain_settings.minimum, in bt_aics_gain_setting_get()
702 inst->srv.gain_settings.maximum); in bt_aics_gain_setting_get()
704 LOG_DBG("Callback not registered for instance %p", inst); in bt_aics_gain_setting_get()
712 int bt_aics_type_get(struct bt_aics *inst) in bt_aics_type_get() argument
714 CHECKIF(!inst) { in bt_aics_type_get()
719 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_type_get()
720 return bt_aics_client_type_get(inst); in bt_aics_type_get()
721 } else if (IS_ENABLED(CONFIG_BT_AICS) && !inst->client_instance) { in bt_aics_type_get()
722 if (inst->srv.cb && inst->srv.cb->type) { in bt_aics_type_get()
723 inst->srv.cb->type(inst, 0, inst->srv.type); in bt_aics_type_get()
725 LOG_DBG("Callback not registered for instance %p", inst); in bt_aics_type_get()
733 int bt_aics_status_get(struct bt_aics *inst) in bt_aics_status_get() argument
735 CHECKIF(!inst) { in bt_aics_status_get()
740 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_status_get()
741 return bt_aics_client_status_get(inst); in bt_aics_status_get()
742 } else if (IS_ENABLED(CONFIG_BT_AICS) && !inst->client_instance) { in bt_aics_status_get()
743 if (inst->srv.cb && inst->srv.cb->status) { in bt_aics_status_get()
744 inst->srv.cb->status(inst, 0, inst->srv.status); in bt_aics_status_get()
746 LOG_DBG("Callback not registered for instance %p", inst); in bt_aics_status_get()
754 int bt_aics_disable_mute(struct bt_aics *inst) in bt_aics_disable_mute() argument
756 CHECKIF(!inst) { in bt_aics_disable_mute()
761 inst->srv.state.mute = BT_AICS_STATE_MUTE_DISABLED; in bt_aics_disable_mute()
763 value_changed(inst, AICS_NOTIFY_STATE); in bt_aics_disable_mute()
768 int bt_aics_unmute(struct bt_aics *inst) in bt_aics_unmute() argument
770 CHECKIF(!inst) { in bt_aics_unmute()
775 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_unmute()
776 return bt_aics_client_unmute(inst); in bt_aics_unmute()
777 } else if (IS_ENABLED(CONFIG_BT_AICS) && !inst->client_instance) { in bt_aics_unmute()
781 cp.counter = inst->srv.state.change_counter; in bt_aics_unmute()
783 return aics_write(inst, write_aics_control, &cp, sizeof(cp)); in bt_aics_unmute()
789 int bt_aics_mute(struct bt_aics *inst) in bt_aics_mute() argument
791 CHECKIF(!inst) { in bt_aics_mute()
796 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_mute()
797 return bt_aics_client_mute(inst); in bt_aics_mute()
798 } else if (IS_ENABLED(CONFIG_BT_AICS) && !inst->client_instance) { in bt_aics_mute()
802 cp.counter = inst->srv.state.change_counter; in bt_aics_mute()
804 return aics_write(inst, write_aics_control, &cp, sizeof(cp)); in bt_aics_mute()
810 int bt_aics_manual_gain_set(struct bt_aics *inst) in bt_aics_manual_gain_set() argument
812 CHECKIF(!inst) { in bt_aics_manual_gain_set()
817 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_manual_gain_set()
818 return bt_aics_client_manual_gain_set(inst); in bt_aics_manual_gain_set()
819 } else if (IS_ENABLED(CONFIG_BT_AICS) && !inst->client_instance) { in bt_aics_manual_gain_set()
823 cp.counter = inst->srv.state.change_counter; in bt_aics_manual_gain_set()
825 return aics_write(inst, write_aics_control, &cp, sizeof(cp)); in bt_aics_manual_gain_set()
831 int bt_aics_automatic_gain_set(struct bt_aics *inst) in bt_aics_automatic_gain_set() argument
833 CHECKIF(!inst) { in bt_aics_automatic_gain_set()
838 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_automatic_gain_set()
839 return bt_aics_client_automatic_gain_set(inst); in bt_aics_automatic_gain_set()
840 } else if (IS_ENABLED(CONFIG_BT_AICS) && !inst->client_instance) { in bt_aics_automatic_gain_set()
844 cp.counter = inst->srv.state.change_counter; in bt_aics_automatic_gain_set()
846 return aics_write(inst, write_aics_control, &cp, sizeof(cp)); in bt_aics_automatic_gain_set()
852 int bt_aics_gain_set(struct bt_aics *inst, int8_t gain) in bt_aics_gain_set() argument
854 CHECKIF(!inst) { in bt_aics_gain_set()
859 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_gain_set()
860 return bt_aics_client_gain_set(inst, gain); in bt_aics_gain_set()
861 } else if (IS_ENABLED(CONFIG_BT_AICS) && !inst->client_instance) { in bt_aics_gain_set()
865 cp.cp.counter = inst->srv.state.change_counter; in bt_aics_gain_set()
868 return aics_write(inst, write_aics_control, &cp, sizeof(cp)); in bt_aics_gain_set()
874 int bt_aics_description_get(struct bt_aics *inst) in bt_aics_description_get() argument
876 CHECKIF(!inst) { in bt_aics_description_get()
881 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_description_get()
882 return bt_aics_client_description_get(inst); in bt_aics_description_get()
883 } else if (IS_ENABLED(CONFIG_BT_AICS) && !inst->client_instance) { in bt_aics_description_get()
884 if (inst->srv.cb && inst->srv.cb->description) { in bt_aics_description_get()
885 inst->srv.cb->description(inst, 0, in bt_aics_description_get()
886 inst->srv.description); in bt_aics_description_get()
888 LOG_DBG("Callback not registered for instance %p", inst); in bt_aics_description_get()
896 int bt_aics_description_set(struct bt_aics *inst, const char *description) in bt_aics_description_set() argument
898 CHECKIF(!inst) { in bt_aics_description_set()
908 if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) && inst->client_instance) { in bt_aics_description_set()
909 return bt_aics_client_description_set(inst, description); in bt_aics_description_set()
910 } else if (IS_ENABLED(CONFIG_BT_AICS) && !inst->client_instance) { in bt_aics_description_set()
911 return aics_write(inst, write_description, description, strlen(description)); in bt_aics_description_set()