1719f82d3SEliot Blennerhassett 2719f82d3SEliot Blennerhassett #include "hpi_internal.h" 3719f82d3SEliot Blennerhassett #include "hpimsginit.h" 4719f82d3SEliot Blennerhassett 5719f82d3SEliot Blennerhassett #include "hpidebug.h" 6719f82d3SEliot Blennerhassett 7719f82d3SEliot Blennerhassett struct hpi_handle { 8719f82d3SEliot Blennerhassett unsigned int obj_index:12; 9719f82d3SEliot Blennerhassett unsigned int obj_type:4; 10719f82d3SEliot Blennerhassett unsigned int adapter_index:14; 11719f82d3SEliot Blennerhassett unsigned int spare:1; 12719f82d3SEliot Blennerhassett unsigned int read_only:1; 13719f82d3SEliot Blennerhassett }; 14719f82d3SEliot Blennerhassett 15719f82d3SEliot Blennerhassett union handle_word { 16719f82d3SEliot Blennerhassett struct hpi_handle h; 17719f82d3SEliot Blennerhassett u32 w; 18719f82d3SEliot Blennerhassett }; 19719f82d3SEliot Blennerhassett 20719f82d3SEliot Blennerhassett u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index, 21719f82d3SEliot Blennerhassett const u16 object_index) 22719f82d3SEliot Blennerhassett { 23719f82d3SEliot Blennerhassett union handle_word handle; 24719f82d3SEliot Blennerhassett 25719f82d3SEliot Blennerhassett handle.h.adapter_index = adapter_index; 26719f82d3SEliot Blennerhassett handle.h.spare = 0; 27719f82d3SEliot Blennerhassett handle.h.read_only = 0; 28719f82d3SEliot Blennerhassett handle.h.obj_type = c_object; 29719f82d3SEliot Blennerhassett handle.h.obj_index = object_index; 30719f82d3SEliot Blennerhassett return handle.w; 31719f82d3SEliot Blennerhassett } 32719f82d3SEliot Blennerhassett 33719f82d3SEliot Blennerhassett void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index, 34719f82d3SEliot Blennerhassett u16 *pw_object_index) 35719f82d3SEliot Blennerhassett { 36719f82d3SEliot Blennerhassett union handle_word uhandle; 37719f82d3SEliot Blennerhassett uhandle.w = handle; 38719f82d3SEliot Blennerhassett 39719f82d3SEliot Blennerhassett if (pw_adapter_index) 40719f82d3SEliot Blennerhassett *pw_adapter_index = (u16)uhandle.h.adapter_index; 41719f82d3SEliot Blennerhassett if (pw_object_index) 42719f82d3SEliot Blennerhassett *pw_object_index = (u16)uhandle.h.obj_index; 43719f82d3SEliot Blennerhassett } 44719f82d3SEliot Blennerhassett 45719f82d3SEliot Blennerhassett char hpi_handle_object(const u32 handle) 46719f82d3SEliot Blennerhassett { 47719f82d3SEliot Blennerhassett union handle_word uhandle; 48719f82d3SEliot Blennerhassett uhandle.w = handle; 49719f82d3SEliot Blennerhassett return (char)uhandle.h.obj_type; 50719f82d3SEliot Blennerhassett } 51719f82d3SEliot Blennerhassett 52719f82d3SEliot Blennerhassett #define u32TOINDEX(h, i1) \ 53719f82d3SEliot Blennerhassett do {\ 54719f82d3SEliot Blennerhassett if (h == 0) \ 55719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_OBJ; \ 56719f82d3SEliot Blennerhassett else \ 57719f82d3SEliot Blennerhassett hpi_handle_to_indexes(h, i1, NULL); \ 58719f82d3SEliot Blennerhassett } while (0) 59719f82d3SEliot Blennerhassett 60719f82d3SEliot Blennerhassett #define u32TOINDEXES(h, i1, i2) \ 61719f82d3SEliot Blennerhassett do {\ 62719f82d3SEliot Blennerhassett if (h == 0) \ 63719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_OBJ; \ 64719f82d3SEliot Blennerhassett else \ 65719f82d3SEliot Blennerhassett hpi_handle_to_indexes(h, i1, i2);\ 66719f82d3SEliot Blennerhassett } while (0) 67719f82d3SEliot Blennerhassett 68719f82d3SEliot Blennerhassett void hpi_format_to_msg(struct hpi_msg_format *pMF, 69719f82d3SEliot Blennerhassett const struct hpi_format *pF) 70719f82d3SEliot Blennerhassett { 71719f82d3SEliot Blennerhassett pMF->sample_rate = pF->sample_rate; 72719f82d3SEliot Blennerhassett pMF->bit_rate = pF->bit_rate; 73719f82d3SEliot Blennerhassett pMF->attributes = pF->attributes; 74719f82d3SEliot Blennerhassett pMF->channels = pF->channels; 75719f82d3SEliot Blennerhassett pMF->format = pF->format; 76719f82d3SEliot Blennerhassett } 77719f82d3SEliot Blennerhassett 78719f82d3SEliot Blennerhassett static void hpi_msg_to_format(struct hpi_format *pF, 79719f82d3SEliot Blennerhassett struct hpi_msg_format *pMF) 80719f82d3SEliot Blennerhassett { 81719f82d3SEliot Blennerhassett pF->sample_rate = pMF->sample_rate; 82719f82d3SEliot Blennerhassett pF->bit_rate = pMF->bit_rate; 83719f82d3SEliot Blennerhassett pF->attributes = pMF->attributes; 84719f82d3SEliot Blennerhassett pF->channels = pMF->channels; 85719f82d3SEliot Blennerhassett pF->format = pMF->format; 86719f82d3SEliot Blennerhassett pF->mode_legacy = 0; 87719f82d3SEliot Blennerhassett pF->unused = 0; 88719f82d3SEliot Blennerhassett } 89719f82d3SEliot Blennerhassett 90719f82d3SEliot Blennerhassett void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR) 91719f82d3SEliot Blennerhassett { 92719f82d3SEliot Blennerhassett pSR->u.legacy_stream_info.auxiliary_data_available = 93719f82d3SEliot Blennerhassett pSR->u.stream_info.auxiliary_data_available; 94719f82d3SEliot Blennerhassett pSR->u.legacy_stream_info.state = pSR->u.stream_info.state; 95719f82d3SEliot Blennerhassett } 96719f82d3SEliot Blennerhassett 97719f82d3SEliot Blennerhassett static struct hpi_hsubsys gh_subsys; 98719f82d3SEliot Blennerhassett 99108ccb3fSEliot Blennerhassett struct hpi_hsubsys *hpi_subsys_create(void) 100719f82d3SEliot Blennerhassett { 101719f82d3SEliot Blennerhassett return &gh_subsys; 102719f82d3SEliot Blennerhassett } 103719f82d3SEliot Blennerhassett 104719f82d3SEliot Blennerhassett void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys) 105719f82d3SEliot Blennerhassett { 106719f82d3SEliot Blennerhassett struct hpi_message hm; 107719f82d3SEliot Blennerhassett struct hpi_response hr; 108719f82d3SEliot Blennerhassett 109719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 110719f82d3SEliot Blennerhassett HPI_SUBSYS_CLOSE); 111719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 112719f82d3SEliot Blennerhassett 113719f82d3SEliot Blennerhassett } 114719f82d3SEliot Blennerhassett 115719f82d3SEliot Blennerhassett u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys, 116719f82d3SEliot Blennerhassett u32 *pversion_ex) 117719f82d3SEliot Blennerhassett { 118719f82d3SEliot Blennerhassett struct hpi_message hm; 119719f82d3SEliot Blennerhassett struct hpi_response hr; 120719f82d3SEliot Blennerhassett 121719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 122719f82d3SEliot Blennerhassett HPI_SUBSYS_GET_VERSION); 123719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 124719f82d3SEliot Blennerhassett *pversion_ex = hr.u.s.data; 125719f82d3SEliot Blennerhassett return hr.error; 126719f82d3SEliot Blennerhassett } 127719f82d3SEliot Blennerhassett 128719f82d3SEliot Blennerhassett u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys, 129719f82d3SEliot Blennerhassett const struct hpi_resource *p_resource, u16 *pw_adapter_index) 130719f82d3SEliot Blennerhassett { 131719f82d3SEliot Blennerhassett struct hpi_message hm; 132719f82d3SEliot Blennerhassett struct hpi_response hr; 133719f82d3SEliot Blennerhassett 134719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 135719f82d3SEliot Blennerhassett HPI_SUBSYS_CREATE_ADAPTER); 136719f82d3SEliot Blennerhassett hm.u.s.resource = *p_resource; 137719f82d3SEliot Blennerhassett 138719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 139719f82d3SEliot Blennerhassett 140719f82d3SEliot Blennerhassett *pw_adapter_index = hr.u.s.adapter_index; 141719f82d3SEliot Blennerhassett return hr.error; 142719f82d3SEliot Blennerhassett } 143719f82d3SEliot Blennerhassett 144719f82d3SEliot Blennerhassett u16 hpi_subsys_delete_adapter(const struct hpi_hsubsys *ph_subsys, 145719f82d3SEliot Blennerhassett u16 adapter_index) 146719f82d3SEliot Blennerhassett { 147719f82d3SEliot Blennerhassett struct hpi_message hm; 148719f82d3SEliot Blennerhassett struct hpi_response hr; 149719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 150719f82d3SEliot Blennerhassett HPI_SUBSYS_DELETE_ADAPTER); 151*3285ea10SEliot Blennerhassett hm.obj_index = adapter_index; 152719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 153719f82d3SEliot Blennerhassett return hr.error; 154719f82d3SEliot Blennerhassett } 155719f82d3SEliot Blennerhassett 156719f82d3SEliot Blennerhassett u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys, 157719f82d3SEliot Blennerhassett int *pn_num_adapters) 158719f82d3SEliot Blennerhassett { 159719f82d3SEliot Blennerhassett struct hpi_message hm; 160719f82d3SEliot Blennerhassett struct hpi_response hr; 161719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 162719f82d3SEliot Blennerhassett HPI_SUBSYS_GET_NUM_ADAPTERS); 163719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 164719f82d3SEliot Blennerhassett *pn_num_adapters = (int)hr.u.s.num_adapters; 165719f82d3SEliot Blennerhassett return hr.error; 166719f82d3SEliot Blennerhassett } 167719f82d3SEliot Blennerhassett 168719f82d3SEliot Blennerhassett u16 hpi_subsys_get_adapter(const struct hpi_hsubsys *ph_subsys, int iterator, 169719f82d3SEliot Blennerhassett u32 *padapter_index, u16 *pw_adapter_type) 170719f82d3SEliot Blennerhassett { 171719f82d3SEliot Blennerhassett struct hpi_message hm; 172719f82d3SEliot Blennerhassett struct hpi_response hr; 173719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 174719f82d3SEliot Blennerhassett HPI_SUBSYS_GET_ADAPTER); 175*3285ea10SEliot Blennerhassett hm.obj_index = (u16)iterator; 176719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 177719f82d3SEliot Blennerhassett *padapter_index = (int)hr.u.s.adapter_index; 178719f82d3SEliot Blennerhassett *pw_adapter_type = hr.u.s.aw_adapter_list[0]; 179719f82d3SEliot Blennerhassett return hr.error; 180719f82d3SEliot Blennerhassett } 181719f82d3SEliot Blennerhassett 182719f82d3SEliot Blennerhassett u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) 183719f82d3SEliot Blennerhassett { 184719f82d3SEliot Blennerhassett struct hpi_message hm; 185719f82d3SEliot Blennerhassett struct hpi_response hr; 186719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 187719f82d3SEliot Blennerhassett HPI_ADAPTER_OPEN); 188719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 189719f82d3SEliot Blennerhassett 190719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 191719f82d3SEliot Blennerhassett 192719f82d3SEliot Blennerhassett return hr.error; 193719f82d3SEliot Blennerhassett 194719f82d3SEliot Blennerhassett } 195719f82d3SEliot Blennerhassett 196719f82d3SEliot Blennerhassett u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) 197719f82d3SEliot Blennerhassett { 198719f82d3SEliot Blennerhassett struct hpi_message hm; 199719f82d3SEliot Blennerhassett struct hpi_response hr; 200719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 201719f82d3SEliot Blennerhassett HPI_ADAPTER_CLOSE); 202719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 203719f82d3SEliot Blennerhassett 204719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 205719f82d3SEliot Blennerhassett 206719f82d3SEliot Blennerhassett return hr.error; 207719f82d3SEliot Blennerhassett } 208719f82d3SEliot Blennerhassett 209719f82d3SEliot Blennerhassett u16 hpi_adapter_set_mode(const struct hpi_hsubsys *ph_subsys, 210719f82d3SEliot Blennerhassett u16 adapter_index, u32 adapter_mode) 211719f82d3SEliot Blennerhassett { 212719f82d3SEliot Blennerhassett return hpi_adapter_set_mode_ex(ph_subsys, adapter_index, adapter_mode, 213719f82d3SEliot Blennerhassett HPI_ADAPTER_MODE_SET); 214719f82d3SEliot Blennerhassett } 215719f82d3SEliot Blennerhassett 216719f82d3SEliot Blennerhassett u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys, 217719f82d3SEliot Blennerhassett u16 adapter_index, u32 adapter_mode, u16 query_or_set) 218719f82d3SEliot Blennerhassett { 219719f82d3SEliot Blennerhassett struct hpi_message hm; 220719f82d3SEliot Blennerhassett struct hpi_response hr; 221108ccb3fSEliot Blennerhassett 222719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 223719f82d3SEliot Blennerhassett HPI_ADAPTER_SET_MODE); 224719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 225*3285ea10SEliot Blennerhassett hm.u.ax.mode.adapter_mode = adapter_mode; 226*3285ea10SEliot Blennerhassett hm.u.ax.mode.query_or_set = query_or_set; 227719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 228719f82d3SEliot Blennerhassett return hr.error; 229719f82d3SEliot Blennerhassett } 230719f82d3SEliot Blennerhassett 231719f82d3SEliot Blennerhassett u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys, 232719f82d3SEliot Blennerhassett u16 adapter_index, u32 *padapter_mode) 233719f82d3SEliot Blennerhassett { 234719f82d3SEliot Blennerhassett struct hpi_message hm; 235719f82d3SEliot Blennerhassett struct hpi_response hr; 236719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 237719f82d3SEliot Blennerhassett HPI_ADAPTER_GET_MODE); 238719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 239719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 240719f82d3SEliot Blennerhassett if (padapter_mode) 241*3285ea10SEliot Blennerhassett *padapter_mode = hr.u.ax.mode.adapter_mode; 242719f82d3SEliot Blennerhassett return hr.error; 243719f82d3SEliot Blennerhassett } 244719f82d3SEliot Blennerhassett 245719f82d3SEliot Blennerhassett u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys, 246719f82d3SEliot Blennerhassett u16 adapter_index, u16 *pw_num_outstreams, u16 *pw_num_instreams, 247719f82d3SEliot Blennerhassett u16 *pw_version, u32 *pserial_number, u16 *pw_adapter_type) 248719f82d3SEliot Blennerhassett { 249719f82d3SEliot Blennerhassett struct hpi_message hm; 250719f82d3SEliot Blennerhassett struct hpi_response hr; 251719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 252719f82d3SEliot Blennerhassett HPI_ADAPTER_GET_INFO); 253719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 254719f82d3SEliot Blennerhassett 255719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 256719f82d3SEliot Blennerhassett 257*3285ea10SEliot Blennerhassett *pw_adapter_type = hr.u.ax.info.adapter_type; 258*3285ea10SEliot Blennerhassett *pw_num_outstreams = hr.u.ax.info.num_outstreams; 259*3285ea10SEliot Blennerhassett *pw_num_instreams = hr.u.ax.info.num_instreams; 260*3285ea10SEliot Blennerhassett *pw_version = hr.u.ax.info.version; 261*3285ea10SEliot Blennerhassett *pserial_number = hr.u.ax.info.serial_number; 262719f82d3SEliot Blennerhassett return hr.error; 263719f82d3SEliot Blennerhassett } 264719f82d3SEliot Blennerhassett 265719f82d3SEliot Blennerhassett u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys, 266719f82d3SEliot Blennerhassett u16 adapter_index, u16 module_index, u16 *pw_num_outputs, 267719f82d3SEliot Blennerhassett u16 *pw_num_inputs, u16 *pw_version, u32 *pserial_number, 268719f82d3SEliot Blennerhassett u16 *pw_module_type, u32 *ph_module) 269719f82d3SEliot Blennerhassett { 270719f82d3SEliot Blennerhassett struct hpi_message hm; 271719f82d3SEliot Blennerhassett struct hpi_response hr; 272719f82d3SEliot Blennerhassett 273719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 274719f82d3SEliot Blennerhassett HPI_ADAPTER_MODULE_INFO); 275719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 276719f82d3SEliot Blennerhassett hm.u.ax.module_info.index = module_index; 277719f82d3SEliot Blennerhassett 278719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 279719f82d3SEliot Blennerhassett 280*3285ea10SEliot Blennerhassett *pw_module_type = hr.u.ax.info.adapter_type; 281*3285ea10SEliot Blennerhassett *pw_num_outputs = hr.u.ax.info.num_outstreams; 282*3285ea10SEliot Blennerhassett *pw_num_inputs = hr.u.ax.info.num_instreams; 283*3285ea10SEliot Blennerhassett *pw_version = hr.u.ax.info.version; 284*3285ea10SEliot Blennerhassett *pserial_number = hr.u.ax.info.serial_number; 285719f82d3SEliot Blennerhassett *ph_module = 0; 286719f82d3SEliot Blennerhassett 287719f82d3SEliot Blennerhassett return hr.error; 288719f82d3SEliot Blennerhassett } 289719f82d3SEliot Blennerhassett 290*3285ea10SEliot Blennerhassett u16 hpi_adapter_get_assert2(const struct hpi_hsubsys *ph_subsys, 291*3285ea10SEliot Blennerhassett u16 adapter_index, u16 *p_assert_count, char *psz_assert, 292*3285ea10SEliot Blennerhassett u32 *p_param1, u32 *p_param2, u32 *p_dsp_string_addr, 293*3285ea10SEliot Blennerhassett u16 *p_processor_id) 294719f82d3SEliot Blennerhassett { 295719f82d3SEliot Blennerhassett struct hpi_message hm; 296719f82d3SEliot Blennerhassett struct hpi_response hr; 297719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 298719f82d3SEliot Blennerhassett HPI_ADAPTER_GET_ASSERT); 299719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 300719f82d3SEliot Blennerhassett 301719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 302719f82d3SEliot Blennerhassett 303*3285ea10SEliot Blennerhassett *p_assert_count = 0; 304719f82d3SEliot Blennerhassett 305719f82d3SEliot Blennerhassett if (!hr.error) { 306*3285ea10SEliot Blennerhassett *p_assert_count = hr.u.ax.assert.count; 307719f82d3SEliot Blennerhassett 308*3285ea10SEliot Blennerhassett if (*p_assert_count) { 309*3285ea10SEliot Blennerhassett *p_param1 = hr.u.ax.assert.p1; 310*3285ea10SEliot Blennerhassett *p_param2 = hr.u.ax.assert.p2; 311*3285ea10SEliot Blennerhassett *p_processor_id = hr.u.ax.assert.dsp_index; 312*3285ea10SEliot Blennerhassett *p_dsp_string_addr = hr.u.ax.assert.dsp_msg_addr; 313*3285ea10SEliot Blennerhassett memcpy(psz_assert, hr.u.ax.assert.sz_message, 314*3285ea10SEliot Blennerhassett HPI_STRING_LEN); 315719f82d3SEliot Blennerhassett } else { 316719f82d3SEliot Blennerhassett *psz_assert = 0; 317719f82d3SEliot Blennerhassett } 318719f82d3SEliot Blennerhassett } 319719f82d3SEliot Blennerhassett return hr.error; 320719f82d3SEliot Blennerhassett } 321719f82d3SEliot Blennerhassett 322719f82d3SEliot Blennerhassett u16 hpi_adapter_test_assert(const struct hpi_hsubsys *ph_subsys, 323719f82d3SEliot Blennerhassett u16 adapter_index, u16 assert_id) 324719f82d3SEliot Blennerhassett { 325719f82d3SEliot Blennerhassett struct hpi_message hm; 326719f82d3SEliot Blennerhassett struct hpi_response hr; 327719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 328719f82d3SEliot Blennerhassett HPI_ADAPTER_TEST_ASSERT); 329719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 330*3285ea10SEliot Blennerhassett hm.u.ax.test_assert.value = assert_id; 331719f82d3SEliot Blennerhassett 332719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 333719f82d3SEliot Blennerhassett 334719f82d3SEliot Blennerhassett return hr.error; 335719f82d3SEliot Blennerhassett } 336719f82d3SEliot Blennerhassett 337719f82d3SEliot Blennerhassett u16 hpi_adapter_enable_capability(const struct hpi_hsubsys *ph_subsys, 338719f82d3SEliot Blennerhassett u16 adapter_index, u16 capability, u32 key) 339719f82d3SEliot Blennerhassett { 340*3285ea10SEliot Blennerhassett #if 1 341*3285ea10SEliot Blennerhassett return HPI_ERROR_UNIMPLEMENTED; 342*3285ea10SEliot Blennerhassett #else 343719f82d3SEliot Blennerhassett struct hpi_message hm; 344719f82d3SEliot Blennerhassett struct hpi_response hr; 345719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 346719f82d3SEliot Blennerhassett HPI_ADAPTER_ENABLE_CAPABILITY); 347719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 348*3285ea10SEliot Blennerhassett hm.u.ax.enable_cap.cap = capability; 349*3285ea10SEliot Blennerhassett hm.u.ax.enable_cap.key = key; 350719f82d3SEliot Blennerhassett 351719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 352719f82d3SEliot Blennerhassett 353719f82d3SEliot Blennerhassett return hr.error; 354*3285ea10SEliot Blennerhassett #endif 355719f82d3SEliot Blennerhassett } 356719f82d3SEliot Blennerhassett 357719f82d3SEliot Blennerhassett u16 hpi_adapter_self_test(const struct hpi_hsubsys *ph_subsys, 358719f82d3SEliot Blennerhassett u16 adapter_index) 359719f82d3SEliot Blennerhassett { 360719f82d3SEliot Blennerhassett struct hpi_message hm; 361719f82d3SEliot Blennerhassett struct hpi_response hr; 362719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 363719f82d3SEliot Blennerhassett HPI_ADAPTER_SELFTEST); 364719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 365719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 366719f82d3SEliot Blennerhassett return hr.error; 367719f82d3SEliot Blennerhassett } 368719f82d3SEliot Blennerhassett 369719f82d3SEliot Blennerhassett u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys, 370719f82d3SEliot Blennerhassett u16 adapter_index, u32 dsp_address, char *p_buffer, int *count_bytes) 371719f82d3SEliot Blennerhassett { 372*3285ea10SEliot Blennerhassett struct hpi_msg_adapter_debug_read hm; 373*3285ea10SEliot Blennerhassett struct hpi_res_adapter_debug_read hr; 374719f82d3SEliot Blennerhassett 375*3285ea10SEliot Blennerhassett hpi_init_message_responseV1(&hm.h, sizeof(hm), &hr.h, sizeof(hr), 376*3285ea10SEliot Blennerhassett HPI_OBJ_ADAPTER, HPI_ADAPTER_DEBUG_READ); 377719f82d3SEliot Blennerhassett 378*3285ea10SEliot Blennerhassett hm.h.adapter_index = adapter_index; 379*3285ea10SEliot Blennerhassett hm.dsp_address = dsp_address; 380719f82d3SEliot Blennerhassett 381*3285ea10SEliot Blennerhassett if (*count_bytes > (int)sizeof(hr.bytes)) 382*3285ea10SEliot Blennerhassett *count_bytes = (int)sizeof(hr.bytes); 383719f82d3SEliot Blennerhassett 384*3285ea10SEliot Blennerhassett hm.count_bytes = *count_bytes; 385719f82d3SEliot Blennerhassett 386*3285ea10SEliot Blennerhassett hpi_send_recv((struct hpi_message *)&hm, (struct hpi_response *)&hr); 387719f82d3SEliot Blennerhassett 388*3285ea10SEliot Blennerhassett if (!hr.h.error) { 389*3285ea10SEliot Blennerhassett int res_bytes = hr.h.size - sizeof(hr.h); 390*3285ea10SEliot Blennerhassett if (res_bytes > *count_bytes) 391*3285ea10SEliot Blennerhassett res_bytes = *count_bytes; 392*3285ea10SEliot Blennerhassett *count_bytes = res_bytes; 393*3285ea10SEliot Blennerhassett memcpy(p_buffer, &hr.bytes, res_bytes); 394719f82d3SEliot Blennerhassett } else 395719f82d3SEliot Blennerhassett *count_bytes = 0; 396*3285ea10SEliot Blennerhassett 397*3285ea10SEliot Blennerhassett return hr.h.error; 398719f82d3SEliot Blennerhassett } 399719f82d3SEliot Blennerhassett 400719f82d3SEliot Blennerhassett u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys, 401719f82d3SEliot Blennerhassett u16 adapter_index, u16 property, u16 parameter1, u16 parameter2) 402719f82d3SEliot Blennerhassett { 403719f82d3SEliot Blennerhassett struct hpi_message hm; 404719f82d3SEliot Blennerhassett struct hpi_response hr; 405719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 406719f82d3SEliot Blennerhassett HPI_ADAPTER_SET_PROPERTY); 407719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 408719f82d3SEliot Blennerhassett hm.u.ax.property_set.property = property; 409719f82d3SEliot Blennerhassett hm.u.ax.property_set.parameter1 = parameter1; 410719f82d3SEliot Blennerhassett hm.u.ax.property_set.parameter2 = parameter2; 411719f82d3SEliot Blennerhassett 412719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 413719f82d3SEliot Blennerhassett 414719f82d3SEliot Blennerhassett return hr.error; 415719f82d3SEliot Blennerhassett } 416719f82d3SEliot Blennerhassett 417719f82d3SEliot Blennerhassett u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys, 418719f82d3SEliot Blennerhassett u16 adapter_index, u16 property, u16 *pw_parameter1, 419719f82d3SEliot Blennerhassett u16 *pw_parameter2) 420719f82d3SEliot Blennerhassett { 421719f82d3SEliot Blennerhassett struct hpi_message hm; 422719f82d3SEliot Blennerhassett struct hpi_response hr; 423719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 424719f82d3SEliot Blennerhassett HPI_ADAPTER_GET_PROPERTY); 425719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 426719f82d3SEliot Blennerhassett hm.u.ax.property_set.property = property; 427719f82d3SEliot Blennerhassett 428719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 429719f82d3SEliot Blennerhassett if (!hr.error) { 430719f82d3SEliot Blennerhassett if (pw_parameter1) 431719f82d3SEliot Blennerhassett *pw_parameter1 = hr.u.ax.property_get.parameter1; 432719f82d3SEliot Blennerhassett if (pw_parameter2) 433719f82d3SEliot Blennerhassett *pw_parameter2 = hr.u.ax.property_get.parameter2; 434719f82d3SEliot Blennerhassett } 435719f82d3SEliot Blennerhassett 436719f82d3SEliot Blennerhassett return hr.error; 437719f82d3SEliot Blennerhassett } 438719f82d3SEliot Blennerhassett 439719f82d3SEliot Blennerhassett u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys, 440719f82d3SEliot Blennerhassett u16 adapter_index, u16 index, u16 what_to_enumerate, 441719f82d3SEliot Blennerhassett u16 property_index, u32 *psetting) 442719f82d3SEliot Blennerhassett { 443719f82d3SEliot Blennerhassett return 0; 444719f82d3SEliot Blennerhassett } 445719f82d3SEliot Blennerhassett 446719f82d3SEliot Blennerhassett u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, 447719f82d3SEliot Blennerhassett u32 sample_rate, u32 bit_rate, u32 attributes) 448719f82d3SEliot Blennerhassett { 449719f82d3SEliot Blennerhassett u16 error = 0; 450719f82d3SEliot Blennerhassett struct hpi_msg_format fmt; 451719f82d3SEliot Blennerhassett 452719f82d3SEliot Blennerhassett switch (channels) { 453719f82d3SEliot Blennerhassett case 1: 454719f82d3SEliot Blennerhassett case 2: 455719f82d3SEliot Blennerhassett case 4: 456719f82d3SEliot Blennerhassett case 6: 457719f82d3SEliot Blennerhassett case 8: 458719f82d3SEliot Blennerhassett case 16: 459719f82d3SEliot Blennerhassett break; 460719f82d3SEliot Blennerhassett default: 461719f82d3SEliot Blennerhassett error = HPI_ERROR_INVALID_CHANNELS; 462719f82d3SEliot Blennerhassett return error; 463719f82d3SEliot Blennerhassett } 464719f82d3SEliot Blennerhassett fmt.channels = channels; 465719f82d3SEliot Blennerhassett 466719f82d3SEliot Blennerhassett switch (format) { 467719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM16_SIGNED: 468719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM24_SIGNED: 469719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM32_SIGNED: 470719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM32_FLOAT: 471719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM16_BIGENDIAN: 472719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM8_UNSIGNED: 473719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L1: 474719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L2: 475719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L3: 476719f82d3SEliot Blennerhassett case HPI_FORMAT_DOLBY_AC2: 477719f82d3SEliot Blennerhassett case HPI_FORMAT_AA_TAGIT1_HITS: 478719f82d3SEliot Blennerhassett case HPI_FORMAT_AA_TAGIT1_INSERTS: 479719f82d3SEliot Blennerhassett case HPI_FORMAT_RAW_BITSTREAM: 480719f82d3SEliot Blennerhassett case HPI_FORMAT_AA_TAGIT1_HITS_EX1: 481719f82d3SEliot Blennerhassett case HPI_FORMAT_OEM1: 482719f82d3SEliot Blennerhassett case HPI_FORMAT_OEM2: 483719f82d3SEliot Blennerhassett break; 484719f82d3SEliot Blennerhassett default: 485719f82d3SEliot Blennerhassett error = HPI_ERROR_INVALID_FORMAT; 486719f82d3SEliot Blennerhassett return error; 487719f82d3SEliot Blennerhassett } 488719f82d3SEliot Blennerhassett fmt.format = format; 489719f82d3SEliot Blennerhassett 490719f82d3SEliot Blennerhassett if (sample_rate < 8000L) { 491719f82d3SEliot Blennerhassett error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; 492719f82d3SEliot Blennerhassett sample_rate = 8000L; 493719f82d3SEliot Blennerhassett } 494719f82d3SEliot Blennerhassett if (sample_rate > 200000L) { 495719f82d3SEliot Blennerhassett error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; 496719f82d3SEliot Blennerhassett sample_rate = 200000L; 497719f82d3SEliot Blennerhassett } 498719f82d3SEliot Blennerhassett fmt.sample_rate = sample_rate; 499719f82d3SEliot Blennerhassett 500719f82d3SEliot Blennerhassett switch (format) { 501719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L1: 502719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L2: 503719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L3: 504719f82d3SEliot Blennerhassett fmt.bit_rate = bit_rate; 505719f82d3SEliot Blennerhassett break; 506719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM16_SIGNED: 507719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM16_BIGENDIAN: 508719f82d3SEliot Blennerhassett fmt.bit_rate = channels * sample_rate * 2; 509719f82d3SEliot Blennerhassett break; 510719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM32_SIGNED: 511719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM32_FLOAT: 512719f82d3SEliot Blennerhassett fmt.bit_rate = channels * sample_rate * 4; 513719f82d3SEliot Blennerhassett break; 514719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM8_UNSIGNED: 515719f82d3SEliot Blennerhassett fmt.bit_rate = channels * sample_rate; 516719f82d3SEliot Blennerhassett break; 517719f82d3SEliot Blennerhassett default: 518719f82d3SEliot Blennerhassett fmt.bit_rate = 0; 519719f82d3SEliot Blennerhassett } 520719f82d3SEliot Blennerhassett 521719f82d3SEliot Blennerhassett switch (format) { 522719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L2: 523719f82d3SEliot Blennerhassett if ((channels == 1) 524719f82d3SEliot Blennerhassett && (attributes != HPI_MPEG_MODE_DEFAULT)) { 525719f82d3SEliot Blennerhassett attributes = HPI_MPEG_MODE_DEFAULT; 526719f82d3SEliot Blennerhassett error = HPI_ERROR_INVALID_FORMAT; 527719f82d3SEliot Blennerhassett } else if (attributes > HPI_MPEG_MODE_DUALCHANNEL) { 528719f82d3SEliot Blennerhassett attributes = HPI_MPEG_MODE_DEFAULT; 529719f82d3SEliot Blennerhassett error = HPI_ERROR_INVALID_FORMAT; 530719f82d3SEliot Blennerhassett } 531719f82d3SEliot Blennerhassett fmt.attributes = attributes; 532719f82d3SEliot Blennerhassett break; 533719f82d3SEliot Blennerhassett default: 534719f82d3SEliot Blennerhassett fmt.attributes = attributes; 535719f82d3SEliot Blennerhassett } 536719f82d3SEliot Blennerhassett 537719f82d3SEliot Blennerhassett hpi_msg_to_format(p_format, &fmt); 538719f82d3SEliot Blennerhassett return error; 539719f82d3SEliot Blennerhassett } 540719f82d3SEliot Blennerhassett 541719f82d3SEliot Blennerhassett u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format, 542719f82d3SEliot Blennerhassett u32 host_polling_rate_in_milli_seconds, u32 *recommended_buffer_size) 543719f82d3SEliot Blennerhassett { 544719f82d3SEliot Blennerhassett 545719f82d3SEliot Blennerhassett u32 bytes_per_second; 546719f82d3SEliot Blennerhassett u32 size; 547719f82d3SEliot Blennerhassett u16 channels; 548719f82d3SEliot Blennerhassett struct hpi_format *pF = p_format; 549719f82d3SEliot Blennerhassett 550719f82d3SEliot Blennerhassett channels = pF->channels; 551719f82d3SEliot Blennerhassett 552719f82d3SEliot Blennerhassett switch (pF->format) { 553719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM16_BIGENDIAN: 554719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM16_SIGNED: 555719f82d3SEliot Blennerhassett bytes_per_second = pF->sample_rate * 2L * channels; 556719f82d3SEliot Blennerhassett break; 557719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM24_SIGNED: 558719f82d3SEliot Blennerhassett bytes_per_second = pF->sample_rate * 3L * channels; 559719f82d3SEliot Blennerhassett break; 560719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM32_SIGNED: 561719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM32_FLOAT: 562719f82d3SEliot Blennerhassett bytes_per_second = pF->sample_rate * 4L * channels; 563719f82d3SEliot Blennerhassett break; 564719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM8_UNSIGNED: 565719f82d3SEliot Blennerhassett bytes_per_second = pF->sample_rate * 1L * channels; 566719f82d3SEliot Blennerhassett break; 567719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L1: 568719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L2: 569719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L3: 570719f82d3SEliot Blennerhassett bytes_per_second = pF->bit_rate / 8L; 571719f82d3SEliot Blennerhassett break; 572719f82d3SEliot Blennerhassett case HPI_FORMAT_DOLBY_AC2: 573719f82d3SEliot Blennerhassett 574719f82d3SEliot Blennerhassett bytes_per_second = 256000L / 8L; 575719f82d3SEliot Blennerhassett break; 576719f82d3SEliot Blennerhassett default: 577719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_FORMAT; 578719f82d3SEliot Blennerhassett } 579719f82d3SEliot Blennerhassett size = (bytes_per_second * host_polling_rate_in_milli_seconds * 2) / 580719f82d3SEliot Blennerhassett 1000L; 581719f82d3SEliot Blennerhassett 582719f82d3SEliot Blennerhassett *recommended_buffer_size = 583719f82d3SEliot Blennerhassett roundup_pow_of_two(((size + 4095L) & ~4095L)); 584719f82d3SEliot Blennerhassett return 0; 585719f82d3SEliot Blennerhassett } 586719f82d3SEliot Blennerhassett 587719f82d3SEliot Blennerhassett u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 588719f82d3SEliot Blennerhassett u16 outstream_index, u32 *ph_outstream) 589719f82d3SEliot Blennerhassett { 590719f82d3SEliot Blennerhassett struct hpi_message hm; 591719f82d3SEliot Blennerhassett struct hpi_response hr; 592719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 593719f82d3SEliot Blennerhassett HPI_OSTREAM_OPEN); 594719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 595719f82d3SEliot Blennerhassett hm.obj_index = outstream_index; 596719f82d3SEliot Blennerhassett 597719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 598719f82d3SEliot Blennerhassett 599719f82d3SEliot Blennerhassett if (hr.error == 0) 600719f82d3SEliot Blennerhassett *ph_outstream = 601719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_OSTREAM, adapter_index, 602719f82d3SEliot Blennerhassett outstream_index); 603719f82d3SEliot Blennerhassett else 604719f82d3SEliot Blennerhassett *ph_outstream = 0; 605719f82d3SEliot Blennerhassett return hr.error; 606719f82d3SEliot Blennerhassett } 607719f82d3SEliot Blennerhassett 608719f82d3SEliot Blennerhassett u16 hpi_outstream_close(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 609719f82d3SEliot Blennerhassett { 610719f82d3SEliot Blennerhassett struct hpi_message hm; 611719f82d3SEliot Blennerhassett struct hpi_response hr; 612719f82d3SEliot Blennerhassett 613719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 614719f82d3SEliot Blennerhassett HPI_OSTREAM_HOSTBUFFER_FREE); 615719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 616719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 617719f82d3SEliot Blennerhassett 618719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 619719f82d3SEliot Blennerhassett HPI_OSTREAM_GROUP_RESET); 620719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 621719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 622719f82d3SEliot Blennerhassett 623719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 624719f82d3SEliot Blennerhassett HPI_OSTREAM_CLOSE); 625719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 626719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 627719f82d3SEliot Blennerhassett 628719f82d3SEliot Blennerhassett return hr.error; 629719f82d3SEliot Blennerhassett } 630719f82d3SEliot Blennerhassett 631719f82d3SEliot Blennerhassett u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys, 632719f82d3SEliot Blennerhassett u32 h_outstream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_to_play, 633719f82d3SEliot Blennerhassett u32 *psamples_played, u32 *pauxiliary_data_to_play) 634719f82d3SEliot Blennerhassett { 635719f82d3SEliot Blennerhassett struct hpi_message hm; 636719f82d3SEliot Blennerhassett struct hpi_response hr; 637719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 638719f82d3SEliot Blennerhassett HPI_OSTREAM_GET_INFO); 639719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 640719f82d3SEliot Blennerhassett 641719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 642719f82d3SEliot Blennerhassett 643719f82d3SEliot Blennerhassett if (pw_state) 644719f82d3SEliot Blennerhassett *pw_state = hr.u.d.u.stream_info.state; 645719f82d3SEliot Blennerhassett if (pbuffer_size) 646719f82d3SEliot Blennerhassett *pbuffer_size = hr.u.d.u.stream_info.buffer_size; 647719f82d3SEliot Blennerhassett if (pdata_to_play) 648719f82d3SEliot Blennerhassett *pdata_to_play = hr.u.d.u.stream_info.data_available; 649719f82d3SEliot Blennerhassett if (psamples_played) 650719f82d3SEliot Blennerhassett *psamples_played = hr.u.d.u.stream_info.samples_transferred; 651719f82d3SEliot Blennerhassett if (pauxiliary_data_to_play) 652719f82d3SEliot Blennerhassett *pauxiliary_data_to_play = 653719f82d3SEliot Blennerhassett hr.u.d.u.stream_info.auxiliary_data_available; 654719f82d3SEliot Blennerhassett return hr.error; 655719f82d3SEliot Blennerhassett } 656719f82d3SEliot Blennerhassett 657719f82d3SEliot Blennerhassett u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys, 658719f82d3SEliot Blennerhassett u32 h_outstream, const u8 *pb_data, u32 bytes_to_write, 659719f82d3SEliot Blennerhassett const struct hpi_format *p_format) 660719f82d3SEliot Blennerhassett { 661719f82d3SEliot Blennerhassett struct hpi_message hm; 662719f82d3SEliot Blennerhassett struct hpi_response hr; 663719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 664719f82d3SEliot Blennerhassett HPI_OSTREAM_WRITE); 665719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 666719f82d3SEliot Blennerhassett hm.u.d.u.data.pb_data = (u8 *)pb_data; 667719f82d3SEliot Blennerhassett hm.u.d.u.data.data_size = bytes_to_write; 668719f82d3SEliot Blennerhassett 669719f82d3SEliot Blennerhassett hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 670719f82d3SEliot Blennerhassett 671719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 672719f82d3SEliot Blennerhassett 673719f82d3SEliot Blennerhassett return hr.error; 674719f82d3SEliot Blennerhassett } 675719f82d3SEliot Blennerhassett 676719f82d3SEliot Blennerhassett u16 hpi_outstream_start(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 677719f82d3SEliot Blennerhassett { 678719f82d3SEliot Blennerhassett struct hpi_message hm; 679719f82d3SEliot Blennerhassett struct hpi_response hr; 680719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 681719f82d3SEliot Blennerhassett HPI_OSTREAM_START); 682719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 683719f82d3SEliot Blennerhassett 684719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 685719f82d3SEliot Blennerhassett 686719f82d3SEliot Blennerhassett return hr.error; 687719f82d3SEliot Blennerhassett } 688719f82d3SEliot Blennerhassett 689719f82d3SEliot Blennerhassett u16 hpi_outstream_wait_start(const struct hpi_hsubsys *ph_subsys, 690719f82d3SEliot Blennerhassett u32 h_outstream) 691719f82d3SEliot Blennerhassett { 692719f82d3SEliot Blennerhassett struct hpi_message hm; 693719f82d3SEliot Blennerhassett struct hpi_response hr; 694719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 695719f82d3SEliot Blennerhassett HPI_OSTREAM_WAIT_START); 696719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 697719f82d3SEliot Blennerhassett 698719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 699719f82d3SEliot Blennerhassett 700719f82d3SEliot Blennerhassett return hr.error; 701719f82d3SEliot Blennerhassett } 702719f82d3SEliot Blennerhassett 703719f82d3SEliot Blennerhassett u16 hpi_outstream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 704719f82d3SEliot Blennerhassett { 705719f82d3SEliot Blennerhassett struct hpi_message hm; 706719f82d3SEliot Blennerhassett struct hpi_response hr; 707719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 708719f82d3SEliot Blennerhassett HPI_OSTREAM_STOP); 709719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 710719f82d3SEliot Blennerhassett 711719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 712719f82d3SEliot Blennerhassett 713719f82d3SEliot Blennerhassett return hr.error; 714719f82d3SEliot Blennerhassett } 715719f82d3SEliot Blennerhassett 716719f82d3SEliot Blennerhassett u16 hpi_outstream_sinegen(const struct hpi_hsubsys *ph_subsys, 717719f82d3SEliot Blennerhassett u32 h_outstream) 718719f82d3SEliot Blennerhassett { 719719f82d3SEliot Blennerhassett struct hpi_message hm; 720719f82d3SEliot Blennerhassett struct hpi_response hr; 721719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 722719f82d3SEliot Blennerhassett HPI_OSTREAM_SINEGEN); 723719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 724719f82d3SEliot Blennerhassett 725719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 726719f82d3SEliot Blennerhassett 727719f82d3SEliot Blennerhassett return hr.error; 728719f82d3SEliot Blennerhassett } 729719f82d3SEliot Blennerhassett 730719f82d3SEliot Blennerhassett u16 hpi_outstream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 731719f82d3SEliot Blennerhassett { 732719f82d3SEliot Blennerhassett struct hpi_message hm; 733719f82d3SEliot Blennerhassett struct hpi_response hr; 734719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 735719f82d3SEliot Blennerhassett HPI_OSTREAM_RESET); 736719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 737719f82d3SEliot Blennerhassett 738719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 739719f82d3SEliot Blennerhassett 740719f82d3SEliot Blennerhassett return hr.error; 741719f82d3SEliot Blennerhassett } 742719f82d3SEliot Blennerhassett 743719f82d3SEliot Blennerhassett u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys, 744719f82d3SEliot Blennerhassett u32 h_outstream, struct hpi_format *p_format) 745719f82d3SEliot Blennerhassett { 746719f82d3SEliot Blennerhassett struct hpi_message hm; 747719f82d3SEliot Blennerhassett struct hpi_response hr; 748719f82d3SEliot Blennerhassett 749719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 750719f82d3SEliot Blennerhassett HPI_OSTREAM_QUERY_FORMAT); 751719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 752719f82d3SEliot Blennerhassett 753719f82d3SEliot Blennerhassett hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 754719f82d3SEliot Blennerhassett 755719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 756719f82d3SEliot Blennerhassett 757719f82d3SEliot Blennerhassett return hr.error; 758719f82d3SEliot Blennerhassett } 759719f82d3SEliot Blennerhassett 760719f82d3SEliot Blennerhassett u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys, 761719f82d3SEliot Blennerhassett u32 h_outstream, struct hpi_format *p_format) 762719f82d3SEliot Blennerhassett { 763719f82d3SEliot Blennerhassett struct hpi_message hm; 764719f82d3SEliot Blennerhassett struct hpi_response hr; 765719f82d3SEliot Blennerhassett 766719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 767719f82d3SEliot Blennerhassett HPI_OSTREAM_SET_FORMAT); 768719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 769719f82d3SEliot Blennerhassett 770719f82d3SEliot Blennerhassett hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 771719f82d3SEliot Blennerhassett 772719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 773719f82d3SEliot Blennerhassett 774719f82d3SEliot Blennerhassett return hr.error; 775719f82d3SEliot Blennerhassett } 776719f82d3SEliot Blennerhassett 777719f82d3SEliot Blennerhassett u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys, 778719f82d3SEliot Blennerhassett u32 h_outstream, short velocity) 779719f82d3SEliot Blennerhassett { 780719f82d3SEliot Blennerhassett struct hpi_message hm; 781719f82d3SEliot Blennerhassett struct hpi_response hr; 782719f82d3SEliot Blennerhassett 783719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 784719f82d3SEliot Blennerhassett HPI_OSTREAM_SET_VELOCITY); 785719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 786719f82d3SEliot Blennerhassett hm.u.d.u.velocity = velocity; 787719f82d3SEliot Blennerhassett 788719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 789719f82d3SEliot Blennerhassett 790719f82d3SEliot Blennerhassett return hr.error; 791719f82d3SEliot Blennerhassett } 792719f82d3SEliot Blennerhassett 793719f82d3SEliot Blennerhassett u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys, 794719f82d3SEliot Blennerhassett u32 h_outstream, u32 punch_in_sample, u32 punch_out_sample) 795719f82d3SEliot Blennerhassett { 796719f82d3SEliot Blennerhassett struct hpi_message hm; 797719f82d3SEliot Blennerhassett struct hpi_response hr; 798719f82d3SEliot Blennerhassett 799719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 800719f82d3SEliot Blennerhassett HPI_OSTREAM_SET_PUNCHINOUT); 801719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 802719f82d3SEliot Blennerhassett 803719f82d3SEliot Blennerhassett hm.u.d.u.pio.punch_in_sample = punch_in_sample; 804719f82d3SEliot Blennerhassett hm.u.d.u.pio.punch_out_sample = punch_out_sample; 805719f82d3SEliot Blennerhassett 806719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 807719f82d3SEliot Blennerhassett 808719f82d3SEliot Blennerhassett return hr.error; 809719f82d3SEliot Blennerhassett } 810719f82d3SEliot Blennerhassett 811719f82d3SEliot Blennerhassett u16 hpi_outstream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, 812719f82d3SEliot Blennerhassett u32 h_outstream, u16 mode) 813719f82d3SEliot Blennerhassett { 814719f82d3SEliot Blennerhassett struct hpi_message hm; 815719f82d3SEliot Blennerhassett struct hpi_response hr; 816719f82d3SEliot Blennerhassett 817719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 818719f82d3SEliot Blennerhassett HPI_OSTREAM_ANC_RESET); 819719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 820719f82d3SEliot Blennerhassett hm.u.d.u.data.format.channels = mode; 821719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 822719f82d3SEliot Blennerhassett return hr.error; 823719f82d3SEliot Blennerhassett } 824719f82d3SEliot Blennerhassett 825719f82d3SEliot Blennerhassett u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, 826719f82d3SEliot Blennerhassett u32 h_outstream, u32 *pframes_available) 827719f82d3SEliot Blennerhassett { 828719f82d3SEliot Blennerhassett struct hpi_message hm; 829719f82d3SEliot Blennerhassett struct hpi_response hr; 830719f82d3SEliot Blennerhassett 831719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 832719f82d3SEliot Blennerhassett HPI_OSTREAM_ANC_GET_INFO); 833719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 834719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 835719f82d3SEliot Blennerhassett if (hr.error == 0) { 836719f82d3SEliot Blennerhassett if (pframes_available) 837719f82d3SEliot Blennerhassett *pframes_available = 838719f82d3SEliot Blennerhassett hr.u.d.u.stream_info.data_available / 839719f82d3SEliot Blennerhassett sizeof(struct hpi_anc_frame); 840719f82d3SEliot Blennerhassett } 841719f82d3SEliot Blennerhassett return hr.error; 842719f82d3SEliot Blennerhassett } 843719f82d3SEliot Blennerhassett 844719f82d3SEliot Blennerhassett u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys, 845719f82d3SEliot Blennerhassett u32 h_outstream, struct hpi_anc_frame *p_anc_frame_buffer, 846719f82d3SEliot Blennerhassett u32 anc_frame_buffer_size_in_bytes, 847719f82d3SEliot Blennerhassett u32 number_of_ancillary_frames_to_read) 848719f82d3SEliot Blennerhassett { 849719f82d3SEliot Blennerhassett struct hpi_message hm; 850719f82d3SEliot Blennerhassett struct hpi_response hr; 851108ccb3fSEliot Blennerhassett 852719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 853719f82d3SEliot Blennerhassett HPI_OSTREAM_ANC_READ); 854719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 855719f82d3SEliot Blennerhassett hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer; 856719f82d3SEliot Blennerhassett hm.u.d.u.data.data_size = 857719f82d3SEliot Blennerhassett number_of_ancillary_frames_to_read * 858719f82d3SEliot Blennerhassett sizeof(struct hpi_anc_frame); 859719f82d3SEliot Blennerhassett if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes) 860719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 861719f82d3SEliot Blennerhassett else 862719f82d3SEliot Blennerhassett hr.error = HPI_ERROR_INVALID_DATA_TRANSFER; 863719f82d3SEliot Blennerhassett return hr.error; 864719f82d3SEliot Blennerhassett } 865719f82d3SEliot Blennerhassett 866719f82d3SEliot Blennerhassett u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys, 867719f82d3SEliot Blennerhassett u32 h_outstream, u32 time_scale) 868719f82d3SEliot Blennerhassett { 869719f82d3SEliot Blennerhassett struct hpi_message hm; 870719f82d3SEliot Blennerhassett struct hpi_response hr; 871719f82d3SEliot Blennerhassett 872719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 873719f82d3SEliot Blennerhassett HPI_OSTREAM_SET_TIMESCALE); 874719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 875719f82d3SEliot Blennerhassett 876719f82d3SEliot Blennerhassett hm.u.d.u.time_scale = time_scale; 877719f82d3SEliot Blennerhassett 878719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 879719f82d3SEliot Blennerhassett 880719f82d3SEliot Blennerhassett return hr.error; 881719f82d3SEliot Blennerhassett } 882719f82d3SEliot Blennerhassett 883719f82d3SEliot Blennerhassett u16 hpi_outstream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, 884719f82d3SEliot Blennerhassett u32 h_outstream, u32 size_in_bytes) 885719f82d3SEliot Blennerhassett { 886719f82d3SEliot Blennerhassett struct hpi_message hm; 887719f82d3SEliot Blennerhassett struct hpi_response hr; 888719f82d3SEliot Blennerhassett 889719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 890719f82d3SEliot Blennerhassett HPI_OSTREAM_HOSTBUFFER_ALLOC); 891719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 892719f82d3SEliot Blennerhassett hm.u.d.u.data.data_size = size_in_bytes; 893719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 894719f82d3SEliot Blennerhassett return hr.error; 895719f82d3SEliot Blennerhassett } 896719f82d3SEliot Blennerhassett 897719f82d3SEliot Blennerhassett u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, 898719f82d3SEliot Blennerhassett u32 h_outstream, u8 **pp_buffer, 899719f82d3SEliot Blennerhassett struct hpi_hostbuffer_status **pp_status) 900719f82d3SEliot Blennerhassett { 901719f82d3SEliot Blennerhassett struct hpi_message hm; 902719f82d3SEliot Blennerhassett struct hpi_response hr; 903719f82d3SEliot Blennerhassett 904719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 905719f82d3SEliot Blennerhassett HPI_OSTREAM_HOSTBUFFER_GET_INFO); 906719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 907719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 908719f82d3SEliot Blennerhassett 909719f82d3SEliot Blennerhassett if (hr.error == 0) { 910719f82d3SEliot Blennerhassett if (pp_buffer) 911719f82d3SEliot Blennerhassett *pp_buffer = hr.u.d.u.hostbuffer_info.p_buffer; 912719f82d3SEliot Blennerhassett if (pp_status) 913719f82d3SEliot Blennerhassett *pp_status = hr.u.d.u.hostbuffer_info.p_status; 914719f82d3SEliot Blennerhassett } 915719f82d3SEliot Blennerhassett return hr.error; 916719f82d3SEliot Blennerhassett } 917719f82d3SEliot Blennerhassett 918719f82d3SEliot Blennerhassett u16 hpi_outstream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, 919719f82d3SEliot Blennerhassett u32 h_outstream) 920719f82d3SEliot Blennerhassett { 921719f82d3SEliot Blennerhassett struct hpi_message hm; 922719f82d3SEliot Blennerhassett struct hpi_response hr; 923719f82d3SEliot Blennerhassett 924719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 925719f82d3SEliot Blennerhassett HPI_OSTREAM_HOSTBUFFER_FREE); 926719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 927719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 928719f82d3SEliot Blennerhassett return hr.error; 929719f82d3SEliot Blennerhassett } 930719f82d3SEliot Blennerhassett 931719f82d3SEliot Blennerhassett u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys, 932719f82d3SEliot Blennerhassett u32 h_outstream, u32 h_stream) 933719f82d3SEliot Blennerhassett { 934719f82d3SEliot Blennerhassett struct hpi_message hm; 935719f82d3SEliot Blennerhassett struct hpi_response hr; 936719f82d3SEliot Blennerhassett u16 adapter; 937719f82d3SEliot Blennerhassett char c_obj_type; 938719f82d3SEliot Blennerhassett 939719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 940719f82d3SEliot Blennerhassett HPI_OSTREAM_GROUP_ADD); 941719f82d3SEliot Blennerhassett hr.error = 0; 942719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 943719f82d3SEliot Blennerhassett c_obj_type = hpi_handle_object(h_stream); 944719f82d3SEliot Blennerhassett switch (c_obj_type) { 945719f82d3SEliot Blennerhassett case HPI_OBJ_OSTREAM: 946719f82d3SEliot Blennerhassett hm.u.d.u.stream.object_type = HPI_OBJ_OSTREAM; 947719f82d3SEliot Blennerhassett u32TOINDEXES(h_stream, &adapter, 948719f82d3SEliot Blennerhassett &hm.u.d.u.stream.stream_index); 949719f82d3SEliot Blennerhassett break; 950719f82d3SEliot Blennerhassett case HPI_OBJ_ISTREAM: 951719f82d3SEliot Blennerhassett hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM; 952719f82d3SEliot Blennerhassett u32TOINDEXES(h_stream, &adapter, 953719f82d3SEliot Blennerhassett &hm.u.d.u.stream.stream_index); 954719f82d3SEliot Blennerhassett break; 955719f82d3SEliot Blennerhassett default: 956719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_STREAM; 957719f82d3SEliot Blennerhassett } 958719f82d3SEliot Blennerhassett if (adapter != hm.adapter_index) 959719f82d3SEliot Blennerhassett return HPI_ERROR_NO_INTERADAPTER_GROUPS; 960719f82d3SEliot Blennerhassett 961719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 962719f82d3SEliot Blennerhassett return hr.error; 963719f82d3SEliot Blennerhassett } 964719f82d3SEliot Blennerhassett 965719f82d3SEliot Blennerhassett u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys, 966719f82d3SEliot Blennerhassett u32 h_outstream, u32 *poutstream_map, u32 *pinstream_map) 967719f82d3SEliot Blennerhassett { 968719f82d3SEliot Blennerhassett struct hpi_message hm; 969719f82d3SEliot Blennerhassett struct hpi_response hr; 970719f82d3SEliot Blennerhassett 971719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 972719f82d3SEliot Blennerhassett HPI_OSTREAM_GROUP_GETMAP); 973719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 974719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 975719f82d3SEliot Blennerhassett 976719f82d3SEliot Blennerhassett if (poutstream_map) 977719f82d3SEliot Blennerhassett *poutstream_map = hr.u.d.u.group_info.outstream_group_map; 978719f82d3SEliot Blennerhassett if (pinstream_map) 979719f82d3SEliot Blennerhassett *pinstream_map = hr.u.d.u.group_info.instream_group_map; 980719f82d3SEliot Blennerhassett 981719f82d3SEliot Blennerhassett return hr.error; 982719f82d3SEliot Blennerhassett } 983719f82d3SEliot Blennerhassett 984719f82d3SEliot Blennerhassett u16 hpi_outstream_group_reset(const struct hpi_hsubsys *ph_subsys, 985719f82d3SEliot Blennerhassett u32 h_outstream) 986719f82d3SEliot Blennerhassett { 987719f82d3SEliot Blennerhassett struct hpi_message hm; 988719f82d3SEliot Blennerhassett struct hpi_response hr; 989719f82d3SEliot Blennerhassett 990719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 991719f82d3SEliot Blennerhassett HPI_OSTREAM_GROUP_RESET); 992719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 993719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 994719f82d3SEliot Blennerhassett return hr.error; 995719f82d3SEliot Blennerhassett } 996719f82d3SEliot Blennerhassett 997719f82d3SEliot Blennerhassett u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 998719f82d3SEliot Blennerhassett u16 instream_index, u32 *ph_instream) 999719f82d3SEliot Blennerhassett { 1000719f82d3SEliot Blennerhassett struct hpi_message hm; 1001719f82d3SEliot Blennerhassett struct hpi_response hr; 1002719f82d3SEliot Blennerhassett 1003719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1004719f82d3SEliot Blennerhassett HPI_ISTREAM_OPEN); 1005719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 1006719f82d3SEliot Blennerhassett hm.obj_index = instream_index; 1007719f82d3SEliot Blennerhassett 1008719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1009719f82d3SEliot Blennerhassett 1010719f82d3SEliot Blennerhassett if (hr.error == 0) 1011719f82d3SEliot Blennerhassett *ph_instream = 1012719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_ISTREAM, adapter_index, 1013719f82d3SEliot Blennerhassett instream_index); 1014719f82d3SEliot Blennerhassett else 1015719f82d3SEliot Blennerhassett *ph_instream = 0; 1016719f82d3SEliot Blennerhassett 1017719f82d3SEliot Blennerhassett return hr.error; 1018719f82d3SEliot Blennerhassett } 1019719f82d3SEliot Blennerhassett 1020719f82d3SEliot Blennerhassett u16 hpi_instream_close(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 1021719f82d3SEliot Blennerhassett { 1022719f82d3SEliot Blennerhassett struct hpi_message hm; 1023719f82d3SEliot Blennerhassett struct hpi_response hr; 1024719f82d3SEliot Blennerhassett 1025719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1026719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_FREE); 1027719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1028719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1029719f82d3SEliot Blennerhassett 1030719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1031719f82d3SEliot Blennerhassett HPI_ISTREAM_GROUP_RESET); 1032719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1033719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1034719f82d3SEliot Blennerhassett 1035719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1036719f82d3SEliot Blennerhassett HPI_ISTREAM_CLOSE); 1037719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1038719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1039719f82d3SEliot Blennerhassett 1040719f82d3SEliot Blennerhassett return hr.error; 1041719f82d3SEliot Blennerhassett } 1042719f82d3SEliot Blennerhassett 1043719f82d3SEliot Blennerhassett u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys, 1044719f82d3SEliot Blennerhassett u32 h_instream, const struct hpi_format *p_format) 1045719f82d3SEliot Blennerhassett { 1046719f82d3SEliot Blennerhassett struct hpi_message hm; 1047719f82d3SEliot Blennerhassett struct hpi_response hr; 1048719f82d3SEliot Blennerhassett 1049719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1050719f82d3SEliot Blennerhassett HPI_ISTREAM_QUERY_FORMAT); 1051719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1052719f82d3SEliot Blennerhassett hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 1053719f82d3SEliot Blennerhassett 1054719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1055719f82d3SEliot Blennerhassett 1056719f82d3SEliot Blennerhassett return hr.error; 1057719f82d3SEliot Blennerhassett } 1058719f82d3SEliot Blennerhassett 1059719f82d3SEliot Blennerhassett u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys, 1060719f82d3SEliot Blennerhassett u32 h_instream, const struct hpi_format *p_format) 1061719f82d3SEliot Blennerhassett { 1062719f82d3SEliot Blennerhassett struct hpi_message hm; 1063719f82d3SEliot Blennerhassett struct hpi_response hr; 1064719f82d3SEliot Blennerhassett 1065719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1066719f82d3SEliot Blennerhassett HPI_ISTREAM_SET_FORMAT); 1067719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1068719f82d3SEliot Blennerhassett hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 1069719f82d3SEliot Blennerhassett 1070719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1071719f82d3SEliot Blennerhassett 1072719f82d3SEliot Blennerhassett return hr.error; 1073719f82d3SEliot Blennerhassett } 1074719f82d3SEliot Blennerhassett 1075719f82d3SEliot Blennerhassett u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream, 1076719f82d3SEliot Blennerhassett u8 *pb_data, u32 bytes_to_read) 1077719f82d3SEliot Blennerhassett { 1078719f82d3SEliot Blennerhassett struct hpi_message hm; 1079719f82d3SEliot Blennerhassett struct hpi_response hr; 1080719f82d3SEliot Blennerhassett 1081719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1082719f82d3SEliot Blennerhassett HPI_ISTREAM_READ); 1083719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1084719f82d3SEliot Blennerhassett hm.u.d.u.data.data_size = bytes_to_read; 1085719f82d3SEliot Blennerhassett hm.u.d.u.data.pb_data = pb_data; 1086719f82d3SEliot Blennerhassett 1087719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1088719f82d3SEliot Blennerhassett 1089719f82d3SEliot Blennerhassett return hr.error; 1090719f82d3SEliot Blennerhassett } 1091719f82d3SEliot Blennerhassett 1092719f82d3SEliot Blennerhassett u16 hpi_instream_start(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 1093719f82d3SEliot Blennerhassett { 1094719f82d3SEliot Blennerhassett struct hpi_message hm; 1095719f82d3SEliot Blennerhassett struct hpi_response hr; 1096719f82d3SEliot Blennerhassett 1097719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1098719f82d3SEliot Blennerhassett HPI_ISTREAM_START); 1099719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1100719f82d3SEliot Blennerhassett 1101719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1102719f82d3SEliot Blennerhassett 1103719f82d3SEliot Blennerhassett return hr.error; 1104719f82d3SEliot Blennerhassett } 1105719f82d3SEliot Blennerhassett 1106719f82d3SEliot Blennerhassett u16 hpi_instream_wait_start(const struct hpi_hsubsys *ph_subsys, 1107719f82d3SEliot Blennerhassett u32 h_instream) 1108719f82d3SEliot Blennerhassett { 1109719f82d3SEliot Blennerhassett struct hpi_message hm; 1110719f82d3SEliot Blennerhassett struct hpi_response hr; 1111719f82d3SEliot Blennerhassett 1112719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1113719f82d3SEliot Blennerhassett HPI_ISTREAM_WAIT_START); 1114719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1115719f82d3SEliot Blennerhassett 1116719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1117719f82d3SEliot Blennerhassett 1118719f82d3SEliot Blennerhassett return hr.error; 1119719f82d3SEliot Blennerhassett } 1120719f82d3SEliot Blennerhassett 1121719f82d3SEliot Blennerhassett u16 hpi_instream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 1122719f82d3SEliot Blennerhassett { 1123719f82d3SEliot Blennerhassett struct hpi_message hm; 1124719f82d3SEliot Blennerhassett struct hpi_response hr; 1125719f82d3SEliot Blennerhassett 1126719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1127719f82d3SEliot Blennerhassett HPI_ISTREAM_STOP); 1128719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1129719f82d3SEliot Blennerhassett 1130719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1131719f82d3SEliot Blennerhassett 1132719f82d3SEliot Blennerhassett return hr.error; 1133719f82d3SEliot Blennerhassett } 1134719f82d3SEliot Blennerhassett 1135719f82d3SEliot Blennerhassett u16 hpi_instream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 1136719f82d3SEliot Blennerhassett { 1137719f82d3SEliot Blennerhassett struct hpi_message hm; 1138719f82d3SEliot Blennerhassett struct hpi_response hr; 1139719f82d3SEliot Blennerhassett 1140719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1141719f82d3SEliot Blennerhassett HPI_ISTREAM_RESET); 1142719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1143719f82d3SEliot Blennerhassett 1144719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1145719f82d3SEliot Blennerhassett 1146719f82d3SEliot Blennerhassett return hr.error; 1147719f82d3SEliot Blennerhassett } 1148719f82d3SEliot Blennerhassett 1149719f82d3SEliot Blennerhassett u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys, 1150719f82d3SEliot Blennerhassett u32 h_instream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_recorded, 1151719f82d3SEliot Blennerhassett u32 *psamples_recorded, u32 *pauxiliary_data_recorded) 1152719f82d3SEliot Blennerhassett { 1153719f82d3SEliot Blennerhassett struct hpi_message hm; 1154719f82d3SEliot Blennerhassett struct hpi_response hr; 1155719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1156719f82d3SEliot Blennerhassett HPI_ISTREAM_GET_INFO); 1157719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1158719f82d3SEliot Blennerhassett 1159719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1160719f82d3SEliot Blennerhassett 1161719f82d3SEliot Blennerhassett if (pw_state) 1162719f82d3SEliot Blennerhassett *pw_state = hr.u.d.u.stream_info.state; 1163719f82d3SEliot Blennerhassett if (pbuffer_size) 1164719f82d3SEliot Blennerhassett *pbuffer_size = hr.u.d.u.stream_info.buffer_size; 1165719f82d3SEliot Blennerhassett if (pdata_recorded) 1166719f82d3SEliot Blennerhassett *pdata_recorded = hr.u.d.u.stream_info.data_available; 1167719f82d3SEliot Blennerhassett if (psamples_recorded) 1168719f82d3SEliot Blennerhassett *psamples_recorded = hr.u.d.u.stream_info.samples_transferred; 1169719f82d3SEliot Blennerhassett if (pauxiliary_data_recorded) 1170719f82d3SEliot Blennerhassett *pauxiliary_data_recorded = 1171719f82d3SEliot Blennerhassett hr.u.d.u.stream_info.auxiliary_data_available; 1172719f82d3SEliot Blennerhassett return hr.error; 1173719f82d3SEliot Blennerhassett } 1174719f82d3SEliot Blennerhassett 1175719f82d3SEliot Blennerhassett u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, 1176719f82d3SEliot Blennerhassett u32 h_instream, u16 bytes_per_frame, u16 mode, u16 alignment, 1177719f82d3SEliot Blennerhassett u16 idle_bit) 1178719f82d3SEliot Blennerhassett { 1179719f82d3SEliot Blennerhassett struct hpi_message hm; 1180719f82d3SEliot Blennerhassett struct hpi_response hr; 1181719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1182719f82d3SEliot Blennerhassett HPI_ISTREAM_ANC_RESET); 1183719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1184719f82d3SEliot Blennerhassett hm.u.d.u.data.format.attributes = bytes_per_frame; 1185719f82d3SEliot Blennerhassett hm.u.d.u.data.format.format = (mode << 8) | (alignment & 0xff); 1186719f82d3SEliot Blennerhassett hm.u.d.u.data.format.channels = idle_bit; 1187719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1188719f82d3SEliot Blennerhassett return hr.error; 1189719f82d3SEliot Blennerhassett } 1190719f82d3SEliot Blennerhassett 1191719f82d3SEliot Blennerhassett u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, 1192719f82d3SEliot Blennerhassett u32 h_instream, u32 *pframe_space) 1193719f82d3SEliot Blennerhassett { 1194719f82d3SEliot Blennerhassett struct hpi_message hm; 1195719f82d3SEliot Blennerhassett struct hpi_response hr; 1196719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1197719f82d3SEliot Blennerhassett HPI_ISTREAM_ANC_GET_INFO); 1198719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1199719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1200719f82d3SEliot Blennerhassett if (pframe_space) 1201719f82d3SEliot Blennerhassett *pframe_space = 1202719f82d3SEliot Blennerhassett (hr.u.d.u.stream_info.buffer_size - 1203719f82d3SEliot Blennerhassett hr.u.d.u.stream_info.data_available) / 1204719f82d3SEliot Blennerhassett sizeof(struct hpi_anc_frame); 1205719f82d3SEliot Blennerhassett return hr.error; 1206719f82d3SEliot Blennerhassett } 1207719f82d3SEliot Blennerhassett 1208719f82d3SEliot Blennerhassett u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys, 1209719f82d3SEliot Blennerhassett u32 h_instream, const struct hpi_anc_frame *p_anc_frame_buffer, 1210719f82d3SEliot Blennerhassett u32 anc_frame_buffer_size_in_bytes, 1211719f82d3SEliot Blennerhassett u32 number_of_ancillary_frames_to_write) 1212719f82d3SEliot Blennerhassett { 1213719f82d3SEliot Blennerhassett struct hpi_message hm; 1214719f82d3SEliot Blennerhassett struct hpi_response hr; 1215719f82d3SEliot Blennerhassett 1216719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1217719f82d3SEliot Blennerhassett HPI_ISTREAM_ANC_WRITE); 1218719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1219719f82d3SEliot Blennerhassett hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer; 1220719f82d3SEliot Blennerhassett hm.u.d.u.data.data_size = 1221719f82d3SEliot Blennerhassett number_of_ancillary_frames_to_write * 1222719f82d3SEliot Blennerhassett sizeof(struct hpi_anc_frame); 1223719f82d3SEliot Blennerhassett if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes) 1224719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1225719f82d3SEliot Blennerhassett else 1226719f82d3SEliot Blennerhassett hr.error = HPI_ERROR_INVALID_DATA_TRANSFER; 1227719f82d3SEliot Blennerhassett return hr.error; 1228719f82d3SEliot Blennerhassett } 1229719f82d3SEliot Blennerhassett 1230719f82d3SEliot Blennerhassett u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, 1231719f82d3SEliot Blennerhassett u32 h_instream, u32 size_in_bytes) 1232719f82d3SEliot Blennerhassett { 1233719f82d3SEliot Blennerhassett 1234719f82d3SEliot Blennerhassett struct hpi_message hm; 1235719f82d3SEliot Blennerhassett struct hpi_response hr; 1236719f82d3SEliot Blennerhassett 1237719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1238719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_ALLOC); 1239719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1240719f82d3SEliot Blennerhassett hm.u.d.u.data.data_size = size_in_bytes; 1241719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1242719f82d3SEliot Blennerhassett return hr.error; 1243719f82d3SEliot Blennerhassett } 1244719f82d3SEliot Blennerhassett 1245719f82d3SEliot Blennerhassett u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, 1246719f82d3SEliot Blennerhassett u32 h_instream, u8 **pp_buffer, 1247719f82d3SEliot Blennerhassett struct hpi_hostbuffer_status **pp_status) 1248719f82d3SEliot Blennerhassett { 1249719f82d3SEliot Blennerhassett struct hpi_message hm; 1250719f82d3SEliot Blennerhassett struct hpi_response hr; 1251719f82d3SEliot Blennerhassett 1252719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1253719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_GET_INFO); 1254719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1255719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1256719f82d3SEliot Blennerhassett 1257719f82d3SEliot Blennerhassett if (hr.error == 0) { 1258719f82d3SEliot Blennerhassett if (pp_buffer) 1259719f82d3SEliot Blennerhassett *pp_buffer = hr.u.d.u.hostbuffer_info.p_buffer; 1260719f82d3SEliot Blennerhassett if (pp_status) 1261719f82d3SEliot Blennerhassett *pp_status = hr.u.d.u.hostbuffer_info.p_status; 1262719f82d3SEliot Blennerhassett } 1263719f82d3SEliot Blennerhassett return hr.error; 1264719f82d3SEliot Blennerhassett } 1265719f82d3SEliot Blennerhassett 1266719f82d3SEliot Blennerhassett u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, 1267719f82d3SEliot Blennerhassett u32 h_instream) 1268719f82d3SEliot Blennerhassett { 1269719f82d3SEliot Blennerhassett 1270719f82d3SEliot Blennerhassett struct hpi_message hm; 1271719f82d3SEliot Blennerhassett struct hpi_response hr; 1272719f82d3SEliot Blennerhassett 1273719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1274719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_FREE); 1275719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1276719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1277719f82d3SEliot Blennerhassett return hr.error; 1278719f82d3SEliot Blennerhassett } 1279719f82d3SEliot Blennerhassett 1280719f82d3SEliot Blennerhassett u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys, 1281719f82d3SEliot Blennerhassett u32 h_instream, u32 h_stream) 1282719f82d3SEliot Blennerhassett { 1283719f82d3SEliot Blennerhassett struct hpi_message hm; 1284719f82d3SEliot Blennerhassett struct hpi_response hr; 1285719f82d3SEliot Blennerhassett u16 adapter; 1286719f82d3SEliot Blennerhassett char c_obj_type; 1287719f82d3SEliot Blennerhassett 1288719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1289719f82d3SEliot Blennerhassett HPI_ISTREAM_GROUP_ADD); 1290719f82d3SEliot Blennerhassett hr.error = 0; 1291719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1292719f82d3SEliot Blennerhassett c_obj_type = hpi_handle_object(h_stream); 1293719f82d3SEliot Blennerhassett 1294719f82d3SEliot Blennerhassett switch (c_obj_type) { 1295719f82d3SEliot Blennerhassett case HPI_OBJ_OSTREAM: 1296719f82d3SEliot Blennerhassett hm.u.d.u.stream.object_type = HPI_OBJ_OSTREAM; 1297719f82d3SEliot Blennerhassett u32TOINDEXES(h_stream, &adapter, 1298719f82d3SEliot Blennerhassett &hm.u.d.u.stream.stream_index); 1299719f82d3SEliot Blennerhassett break; 1300719f82d3SEliot Blennerhassett case HPI_OBJ_ISTREAM: 1301719f82d3SEliot Blennerhassett hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM; 1302719f82d3SEliot Blennerhassett u32TOINDEXES(h_stream, &adapter, 1303719f82d3SEliot Blennerhassett &hm.u.d.u.stream.stream_index); 1304719f82d3SEliot Blennerhassett break; 1305719f82d3SEliot Blennerhassett default: 1306719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_STREAM; 1307719f82d3SEliot Blennerhassett } 1308719f82d3SEliot Blennerhassett 1309719f82d3SEliot Blennerhassett if (adapter != hm.adapter_index) 1310719f82d3SEliot Blennerhassett return HPI_ERROR_NO_INTERADAPTER_GROUPS; 1311719f82d3SEliot Blennerhassett 1312719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1313719f82d3SEliot Blennerhassett return hr.error; 1314719f82d3SEliot Blennerhassett } 1315719f82d3SEliot Blennerhassett 1316719f82d3SEliot Blennerhassett u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys, 1317719f82d3SEliot Blennerhassett u32 h_instream, u32 *poutstream_map, u32 *pinstream_map) 1318719f82d3SEliot Blennerhassett { 1319719f82d3SEliot Blennerhassett struct hpi_message hm; 1320719f82d3SEliot Blennerhassett struct hpi_response hr; 1321719f82d3SEliot Blennerhassett 1322719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1323719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_FREE); 1324719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1325719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1326719f82d3SEliot Blennerhassett 1327719f82d3SEliot Blennerhassett if (poutstream_map) 1328719f82d3SEliot Blennerhassett *poutstream_map = hr.u.d.u.group_info.outstream_group_map; 1329719f82d3SEliot Blennerhassett if (pinstream_map) 1330719f82d3SEliot Blennerhassett *pinstream_map = hr.u.d.u.group_info.instream_group_map; 1331719f82d3SEliot Blennerhassett 1332719f82d3SEliot Blennerhassett return hr.error; 1333719f82d3SEliot Blennerhassett } 1334719f82d3SEliot Blennerhassett 1335719f82d3SEliot Blennerhassett u16 hpi_instream_group_reset(const struct hpi_hsubsys *ph_subsys, 1336719f82d3SEliot Blennerhassett u32 h_instream) 1337719f82d3SEliot Blennerhassett { 1338719f82d3SEliot Blennerhassett struct hpi_message hm; 1339719f82d3SEliot Blennerhassett struct hpi_response hr; 1340719f82d3SEliot Blennerhassett 1341719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1342719f82d3SEliot Blennerhassett HPI_ISTREAM_GROUP_RESET); 1343719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1344719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1345719f82d3SEliot Blennerhassett return hr.error; 1346719f82d3SEliot Blennerhassett } 1347719f82d3SEliot Blennerhassett 1348719f82d3SEliot Blennerhassett u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 1349719f82d3SEliot Blennerhassett u32 *ph_mixer) 1350719f82d3SEliot Blennerhassett { 1351719f82d3SEliot Blennerhassett struct hpi_message hm; 1352719f82d3SEliot Blennerhassett struct hpi_response hr; 1353719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN); 1354719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 1355719f82d3SEliot Blennerhassett 1356719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1357719f82d3SEliot Blennerhassett 1358719f82d3SEliot Blennerhassett if (hr.error == 0) 1359719f82d3SEliot Blennerhassett *ph_mixer = 1360719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_MIXER, adapter_index, 1361719f82d3SEliot Blennerhassett 0); 1362719f82d3SEliot Blennerhassett else 1363719f82d3SEliot Blennerhassett *ph_mixer = 0; 1364719f82d3SEliot Blennerhassett return hr.error; 1365719f82d3SEliot Blennerhassett } 1366719f82d3SEliot Blennerhassett 1367719f82d3SEliot Blennerhassett u16 hpi_mixer_close(const struct hpi_hsubsys *ph_subsys, u32 h_mixer) 1368719f82d3SEliot Blennerhassett { 1369719f82d3SEliot Blennerhassett struct hpi_message hm; 1370719f82d3SEliot Blennerhassett struct hpi_response hr; 1371719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE); 1372719f82d3SEliot Blennerhassett u32TOINDEX(h_mixer, &hm.adapter_index); 1373719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1374719f82d3SEliot Blennerhassett return hr.error; 1375719f82d3SEliot Blennerhassett } 1376719f82d3SEliot Blennerhassett 1377719f82d3SEliot Blennerhassett u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, 1378719f82d3SEliot Blennerhassett u16 src_node_type, u16 src_node_type_index, u16 dst_node_type, 1379719f82d3SEliot Blennerhassett u16 dst_node_type_index, u16 control_type, u32 *ph_control) 1380719f82d3SEliot Blennerhassett { 1381719f82d3SEliot Blennerhassett struct hpi_message hm; 1382719f82d3SEliot Blennerhassett struct hpi_response hr; 1383719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, 1384719f82d3SEliot Blennerhassett HPI_MIXER_GET_CONTROL); 1385719f82d3SEliot Blennerhassett u32TOINDEX(h_mixer, &hm.adapter_index); 1386719f82d3SEliot Blennerhassett hm.u.m.node_type1 = src_node_type; 1387719f82d3SEliot Blennerhassett hm.u.m.node_index1 = src_node_type_index; 1388719f82d3SEliot Blennerhassett hm.u.m.node_type2 = dst_node_type; 1389719f82d3SEliot Blennerhassett hm.u.m.node_index2 = dst_node_type_index; 1390719f82d3SEliot Blennerhassett hm.u.m.control_type = control_type; 1391719f82d3SEliot Blennerhassett 1392719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1393719f82d3SEliot Blennerhassett 1394719f82d3SEliot Blennerhassett if (hr.error == 0) 1395719f82d3SEliot Blennerhassett *ph_control = 1396719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_CONTROL, 1397719f82d3SEliot Blennerhassett hm.adapter_index, hr.u.m.control_index); 1398719f82d3SEliot Blennerhassett else 1399719f82d3SEliot Blennerhassett *ph_control = 0; 1400719f82d3SEliot Blennerhassett return hr.error; 1401719f82d3SEliot Blennerhassett } 1402719f82d3SEliot Blennerhassett 1403719f82d3SEliot Blennerhassett u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys, 1404719f82d3SEliot Blennerhassett u32 h_mixer, u16 control_index, u16 *pw_src_node_type, 1405719f82d3SEliot Blennerhassett u16 *pw_src_node_index, u16 *pw_dst_node_type, u16 *pw_dst_node_index, 1406719f82d3SEliot Blennerhassett u16 *pw_control_type, u32 *ph_control) 1407719f82d3SEliot Blennerhassett { 1408719f82d3SEliot Blennerhassett struct hpi_message hm; 1409719f82d3SEliot Blennerhassett struct hpi_response hr; 1410719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, 1411719f82d3SEliot Blennerhassett HPI_MIXER_GET_CONTROL_BY_INDEX); 1412719f82d3SEliot Blennerhassett u32TOINDEX(h_mixer, &hm.adapter_index); 1413719f82d3SEliot Blennerhassett hm.u.m.control_index = control_index; 1414719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1415719f82d3SEliot Blennerhassett 1416719f82d3SEliot Blennerhassett if (pw_src_node_type) { 1417719f82d3SEliot Blennerhassett *pw_src_node_type = 1418719f82d3SEliot Blennerhassett hr.u.m.src_node_type + HPI_SOURCENODE_NONE; 1419719f82d3SEliot Blennerhassett *pw_src_node_index = hr.u.m.src_node_index; 1420719f82d3SEliot Blennerhassett *pw_dst_node_type = hr.u.m.dst_node_type + HPI_DESTNODE_NONE; 1421719f82d3SEliot Blennerhassett *pw_dst_node_index = hr.u.m.dst_node_index; 1422719f82d3SEliot Blennerhassett } 1423719f82d3SEliot Blennerhassett if (pw_control_type) 1424719f82d3SEliot Blennerhassett *pw_control_type = hr.u.m.control_index; 1425719f82d3SEliot Blennerhassett 1426719f82d3SEliot Blennerhassett if (ph_control) { 1427719f82d3SEliot Blennerhassett if (hr.error == 0) 1428719f82d3SEliot Blennerhassett *ph_control = 1429719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_CONTROL, 1430719f82d3SEliot Blennerhassett hm.adapter_index, control_index); 1431719f82d3SEliot Blennerhassett else 1432719f82d3SEliot Blennerhassett *ph_control = 0; 1433719f82d3SEliot Blennerhassett } 1434719f82d3SEliot Blennerhassett return hr.error; 1435719f82d3SEliot Blennerhassett } 1436719f82d3SEliot Blennerhassett 1437719f82d3SEliot Blennerhassett u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, 1438719f82d3SEliot Blennerhassett enum HPI_MIXER_STORE_COMMAND command, u16 index) 1439719f82d3SEliot Blennerhassett { 1440719f82d3SEliot Blennerhassett struct hpi_message hm; 1441719f82d3SEliot Blennerhassett struct hpi_response hr; 1442719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_STORE); 1443719f82d3SEliot Blennerhassett u32TOINDEX(h_mixer, &hm.adapter_index); 1444719f82d3SEliot Blennerhassett hm.u.mx.store.command = command; 1445719f82d3SEliot Blennerhassett hm.u.mx.store.index = index; 1446719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1447719f82d3SEliot Blennerhassett return hr.error; 1448719f82d3SEliot Blennerhassett } 1449719f82d3SEliot Blennerhassett 1450719f82d3SEliot Blennerhassett static 1451719f82d3SEliot Blennerhassett u16 hpi_control_param_set(const struct hpi_hsubsys *ph_subsys, 1452719f82d3SEliot Blennerhassett const u32 h_control, const u16 attrib, const u32 param1, 1453719f82d3SEliot Blennerhassett const u32 param2) 1454719f82d3SEliot Blennerhassett { 1455719f82d3SEliot Blennerhassett struct hpi_message hm; 1456719f82d3SEliot Blennerhassett struct hpi_response hr; 1457108ccb3fSEliot Blennerhassett 1458719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1459719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 1460719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1461719f82d3SEliot Blennerhassett hm.u.c.attribute = attrib; 1462719f82d3SEliot Blennerhassett hm.u.c.param1 = param1; 1463719f82d3SEliot Blennerhassett hm.u.c.param2 = param2; 1464719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1465719f82d3SEliot Blennerhassett return hr.error; 1466719f82d3SEliot Blennerhassett } 1467719f82d3SEliot Blennerhassett 1468108ccb3fSEliot Blennerhassett static u16 hpi_control_log_set2(u32 h_control, u16 attrib, short sv0, 1469108ccb3fSEliot Blennerhassett short sv1) 1470108ccb3fSEliot Blennerhassett { 1471108ccb3fSEliot Blennerhassett struct hpi_message hm; 1472108ccb3fSEliot Blennerhassett struct hpi_response hr; 1473108ccb3fSEliot Blennerhassett 1474108ccb3fSEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1475108ccb3fSEliot Blennerhassett HPI_CONTROL_SET_STATE); 1476108ccb3fSEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1477108ccb3fSEliot Blennerhassett hm.u.c.attribute = attrib; 1478108ccb3fSEliot Blennerhassett hm.u.c.an_log_value[0] = sv0; 1479108ccb3fSEliot Blennerhassett hm.u.c.an_log_value[1] = sv1; 1480108ccb3fSEliot Blennerhassett hpi_send_recv(&hm, &hr); 1481108ccb3fSEliot Blennerhassett return hr.error; 1482108ccb3fSEliot Blennerhassett } 1483108ccb3fSEliot Blennerhassett 1484719f82d3SEliot Blennerhassett static 1485719f82d3SEliot Blennerhassett u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys, 1486719f82d3SEliot Blennerhassett const u32 h_control, const u16 attrib, u32 param1, u32 param2, 1487719f82d3SEliot Blennerhassett u32 *pparam1, u32 *pparam2) 1488719f82d3SEliot Blennerhassett { 1489719f82d3SEliot Blennerhassett struct hpi_message hm; 1490719f82d3SEliot Blennerhassett struct hpi_response hr; 1491108ccb3fSEliot Blennerhassett 1492719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1493719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1494719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1495719f82d3SEliot Blennerhassett hm.u.c.attribute = attrib; 1496719f82d3SEliot Blennerhassett hm.u.c.param1 = param1; 1497719f82d3SEliot Blennerhassett hm.u.c.param2 = param2; 1498719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1499108ccb3fSEliot Blennerhassett 1500719f82d3SEliot Blennerhassett *pparam1 = hr.u.c.param1; 1501719f82d3SEliot Blennerhassett if (pparam2) 1502719f82d3SEliot Blennerhassett *pparam2 = hr.u.c.param2; 1503719f82d3SEliot Blennerhassett 1504719f82d3SEliot Blennerhassett return hr.error; 1505719f82d3SEliot Blennerhassett } 1506719f82d3SEliot Blennerhassett 1507719f82d3SEliot Blennerhassett #define hpi_control_param1_get(s, h, a, p1) \ 1508719f82d3SEliot Blennerhassett hpi_control_param_get(s, h, a, 0, 0, p1, NULL) 1509719f82d3SEliot Blennerhassett #define hpi_control_param2_get(s, h, a, p1, p2) \ 1510719f82d3SEliot Blennerhassett hpi_control_param_get(s, h, a, 0, 0, p1, p2) 1511108ccb3fSEliot Blennerhassett 1512108ccb3fSEliot Blennerhassett static u16 hpi_control_log_get2(const struct hpi_hsubsys *ph_subsys, 1513108ccb3fSEliot Blennerhassett u32 h_control, u16 attrib, short *sv0, short *sv1) 1514108ccb3fSEliot Blennerhassett { 1515108ccb3fSEliot Blennerhassett struct hpi_message hm; 1516108ccb3fSEliot Blennerhassett struct hpi_response hr; 1517108ccb3fSEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1518108ccb3fSEliot Blennerhassett HPI_CONTROL_GET_STATE); 1519108ccb3fSEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1520108ccb3fSEliot Blennerhassett hm.u.c.attribute = attrib; 1521108ccb3fSEliot Blennerhassett 1522108ccb3fSEliot Blennerhassett hpi_send_recv(&hm, &hr); 1523108ccb3fSEliot Blennerhassett *sv0 = hr.u.c.an_log_value[0]; 1524108ccb3fSEliot Blennerhassett if (sv1) 1525108ccb3fSEliot Blennerhassett *sv1 = hr.u.c.an_log_value[1]; 1526108ccb3fSEliot Blennerhassett return hr.error; 1527108ccb3fSEliot Blennerhassett } 1528719f82d3SEliot Blennerhassett 1529719f82d3SEliot Blennerhassett static 1530719f82d3SEliot Blennerhassett u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys, 1531719f82d3SEliot Blennerhassett const u32 h_control, const u16 attrib, const u32 index, 1532719f82d3SEliot Blennerhassett const u32 param, u32 *psetting) 1533719f82d3SEliot Blennerhassett { 1534719f82d3SEliot Blennerhassett struct hpi_message hm; 1535719f82d3SEliot Blennerhassett struct hpi_response hr; 1536108ccb3fSEliot Blennerhassett 1537719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1538719f82d3SEliot Blennerhassett HPI_CONTROL_GET_INFO); 1539719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1540719f82d3SEliot Blennerhassett 1541719f82d3SEliot Blennerhassett hm.u.c.attribute = attrib; 1542719f82d3SEliot Blennerhassett hm.u.c.param1 = index; 1543719f82d3SEliot Blennerhassett hm.u.c.param2 = param; 1544719f82d3SEliot Blennerhassett 1545719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1546719f82d3SEliot Blennerhassett *psetting = hr.u.c.param1; 1547719f82d3SEliot Blennerhassett 1548719f82d3SEliot Blennerhassett return hr.error; 1549719f82d3SEliot Blennerhassett } 1550719f82d3SEliot Blennerhassett 1551108ccb3fSEliot Blennerhassett static u16 hpi_control_get_string(const u32 h_control, const u16 attribute, 1552108ccb3fSEliot Blennerhassett char *psz_string, const u32 string_length) 1553719f82d3SEliot Blennerhassett { 1554719f82d3SEliot Blennerhassett unsigned int sub_string_index = 0, j = 0; 1555719f82d3SEliot Blennerhassett char c = 0; 1556719f82d3SEliot Blennerhassett unsigned int n = 0; 1557*3285ea10SEliot Blennerhassett u16 err = 0; 1558719f82d3SEliot Blennerhassett 1559719f82d3SEliot Blennerhassett if ((string_length < 1) || (string_length > 256)) 1560719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_CONTROL_VALUE; 1561719f82d3SEliot Blennerhassett for (sub_string_index = 0; sub_string_index < string_length; 1562719f82d3SEliot Blennerhassett sub_string_index += 8) { 1563719f82d3SEliot Blennerhassett struct hpi_message hm; 1564719f82d3SEliot Blennerhassett struct hpi_response hr; 1565719f82d3SEliot Blennerhassett 1566719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1567719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1568719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1569719f82d3SEliot Blennerhassett hm.u.c.attribute = attribute; 1570719f82d3SEliot Blennerhassett hm.u.c.param1 = sub_string_index; 1571719f82d3SEliot Blennerhassett hm.u.c.param2 = 0; 1572719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1573719f82d3SEliot Blennerhassett 1574719f82d3SEliot Blennerhassett if (sub_string_index == 0 1575719f82d3SEliot Blennerhassett && (hr.u.cu.chars8.remaining_chars + 8) > 1576719f82d3SEliot Blennerhassett string_length) 1577719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_CONTROL_VALUE; 1578719f82d3SEliot Blennerhassett 1579719f82d3SEliot Blennerhassett if (hr.error) { 1580*3285ea10SEliot Blennerhassett err = hr.error; 1581719f82d3SEliot Blennerhassett break; 1582719f82d3SEliot Blennerhassett } 1583719f82d3SEliot Blennerhassett for (j = 0; j < 8; j++) { 1584719f82d3SEliot Blennerhassett c = hr.u.cu.chars8.sz_data[j]; 1585719f82d3SEliot Blennerhassett psz_string[sub_string_index + j] = c; 1586719f82d3SEliot Blennerhassett n++; 1587719f82d3SEliot Blennerhassett if (n >= string_length) { 1588719f82d3SEliot Blennerhassett psz_string[string_length - 1] = 0; 1589*3285ea10SEliot Blennerhassett err = HPI_ERROR_INVALID_CONTROL_VALUE; 1590719f82d3SEliot Blennerhassett break; 1591719f82d3SEliot Blennerhassett } 1592719f82d3SEliot Blennerhassett if (c == 0) 1593719f82d3SEliot Blennerhassett break; 1594719f82d3SEliot Blennerhassett } 1595719f82d3SEliot Blennerhassett 1596719f82d3SEliot Blennerhassett if ((hr.u.cu.chars8.remaining_chars == 0) 1597719f82d3SEliot Blennerhassett && ((sub_string_index + j) < string_length) 1598719f82d3SEliot Blennerhassett && (c != 0)) { 1599719f82d3SEliot Blennerhassett c = 0; 1600719f82d3SEliot Blennerhassett psz_string[sub_string_index + j] = c; 1601719f82d3SEliot Blennerhassett } 1602719f82d3SEliot Blennerhassett if (c == 0) 1603719f82d3SEliot Blennerhassett break; 1604719f82d3SEliot Blennerhassett } 1605*3285ea10SEliot Blennerhassett return err; 1606719f82d3SEliot Blennerhassett } 1607719f82d3SEliot Blennerhassett 1608719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys *ph_subsys, 1609719f82d3SEliot Blennerhassett const u32 h_aes_rx, const u32 index, u16 *pw_format) 1610719f82d3SEliot Blennerhassett { 1611719f82d3SEliot Blennerhassett u32 qr; 1612719f82d3SEliot Blennerhassett u16 err; 1613719f82d3SEliot Blennerhassett 1614719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_aes_rx, HPI_AESEBURX_FORMAT, 1615719f82d3SEliot Blennerhassett index, 0, &qr); 1616719f82d3SEliot Blennerhassett *pw_format = (u16)qr; 1617719f82d3SEliot Blennerhassett return err; 1618719f82d3SEliot Blennerhassett } 1619719f82d3SEliot Blennerhassett 1620719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_set_format(const struct hpi_hsubsys *ph_subsys, 1621719f82d3SEliot Blennerhassett u32 h_control, u16 format) 1622719f82d3SEliot Blennerhassett { 1623719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1624719f82d3SEliot Blennerhassett HPI_AESEBURX_FORMAT, format, 0); 1625719f82d3SEliot Blennerhassett } 1626719f82d3SEliot Blennerhassett 1627719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_get_format(const struct hpi_hsubsys *ph_subsys, 1628719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_format) 1629719f82d3SEliot Blennerhassett { 1630719f82d3SEliot Blennerhassett u16 err; 1631719f82d3SEliot Blennerhassett u32 param; 1632719f82d3SEliot Blennerhassett 1633719f82d3SEliot Blennerhassett err = hpi_control_param1_get(ph_subsys, h_control, 1634719f82d3SEliot Blennerhassett HPI_AESEBURX_FORMAT, ¶m); 1635719f82d3SEliot Blennerhassett if (!err && pw_format) 1636719f82d3SEliot Blennerhassett *pw_format = (u16)param; 1637719f82d3SEliot Blennerhassett 1638719f82d3SEliot Blennerhassett return err; 1639719f82d3SEliot Blennerhassett } 1640719f82d3SEliot Blennerhassett 1641719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_get_sample_rate(const struct hpi_hsubsys *ph_subsys, 1642719f82d3SEliot Blennerhassett u32 h_control, u32 *psample_rate) 1643719f82d3SEliot Blennerhassett { 1644719f82d3SEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 1645719f82d3SEliot Blennerhassett HPI_AESEBURX_SAMPLERATE, psample_rate); 1646719f82d3SEliot Blennerhassett } 1647719f82d3SEliot Blennerhassett 1648719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys, 1649719f82d3SEliot Blennerhassett u32 h_control, u16 index, u16 *pw_data) 1650719f82d3SEliot Blennerhassett { 1651719f82d3SEliot Blennerhassett struct hpi_message hm; 1652719f82d3SEliot Blennerhassett struct hpi_response hr; 1653719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1654719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1655719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1656719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_AESEBURX_USERDATA; 1657719f82d3SEliot Blennerhassett hm.u.c.param1 = index; 1658719f82d3SEliot Blennerhassett 1659719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1660719f82d3SEliot Blennerhassett 1661719f82d3SEliot Blennerhassett if (pw_data) 1662719f82d3SEliot Blennerhassett *pw_data = (u16)hr.u.c.param2; 1663719f82d3SEliot Blennerhassett return hr.error; 1664719f82d3SEliot Blennerhassett } 1665719f82d3SEliot Blennerhassett 1666719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys 1667719f82d3SEliot Blennerhassett *ph_subsys, u32 h_control, u16 index, u16 *pw_data) 1668719f82d3SEliot Blennerhassett { 1669719f82d3SEliot Blennerhassett struct hpi_message hm; 1670719f82d3SEliot Blennerhassett struct hpi_response hr; 1671719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1672719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1673719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1674719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_AESEBURX_CHANNELSTATUS; 1675719f82d3SEliot Blennerhassett hm.u.c.param1 = index; 1676719f82d3SEliot Blennerhassett 1677719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1678719f82d3SEliot Blennerhassett 1679719f82d3SEliot Blennerhassett if (pw_data) 1680719f82d3SEliot Blennerhassett *pw_data = (u16)hr.u.c.param2; 1681719f82d3SEliot Blennerhassett return hr.error; 1682719f82d3SEliot Blennerhassett } 1683719f82d3SEliot Blennerhassett 1684719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_get_error_status(const struct hpi_hsubsys *ph_subsys, 1685719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_error_data) 1686719f82d3SEliot Blennerhassett { 1687719f82d3SEliot Blennerhassett u32 error_data = 0; 1688719f82d3SEliot Blennerhassett u16 error = 0; 1689719f82d3SEliot Blennerhassett 1690719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, 1691719f82d3SEliot Blennerhassett HPI_AESEBURX_ERRORSTATUS, &error_data); 1692719f82d3SEliot Blennerhassett if (pw_error_data) 1693719f82d3SEliot Blennerhassett *pw_error_data = (u16)error_data; 1694719f82d3SEliot Blennerhassett return error; 1695719f82d3SEliot Blennerhassett } 1696719f82d3SEliot Blennerhassett 1697719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_set_sample_rate(const struct hpi_hsubsys 1698719f82d3SEliot Blennerhassett *ph_subsys, u32 h_control, u32 sample_rate) 1699719f82d3SEliot Blennerhassett { 1700719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1701719f82d3SEliot Blennerhassett HPI_AESEBUTX_SAMPLERATE, sample_rate, 0); 1702719f82d3SEliot Blennerhassett } 1703719f82d3SEliot Blennerhassett 1704719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_set_user_data(const struct hpi_hsubsys *ph_subsys, 1705719f82d3SEliot Blennerhassett u32 h_control, u16 index, u16 data) 1706719f82d3SEliot Blennerhassett { 1707719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1708719f82d3SEliot Blennerhassett HPI_AESEBUTX_USERDATA, index, data); 1709719f82d3SEliot Blennerhassett } 1710719f82d3SEliot Blennerhassett 1711719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_set_channel_status(const struct hpi_hsubsys 1712719f82d3SEliot Blennerhassett *ph_subsys, u32 h_control, u16 index, u16 data) 1713719f82d3SEliot Blennerhassett { 1714719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1715719f82d3SEliot Blennerhassett HPI_AESEBUTX_CHANNELSTATUS, index, data); 1716719f82d3SEliot Blennerhassett } 1717719f82d3SEliot Blennerhassett 1718719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_get_channel_status(const struct hpi_hsubsys 1719719f82d3SEliot Blennerhassett *ph_subsys, u32 h_control, u16 index, u16 *pw_data) 1720719f82d3SEliot Blennerhassett { 1721719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_OPERATION; 1722719f82d3SEliot Blennerhassett } 1723719f82d3SEliot Blennerhassett 1724719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_query_format(const struct hpi_hsubsys *ph_subsys, 1725719f82d3SEliot Blennerhassett const u32 h_aes_tx, const u32 index, u16 *pw_format) 1726719f82d3SEliot Blennerhassett { 1727719f82d3SEliot Blennerhassett u32 qr; 1728719f82d3SEliot Blennerhassett u16 err; 1729719f82d3SEliot Blennerhassett 1730719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_aes_tx, HPI_AESEBUTX_FORMAT, 1731719f82d3SEliot Blennerhassett index, 0, &qr); 1732719f82d3SEliot Blennerhassett *pw_format = (u16)qr; 1733719f82d3SEliot Blennerhassett return err; 1734719f82d3SEliot Blennerhassett } 1735719f82d3SEliot Blennerhassett 1736719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_set_format(const struct hpi_hsubsys *ph_subsys, 1737719f82d3SEliot Blennerhassett u32 h_control, u16 output_format) 1738719f82d3SEliot Blennerhassett { 1739719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1740719f82d3SEliot Blennerhassett HPI_AESEBUTX_FORMAT, output_format, 0); 1741719f82d3SEliot Blennerhassett } 1742719f82d3SEliot Blennerhassett 1743719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_get_format(const struct hpi_hsubsys *ph_subsys, 1744719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_output_format) 1745719f82d3SEliot Blennerhassett { 1746719f82d3SEliot Blennerhassett u16 err; 1747719f82d3SEliot Blennerhassett u32 param; 1748719f82d3SEliot Blennerhassett 1749719f82d3SEliot Blennerhassett err = hpi_control_param1_get(ph_subsys, h_control, 1750719f82d3SEliot Blennerhassett HPI_AESEBUTX_FORMAT, ¶m); 1751719f82d3SEliot Blennerhassett if (!err && pw_output_format) 1752719f82d3SEliot Blennerhassett *pw_output_format = (u16)param; 1753719f82d3SEliot Blennerhassett 1754719f82d3SEliot Blennerhassett return err; 1755719f82d3SEliot Blennerhassett } 1756719f82d3SEliot Blennerhassett 1757719f82d3SEliot Blennerhassett u16 hpi_bitstream_set_clock_edge(const struct hpi_hsubsys *ph_subsys, 1758719f82d3SEliot Blennerhassett u32 h_control, u16 edge_type) 1759719f82d3SEliot Blennerhassett { 1760719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1761719f82d3SEliot Blennerhassett HPI_BITSTREAM_CLOCK_EDGE, edge_type, 0); 1762719f82d3SEliot Blennerhassett } 1763719f82d3SEliot Blennerhassett 1764719f82d3SEliot Blennerhassett u16 hpi_bitstream_set_data_polarity(const struct hpi_hsubsys *ph_subsys, 1765719f82d3SEliot Blennerhassett u32 h_control, u16 polarity) 1766719f82d3SEliot Blennerhassett { 1767719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1768719f82d3SEliot Blennerhassett HPI_BITSTREAM_DATA_POLARITY, polarity, 0); 1769719f82d3SEliot Blennerhassett } 1770719f82d3SEliot Blennerhassett 1771719f82d3SEliot Blennerhassett u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys, 1772719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_clk_activity, u16 *pw_data_activity) 1773719f82d3SEliot Blennerhassett { 1774719f82d3SEliot Blennerhassett struct hpi_message hm; 1775719f82d3SEliot Blennerhassett struct hpi_response hr; 1776719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1777719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1778719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1779719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_BITSTREAM_ACTIVITY; 1780719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1781719f82d3SEliot Blennerhassett if (pw_clk_activity) 1782719f82d3SEliot Blennerhassett *pw_clk_activity = (u16)hr.u.c.param1; 1783719f82d3SEliot Blennerhassett if (pw_data_activity) 1784719f82d3SEliot Blennerhassett *pw_data_activity = (u16)hr.u.c.param2; 1785719f82d3SEliot Blennerhassett return hr.error; 1786719f82d3SEliot Blennerhassett } 1787719f82d3SEliot Blennerhassett 1788719f82d3SEliot Blennerhassett u16 hpi_channel_mode_query_mode(const struct hpi_hsubsys *ph_subsys, 1789719f82d3SEliot Blennerhassett const u32 h_mode, const u32 index, u16 *pw_mode) 1790719f82d3SEliot Blennerhassett { 1791719f82d3SEliot Blennerhassett u32 qr; 1792719f82d3SEliot Blennerhassett u16 err; 1793719f82d3SEliot Blennerhassett 1794719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_mode, HPI_CHANNEL_MODE_MODE, 1795719f82d3SEliot Blennerhassett index, 0, &qr); 1796719f82d3SEliot Blennerhassett *pw_mode = (u16)qr; 1797719f82d3SEliot Blennerhassett return err; 1798719f82d3SEliot Blennerhassett } 1799719f82d3SEliot Blennerhassett 1800719f82d3SEliot Blennerhassett u16 hpi_channel_mode_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1801719f82d3SEliot Blennerhassett u16 mode) 1802719f82d3SEliot Blennerhassett { 1803719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1804719f82d3SEliot Blennerhassett HPI_CHANNEL_MODE_MODE, mode, 0); 1805719f82d3SEliot Blennerhassett } 1806719f82d3SEliot Blennerhassett 1807719f82d3SEliot Blennerhassett u16 hpi_channel_mode_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1808719f82d3SEliot Blennerhassett u16 *mode) 1809719f82d3SEliot Blennerhassett { 1810719f82d3SEliot Blennerhassett u32 mode32 = 0; 1811719f82d3SEliot Blennerhassett u16 error = hpi_control_param1_get(ph_subsys, h_control, 1812719f82d3SEliot Blennerhassett HPI_CHANNEL_MODE_MODE, &mode32); 1813719f82d3SEliot Blennerhassett if (mode) 1814719f82d3SEliot Blennerhassett *mode = (u16)mode32; 1815719f82d3SEliot Blennerhassett return error; 1816719f82d3SEliot Blennerhassett } 1817719f82d3SEliot Blennerhassett 1818719f82d3SEliot Blennerhassett u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1819719f82d3SEliot Blennerhassett u32 hmi_address, u32 byte_count, u8 *pb_data) 1820719f82d3SEliot Blennerhassett { 1821719f82d3SEliot Blennerhassett struct hpi_message hm; 1822719f82d3SEliot Blennerhassett struct hpi_response hr; 1823108ccb3fSEliot Blennerhassett 1824719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1825719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 1826719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1827719f82d3SEliot Blennerhassett 1828719f82d3SEliot Blennerhassett hm.u.cx.u.cobranet_data.byte_count = byte_count; 1829719f82d3SEliot Blennerhassett hm.u.cx.u.cobranet_data.hmi_address = hmi_address; 1830719f82d3SEliot Blennerhassett 1831719f82d3SEliot Blennerhassett if (byte_count <= 8) { 1832719f82d3SEliot Blennerhassett memcpy(hm.u.cx.u.cobranet_data.data, pb_data, byte_count); 1833719f82d3SEliot Blennerhassett hm.u.cx.attribute = HPI_COBRANET_SET; 1834719f82d3SEliot Blennerhassett } else { 1835719f82d3SEliot Blennerhassett hm.u.cx.u.cobranet_bigdata.pb_data = pb_data; 1836719f82d3SEliot Blennerhassett hm.u.cx.attribute = HPI_COBRANET_SET_DATA; 1837719f82d3SEliot Blennerhassett } 1838719f82d3SEliot Blennerhassett 1839719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1840719f82d3SEliot Blennerhassett 1841719f82d3SEliot Blennerhassett return hr.error; 1842719f82d3SEliot Blennerhassett } 1843719f82d3SEliot Blennerhassett 1844719f82d3SEliot Blennerhassett u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1845719f82d3SEliot Blennerhassett u32 hmi_address, u32 max_byte_count, u32 *pbyte_count, u8 *pb_data) 1846719f82d3SEliot Blennerhassett { 1847719f82d3SEliot Blennerhassett struct hpi_message hm; 1848719f82d3SEliot Blennerhassett struct hpi_response hr; 1849108ccb3fSEliot Blennerhassett 1850719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1851719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1852719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1853719f82d3SEliot Blennerhassett 1854719f82d3SEliot Blennerhassett hm.u.cx.u.cobranet_data.byte_count = max_byte_count; 1855719f82d3SEliot Blennerhassett hm.u.cx.u.cobranet_data.hmi_address = hmi_address; 1856719f82d3SEliot Blennerhassett 1857719f82d3SEliot Blennerhassett if (max_byte_count <= 8) { 1858719f82d3SEliot Blennerhassett hm.u.cx.attribute = HPI_COBRANET_GET; 1859719f82d3SEliot Blennerhassett } else { 1860719f82d3SEliot Blennerhassett hm.u.cx.u.cobranet_bigdata.pb_data = pb_data; 1861719f82d3SEliot Blennerhassett hm.u.cx.attribute = HPI_COBRANET_GET_DATA; 1862719f82d3SEliot Blennerhassett } 1863719f82d3SEliot Blennerhassett 1864719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1865719f82d3SEliot Blennerhassett if (!hr.error && pb_data) { 1866719f82d3SEliot Blennerhassett 1867719f82d3SEliot Blennerhassett *pbyte_count = hr.u.cx.u.cobranet_data.byte_count; 1868719f82d3SEliot Blennerhassett 1869719f82d3SEliot Blennerhassett if (*pbyte_count < max_byte_count) 1870719f82d3SEliot Blennerhassett max_byte_count = *pbyte_count; 1871719f82d3SEliot Blennerhassett 1872719f82d3SEliot Blennerhassett if (hm.u.cx.attribute == HPI_COBRANET_GET) { 1873719f82d3SEliot Blennerhassett memcpy(pb_data, hr.u.cx.u.cobranet_data.data, 1874719f82d3SEliot Blennerhassett max_byte_count); 1875719f82d3SEliot Blennerhassett } else { 1876719f82d3SEliot Blennerhassett 1877719f82d3SEliot Blennerhassett } 1878719f82d3SEliot Blennerhassett 1879719f82d3SEliot Blennerhassett } 1880719f82d3SEliot Blennerhassett return hr.error; 1881719f82d3SEliot Blennerhassett } 1882719f82d3SEliot Blennerhassett 1883719f82d3SEliot Blennerhassett u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys, 1884719f82d3SEliot Blennerhassett u32 h_control, u32 *pstatus, u32 *preadable_size, 1885719f82d3SEliot Blennerhassett u32 *pwriteable_size) 1886719f82d3SEliot Blennerhassett { 1887719f82d3SEliot Blennerhassett struct hpi_message hm; 1888719f82d3SEliot Blennerhassett struct hpi_response hr; 1889108ccb3fSEliot Blennerhassett 1890719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1891719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1892719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1893719f82d3SEliot Blennerhassett 1894719f82d3SEliot Blennerhassett hm.u.cx.attribute = HPI_COBRANET_GET_STATUS; 1895719f82d3SEliot Blennerhassett 1896719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1897719f82d3SEliot Blennerhassett if (!hr.error) { 1898719f82d3SEliot Blennerhassett if (pstatus) 1899719f82d3SEliot Blennerhassett *pstatus = hr.u.cx.u.cobranet_status.status; 1900719f82d3SEliot Blennerhassett if (preadable_size) 1901719f82d3SEliot Blennerhassett *preadable_size = 1902719f82d3SEliot Blennerhassett hr.u.cx.u.cobranet_status.readable_size; 1903719f82d3SEliot Blennerhassett if (pwriteable_size) 1904719f82d3SEliot Blennerhassett *pwriteable_size = 1905719f82d3SEliot Blennerhassett hr.u.cx.u.cobranet_status.writeable_size; 1906719f82d3SEliot Blennerhassett } 1907719f82d3SEliot Blennerhassett return hr.error; 1908719f82d3SEliot Blennerhassett } 1909719f82d3SEliot Blennerhassett 1910719f82d3SEliot Blennerhassett u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys, 1911719f82d3SEliot Blennerhassett u32 h_control, u32 *pi_paddress) 1912719f82d3SEliot Blennerhassett { 1913719f82d3SEliot Blennerhassett u32 byte_count; 1914719f82d3SEliot Blennerhassett u32 iP; 1915719f82d3SEliot Blennerhassett u16 error; 1916108ccb3fSEliot Blennerhassett 1917719f82d3SEliot Blennerhassett error = hpi_cobranet_hmi_read(ph_subsys, h_control, 1918719f82d3SEliot Blennerhassett HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count, 1919719f82d3SEliot Blennerhassett (u8 *)&iP); 1920719f82d3SEliot Blennerhassett 1921719f82d3SEliot Blennerhassett *pi_paddress = 1922719f82d3SEliot Blennerhassett ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP & 1923719f82d3SEliot Blennerhassett 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8); 1924719f82d3SEliot Blennerhassett 1925719f82d3SEliot Blennerhassett if (error) 1926719f82d3SEliot Blennerhassett *pi_paddress = 0; 1927719f82d3SEliot Blennerhassett 1928719f82d3SEliot Blennerhassett return error; 1929719f82d3SEliot Blennerhassett 1930719f82d3SEliot Blennerhassett } 1931719f82d3SEliot Blennerhassett 1932719f82d3SEliot Blennerhassett u16 hpi_cobranet_setI_paddress(const struct hpi_hsubsys *ph_subsys, 1933719f82d3SEliot Blennerhassett u32 h_control, u32 i_paddress) 1934719f82d3SEliot Blennerhassett { 1935719f82d3SEliot Blennerhassett u32 iP; 1936719f82d3SEliot Blennerhassett u16 error; 1937719f82d3SEliot Blennerhassett 1938719f82d3SEliot Blennerhassett iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) << 1939719f82d3SEliot Blennerhassett 8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress & 1940719f82d3SEliot Blennerhassett 0x000000ff) << 8); 1941719f82d3SEliot Blennerhassett 1942719f82d3SEliot Blennerhassett error = hpi_cobranet_hmi_write(ph_subsys, h_control, 1943719f82d3SEliot Blennerhassett HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, (u8 *)&iP); 1944719f82d3SEliot Blennerhassett 1945719f82d3SEliot Blennerhassett return error; 1946719f82d3SEliot Blennerhassett 1947719f82d3SEliot Blennerhassett } 1948719f82d3SEliot Blennerhassett 1949719f82d3SEliot Blennerhassett u16 hpi_cobranet_get_staticI_paddress(const struct hpi_hsubsys *ph_subsys, 1950719f82d3SEliot Blennerhassett u32 h_control, u32 *pi_paddress) 1951719f82d3SEliot Blennerhassett { 1952719f82d3SEliot Blennerhassett u32 byte_count; 1953719f82d3SEliot Blennerhassett u32 iP; 1954719f82d3SEliot Blennerhassett u16 error; 1955719f82d3SEliot Blennerhassett error = hpi_cobranet_hmi_read(ph_subsys, h_control, 1956719f82d3SEliot Blennerhassett HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count, 1957719f82d3SEliot Blennerhassett (u8 *)&iP); 1958719f82d3SEliot Blennerhassett 1959719f82d3SEliot Blennerhassett *pi_paddress = 1960719f82d3SEliot Blennerhassett ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP & 1961719f82d3SEliot Blennerhassett 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8); 1962719f82d3SEliot Blennerhassett 1963719f82d3SEliot Blennerhassett if (error) 1964719f82d3SEliot Blennerhassett *pi_paddress = 0; 1965719f82d3SEliot Blennerhassett 1966719f82d3SEliot Blennerhassett return error; 1967719f82d3SEliot Blennerhassett 1968719f82d3SEliot Blennerhassett } 1969719f82d3SEliot Blennerhassett 1970719f82d3SEliot Blennerhassett u16 hpi_cobranet_set_staticI_paddress(const struct hpi_hsubsys *ph_subsys, 1971719f82d3SEliot Blennerhassett u32 h_control, u32 i_paddress) 1972719f82d3SEliot Blennerhassett { 1973719f82d3SEliot Blennerhassett u32 iP; 1974719f82d3SEliot Blennerhassett u16 error; 1975719f82d3SEliot Blennerhassett 1976719f82d3SEliot Blennerhassett iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) << 1977719f82d3SEliot Blennerhassett 8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress & 1978719f82d3SEliot Blennerhassett 0x000000ff) << 8); 1979719f82d3SEliot Blennerhassett 1980719f82d3SEliot Blennerhassett error = hpi_cobranet_hmi_write(ph_subsys, h_control, 1981719f82d3SEliot Blennerhassett HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, (u8 *)&iP); 1982719f82d3SEliot Blennerhassett 1983719f82d3SEliot Blennerhassett return error; 1984719f82d3SEliot Blennerhassett 1985719f82d3SEliot Blennerhassett } 1986719f82d3SEliot Blennerhassett 1987719f82d3SEliot Blennerhassett u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys, 1988719f82d3SEliot Blennerhassett u32 h_control, u32 *pmAC_MS_bs, u32 *pmAC_LS_bs) 1989719f82d3SEliot Blennerhassett { 1990719f82d3SEliot Blennerhassett u32 byte_count; 1991719f82d3SEliot Blennerhassett u16 error; 1992719f82d3SEliot Blennerhassett u32 mAC; 1993108ccb3fSEliot Blennerhassett 1994719f82d3SEliot Blennerhassett error = hpi_cobranet_hmi_read(ph_subsys, h_control, 1995719f82d3SEliot Blennerhassett HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count, 1996719f82d3SEliot Blennerhassett (u8 *)&mAC); 1997719f82d3SEliot Blennerhassett *pmAC_MS_bs = 1998719f82d3SEliot Blennerhassett ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC 1999719f82d3SEliot Blennerhassett & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8); 2000719f82d3SEliot Blennerhassett error += hpi_cobranet_hmi_read(ph_subsys, h_control, 2001719f82d3SEliot Blennerhassett HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4, &byte_count, 2002719f82d3SEliot Blennerhassett (u8 *)&mAC); 2003719f82d3SEliot Blennerhassett *pmAC_LS_bs = 2004719f82d3SEliot Blennerhassett ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC 2005719f82d3SEliot Blennerhassett & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8); 2006719f82d3SEliot Blennerhassett 2007719f82d3SEliot Blennerhassett if (error) { 2008719f82d3SEliot Blennerhassett *pmAC_MS_bs = 0; 2009719f82d3SEliot Blennerhassett *pmAC_LS_bs = 0; 2010719f82d3SEliot Blennerhassett } 2011719f82d3SEliot Blennerhassett 2012719f82d3SEliot Blennerhassett return error; 2013719f82d3SEliot Blennerhassett } 2014719f82d3SEliot Blennerhassett 2015108ccb3fSEliot Blennerhassett u16 hpi_compander_set_enable(const struct hpi_hsubsys *ph_subsys, 2016108ccb3fSEliot Blennerhassett u32 h_control, u32 enable) 2017108ccb3fSEliot Blennerhassett { 2018108ccb3fSEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2019108ccb3fSEliot Blennerhassett enable, 0); 2020108ccb3fSEliot Blennerhassett } 2021108ccb3fSEliot Blennerhassett 2022108ccb3fSEliot Blennerhassett u16 hpi_compander_get_enable(const struct hpi_hsubsys *ph_subsys, 2023108ccb3fSEliot Blennerhassett u32 h_control, u32 *enable) 2024108ccb3fSEliot Blennerhassett { 2025108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2026108ccb3fSEliot Blennerhassett HPI_GENERIC_ENABLE, enable); 2027108ccb3fSEliot Blennerhassett } 2028108ccb3fSEliot Blennerhassett 2029108ccb3fSEliot Blennerhassett u16 hpi_compander_set_makeup_gain(const struct hpi_hsubsys *ph_subsys, 2030108ccb3fSEliot Blennerhassett u32 h_control, short makeup_gain0_01dB) 2031108ccb3fSEliot Blennerhassett { 2032108ccb3fSEliot Blennerhassett return hpi_control_log_set2(h_control, HPI_COMPANDER_MAKEUPGAIN, 2033108ccb3fSEliot Blennerhassett makeup_gain0_01dB, 0); 2034108ccb3fSEliot Blennerhassett } 2035108ccb3fSEliot Blennerhassett 2036108ccb3fSEliot Blennerhassett u16 hpi_compander_get_makeup_gain(const struct hpi_hsubsys *ph_subsys, 2037108ccb3fSEliot Blennerhassett u32 h_control, short *makeup_gain0_01dB) 2038108ccb3fSEliot Blennerhassett { 2039108ccb3fSEliot Blennerhassett return hpi_control_log_get2(ph_subsys, h_control, 2040108ccb3fSEliot Blennerhassett HPI_COMPANDER_MAKEUPGAIN, makeup_gain0_01dB, NULL); 2041108ccb3fSEliot Blennerhassett } 2042108ccb3fSEliot Blennerhassett 2043108ccb3fSEliot Blennerhassett u16 hpi_compander_set_attack_time_constant(const struct hpi_hsubsys 2044108ccb3fSEliot Blennerhassett *ph_subsys, u32 h_control, unsigned int index, u32 attack) 2045108ccb3fSEliot Blennerhassett { 2046108ccb3fSEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2047108ccb3fSEliot Blennerhassett HPI_COMPANDER_ATTACK, attack, index); 2048108ccb3fSEliot Blennerhassett } 2049108ccb3fSEliot Blennerhassett 2050108ccb3fSEliot Blennerhassett u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys 2051108ccb3fSEliot Blennerhassett *ph_subsys, u32 h_control, unsigned int index, u32 *attack) 2052108ccb3fSEliot Blennerhassett { 2053108ccb3fSEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2054e2768c0cSEliot Blennerhassett HPI_COMPANDER_ATTACK, 0, index, attack, NULL); 2055108ccb3fSEliot Blennerhassett } 2056108ccb3fSEliot Blennerhassett 2057108ccb3fSEliot Blennerhassett u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys, 2058108ccb3fSEliot Blennerhassett u32 h_control, unsigned int index, u32 decay) 2059108ccb3fSEliot Blennerhassett { 2060108ccb3fSEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2061108ccb3fSEliot Blennerhassett HPI_COMPANDER_DECAY, decay, index); 2062108ccb3fSEliot Blennerhassett } 2063108ccb3fSEliot Blennerhassett 2064108ccb3fSEliot Blennerhassett u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys, 2065108ccb3fSEliot Blennerhassett u32 h_control, unsigned int index, u32 *decay) 2066108ccb3fSEliot Blennerhassett { 2067108ccb3fSEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2068e2768c0cSEliot Blennerhassett HPI_COMPANDER_DECAY, 0, index, decay, NULL); 2069108ccb3fSEliot Blennerhassett 2070108ccb3fSEliot Blennerhassett } 2071108ccb3fSEliot Blennerhassett 2072108ccb3fSEliot Blennerhassett u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys, 2073108ccb3fSEliot Blennerhassett u32 h_control, unsigned int index, short threshold0_01dB) 2074719f82d3SEliot Blennerhassett { 2075719f82d3SEliot Blennerhassett struct hpi_message hm; 2076719f82d3SEliot Blennerhassett struct hpi_response hr; 2077108ccb3fSEliot Blennerhassett 2078719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2079719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 2080719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2081108ccb3fSEliot Blennerhassett hm.u.c.attribute = HPI_COMPANDER_THRESHOLD; 2082108ccb3fSEliot Blennerhassett hm.u.c.param2 = index; 2083719f82d3SEliot Blennerhassett hm.u.c.an_log_value[0] = threshold0_01dB; 2084719f82d3SEliot Blennerhassett 2085719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2086719f82d3SEliot Blennerhassett 2087719f82d3SEliot Blennerhassett return hr.error; 2088719f82d3SEliot Blennerhassett } 2089719f82d3SEliot Blennerhassett 2090108ccb3fSEliot Blennerhassett u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys, 2091108ccb3fSEliot Blennerhassett u32 h_control, unsigned int index, short *threshold0_01dB) 2092719f82d3SEliot Blennerhassett { 2093719f82d3SEliot Blennerhassett struct hpi_message hm; 2094719f82d3SEliot Blennerhassett struct hpi_response hr; 2095108ccb3fSEliot Blennerhassett 2096719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2097719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2098719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2099108ccb3fSEliot Blennerhassett hm.u.c.attribute = HPI_COMPANDER_THRESHOLD; 2100108ccb3fSEliot Blennerhassett hm.u.c.param2 = index; 2101719f82d3SEliot Blennerhassett 2102719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2103108ccb3fSEliot Blennerhassett *threshold0_01dB = hr.u.c.an_log_value[0]; 2104719f82d3SEliot Blennerhassett 2105719f82d3SEliot Blennerhassett return hr.error; 2106719f82d3SEliot Blennerhassett } 2107719f82d3SEliot Blennerhassett 2108108ccb3fSEliot Blennerhassett u16 hpi_compander_set_ratio(const struct hpi_hsubsys *ph_subsys, 2109108ccb3fSEliot Blennerhassett u32 h_control, u32 index, u32 ratio100) 2110108ccb3fSEliot Blennerhassett { 2111108ccb3fSEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2112108ccb3fSEliot Blennerhassett HPI_COMPANDER_RATIO, ratio100, index); 2113108ccb3fSEliot Blennerhassett } 2114108ccb3fSEliot Blennerhassett 2115108ccb3fSEliot Blennerhassett u16 hpi_compander_get_ratio(const struct hpi_hsubsys *ph_subsys, 2116108ccb3fSEliot Blennerhassett u32 h_control, u32 index, u32 *ratio100) 2117108ccb3fSEliot Blennerhassett { 2118108ccb3fSEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2119e2768c0cSEliot Blennerhassett HPI_COMPANDER_RATIO, 0, index, ratio100, NULL); 2120108ccb3fSEliot Blennerhassett } 2121108ccb3fSEliot Blennerhassett 2122719f82d3SEliot Blennerhassett u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2123719f82d3SEliot Blennerhassett short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB) 2124719f82d3SEliot Blennerhassett { 2125719f82d3SEliot Blennerhassett struct hpi_message hm; 2126719f82d3SEliot Blennerhassett struct hpi_response hr; 2127108ccb3fSEliot Blennerhassett 2128719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2129719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2130719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2131719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_LEVEL_RANGE; 2132719f82d3SEliot Blennerhassett 2133719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2134719f82d3SEliot Blennerhassett if (hr.error) { 2135719f82d3SEliot Blennerhassett hr.u.c.an_log_value[0] = 0; 2136719f82d3SEliot Blennerhassett hr.u.c.an_log_value[1] = 0; 2137719f82d3SEliot Blennerhassett hr.u.c.param1 = 0; 2138719f82d3SEliot Blennerhassett } 2139719f82d3SEliot Blennerhassett if (min_gain_01dB) 2140719f82d3SEliot Blennerhassett *min_gain_01dB = hr.u.c.an_log_value[0]; 2141719f82d3SEliot Blennerhassett if (max_gain_01dB) 2142719f82d3SEliot Blennerhassett *max_gain_01dB = hr.u.c.an_log_value[1]; 2143719f82d3SEliot Blennerhassett if (step_gain_01dB) 2144719f82d3SEliot Blennerhassett *step_gain_01dB = (short)hr.u.c.param1; 2145719f82d3SEliot Blennerhassett return hr.error; 2146719f82d3SEliot Blennerhassett } 2147719f82d3SEliot Blennerhassett 2148719f82d3SEliot Blennerhassett u16 hpi_level_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2149719f82d3SEliot Blennerhassett short an_gain0_01dB[HPI_MAX_CHANNELS] 2150719f82d3SEliot Blennerhassett ) 2151719f82d3SEliot Blennerhassett { 2152108ccb3fSEliot Blennerhassett return hpi_control_log_set2(h_control, HPI_LEVEL_GAIN, 2153108ccb3fSEliot Blennerhassett an_gain0_01dB[0], an_gain0_01dB[1]); 2154719f82d3SEliot Blennerhassett } 2155719f82d3SEliot Blennerhassett 2156719f82d3SEliot Blennerhassett u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2157719f82d3SEliot Blennerhassett short an_gain0_01dB[HPI_MAX_CHANNELS] 2158719f82d3SEliot Blennerhassett ) 2159719f82d3SEliot Blennerhassett { 2160108ccb3fSEliot Blennerhassett return hpi_control_log_get2(ph_subsys, h_control, HPI_LEVEL_GAIN, 2161108ccb3fSEliot Blennerhassett &an_gain0_01dB[0], &an_gain0_01dB[1]); 2162719f82d3SEliot Blennerhassett } 2163719f82d3SEliot Blennerhassett 2164719f82d3SEliot Blennerhassett u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys, 2165719f82d3SEliot Blennerhassett const u32 h_meter, u32 *p_channels) 2166719f82d3SEliot Blennerhassett { 2167719f82d3SEliot Blennerhassett return hpi_control_query(ph_subsys, h_meter, HPI_METER_NUM_CHANNELS, 2168719f82d3SEliot Blennerhassett 0, 0, p_channels); 2169719f82d3SEliot Blennerhassett } 2170719f82d3SEliot Blennerhassett 2171719f82d3SEliot Blennerhassett u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2172719f82d3SEliot Blennerhassett short an_peakdB[HPI_MAX_CHANNELS] 2173719f82d3SEliot Blennerhassett ) 2174719f82d3SEliot Blennerhassett { 2175719f82d3SEliot Blennerhassett short i = 0; 2176719f82d3SEliot Blennerhassett 2177719f82d3SEliot Blennerhassett struct hpi_message hm; 2178719f82d3SEliot Blennerhassett struct hpi_response hr; 2179719f82d3SEliot Blennerhassett 2180719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2181719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2182719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2183719f82d3SEliot Blennerhassett hm.obj_index = hm.obj_index; 2184719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_METER_PEAK; 2185719f82d3SEliot Blennerhassett 2186719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2187719f82d3SEliot Blennerhassett 2188719f82d3SEliot Blennerhassett if (!hr.error) 2189719f82d3SEliot Blennerhassett memcpy(an_peakdB, hr.u.c.an_log_value, 2190719f82d3SEliot Blennerhassett sizeof(short) * HPI_MAX_CHANNELS); 2191719f82d3SEliot Blennerhassett else 2192719f82d3SEliot Blennerhassett for (i = 0; i < HPI_MAX_CHANNELS; i++) 2193719f82d3SEliot Blennerhassett an_peakdB[i] = HPI_METER_MINIMUM; 2194719f82d3SEliot Blennerhassett return hr.error; 2195719f82d3SEliot Blennerhassett } 2196719f82d3SEliot Blennerhassett 2197719f82d3SEliot Blennerhassett u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2198719f82d3SEliot Blennerhassett short an_rmsdB[HPI_MAX_CHANNELS] 2199719f82d3SEliot Blennerhassett ) 2200719f82d3SEliot Blennerhassett { 2201719f82d3SEliot Blennerhassett short i = 0; 2202719f82d3SEliot Blennerhassett 2203719f82d3SEliot Blennerhassett struct hpi_message hm; 2204719f82d3SEliot Blennerhassett struct hpi_response hr; 2205719f82d3SEliot Blennerhassett 2206719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2207719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2208719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2209719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_METER_RMS; 2210719f82d3SEliot Blennerhassett 2211719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2212719f82d3SEliot Blennerhassett 2213719f82d3SEliot Blennerhassett if (!hr.error) 2214719f82d3SEliot Blennerhassett memcpy(an_rmsdB, hr.u.c.an_log_value, 2215719f82d3SEliot Blennerhassett sizeof(short) * HPI_MAX_CHANNELS); 2216719f82d3SEliot Blennerhassett else 2217719f82d3SEliot Blennerhassett for (i = 0; i < HPI_MAX_CHANNELS; i++) 2218719f82d3SEliot Blennerhassett an_rmsdB[i] = HPI_METER_MINIMUM; 2219719f82d3SEliot Blennerhassett 2220719f82d3SEliot Blennerhassett return hr.error; 2221719f82d3SEliot Blennerhassett } 2222719f82d3SEliot Blennerhassett 2223719f82d3SEliot Blennerhassett u16 hpi_meter_set_rms_ballistics(const struct hpi_hsubsys *ph_subsys, 2224719f82d3SEliot Blennerhassett u32 h_control, u16 attack, u16 decay) 2225719f82d3SEliot Blennerhassett { 2226719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2227719f82d3SEliot Blennerhassett HPI_METER_RMS_BALLISTICS, attack, decay); 2228719f82d3SEliot Blennerhassett } 2229719f82d3SEliot Blennerhassett 2230719f82d3SEliot Blennerhassett u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys, 2231719f82d3SEliot Blennerhassett u32 h_control, u16 *pn_attack, u16 *pn_decay) 2232719f82d3SEliot Blennerhassett { 2233719f82d3SEliot Blennerhassett u32 attack; 2234719f82d3SEliot Blennerhassett u32 decay; 2235719f82d3SEliot Blennerhassett u16 error; 2236719f82d3SEliot Blennerhassett 2237719f82d3SEliot Blennerhassett error = hpi_control_param2_get(ph_subsys, h_control, 2238719f82d3SEliot Blennerhassett HPI_METER_RMS_BALLISTICS, &attack, &decay); 2239719f82d3SEliot Blennerhassett 2240719f82d3SEliot Blennerhassett if (pn_attack) 2241719f82d3SEliot Blennerhassett *pn_attack = (unsigned short)attack; 2242719f82d3SEliot Blennerhassett if (pn_decay) 2243719f82d3SEliot Blennerhassett *pn_decay = (unsigned short)decay; 2244719f82d3SEliot Blennerhassett 2245719f82d3SEliot Blennerhassett return error; 2246719f82d3SEliot Blennerhassett } 2247719f82d3SEliot Blennerhassett 2248719f82d3SEliot Blennerhassett u16 hpi_meter_set_peak_ballistics(const struct hpi_hsubsys *ph_subsys, 2249719f82d3SEliot Blennerhassett u32 h_control, u16 attack, u16 decay) 2250719f82d3SEliot Blennerhassett { 2251719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2252719f82d3SEliot Blennerhassett HPI_METER_PEAK_BALLISTICS, attack, decay); 2253719f82d3SEliot Blennerhassett } 2254719f82d3SEliot Blennerhassett 2255719f82d3SEliot Blennerhassett u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys, 2256719f82d3SEliot Blennerhassett u32 h_control, u16 *pn_attack, u16 *pn_decay) 2257719f82d3SEliot Blennerhassett { 2258719f82d3SEliot Blennerhassett u32 attack; 2259719f82d3SEliot Blennerhassett u32 decay; 2260719f82d3SEliot Blennerhassett u16 error; 2261719f82d3SEliot Blennerhassett 2262719f82d3SEliot Blennerhassett error = hpi_control_param2_get(ph_subsys, h_control, 2263719f82d3SEliot Blennerhassett HPI_METER_PEAK_BALLISTICS, &attack, &decay); 2264719f82d3SEliot Blennerhassett 2265719f82d3SEliot Blennerhassett if (pn_attack) 2266719f82d3SEliot Blennerhassett *pn_attack = (short)attack; 2267719f82d3SEliot Blennerhassett if (pn_decay) 2268719f82d3SEliot Blennerhassett *pn_decay = (short)decay; 2269719f82d3SEliot Blennerhassett 2270719f82d3SEliot Blennerhassett return error; 2271719f82d3SEliot Blennerhassett } 2272719f82d3SEliot Blennerhassett 2273719f82d3SEliot Blennerhassett u16 hpi_microphone_set_phantom_power(const struct hpi_hsubsys *ph_subsys, 2274719f82d3SEliot Blennerhassett u32 h_control, u16 on_off) 2275719f82d3SEliot Blennerhassett { 2276719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2277719f82d3SEliot Blennerhassett HPI_MICROPHONE_PHANTOM_POWER, (u32)on_off, 0); 2278719f82d3SEliot Blennerhassett } 2279719f82d3SEliot Blennerhassett 2280719f82d3SEliot Blennerhassett u16 hpi_microphone_get_phantom_power(const struct hpi_hsubsys *ph_subsys, 2281719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_on_off) 2282719f82d3SEliot Blennerhassett { 2283719f82d3SEliot Blennerhassett u16 error = 0; 2284719f82d3SEliot Blennerhassett u32 on_off = 0; 2285719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, 2286719f82d3SEliot Blennerhassett HPI_MICROPHONE_PHANTOM_POWER, &on_off); 2287719f82d3SEliot Blennerhassett if (pw_on_off) 2288719f82d3SEliot Blennerhassett *pw_on_off = (u16)on_off; 2289719f82d3SEliot Blennerhassett return error; 2290719f82d3SEliot Blennerhassett } 2291719f82d3SEliot Blennerhassett 2292719f82d3SEliot Blennerhassett u16 hpi_multiplexer_set_source(const struct hpi_hsubsys *ph_subsys, 2293719f82d3SEliot Blennerhassett u32 h_control, u16 source_node_type, u16 source_node_index) 2294719f82d3SEliot Blennerhassett { 2295719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2296719f82d3SEliot Blennerhassett HPI_MULTIPLEXER_SOURCE, source_node_type, source_node_index); 2297719f82d3SEliot Blennerhassett } 2298719f82d3SEliot Blennerhassett 2299719f82d3SEliot Blennerhassett u16 hpi_multiplexer_get_source(const struct hpi_hsubsys *ph_subsys, 2300719f82d3SEliot Blennerhassett u32 h_control, u16 *source_node_type, u16 *source_node_index) 2301719f82d3SEliot Blennerhassett { 2302719f82d3SEliot Blennerhassett u32 node, index; 2303719f82d3SEliot Blennerhassett u16 error = hpi_control_param2_get(ph_subsys, h_control, 2304719f82d3SEliot Blennerhassett HPI_MULTIPLEXER_SOURCE, &node, 2305719f82d3SEliot Blennerhassett &index); 2306719f82d3SEliot Blennerhassett if (source_node_type) 2307719f82d3SEliot Blennerhassett *source_node_type = (u16)node; 2308719f82d3SEliot Blennerhassett if (source_node_index) 2309719f82d3SEliot Blennerhassett *source_node_index = (u16)index; 2310719f82d3SEliot Blennerhassett return error; 2311719f82d3SEliot Blennerhassett } 2312719f82d3SEliot Blennerhassett 2313719f82d3SEliot Blennerhassett u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys, 2314719f82d3SEliot Blennerhassett u32 h_control, u16 index, u16 *source_node_type, 2315719f82d3SEliot Blennerhassett u16 *source_node_index) 2316719f82d3SEliot Blennerhassett { 2317719f82d3SEliot Blennerhassett struct hpi_message hm; 2318719f82d3SEliot Blennerhassett struct hpi_response hr; 2319719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2320719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2321719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2322719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_MULTIPLEXER_QUERYSOURCE; 2323719f82d3SEliot Blennerhassett hm.u.c.param1 = index; 2324719f82d3SEliot Blennerhassett 2325719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2326719f82d3SEliot Blennerhassett 2327719f82d3SEliot Blennerhassett if (source_node_type) 2328719f82d3SEliot Blennerhassett *source_node_type = (u16)hr.u.c.param1; 2329719f82d3SEliot Blennerhassett if (source_node_index) 2330719f82d3SEliot Blennerhassett *source_node_index = (u16)hr.u.c.param2; 2331719f82d3SEliot Blennerhassett return hr.error; 2332719f82d3SEliot Blennerhassett } 2333719f82d3SEliot Blennerhassett 2334719f82d3SEliot Blennerhassett u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys, 2335719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_number_of_bands, u16 *pw_on_off) 2336719f82d3SEliot Blennerhassett { 2337719f82d3SEliot Blennerhassett u32 oB = 0; 2338719f82d3SEliot Blennerhassett u32 oO = 0; 2339719f82d3SEliot Blennerhassett u16 error = 0; 2340719f82d3SEliot Blennerhassett 2341719f82d3SEliot Blennerhassett error = hpi_control_param2_get(ph_subsys, h_control, 2342719f82d3SEliot Blennerhassett HPI_EQUALIZER_NUM_FILTERS, &oO, &oB); 2343719f82d3SEliot Blennerhassett if (pw_number_of_bands) 2344719f82d3SEliot Blennerhassett *pw_number_of_bands = (u16)oB; 2345719f82d3SEliot Blennerhassett if (pw_on_off) 2346719f82d3SEliot Blennerhassett *pw_on_off = (u16)oO; 2347719f82d3SEliot Blennerhassett return error; 2348719f82d3SEliot Blennerhassett } 2349719f82d3SEliot Blennerhassett 2350719f82d3SEliot Blennerhassett u16 hpi_parametricEQ__set_state(const struct hpi_hsubsys *ph_subsys, 2351719f82d3SEliot Blennerhassett u32 h_control, u16 on_off) 2352719f82d3SEliot Blennerhassett { 2353719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2354719f82d3SEliot Blennerhassett HPI_EQUALIZER_NUM_FILTERS, on_off, 0); 2355719f82d3SEliot Blennerhassett } 2356719f82d3SEliot Blennerhassett 2357719f82d3SEliot Blennerhassett u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys, 2358719f82d3SEliot Blennerhassett u32 h_control, u16 index, u16 *pn_type, u32 *pfrequency_hz, 2359719f82d3SEliot Blennerhassett short *pnQ100, short *pn_gain0_01dB) 2360719f82d3SEliot Blennerhassett { 2361719f82d3SEliot Blennerhassett struct hpi_message hm; 2362719f82d3SEliot Blennerhassett struct hpi_response hr; 2363108ccb3fSEliot Blennerhassett 2364719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2365719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2366719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2367719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_EQUALIZER_FILTER; 2368719f82d3SEliot Blennerhassett hm.u.c.param2 = index; 2369719f82d3SEliot Blennerhassett 2370719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2371719f82d3SEliot Blennerhassett 2372719f82d3SEliot Blennerhassett if (pfrequency_hz) 2373719f82d3SEliot Blennerhassett *pfrequency_hz = hr.u.c.param1; 2374719f82d3SEliot Blennerhassett if (pn_type) 2375719f82d3SEliot Blennerhassett *pn_type = (u16)(hr.u.c.param2 >> 16); 2376719f82d3SEliot Blennerhassett if (pnQ100) 2377719f82d3SEliot Blennerhassett *pnQ100 = hr.u.c.an_log_value[1]; 2378719f82d3SEliot Blennerhassett if (pn_gain0_01dB) 2379719f82d3SEliot Blennerhassett *pn_gain0_01dB = hr.u.c.an_log_value[0]; 2380719f82d3SEliot Blennerhassett 2381719f82d3SEliot Blennerhassett return hr.error; 2382719f82d3SEliot Blennerhassett } 2383719f82d3SEliot Blennerhassett 2384719f82d3SEliot Blennerhassett u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys, 2385719f82d3SEliot Blennerhassett u32 h_control, u16 index, u16 type, u32 frequency_hz, short q100, 2386719f82d3SEliot Blennerhassett short gain0_01dB) 2387719f82d3SEliot Blennerhassett { 2388719f82d3SEliot Blennerhassett struct hpi_message hm; 2389719f82d3SEliot Blennerhassett struct hpi_response hr; 2390108ccb3fSEliot Blennerhassett 2391719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2392719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 2393719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2394719f82d3SEliot Blennerhassett 2395719f82d3SEliot Blennerhassett hm.u.c.param1 = frequency_hz; 2396719f82d3SEliot Blennerhassett hm.u.c.param2 = (index & 0xFFFFL) + ((u32)type << 16); 2397719f82d3SEliot Blennerhassett hm.u.c.an_log_value[0] = gain0_01dB; 2398719f82d3SEliot Blennerhassett hm.u.c.an_log_value[1] = q100; 2399719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_EQUALIZER_FILTER; 2400719f82d3SEliot Blennerhassett 2401719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2402719f82d3SEliot Blennerhassett 2403719f82d3SEliot Blennerhassett return hr.error; 2404719f82d3SEliot Blennerhassett } 2405719f82d3SEliot Blennerhassett 2406719f82d3SEliot Blennerhassett u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys, 2407719f82d3SEliot Blennerhassett u32 h_control, u16 index, short coeffs[5] 2408719f82d3SEliot Blennerhassett ) 2409719f82d3SEliot Blennerhassett { 2410719f82d3SEliot Blennerhassett struct hpi_message hm; 2411719f82d3SEliot Blennerhassett struct hpi_response hr; 2412108ccb3fSEliot Blennerhassett 2413719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2414719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2415719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2416719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_EQUALIZER_COEFFICIENTS; 2417719f82d3SEliot Blennerhassett hm.u.c.param2 = index; 2418719f82d3SEliot Blennerhassett 2419719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2420719f82d3SEliot Blennerhassett 2421719f82d3SEliot Blennerhassett coeffs[0] = (short)hr.u.c.an_log_value[0]; 2422719f82d3SEliot Blennerhassett coeffs[1] = (short)hr.u.c.an_log_value[1]; 2423719f82d3SEliot Blennerhassett coeffs[2] = (short)hr.u.c.param1; 2424719f82d3SEliot Blennerhassett coeffs[3] = (short)(hr.u.c.param1 >> 16); 2425719f82d3SEliot Blennerhassett coeffs[4] = (short)hr.u.c.param2; 2426719f82d3SEliot Blennerhassett 2427719f82d3SEliot Blennerhassett return hr.error; 2428719f82d3SEliot Blennerhassett } 2429719f82d3SEliot Blennerhassett 2430719f82d3SEliot Blennerhassett u16 hpi_sample_clock_query_source(const struct hpi_hsubsys *ph_subsys, 2431719f82d3SEliot Blennerhassett const u32 h_clock, const u32 index, u16 *pw_source) 2432719f82d3SEliot Blennerhassett { 2433719f82d3SEliot Blennerhassett u32 qr; 2434719f82d3SEliot Blennerhassett u16 err; 2435719f82d3SEliot Blennerhassett 2436719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_clock, HPI_SAMPLECLOCK_SOURCE, 2437719f82d3SEliot Blennerhassett index, 0, &qr); 2438719f82d3SEliot Blennerhassett *pw_source = (u16)qr; 2439719f82d3SEliot Blennerhassett return err; 2440719f82d3SEliot Blennerhassett } 2441719f82d3SEliot Blennerhassett 2442719f82d3SEliot Blennerhassett u16 hpi_sample_clock_set_source(const struct hpi_hsubsys *ph_subsys, 2443719f82d3SEliot Blennerhassett u32 h_control, u16 source) 2444719f82d3SEliot Blennerhassett { 2445719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2446719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_SOURCE, source, 0); 2447719f82d3SEliot Blennerhassett } 2448719f82d3SEliot Blennerhassett 2449719f82d3SEliot Blennerhassett u16 hpi_sample_clock_get_source(const struct hpi_hsubsys *ph_subsys, 2450719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_source) 2451719f82d3SEliot Blennerhassett { 2452719f82d3SEliot Blennerhassett u16 error = 0; 2453719f82d3SEliot Blennerhassett u32 source = 0; 2454719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, 2455719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_SOURCE, &source); 2456719f82d3SEliot Blennerhassett if (!error) 2457719f82d3SEliot Blennerhassett if (pw_source) 2458719f82d3SEliot Blennerhassett *pw_source = (u16)source; 2459719f82d3SEliot Blennerhassett return error; 2460719f82d3SEliot Blennerhassett } 2461719f82d3SEliot Blennerhassett 2462719f82d3SEliot Blennerhassett u16 hpi_sample_clock_query_source_index(const struct hpi_hsubsys *ph_subsys, 2463719f82d3SEliot Blennerhassett const u32 h_clock, const u32 index, const u32 source, 2464719f82d3SEliot Blennerhassett u16 *pw_source_index) 2465719f82d3SEliot Blennerhassett { 2466719f82d3SEliot Blennerhassett u32 qr; 2467719f82d3SEliot Blennerhassett u16 err; 2468719f82d3SEliot Blennerhassett 2469719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_clock, 2470719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_SOURCE_INDEX, index, source, &qr); 2471719f82d3SEliot Blennerhassett *pw_source_index = (u16)qr; 2472719f82d3SEliot Blennerhassett return err; 2473719f82d3SEliot Blennerhassett } 2474719f82d3SEliot Blennerhassett 2475719f82d3SEliot Blennerhassett u16 hpi_sample_clock_set_source_index(const struct hpi_hsubsys *ph_subsys, 2476719f82d3SEliot Blennerhassett u32 h_control, u16 source_index) 2477719f82d3SEliot Blennerhassett { 2478719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2479719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_SOURCE_INDEX, source_index, 0); 2480719f82d3SEliot Blennerhassett } 2481719f82d3SEliot Blennerhassett 2482719f82d3SEliot Blennerhassett u16 hpi_sample_clock_get_source_index(const struct hpi_hsubsys *ph_subsys, 2483719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_source_index) 2484719f82d3SEliot Blennerhassett { 2485719f82d3SEliot Blennerhassett u16 error = 0; 2486719f82d3SEliot Blennerhassett u32 source_index = 0; 2487719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, 2488719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_SOURCE_INDEX, &source_index); 2489719f82d3SEliot Blennerhassett if (!error) 2490719f82d3SEliot Blennerhassett if (pw_source_index) 2491719f82d3SEliot Blennerhassett *pw_source_index = (u16)source_index; 2492719f82d3SEliot Blennerhassett return error; 2493719f82d3SEliot Blennerhassett } 2494719f82d3SEliot Blennerhassett 2495719f82d3SEliot Blennerhassett u16 hpi_sample_clock_query_local_rate(const struct hpi_hsubsys *ph_subsys, 2496719f82d3SEliot Blennerhassett const u32 h_clock, const u32 index, u32 *prate) 2497719f82d3SEliot Blennerhassett { 2498719f82d3SEliot Blennerhassett u16 err; 2499719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_clock, 2500719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, index, 0, prate); 2501719f82d3SEliot Blennerhassett 2502719f82d3SEliot Blennerhassett return err; 2503719f82d3SEliot Blennerhassett } 2504719f82d3SEliot Blennerhassett 2505719f82d3SEliot Blennerhassett u16 hpi_sample_clock_set_local_rate(const struct hpi_hsubsys *ph_subsys, 2506719f82d3SEliot Blennerhassett u32 h_control, u32 sample_rate) 2507719f82d3SEliot Blennerhassett { 2508719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2509719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, sample_rate, 0); 2510719f82d3SEliot Blennerhassett } 2511719f82d3SEliot Blennerhassett 2512719f82d3SEliot Blennerhassett u16 hpi_sample_clock_get_local_rate(const struct hpi_hsubsys *ph_subsys, 2513719f82d3SEliot Blennerhassett u32 h_control, u32 *psample_rate) 2514719f82d3SEliot Blennerhassett { 2515719f82d3SEliot Blennerhassett u16 error = 0; 2516719f82d3SEliot Blennerhassett u32 sample_rate = 0; 2517719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, 2518719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate); 2519719f82d3SEliot Blennerhassett if (!error) 2520719f82d3SEliot Blennerhassett if (psample_rate) 2521719f82d3SEliot Blennerhassett *psample_rate = sample_rate; 2522719f82d3SEliot Blennerhassett return error; 2523719f82d3SEliot Blennerhassett } 2524719f82d3SEliot Blennerhassett 2525719f82d3SEliot Blennerhassett u16 hpi_sample_clock_get_sample_rate(const struct hpi_hsubsys *ph_subsys, 2526719f82d3SEliot Blennerhassett u32 h_control, u32 *psample_rate) 2527719f82d3SEliot Blennerhassett { 2528719f82d3SEliot Blennerhassett u16 error = 0; 2529719f82d3SEliot Blennerhassett u32 sample_rate = 0; 2530719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, 2531719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_SAMPLERATE, &sample_rate); 2532719f82d3SEliot Blennerhassett if (!error) 2533719f82d3SEliot Blennerhassett if (psample_rate) 2534719f82d3SEliot Blennerhassett *psample_rate = sample_rate; 2535719f82d3SEliot Blennerhassett return error; 2536719f82d3SEliot Blennerhassett } 2537719f82d3SEliot Blennerhassett 2538719f82d3SEliot Blennerhassett u16 hpi_sample_clock_set_auto(const struct hpi_hsubsys *ph_subsys, 2539719f82d3SEliot Blennerhassett u32 h_control, u32 enable) 2540719f82d3SEliot Blennerhassett { 2541719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2542719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_AUTO, enable, 0); 2543719f82d3SEliot Blennerhassett } 2544719f82d3SEliot Blennerhassett 2545719f82d3SEliot Blennerhassett u16 hpi_sample_clock_get_auto(const struct hpi_hsubsys *ph_subsys, 2546719f82d3SEliot Blennerhassett u32 h_control, u32 *penable) 2547719f82d3SEliot Blennerhassett { 2548719f82d3SEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2549719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_AUTO, penable); 2550719f82d3SEliot Blennerhassett } 2551719f82d3SEliot Blennerhassett 2552719f82d3SEliot Blennerhassett u16 hpi_sample_clock_set_local_rate_lock(const struct hpi_hsubsys *ph_subsys, 2553719f82d3SEliot Blennerhassett u32 h_control, u32 lock) 2554719f82d3SEliot Blennerhassett { 2555719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2556719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_LOCAL_LOCK, lock, 0); 2557719f82d3SEliot Blennerhassett } 2558719f82d3SEliot Blennerhassett 2559719f82d3SEliot Blennerhassett u16 hpi_sample_clock_get_local_rate_lock(const struct hpi_hsubsys *ph_subsys, 2560719f82d3SEliot Blennerhassett u32 h_control, u32 *plock) 2561719f82d3SEliot Blennerhassett { 2562719f82d3SEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2563719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_LOCAL_LOCK, plock); 2564719f82d3SEliot Blennerhassett } 2565719f82d3SEliot Blennerhassett 2566719f82d3SEliot Blennerhassett u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys, 2567719f82d3SEliot Blennerhassett u32 h_control, u32 index, u32 *frequency) 2568719f82d3SEliot Blennerhassett { 2569719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2570719f82d3SEliot Blennerhassett HPI_TONEDETECTOR_FREQUENCY, index, 0, frequency, NULL); 2571719f82d3SEliot Blennerhassett } 2572719f82d3SEliot Blennerhassett 2573719f82d3SEliot Blennerhassett u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys, 2574719f82d3SEliot Blennerhassett u32 h_control, u32 *state) 2575719f82d3SEliot Blennerhassett { 2576108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2577108ccb3fSEliot Blennerhassett HPI_TONEDETECTOR_STATE, state); 2578719f82d3SEliot Blennerhassett } 2579719f82d3SEliot Blennerhassett 2580719f82d3SEliot Blennerhassett u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys, 2581719f82d3SEliot Blennerhassett u32 h_control, u32 enable) 2582719f82d3SEliot Blennerhassett { 2583719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2584*3285ea10SEliot Blennerhassett enable, 0); 2585719f82d3SEliot Blennerhassett } 2586719f82d3SEliot Blennerhassett 2587719f82d3SEliot Blennerhassett u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 2588719f82d3SEliot Blennerhassett u32 h_control, u32 *enable) 2589719f82d3SEliot Blennerhassett { 2590108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2591108ccb3fSEliot Blennerhassett HPI_GENERIC_ENABLE, enable); 2592719f82d3SEliot Blennerhassett } 2593719f82d3SEliot Blennerhassett 2594719f82d3SEliot Blennerhassett u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, 2595719f82d3SEliot Blennerhassett u32 h_control, u32 event_enable) 2596719f82d3SEliot Blennerhassett { 2597719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2598719f82d3SEliot Blennerhassett HPI_GENERIC_EVENT_ENABLE, (u32)event_enable, 0); 2599719f82d3SEliot Blennerhassett } 2600719f82d3SEliot Blennerhassett 2601719f82d3SEliot Blennerhassett u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, 2602719f82d3SEliot Blennerhassett u32 h_control, u32 *event_enable) 2603719f82d3SEliot Blennerhassett { 2604108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2605108ccb3fSEliot Blennerhassett HPI_GENERIC_EVENT_ENABLE, event_enable); 2606719f82d3SEliot Blennerhassett } 2607719f82d3SEliot Blennerhassett 2608719f82d3SEliot Blennerhassett u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, 2609719f82d3SEliot Blennerhassett u32 h_control, int threshold) 2610719f82d3SEliot Blennerhassett { 2611719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2612719f82d3SEliot Blennerhassett HPI_TONEDETECTOR_THRESHOLD, (u32)threshold, 0); 2613719f82d3SEliot Blennerhassett } 2614719f82d3SEliot Blennerhassett 2615719f82d3SEliot Blennerhassett u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, 2616719f82d3SEliot Blennerhassett u32 h_control, int *threshold) 2617719f82d3SEliot Blennerhassett { 2618108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2619108ccb3fSEliot Blennerhassett HPI_TONEDETECTOR_THRESHOLD, (u32 *)threshold); 2620719f82d3SEliot Blennerhassett } 2621719f82d3SEliot Blennerhassett 2622719f82d3SEliot Blennerhassett u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys, 2623719f82d3SEliot Blennerhassett u32 h_control, u32 *state) 2624719f82d3SEliot Blennerhassett { 2625108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2626108ccb3fSEliot Blennerhassett HPI_SILENCEDETECTOR_STATE, state); 2627719f82d3SEliot Blennerhassett } 2628719f82d3SEliot Blennerhassett 2629719f82d3SEliot Blennerhassett u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys, 2630719f82d3SEliot Blennerhassett u32 h_control, u32 enable) 2631719f82d3SEliot Blennerhassett { 2632719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2633*3285ea10SEliot Blennerhassett enable, 0); 2634719f82d3SEliot Blennerhassett } 2635719f82d3SEliot Blennerhassett 2636719f82d3SEliot Blennerhassett u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 2637719f82d3SEliot Blennerhassett u32 h_control, u32 *enable) 2638719f82d3SEliot Blennerhassett { 2639108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2640108ccb3fSEliot Blennerhassett HPI_GENERIC_ENABLE, enable); 2641719f82d3SEliot Blennerhassett } 2642719f82d3SEliot Blennerhassett 2643719f82d3SEliot Blennerhassett u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, 2644719f82d3SEliot Blennerhassett u32 h_control, u32 event_enable) 2645719f82d3SEliot Blennerhassett { 2646719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2647108ccb3fSEliot Blennerhassett HPI_GENERIC_EVENT_ENABLE, event_enable, 0); 2648719f82d3SEliot Blennerhassett } 2649719f82d3SEliot Blennerhassett 2650719f82d3SEliot Blennerhassett u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, 2651719f82d3SEliot Blennerhassett u32 h_control, u32 *event_enable) 2652719f82d3SEliot Blennerhassett { 2653108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2654108ccb3fSEliot Blennerhassett HPI_GENERIC_EVENT_ENABLE, event_enable); 2655719f82d3SEliot Blennerhassett } 2656719f82d3SEliot Blennerhassett 2657719f82d3SEliot Blennerhassett u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys, 2658719f82d3SEliot Blennerhassett u32 h_control, u32 delay) 2659719f82d3SEliot Blennerhassett { 2660719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2661108ccb3fSEliot Blennerhassett HPI_SILENCEDETECTOR_DELAY, delay, 0); 2662719f82d3SEliot Blennerhassett } 2663719f82d3SEliot Blennerhassett 2664719f82d3SEliot Blennerhassett u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys, 2665719f82d3SEliot Blennerhassett u32 h_control, u32 *delay) 2666719f82d3SEliot Blennerhassett { 2667108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2668108ccb3fSEliot Blennerhassett HPI_SILENCEDETECTOR_DELAY, delay); 2669719f82d3SEliot Blennerhassett } 2670719f82d3SEliot Blennerhassett 2671719f82d3SEliot Blennerhassett u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, 2672719f82d3SEliot Blennerhassett u32 h_control, int threshold) 2673719f82d3SEliot Blennerhassett { 2674719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2675108ccb3fSEliot Blennerhassett HPI_SILENCEDETECTOR_THRESHOLD, threshold, 0); 2676719f82d3SEliot Blennerhassett } 2677719f82d3SEliot Blennerhassett 2678719f82d3SEliot Blennerhassett u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, 2679719f82d3SEliot Blennerhassett u32 h_control, int *threshold) 2680719f82d3SEliot Blennerhassett { 2681108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2682108ccb3fSEliot Blennerhassett HPI_SILENCEDETECTOR_THRESHOLD, (u32 *)threshold); 2683719f82d3SEliot Blennerhassett } 2684719f82d3SEliot Blennerhassett 2685719f82d3SEliot Blennerhassett u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys, 2686719f82d3SEliot Blennerhassett const u32 h_tuner, const u32 index, u16 *pw_band) 2687719f82d3SEliot Blennerhassett { 2688719f82d3SEliot Blennerhassett u32 qr; 2689719f82d3SEliot Blennerhassett u16 err; 2690719f82d3SEliot Blennerhassett 2691719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0, 2692719f82d3SEliot Blennerhassett &qr); 2693719f82d3SEliot Blennerhassett *pw_band = (u16)qr; 2694719f82d3SEliot Blennerhassett return err; 2695719f82d3SEliot Blennerhassett } 2696719f82d3SEliot Blennerhassett 2697719f82d3SEliot Blennerhassett u16 hpi_tuner_set_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2698719f82d3SEliot Blennerhassett u16 band) 2699719f82d3SEliot Blennerhassett { 2700719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_BAND, 2701719f82d3SEliot Blennerhassett band, 0); 2702719f82d3SEliot Blennerhassett } 2703719f82d3SEliot Blennerhassett 2704719f82d3SEliot Blennerhassett u16 hpi_tuner_get_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2705719f82d3SEliot Blennerhassett u16 *pw_band) 2706719f82d3SEliot Blennerhassett { 2707719f82d3SEliot Blennerhassett u32 band = 0; 2708719f82d3SEliot Blennerhassett u16 error = 0; 2709719f82d3SEliot Blennerhassett 2710719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_BAND, 2711719f82d3SEliot Blennerhassett &band); 2712719f82d3SEliot Blennerhassett if (pw_band) 2713719f82d3SEliot Blennerhassett *pw_band = (u16)band; 2714719f82d3SEliot Blennerhassett return error; 2715719f82d3SEliot Blennerhassett } 2716719f82d3SEliot Blennerhassett 2717719f82d3SEliot Blennerhassett u16 hpi_tuner_query_frequency(const struct hpi_hsubsys *ph_subsys, 2718719f82d3SEliot Blennerhassett const u32 h_tuner, const u32 index, const u16 band, u32 *pfreq) 2719719f82d3SEliot Blennerhassett { 2720719f82d3SEliot Blennerhassett return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_FREQ, index, 2721719f82d3SEliot Blennerhassett band, pfreq); 2722719f82d3SEliot Blennerhassett } 2723719f82d3SEliot Blennerhassett 2724719f82d3SEliot Blennerhassett u16 hpi_tuner_set_frequency(const struct hpi_hsubsys *ph_subsys, 2725719f82d3SEliot Blennerhassett u32 h_control, u32 freq_ink_hz) 2726719f82d3SEliot Blennerhassett { 2727719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_FREQ, 2728719f82d3SEliot Blennerhassett freq_ink_hz, 0); 2729719f82d3SEliot Blennerhassett } 2730719f82d3SEliot Blennerhassett 2731719f82d3SEliot Blennerhassett u16 hpi_tuner_get_frequency(const struct hpi_hsubsys *ph_subsys, 2732719f82d3SEliot Blennerhassett u32 h_control, u32 *pw_freq_ink_hz) 2733719f82d3SEliot Blennerhassett { 2734719f82d3SEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_FREQ, 2735719f82d3SEliot Blennerhassett pw_freq_ink_hz); 2736719f82d3SEliot Blennerhassett } 2737719f82d3SEliot Blennerhassett 2738719f82d3SEliot Blennerhassett u16 hpi_tuner_query_gain(const struct hpi_hsubsys *ph_subsys, 2739719f82d3SEliot Blennerhassett const u32 h_tuner, const u32 index, u16 *pw_gain) 2740719f82d3SEliot Blennerhassett { 2741719f82d3SEliot Blennerhassett u32 qr; 2742719f82d3SEliot Blennerhassett u16 err; 2743719f82d3SEliot Blennerhassett 2744719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0, 2745719f82d3SEliot Blennerhassett &qr); 2746719f82d3SEliot Blennerhassett *pw_gain = (u16)qr; 2747719f82d3SEliot Blennerhassett return err; 2748719f82d3SEliot Blennerhassett } 2749719f82d3SEliot Blennerhassett 2750719f82d3SEliot Blennerhassett u16 hpi_tuner_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2751719f82d3SEliot Blennerhassett short gain) 2752719f82d3SEliot Blennerhassett { 2753719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_GAIN, 2754719f82d3SEliot Blennerhassett gain, 0); 2755719f82d3SEliot Blennerhassett } 2756719f82d3SEliot Blennerhassett 2757719f82d3SEliot Blennerhassett u16 hpi_tuner_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2758719f82d3SEliot Blennerhassett short *pn_gain) 2759719f82d3SEliot Blennerhassett { 2760719f82d3SEliot Blennerhassett u32 gain = 0; 2761719f82d3SEliot Blennerhassett u16 error = 0; 2762719f82d3SEliot Blennerhassett 2763719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_GAIN, 2764719f82d3SEliot Blennerhassett &gain); 2765719f82d3SEliot Blennerhassett if (pn_gain) 2766719f82d3SEliot Blennerhassett *pn_gain = (u16)gain; 2767719f82d3SEliot Blennerhassett return error; 2768719f82d3SEliot Blennerhassett } 2769719f82d3SEliot Blennerhassett 2770719f82d3SEliot Blennerhassett u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2771719f82d3SEliot Blennerhassett short *pw_level) 2772719f82d3SEliot Blennerhassett { 2773719f82d3SEliot Blennerhassett struct hpi_message hm; 2774719f82d3SEliot Blennerhassett struct hpi_response hr; 2775108ccb3fSEliot Blennerhassett 2776719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2777719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2778719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2779*3285ea10SEliot Blennerhassett hm.u.cu.attribute = HPI_TUNER_LEVEL_AVG; 2780719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2781719f82d3SEliot Blennerhassett if (pw_level) 2782*3285ea10SEliot Blennerhassett *pw_level = hr.u.cu.tuner.s_level; 2783719f82d3SEliot Blennerhassett return hr.error; 2784719f82d3SEliot Blennerhassett } 2785719f82d3SEliot Blennerhassett 2786719f82d3SEliot Blennerhassett u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys, 2787719f82d3SEliot Blennerhassett u32 h_control, short *pw_level) 2788719f82d3SEliot Blennerhassett { 2789719f82d3SEliot Blennerhassett struct hpi_message hm; 2790719f82d3SEliot Blennerhassett struct hpi_response hr; 2791108ccb3fSEliot Blennerhassett 2792719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2793719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2794719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2795*3285ea10SEliot Blennerhassett hm.u.cu.attribute = HPI_TUNER_LEVEL_RAW; 2796719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2797719f82d3SEliot Blennerhassett if (pw_level) 2798*3285ea10SEliot Blennerhassett *pw_level = hr.u.cu.tuner.s_level; 2799719f82d3SEliot Blennerhassett return hr.error; 2800719f82d3SEliot Blennerhassett } 2801719f82d3SEliot Blennerhassett 2802719f82d3SEliot Blennerhassett u16 hpi_tuner_query_deemphasis(const struct hpi_hsubsys *ph_subsys, 2803719f82d3SEliot Blennerhassett const u32 h_tuner, const u32 index, const u16 band, u32 *pdeemphasis) 2804719f82d3SEliot Blennerhassett { 2805719f82d3SEliot Blennerhassett return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_DEEMPHASIS, 2806719f82d3SEliot Blennerhassett index, band, pdeemphasis); 2807719f82d3SEliot Blennerhassett } 2808719f82d3SEliot Blennerhassett 2809719f82d3SEliot Blennerhassett u16 hpi_tuner_set_deemphasis(const struct hpi_hsubsys *ph_subsys, 2810719f82d3SEliot Blennerhassett u32 h_control, u32 deemphasis) 2811719f82d3SEliot Blennerhassett { 2812719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2813719f82d3SEliot Blennerhassett HPI_TUNER_DEEMPHASIS, deemphasis, 0); 2814719f82d3SEliot Blennerhassett } 2815719f82d3SEliot Blennerhassett 2816719f82d3SEliot Blennerhassett u16 hpi_tuner_get_deemphasis(const struct hpi_hsubsys *ph_subsys, 2817719f82d3SEliot Blennerhassett u32 h_control, u32 *pdeemphasis) 2818719f82d3SEliot Blennerhassett { 2819719f82d3SEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2820719f82d3SEliot Blennerhassett HPI_TUNER_DEEMPHASIS, pdeemphasis); 2821719f82d3SEliot Blennerhassett } 2822719f82d3SEliot Blennerhassett 2823719f82d3SEliot Blennerhassett u16 hpi_tuner_query_program(const struct hpi_hsubsys *ph_subsys, 2824719f82d3SEliot Blennerhassett const u32 h_tuner, u32 *pbitmap_program) 2825719f82d3SEliot Blennerhassett { 2826719f82d3SEliot Blennerhassett return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_PROGRAM, 0, 0, 2827719f82d3SEliot Blennerhassett pbitmap_program); 2828719f82d3SEliot Blennerhassett } 2829719f82d3SEliot Blennerhassett 2830719f82d3SEliot Blennerhassett u16 hpi_tuner_set_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2831719f82d3SEliot Blennerhassett u32 program) 2832719f82d3SEliot Blennerhassett { 2833719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_PROGRAM, 2834719f82d3SEliot Blennerhassett program, 0); 2835719f82d3SEliot Blennerhassett } 2836719f82d3SEliot Blennerhassett 2837719f82d3SEliot Blennerhassett u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2838719f82d3SEliot Blennerhassett u32 *pprogram) 2839719f82d3SEliot Blennerhassett { 2840719f82d3SEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_PROGRAM, 2841719f82d3SEliot Blennerhassett pprogram); 2842719f82d3SEliot Blennerhassett } 2843719f82d3SEliot Blennerhassett 2844719f82d3SEliot Blennerhassett u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys, 2845719f82d3SEliot Blennerhassett u32 h_control, char *psz_dsp_version, const u32 string_size) 2846719f82d3SEliot Blennerhassett { 2847108ccb3fSEliot Blennerhassett return hpi_control_get_string(h_control, 2848719f82d3SEliot Blennerhassett HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size); 2849719f82d3SEliot Blennerhassett } 2850719f82d3SEliot Blennerhassett 2851719f82d3SEliot Blennerhassett u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys, 2852719f82d3SEliot Blennerhassett u32 h_control, char *psz_sdk_version, const u32 string_size) 2853719f82d3SEliot Blennerhassett { 2854108ccb3fSEliot Blennerhassett return hpi_control_get_string(h_control, 2855719f82d3SEliot Blennerhassett HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size); 2856719f82d3SEliot Blennerhassett } 2857719f82d3SEliot Blennerhassett 2858719f82d3SEliot Blennerhassett u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2859719f82d3SEliot Blennerhassett u16 *pw_status_mask, u16 *pw_status) 2860719f82d3SEliot Blennerhassett { 2861719f82d3SEliot Blennerhassett u32 status = 0; 2862719f82d3SEliot Blennerhassett u16 error = 0; 2863719f82d3SEliot Blennerhassett 2864719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_STATUS, 2865719f82d3SEliot Blennerhassett &status); 2866719f82d3SEliot Blennerhassett if (pw_status) { 2867719f82d3SEliot Blennerhassett if (!error) { 2868719f82d3SEliot Blennerhassett *pw_status_mask = (u16)(status >> 16); 2869719f82d3SEliot Blennerhassett *pw_status = (u16)(status & 0xFFFF); 2870719f82d3SEliot Blennerhassett } else { 2871719f82d3SEliot Blennerhassett *pw_status_mask = 0; 2872719f82d3SEliot Blennerhassett *pw_status = 0; 2873719f82d3SEliot Blennerhassett } 2874719f82d3SEliot Blennerhassett } 2875719f82d3SEliot Blennerhassett return error; 2876719f82d3SEliot Blennerhassett } 2877719f82d3SEliot Blennerhassett 2878719f82d3SEliot Blennerhassett u16 hpi_tuner_set_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2879719f82d3SEliot Blennerhassett u32 mode, u32 value) 2880719f82d3SEliot Blennerhassett { 2881719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_MODE, 2882719f82d3SEliot Blennerhassett mode, value); 2883719f82d3SEliot Blennerhassett } 2884719f82d3SEliot Blennerhassett 2885719f82d3SEliot Blennerhassett u16 hpi_tuner_get_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2886719f82d3SEliot Blennerhassett u32 mode, u32 *pn_value) 2887719f82d3SEliot Blennerhassett { 2888719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, HPI_TUNER_MODE, 2889719f82d3SEliot Blennerhassett mode, 0, pn_value, NULL); 2890719f82d3SEliot Blennerhassett } 2891719f82d3SEliot Blennerhassett 2892719f82d3SEliot Blennerhassett u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys, 2893719f82d3SEliot Blennerhassett u32 h_control, u32 *pquality) 2894719f82d3SEliot Blennerhassett { 2895108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2896108ccb3fSEliot Blennerhassett HPI_TUNER_HDRADIO_SIGNAL_QUALITY, pquality); 2897719f82d3SEliot Blennerhassett } 2898719f82d3SEliot Blennerhassett 28995a498ef1SEliot Blennerhassett u16 hpi_tuner_get_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys, 29005a498ef1SEliot Blennerhassett u32 h_control, u32 *pblend) 29015a498ef1SEliot Blennerhassett { 2902108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2903108ccb3fSEliot Blennerhassett HPI_TUNER_HDRADIO_BLEND, pblend); 29045a498ef1SEliot Blennerhassett } 29055a498ef1SEliot Blennerhassett 29065a498ef1SEliot Blennerhassett u16 hpi_tuner_set_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys, 29075a498ef1SEliot Blennerhassett u32 h_control, const u32 blend) 29085a498ef1SEliot Blennerhassett { 29095a498ef1SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 29105a498ef1SEliot Blennerhassett HPI_TUNER_HDRADIO_BLEND, blend, 0); 29115a498ef1SEliot Blennerhassett } 29125a498ef1SEliot Blennerhassett 2913719f82d3SEliot Blennerhassett u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2914719f82d3SEliot Blennerhassett char *p_data) 2915719f82d3SEliot Blennerhassett { 2916719f82d3SEliot Blennerhassett struct hpi_message hm; 2917719f82d3SEliot Blennerhassett struct hpi_response hr; 2918108ccb3fSEliot Blennerhassett 2919719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2920719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2921719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2922719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_TUNER_RDS; 2923719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2924719f82d3SEliot Blennerhassett if (p_data) { 2925719f82d3SEliot Blennerhassett *(u32 *)&p_data[0] = hr.u.cu.tuner.rds.data[0]; 2926719f82d3SEliot Blennerhassett *(u32 *)&p_data[4] = hr.u.cu.tuner.rds.data[1]; 2927719f82d3SEliot Blennerhassett *(u32 *)&p_data[8] = hr.u.cu.tuner.rds.bLER; 2928719f82d3SEliot Blennerhassett } 2929719f82d3SEliot Blennerhassett return hr.error; 2930719f82d3SEliot Blennerhassett } 2931719f82d3SEliot Blennerhassett 2932719f82d3SEliot Blennerhassett u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys, 2933719f82d3SEliot Blennerhassett u32 h_control, char *psz_string, const u32 data_length) 2934719f82d3SEliot Blennerhassett { 2935108ccb3fSEliot Blennerhassett return hpi_control_get_string(h_control, HPI_PAD_CHANNEL_NAME, 2936108ccb3fSEliot Blennerhassett psz_string, data_length); 2937719f82d3SEliot Blennerhassett } 2938719f82d3SEliot Blennerhassett 2939719f82d3SEliot Blennerhassett u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2940719f82d3SEliot Blennerhassett char *psz_string, const u32 data_length) 2941719f82d3SEliot Blennerhassett { 2942108ccb3fSEliot Blennerhassett return hpi_control_get_string(h_control, HPI_PAD_ARTIST, psz_string, 2943108ccb3fSEliot Blennerhassett data_length); 2944719f82d3SEliot Blennerhassett } 2945719f82d3SEliot Blennerhassett 2946719f82d3SEliot Blennerhassett u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2947719f82d3SEliot Blennerhassett char *psz_string, const u32 data_length) 2948719f82d3SEliot Blennerhassett { 2949108ccb3fSEliot Blennerhassett return hpi_control_get_string(h_control, HPI_PAD_TITLE, psz_string, 2950108ccb3fSEliot Blennerhassett data_length); 2951719f82d3SEliot Blennerhassett } 2952719f82d3SEliot Blennerhassett 2953719f82d3SEliot Blennerhassett u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2954719f82d3SEliot Blennerhassett char *psz_string, const u32 data_length) 2955719f82d3SEliot Blennerhassett { 2956108ccb3fSEliot Blennerhassett return hpi_control_get_string(h_control, HPI_PAD_COMMENT, psz_string, 2957108ccb3fSEliot Blennerhassett data_length); 2958719f82d3SEliot Blennerhassett } 2959719f82d3SEliot Blennerhassett 2960719f82d3SEliot Blennerhassett u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys, 2961719f82d3SEliot Blennerhassett u32 h_control, u32 *ppTY) 2962719f82d3SEliot Blennerhassett { 2963108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2964108ccb3fSEliot Blennerhassett HPI_PAD_PROGRAM_TYPE, ppTY); 2965719f82d3SEliot Blennerhassett } 2966719f82d3SEliot Blennerhassett 2967719f82d3SEliot Blennerhassett u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2968719f82d3SEliot Blennerhassett u32 *ppI) 2969719f82d3SEliot Blennerhassett { 2970108ccb3fSEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2971108ccb3fSEliot Blennerhassett HPI_PAD_PROGRAM_ID, ppI); 2972719f82d3SEliot Blennerhassett } 2973719f82d3SEliot Blennerhassett 2974719f82d3SEliot Blennerhassett u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys, 2975719f82d3SEliot Blennerhassett const u32 h_volume, u32 *p_channels) 2976719f82d3SEliot Blennerhassett { 2977719f82d3SEliot Blennerhassett return hpi_control_query(ph_subsys, h_volume, HPI_VOLUME_NUM_CHANNELS, 2978719f82d3SEliot Blennerhassett 0, 0, p_channels); 2979719f82d3SEliot Blennerhassett } 2980719f82d3SEliot Blennerhassett 2981719f82d3SEliot Blennerhassett u16 hpi_volume_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2982719f82d3SEliot Blennerhassett short an_log_gain[HPI_MAX_CHANNELS] 2983719f82d3SEliot Blennerhassett ) 2984719f82d3SEliot Blennerhassett { 2985108ccb3fSEliot Blennerhassett return hpi_control_log_set2(h_control, HPI_VOLUME_GAIN, 2986108ccb3fSEliot Blennerhassett an_log_gain[0], an_log_gain[1]); 2987719f82d3SEliot Blennerhassett } 2988719f82d3SEliot Blennerhassett 2989719f82d3SEliot Blennerhassett u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2990719f82d3SEliot Blennerhassett short an_log_gain[HPI_MAX_CHANNELS] 2991719f82d3SEliot Blennerhassett ) 2992719f82d3SEliot Blennerhassett { 2993108ccb3fSEliot Blennerhassett return hpi_control_log_get2(ph_subsys, h_control, HPI_VOLUME_GAIN, 2994108ccb3fSEliot Blennerhassett &an_log_gain[0], &an_log_gain[1]); 2995719f82d3SEliot Blennerhassett } 2996719f82d3SEliot Blennerhassett 2997719f82d3SEliot Blennerhassett u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2998719f82d3SEliot Blennerhassett short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB) 2999719f82d3SEliot Blennerhassett { 3000719f82d3SEliot Blennerhassett struct hpi_message hm; 3001719f82d3SEliot Blennerhassett struct hpi_response hr; 3002108ccb3fSEliot Blennerhassett 3003719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3004719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 3005719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3006719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_VOLUME_RANGE; 3007719f82d3SEliot Blennerhassett 3008719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3009719f82d3SEliot Blennerhassett if (hr.error) { 3010719f82d3SEliot Blennerhassett hr.u.c.an_log_value[0] = 0; 3011719f82d3SEliot Blennerhassett hr.u.c.an_log_value[1] = 0; 3012719f82d3SEliot Blennerhassett hr.u.c.param1 = 0; 3013719f82d3SEliot Blennerhassett } 3014719f82d3SEliot Blennerhassett if (min_gain_01dB) 3015719f82d3SEliot Blennerhassett *min_gain_01dB = hr.u.c.an_log_value[0]; 3016719f82d3SEliot Blennerhassett if (max_gain_01dB) 3017719f82d3SEliot Blennerhassett *max_gain_01dB = hr.u.c.an_log_value[1]; 3018719f82d3SEliot Blennerhassett if (step_gain_01dB) 3019719f82d3SEliot Blennerhassett *step_gain_01dB = (short)hr.u.c.param1; 3020719f82d3SEliot Blennerhassett return hr.error; 3021719f82d3SEliot Blennerhassett } 3022719f82d3SEliot Blennerhassett 3023719f82d3SEliot Blennerhassett u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys, 3024719f82d3SEliot Blennerhassett u32 h_control, short an_stop_gain0_01dB[HPI_MAX_CHANNELS], 3025719f82d3SEliot Blennerhassett u32 duration_ms, u16 profile) 3026719f82d3SEliot Blennerhassett { 3027719f82d3SEliot Blennerhassett struct hpi_message hm; 3028719f82d3SEliot Blennerhassett struct hpi_response hr; 3029108ccb3fSEliot Blennerhassett 3030719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3031719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 3032719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3033719f82d3SEliot Blennerhassett 3034719f82d3SEliot Blennerhassett memcpy(hm.u.c.an_log_value, an_stop_gain0_01dB, 3035719f82d3SEliot Blennerhassett sizeof(short) * HPI_MAX_CHANNELS); 3036719f82d3SEliot Blennerhassett 3037719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_VOLUME_AUTOFADE; 3038719f82d3SEliot Blennerhassett hm.u.c.param1 = duration_ms; 3039719f82d3SEliot Blennerhassett hm.u.c.param2 = profile; 3040719f82d3SEliot Blennerhassett 3041719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3042719f82d3SEliot Blennerhassett 3043719f82d3SEliot Blennerhassett return hr.error; 3044719f82d3SEliot Blennerhassett } 3045719f82d3SEliot Blennerhassett 3046719f82d3SEliot Blennerhassett u16 hpi_volume_auto_fade(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3047719f82d3SEliot Blennerhassett short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms) 3048719f82d3SEliot Blennerhassett { 3049719f82d3SEliot Blennerhassett return hpi_volume_auto_fade_profile(ph_subsys, h_control, 3050719f82d3SEliot Blennerhassett an_stop_gain0_01dB, duration_ms, HPI_VOLUME_AUTOFADE_LOG); 3051719f82d3SEliot Blennerhassett } 3052719f82d3SEliot Blennerhassett 3053719f82d3SEliot Blennerhassett u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3054719f82d3SEliot Blennerhassett short an_gain0_01dB) 3055719f82d3SEliot Blennerhassett { 3056719f82d3SEliot Blennerhassett struct hpi_message hm; 3057719f82d3SEliot Blennerhassett struct hpi_response hr; 3058719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3059719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 3060719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3061719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_VOX_THRESHOLD; 3062719f82d3SEliot Blennerhassett 3063719f82d3SEliot Blennerhassett hm.u.c.an_log_value[0] = an_gain0_01dB; 3064719f82d3SEliot Blennerhassett 3065719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3066719f82d3SEliot Blennerhassett 3067719f82d3SEliot Blennerhassett return hr.error; 3068719f82d3SEliot Blennerhassett } 3069719f82d3SEliot Blennerhassett 3070719f82d3SEliot Blennerhassett u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3071719f82d3SEliot Blennerhassett short *an_gain0_01dB) 3072719f82d3SEliot Blennerhassett { 3073719f82d3SEliot Blennerhassett struct hpi_message hm; 3074719f82d3SEliot Blennerhassett struct hpi_response hr; 3075719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3076719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 3077719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3078719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_VOX_THRESHOLD; 3079719f82d3SEliot Blennerhassett 3080719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3081719f82d3SEliot Blennerhassett 3082719f82d3SEliot Blennerhassett *an_gain0_01dB = hr.u.c.an_log_value[0]; 3083719f82d3SEliot Blennerhassett 3084719f82d3SEliot Blennerhassett return hr.error; 3085719f82d3SEliot Blennerhassett } 3086