^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include "hpi_internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include "hpimsginit.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include "hpidebug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) struct hpi_handle {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) unsigned int obj_index:12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) unsigned int obj_type:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) unsigned int adapter_index:14;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) unsigned int spare:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) unsigned int read_only:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) union handle_word {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct hpi_handle h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) u32 w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) const u16 object_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) union handle_word handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) handle.h.adapter_index = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) handle.h.spare = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) handle.h.read_only = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) handle.h.obj_type = c_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) handle.h.obj_index = object_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) return handle.w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static u16 hpi_handle_indexes(const u32 h, u16 *p1, u16 *p2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) union handle_word uhandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) if (!h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) uhandle.w = h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *p1 = (u16)uhandle.h.adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) if (p2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) *p2 = (u16)uhandle.h.obj_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) u16 *pw_object_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) hpi_handle_indexes(handle, pw_adapter_index, pw_object_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) char hpi_handle_object(const u32 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) union handle_word uhandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) uhandle.w = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) return (char)uhandle.h.obj_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) void hpi_format_to_msg(struct hpi_msg_format *pMF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) const struct hpi_format *pF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) pMF->sample_rate = pF->sample_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) pMF->bit_rate = pF->bit_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) pMF->attributes = pF->attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) pMF->channels = pF->channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) pMF->format = pF->format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static void hpi_msg_to_format(struct hpi_format *pF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct hpi_msg_format *pMF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) pF->sample_rate = pMF->sample_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) pF->bit_rate = pMF->bit_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) pF->attributes = pMF->attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) pF->channels = pMF->channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) pF->format = pMF->format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) pF->mode_legacy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) pF->unused = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) pSR->u.legacy_stream_info.auxiliary_data_available =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) pSR->u.stream_info.auxiliary_data_available;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) pSR->u.legacy_stream_info.state = pSR->u.stream_info.state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) static inline void hpi_send_recvV1(struct hpi_message_header *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct hpi_response_header *r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) hpi_send_recv((struct hpi_message *)m, (struct hpi_response *)r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) u16 hpi_subsys_get_version_ex(u32 *pversion_ex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) HPI_SUBSYS_GET_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) *pversion_ex = hr.u.s.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) u16 hpi_subsys_get_num_adapters(int *pn_num_adapters)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) HPI_SUBSYS_GET_NUM_ADAPTERS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) *pn_num_adapters = (int)hr.u.s.num_adapters;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) u16 hpi_subsys_get_adapter(int iterator, u32 *padapter_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) u16 *pw_adapter_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) HPI_SUBSYS_GET_ADAPTER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) hm.obj_index = (u16)iterator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) *padapter_index = (int)hr.u.s.adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) *pw_adapter_type = hr.u.s.adapter_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) u16 hpi_adapter_open(u16 adapter_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) HPI_ADAPTER_OPEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) hm.adapter_index = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) u16 hpi_adapter_close(u16 adapter_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) HPI_ADAPTER_CLOSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) hm.adapter_index = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) u16 hpi_adapter_set_mode(u16 adapter_index, u32 adapter_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) return hpi_adapter_set_mode_ex(adapter_index, adapter_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) HPI_ADAPTER_MODE_SET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) u16 hpi_adapter_set_mode_ex(u16 adapter_index, u32 adapter_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) u16 query_or_set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) HPI_ADAPTER_SET_MODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) hm.adapter_index = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) hm.u.ax.mode.adapter_mode = adapter_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) hm.u.ax.mode.query_or_set = query_or_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) u16 hpi_adapter_get_mode(u16 adapter_index, u32 *padapter_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) HPI_ADAPTER_GET_MODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) hm.adapter_index = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if (padapter_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) *padapter_mode = hr.u.ax.mode.adapter_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) u16 hpi_adapter_get_info(u16 adapter_index, u16 *pw_num_outstreams,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) u16 *pw_num_instreams, u16 *pw_version, u32 *pserial_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) u16 *pw_adapter_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) HPI_ADAPTER_GET_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) hm.adapter_index = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) *pw_adapter_type = hr.u.ax.info.adapter_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) *pw_num_outstreams = hr.u.ax.info.num_outstreams;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) *pw_num_instreams = hr.u.ax.info.num_instreams;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) *pw_version = hr.u.ax.info.version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) *pserial_number = hr.u.ax.info.serial_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) u16 hpi_adapter_get_module_by_index(u16 adapter_index, u16 module_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) u16 *pw_num_outputs, u16 *pw_num_inputs, u16 *pw_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) u32 *pserial_number, u16 *pw_module_type, u32 *ph_module)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) HPI_ADAPTER_MODULE_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) hm.adapter_index = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) hm.u.ax.module_info.index = module_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) *pw_module_type = hr.u.ax.info.adapter_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) *pw_num_outputs = hr.u.ax.info.num_outstreams;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) *pw_num_inputs = hr.u.ax.info.num_instreams;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) *pw_version = hr.u.ax.info.version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) *pserial_number = hr.u.ax.info.serial_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) *ph_module = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) u16 hpi_adapter_set_property(u16 adapter_index, u16 property, u16 parameter1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) u16 parameter2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) HPI_ADAPTER_SET_PROPERTY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) hm.adapter_index = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) hm.u.ax.property_set.property = property;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) hm.u.ax.property_set.parameter1 = parameter1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) hm.u.ax.property_set.parameter2 = parameter2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) u16 hpi_adapter_get_property(u16 adapter_index, u16 property,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) u16 *pw_parameter1, u16 *pw_parameter2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) HPI_ADAPTER_GET_PROPERTY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) hm.adapter_index = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) hm.u.ax.property_set.property = property;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) if (!hr.error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) if (pw_parameter1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) *pw_parameter1 = hr.u.ax.property_get.parameter1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) if (pw_parameter2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) *pw_parameter2 = hr.u.ax.property_get.parameter2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) u16 hpi_adapter_enumerate_property(u16 adapter_index, u16 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) u16 what_to_enumerate, u16 property_index, u32 *psetting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) u32 sample_rate, u32 bit_rate, u32 attributes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) u16 err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct hpi_msg_format fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) switch (channels) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) case 4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) case 6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) case 8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) case 16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) err = HPI_ERROR_INVALID_CHANNELS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) fmt.channels = channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) switch (format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) case HPI_FORMAT_PCM16_SIGNED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) case HPI_FORMAT_PCM24_SIGNED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) case HPI_FORMAT_PCM32_SIGNED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) case HPI_FORMAT_PCM32_FLOAT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) case HPI_FORMAT_PCM16_BIGENDIAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) case HPI_FORMAT_PCM8_UNSIGNED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) case HPI_FORMAT_MPEG_L1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) case HPI_FORMAT_MPEG_L2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) case HPI_FORMAT_MPEG_L3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) case HPI_FORMAT_DOLBY_AC2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) case HPI_FORMAT_AA_TAGIT1_HITS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) case HPI_FORMAT_AA_TAGIT1_INSERTS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) case HPI_FORMAT_RAW_BITSTREAM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) case HPI_FORMAT_AA_TAGIT1_HITS_EX1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) case HPI_FORMAT_OEM1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) case HPI_FORMAT_OEM2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) err = HPI_ERROR_INVALID_FORMAT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) fmt.format = format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) if (sample_rate < 8000L) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) err = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) sample_rate = 8000L;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) if (sample_rate > 200000L) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) err = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) sample_rate = 200000L;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) fmt.sample_rate = sample_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) switch (format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) case HPI_FORMAT_MPEG_L1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) case HPI_FORMAT_MPEG_L2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) case HPI_FORMAT_MPEG_L3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) fmt.bit_rate = bit_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) case HPI_FORMAT_PCM16_SIGNED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) case HPI_FORMAT_PCM16_BIGENDIAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) fmt.bit_rate = channels * sample_rate * 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) case HPI_FORMAT_PCM32_SIGNED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) case HPI_FORMAT_PCM32_FLOAT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) fmt.bit_rate = channels * sample_rate * 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) case HPI_FORMAT_PCM8_UNSIGNED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) fmt.bit_rate = channels * sample_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) fmt.bit_rate = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) switch (format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) case HPI_FORMAT_MPEG_L2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) if ((channels == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) && (attributes != HPI_MPEG_MODE_DEFAULT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) attributes = HPI_MPEG_MODE_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) err = HPI_ERROR_INVALID_FORMAT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) } else if (attributes > HPI_MPEG_MODE_DUALCHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) attributes = HPI_MPEG_MODE_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) err = HPI_ERROR_INVALID_FORMAT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) fmt.attributes = attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) fmt.attributes = attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) hpi_msg_to_format(p_format, &fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) u32 host_polling_rate_in_milli_seconds, u32 *recommended_buffer_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) u32 bytes_per_second;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) u32 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) u16 channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) struct hpi_format *pF = p_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) channels = pF->channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) switch (pF->format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) case HPI_FORMAT_PCM16_BIGENDIAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) case HPI_FORMAT_PCM16_SIGNED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) bytes_per_second = pF->sample_rate * 2L * channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) case HPI_FORMAT_PCM24_SIGNED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) bytes_per_second = pF->sample_rate * 3L * channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) case HPI_FORMAT_PCM32_SIGNED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) case HPI_FORMAT_PCM32_FLOAT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) bytes_per_second = pF->sample_rate * 4L * channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) case HPI_FORMAT_PCM8_UNSIGNED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) bytes_per_second = pF->sample_rate * 1L * channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) case HPI_FORMAT_MPEG_L1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) case HPI_FORMAT_MPEG_L2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) case HPI_FORMAT_MPEG_L3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) bytes_per_second = pF->bit_rate / 8L;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) case HPI_FORMAT_DOLBY_AC2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) bytes_per_second = 256000L / 8L;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) return HPI_ERROR_INVALID_FORMAT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) size = (bytes_per_second * host_polling_rate_in_milli_seconds * 2) /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 1000L;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) *recommended_buffer_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) roundup_pow_of_two(((size + 4095L) & ~4095L));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) u16 hpi_outstream_open(u16 adapter_index, u16 outstream_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) u32 *ph_outstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) HPI_OSTREAM_OPEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) hm.adapter_index = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) hm.obj_index = outstream_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if (hr.error == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) *ph_outstream =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) hpi_indexes_to_handle(HPI_OBJ_OSTREAM, adapter_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) outstream_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) *ph_outstream = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) u16 hpi_outstream_close(u32 h_outstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) HPI_OSTREAM_HOSTBUFFER_FREE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) HPI_OSTREAM_GROUP_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) HPI_OSTREAM_CLOSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) u16 hpi_outstream_get_info_ex(u32 h_outstream, u16 *pw_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) u32 *pbuffer_size, u32 *pdata_to_play, u32 *psamples_played,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) u32 *pauxiliary_data_to_play)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) HPI_OSTREAM_GET_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) if (pw_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) *pw_state = hr.u.d.u.stream_info.state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) if (pbuffer_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) *pbuffer_size = hr.u.d.u.stream_info.buffer_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) if (pdata_to_play)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) *pdata_to_play = hr.u.d.u.stream_info.data_available;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) if (psamples_played)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) *psamples_played = hr.u.d.u.stream_info.samples_transferred;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) if (pauxiliary_data_to_play)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) *pauxiliary_data_to_play =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) hr.u.d.u.stream_info.auxiliary_data_available;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) u16 hpi_outstream_write_buf(u32 h_outstream, const u8 *pb_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) u32 bytes_to_write, const struct hpi_format *p_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) HPI_OSTREAM_WRITE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) hm.u.d.u.data.pb_data = (u8 *)pb_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) hm.u.d.u.data.data_size = bytes_to_write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) u16 hpi_outstream_start(u32 h_outstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) HPI_OSTREAM_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) u16 hpi_outstream_wait_start(u32 h_outstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) HPI_OSTREAM_WAIT_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) u16 hpi_outstream_stop(u32 h_outstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) HPI_OSTREAM_STOP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) u16 hpi_outstream_sinegen(u32 h_outstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) HPI_OSTREAM_SINEGEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) u16 hpi_outstream_reset(u32 h_outstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) HPI_OSTREAM_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) u16 hpi_outstream_query_format(u32 h_outstream, struct hpi_format *p_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) HPI_OSTREAM_QUERY_FORMAT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) u16 hpi_outstream_set_format(u32 h_outstream, struct hpi_format *p_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) HPI_OSTREAM_SET_FORMAT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) u16 hpi_outstream_set_velocity(u32 h_outstream, short velocity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) HPI_OSTREAM_SET_VELOCITY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) hm.u.d.u.velocity = velocity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) u16 hpi_outstream_set_punch_in_out(u32 h_outstream, u32 punch_in_sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) u32 punch_out_sample)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) HPI_OSTREAM_SET_PUNCHINOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) hm.u.d.u.pio.punch_in_sample = punch_in_sample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) hm.u.d.u.pio.punch_out_sample = punch_out_sample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) u16 hpi_outstream_ancillary_reset(u32 h_outstream, u16 mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) HPI_OSTREAM_ANC_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) hm.u.d.u.data.format.channels = mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) u16 hpi_outstream_ancillary_get_info(u32 h_outstream, u32 *pframes_available)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) HPI_OSTREAM_ANC_GET_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) if (hr.error == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) if (pframes_available)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) *pframes_available =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) hr.u.d.u.stream_info.data_available /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) sizeof(struct hpi_anc_frame);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) u16 hpi_outstream_ancillary_read(u32 h_outstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) struct hpi_anc_frame *p_anc_frame_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) u32 anc_frame_buffer_size_in_bytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) u32 number_of_ancillary_frames_to_read)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) HPI_OSTREAM_ANC_READ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) hm.u.d.u.data.data_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) number_of_ancillary_frames_to_read *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) sizeof(struct hpi_anc_frame);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) hr.error = HPI_ERROR_INVALID_DATASIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) u16 hpi_outstream_set_time_scale(u32 h_outstream, u32 time_scale)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) HPI_OSTREAM_SET_TIMESCALE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) hm.u.d.u.time_scale = time_scale;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) u16 hpi_outstream_host_buffer_allocate(u32 h_outstream, u32 size_in_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) HPI_OSTREAM_HOSTBUFFER_ALLOC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) hm.u.d.u.data.data_size = size_in_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) u16 hpi_outstream_host_buffer_get_info(u32 h_outstream, u8 **pp_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) struct hpi_hostbuffer_status **pp_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) HPI_OSTREAM_HOSTBUFFER_GET_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) if (hr.error == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) if (pp_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) *pp_buffer = hr.u.d.u.hostbuffer_info.p_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) if (pp_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) *pp_status = hr.u.d.u.hostbuffer_info.p_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) u16 hpi_outstream_host_buffer_free(u32 h_outstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) HPI_OSTREAM_HOSTBUFFER_FREE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) u16 hpi_outstream_group_add(u32 h_outstream, u32 h_stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) u16 adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) char c_obj_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) HPI_OSTREAM_GROUP_ADD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) if (hpi_handle_indexes(h_stream, &adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) &hm.u.d.u.stream.stream_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) c_obj_type = hpi_handle_object(h_stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) switch (c_obj_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) case HPI_OBJ_OSTREAM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) case HPI_OBJ_ISTREAM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) hm.u.d.u.stream.object_type = c_obj_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) return HPI_ERROR_INVALID_OBJ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) if (adapter != hm.adapter_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) return HPI_ERROR_NO_INTERADAPTER_GROUPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) u16 hpi_outstream_group_get_map(u32 h_outstream, u32 *poutstream_map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) u32 *pinstream_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) HPI_OSTREAM_GROUP_GETMAP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) if (poutstream_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) *poutstream_map = hr.u.d.u.group_info.outstream_group_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) if (pinstream_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) *pinstream_map = hr.u.d.u.group_info.instream_group_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) u16 hpi_outstream_group_reset(u32 h_outstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) HPI_OSTREAM_GROUP_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) u16 hpi_instream_open(u16 adapter_index, u16 instream_index, u32 *ph_instream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) HPI_ISTREAM_OPEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) hm.adapter_index = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) hm.obj_index = instream_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) if (hr.error == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) *ph_instream =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) hpi_indexes_to_handle(HPI_OBJ_ISTREAM, adapter_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) instream_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) *ph_instream = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) u16 hpi_instream_close(u32 h_instream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) HPI_ISTREAM_HOSTBUFFER_FREE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) HPI_ISTREAM_GROUP_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) HPI_ISTREAM_CLOSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) u16 hpi_instream_query_format(u32 h_instream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) const struct hpi_format *p_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) HPI_ISTREAM_QUERY_FORMAT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) u16 hpi_instream_set_format(u32 h_instream, const struct hpi_format *p_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) HPI_ISTREAM_SET_FORMAT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) u16 hpi_instream_read_buf(u32 h_instream, u8 *pb_data, u32 bytes_to_read)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) HPI_ISTREAM_READ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) hm.u.d.u.data.data_size = bytes_to_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) hm.u.d.u.data.pb_data = pb_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) u16 hpi_instream_start(u32 h_instream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) HPI_ISTREAM_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) u16 hpi_instream_wait_start(u32 h_instream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) HPI_ISTREAM_WAIT_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) u16 hpi_instream_stop(u32 h_instream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) HPI_ISTREAM_STOP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) u16 hpi_instream_reset(u32 h_instream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) HPI_ISTREAM_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) u16 hpi_instream_get_info_ex(u32 h_instream, u16 *pw_state, u32 *pbuffer_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) u32 *pdata_recorded, u32 *psamples_recorded,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) u32 *pauxiliary_data_recorded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) HPI_ISTREAM_GET_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) if (pw_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) *pw_state = hr.u.d.u.stream_info.state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) if (pbuffer_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) *pbuffer_size = hr.u.d.u.stream_info.buffer_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) if (pdata_recorded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) *pdata_recorded = hr.u.d.u.stream_info.data_available;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) if (psamples_recorded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) *psamples_recorded = hr.u.d.u.stream_info.samples_transferred;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) if (pauxiliary_data_recorded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) *pauxiliary_data_recorded =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) hr.u.d.u.stream_info.auxiliary_data_available;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) u16 hpi_instream_ancillary_reset(u32 h_instream, u16 bytes_per_frame,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) u16 mode, u16 alignment, u16 idle_bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) HPI_ISTREAM_ANC_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) hm.u.d.u.data.format.attributes = bytes_per_frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) hm.u.d.u.data.format.format = (mode << 8) | (alignment & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) hm.u.d.u.data.format.channels = idle_bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) u16 hpi_instream_ancillary_get_info(u32 h_instream, u32 *pframe_space)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) HPI_ISTREAM_ANC_GET_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) if (pframe_space)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) *pframe_space =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) (hr.u.d.u.stream_info.buffer_size -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) hr.u.d.u.stream_info.data_available) /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) sizeof(struct hpi_anc_frame);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) u16 hpi_instream_ancillary_write(u32 h_instream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) const struct hpi_anc_frame *p_anc_frame_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) u32 anc_frame_buffer_size_in_bytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) u32 number_of_ancillary_frames_to_write)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) HPI_ISTREAM_ANC_WRITE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) hm.u.d.u.data.data_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) number_of_ancillary_frames_to_write *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) sizeof(struct hpi_anc_frame);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) hr.error = HPI_ERROR_INVALID_DATASIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) u16 hpi_instream_host_buffer_allocate(u32 h_instream, u32 size_in_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) HPI_ISTREAM_HOSTBUFFER_ALLOC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) hm.u.d.u.data.data_size = size_in_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) u16 hpi_instream_host_buffer_get_info(u32 h_instream, u8 **pp_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) struct hpi_hostbuffer_status **pp_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) HPI_ISTREAM_HOSTBUFFER_GET_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) if (hr.error == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) if (pp_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) *pp_buffer = hr.u.d.u.hostbuffer_info.p_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) if (pp_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) *pp_status = hr.u.d.u.hostbuffer_info.p_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) u16 hpi_instream_host_buffer_free(u32 h_instream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) HPI_ISTREAM_HOSTBUFFER_FREE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) u16 hpi_instream_group_add(u32 h_instream, u32 h_stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) u16 adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) char c_obj_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) HPI_ISTREAM_GROUP_ADD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) hr.error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) if (hpi_handle_indexes(h_stream, &adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) &hm.u.d.u.stream.stream_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) c_obj_type = hpi_handle_object(h_stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) switch (c_obj_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) case HPI_OBJ_OSTREAM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) case HPI_OBJ_ISTREAM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) hm.u.d.u.stream.object_type = c_obj_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) return HPI_ERROR_INVALID_OBJ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) if (adapter != hm.adapter_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) return HPI_ERROR_NO_INTERADAPTER_GROUPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) u16 hpi_instream_group_get_map(u32 h_instream, u32 *poutstream_map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) u32 *pinstream_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) HPI_ISTREAM_HOSTBUFFER_FREE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) if (poutstream_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) *poutstream_map = hr.u.d.u.group_info.outstream_group_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) if (pinstream_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) *pinstream_map = hr.u.d.u.group_info.instream_group_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) u16 hpi_instream_group_reset(u32 h_instream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) HPI_ISTREAM_GROUP_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) u16 hpi_mixer_open(u16 adapter_index, u32 *ph_mixer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) hm.adapter_index = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) if (hr.error == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) *ph_mixer =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) hpi_indexes_to_handle(HPI_OBJ_MIXER, adapter_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) *ph_mixer = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) u16 hpi_mixer_close(u32 h_mixer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) u16 hpi_mixer_get_control(u32 h_mixer, u16 src_node_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) u16 src_node_type_index, u16 dst_node_type, u16 dst_node_type_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) u16 control_type, u32 *ph_control)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) HPI_MIXER_GET_CONTROL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) hm.u.m.node_type1 = src_node_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) hm.u.m.node_index1 = src_node_type_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) hm.u.m.node_type2 = dst_node_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) hm.u.m.node_index2 = dst_node_type_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) hm.u.m.control_type = control_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) if (hr.error == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) *ph_control =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) hpi_indexes_to_handle(HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) hm.adapter_index, hr.u.m.control_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) *ph_control = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) u16 hpi_mixer_get_control_by_index(u32 h_mixer, u16 control_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) u16 *pw_src_node_type, u16 *pw_src_node_index, u16 *pw_dst_node_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) u16 *pw_dst_node_index, u16 *pw_control_type, u32 *ph_control)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) HPI_MIXER_GET_CONTROL_BY_INDEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) hm.u.m.control_index = control_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) if (pw_src_node_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) *pw_src_node_type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) hr.u.m.src_node_type + HPI_SOURCENODE_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) *pw_src_node_index = hr.u.m.src_node_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) *pw_dst_node_type = hr.u.m.dst_node_type + HPI_DESTNODE_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) *pw_dst_node_index = hr.u.m.dst_node_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) if (pw_control_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) *pw_control_type = hr.u.m.control_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) if (ph_control) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) if (hr.error == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) *ph_control =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) hpi_indexes_to_handle(HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) hm.adapter_index, control_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) *ph_control = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) u16 hpi_mixer_store(u32 h_mixer, enum HPI_MIXER_STORE_COMMAND command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) u16 index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_STORE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) hm.u.mx.store.command = command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) hm.u.mx.store.index = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) static
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) u16 hpi_control_param_set(const u32 h_control, const u16 attrib,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) const u32 param1, const u32 param2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) HPI_CONTROL_SET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) hm.u.c.attribute = attrib;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) hm.u.c.param1 = param1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) hm.u.c.param2 = param2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) static u16 hpi_control_log_set2(u32 h_control, u16 attrib, short sv0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) short sv1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) HPI_CONTROL_SET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) hm.u.c.attribute = attrib;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) hm.u.c.an_log_value[0] = sv0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) hm.u.c.an_log_value[1] = sv1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) static
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) u16 hpi_control_param_get(const u32 h_control, const u16 attrib, u32 param1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) u32 param2, u32 *pparam1, u32 *pparam2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) hm.u.c.attribute = attrib;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) hm.u.c.param1 = param1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) hm.u.c.param2 = param2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) *pparam1 = hr.u.c.param1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) if (pparam2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) *pparam2 = hr.u.c.param2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) #define hpi_control_param1_get(h, a, p1) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) hpi_control_param_get(h, a, 0, 0, p1, NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) #define hpi_control_param2_get(h, a, p1, p2) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) hpi_control_param_get(h, a, 0, 0, p1, p2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) static u16 hpi_control_log_get2(u32 h_control, u16 attrib, short *sv0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) short *sv1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) hm.u.c.attribute = attrib;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) *sv0 = hr.u.c.an_log_value[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) if (sv1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) *sv1 = hr.u.c.an_log_value[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) static
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) u16 hpi_control_query(const u32 h_control, const u16 attrib, const u32 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) const u32 param, u32 *psetting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) HPI_CONTROL_GET_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) hm.u.c.attribute = attrib;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) hm.u.c.param1 = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) hm.u.c.param2 = param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) *psetting = hr.u.c.param1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) char *psz_string, const u32 string_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) unsigned int sub_string_index = 0, j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) char c = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) unsigned int n = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) u16 err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) if ((string_length < 1) || (string_length > 256))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) return HPI_ERROR_INVALID_CONTROL_VALUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) for (sub_string_index = 0; sub_string_index < string_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) sub_string_index += 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) if (hpi_handle_indexes(h_control, &hm.adapter_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) hm.u.c.attribute = attribute;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) hm.u.c.param1 = sub_string_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) hm.u.c.param2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) if (sub_string_index == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) && (hr.u.cu.chars8.remaining_chars + 8) >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) string_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) return HPI_ERROR_INVALID_CONTROL_VALUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) if (hr.error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) err = hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) for (j = 0; j < 8; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) c = hr.u.cu.chars8.sz_data[j];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) psz_string[sub_string_index + j] = c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) n++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) if (n >= string_length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) psz_string[string_length - 1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) err = HPI_ERROR_INVALID_CONTROL_VALUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) if (c == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) if ((hr.u.cu.chars8.remaining_chars == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) && ((sub_string_index + j) < string_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) && (c != 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) c = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) psz_string[sub_string_index + j] = c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) if (c == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) u16 hpi_aesebu_receiver_query_format(const u32 h_aes_rx, const u32 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) u16 *pw_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) u32 qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) err = hpi_control_query(h_aes_rx, HPI_AESEBURX_FORMAT, index, 0, &qr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) *pw_format = (u16)qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) u16 hpi_aesebu_receiver_set_format(u32 h_control, u16 format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) return hpi_control_param_set(h_control, HPI_AESEBURX_FORMAT, format,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) u16 hpi_aesebu_receiver_get_format(u32 h_control, u16 *pw_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) u32 param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) err = hpi_control_param1_get(h_control, HPI_AESEBURX_FORMAT, ¶m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) if (!err && pw_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) *pw_format = (u16)param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) u16 hpi_aesebu_receiver_get_sample_rate(u32 h_control, u32 *psample_rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) return hpi_control_param1_get(h_control, HPI_AESEBURX_SAMPLERATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) psample_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) u16 hpi_aesebu_receiver_get_user_data(u32 h_control, u16 index, u16 *pw_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) hm.u.c.attribute = HPI_AESEBURX_USERDATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) hm.u.c.param1 = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) if (pw_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) *pw_data = (u16)hr.u.c.param2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) u16 hpi_aesebu_receiver_get_channel_status(u32 h_control, u16 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) u16 *pw_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) hm.u.c.attribute = HPI_AESEBURX_CHANNELSTATUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) hm.u.c.param1 = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) if (pw_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) *pw_data = (u16)hr.u.c.param2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) u16 hpi_aesebu_receiver_get_error_status(u32 h_control, u16 *pw_error_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) u32 error_data = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) u16 err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) err = hpi_control_param1_get(h_control, HPI_AESEBURX_ERRORSTATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) &error_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) if (pw_error_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) *pw_error_data = (u16)error_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) u16 hpi_aesebu_transmitter_set_sample_rate(u32 h_control, u32 sample_rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) return hpi_control_param_set(h_control, HPI_AESEBUTX_SAMPLERATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) sample_rate, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) u16 hpi_aesebu_transmitter_set_user_data(u32 h_control, u16 index, u16 data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) return hpi_control_param_set(h_control, HPI_AESEBUTX_USERDATA, index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) u16 hpi_aesebu_transmitter_set_channel_status(u32 h_control, u16 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) u16 data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) return hpi_control_param_set(h_control, HPI_AESEBUTX_CHANNELSTATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) index, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) u16 hpi_aesebu_transmitter_get_channel_status(u32 h_control, u16 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) u16 *pw_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) return HPI_ERROR_INVALID_OPERATION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) u16 hpi_aesebu_transmitter_query_format(const u32 h_aes_tx, const u32 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) u16 *pw_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) u32 qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) err = hpi_control_query(h_aes_tx, HPI_AESEBUTX_FORMAT, index, 0, &qr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) *pw_format = (u16)qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) u16 hpi_aesebu_transmitter_set_format(u32 h_control, u16 output_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) return hpi_control_param_set(h_control, HPI_AESEBUTX_FORMAT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) output_format, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) u16 hpi_aesebu_transmitter_get_format(u32 h_control, u16 *pw_output_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) u32 param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) err = hpi_control_param1_get(h_control, HPI_AESEBUTX_FORMAT, ¶m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) if (!err && pw_output_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) *pw_output_format = (u16)param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) u16 hpi_bitstream_set_clock_edge(u32 h_control, u16 edge_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) return hpi_control_param_set(h_control, HPI_BITSTREAM_CLOCK_EDGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) edge_type, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) u16 hpi_bitstream_set_data_polarity(u32 h_control, u16 polarity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) return hpi_control_param_set(h_control, HPI_BITSTREAM_DATA_POLARITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) polarity, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) u16 hpi_bitstream_get_activity(u32 h_control, u16 *pw_clk_activity,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) u16 *pw_data_activity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) hm.u.c.attribute = HPI_BITSTREAM_ACTIVITY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) if (pw_clk_activity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) *pw_clk_activity = (u16)hr.u.c.param1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) if (pw_data_activity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) *pw_data_activity = (u16)hr.u.c.param2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) u16 hpi_channel_mode_query_mode(const u32 h_mode, const u32 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) u16 *pw_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) u32 qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) err = hpi_control_query(h_mode, HPI_CHANNEL_MODE_MODE, index, 0, &qr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) *pw_mode = (u16)qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) u16 hpi_channel_mode_set(u32 h_control, u16 mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) return hpi_control_param_set(h_control, HPI_CHANNEL_MODE_MODE, mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) u16 hpi_channel_mode_get(u32 h_control, u16 *mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) u32 mode32 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) u16 err = hpi_control_param1_get(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) HPI_CHANNEL_MODE_MODE, &mode32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) if (mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) *mode = (u16)mode32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) u8 *pb_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) struct hpi_msg_cobranet_hmiwrite hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) struct hpi_response_header hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) hpi_init_message_responseV1(&hm.h, sizeof(hm), &hr, sizeof(hr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) if (hpi_handle_indexes(h_control, &hm.h.adapter_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) &hm.h.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) if (byte_count > sizeof(hm.bytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) return HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) hm.p.attribute = HPI_COBRANET_SET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) hm.p.byte_count = byte_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) hm.p.hmi_address = hmi_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) memcpy(hm.bytes, pb_data, byte_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) hm.h.size = (u16)(sizeof(hm.h) + sizeof(hm.p) + byte_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) hpi_send_recvV1(&hm.h, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) u16 hpi_cobranet_hmi_read(u32 h_control, u32 hmi_address, u32 max_byte_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) u32 *pbyte_count, u8 *pb_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) struct hpi_msg_cobranet_hmiread hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) struct hpi_res_cobranet_hmiread hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) hpi_init_message_responseV1(&hm.h, sizeof(hm), &hr.h, sizeof(hr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) if (hpi_handle_indexes(h_control, &hm.h.adapter_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) &hm.h.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) if (max_byte_count > sizeof(hr.bytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) return HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) hm.p.attribute = HPI_COBRANET_GET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) hm.p.byte_count = max_byte_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) hm.p.hmi_address = hmi_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) hpi_send_recvV1(&hm.h, &hr.h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) if (!hr.h.error && pb_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) if (hr.byte_count > sizeof(hr.bytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) return HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) *pbyte_count = hr.byte_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) if (hr.byte_count < max_byte_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) max_byte_count = *pbyte_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) memcpy(pb_data, hr.bytes, max_byte_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) return hr.h.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) u32 *preadable_size, u32 *pwriteable_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) hm.u.c.attribute = HPI_COBRANET_GET_STATUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) if (!hr.error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) if (pstatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) *pstatus = hr.u.cu.cobranet.status.status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) if (preadable_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) *preadable_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) hr.u.cu.cobranet.status.readable_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) if (pwriteable_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) *pwriteable_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) hr.u.cu.cobranet.status.writeable_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) u16 hpi_cobranet_get_ip_address(u32 h_control, u32 *pdw_ip_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) u32 byte_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) u32 iP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) err = hpi_cobranet_hmi_read(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) (u8 *)&iP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) *pdw_ip_address =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) *pdw_ip_address = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) u16 hpi_cobranet_set_ip_address(u32 h_control, u32 dw_ip_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) u32 iP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) 0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) 8) | ((dw_ip_address & 0x000000ff) << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) err = hpi_cobranet_hmi_write(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, (u8 *)&iP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) u16 hpi_cobranet_get_static_ip_address(u32 h_control, u32 *pdw_ip_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) u32 byte_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) u32 iP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) err = hpi_cobranet_hmi_read(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) (u8 *)&iP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) *pdw_ip_address =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) *pdw_ip_address = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) u16 hpi_cobranet_set_static_ip_address(u32 h_control, u32 dw_ip_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) u32 iP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) 0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) 8) | ((dw_ip_address & 0x000000ff) << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) err = hpi_cobranet_hmi_write(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, (u8 *)&iP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *p_mac_msbs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) u32 *p_mac_lsbs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) u32 byte_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) u32 mac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) err = hpi_cobranet_hmi_read(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) (u8 *)&mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) if (!err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) *p_mac_msbs =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) ((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) | ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) err = hpi_cobranet_hmi_read(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) &byte_count, (u8 *)&mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) if (!err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) *p_mac_lsbs =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) ((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) | ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) *p_mac_msbs = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) *p_mac_lsbs = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) u16 hpi_compander_set_enable(u32 h_control, u32 enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) u16 hpi_compander_get_enable(u32 h_control, u32 *enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) u16 hpi_compander_set_makeup_gain(u32 h_control, short makeup_gain0_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) return hpi_control_log_set2(h_control, HPI_COMPANDER_MAKEUPGAIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) makeup_gain0_01dB, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) u16 hpi_compander_get_makeup_gain(u32 h_control, short *makeup_gain0_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) return hpi_control_log_get2(h_control, HPI_COMPANDER_MAKEUPGAIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) makeup_gain0_01dB, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) u16 hpi_compander_set_attack_time_constant(u32 h_control, unsigned int index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) u32 attack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) return hpi_control_param_set(h_control, HPI_COMPANDER_ATTACK, attack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) u16 hpi_compander_get_attack_time_constant(u32 h_control, unsigned int index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) u32 *attack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) return hpi_control_param_get(h_control, HPI_COMPANDER_ATTACK, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) index, attack, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) u16 hpi_compander_set_decay_time_constant(u32 h_control, unsigned int index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) u32 decay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) return hpi_control_param_set(h_control, HPI_COMPANDER_DECAY, decay,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) u16 hpi_compander_get_decay_time_constant(u32 h_control, unsigned int index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) u32 *decay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) return hpi_control_param_get(h_control, HPI_COMPANDER_DECAY, 0, index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) decay, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) u16 hpi_compander_set_threshold(u32 h_control, unsigned int index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) short threshold0_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) HPI_CONTROL_SET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) hm.u.c.param2 = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) hm.u.c.an_log_value[0] = threshold0_01dB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) u16 hpi_compander_get_threshold(u32 h_control, unsigned int index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) short *threshold0_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) hm.u.c.param2 = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) *threshold0_01dB = hr.u.c.an_log_value[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) u16 hpi_compander_set_ratio(u32 h_control, u32 index, u32 ratio100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) return hpi_control_param_set(h_control, HPI_COMPANDER_RATIO, ratio100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) u16 hpi_compander_get_ratio(u32 h_control, u32 index, u32 *ratio100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) return hpi_control_param_get(h_control, HPI_COMPANDER_RATIO, 0, index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) ratio100, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) u16 hpi_level_query_range(u32 h_control, short *min_gain_01dB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) short *max_gain_01dB, short *step_gain_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) hm.u.c.attribute = HPI_LEVEL_RANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) if (hr.error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) hr.u.c.an_log_value[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) hr.u.c.an_log_value[1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) hr.u.c.param1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) if (min_gain_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) *min_gain_01dB = hr.u.c.an_log_value[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) if (max_gain_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) *max_gain_01dB = hr.u.c.an_log_value[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) if (step_gain_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) *step_gain_01dB = (short)hr.u.c.param1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) u16 hpi_level_set_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) return hpi_control_log_set2(h_control, HPI_LEVEL_GAIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) an_gain0_01dB[0], an_gain0_01dB[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) u16 hpi_level_get_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) return hpi_control_log_get2(h_control, HPI_LEVEL_GAIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) &an_gain0_01dB[0], &an_gain0_01dB[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) u16 hpi_meter_query_channels(const u32 h_meter, u32 *p_channels)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) return hpi_control_query(h_meter, HPI_METER_NUM_CHANNELS, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) p_channels);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) u16 hpi_meter_get_peak(u32 h_control, short an_peakdB[HPI_MAX_CHANNELS]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) short i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) hm.obj_index = hm.obj_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) hm.u.c.attribute = HPI_METER_PEAK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) if (!hr.error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) memcpy(an_peakdB, hr.u.c.an_log_value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) sizeof(short) * HPI_MAX_CHANNELS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) for (i = 0; i < HPI_MAX_CHANNELS; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) an_peakdB[i] = HPI_METER_MINIMUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) u16 hpi_meter_get_rms(u32 h_control, short an_rmsdB[HPI_MAX_CHANNELS]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) short i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) hm.u.c.attribute = HPI_METER_RMS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) if (!hr.error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) memcpy(an_rmsdB, hr.u.c.an_log_value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) sizeof(short) * HPI_MAX_CHANNELS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) for (i = 0; i < HPI_MAX_CHANNELS; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) an_rmsdB[i] = HPI_METER_MINIMUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) u16 hpi_meter_set_rms_ballistics(u32 h_control, u16 attack, u16 decay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) return hpi_control_param_set(h_control, HPI_METER_RMS_BALLISTICS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) attack, decay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) u16 hpi_meter_get_rms_ballistics(u32 h_control, u16 *pn_attack, u16 *pn_decay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) u32 attack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) u32 decay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) u16 error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) error = hpi_control_param2_get(h_control, HPI_METER_RMS_BALLISTICS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) &attack, &decay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) if (pn_attack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) *pn_attack = (unsigned short)attack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) if (pn_decay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) *pn_decay = (unsigned short)decay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) u16 hpi_meter_set_peak_ballistics(u32 h_control, u16 attack, u16 decay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) return hpi_control_param_set(h_control, HPI_METER_PEAK_BALLISTICS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) attack, decay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) u16 hpi_meter_get_peak_ballistics(u32 h_control, u16 *pn_attack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) u16 *pn_decay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) u32 attack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) u32 decay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) u16 error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) error = hpi_control_param2_get(h_control, HPI_METER_PEAK_BALLISTICS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) &attack, &decay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) if (pn_attack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) *pn_attack = (short)attack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) if (pn_decay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) *pn_decay = (short)decay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) u16 hpi_microphone_set_phantom_power(u32 h_control, u16 on_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) return hpi_control_param_set(h_control, HPI_MICROPHONE_PHANTOM_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) (u32)on_off, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) u16 hpi_microphone_get_phantom_power(u32 h_control, u16 *pw_on_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) u16 error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) u32 on_off = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) error = hpi_control_param1_get(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) HPI_MICROPHONE_PHANTOM_POWER, &on_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) if (pw_on_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) *pw_on_off = (u16)on_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) u16 hpi_multiplexer_set_source(u32 h_control, u16 source_node_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) u16 source_node_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) return hpi_control_param_set(h_control, HPI_MULTIPLEXER_SOURCE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) source_node_type, source_node_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) u16 hpi_multiplexer_get_source(u32 h_control, u16 *source_node_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) u16 *source_node_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) u32 node, index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) u16 err = hpi_control_param2_get(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) HPI_MULTIPLEXER_SOURCE, &node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) &index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) if (source_node_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) *source_node_type = (u16)node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) if (source_node_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) *source_node_index = (u16)index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) u16 hpi_multiplexer_query_source(u32 h_control, u16 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) u16 *source_node_type, u16 *source_node_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) hm.u.c.attribute = HPI_MULTIPLEXER_QUERYSOURCE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) hm.u.c.param1 = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) if (source_node_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) *source_node_type = (u16)hr.u.c.param1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) if (source_node_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) *source_node_index = (u16)hr.u.c.param2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) u16 hpi_parametric_eq_get_info(u32 h_control, u16 *pw_number_of_bands,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) u16 *pw_on_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) u32 oB = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) u32 oO = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) u16 error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) error = hpi_control_param2_get(h_control, HPI_EQUALIZER_NUM_FILTERS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) &oO, &oB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) if (pw_number_of_bands)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) *pw_number_of_bands = (u16)oB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) if (pw_on_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) *pw_on_off = (u16)oO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) u16 hpi_parametric_eq_set_state(u32 h_control, u16 on_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) return hpi_control_param_set(h_control, HPI_EQUALIZER_NUM_FILTERS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) on_off, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) u16 hpi_parametric_eq_get_band(u32 h_control, u16 index, u16 *pn_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) u32 *pfrequency_hz, short *pnQ100, short *pn_gain0_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) hm.u.c.attribute = HPI_EQUALIZER_FILTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) hm.u.c.param2 = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) if (pfrequency_hz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) *pfrequency_hz = hr.u.c.param1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) if (pn_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) *pn_type = (u16)(hr.u.c.param2 >> 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) if (pnQ100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) *pnQ100 = hr.u.c.an_log_value[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) if (pn_gain0_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) *pn_gain0_01dB = hr.u.c.an_log_value[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) u16 hpi_parametric_eq_set_band(u32 h_control, u16 index, u16 type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) u32 frequency_hz, short q100, short gain0_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) HPI_CONTROL_SET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) hm.u.c.param1 = frequency_hz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) hm.u.c.param2 = (index & 0xFFFFL) + ((u32)type << 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) hm.u.c.an_log_value[0] = gain0_01dB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) hm.u.c.an_log_value[1] = q100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) hm.u.c.attribute = HPI_EQUALIZER_FILTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) u16 hpi_parametric_eq_get_coeffs(u32 h_control, u16 index, short coeffs[5]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) hm.u.c.attribute = HPI_EQUALIZER_COEFFICIENTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) hm.u.c.param2 = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) coeffs[0] = (short)hr.u.c.an_log_value[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) coeffs[1] = (short)hr.u.c.an_log_value[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) coeffs[2] = (short)hr.u.c.param1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) coeffs[3] = (short)(hr.u.c.param1 >> 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) coeffs[4] = (short)hr.u.c.param2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) u16 hpi_sample_clock_query_source(const u32 h_clock, const u32 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) u16 *pw_source)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) u32 qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE, index, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) &qr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) *pw_source = (u16)qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) u16 hpi_sample_clock_set_source(u32 h_control, u16 source)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) source, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) u16 hpi_sample_clock_get_source(u32 h_control, u16 *pw_source)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) u16 err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) u32 source = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) &source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) if (!err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) if (pw_source)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) *pw_source = (u16)source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) u16 hpi_sample_clock_query_source_index(const u32 h_clock, const u32 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) const u32 source, u16 *pw_source_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) u32 qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE_INDEX, index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) source, &qr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) *pw_source_index = (u16)qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) u16 hpi_sample_clock_set_source_index(u32 h_control, u16 source_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) source_index, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) u16 hpi_sample_clock_get_source_index(u32 h_control, u16 *pw_source_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) u16 err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) u32 source_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) &source_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) if (!err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) if (pw_source_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) *pw_source_index = (u16)source_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) u16 hpi_sample_clock_query_local_rate(const u32 h_clock, const u32 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) u32 *prate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) return hpi_control_query(h_clock, HPI_SAMPLECLOCK_LOCAL_SAMPLERATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) index, 0, prate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) u16 hpi_sample_clock_set_local_rate(u32 h_control, u32 sample_rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) return hpi_control_param_set(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, sample_rate, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) u16 hpi_sample_clock_get_local_rate(u32 h_control, u32 *psample_rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) u16 err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) u32 sample_rate = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) err = hpi_control_param1_get(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) if (!err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) if (psample_rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) *psample_rate = sample_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) u16 hpi_sample_clock_get_sample_rate(u32 h_control, u32 *psample_rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) u16 err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) u32 sample_rate = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SAMPLERATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) &sample_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) if (!err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) if (psample_rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) *psample_rate = sample_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) u16 hpi_sample_clock_set_auto(u32 h_control, u32 enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_AUTO, enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) u16 hpi_sample_clock_get_auto(u32 h_control, u32 *penable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_AUTO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) penable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) u16 hpi_sample_clock_set_local_rate_lock(u32 h_control, u32 lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) lock, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) u16 hpi_sample_clock_get_local_rate_lock(u32 h_control, u32 *plock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) plock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) u16 hpi_tone_detector_get_frequency(u32 h_control, u32 index, u32 *frequency)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) return hpi_control_param_get(h_control, HPI_TONEDETECTOR_FREQUENCY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) index, 0, frequency, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) u16 hpi_tone_detector_get_state(u32 h_control, u32 *state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_STATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) u16 hpi_tone_detector_set_enable(u32 h_control, u32 enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) u16 hpi_tone_detector_get_enable(u32 h_control, u32 *enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) u16 hpi_tone_detector_set_event_enable(u32 h_control, u32 event_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) (u32)event_enable, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) u16 hpi_tone_detector_get_event_enable(u32 h_control, u32 *event_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) event_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) u16 hpi_tone_detector_set_threshold(u32 h_control, int threshold)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) return hpi_control_param_set(h_control, HPI_TONEDETECTOR_THRESHOLD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) (u32)threshold, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) u16 hpi_tone_detector_get_threshold(u32 h_control, int *threshold)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_THRESHOLD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) (u32 *)threshold);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) u16 hpi_silence_detector_get_state(u32 h_control, u32 *state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_STATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) u16 hpi_silence_detector_set_enable(u32 h_control, u32 enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) u16 hpi_silence_detector_get_enable(u32 h_control, u32 *enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) u16 hpi_silence_detector_set_event_enable(u32 h_control, u32 event_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) event_enable, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) u16 hpi_silence_detector_get_event_enable(u32 h_control, u32 *event_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) event_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) u16 hpi_silence_detector_set_delay(u32 h_control, u32 delay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_DELAY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) delay, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) u16 hpi_silence_detector_get_delay(u32 h_control, u32 *delay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_DELAY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) u16 hpi_silence_detector_set_threshold(u32 h_control, int threshold)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_THRESHOLD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) threshold, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) u16 hpi_silence_detector_get_threshold(u32 h_control, int *threshold)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) return hpi_control_param1_get(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) HPI_SILENCEDETECTOR_THRESHOLD, (u32 *)threshold);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) u16 hpi_tuner_query_band(const u32 h_tuner, const u32 index, u16 *pw_band)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) u32 qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) *pw_band = (u16)qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) u16 hpi_tuner_set_band(u32 h_control, u16 band)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) return hpi_control_param_set(h_control, HPI_TUNER_BAND, band, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) u16 hpi_tuner_get_band(u32 h_control, u16 *pw_band)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) u32 band = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) u16 error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) error = hpi_control_param1_get(h_control, HPI_TUNER_BAND, &band);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) if (pw_band)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) *pw_band = (u16)band;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) u16 hpi_tuner_query_frequency(const u32 h_tuner, const u32 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) const u16 band, u32 *pfreq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) return hpi_control_query(h_tuner, HPI_TUNER_FREQ, index, band, pfreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) u16 hpi_tuner_set_frequency(u32 h_control, u32 freq_ink_hz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) return hpi_control_param_set(h_control, HPI_TUNER_FREQ, freq_ink_hz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) u16 hpi_tuner_get_frequency(u32 h_control, u32 *pw_freq_ink_hz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) return hpi_control_param1_get(h_control, HPI_TUNER_FREQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) pw_freq_ink_hz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) u16 hpi_tuner_query_gain(const u32 h_tuner, const u32 index, u16 *pw_gain)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) u32 qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) u16 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) *pw_gain = (u16)qr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) u16 hpi_tuner_set_gain(u32 h_control, short gain)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) return hpi_control_param_set(h_control, HPI_TUNER_GAIN, gain, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) u16 hpi_tuner_get_gain(u32 h_control, short *pn_gain)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) u32 gain = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) u16 error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) error = hpi_control_param1_get(h_control, HPI_TUNER_GAIN, &gain);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) if (pn_gain)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) *pn_gain = (u16)gain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) u16 hpi_tuner_get_rf_level(u32 h_control, short *pw_level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) hm.u.cu.attribute = HPI_TUNER_LEVEL_AVG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) if (pw_level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) *pw_level = hr.u.cu.tuner.s_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) u16 hpi_tuner_get_raw_rf_level(u32 h_control, short *pw_level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) hm.u.cu.attribute = HPI_TUNER_LEVEL_RAW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) if (pw_level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) *pw_level = hr.u.cu.tuner.s_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) u16 hpi_tuner_query_deemphasis(const u32 h_tuner, const u32 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) const u16 band, u32 *pdeemphasis)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) return hpi_control_query(h_tuner, HPI_TUNER_DEEMPHASIS, index, band,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) pdeemphasis);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) u16 hpi_tuner_set_deemphasis(u32 h_control, u32 deemphasis)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) return hpi_control_param_set(h_control, HPI_TUNER_DEEMPHASIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) deemphasis, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) u16 hpi_tuner_get_deemphasis(u32 h_control, u32 *pdeemphasis)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) return hpi_control_param1_get(h_control, HPI_TUNER_DEEMPHASIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) pdeemphasis);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) u16 hpi_tuner_query_program(const u32 h_tuner, u32 *pbitmap_program)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) return hpi_control_query(h_tuner, HPI_TUNER_PROGRAM, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) pbitmap_program);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) u16 hpi_tuner_set_program(u32 h_control, u32 program)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) return hpi_control_param_set(h_control, HPI_TUNER_PROGRAM, program,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) u16 hpi_tuner_get_program(u32 h_control, u32 *pprogram)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) return hpi_control_param1_get(h_control, HPI_TUNER_PROGRAM, pprogram);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) u16 hpi_tuner_get_hd_radio_dsp_version(u32 h_control, char *psz_dsp_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) const u32 string_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) return hpi_control_get_string(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) u16 hpi_tuner_get_hd_radio_sdk_version(u32 h_control, char *psz_sdk_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) const u32 string_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) return hpi_control_get_string(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) u16 hpi_tuner_get_status(u32 h_control, u16 *pw_status_mask, u16 *pw_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) u32 status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) u16 error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) error = hpi_control_param1_get(h_control, HPI_TUNER_STATUS, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) if (pw_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) if (!error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) *pw_status_mask = (u16)(status >> 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) *pw_status = (u16)(status & 0xFFFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) *pw_status_mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) *pw_status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) u16 hpi_tuner_set_mode(u32 h_control, u32 mode, u32 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) return hpi_control_param_set(h_control, HPI_TUNER_MODE, mode, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) u16 hpi_tuner_get_mode(u32 h_control, u32 mode, u32 *pn_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) return hpi_control_param_get(h_control, HPI_TUNER_MODE, mode, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) pn_value, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) u16 hpi_tuner_get_hd_radio_signal_quality(u32 h_control, u32 *pquality)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) return hpi_control_param1_get(h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) HPI_TUNER_HDRADIO_SIGNAL_QUALITY, pquality);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) u16 hpi_tuner_get_hd_radio_signal_blend(u32 h_control, u32 *pblend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) return hpi_control_param1_get(h_control, HPI_TUNER_HDRADIO_BLEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) pblend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) u16 hpi_tuner_set_hd_radio_signal_blend(u32 h_control, const u32 blend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) return hpi_control_param_set(h_control, HPI_TUNER_HDRADIO_BLEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) blend, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) u16 hpi_tuner_get_rds(u32 h_control, char *p_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) hm.u.c.attribute = HPI_TUNER_RDS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) if (p_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) *(u32 *)&p_data[0] = hr.u.cu.tuner.rds.data[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) *(u32 *)&p_data[4] = hr.u.cu.tuner.rds.data[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) *(u32 *)&p_data[8] = hr.u.cu.tuner.rds.bLER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) u16 hpi_pad_get_channel_name(u32 h_control, char *psz_string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) const u32 data_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) return hpi_control_get_string(h_control, HPI_PAD_CHANNEL_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) psz_string, data_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) u16 hpi_pad_get_artist(u32 h_control, char *psz_string, const u32 data_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) return hpi_control_get_string(h_control, HPI_PAD_ARTIST, psz_string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) data_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) u16 hpi_pad_get_title(u32 h_control, char *psz_string, const u32 data_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) return hpi_control_get_string(h_control, HPI_PAD_TITLE, psz_string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) data_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) u16 hpi_pad_get_comment(u32 h_control, char *psz_string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) const u32 data_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) return hpi_control_get_string(h_control, HPI_PAD_COMMENT, psz_string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) data_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) u16 hpi_pad_get_program_type(u32 h_control, u32 *ppTY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) return hpi_control_param1_get(h_control, HPI_PAD_PROGRAM_TYPE, ppTY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) u16 hpi_pad_get_rdsPI(u32 h_control, u32 *ppI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) return hpi_control_param1_get(h_control, HPI_PAD_PROGRAM_ID, ppI);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) u16 hpi_volume_query_channels(const u32 h_volume, u32 *p_channels)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) return hpi_control_query(h_volume, HPI_VOLUME_NUM_CHANNELS, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) p_channels);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) u16 hpi_volume_set_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) return hpi_control_log_set2(h_control, HPI_VOLUME_GAIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) an_log_gain[0], an_log_gain[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) u16 hpi_volume_get_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) return hpi_control_log_get2(h_control, HPI_VOLUME_GAIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) &an_log_gain[0], &an_log_gain[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) u16 hpi_volume_set_mute(u32 h_control, u32 mute)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) return hpi_control_param_set(h_control, HPI_VOLUME_MUTE, mute, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) u16 hpi_volume_get_mute(u32 h_control, u32 *mute)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) return hpi_control_param1_get(h_control, HPI_VOLUME_MUTE, mute);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) short *max_gain_01dB, short *step_gain_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) hm.u.c.attribute = HPI_VOLUME_RANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) if (hr.error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) hr.u.c.an_log_value[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) hr.u.c.an_log_value[1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) hr.u.c.param1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) if (min_gain_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) *min_gain_01dB = hr.u.c.an_log_value[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) if (max_gain_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) *max_gain_01dB = hr.u.c.an_log_value[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) if (step_gain_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) *step_gain_01dB = (short)hr.u.c.param1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) u16 hpi_volume_auto_fade_profile(u32 h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) u16 profile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) HPI_CONTROL_SET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) memcpy(hm.u.c.an_log_value, an_stop_gain0_01dB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) sizeof(short) * HPI_MAX_CHANNELS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) hm.u.c.attribute = HPI_VOLUME_AUTOFADE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) hm.u.c.param1 = duration_ms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) hm.u.c.param2 = profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) u16 hpi_volume_auto_fade(u32 h_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) return hpi_volume_auto_fade_profile(h_control, an_stop_gain0_01dB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) duration_ms, HPI_VOLUME_AUTOFADE_LOG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) u16 hpi_volume_query_auto_fade_profile(const u32 h_volume, const u32 i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) u16 *profile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) u16 e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) u32 u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) e = hpi_control_query(h_volume, HPI_VOLUME_AUTOFADE, i, 0, &u);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) *profile = (u16)u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) return e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) u16 hpi_vox_set_threshold(u32 h_control, short an_gain0_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) HPI_CONTROL_SET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) hm.u.c.attribute = HPI_VOX_THRESHOLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) hm.u.c.an_log_value[0] = an_gain0_01dB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) u16 hpi_vox_get_threshold(u32 h_control, short *an_gain0_01dB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) HPI_CONTROL_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) return HPI_ERROR_INVALID_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) hm.u.c.attribute = HPI_VOX_THRESHOLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) hpi_send_recv(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) *an_gain0_01dB = hr.u.c.an_log_value[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) }