Lines Matching refs:srv

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()
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()
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()
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()
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()
212 err = bt_gatt_notify_uuid(NULL, uuid, inst->srv.service_p->attrs, data, len); in notify()
223 struct bt_aics *inst = CONTAINER_OF(d_work, struct bt_aics, srv.notify_work); in notify_work_handler()
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()
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()
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()
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()
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()
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()
397 LOG_DBG("%s", inst->srv.description); in write_description()
432 LOG_DBG("%s", inst->srv.description); in read_description()
435 &inst->srv.description, strlen(inst->srv.description)); in read_description()
446 return aics->srv.service_p->attrs; in bt_aics_svc_decl_get()
452 aics_insts[i].srv.service_p = &aics_service_list[i]; in prepare_aics_instances()
476 CHECKIF(aics->srv.initialized) { in bt_aics_register()
513 aics->srv.state.gain = param->gain; in bt_aics_register()
514 aics->srv.state.mute = param->mute; in bt_aics_register()
515 aics->srv.state.gain_mode = param->gain_mode; in bt_aics_register()
516 aics->srv.gain_settings.units = param->units; in bt_aics_register()
517 aics->srv.gain_settings.minimum = param->min_gain; in bt_aics_register()
518 aics->srv.gain_settings.maximum = param->max_gain; in bt_aics_register()
519 aics->srv.type = param->type; in bt_aics_register()
520 aics->srv.status = param->status ? BT_AICS_STATUS_ACTIVE : BT_AICS_STATUS_INACTIVE; in bt_aics_register()
521 aics->srv.cb = param->cb; in bt_aics_register()
523 atomic_clear(aics->srv.notify); in bt_aics_register()
524 k_work_init_delayable(&aics->srv.notify_work, notify_work_handler); in bt_aics_register()
527 (void)utf8_lcpy(aics->srv.description, param->description, in bt_aics_register()
528 sizeof(aics->srv.description)); in bt_aics_register()
530 strcmp(aics->srv.description, param->description)) { in bt_aics_register()
531 LOG_DBG("Input desc clipped to %s", aics->srv.description); in bt_aics_register()
543 for (int i = 1; i < aics->srv.service_p->attr_count; i++) { in bt_aics_register()
546 attr = &aics->srv.service_p->attrs[i]; in bt_aics_register()
552 chrc = aics->srv.service_p->attrs[i - 1].user_data; in bt_aics_register()
561 err = bt_gatt_service_register(aics->srv.service_p); in bt_aics_register()
567 aics->srv.initialized = true; in bt_aics_register()
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()
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()
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()
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()
644 inst->srv.state.gain_mode = BT_AICS_MODE_MANUAL_ONLY; in bt_aics_gain_set_manual_only()
658 inst->srv.state.gain_mode = BT_AICS_MODE_AUTO_ONLY; in bt_aics_gain_set_auto_only()
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()
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()
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()
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()
761 inst->srv.state.mute = BT_AICS_STATE_MUTE_DISABLED; in bt_aics_disable_mute()
781 cp.counter = inst->srv.state.change_counter; in bt_aics_unmute()
802 cp.counter = inst->srv.state.change_counter; in bt_aics_mute()
823 cp.counter = inst->srv.state.change_counter; in bt_aics_manual_gain_set()
844 cp.counter = inst->srv.state.change_counter; in bt_aics_automatic_gain_set()
865 cp.cp.counter = inst->srv.state.change_counter; in bt_aics_gain_set()
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()