1*719f82d3SEliot Blennerhassett 2*719f82d3SEliot Blennerhassett #include "hpi_internal.h" 3*719f82d3SEliot Blennerhassett #include "hpimsginit.h" 4*719f82d3SEliot Blennerhassett 5*719f82d3SEliot Blennerhassett #include "hpidebug.h" 6*719f82d3SEliot Blennerhassett 7*719f82d3SEliot Blennerhassett struct hpi_handle { 8*719f82d3SEliot Blennerhassett unsigned int obj_index:12; 9*719f82d3SEliot Blennerhassett unsigned int obj_type:4; 10*719f82d3SEliot Blennerhassett unsigned int adapter_index:14; 11*719f82d3SEliot Blennerhassett unsigned int spare:1; 12*719f82d3SEliot Blennerhassett unsigned int read_only:1; 13*719f82d3SEliot Blennerhassett }; 14*719f82d3SEliot Blennerhassett 15*719f82d3SEliot Blennerhassett union handle_word { 16*719f82d3SEliot Blennerhassett struct hpi_handle h; 17*719f82d3SEliot Blennerhassett u32 w; 18*719f82d3SEliot Blennerhassett }; 19*719f82d3SEliot Blennerhassett 20*719f82d3SEliot Blennerhassett u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index, 21*719f82d3SEliot Blennerhassett const u16 object_index) 22*719f82d3SEliot Blennerhassett { 23*719f82d3SEliot Blennerhassett union handle_word handle; 24*719f82d3SEliot Blennerhassett 25*719f82d3SEliot Blennerhassett handle.h.adapter_index = adapter_index; 26*719f82d3SEliot Blennerhassett handle.h.spare = 0; 27*719f82d3SEliot Blennerhassett handle.h.read_only = 0; 28*719f82d3SEliot Blennerhassett handle.h.obj_type = c_object; 29*719f82d3SEliot Blennerhassett handle.h.obj_index = object_index; 30*719f82d3SEliot Blennerhassett return handle.w; 31*719f82d3SEliot Blennerhassett } 32*719f82d3SEliot Blennerhassett 33*719f82d3SEliot Blennerhassett void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index, 34*719f82d3SEliot Blennerhassett u16 *pw_object_index) 35*719f82d3SEliot Blennerhassett { 36*719f82d3SEliot Blennerhassett union handle_word uhandle; 37*719f82d3SEliot Blennerhassett uhandle.w = handle; 38*719f82d3SEliot Blennerhassett 39*719f82d3SEliot Blennerhassett if (pw_adapter_index) 40*719f82d3SEliot Blennerhassett *pw_adapter_index = (u16)uhandle.h.adapter_index; 41*719f82d3SEliot Blennerhassett if (pw_object_index) 42*719f82d3SEliot Blennerhassett *pw_object_index = (u16)uhandle.h.obj_index; 43*719f82d3SEliot Blennerhassett } 44*719f82d3SEliot Blennerhassett 45*719f82d3SEliot Blennerhassett char hpi_handle_object(const u32 handle) 46*719f82d3SEliot Blennerhassett { 47*719f82d3SEliot Blennerhassett union handle_word uhandle; 48*719f82d3SEliot Blennerhassett uhandle.w = handle; 49*719f82d3SEliot Blennerhassett return (char)uhandle.h.obj_type; 50*719f82d3SEliot Blennerhassett } 51*719f82d3SEliot Blennerhassett 52*719f82d3SEliot Blennerhassett #define u32TOINDEX(h, i1) \ 53*719f82d3SEliot Blennerhassett do {\ 54*719f82d3SEliot Blennerhassett if (h == 0) \ 55*719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_OBJ; \ 56*719f82d3SEliot Blennerhassett else \ 57*719f82d3SEliot Blennerhassett hpi_handle_to_indexes(h, i1, NULL); \ 58*719f82d3SEliot Blennerhassett } while (0) 59*719f82d3SEliot Blennerhassett 60*719f82d3SEliot Blennerhassett #define u32TOINDEXES(h, i1, i2) \ 61*719f82d3SEliot Blennerhassett do {\ 62*719f82d3SEliot Blennerhassett if (h == 0) \ 63*719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_OBJ; \ 64*719f82d3SEliot Blennerhassett else \ 65*719f82d3SEliot Blennerhassett hpi_handle_to_indexes(h, i1, i2);\ 66*719f82d3SEliot Blennerhassett } while (0) 67*719f82d3SEliot Blennerhassett 68*719f82d3SEliot Blennerhassett void hpi_format_to_msg(struct hpi_msg_format *pMF, 69*719f82d3SEliot Blennerhassett const struct hpi_format *pF) 70*719f82d3SEliot Blennerhassett { 71*719f82d3SEliot Blennerhassett pMF->sample_rate = pF->sample_rate; 72*719f82d3SEliot Blennerhassett pMF->bit_rate = pF->bit_rate; 73*719f82d3SEliot Blennerhassett pMF->attributes = pF->attributes; 74*719f82d3SEliot Blennerhassett pMF->channels = pF->channels; 75*719f82d3SEliot Blennerhassett pMF->format = pF->format; 76*719f82d3SEliot Blennerhassett } 77*719f82d3SEliot Blennerhassett 78*719f82d3SEliot Blennerhassett static void hpi_msg_to_format(struct hpi_format *pF, 79*719f82d3SEliot Blennerhassett struct hpi_msg_format *pMF) 80*719f82d3SEliot Blennerhassett { 81*719f82d3SEliot Blennerhassett pF->sample_rate = pMF->sample_rate; 82*719f82d3SEliot Blennerhassett pF->bit_rate = pMF->bit_rate; 83*719f82d3SEliot Blennerhassett pF->attributes = pMF->attributes; 84*719f82d3SEliot Blennerhassett pF->channels = pMF->channels; 85*719f82d3SEliot Blennerhassett pF->format = pMF->format; 86*719f82d3SEliot Blennerhassett pF->mode_legacy = 0; 87*719f82d3SEliot Blennerhassett pF->unused = 0; 88*719f82d3SEliot Blennerhassett } 89*719f82d3SEliot Blennerhassett 90*719f82d3SEliot Blennerhassett void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR) 91*719f82d3SEliot Blennerhassett { 92*719f82d3SEliot Blennerhassett pSR->u.legacy_stream_info.auxiliary_data_available = 93*719f82d3SEliot Blennerhassett pSR->u.stream_info.auxiliary_data_available; 94*719f82d3SEliot Blennerhassett pSR->u.legacy_stream_info.state = pSR->u.stream_info.state; 95*719f82d3SEliot Blennerhassett } 96*719f82d3SEliot Blennerhassett 97*719f82d3SEliot Blennerhassett static struct hpi_hsubsys gh_subsys; 98*719f82d3SEliot Blennerhassett 99*719f82d3SEliot Blennerhassett struct hpi_hsubsys *hpi_subsys_create(void 100*719f82d3SEliot Blennerhassett ) 101*719f82d3SEliot Blennerhassett { 102*719f82d3SEliot Blennerhassett struct hpi_message hm; 103*719f82d3SEliot Blennerhassett struct hpi_response hr; 104*719f82d3SEliot Blennerhassett 105*719f82d3SEliot Blennerhassett memset(&gh_subsys, 0, sizeof(struct hpi_hsubsys)); 106*719f82d3SEliot Blennerhassett 107*719f82d3SEliot Blennerhassett { 108*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 109*719f82d3SEliot Blennerhassett HPI_SUBSYS_OPEN); 110*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 111*719f82d3SEliot Blennerhassett 112*719f82d3SEliot Blennerhassett if (hr.error == 0) 113*719f82d3SEliot Blennerhassett return &gh_subsys; 114*719f82d3SEliot Blennerhassett 115*719f82d3SEliot Blennerhassett } 116*719f82d3SEliot Blennerhassett return NULL; 117*719f82d3SEliot Blennerhassett } 118*719f82d3SEliot Blennerhassett 119*719f82d3SEliot Blennerhassett void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys) 120*719f82d3SEliot Blennerhassett { 121*719f82d3SEliot Blennerhassett struct hpi_message hm; 122*719f82d3SEliot Blennerhassett struct hpi_response hr; 123*719f82d3SEliot Blennerhassett 124*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 125*719f82d3SEliot Blennerhassett HPI_SUBSYS_CLOSE); 126*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 127*719f82d3SEliot Blennerhassett 128*719f82d3SEliot Blennerhassett } 129*719f82d3SEliot Blennerhassett 130*719f82d3SEliot Blennerhassett u16 hpi_subsys_get_version(const struct hpi_hsubsys *ph_subsys, u32 *pversion) 131*719f82d3SEliot Blennerhassett { 132*719f82d3SEliot Blennerhassett struct hpi_message hm; 133*719f82d3SEliot Blennerhassett struct hpi_response hr; 134*719f82d3SEliot Blennerhassett 135*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 136*719f82d3SEliot Blennerhassett HPI_SUBSYS_GET_VERSION); 137*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 138*719f82d3SEliot Blennerhassett *pversion = hr.u.s.version; 139*719f82d3SEliot Blennerhassett return hr.error; 140*719f82d3SEliot Blennerhassett } 141*719f82d3SEliot Blennerhassett 142*719f82d3SEliot Blennerhassett u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys, 143*719f82d3SEliot Blennerhassett u32 *pversion_ex) 144*719f82d3SEliot Blennerhassett { 145*719f82d3SEliot Blennerhassett struct hpi_message hm; 146*719f82d3SEliot Blennerhassett struct hpi_response hr; 147*719f82d3SEliot Blennerhassett 148*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 149*719f82d3SEliot Blennerhassett HPI_SUBSYS_GET_VERSION); 150*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 151*719f82d3SEliot Blennerhassett *pversion_ex = hr.u.s.data; 152*719f82d3SEliot Blennerhassett return hr.error; 153*719f82d3SEliot Blennerhassett } 154*719f82d3SEliot Blennerhassett 155*719f82d3SEliot Blennerhassett u16 hpi_subsys_get_info(const struct hpi_hsubsys *ph_subsys, u32 *pversion, 156*719f82d3SEliot Blennerhassett u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length) 157*719f82d3SEliot Blennerhassett { 158*719f82d3SEliot Blennerhassett struct hpi_message hm; 159*719f82d3SEliot Blennerhassett struct hpi_response hr; 160*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 161*719f82d3SEliot Blennerhassett HPI_SUBSYS_GET_INFO); 162*719f82d3SEliot Blennerhassett 163*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 164*719f82d3SEliot Blennerhassett 165*719f82d3SEliot Blennerhassett *pversion = hr.u.s.version; 166*719f82d3SEliot Blennerhassett if (list_length > HPI_MAX_ADAPTERS) 167*719f82d3SEliot Blennerhassett memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list, 168*719f82d3SEliot Blennerhassett HPI_MAX_ADAPTERS); 169*719f82d3SEliot Blennerhassett else 170*719f82d3SEliot Blennerhassett memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list, list_length); 171*719f82d3SEliot Blennerhassett *pw_num_adapters = hr.u.s.num_adapters; 172*719f82d3SEliot Blennerhassett return hr.error; 173*719f82d3SEliot Blennerhassett } 174*719f82d3SEliot Blennerhassett 175*719f82d3SEliot Blennerhassett u16 hpi_subsys_find_adapters(const struct hpi_hsubsys *ph_subsys, 176*719f82d3SEliot Blennerhassett u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length) 177*719f82d3SEliot Blennerhassett { 178*719f82d3SEliot Blennerhassett struct hpi_message hm; 179*719f82d3SEliot Blennerhassett struct hpi_response hr; 180*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 181*719f82d3SEliot Blennerhassett HPI_SUBSYS_FIND_ADAPTERS); 182*719f82d3SEliot Blennerhassett 183*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 184*719f82d3SEliot Blennerhassett 185*719f82d3SEliot Blennerhassett if (list_length > HPI_MAX_ADAPTERS) { 186*719f82d3SEliot Blennerhassett memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list, 187*719f82d3SEliot Blennerhassett HPI_MAX_ADAPTERS * sizeof(u16)); 188*719f82d3SEliot Blennerhassett memset(&aw_adapter_list[HPI_MAX_ADAPTERS], 0, 189*719f82d3SEliot Blennerhassett (list_length - HPI_MAX_ADAPTERS) * sizeof(u16)); 190*719f82d3SEliot Blennerhassett } else 191*719f82d3SEliot Blennerhassett memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list, 192*719f82d3SEliot Blennerhassett list_length * sizeof(u16)); 193*719f82d3SEliot Blennerhassett *pw_num_adapters = hr.u.s.num_adapters; 194*719f82d3SEliot Blennerhassett 195*719f82d3SEliot Blennerhassett return hr.error; 196*719f82d3SEliot Blennerhassett } 197*719f82d3SEliot Blennerhassett 198*719f82d3SEliot Blennerhassett u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys, 199*719f82d3SEliot Blennerhassett const struct hpi_resource *p_resource, u16 *pw_adapter_index) 200*719f82d3SEliot Blennerhassett { 201*719f82d3SEliot Blennerhassett struct hpi_message hm; 202*719f82d3SEliot Blennerhassett struct hpi_response hr; 203*719f82d3SEliot Blennerhassett 204*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 205*719f82d3SEliot Blennerhassett HPI_SUBSYS_CREATE_ADAPTER); 206*719f82d3SEliot Blennerhassett hm.u.s.resource = *p_resource; 207*719f82d3SEliot Blennerhassett 208*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 209*719f82d3SEliot Blennerhassett 210*719f82d3SEliot Blennerhassett *pw_adapter_index = hr.u.s.adapter_index; 211*719f82d3SEliot Blennerhassett return hr.error; 212*719f82d3SEliot Blennerhassett } 213*719f82d3SEliot Blennerhassett 214*719f82d3SEliot Blennerhassett u16 hpi_subsys_delete_adapter(const struct hpi_hsubsys *ph_subsys, 215*719f82d3SEliot Blennerhassett u16 adapter_index) 216*719f82d3SEliot Blennerhassett { 217*719f82d3SEliot Blennerhassett struct hpi_message hm; 218*719f82d3SEliot Blennerhassett struct hpi_response hr; 219*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 220*719f82d3SEliot Blennerhassett HPI_SUBSYS_DELETE_ADAPTER); 221*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 222*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 223*719f82d3SEliot Blennerhassett return hr.error; 224*719f82d3SEliot Blennerhassett } 225*719f82d3SEliot Blennerhassett 226*719f82d3SEliot Blennerhassett u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys, 227*719f82d3SEliot Blennerhassett int *pn_num_adapters) 228*719f82d3SEliot Blennerhassett { 229*719f82d3SEliot Blennerhassett struct hpi_message hm; 230*719f82d3SEliot Blennerhassett struct hpi_response hr; 231*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 232*719f82d3SEliot Blennerhassett HPI_SUBSYS_GET_NUM_ADAPTERS); 233*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 234*719f82d3SEliot Blennerhassett *pn_num_adapters = (int)hr.u.s.num_adapters; 235*719f82d3SEliot Blennerhassett return hr.error; 236*719f82d3SEliot Blennerhassett } 237*719f82d3SEliot Blennerhassett 238*719f82d3SEliot Blennerhassett u16 hpi_subsys_get_adapter(const struct hpi_hsubsys *ph_subsys, int iterator, 239*719f82d3SEliot Blennerhassett u32 *padapter_index, u16 *pw_adapter_type) 240*719f82d3SEliot Blennerhassett { 241*719f82d3SEliot Blennerhassett struct hpi_message hm; 242*719f82d3SEliot Blennerhassett struct hpi_response hr; 243*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 244*719f82d3SEliot Blennerhassett HPI_SUBSYS_GET_ADAPTER); 245*719f82d3SEliot Blennerhassett hm.adapter_index = (u16)iterator; 246*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 247*719f82d3SEliot Blennerhassett *padapter_index = (int)hr.u.s.adapter_index; 248*719f82d3SEliot Blennerhassett *pw_adapter_type = hr.u.s.aw_adapter_list[0]; 249*719f82d3SEliot Blennerhassett return hr.error; 250*719f82d3SEliot Blennerhassett } 251*719f82d3SEliot Blennerhassett 252*719f82d3SEliot Blennerhassett u16 hpi_subsys_set_host_network_interface(const struct hpi_hsubsys *ph_subsys, 253*719f82d3SEliot Blennerhassett const char *sz_interface) 254*719f82d3SEliot Blennerhassett { 255*719f82d3SEliot Blennerhassett struct hpi_message hm; 256*719f82d3SEliot Blennerhassett struct hpi_response hr; 257*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 258*719f82d3SEliot Blennerhassett HPI_SUBSYS_SET_NETWORK_INTERFACE); 259*719f82d3SEliot Blennerhassett if (sz_interface == NULL) 260*719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_RESOURCE; 261*719f82d3SEliot Blennerhassett hm.u.s.resource.r.net_if = sz_interface; 262*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 263*719f82d3SEliot Blennerhassett return hr.error; 264*719f82d3SEliot Blennerhassett } 265*719f82d3SEliot Blennerhassett 266*719f82d3SEliot Blennerhassett u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) 267*719f82d3SEliot Blennerhassett { 268*719f82d3SEliot Blennerhassett struct hpi_message hm; 269*719f82d3SEliot Blennerhassett struct hpi_response hr; 270*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 271*719f82d3SEliot Blennerhassett HPI_ADAPTER_OPEN); 272*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 273*719f82d3SEliot Blennerhassett 274*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 275*719f82d3SEliot Blennerhassett 276*719f82d3SEliot Blennerhassett return hr.error; 277*719f82d3SEliot Blennerhassett 278*719f82d3SEliot Blennerhassett } 279*719f82d3SEliot Blennerhassett 280*719f82d3SEliot Blennerhassett u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) 281*719f82d3SEliot Blennerhassett { 282*719f82d3SEliot Blennerhassett struct hpi_message hm; 283*719f82d3SEliot Blennerhassett struct hpi_response hr; 284*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 285*719f82d3SEliot Blennerhassett HPI_ADAPTER_CLOSE); 286*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 287*719f82d3SEliot Blennerhassett 288*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 289*719f82d3SEliot Blennerhassett 290*719f82d3SEliot Blennerhassett return hr.error; 291*719f82d3SEliot Blennerhassett } 292*719f82d3SEliot Blennerhassett 293*719f82d3SEliot Blennerhassett u16 hpi_adapter_set_mode(const struct hpi_hsubsys *ph_subsys, 294*719f82d3SEliot Blennerhassett u16 adapter_index, u32 adapter_mode) 295*719f82d3SEliot Blennerhassett { 296*719f82d3SEliot Blennerhassett return hpi_adapter_set_mode_ex(ph_subsys, adapter_index, adapter_mode, 297*719f82d3SEliot Blennerhassett HPI_ADAPTER_MODE_SET); 298*719f82d3SEliot Blennerhassett } 299*719f82d3SEliot Blennerhassett 300*719f82d3SEliot Blennerhassett u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys, 301*719f82d3SEliot Blennerhassett u16 adapter_index, u32 adapter_mode, u16 query_or_set) 302*719f82d3SEliot Blennerhassett { 303*719f82d3SEliot Blennerhassett struct hpi_message hm; 304*719f82d3SEliot Blennerhassett struct hpi_response hr; 305*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 306*719f82d3SEliot Blennerhassett HPI_ADAPTER_SET_MODE); 307*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 308*719f82d3SEliot Blennerhassett hm.u.a.adapter_mode = adapter_mode; 309*719f82d3SEliot Blennerhassett hm.u.a.assert_id = query_or_set; 310*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 311*719f82d3SEliot Blennerhassett return hr.error; 312*719f82d3SEliot Blennerhassett } 313*719f82d3SEliot Blennerhassett 314*719f82d3SEliot Blennerhassett u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys, 315*719f82d3SEliot Blennerhassett u16 adapter_index, u32 *padapter_mode) 316*719f82d3SEliot Blennerhassett { 317*719f82d3SEliot Blennerhassett struct hpi_message hm; 318*719f82d3SEliot Blennerhassett struct hpi_response hr; 319*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 320*719f82d3SEliot Blennerhassett HPI_ADAPTER_GET_MODE); 321*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 322*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 323*719f82d3SEliot Blennerhassett if (padapter_mode) 324*719f82d3SEliot Blennerhassett *padapter_mode = hr.u.a.serial_number; 325*719f82d3SEliot Blennerhassett return hr.error; 326*719f82d3SEliot Blennerhassett } 327*719f82d3SEliot Blennerhassett 328*719f82d3SEliot Blennerhassett u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys, 329*719f82d3SEliot Blennerhassett u16 adapter_index, u16 *pw_num_outstreams, u16 *pw_num_instreams, 330*719f82d3SEliot Blennerhassett u16 *pw_version, u32 *pserial_number, u16 *pw_adapter_type) 331*719f82d3SEliot Blennerhassett { 332*719f82d3SEliot Blennerhassett struct hpi_message hm; 333*719f82d3SEliot Blennerhassett struct hpi_response hr; 334*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 335*719f82d3SEliot Blennerhassett HPI_ADAPTER_GET_INFO); 336*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 337*719f82d3SEliot Blennerhassett 338*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 339*719f82d3SEliot Blennerhassett 340*719f82d3SEliot Blennerhassett *pw_adapter_type = hr.u.a.adapter_type; 341*719f82d3SEliot Blennerhassett *pw_num_outstreams = hr.u.a.num_outstreams; 342*719f82d3SEliot Blennerhassett *pw_num_instreams = hr.u.a.num_instreams; 343*719f82d3SEliot Blennerhassett *pw_version = hr.u.a.version; 344*719f82d3SEliot Blennerhassett *pserial_number = hr.u.a.serial_number; 345*719f82d3SEliot Blennerhassett return hr.error; 346*719f82d3SEliot Blennerhassett } 347*719f82d3SEliot Blennerhassett 348*719f82d3SEliot Blennerhassett u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys, 349*719f82d3SEliot Blennerhassett u16 adapter_index, u16 module_index, u16 *pw_num_outputs, 350*719f82d3SEliot Blennerhassett u16 *pw_num_inputs, u16 *pw_version, u32 *pserial_number, 351*719f82d3SEliot Blennerhassett u16 *pw_module_type, u32 *ph_module) 352*719f82d3SEliot Blennerhassett { 353*719f82d3SEliot Blennerhassett struct hpi_message hm; 354*719f82d3SEliot Blennerhassett struct hpi_response hr; 355*719f82d3SEliot Blennerhassett 356*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 357*719f82d3SEliot Blennerhassett HPI_ADAPTER_MODULE_INFO); 358*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 359*719f82d3SEliot Blennerhassett hm.u.ax.module_info.index = module_index; 360*719f82d3SEliot Blennerhassett 361*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 362*719f82d3SEliot Blennerhassett 363*719f82d3SEliot Blennerhassett *pw_module_type = hr.u.a.adapter_type; 364*719f82d3SEliot Blennerhassett *pw_num_outputs = hr.u.a.num_outstreams; 365*719f82d3SEliot Blennerhassett *pw_num_inputs = hr.u.a.num_instreams; 366*719f82d3SEliot Blennerhassett *pw_version = hr.u.a.version; 367*719f82d3SEliot Blennerhassett *pserial_number = hr.u.a.serial_number; 368*719f82d3SEliot Blennerhassett *ph_module = 0; 369*719f82d3SEliot Blennerhassett 370*719f82d3SEliot Blennerhassett return hr.error; 371*719f82d3SEliot Blennerhassett } 372*719f82d3SEliot Blennerhassett 373*719f82d3SEliot Blennerhassett u16 hpi_adapter_get_assert(const struct hpi_hsubsys *ph_subsys, 374*719f82d3SEliot Blennerhassett u16 adapter_index, u16 *assert_present, char *psz_assert, 375*719f82d3SEliot Blennerhassett u16 *pw_line_number) 376*719f82d3SEliot Blennerhassett { 377*719f82d3SEliot Blennerhassett struct hpi_message hm; 378*719f82d3SEliot Blennerhassett struct hpi_response hr; 379*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 380*719f82d3SEliot Blennerhassett HPI_ADAPTER_GET_ASSERT); 381*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 382*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 383*719f82d3SEliot Blennerhassett 384*719f82d3SEliot Blennerhassett *assert_present = 0; 385*719f82d3SEliot Blennerhassett 386*719f82d3SEliot Blennerhassett if (!hr.error) { 387*719f82d3SEliot Blennerhassett 388*719f82d3SEliot Blennerhassett *pw_line_number = (u16)hr.u.a.serial_number; 389*719f82d3SEliot Blennerhassett if (*pw_line_number) { 390*719f82d3SEliot Blennerhassett 391*719f82d3SEliot Blennerhassett int i; 392*719f82d3SEliot Blennerhassett char *src = (char *)hr.u.a.sz_adapter_assert; 393*719f82d3SEliot Blennerhassett char *dst = psz_assert; 394*719f82d3SEliot Blennerhassett 395*719f82d3SEliot Blennerhassett *assert_present = 1; 396*719f82d3SEliot Blennerhassett 397*719f82d3SEliot Blennerhassett for (i = 0; i < HPI_STRING_LEN; i++) { 398*719f82d3SEliot Blennerhassett char c; 399*719f82d3SEliot Blennerhassett c = *src++; 400*719f82d3SEliot Blennerhassett *dst++ = c; 401*719f82d3SEliot Blennerhassett if (c == 0) 402*719f82d3SEliot Blennerhassett break; 403*719f82d3SEliot Blennerhassett } 404*719f82d3SEliot Blennerhassett 405*719f82d3SEliot Blennerhassett } 406*719f82d3SEliot Blennerhassett } 407*719f82d3SEliot Blennerhassett return hr.error; 408*719f82d3SEliot Blennerhassett } 409*719f82d3SEliot Blennerhassett 410*719f82d3SEliot Blennerhassett u16 hpi_adapter_get_assert_ex(const struct hpi_hsubsys *ph_subsys, 411*719f82d3SEliot Blennerhassett u16 adapter_index, u16 *assert_present, char *psz_assert, 412*719f82d3SEliot Blennerhassett u32 *pline_number, u16 *pw_assert_on_dsp) 413*719f82d3SEliot Blennerhassett { 414*719f82d3SEliot Blennerhassett struct hpi_message hm; 415*719f82d3SEliot Blennerhassett struct hpi_response hr; 416*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 417*719f82d3SEliot Blennerhassett HPI_ADAPTER_GET_ASSERT); 418*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 419*719f82d3SEliot Blennerhassett 420*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 421*719f82d3SEliot Blennerhassett 422*719f82d3SEliot Blennerhassett *assert_present = 0; 423*719f82d3SEliot Blennerhassett 424*719f82d3SEliot Blennerhassett if (!hr.error) { 425*719f82d3SEliot Blennerhassett 426*719f82d3SEliot Blennerhassett *pline_number = hr.u.a.serial_number; 427*719f82d3SEliot Blennerhassett 428*719f82d3SEliot Blennerhassett *assert_present = hr.u.a.adapter_type; 429*719f82d3SEliot Blennerhassett 430*719f82d3SEliot Blennerhassett *pw_assert_on_dsp = hr.u.a.adapter_index; 431*719f82d3SEliot Blennerhassett 432*719f82d3SEliot Blennerhassett if (!*assert_present && *pline_number) 433*719f82d3SEliot Blennerhassett 434*719f82d3SEliot Blennerhassett *assert_present = 1; 435*719f82d3SEliot Blennerhassett 436*719f82d3SEliot Blennerhassett if (*assert_present) { 437*719f82d3SEliot Blennerhassett 438*719f82d3SEliot Blennerhassett int i; 439*719f82d3SEliot Blennerhassett char *src = (char *)hr.u.a.sz_adapter_assert; 440*719f82d3SEliot Blennerhassett char *dst = psz_assert; 441*719f82d3SEliot Blennerhassett 442*719f82d3SEliot Blennerhassett for (i = 0; i < HPI_STRING_LEN; i++) { 443*719f82d3SEliot Blennerhassett char c; 444*719f82d3SEliot Blennerhassett c = *src++; 445*719f82d3SEliot Blennerhassett *dst++ = c; 446*719f82d3SEliot Blennerhassett if (c == 0) 447*719f82d3SEliot Blennerhassett break; 448*719f82d3SEliot Blennerhassett } 449*719f82d3SEliot Blennerhassett 450*719f82d3SEliot Blennerhassett } else { 451*719f82d3SEliot Blennerhassett *psz_assert = 0; 452*719f82d3SEliot Blennerhassett } 453*719f82d3SEliot Blennerhassett } 454*719f82d3SEliot Blennerhassett return hr.error; 455*719f82d3SEliot Blennerhassett } 456*719f82d3SEliot Blennerhassett 457*719f82d3SEliot Blennerhassett u16 hpi_adapter_test_assert(const struct hpi_hsubsys *ph_subsys, 458*719f82d3SEliot Blennerhassett u16 adapter_index, u16 assert_id) 459*719f82d3SEliot Blennerhassett { 460*719f82d3SEliot Blennerhassett struct hpi_message hm; 461*719f82d3SEliot Blennerhassett struct hpi_response hr; 462*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 463*719f82d3SEliot Blennerhassett HPI_ADAPTER_TEST_ASSERT); 464*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 465*719f82d3SEliot Blennerhassett hm.u.a.assert_id = assert_id; 466*719f82d3SEliot Blennerhassett 467*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 468*719f82d3SEliot Blennerhassett 469*719f82d3SEliot Blennerhassett return hr.error; 470*719f82d3SEliot Blennerhassett } 471*719f82d3SEliot Blennerhassett 472*719f82d3SEliot Blennerhassett u16 hpi_adapter_enable_capability(const struct hpi_hsubsys *ph_subsys, 473*719f82d3SEliot Blennerhassett u16 adapter_index, u16 capability, u32 key) 474*719f82d3SEliot Blennerhassett { 475*719f82d3SEliot Blennerhassett struct hpi_message hm; 476*719f82d3SEliot Blennerhassett struct hpi_response hr; 477*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 478*719f82d3SEliot Blennerhassett HPI_ADAPTER_ENABLE_CAPABILITY); 479*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 480*719f82d3SEliot Blennerhassett hm.u.a.assert_id = capability; 481*719f82d3SEliot Blennerhassett hm.u.a.adapter_mode = key; 482*719f82d3SEliot Blennerhassett 483*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 484*719f82d3SEliot Blennerhassett 485*719f82d3SEliot Blennerhassett return hr.error; 486*719f82d3SEliot Blennerhassett } 487*719f82d3SEliot Blennerhassett 488*719f82d3SEliot Blennerhassett u16 hpi_adapter_self_test(const struct hpi_hsubsys *ph_subsys, 489*719f82d3SEliot Blennerhassett u16 adapter_index) 490*719f82d3SEliot Blennerhassett { 491*719f82d3SEliot Blennerhassett struct hpi_message hm; 492*719f82d3SEliot Blennerhassett struct hpi_response hr; 493*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 494*719f82d3SEliot Blennerhassett HPI_ADAPTER_SELFTEST); 495*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 496*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 497*719f82d3SEliot Blennerhassett return hr.error; 498*719f82d3SEliot Blennerhassett } 499*719f82d3SEliot Blennerhassett 500*719f82d3SEliot Blennerhassett u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys, 501*719f82d3SEliot Blennerhassett u16 adapter_index, u32 dsp_address, char *p_buffer, int *count_bytes) 502*719f82d3SEliot Blennerhassett { 503*719f82d3SEliot Blennerhassett struct hpi_message hm; 504*719f82d3SEliot Blennerhassett struct hpi_response hr; 505*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 506*719f82d3SEliot Blennerhassett HPI_ADAPTER_DEBUG_READ); 507*719f82d3SEliot Blennerhassett 508*719f82d3SEliot Blennerhassett hr.size = sizeof(hr); 509*719f82d3SEliot Blennerhassett 510*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 511*719f82d3SEliot Blennerhassett hm.u.ax.debug_read.dsp_address = dsp_address; 512*719f82d3SEliot Blennerhassett 513*719f82d3SEliot Blennerhassett if (*count_bytes > sizeof(hr.u.bytes)) 514*719f82d3SEliot Blennerhassett *count_bytes = sizeof(hr.u.bytes); 515*719f82d3SEliot Blennerhassett 516*719f82d3SEliot Blennerhassett hm.u.ax.debug_read.count_bytes = *count_bytes; 517*719f82d3SEliot Blennerhassett 518*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 519*719f82d3SEliot Blennerhassett 520*719f82d3SEliot Blennerhassett if (!hr.error) { 521*719f82d3SEliot Blennerhassett *count_bytes = hr.size - 12; 522*719f82d3SEliot Blennerhassett memcpy(p_buffer, &hr.u.bytes, *count_bytes); 523*719f82d3SEliot Blennerhassett } else 524*719f82d3SEliot Blennerhassett *count_bytes = 0; 525*719f82d3SEliot Blennerhassett return hr.error; 526*719f82d3SEliot Blennerhassett } 527*719f82d3SEliot Blennerhassett 528*719f82d3SEliot Blennerhassett u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys, 529*719f82d3SEliot Blennerhassett u16 adapter_index, u16 property, u16 parameter1, u16 parameter2) 530*719f82d3SEliot Blennerhassett { 531*719f82d3SEliot Blennerhassett struct hpi_message hm; 532*719f82d3SEliot Blennerhassett struct hpi_response hr; 533*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 534*719f82d3SEliot Blennerhassett HPI_ADAPTER_SET_PROPERTY); 535*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 536*719f82d3SEliot Blennerhassett hm.u.ax.property_set.property = property; 537*719f82d3SEliot Blennerhassett hm.u.ax.property_set.parameter1 = parameter1; 538*719f82d3SEliot Blennerhassett hm.u.ax.property_set.parameter2 = parameter2; 539*719f82d3SEliot Blennerhassett 540*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 541*719f82d3SEliot Blennerhassett 542*719f82d3SEliot Blennerhassett return hr.error; 543*719f82d3SEliot Blennerhassett } 544*719f82d3SEliot Blennerhassett 545*719f82d3SEliot Blennerhassett u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys, 546*719f82d3SEliot Blennerhassett u16 adapter_index, u16 property, u16 *pw_parameter1, 547*719f82d3SEliot Blennerhassett u16 *pw_parameter2) 548*719f82d3SEliot Blennerhassett { 549*719f82d3SEliot Blennerhassett struct hpi_message hm; 550*719f82d3SEliot Blennerhassett struct hpi_response hr; 551*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 552*719f82d3SEliot Blennerhassett HPI_ADAPTER_GET_PROPERTY); 553*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 554*719f82d3SEliot Blennerhassett hm.u.ax.property_set.property = property; 555*719f82d3SEliot Blennerhassett 556*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 557*719f82d3SEliot Blennerhassett if (!hr.error) { 558*719f82d3SEliot Blennerhassett if (pw_parameter1) 559*719f82d3SEliot Blennerhassett *pw_parameter1 = hr.u.ax.property_get.parameter1; 560*719f82d3SEliot Blennerhassett if (pw_parameter2) 561*719f82d3SEliot Blennerhassett *pw_parameter2 = hr.u.ax.property_get.parameter2; 562*719f82d3SEliot Blennerhassett } 563*719f82d3SEliot Blennerhassett 564*719f82d3SEliot Blennerhassett return hr.error; 565*719f82d3SEliot Blennerhassett } 566*719f82d3SEliot Blennerhassett 567*719f82d3SEliot Blennerhassett u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys, 568*719f82d3SEliot Blennerhassett u16 adapter_index, u16 index, u16 what_to_enumerate, 569*719f82d3SEliot Blennerhassett u16 property_index, u32 *psetting) 570*719f82d3SEliot Blennerhassett { 571*719f82d3SEliot Blennerhassett return 0; 572*719f82d3SEliot Blennerhassett } 573*719f82d3SEliot Blennerhassett 574*719f82d3SEliot Blennerhassett u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, 575*719f82d3SEliot Blennerhassett u32 sample_rate, u32 bit_rate, u32 attributes) 576*719f82d3SEliot Blennerhassett { 577*719f82d3SEliot Blennerhassett u16 error = 0; 578*719f82d3SEliot Blennerhassett struct hpi_msg_format fmt; 579*719f82d3SEliot Blennerhassett 580*719f82d3SEliot Blennerhassett switch (channels) { 581*719f82d3SEliot Blennerhassett case 1: 582*719f82d3SEliot Blennerhassett case 2: 583*719f82d3SEliot Blennerhassett case 4: 584*719f82d3SEliot Blennerhassett case 6: 585*719f82d3SEliot Blennerhassett case 8: 586*719f82d3SEliot Blennerhassett case 16: 587*719f82d3SEliot Blennerhassett break; 588*719f82d3SEliot Blennerhassett default: 589*719f82d3SEliot Blennerhassett error = HPI_ERROR_INVALID_CHANNELS; 590*719f82d3SEliot Blennerhassett return error; 591*719f82d3SEliot Blennerhassett } 592*719f82d3SEliot Blennerhassett fmt.channels = channels; 593*719f82d3SEliot Blennerhassett 594*719f82d3SEliot Blennerhassett switch (format) { 595*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM16_SIGNED: 596*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM24_SIGNED: 597*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM32_SIGNED: 598*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM32_FLOAT: 599*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM16_BIGENDIAN: 600*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM8_UNSIGNED: 601*719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L1: 602*719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L2: 603*719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L3: 604*719f82d3SEliot Blennerhassett case HPI_FORMAT_DOLBY_AC2: 605*719f82d3SEliot Blennerhassett case HPI_FORMAT_AA_TAGIT1_HITS: 606*719f82d3SEliot Blennerhassett case HPI_FORMAT_AA_TAGIT1_INSERTS: 607*719f82d3SEliot Blennerhassett case HPI_FORMAT_RAW_BITSTREAM: 608*719f82d3SEliot Blennerhassett case HPI_FORMAT_AA_TAGIT1_HITS_EX1: 609*719f82d3SEliot Blennerhassett case HPI_FORMAT_OEM1: 610*719f82d3SEliot Blennerhassett case HPI_FORMAT_OEM2: 611*719f82d3SEliot Blennerhassett break; 612*719f82d3SEliot Blennerhassett default: 613*719f82d3SEliot Blennerhassett error = HPI_ERROR_INVALID_FORMAT; 614*719f82d3SEliot Blennerhassett return error; 615*719f82d3SEliot Blennerhassett } 616*719f82d3SEliot Blennerhassett fmt.format = format; 617*719f82d3SEliot Blennerhassett 618*719f82d3SEliot Blennerhassett if (sample_rate < 8000L) { 619*719f82d3SEliot Blennerhassett error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; 620*719f82d3SEliot Blennerhassett sample_rate = 8000L; 621*719f82d3SEliot Blennerhassett } 622*719f82d3SEliot Blennerhassett if (sample_rate > 200000L) { 623*719f82d3SEliot Blennerhassett error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; 624*719f82d3SEliot Blennerhassett sample_rate = 200000L; 625*719f82d3SEliot Blennerhassett } 626*719f82d3SEliot Blennerhassett fmt.sample_rate = sample_rate; 627*719f82d3SEliot Blennerhassett 628*719f82d3SEliot Blennerhassett switch (format) { 629*719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L1: 630*719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L2: 631*719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L3: 632*719f82d3SEliot Blennerhassett fmt.bit_rate = bit_rate; 633*719f82d3SEliot Blennerhassett break; 634*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM16_SIGNED: 635*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM16_BIGENDIAN: 636*719f82d3SEliot Blennerhassett fmt.bit_rate = channels * sample_rate * 2; 637*719f82d3SEliot Blennerhassett break; 638*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM32_SIGNED: 639*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM32_FLOAT: 640*719f82d3SEliot Blennerhassett fmt.bit_rate = channels * sample_rate * 4; 641*719f82d3SEliot Blennerhassett break; 642*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM8_UNSIGNED: 643*719f82d3SEliot Blennerhassett fmt.bit_rate = channels * sample_rate; 644*719f82d3SEliot Blennerhassett break; 645*719f82d3SEliot Blennerhassett default: 646*719f82d3SEliot Blennerhassett fmt.bit_rate = 0; 647*719f82d3SEliot Blennerhassett } 648*719f82d3SEliot Blennerhassett 649*719f82d3SEliot Blennerhassett switch (format) { 650*719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L2: 651*719f82d3SEliot Blennerhassett if ((channels == 1) 652*719f82d3SEliot Blennerhassett && (attributes != HPI_MPEG_MODE_DEFAULT)) { 653*719f82d3SEliot Blennerhassett attributes = HPI_MPEG_MODE_DEFAULT; 654*719f82d3SEliot Blennerhassett error = HPI_ERROR_INVALID_FORMAT; 655*719f82d3SEliot Blennerhassett } else if (attributes > HPI_MPEG_MODE_DUALCHANNEL) { 656*719f82d3SEliot Blennerhassett attributes = HPI_MPEG_MODE_DEFAULT; 657*719f82d3SEliot Blennerhassett error = HPI_ERROR_INVALID_FORMAT; 658*719f82d3SEliot Blennerhassett } 659*719f82d3SEliot Blennerhassett fmt.attributes = attributes; 660*719f82d3SEliot Blennerhassett break; 661*719f82d3SEliot Blennerhassett default: 662*719f82d3SEliot Blennerhassett fmt.attributes = attributes; 663*719f82d3SEliot Blennerhassett } 664*719f82d3SEliot Blennerhassett 665*719f82d3SEliot Blennerhassett hpi_msg_to_format(p_format, &fmt); 666*719f82d3SEliot Blennerhassett return error; 667*719f82d3SEliot Blennerhassett } 668*719f82d3SEliot Blennerhassett 669*719f82d3SEliot Blennerhassett u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format, 670*719f82d3SEliot Blennerhassett u32 host_polling_rate_in_milli_seconds, u32 *recommended_buffer_size) 671*719f82d3SEliot Blennerhassett { 672*719f82d3SEliot Blennerhassett 673*719f82d3SEliot Blennerhassett u32 bytes_per_second; 674*719f82d3SEliot Blennerhassett u32 size; 675*719f82d3SEliot Blennerhassett u16 channels; 676*719f82d3SEliot Blennerhassett struct hpi_format *pF = p_format; 677*719f82d3SEliot Blennerhassett 678*719f82d3SEliot Blennerhassett channels = pF->channels; 679*719f82d3SEliot Blennerhassett 680*719f82d3SEliot Blennerhassett switch (pF->format) { 681*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM16_BIGENDIAN: 682*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM16_SIGNED: 683*719f82d3SEliot Blennerhassett bytes_per_second = pF->sample_rate * 2L * channels; 684*719f82d3SEliot Blennerhassett break; 685*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM24_SIGNED: 686*719f82d3SEliot Blennerhassett bytes_per_second = pF->sample_rate * 3L * channels; 687*719f82d3SEliot Blennerhassett break; 688*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM32_SIGNED: 689*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM32_FLOAT: 690*719f82d3SEliot Blennerhassett bytes_per_second = pF->sample_rate * 4L * channels; 691*719f82d3SEliot Blennerhassett break; 692*719f82d3SEliot Blennerhassett case HPI_FORMAT_PCM8_UNSIGNED: 693*719f82d3SEliot Blennerhassett bytes_per_second = pF->sample_rate * 1L * channels; 694*719f82d3SEliot Blennerhassett break; 695*719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L1: 696*719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L2: 697*719f82d3SEliot Blennerhassett case HPI_FORMAT_MPEG_L3: 698*719f82d3SEliot Blennerhassett bytes_per_second = pF->bit_rate / 8L; 699*719f82d3SEliot Blennerhassett break; 700*719f82d3SEliot Blennerhassett case HPI_FORMAT_DOLBY_AC2: 701*719f82d3SEliot Blennerhassett 702*719f82d3SEliot Blennerhassett bytes_per_second = 256000L / 8L; 703*719f82d3SEliot Blennerhassett break; 704*719f82d3SEliot Blennerhassett default: 705*719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_FORMAT; 706*719f82d3SEliot Blennerhassett } 707*719f82d3SEliot Blennerhassett size = (bytes_per_second * host_polling_rate_in_milli_seconds * 2) / 708*719f82d3SEliot Blennerhassett 1000L; 709*719f82d3SEliot Blennerhassett 710*719f82d3SEliot Blennerhassett *recommended_buffer_size = 711*719f82d3SEliot Blennerhassett roundup_pow_of_two(((size + 4095L) & ~4095L)); 712*719f82d3SEliot Blennerhassett return 0; 713*719f82d3SEliot Blennerhassett } 714*719f82d3SEliot Blennerhassett 715*719f82d3SEliot Blennerhassett u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 716*719f82d3SEliot Blennerhassett u16 outstream_index, u32 *ph_outstream) 717*719f82d3SEliot Blennerhassett { 718*719f82d3SEliot Blennerhassett struct hpi_message hm; 719*719f82d3SEliot Blennerhassett struct hpi_response hr; 720*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 721*719f82d3SEliot Blennerhassett HPI_OSTREAM_OPEN); 722*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 723*719f82d3SEliot Blennerhassett hm.obj_index = outstream_index; 724*719f82d3SEliot Blennerhassett 725*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 726*719f82d3SEliot Blennerhassett 727*719f82d3SEliot Blennerhassett if (hr.error == 0) 728*719f82d3SEliot Blennerhassett *ph_outstream = 729*719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_OSTREAM, adapter_index, 730*719f82d3SEliot Blennerhassett outstream_index); 731*719f82d3SEliot Blennerhassett else 732*719f82d3SEliot Blennerhassett *ph_outstream = 0; 733*719f82d3SEliot Blennerhassett return hr.error; 734*719f82d3SEliot Blennerhassett } 735*719f82d3SEliot Blennerhassett 736*719f82d3SEliot Blennerhassett u16 hpi_outstream_close(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 737*719f82d3SEliot Blennerhassett { 738*719f82d3SEliot Blennerhassett struct hpi_message hm; 739*719f82d3SEliot Blennerhassett struct hpi_response hr; 740*719f82d3SEliot Blennerhassett 741*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 742*719f82d3SEliot Blennerhassett HPI_OSTREAM_HOSTBUFFER_FREE); 743*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 744*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 745*719f82d3SEliot Blennerhassett 746*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 747*719f82d3SEliot Blennerhassett HPI_OSTREAM_GROUP_RESET); 748*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 749*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 750*719f82d3SEliot Blennerhassett 751*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 752*719f82d3SEliot Blennerhassett HPI_OSTREAM_CLOSE); 753*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 754*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 755*719f82d3SEliot Blennerhassett 756*719f82d3SEliot Blennerhassett return hr.error; 757*719f82d3SEliot Blennerhassett } 758*719f82d3SEliot Blennerhassett 759*719f82d3SEliot Blennerhassett u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys, 760*719f82d3SEliot Blennerhassett u32 h_outstream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_to_play, 761*719f82d3SEliot Blennerhassett u32 *psamples_played, u32 *pauxiliary_data_to_play) 762*719f82d3SEliot Blennerhassett { 763*719f82d3SEliot Blennerhassett struct hpi_message hm; 764*719f82d3SEliot Blennerhassett struct hpi_response hr; 765*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 766*719f82d3SEliot Blennerhassett HPI_OSTREAM_GET_INFO); 767*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 768*719f82d3SEliot Blennerhassett 769*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 770*719f82d3SEliot Blennerhassett 771*719f82d3SEliot Blennerhassett if (pw_state) 772*719f82d3SEliot Blennerhassett *pw_state = hr.u.d.u.stream_info.state; 773*719f82d3SEliot Blennerhassett if (pbuffer_size) 774*719f82d3SEliot Blennerhassett *pbuffer_size = hr.u.d.u.stream_info.buffer_size; 775*719f82d3SEliot Blennerhassett if (pdata_to_play) 776*719f82d3SEliot Blennerhassett *pdata_to_play = hr.u.d.u.stream_info.data_available; 777*719f82d3SEliot Blennerhassett if (psamples_played) 778*719f82d3SEliot Blennerhassett *psamples_played = hr.u.d.u.stream_info.samples_transferred; 779*719f82d3SEliot Blennerhassett if (pauxiliary_data_to_play) 780*719f82d3SEliot Blennerhassett *pauxiliary_data_to_play = 781*719f82d3SEliot Blennerhassett hr.u.d.u.stream_info.auxiliary_data_available; 782*719f82d3SEliot Blennerhassett return hr.error; 783*719f82d3SEliot Blennerhassett } 784*719f82d3SEliot Blennerhassett 785*719f82d3SEliot Blennerhassett u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys, 786*719f82d3SEliot Blennerhassett u32 h_outstream, const u8 *pb_data, u32 bytes_to_write, 787*719f82d3SEliot Blennerhassett const struct hpi_format *p_format) 788*719f82d3SEliot Blennerhassett { 789*719f82d3SEliot Blennerhassett struct hpi_message hm; 790*719f82d3SEliot Blennerhassett struct hpi_response hr; 791*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 792*719f82d3SEliot Blennerhassett HPI_OSTREAM_WRITE); 793*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 794*719f82d3SEliot Blennerhassett hm.u.d.u.data.pb_data = (u8 *)pb_data; 795*719f82d3SEliot Blennerhassett hm.u.d.u.data.data_size = bytes_to_write; 796*719f82d3SEliot Blennerhassett 797*719f82d3SEliot Blennerhassett hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 798*719f82d3SEliot Blennerhassett 799*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 800*719f82d3SEliot Blennerhassett 801*719f82d3SEliot Blennerhassett return hr.error; 802*719f82d3SEliot Blennerhassett } 803*719f82d3SEliot Blennerhassett 804*719f82d3SEliot Blennerhassett u16 hpi_outstream_start(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 805*719f82d3SEliot Blennerhassett { 806*719f82d3SEliot Blennerhassett struct hpi_message hm; 807*719f82d3SEliot Blennerhassett struct hpi_response hr; 808*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 809*719f82d3SEliot Blennerhassett HPI_OSTREAM_START); 810*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 811*719f82d3SEliot Blennerhassett 812*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 813*719f82d3SEliot Blennerhassett 814*719f82d3SEliot Blennerhassett return hr.error; 815*719f82d3SEliot Blennerhassett } 816*719f82d3SEliot Blennerhassett 817*719f82d3SEliot Blennerhassett u16 hpi_outstream_wait_start(const struct hpi_hsubsys *ph_subsys, 818*719f82d3SEliot Blennerhassett u32 h_outstream) 819*719f82d3SEliot Blennerhassett { 820*719f82d3SEliot Blennerhassett struct hpi_message hm; 821*719f82d3SEliot Blennerhassett struct hpi_response hr; 822*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 823*719f82d3SEliot Blennerhassett HPI_OSTREAM_WAIT_START); 824*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 825*719f82d3SEliot Blennerhassett 826*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 827*719f82d3SEliot Blennerhassett 828*719f82d3SEliot Blennerhassett return hr.error; 829*719f82d3SEliot Blennerhassett } 830*719f82d3SEliot Blennerhassett 831*719f82d3SEliot Blennerhassett u16 hpi_outstream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 832*719f82d3SEliot Blennerhassett { 833*719f82d3SEliot Blennerhassett struct hpi_message hm; 834*719f82d3SEliot Blennerhassett struct hpi_response hr; 835*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 836*719f82d3SEliot Blennerhassett HPI_OSTREAM_STOP); 837*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 838*719f82d3SEliot Blennerhassett 839*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 840*719f82d3SEliot Blennerhassett 841*719f82d3SEliot Blennerhassett return hr.error; 842*719f82d3SEliot Blennerhassett } 843*719f82d3SEliot Blennerhassett 844*719f82d3SEliot Blennerhassett u16 hpi_outstream_sinegen(const struct hpi_hsubsys *ph_subsys, 845*719f82d3SEliot Blennerhassett u32 h_outstream) 846*719f82d3SEliot Blennerhassett { 847*719f82d3SEliot Blennerhassett struct hpi_message hm; 848*719f82d3SEliot Blennerhassett struct hpi_response hr; 849*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 850*719f82d3SEliot Blennerhassett HPI_OSTREAM_SINEGEN); 851*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 852*719f82d3SEliot Blennerhassett 853*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 854*719f82d3SEliot Blennerhassett 855*719f82d3SEliot Blennerhassett return hr.error; 856*719f82d3SEliot Blennerhassett } 857*719f82d3SEliot Blennerhassett 858*719f82d3SEliot Blennerhassett u16 hpi_outstream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 859*719f82d3SEliot Blennerhassett { 860*719f82d3SEliot Blennerhassett struct hpi_message hm; 861*719f82d3SEliot Blennerhassett struct hpi_response hr; 862*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 863*719f82d3SEliot Blennerhassett HPI_OSTREAM_RESET); 864*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 865*719f82d3SEliot Blennerhassett 866*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 867*719f82d3SEliot Blennerhassett 868*719f82d3SEliot Blennerhassett return hr.error; 869*719f82d3SEliot Blennerhassett } 870*719f82d3SEliot Blennerhassett 871*719f82d3SEliot Blennerhassett u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys, 872*719f82d3SEliot Blennerhassett u32 h_outstream, struct hpi_format *p_format) 873*719f82d3SEliot Blennerhassett { 874*719f82d3SEliot Blennerhassett struct hpi_message hm; 875*719f82d3SEliot Blennerhassett struct hpi_response hr; 876*719f82d3SEliot Blennerhassett 877*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 878*719f82d3SEliot Blennerhassett HPI_OSTREAM_QUERY_FORMAT); 879*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 880*719f82d3SEliot Blennerhassett 881*719f82d3SEliot Blennerhassett hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 882*719f82d3SEliot Blennerhassett 883*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 884*719f82d3SEliot Blennerhassett 885*719f82d3SEliot Blennerhassett return hr.error; 886*719f82d3SEliot Blennerhassett } 887*719f82d3SEliot Blennerhassett 888*719f82d3SEliot Blennerhassett u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys, 889*719f82d3SEliot Blennerhassett u32 h_outstream, struct hpi_format *p_format) 890*719f82d3SEliot Blennerhassett { 891*719f82d3SEliot Blennerhassett struct hpi_message hm; 892*719f82d3SEliot Blennerhassett struct hpi_response hr; 893*719f82d3SEliot Blennerhassett 894*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 895*719f82d3SEliot Blennerhassett HPI_OSTREAM_SET_FORMAT); 896*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 897*719f82d3SEliot Blennerhassett 898*719f82d3SEliot Blennerhassett hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 899*719f82d3SEliot Blennerhassett 900*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 901*719f82d3SEliot Blennerhassett 902*719f82d3SEliot Blennerhassett return hr.error; 903*719f82d3SEliot Blennerhassett } 904*719f82d3SEliot Blennerhassett 905*719f82d3SEliot Blennerhassett u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys, 906*719f82d3SEliot Blennerhassett u32 h_outstream, short velocity) 907*719f82d3SEliot Blennerhassett { 908*719f82d3SEliot Blennerhassett struct hpi_message hm; 909*719f82d3SEliot Blennerhassett struct hpi_response hr; 910*719f82d3SEliot Blennerhassett 911*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 912*719f82d3SEliot Blennerhassett HPI_OSTREAM_SET_VELOCITY); 913*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 914*719f82d3SEliot Blennerhassett hm.u.d.u.velocity = velocity; 915*719f82d3SEliot Blennerhassett 916*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 917*719f82d3SEliot Blennerhassett 918*719f82d3SEliot Blennerhassett return hr.error; 919*719f82d3SEliot Blennerhassett } 920*719f82d3SEliot Blennerhassett 921*719f82d3SEliot Blennerhassett u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys, 922*719f82d3SEliot Blennerhassett u32 h_outstream, u32 punch_in_sample, u32 punch_out_sample) 923*719f82d3SEliot Blennerhassett { 924*719f82d3SEliot Blennerhassett struct hpi_message hm; 925*719f82d3SEliot Blennerhassett struct hpi_response hr; 926*719f82d3SEliot Blennerhassett 927*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 928*719f82d3SEliot Blennerhassett HPI_OSTREAM_SET_PUNCHINOUT); 929*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 930*719f82d3SEliot Blennerhassett 931*719f82d3SEliot Blennerhassett hm.u.d.u.pio.punch_in_sample = punch_in_sample; 932*719f82d3SEliot Blennerhassett hm.u.d.u.pio.punch_out_sample = punch_out_sample; 933*719f82d3SEliot Blennerhassett 934*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 935*719f82d3SEliot Blennerhassett 936*719f82d3SEliot Blennerhassett return hr.error; 937*719f82d3SEliot Blennerhassett } 938*719f82d3SEliot Blennerhassett 939*719f82d3SEliot Blennerhassett u16 hpi_outstream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, 940*719f82d3SEliot Blennerhassett u32 h_outstream, u16 mode) 941*719f82d3SEliot Blennerhassett { 942*719f82d3SEliot Blennerhassett struct hpi_message hm; 943*719f82d3SEliot Blennerhassett struct hpi_response hr; 944*719f82d3SEliot Blennerhassett 945*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 946*719f82d3SEliot Blennerhassett HPI_OSTREAM_ANC_RESET); 947*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 948*719f82d3SEliot Blennerhassett hm.u.d.u.data.format.channels = mode; 949*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 950*719f82d3SEliot Blennerhassett return hr.error; 951*719f82d3SEliot Blennerhassett } 952*719f82d3SEliot Blennerhassett 953*719f82d3SEliot Blennerhassett u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, 954*719f82d3SEliot Blennerhassett u32 h_outstream, u32 *pframes_available) 955*719f82d3SEliot Blennerhassett { 956*719f82d3SEliot Blennerhassett struct hpi_message hm; 957*719f82d3SEliot Blennerhassett struct hpi_response hr; 958*719f82d3SEliot Blennerhassett 959*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 960*719f82d3SEliot Blennerhassett HPI_OSTREAM_ANC_GET_INFO); 961*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 962*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 963*719f82d3SEliot Blennerhassett if (hr.error == 0) { 964*719f82d3SEliot Blennerhassett if (pframes_available) 965*719f82d3SEliot Blennerhassett *pframes_available = 966*719f82d3SEliot Blennerhassett hr.u.d.u.stream_info.data_available / 967*719f82d3SEliot Blennerhassett sizeof(struct hpi_anc_frame); 968*719f82d3SEliot Blennerhassett } 969*719f82d3SEliot Blennerhassett return hr.error; 970*719f82d3SEliot Blennerhassett } 971*719f82d3SEliot Blennerhassett 972*719f82d3SEliot Blennerhassett u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys, 973*719f82d3SEliot Blennerhassett u32 h_outstream, struct hpi_anc_frame *p_anc_frame_buffer, 974*719f82d3SEliot Blennerhassett u32 anc_frame_buffer_size_in_bytes, 975*719f82d3SEliot Blennerhassett u32 number_of_ancillary_frames_to_read) 976*719f82d3SEliot Blennerhassett { 977*719f82d3SEliot Blennerhassett struct hpi_message hm; 978*719f82d3SEliot Blennerhassett struct hpi_response hr; 979*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 980*719f82d3SEliot Blennerhassett HPI_OSTREAM_ANC_READ); 981*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 982*719f82d3SEliot Blennerhassett hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer; 983*719f82d3SEliot Blennerhassett hm.u.d.u.data.data_size = 984*719f82d3SEliot Blennerhassett number_of_ancillary_frames_to_read * 985*719f82d3SEliot Blennerhassett sizeof(struct hpi_anc_frame); 986*719f82d3SEliot Blennerhassett if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes) 987*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 988*719f82d3SEliot Blennerhassett else 989*719f82d3SEliot Blennerhassett hr.error = HPI_ERROR_INVALID_DATA_TRANSFER; 990*719f82d3SEliot Blennerhassett return hr.error; 991*719f82d3SEliot Blennerhassett } 992*719f82d3SEliot Blennerhassett 993*719f82d3SEliot Blennerhassett u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys, 994*719f82d3SEliot Blennerhassett u32 h_outstream, u32 time_scale) 995*719f82d3SEliot Blennerhassett { 996*719f82d3SEliot Blennerhassett struct hpi_message hm; 997*719f82d3SEliot Blennerhassett struct hpi_response hr; 998*719f82d3SEliot Blennerhassett 999*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 1000*719f82d3SEliot Blennerhassett HPI_OSTREAM_SET_TIMESCALE); 1001*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 1002*719f82d3SEliot Blennerhassett 1003*719f82d3SEliot Blennerhassett hm.u.d.u.time_scale = time_scale; 1004*719f82d3SEliot Blennerhassett 1005*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1006*719f82d3SEliot Blennerhassett 1007*719f82d3SEliot Blennerhassett return hr.error; 1008*719f82d3SEliot Blennerhassett } 1009*719f82d3SEliot Blennerhassett 1010*719f82d3SEliot Blennerhassett u16 hpi_outstream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, 1011*719f82d3SEliot Blennerhassett u32 h_outstream, u32 size_in_bytes) 1012*719f82d3SEliot Blennerhassett { 1013*719f82d3SEliot Blennerhassett struct hpi_message hm; 1014*719f82d3SEliot Blennerhassett struct hpi_response hr; 1015*719f82d3SEliot Blennerhassett 1016*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 1017*719f82d3SEliot Blennerhassett HPI_OSTREAM_HOSTBUFFER_ALLOC); 1018*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 1019*719f82d3SEliot Blennerhassett hm.u.d.u.data.data_size = size_in_bytes; 1020*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1021*719f82d3SEliot Blennerhassett return hr.error; 1022*719f82d3SEliot Blennerhassett } 1023*719f82d3SEliot Blennerhassett 1024*719f82d3SEliot Blennerhassett u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, 1025*719f82d3SEliot Blennerhassett u32 h_outstream, u8 **pp_buffer, 1026*719f82d3SEliot Blennerhassett struct hpi_hostbuffer_status **pp_status) 1027*719f82d3SEliot Blennerhassett { 1028*719f82d3SEliot Blennerhassett struct hpi_message hm; 1029*719f82d3SEliot Blennerhassett struct hpi_response hr; 1030*719f82d3SEliot Blennerhassett 1031*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 1032*719f82d3SEliot Blennerhassett HPI_OSTREAM_HOSTBUFFER_GET_INFO); 1033*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 1034*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1035*719f82d3SEliot Blennerhassett 1036*719f82d3SEliot Blennerhassett if (hr.error == 0) { 1037*719f82d3SEliot Blennerhassett if (pp_buffer) 1038*719f82d3SEliot Blennerhassett *pp_buffer = hr.u.d.u.hostbuffer_info.p_buffer; 1039*719f82d3SEliot Blennerhassett if (pp_status) 1040*719f82d3SEliot Blennerhassett *pp_status = hr.u.d.u.hostbuffer_info.p_status; 1041*719f82d3SEliot Blennerhassett } 1042*719f82d3SEliot Blennerhassett return hr.error; 1043*719f82d3SEliot Blennerhassett } 1044*719f82d3SEliot Blennerhassett 1045*719f82d3SEliot Blennerhassett u16 hpi_outstream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, 1046*719f82d3SEliot Blennerhassett u32 h_outstream) 1047*719f82d3SEliot Blennerhassett { 1048*719f82d3SEliot Blennerhassett struct hpi_message hm; 1049*719f82d3SEliot Blennerhassett struct hpi_response hr; 1050*719f82d3SEliot Blennerhassett 1051*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 1052*719f82d3SEliot Blennerhassett HPI_OSTREAM_HOSTBUFFER_FREE); 1053*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 1054*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1055*719f82d3SEliot Blennerhassett return hr.error; 1056*719f82d3SEliot Blennerhassett } 1057*719f82d3SEliot Blennerhassett 1058*719f82d3SEliot Blennerhassett u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys, 1059*719f82d3SEliot Blennerhassett u32 h_outstream, u32 h_stream) 1060*719f82d3SEliot Blennerhassett { 1061*719f82d3SEliot Blennerhassett struct hpi_message hm; 1062*719f82d3SEliot Blennerhassett struct hpi_response hr; 1063*719f82d3SEliot Blennerhassett u16 adapter; 1064*719f82d3SEliot Blennerhassett char c_obj_type; 1065*719f82d3SEliot Blennerhassett 1066*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 1067*719f82d3SEliot Blennerhassett HPI_OSTREAM_GROUP_ADD); 1068*719f82d3SEliot Blennerhassett hr.error = 0; 1069*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 1070*719f82d3SEliot Blennerhassett c_obj_type = hpi_handle_object(h_stream); 1071*719f82d3SEliot Blennerhassett switch (c_obj_type) { 1072*719f82d3SEliot Blennerhassett case HPI_OBJ_OSTREAM: 1073*719f82d3SEliot Blennerhassett hm.u.d.u.stream.object_type = HPI_OBJ_OSTREAM; 1074*719f82d3SEliot Blennerhassett u32TOINDEXES(h_stream, &adapter, 1075*719f82d3SEliot Blennerhassett &hm.u.d.u.stream.stream_index); 1076*719f82d3SEliot Blennerhassett break; 1077*719f82d3SEliot Blennerhassett case HPI_OBJ_ISTREAM: 1078*719f82d3SEliot Blennerhassett hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM; 1079*719f82d3SEliot Blennerhassett u32TOINDEXES(h_stream, &adapter, 1080*719f82d3SEliot Blennerhassett &hm.u.d.u.stream.stream_index); 1081*719f82d3SEliot Blennerhassett break; 1082*719f82d3SEliot Blennerhassett default: 1083*719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_STREAM; 1084*719f82d3SEliot Blennerhassett } 1085*719f82d3SEliot Blennerhassett if (adapter != hm.adapter_index) 1086*719f82d3SEliot Blennerhassett return HPI_ERROR_NO_INTERADAPTER_GROUPS; 1087*719f82d3SEliot Blennerhassett 1088*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1089*719f82d3SEliot Blennerhassett return hr.error; 1090*719f82d3SEliot Blennerhassett } 1091*719f82d3SEliot Blennerhassett 1092*719f82d3SEliot Blennerhassett u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys, 1093*719f82d3SEliot Blennerhassett u32 h_outstream, u32 *poutstream_map, u32 *pinstream_map) 1094*719f82d3SEliot Blennerhassett { 1095*719f82d3SEliot Blennerhassett struct hpi_message hm; 1096*719f82d3SEliot Blennerhassett struct hpi_response hr; 1097*719f82d3SEliot Blennerhassett 1098*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 1099*719f82d3SEliot Blennerhassett HPI_OSTREAM_GROUP_GETMAP); 1100*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 1101*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1102*719f82d3SEliot Blennerhassett 1103*719f82d3SEliot Blennerhassett if (poutstream_map) 1104*719f82d3SEliot Blennerhassett *poutstream_map = hr.u.d.u.group_info.outstream_group_map; 1105*719f82d3SEliot Blennerhassett if (pinstream_map) 1106*719f82d3SEliot Blennerhassett *pinstream_map = hr.u.d.u.group_info.instream_group_map; 1107*719f82d3SEliot Blennerhassett 1108*719f82d3SEliot Blennerhassett return hr.error; 1109*719f82d3SEliot Blennerhassett } 1110*719f82d3SEliot Blennerhassett 1111*719f82d3SEliot Blennerhassett u16 hpi_outstream_group_reset(const struct hpi_hsubsys *ph_subsys, 1112*719f82d3SEliot Blennerhassett u32 h_outstream) 1113*719f82d3SEliot Blennerhassett { 1114*719f82d3SEliot Blennerhassett struct hpi_message hm; 1115*719f82d3SEliot Blennerhassett struct hpi_response hr; 1116*719f82d3SEliot Blennerhassett 1117*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 1118*719f82d3SEliot Blennerhassett HPI_OSTREAM_GROUP_RESET); 1119*719f82d3SEliot Blennerhassett u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 1120*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1121*719f82d3SEliot Blennerhassett return hr.error; 1122*719f82d3SEliot Blennerhassett } 1123*719f82d3SEliot Blennerhassett 1124*719f82d3SEliot Blennerhassett u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 1125*719f82d3SEliot Blennerhassett u16 instream_index, u32 *ph_instream) 1126*719f82d3SEliot Blennerhassett { 1127*719f82d3SEliot Blennerhassett struct hpi_message hm; 1128*719f82d3SEliot Blennerhassett struct hpi_response hr; 1129*719f82d3SEliot Blennerhassett 1130*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1131*719f82d3SEliot Blennerhassett HPI_ISTREAM_OPEN); 1132*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 1133*719f82d3SEliot Blennerhassett hm.obj_index = instream_index; 1134*719f82d3SEliot Blennerhassett 1135*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1136*719f82d3SEliot Blennerhassett 1137*719f82d3SEliot Blennerhassett if (hr.error == 0) 1138*719f82d3SEliot Blennerhassett *ph_instream = 1139*719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_ISTREAM, adapter_index, 1140*719f82d3SEliot Blennerhassett instream_index); 1141*719f82d3SEliot Blennerhassett else 1142*719f82d3SEliot Blennerhassett *ph_instream = 0; 1143*719f82d3SEliot Blennerhassett 1144*719f82d3SEliot Blennerhassett return hr.error; 1145*719f82d3SEliot Blennerhassett } 1146*719f82d3SEliot Blennerhassett 1147*719f82d3SEliot Blennerhassett u16 hpi_instream_close(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 1148*719f82d3SEliot Blennerhassett { 1149*719f82d3SEliot Blennerhassett struct hpi_message hm; 1150*719f82d3SEliot Blennerhassett struct hpi_response hr; 1151*719f82d3SEliot Blennerhassett 1152*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1153*719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_FREE); 1154*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1155*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1156*719f82d3SEliot Blennerhassett 1157*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1158*719f82d3SEliot Blennerhassett HPI_ISTREAM_GROUP_RESET); 1159*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1160*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1161*719f82d3SEliot Blennerhassett 1162*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1163*719f82d3SEliot Blennerhassett HPI_ISTREAM_CLOSE); 1164*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1165*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1166*719f82d3SEliot Blennerhassett 1167*719f82d3SEliot Blennerhassett return hr.error; 1168*719f82d3SEliot Blennerhassett } 1169*719f82d3SEliot Blennerhassett 1170*719f82d3SEliot Blennerhassett u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys, 1171*719f82d3SEliot Blennerhassett u32 h_instream, const struct hpi_format *p_format) 1172*719f82d3SEliot Blennerhassett { 1173*719f82d3SEliot Blennerhassett struct hpi_message hm; 1174*719f82d3SEliot Blennerhassett struct hpi_response hr; 1175*719f82d3SEliot Blennerhassett 1176*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1177*719f82d3SEliot Blennerhassett HPI_ISTREAM_QUERY_FORMAT); 1178*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1179*719f82d3SEliot Blennerhassett hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 1180*719f82d3SEliot Blennerhassett 1181*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1182*719f82d3SEliot Blennerhassett 1183*719f82d3SEliot Blennerhassett return hr.error; 1184*719f82d3SEliot Blennerhassett } 1185*719f82d3SEliot Blennerhassett 1186*719f82d3SEliot Blennerhassett u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys, 1187*719f82d3SEliot Blennerhassett u32 h_instream, const struct hpi_format *p_format) 1188*719f82d3SEliot Blennerhassett { 1189*719f82d3SEliot Blennerhassett struct hpi_message hm; 1190*719f82d3SEliot Blennerhassett struct hpi_response hr; 1191*719f82d3SEliot Blennerhassett 1192*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1193*719f82d3SEliot Blennerhassett HPI_ISTREAM_SET_FORMAT); 1194*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1195*719f82d3SEliot Blennerhassett hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 1196*719f82d3SEliot Blennerhassett 1197*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1198*719f82d3SEliot Blennerhassett 1199*719f82d3SEliot Blennerhassett return hr.error; 1200*719f82d3SEliot Blennerhassett } 1201*719f82d3SEliot Blennerhassett 1202*719f82d3SEliot Blennerhassett u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream, 1203*719f82d3SEliot Blennerhassett u8 *pb_data, u32 bytes_to_read) 1204*719f82d3SEliot Blennerhassett { 1205*719f82d3SEliot Blennerhassett struct hpi_message hm; 1206*719f82d3SEliot Blennerhassett struct hpi_response hr; 1207*719f82d3SEliot Blennerhassett 1208*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1209*719f82d3SEliot Blennerhassett HPI_ISTREAM_READ); 1210*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1211*719f82d3SEliot Blennerhassett hm.u.d.u.data.data_size = bytes_to_read; 1212*719f82d3SEliot Blennerhassett hm.u.d.u.data.pb_data = pb_data; 1213*719f82d3SEliot Blennerhassett 1214*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1215*719f82d3SEliot Blennerhassett 1216*719f82d3SEliot Blennerhassett return hr.error; 1217*719f82d3SEliot Blennerhassett } 1218*719f82d3SEliot Blennerhassett 1219*719f82d3SEliot Blennerhassett u16 hpi_instream_start(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 1220*719f82d3SEliot Blennerhassett { 1221*719f82d3SEliot Blennerhassett struct hpi_message hm; 1222*719f82d3SEliot Blennerhassett struct hpi_response hr; 1223*719f82d3SEliot Blennerhassett 1224*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1225*719f82d3SEliot Blennerhassett HPI_ISTREAM_START); 1226*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1227*719f82d3SEliot Blennerhassett 1228*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1229*719f82d3SEliot Blennerhassett 1230*719f82d3SEliot Blennerhassett return hr.error; 1231*719f82d3SEliot Blennerhassett } 1232*719f82d3SEliot Blennerhassett 1233*719f82d3SEliot Blennerhassett u16 hpi_instream_wait_start(const struct hpi_hsubsys *ph_subsys, 1234*719f82d3SEliot Blennerhassett u32 h_instream) 1235*719f82d3SEliot Blennerhassett { 1236*719f82d3SEliot Blennerhassett struct hpi_message hm; 1237*719f82d3SEliot Blennerhassett struct hpi_response hr; 1238*719f82d3SEliot Blennerhassett 1239*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1240*719f82d3SEliot Blennerhassett HPI_ISTREAM_WAIT_START); 1241*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1242*719f82d3SEliot Blennerhassett 1243*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1244*719f82d3SEliot Blennerhassett 1245*719f82d3SEliot Blennerhassett return hr.error; 1246*719f82d3SEliot Blennerhassett } 1247*719f82d3SEliot Blennerhassett 1248*719f82d3SEliot Blennerhassett u16 hpi_instream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 1249*719f82d3SEliot Blennerhassett { 1250*719f82d3SEliot Blennerhassett struct hpi_message hm; 1251*719f82d3SEliot Blennerhassett struct hpi_response hr; 1252*719f82d3SEliot Blennerhassett 1253*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1254*719f82d3SEliot Blennerhassett HPI_ISTREAM_STOP); 1255*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1256*719f82d3SEliot Blennerhassett 1257*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1258*719f82d3SEliot Blennerhassett 1259*719f82d3SEliot Blennerhassett return hr.error; 1260*719f82d3SEliot Blennerhassett } 1261*719f82d3SEliot Blennerhassett 1262*719f82d3SEliot Blennerhassett u16 hpi_instream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 1263*719f82d3SEliot Blennerhassett { 1264*719f82d3SEliot Blennerhassett struct hpi_message hm; 1265*719f82d3SEliot Blennerhassett struct hpi_response hr; 1266*719f82d3SEliot Blennerhassett 1267*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1268*719f82d3SEliot Blennerhassett HPI_ISTREAM_RESET); 1269*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1270*719f82d3SEliot Blennerhassett 1271*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1272*719f82d3SEliot Blennerhassett 1273*719f82d3SEliot Blennerhassett return hr.error; 1274*719f82d3SEliot Blennerhassett } 1275*719f82d3SEliot Blennerhassett 1276*719f82d3SEliot Blennerhassett u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys, 1277*719f82d3SEliot Blennerhassett u32 h_instream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_recorded, 1278*719f82d3SEliot Blennerhassett u32 *psamples_recorded, u32 *pauxiliary_data_recorded) 1279*719f82d3SEliot Blennerhassett { 1280*719f82d3SEliot Blennerhassett struct hpi_message hm; 1281*719f82d3SEliot Blennerhassett struct hpi_response hr; 1282*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1283*719f82d3SEliot Blennerhassett HPI_ISTREAM_GET_INFO); 1284*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1285*719f82d3SEliot Blennerhassett 1286*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1287*719f82d3SEliot Blennerhassett 1288*719f82d3SEliot Blennerhassett if (pw_state) 1289*719f82d3SEliot Blennerhassett *pw_state = hr.u.d.u.stream_info.state; 1290*719f82d3SEliot Blennerhassett if (pbuffer_size) 1291*719f82d3SEliot Blennerhassett *pbuffer_size = hr.u.d.u.stream_info.buffer_size; 1292*719f82d3SEliot Blennerhassett if (pdata_recorded) 1293*719f82d3SEliot Blennerhassett *pdata_recorded = hr.u.d.u.stream_info.data_available; 1294*719f82d3SEliot Blennerhassett if (psamples_recorded) 1295*719f82d3SEliot Blennerhassett *psamples_recorded = hr.u.d.u.stream_info.samples_transferred; 1296*719f82d3SEliot Blennerhassett if (pauxiliary_data_recorded) 1297*719f82d3SEliot Blennerhassett *pauxiliary_data_recorded = 1298*719f82d3SEliot Blennerhassett hr.u.d.u.stream_info.auxiliary_data_available; 1299*719f82d3SEliot Blennerhassett return hr.error; 1300*719f82d3SEliot Blennerhassett } 1301*719f82d3SEliot Blennerhassett 1302*719f82d3SEliot Blennerhassett u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, 1303*719f82d3SEliot Blennerhassett u32 h_instream, u16 bytes_per_frame, u16 mode, u16 alignment, 1304*719f82d3SEliot Blennerhassett u16 idle_bit) 1305*719f82d3SEliot Blennerhassett { 1306*719f82d3SEliot Blennerhassett struct hpi_message hm; 1307*719f82d3SEliot Blennerhassett struct hpi_response hr; 1308*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1309*719f82d3SEliot Blennerhassett HPI_ISTREAM_ANC_RESET); 1310*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1311*719f82d3SEliot Blennerhassett hm.u.d.u.data.format.attributes = bytes_per_frame; 1312*719f82d3SEliot Blennerhassett hm.u.d.u.data.format.format = (mode << 8) | (alignment & 0xff); 1313*719f82d3SEliot Blennerhassett hm.u.d.u.data.format.channels = idle_bit; 1314*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1315*719f82d3SEliot Blennerhassett return hr.error; 1316*719f82d3SEliot Blennerhassett } 1317*719f82d3SEliot Blennerhassett 1318*719f82d3SEliot Blennerhassett u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, 1319*719f82d3SEliot Blennerhassett u32 h_instream, u32 *pframe_space) 1320*719f82d3SEliot Blennerhassett { 1321*719f82d3SEliot Blennerhassett struct hpi_message hm; 1322*719f82d3SEliot Blennerhassett struct hpi_response hr; 1323*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1324*719f82d3SEliot Blennerhassett HPI_ISTREAM_ANC_GET_INFO); 1325*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1326*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1327*719f82d3SEliot Blennerhassett if (pframe_space) 1328*719f82d3SEliot Blennerhassett *pframe_space = 1329*719f82d3SEliot Blennerhassett (hr.u.d.u.stream_info.buffer_size - 1330*719f82d3SEliot Blennerhassett hr.u.d.u.stream_info.data_available) / 1331*719f82d3SEliot Blennerhassett sizeof(struct hpi_anc_frame); 1332*719f82d3SEliot Blennerhassett return hr.error; 1333*719f82d3SEliot Blennerhassett } 1334*719f82d3SEliot Blennerhassett 1335*719f82d3SEliot Blennerhassett u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys, 1336*719f82d3SEliot Blennerhassett u32 h_instream, const struct hpi_anc_frame *p_anc_frame_buffer, 1337*719f82d3SEliot Blennerhassett u32 anc_frame_buffer_size_in_bytes, 1338*719f82d3SEliot Blennerhassett u32 number_of_ancillary_frames_to_write) 1339*719f82d3SEliot Blennerhassett { 1340*719f82d3SEliot Blennerhassett struct hpi_message hm; 1341*719f82d3SEliot Blennerhassett struct hpi_response hr; 1342*719f82d3SEliot Blennerhassett 1343*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1344*719f82d3SEliot Blennerhassett HPI_ISTREAM_ANC_WRITE); 1345*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1346*719f82d3SEliot Blennerhassett hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer; 1347*719f82d3SEliot Blennerhassett hm.u.d.u.data.data_size = 1348*719f82d3SEliot Blennerhassett number_of_ancillary_frames_to_write * 1349*719f82d3SEliot Blennerhassett sizeof(struct hpi_anc_frame); 1350*719f82d3SEliot Blennerhassett if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes) 1351*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1352*719f82d3SEliot Blennerhassett else 1353*719f82d3SEliot Blennerhassett hr.error = HPI_ERROR_INVALID_DATA_TRANSFER; 1354*719f82d3SEliot Blennerhassett return hr.error; 1355*719f82d3SEliot Blennerhassett } 1356*719f82d3SEliot Blennerhassett 1357*719f82d3SEliot Blennerhassett u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, 1358*719f82d3SEliot Blennerhassett u32 h_instream, u32 size_in_bytes) 1359*719f82d3SEliot Blennerhassett { 1360*719f82d3SEliot Blennerhassett 1361*719f82d3SEliot Blennerhassett struct hpi_message hm; 1362*719f82d3SEliot Blennerhassett struct hpi_response hr; 1363*719f82d3SEliot Blennerhassett 1364*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1365*719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_ALLOC); 1366*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1367*719f82d3SEliot Blennerhassett hm.u.d.u.data.data_size = size_in_bytes; 1368*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1369*719f82d3SEliot Blennerhassett return hr.error; 1370*719f82d3SEliot Blennerhassett } 1371*719f82d3SEliot Blennerhassett 1372*719f82d3SEliot Blennerhassett u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, 1373*719f82d3SEliot Blennerhassett u32 h_instream, u8 **pp_buffer, 1374*719f82d3SEliot Blennerhassett struct hpi_hostbuffer_status **pp_status) 1375*719f82d3SEliot Blennerhassett { 1376*719f82d3SEliot Blennerhassett struct hpi_message hm; 1377*719f82d3SEliot Blennerhassett struct hpi_response hr; 1378*719f82d3SEliot Blennerhassett 1379*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1380*719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_GET_INFO); 1381*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1382*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1383*719f82d3SEliot Blennerhassett 1384*719f82d3SEliot Blennerhassett if (hr.error == 0) { 1385*719f82d3SEliot Blennerhassett if (pp_buffer) 1386*719f82d3SEliot Blennerhassett *pp_buffer = hr.u.d.u.hostbuffer_info.p_buffer; 1387*719f82d3SEliot Blennerhassett if (pp_status) 1388*719f82d3SEliot Blennerhassett *pp_status = hr.u.d.u.hostbuffer_info.p_status; 1389*719f82d3SEliot Blennerhassett } 1390*719f82d3SEliot Blennerhassett return hr.error; 1391*719f82d3SEliot Blennerhassett } 1392*719f82d3SEliot Blennerhassett 1393*719f82d3SEliot Blennerhassett u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, 1394*719f82d3SEliot Blennerhassett u32 h_instream) 1395*719f82d3SEliot Blennerhassett { 1396*719f82d3SEliot Blennerhassett 1397*719f82d3SEliot Blennerhassett struct hpi_message hm; 1398*719f82d3SEliot Blennerhassett struct hpi_response hr; 1399*719f82d3SEliot Blennerhassett 1400*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1401*719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_FREE); 1402*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1403*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1404*719f82d3SEliot Blennerhassett return hr.error; 1405*719f82d3SEliot Blennerhassett } 1406*719f82d3SEliot Blennerhassett 1407*719f82d3SEliot Blennerhassett u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys, 1408*719f82d3SEliot Blennerhassett u32 h_instream, u32 h_stream) 1409*719f82d3SEliot Blennerhassett { 1410*719f82d3SEliot Blennerhassett struct hpi_message hm; 1411*719f82d3SEliot Blennerhassett struct hpi_response hr; 1412*719f82d3SEliot Blennerhassett u16 adapter; 1413*719f82d3SEliot Blennerhassett char c_obj_type; 1414*719f82d3SEliot Blennerhassett 1415*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1416*719f82d3SEliot Blennerhassett HPI_ISTREAM_GROUP_ADD); 1417*719f82d3SEliot Blennerhassett hr.error = 0; 1418*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1419*719f82d3SEliot Blennerhassett c_obj_type = hpi_handle_object(h_stream); 1420*719f82d3SEliot Blennerhassett 1421*719f82d3SEliot Blennerhassett switch (c_obj_type) { 1422*719f82d3SEliot Blennerhassett case HPI_OBJ_OSTREAM: 1423*719f82d3SEliot Blennerhassett hm.u.d.u.stream.object_type = HPI_OBJ_OSTREAM; 1424*719f82d3SEliot Blennerhassett u32TOINDEXES(h_stream, &adapter, 1425*719f82d3SEliot Blennerhassett &hm.u.d.u.stream.stream_index); 1426*719f82d3SEliot Blennerhassett break; 1427*719f82d3SEliot Blennerhassett case HPI_OBJ_ISTREAM: 1428*719f82d3SEliot Blennerhassett hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM; 1429*719f82d3SEliot Blennerhassett u32TOINDEXES(h_stream, &adapter, 1430*719f82d3SEliot Blennerhassett &hm.u.d.u.stream.stream_index); 1431*719f82d3SEliot Blennerhassett break; 1432*719f82d3SEliot Blennerhassett default: 1433*719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_STREAM; 1434*719f82d3SEliot Blennerhassett } 1435*719f82d3SEliot Blennerhassett 1436*719f82d3SEliot Blennerhassett if (adapter != hm.adapter_index) 1437*719f82d3SEliot Blennerhassett return HPI_ERROR_NO_INTERADAPTER_GROUPS; 1438*719f82d3SEliot Blennerhassett 1439*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1440*719f82d3SEliot Blennerhassett return hr.error; 1441*719f82d3SEliot Blennerhassett } 1442*719f82d3SEliot Blennerhassett 1443*719f82d3SEliot Blennerhassett u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys, 1444*719f82d3SEliot Blennerhassett u32 h_instream, u32 *poutstream_map, u32 *pinstream_map) 1445*719f82d3SEliot Blennerhassett { 1446*719f82d3SEliot Blennerhassett struct hpi_message hm; 1447*719f82d3SEliot Blennerhassett struct hpi_response hr; 1448*719f82d3SEliot Blennerhassett 1449*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1450*719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_FREE); 1451*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1452*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1453*719f82d3SEliot Blennerhassett 1454*719f82d3SEliot Blennerhassett if (poutstream_map) 1455*719f82d3SEliot Blennerhassett *poutstream_map = hr.u.d.u.group_info.outstream_group_map; 1456*719f82d3SEliot Blennerhassett if (pinstream_map) 1457*719f82d3SEliot Blennerhassett *pinstream_map = hr.u.d.u.group_info.instream_group_map; 1458*719f82d3SEliot Blennerhassett 1459*719f82d3SEliot Blennerhassett return hr.error; 1460*719f82d3SEliot Blennerhassett } 1461*719f82d3SEliot Blennerhassett 1462*719f82d3SEliot Blennerhassett u16 hpi_instream_group_reset(const struct hpi_hsubsys *ph_subsys, 1463*719f82d3SEliot Blennerhassett u32 h_instream) 1464*719f82d3SEliot Blennerhassett { 1465*719f82d3SEliot Blennerhassett struct hpi_message hm; 1466*719f82d3SEliot Blennerhassett struct hpi_response hr; 1467*719f82d3SEliot Blennerhassett 1468*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1469*719f82d3SEliot Blennerhassett HPI_ISTREAM_GROUP_RESET); 1470*719f82d3SEliot Blennerhassett u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1471*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1472*719f82d3SEliot Blennerhassett return hr.error; 1473*719f82d3SEliot Blennerhassett } 1474*719f82d3SEliot Blennerhassett 1475*719f82d3SEliot Blennerhassett u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 1476*719f82d3SEliot Blennerhassett u32 *ph_mixer) 1477*719f82d3SEliot Blennerhassett { 1478*719f82d3SEliot Blennerhassett struct hpi_message hm; 1479*719f82d3SEliot Blennerhassett struct hpi_response hr; 1480*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN); 1481*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 1482*719f82d3SEliot Blennerhassett 1483*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1484*719f82d3SEliot Blennerhassett 1485*719f82d3SEliot Blennerhassett if (hr.error == 0) 1486*719f82d3SEliot Blennerhassett *ph_mixer = 1487*719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_MIXER, adapter_index, 1488*719f82d3SEliot Blennerhassett 0); 1489*719f82d3SEliot Blennerhassett else 1490*719f82d3SEliot Blennerhassett *ph_mixer = 0; 1491*719f82d3SEliot Blennerhassett return hr.error; 1492*719f82d3SEliot Blennerhassett } 1493*719f82d3SEliot Blennerhassett 1494*719f82d3SEliot Blennerhassett u16 hpi_mixer_close(const struct hpi_hsubsys *ph_subsys, u32 h_mixer) 1495*719f82d3SEliot Blennerhassett { 1496*719f82d3SEliot Blennerhassett struct hpi_message hm; 1497*719f82d3SEliot Blennerhassett struct hpi_response hr; 1498*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE); 1499*719f82d3SEliot Blennerhassett u32TOINDEX(h_mixer, &hm.adapter_index); 1500*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1501*719f82d3SEliot Blennerhassett return hr.error; 1502*719f82d3SEliot Blennerhassett } 1503*719f82d3SEliot Blennerhassett 1504*719f82d3SEliot Blennerhassett u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, 1505*719f82d3SEliot Blennerhassett u16 src_node_type, u16 src_node_type_index, u16 dst_node_type, 1506*719f82d3SEliot Blennerhassett u16 dst_node_type_index, u16 control_type, u32 *ph_control) 1507*719f82d3SEliot Blennerhassett { 1508*719f82d3SEliot Blennerhassett struct hpi_message hm; 1509*719f82d3SEliot Blennerhassett struct hpi_response hr; 1510*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, 1511*719f82d3SEliot Blennerhassett HPI_MIXER_GET_CONTROL); 1512*719f82d3SEliot Blennerhassett u32TOINDEX(h_mixer, &hm.adapter_index); 1513*719f82d3SEliot Blennerhassett hm.u.m.node_type1 = src_node_type; 1514*719f82d3SEliot Blennerhassett hm.u.m.node_index1 = src_node_type_index; 1515*719f82d3SEliot Blennerhassett hm.u.m.node_type2 = dst_node_type; 1516*719f82d3SEliot Blennerhassett hm.u.m.node_index2 = dst_node_type_index; 1517*719f82d3SEliot Blennerhassett hm.u.m.control_type = control_type; 1518*719f82d3SEliot Blennerhassett 1519*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1520*719f82d3SEliot Blennerhassett 1521*719f82d3SEliot Blennerhassett if (hr.error == 0) 1522*719f82d3SEliot Blennerhassett *ph_control = 1523*719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_CONTROL, 1524*719f82d3SEliot Blennerhassett hm.adapter_index, hr.u.m.control_index); 1525*719f82d3SEliot Blennerhassett else 1526*719f82d3SEliot Blennerhassett *ph_control = 0; 1527*719f82d3SEliot Blennerhassett return hr.error; 1528*719f82d3SEliot Blennerhassett } 1529*719f82d3SEliot Blennerhassett 1530*719f82d3SEliot Blennerhassett u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys, 1531*719f82d3SEliot Blennerhassett u32 h_mixer, u16 control_index, u16 *pw_src_node_type, 1532*719f82d3SEliot Blennerhassett u16 *pw_src_node_index, u16 *pw_dst_node_type, u16 *pw_dst_node_index, 1533*719f82d3SEliot Blennerhassett u16 *pw_control_type, u32 *ph_control) 1534*719f82d3SEliot Blennerhassett { 1535*719f82d3SEliot Blennerhassett struct hpi_message hm; 1536*719f82d3SEliot Blennerhassett struct hpi_response hr; 1537*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, 1538*719f82d3SEliot Blennerhassett HPI_MIXER_GET_CONTROL_BY_INDEX); 1539*719f82d3SEliot Blennerhassett u32TOINDEX(h_mixer, &hm.adapter_index); 1540*719f82d3SEliot Blennerhassett hm.u.m.control_index = control_index; 1541*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1542*719f82d3SEliot Blennerhassett 1543*719f82d3SEliot Blennerhassett if (pw_src_node_type) { 1544*719f82d3SEliot Blennerhassett *pw_src_node_type = 1545*719f82d3SEliot Blennerhassett hr.u.m.src_node_type + HPI_SOURCENODE_NONE; 1546*719f82d3SEliot Blennerhassett *pw_src_node_index = hr.u.m.src_node_index; 1547*719f82d3SEliot Blennerhassett *pw_dst_node_type = hr.u.m.dst_node_type + HPI_DESTNODE_NONE; 1548*719f82d3SEliot Blennerhassett *pw_dst_node_index = hr.u.m.dst_node_index; 1549*719f82d3SEliot Blennerhassett } 1550*719f82d3SEliot Blennerhassett if (pw_control_type) 1551*719f82d3SEliot Blennerhassett *pw_control_type = hr.u.m.control_index; 1552*719f82d3SEliot Blennerhassett 1553*719f82d3SEliot Blennerhassett if (ph_control) { 1554*719f82d3SEliot Blennerhassett if (hr.error == 0) 1555*719f82d3SEliot Blennerhassett *ph_control = 1556*719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_CONTROL, 1557*719f82d3SEliot Blennerhassett hm.adapter_index, control_index); 1558*719f82d3SEliot Blennerhassett else 1559*719f82d3SEliot Blennerhassett *ph_control = 0; 1560*719f82d3SEliot Blennerhassett } 1561*719f82d3SEliot Blennerhassett return hr.error; 1562*719f82d3SEliot Blennerhassett } 1563*719f82d3SEliot Blennerhassett 1564*719f82d3SEliot Blennerhassett u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, 1565*719f82d3SEliot Blennerhassett enum HPI_MIXER_STORE_COMMAND command, u16 index) 1566*719f82d3SEliot Blennerhassett { 1567*719f82d3SEliot Blennerhassett struct hpi_message hm; 1568*719f82d3SEliot Blennerhassett struct hpi_response hr; 1569*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_STORE); 1570*719f82d3SEliot Blennerhassett u32TOINDEX(h_mixer, &hm.adapter_index); 1571*719f82d3SEliot Blennerhassett hm.u.mx.store.command = command; 1572*719f82d3SEliot Blennerhassett hm.u.mx.store.index = index; 1573*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1574*719f82d3SEliot Blennerhassett return hr.error; 1575*719f82d3SEliot Blennerhassett } 1576*719f82d3SEliot Blennerhassett 1577*719f82d3SEliot Blennerhassett static 1578*719f82d3SEliot Blennerhassett u16 hpi_control_param_set(const struct hpi_hsubsys *ph_subsys, 1579*719f82d3SEliot Blennerhassett const u32 h_control, const u16 attrib, const u32 param1, 1580*719f82d3SEliot Blennerhassett const u32 param2) 1581*719f82d3SEliot Blennerhassett { 1582*719f82d3SEliot Blennerhassett struct hpi_message hm; 1583*719f82d3SEliot Blennerhassett struct hpi_response hr; 1584*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1585*719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 1586*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1587*719f82d3SEliot Blennerhassett hm.u.c.attribute = attrib; 1588*719f82d3SEliot Blennerhassett hm.u.c.param1 = param1; 1589*719f82d3SEliot Blennerhassett hm.u.c.param2 = param2; 1590*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1591*719f82d3SEliot Blennerhassett return hr.error; 1592*719f82d3SEliot Blennerhassett } 1593*719f82d3SEliot Blennerhassett 1594*719f82d3SEliot Blennerhassett static 1595*719f82d3SEliot Blennerhassett u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys, 1596*719f82d3SEliot Blennerhassett const u32 h_control, const u16 attrib, u32 param1, u32 param2, 1597*719f82d3SEliot Blennerhassett u32 *pparam1, u32 *pparam2) 1598*719f82d3SEliot Blennerhassett { 1599*719f82d3SEliot Blennerhassett struct hpi_message hm; 1600*719f82d3SEliot Blennerhassett struct hpi_response hr; 1601*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1602*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1603*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1604*719f82d3SEliot Blennerhassett hm.u.c.attribute = attrib; 1605*719f82d3SEliot Blennerhassett hm.u.c.param1 = param1; 1606*719f82d3SEliot Blennerhassett hm.u.c.param2 = param2; 1607*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1608*719f82d3SEliot Blennerhassett if (pparam1) 1609*719f82d3SEliot Blennerhassett *pparam1 = hr.u.c.param1; 1610*719f82d3SEliot Blennerhassett if (pparam2) 1611*719f82d3SEliot Blennerhassett *pparam2 = hr.u.c.param2; 1612*719f82d3SEliot Blennerhassett 1613*719f82d3SEliot Blennerhassett return hr.error; 1614*719f82d3SEliot Blennerhassett } 1615*719f82d3SEliot Blennerhassett 1616*719f82d3SEliot Blennerhassett #define hpi_control_param1_get(s, h, a, p1) \ 1617*719f82d3SEliot Blennerhassett hpi_control_param_get(s, h, a, 0, 0, p1, NULL) 1618*719f82d3SEliot Blennerhassett #define hpi_control_param2_get(s, h, a, p1, p2) \ 1619*719f82d3SEliot Blennerhassett hpi_control_param_get(s, h, a, 0, 0, p1, p2) 1620*719f82d3SEliot Blennerhassett #define hpi_control_ex_param1_get(s, h, a, p1) \ 1621*719f82d3SEliot Blennerhassett hpi_control_ex_param_get(s, h, a, 0, 0, p1, NULL) 1622*719f82d3SEliot Blennerhassett #define hpi_control_ex_param2_get(s, h, a, p1, p2) \ 1623*719f82d3SEliot Blennerhassett hpi_control_ex_param_get(s, h, a, 0, 0, p1, p2) 1624*719f82d3SEliot Blennerhassett 1625*719f82d3SEliot Blennerhassett static 1626*719f82d3SEliot Blennerhassett u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys, 1627*719f82d3SEliot Blennerhassett const u32 h_control, const u16 attrib, const u32 index, 1628*719f82d3SEliot Blennerhassett const u32 param, u32 *psetting) 1629*719f82d3SEliot Blennerhassett { 1630*719f82d3SEliot Blennerhassett struct hpi_message hm; 1631*719f82d3SEliot Blennerhassett struct hpi_response hr; 1632*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1633*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_INFO); 1634*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1635*719f82d3SEliot Blennerhassett 1636*719f82d3SEliot Blennerhassett hm.u.c.attribute = attrib; 1637*719f82d3SEliot Blennerhassett hm.u.c.param1 = index; 1638*719f82d3SEliot Blennerhassett hm.u.c.param2 = param; 1639*719f82d3SEliot Blennerhassett 1640*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1641*719f82d3SEliot Blennerhassett *psetting = hr.u.c.param1; 1642*719f82d3SEliot Blennerhassett 1643*719f82d3SEliot Blennerhassett return hr.error; 1644*719f82d3SEliot Blennerhassett } 1645*719f82d3SEliot Blennerhassett 1646*719f82d3SEliot Blennerhassett static u16 hpi_control_get_string(const struct hpi_hsubsys *ph_subsys, 1647*719f82d3SEliot Blennerhassett const u32 h_control, const u16 attribute, char *psz_string, 1648*719f82d3SEliot Blennerhassett const u32 string_length) 1649*719f82d3SEliot Blennerhassett { 1650*719f82d3SEliot Blennerhassett unsigned int sub_string_index = 0, j = 0; 1651*719f82d3SEliot Blennerhassett char c = 0; 1652*719f82d3SEliot Blennerhassett unsigned int n = 0; 1653*719f82d3SEliot Blennerhassett u16 hE = 0; 1654*719f82d3SEliot Blennerhassett 1655*719f82d3SEliot Blennerhassett if ((string_length < 1) || (string_length > 256)) 1656*719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_CONTROL_VALUE; 1657*719f82d3SEliot Blennerhassett for (sub_string_index = 0; sub_string_index < string_length; 1658*719f82d3SEliot Blennerhassett sub_string_index += 8) { 1659*719f82d3SEliot Blennerhassett struct hpi_message hm; 1660*719f82d3SEliot Blennerhassett struct hpi_response hr; 1661*719f82d3SEliot Blennerhassett 1662*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1663*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1664*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1665*719f82d3SEliot Blennerhassett hm.u.c.attribute = attribute; 1666*719f82d3SEliot Blennerhassett hm.u.c.param1 = sub_string_index; 1667*719f82d3SEliot Blennerhassett hm.u.c.param2 = 0; 1668*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1669*719f82d3SEliot Blennerhassett 1670*719f82d3SEliot Blennerhassett if (sub_string_index == 0 1671*719f82d3SEliot Blennerhassett && (hr.u.cu.chars8.remaining_chars + 8) > 1672*719f82d3SEliot Blennerhassett string_length) 1673*719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_CONTROL_VALUE; 1674*719f82d3SEliot Blennerhassett 1675*719f82d3SEliot Blennerhassett if (hr.error) { 1676*719f82d3SEliot Blennerhassett hE = hr.error; 1677*719f82d3SEliot Blennerhassett break; 1678*719f82d3SEliot Blennerhassett } 1679*719f82d3SEliot Blennerhassett for (j = 0; j < 8; j++) { 1680*719f82d3SEliot Blennerhassett c = hr.u.cu.chars8.sz_data[j]; 1681*719f82d3SEliot Blennerhassett psz_string[sub_string_index + j] = c; 1682*719f82d3SEliot Blennerhassett n++; 1683*719f82d3SEliot Blennerhassett if (n >= string_length) { 1684*719f82d3SEliot Blennerhassett psz_string[string_length - 1] = 0; 1685*719f82d3SEliot Blennerhassett hE = HPI_ERROR_INVALID_CONTROL_VALUE; 1686*719f82d3SEliot Blennerhassett break; 1687*719f82d3SEliot Blennerhassett } 1688*719f82d3SEliot Blennerhassett if (c == 0) 1689*719f82d3SEliot Blennerhassett break; 1690*719f82d3SEliot Blennerhassett } 1691*719f82d3SEliot Blennerhassett 1692*719f82d3SEliot Blennerhassett if ((hr.u.cu.chars8.remaining_chars == 0) 1693*719f82d3SEliot Blennerhassett && ((sub_string_index + j) < string_length) 1694*719f82d3SEliot Blennerhassett && (c != 0)) { 1695*719f82d3SEliot Blennerhassett c = 0; 1696*719f82d3SEliot Blennerhassett psz_string[sub_string_index + j] = c; 1697*719f82d3SEliot Blennerhassett } 1698*719f82d3SEliot Blennerhassett if (c == 0) 1699*719f82d3SEliot Blennerhassett break; 1700*719f82d3SEliot Blennerhassett } 1701*719f82d3SEliot Blennerhassett return hE; 1702*719f82d3SEliot Blennerhassett } 1703*719f82d3SEliot Blennerhassett 1704*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys *ph_subsys, 1705*719f82d3SEliot Blennerhassett const u32 h_aes_rx, const u32 index, u16 *pw_format) 1706*719f82d3SEliot Blennerhassett { 1707*719f82d3SEliot Blennerhassett u32 qr; 1708*719f82d3SEliot Blennerhassett u16 err; 1709*719f82d3SEliot Blennerhassett 1710*719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_aes_rx, HPI_AESEBURX_FORMAT, 1711*719f82d3SEliot Blennerhassett index, 0, &qr); 1712*719f82d3SEliot Blennerhassett *pw_format = (u16)qr; 1713*719f82d3SEliot Blennerhassett return err; 1714*719f82d3SEliot Blennerhassett } 1715*719f82d3SEliot Blennerhassett 1716*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_set_format(const struct hpi_hsubsys *ph_subsys, 1717*719f82d3SEliot Blennerhassett u32 h_control, u16 format) 1718*719f82d3SEliot Blennerhassett { 1719*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1720*719f82d3SEliot Blennerhassett HPI_AESEBURX_FORMAT, format, 0); 1721*719f82d3SEliot Blennerhassett } 1722*719f82d3SEliot Blennerhassett 1723*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_get_format(const struct hpi_hsubsys *ph_subsys, 1724*719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_format) 1725*719f82d3SEliot Blennerhassett { 1726*719f82d3SEliot Blennerhassett u16 err; 1727*719f82d3SEliot Blennerhassett u32 param; 1728*719f82d3SEliot Blennerhassett 1729*719f82d3SEliot Blennerhassett err = hpi_control_param1_get(ph_subsys, h_control, 1730*719f82d3SEliot Blennerhassett HPI_AESEBURX_FORMAT, ¶m); 1731*719f82d3SEliot Blennerhassett if (!err && pw_format) 1732*719f82d3SEliot Blennerhassett *pw_format = (u16)param; 1733*719f82d3SEliot Blennerhassett 1734*719f82d3SEliot Blennerhassett return err; 1735*719f82d3SEliot Blennerhassett } 1736*719f82d3SEliot Blennerhassett 1737*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_get_sample_rate(const struct hpi_hsubsys *ph_subsys, 1738*719f82d3SEliot Blennerhassett u32 h_control, u32 *psample_rate) 1739*719f82d3SEliot Blennerhassett { 1740*719f82d3SEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 1741*719f82d3SEliot Blennerhassett HPI_AESEBURX_SAMPLERATE, psample_rate); 1742*719f82d3SEliot Blennerhassett } 1743*719f82d3SEliot Blennerhassett 1744*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys, 1745*719f82d3SEliot Blennerhassett u32 h_control, u16 index, u16 *pw_data) 1746*719f82d3SEliot Blennerhassett { 1747*719f82d3SEliot Blennerhassett struct hpi_message hm; 1748*719f82d3SEliot Blennerhassett struct hpi_response hr; 1749*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1750*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1751*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1752*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_AESEBURX_USERDATA; 1753*719f82d3SEliot Blennerhassett hm.u.c.param1 = index; 1754*719f82d3SEliot Blennerhassett 1755*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1756*719f82d3SEliot Blennerhassett 1757*719f82d3SEliot Blennerhassett if (pw_data) 1758*719f82d3SEliot Blennerhassett *pw_data = (u16)hr.u.c.param2; 1759*719f82d3SEliot Blennerhassett return hr.error; 1760*719f82d3SEliot Blennerhassett } 1761*719f82d3SEliot Blennerhassett 1762*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys 1763*719f82d3SEliot Blennerhassett *ph_subsys, u32 h_control, u16 index, u16 *pw_data) 1764*719f82d3SEliot Blennerhassett { 1765*719f82d3SEliot Blennerhassett struct hpi_message hm; 1766*719f82d3SEliot Blennerhassett struct hpi_response hr; 1767*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1768*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1769*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1770*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_AESEBURX_CHANNELSTATUS; 1771*719f82d3SEliot Blennerhassett hm.u.c.param1 = index; 1772*719f82d3SEliot Blennerhassett 1773*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1774*719f82d3SEliot Blennerhassett 1775*719f82d3SEliot Blennerhassett if (pw_data) 1776*719f82d3SEliot Blennerhassett *pw_data = (u16)hr.u.c.param2; 1777*719f82d3SEliot Blennerhassett return hr.error; 1778*719f82d3SEliot Blennerhassett } 1779*719f82d3SEliot Blennerhassett 1780*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__receiver_get_error_status(const struct hpi_hsubsys *ph_subsys, 1781*719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_error_data) 1782*719f82d3SEliot Blennerhassett { 1783*719f82d3SEliot Blennerhassett u32 error_data = 0; 1784*719f82d3SEliot Blennerhassett u16 error = 0; 1785*719f82d3SEliot Blennerhassett 1786*719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, 1787*719f82d3SEliot Blennerhassett HPI_AESEBURX_ERRORSTATUS, &error_data); 1788*719f82d3SEliot Blennerhassett if (pw_error_data) 1789*719f82d3SEliot Blennerhassett *pw_error_data = (u16)error_data; 1790*719f82d3SEliot Blennerhassett return error; 1791*719f82d3SEliot Blennerhassett } 1792*719f82d3SEliot Blennerhassett 1793*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_set_sample_rate(const struct hpi_hsubsys 1794*719f82d3SEliot Blennerhassett *ph_subsys, u32 h_control, u32 sample_rate) 1795*719f82d3SEliot Blennerhassett { 1796*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1797*719f82d3SEliot Blennerhassett HPI_AESEBUTX_SAMPLERATE, sample_rate, 0); 1798*719f82d3SEliot Blennerhassett } 1799*719f82d3SEliot Blennerhassett 1800*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_set_user_data(const struct hpi_hsubsys *ph_subsys, 1801*719f82d3SEliot Blennerhassett u32 h_control, u16 index, u16 data) 1802*719f82d3SEliot Blennerhassett { 1803*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1804*719f82d3SEliot Blennerhassett HPI_AESEBUTX_USERDATA, index, data); 1805*719f82d3SEliot Blennerhassett } 1806*719f82d3SEliot Blennerhassett 1807*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_set_channel_status(const struct hpi_hsubsys 1808*719f82d3SEliot Blennerhassett *ph_subsys, u32 h_control, u16 index, u16 data) 1809*719f82d3SEliot Blennerhassett { 1810*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1811*719f82d3SEliot Blennerhassett HPI_AESEBUTX_CHANNELSTATUS, index, data); 1812*719f82d3SEliot Blennerhassett } 1813*719f82d3SEliot Blennerhassett 1814*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_get_channel_status(const struct hpi_hsubsys 1815*719f82d3SEliot Blennerhassett *ph_subsys, u32 h_control, u16 index, u16 *pw_data) 1816*719f82d3SEliot Blennerhassett { 1817*719f82d3SEliot Blennerhassett return HPI_ERROR_INVALID_OPERATION; 1818*719f82d3SEliot Blennerhassett } 1819*719f82d3SEliot Blennerhassett 1820*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_query_format(const struct hpi_hsubsys *ph_subsys, 1821*719f82d3SEliot Blennerhassett const u32 h_aes_tx, const u32 index, u16 *pw_format) 1822*719f82d3SEliot Blennerhassett { 1823*719f82d3SEliot Blennerhassett u32 qr; 1824*719f82d3SEliot Blennerhassett u16 err; 1825*719f82d3SEliot Blennerhassett 1826*719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_aes_tx, HPI_AESEBUTX_FORMAT, 1827*719f82d3SEliot Blennerhassett index, 0, &qr); 1828*719f82d3SEliot Blennerhassett *pw_format = (u16)qr; 1829*719f82d3SEliot Blennerhassett return err; 1830*719f82d3SEliot Blennerhassett } 1831*719f82d3SEliot Blennerhassett 1832*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_set_format(const struct hpi_hsubsys *ph_subsys, 1833*719f82d3SEliot Blennerhassett u32 h_control, u16 output_format) 1834*719f82d3SEliot Blennerhassett { 1835*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1836*719f82d3SEliot Blennerhassett HPI_AESEBUTX_FORMAT, output_format, 0); 1837*719f82d3SEliot Blennerhassett } 1838*719f82d3SEliot Blennerhassett 1839*719f82d3SEliot Blennerhassett u16 HPI_AESEBU__transmitter_get_format(const struct hpi_hsubsys *ph_subsys, 1840*719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_output_format) 1841*719f82d3SEliot Blennerhassett { 1842*719f82d3SEliot Blennerhassett u16 err; 1843*719f82d3SEliot Blennerhassett u32 param; 1844*719f82d3SEliot Blennerhassett 1845*719f82d3SEliot Blennerhassett err = hpi_control_param1_get(ph_subsys, h_control, 1846*719f82d3SEliot Blennerhassett HPI_AESEBUTX_FORMAT, ¶m); 1847*719f82d3SEliot Blennerhassett if (!err && pw_output_format) 1848*719f82d3SEliot Blennerhassett *pw_output_format = (u16)param; 1849*719f82d3SEliot Blennerhassett 1850*719f82d3SEliot Blennerhassett return err; 1851*719f82d3SEliot Blennerhassett } 1852*719f82d3SEliot Blennerhassett 1853*719f82d3SEliot Blennerhassett u16 hpi_bitstream_set_clock_edge(const struct hpi_hsubsys *ph_subsys, 1854*719f82d3SEliot Blennerhassett u32 h_control, u16 edge_type) 1855*719f82d3SEliot Blennerhassett { 1856*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1857*719f82d3SEliot Blennerhassett HPI_BITSTREAM_CLOCK_EDGE, edge_type, 0); 1858*719f82d3SEliot Blennerhassett } 1859*719f82d3SEliot Blennerhassett 1860*719f82d3SEliot Blennerhassett u16 hpi_bitstream_set_data_polarity(const struct hpi_hsubsys *ph_subsys, 1861*719f82d3SEliot Blennerhassett u32 h_control, u16 polarity) 1862*719f82d3SEliot Blennerhassett { 1863*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1864*719f82d3SEliot Blennerhassett HPI_BITSTREAM_DATA_POLARITY, polarity, 0); 1865*719f82d3SEliot Blennerhassett } 1866*719f82d3SEliot Blennerhassett 1867*719f82d3SEliot Blennerhassett u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys, 1868*719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_clk_activity, u16 *pw_data_activity) 1869*719f82d3SEliot Blennerhassett { 1870*719f82d3SEliot Blennerhassett struct hpi_message hm; 1871*719f82d3SEliot Blennerhassett struct hpi_response hr; 1872*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1873*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1874*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1875*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_BITSTREAM_ACTIVITY; 1876*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1877*719f82d3SEliot Blennerhassett if (pw_clk_activity) 1878*719f82d3SEliot Blennerhassett *pw_clk_activity = (u16)hr.u.c.param1; 1879*719f82d3SEliot Blennerhassett if (pw_data_activity) 1880*719f82d3SEliot Blennerhassett *pw_data_activity = (u16)hr.u.c.param2; 1881*719f82d3SEliot Blennerhassett return hr.error; 1882*719f82d3SEliot Blennerhassett } 1883*719f82d3SEliot Blennerhassett 1884*719f82d3SEliot Blennerhassett u16 hpi_channel_mode_query_mode(const struct hpi_hsubsys *ph_subsys, 1885*719f82d3SEliot Blennerhassett const u32 h_mode, const u32 index, u16 *pw_mode) 1886*719f82d3SEliot Blennerhassett { 1887*719f82d3SEliot Blennerhassett u32 qr; 1888*719f82d3SEliot Blennerhassett u16 err; 1889*719f82d3SEliot Blennerhassett 1890*719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_mode, HPI_CHANNEL_MODE_MODE, 1891*719f82d3SEliot Blennerhassett index, 0, &qr); 1892*719f82d3SEliot Blennerhassett *pw_mode = (u16)qr; 1893*719f82d3SEliot Blennerhassett return err; 1894*719f82d3SEliot Blennerhassett } 1895*719f82d3SEliot Blennerhassett 1896*719f82d3SEliot Blennerhassett u16 hpi_channel_mode_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1897*719f82d3SEliot Blennerhassett u16 mode) 1898*719f82d3SEliot Blennerhassett { 1899*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 1900*719f82d3SEliot Blennerhassett HPI_CHANNEL_MODE_MODE, mode, 0); 1901*719f82d3SEliot Blennerhassett } 1902*719f82d3SEliot Blennerhassett 1903*719f82d3SEliot Blennerhassett u16 hpi_channel_mode_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1904*719f82d3SEliot Blennerhassett u16 *mode) 1905*719f82d3SEliot Blennerhassett { 1906*719f82d3SEliot Blennerhassett u32 mode32 = 0; 1907*719f82d3SEliot Blennerhassett u16 error = hpi_control_param1_get(ph_subsys, h_control, 1908*719f82d3SEliot Blennerhassett HPI_CHANNEL_MODE_MODE, &mode32); 1909*719f82d3SEliot Blennerhassett if (mode) 1910*719f82d3SEliot Blennerhassett *mode = (u16)mode32; 1911*719f82d3SEliot Blennerhassett return error; 1912*719f82d3SEliot Blennerhassett } 1913*719f82d3SEliot Blennerhassett 1914*719f82d3SEliot Blennerhassett u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1915*719f82d3SEliot Blennerhassett u32 hmi_address, u32 byte_count, u8 *pb_data) 1916*719f82d3SEliot Blennerhassett { 1917*719f82d3SEliot Blennerhassett struct hpi_message hm; 1918*719f82d3SEliot Blennerhassett struct hpi_response hr; 1919*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1920*719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 1921*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1922*719f82d3SEliot Blennerhassett 1923*719f82d3SEliot Blennerhassett hm.u.cx.u.cobranet_data.byte_count = byte_count; 1924*719f82d3SEliot Blennerhassett hm.u.cx.u.cobranet_data.hmi_address = hmi_address; 1925*719f82d3SEliot Blennerhassett 1926*719f82d3SEliot Blennerhassett if (byte_count <= 8) { 1927*719f82d3SEliot Blennerhassett memcpy(hm.u.cx.u.cobranet_data.data, pb_data, byte_count); 1928*719f82d3SEliot Blennerhassett hm.u.cx.attribute = HPI_COBRANET_SET; 1929*719f82d3SEliot Blennerhassett } else { 1930*719f82d3SEliot Blennerhassett hm.u.cx.u.cobranet_bigdata.pb_data = pb_data; 1931*719f82d3SEliot Blennerhassett hm.u.cx.attribute = HPI_COBRANET_SET_DATA; 1932*719f82d3SEliot Blennerhassett } 1933*719f82d3SEliot Blennerhassett 1934*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1935*719f82d3SEliot Blennerhassett 1936*719f82d3SEliot Blennerhassett return hr.error; 1937*719f82d3SEliot Blennerhassett } 1938*719f82d3SEliot Blennerhassett 1939*719f82d3SEliot Blennerhassett u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1940*719f82d3SEliot Blennerhassett u32 hmi_address, u32 max_byte_count, u32 *pbyte_count, u8 *pb_data) 1941*719f82d3SEliot Blennerhassett { 1942*719f82d3SEliot Blennerhassett struct hpi_message hm; 1943*719f82d3SEliot Blennerhassett struct hpi_response hr; 1944*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1945*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1946*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1947*719f82d3SEliot Blennerhassett 1948*719f82d3SEliot Blennerhassett hm.u.cx.u.cobranet_data.byte_count = max_byte_count; 1949*719f82d3SEliot Blennerhassett hm.u.cx.u.cobranet_data.hmi_address = hmi_address; 1950*719f82d3SEliot Blennerhassett 1951*719f82d3SEliot Blennerhassett if (max_byte_count <= 8) { 1952*719f82d3SEliot Blennerhassett hm.u.cx.attribute = HPI_COBRANET_GET; 1953*719f82d3SEliot Blennerhassett } else { 1954*719f82d3SEliot Blennerhassett hm.u.cx.u.cobranet_bigdata.pb_data = pb_data; 1955*719f82d3SEliot Blennerhassett hm.u.cx.attribute = HPI_COBRANET_GET_DATA; 1956*719f82d3SEliot Blennerhassett } 1957*719f82d3SEliot Blennerhassett 1958*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1959*719f82d3SEliot Blennerhassett if (!hr.error && pb_data) { 1960*719f82d3SEliot Blennerhassett 1961*719f82d3SEliot Blennerhassett *pbyte_count = hr.u.cx.u.cobranet_data.byte_count; 1962*719f82d3SEliot Blennerhassett 1963*719f82d3SEliot Blennerhassett if (*pbyte_count < max_byte_count) 1964*719f82d3SEliot Blennerhassett max_byte_count = *pbyte_count; 1965*719f82d3SEliot Blennerhassett 1966*719f82d3SEliot Blennerhassett if (hm.u.cx.attribute == HPI_COBRANET_GET) { 1967*719f82d3SEliot Blennerhassett memcpy(pb_data, hr.u.cx.u.cobranet_data.data, 1968*719f82d3SEliot Blennerhassett max_byte_count); 1969*719f82d3SEliot Blennerhassett } else { 1970*719f82d3SEliot Blennerhassett 1971*719f82d3SEliot Blennerhassett } 1972*719f82d3SEliot Blennerhassett 1973*719f82d3SEliot Blennerhassett } 1974*719f82d3SEliot Blennerhassett return hr.error; 1975*719f82d3SEliot Blennerhassett } 1976*719f82d3SEliot Blennerhassett 1977*719f82d3SEliot Blennerhassett u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys, 1978*719f82d3SEliot Blennerhassett u32 h_control, u32 *pstatus, u32 *preadable_size, 1979*719f82d3SEliot Blennerhassett u32 *pwriteable_size) 1980*719f82d3SEliot Blennerhassett { 1981*719f82d3SEliot Blennerhassett struct hpi_message hm; 1982*719f82d3SEliot Blennerhassett struct hpi_response hr; 1983*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1984*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 1985*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1986*719f82d3SEliot Blennerhassett 1987*719f82d3SEliot Blennerhassett hm.u.cx.attribute = HPI_COBRANET_GET_STATUS; 1988*719f82d3SEliot Blennerhassett 1989*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 1990*719f82d3SEliot Blennerhassett if (!hr.error) { 1991*719f82d3SEliot Blennerhassett if (pstatus) 1992*719f82d3SEliot Blennerhassett *pstatus = hr.u.cx.u.cobranet_status.status; 1993*719f82d3SEliot Blennerhassett if (preadable_size) 1994*719f82d3SEliot Blennerhassett *preadable_size = 1995*719f82d3SEliot Blennerhassett hr.u.cx.u.cobranet_status.readable_size; 1996*719f82d3SEliot Blennerhassett if (pwriteable_size) 1997*719f82d3SEliot Blennerhassett *pwriteable_size = 1998*719f82d3SEliot Blennerhassett hr.u.cx.u.cobranet_status.writeable_size; 1999*719f82d3SEliot Blennerhassett } 2000*719f82d3SEliot Blennerhassett return hr.error; 2001*719f82d3SEliot Blennerhassett } 2002*719f82d3SEliot Blennerhassett 2003*719f82d3SEliot Blennerhassett u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys, 2004*719f82d3SEliot Blennerhassett u32 h_control, u32 *pi_paddress) 2005*719f82d3SEliot Blennerhassett { 2006*719f82d3SEliot Blennerhassett u32 byte_count; 2007*719f82d3SEliot Blennerhassett u32 iP; 2008*719f82d3SEliot Blennerhassett u16 error; 2009*719f82d3SEliot Blennerhassett error = hpi_cobranet_hmi_read(ph_subsys, h_control, 2010*719f82d3SEliot Blennerhassett HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count, 2011*719f82d3SEliot Blennerhassett (u8 *)&iP); 2012*719f82d3SEliot Blennerhassett 2013*719f82d3SEliot Blennerhassett *pi_paddress = 2014*719f82d3SEliot Blennerhassett ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP & 2015*719f82d3SEliot Blennerhassett 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8); 2016*719f82d3SEliot Blennerhassett 2017*719f82d3SEliot Blennerhassett if (error) 2018*719f82d3SEliot Blennerhassett *pi_paddress = 0; 2019*719f82d3SEliot Blennerhassett 2020*719f82d3SEliot Blennerhassett return error; 2021*719f82d3SEliot Blennerhassett 2022*719f82d3SEliot Blennerhassett } 2023*719f82d3SEliot Blennerhassett 2024*719f82d3SEliot Blennerhassett u16 hpi_cobranet_setI_paddress(const struct hpi_hsubsys *ph_subsys, 2025*719f82d3SEliot Blennerhassett u32 h_control, u32 i_paddress) 2026*719f82d3SEliot Blennerhassett { 2027*719f82d3SEliot Blennerhassett u32 iP; 2028*719f82d3SEliot Blennerhassett u16 error; 2029*719f82d3SEliot Blennerhassett 2030*719f82d3SEliot Blennerhassett iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) << 2031*719f82d3SEliot Blennerhassett 8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress & 2032*719f82d3SEliot Blennerhassett 0x000000ff) << 8); 2033*719f82d3SEliot Blennerhassett 2034*719f82d3SEliot Blennerhassett error = hpi_cobranet_hmi_write(ph_subsys, h_control, 2035*719f82d3SEliot Blennerhassett HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, (u8 *)&iP); 2036*719f82d3SEliot Blennerhassett 2037*719f82d3SEliot Blennerhassett return error; 2038*719f82d3SEliot Blennerhassett 2039*719f82d3SEliot Blennerhassett } 2040*719f82d3SEliot Blennerhassett 2041*719f82d3SEliot Blennerhassett u16 hpi_cobranet_get_staticI_paddress(const struct hpi_hsubsys *ph_subsys, 2042*719f82d3SEliot Blennerhassett u32 h_control, u32 *pi_paddress) 2043*719f82d3SEliot Blennerhassett { 2044*719f82d3SEliot Blennerhassett u32 byte_count; 2045*719f82d3SEliot Blennerhassett u32 iP; 2046*719f82d3SEliot Blennerhassett u16 error; 2047*719f82d3SEliot Blennerhassett error = hpi_cobranet_hmi_read(ph_subsys, h_control, 2048*719f82d3SEliot Blennerhassett HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count, 2049*719f82d3SEliot Blennerhassett (u8 *)&iP); 2050*719f82d3SEliot Blennerhassett 2051*719f82d3SEliot Blennerhassett *pi_paddress = 2052*719f82d3SEliot Blennerhassett ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP & 2053*719f82d3SEliot Blennerhassett 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8); 2054*719f82d3SEliot Blennerhassett 2055*719f82d3SEliot Blennerhassett if (error) 2056*719f82d3SEliot Blennerhassett *pi_paddress = 0; 2057*719f82d3SEliot Blennerhassett 2058*719f82d3SEliot Blennerhassett return error; 2059*719f82d3SEliot Blennerhassett 2060*719f82d3SEliot Blennerhassett } 2061*719f82d3SEliot Blennerhassett 2062*719f82d3SEliot Blennerhassett u16 hpi_cobranet_set_staticI_paddress(const struct hpi_hsubsys *ph_subsys, 2063*719f82d3SEliot Blennerhassett u32 h_control, u32 i_paddress) 2064*719f82d3SEliot Blennerhassett { 2065*719f82d3SEliot Blennerhassett u32 iP; 2066*719f82d3SEliot Blennerhassett u16 error; 2067*719f82d3SEliot Blennerhassett 2068*719f82d3SEliot Blennerhassett iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) << 2069*719f82d3SEliot Blennerhassett 8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress & 2070*719f82d3SEliot Blennerhassett 0x000000ff) << 8); 2071*719f82d3SEliot Blennerhassett 2072*719f82d3SEliot Blennerhassett error = hpi_cobranet_hmi_write(ph_subsys, h_control, 2073*719f82d3SEliot Blennerhassett HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, (u8 *)&iP); 2074*719f82d3SEliot Blennerhassett 2075*719f82d3SEliot Blennerhassett return error; 2076*719f82d3SEliot Blennerhassett 2077*719f82d3SEliot Blennerhassett } 2078*719f82d3SEliot Blennerhassett 2079*719f82d3SEliot Blennerhassett u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys, 2080*719f82d3SEliot Blennerhassett u32 h_control, u32 *pmAC_MS_bs, u32 *pmAC_LS_bs) 2081*719f82d3SEliot Blennerhassett { 2082*719f82d3SEliot Blennerhassett u32 byte_count; 2083*719f82d3SEliot Blennerhassett u16 error; 2084*719f82d3SEliot Blennerhassett u32 mAC; 2085*719f82d3SEliot Blennerhassett error = hpi_cobranet_hmi_read(ph_subsys, h_control, 2086*719f82d3SEliot Blennerhassett HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count, 2087*719f82d3SEliot Blennerhassett (u8 *)&mAC); 2088*719f82d3SEliot Blennerhassett *pmAC_MS_bs = 2089*719f82d3SEliot Blennerhassett ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC 2090*719f82d3SEliot Blennerhassett & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8); 2091*719f82d3SEliot Blennerhassett error += hpi_cobranet_hmi_read(ph_subsys, h_control, 2092*719f82d3SEliot Blennerhassett HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4, &byte_count, 2093*719f82d3SEliot Blennerhassett (u8 *)&mAC); 2094*719f82d3SEliot Blennerhassett *pmAC_LS_bs = 2095*719f82d3SEliot Blennerhassett ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC 2096*719f82d3SEliot Blennerhassett & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8); 2097*719f82d3SEliot Blennerhassett 2098*719f82d3SEliot Blennerhassett if (error) { 2099*719f82d3SEliot Blennerhassett *pmAC_MS_bs = 0; 2100*719f82d3SEliot Blennerhassett *pmAC_LS_bs = 0; 2101*719f82d3SEliot Blennerhassett } 2102*719f82d3SEliot Blennerhassett 2103*719f82d3SEliot Blennerhassett return error; 2104*719f82d3SEliot Blennerhassett } 2105*719f82d3SEliot Blennerhassett 2106*719f82d3SEliot Blennerhassett u16 hpi_compander_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2107*719f82d3SEliot Blennerhassett u16 attack, u16 decay, short ratio100, short threshold0_01dB, 2108*719f82d3SEliot Blennerhassett short makeup_gain0_01dB) 2109*719f82d3SEliot Blennerhassett { 2110*719f82d3SEliot Blennerhassett struct hpi_message hm; 2111*719f82d3SEliot Blennerhassett struct hpi_response hr; 2112*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2113*719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 2114*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2115*719f82d3SEliot Blennerhassett 2116*719f82d3SEliot Blennerhassett hm.u.c.param1 = attack + ((u32)ratio100 << 16); 2117*719f82d3SEliot Blennerhassett hm.u.c.param2 = (decay & 0xFFFFL); 2118*719f82d3SEliot Blennerhassett hm.u.c.an_log_value[0] = threshold0_01dB; 2119*719f82d3SEliot Blennerhassett hm.u.c.an_log_value[1] = makeup_gain0_01dB; 2120*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_COMPANDER_PARAMS; 2121*719f82d3SEliot Blennerhassett 2122*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2123*719f82d3SEliot Blennerhassett 2124*719f82d3SEliot Blennerhassett return hr.error; 2125*719f82d3SEliot Blennerhassett } 2126*719f82d3SEliot Blennerhassett 2127*719f82d3SEliot Blennerhassett u16 hpi_compander_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2128*719f82d3SEliot Blennerhassett u16 *pw_attack, u16 *pw_decay, short *pw_ratio100, 2129*719f82d3SEliot Blennerhassett short *pn_threshold0_01dB, short *pn_makeup_gain0_01dB) 2130*719f82d3SEliot Blennerhassett { 2131*719f82d3SEliot Blennerhassett struct hpi_message hm; 2132*719f82d3SEliot Blennerhassett struct hpi_response hr; 2133*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2134*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2135*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2136*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_COMPANDER_PARAMS; 2137*719f82d3SEliot Blennerhassett 2138*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2139*719f82d3SEliot Blennerhassett 2140*719f82d3SEliot Blennerhassett if (pw_attack) 2141*719f82d3SEliot Blennerhassett *pw_attack = (short)(hr.u.c.param1 & 0xFFFF); 2142*719f82d3SEliot Blennerhassett if (pw_decay) 2143*719f82d3SEliot Blennerhassett *pw_decay = (short)(hr.u.c.param2 & 0xFFFF); 2144*719f82d3SEliot Blennerhassett if (pw_ratio100) 2145*719f82d3SEliot Blennerhassett *pw_ratio100 = (short)(hr.u.c.param1 >> 16); 2146*719f82d3SEliot Blennerhassett 2147*719f82d3SEliot Blennerhassett if (pn_threshold0_01dB) 2148*719f82d3SEliot Blennerhassett *pn_threshold0_01dB = hr.u.c.an_log_value[0]; 2149*719f82d3SEliot Blennerhassett if (pn_makeup_gain0_01dB) 2150*719f82d3SEliot Blennerhassett *pn_makeup_gain0_01dB = hr.u.c.an_log_value[1]; 2151*719f82d3SEliot Blennerhassett 2152*719f82d3SEliot Blennerhassett return hr.error; 2153*719f82d3SEliot Blennerhassett } 2154*719f82d3SEliot Blennerhassett 2155*719f82d3SEliot Blennerhassett u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2156*719f82d3SEliot Blennerhassett short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB) 2157*719f82d3SEliot Blennerhassett { 2158*719f82d3SEliot Blennerhassett struct hpi_message hm; 2159*719f82d3SEliot Blennerhassett struct hpi_response hr; 2160*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2161*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2162*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2163*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_LEVEL_RANGE; 2164*719f82d3SEliot Blennerhassett 2165*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2166*719f82d3SEliot Blennerhassett if (hr.error) { 2167*719f82d3SEliot Blennerhassett hr.u.c.an_log_value[0] = 0; 2168*719f82d3SEliot Blennerhassett hr.u.c.an_log_value[1] = 0; 2169*719f82d3SEliot Blennerhassett hr.u.c.param1 = 0; 2170*719f82d3SEliot Blennerhassett } 2171*719f82d3SEliot Blennerhassett if (min_gain_01dB) 2172*719f82d3SEliot Blennerhassett *min_gain_01dB = hr.u.c.an_log_value[0]; 2173*719f82d3SEliot Blennerhassett if (max_gain_01dB) 2174*719f82d3SEliot Blennerhassett *max_gain_01dB = hr.u.c.an_log_value[1]; 2175*719f82d3SEliot Blennerhassett if (step_gain_01dB) 2176*719f82d3SEliot Blennerhassett *step_gain_01dB = (short)hr.u.c.param1; 2177*719f82d3SEliot Blennerhassett return hr.error; 2178*719f82d3SEliot Blennerhassett } 2179*719f82d3SEliot Blennerhassett 2180*719f82d3SEliot Blennerhassett u16 hpi_level_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2181*719f82d3SEliot Blennerhassett short an_gain0_01dB[HPI_MAX_CHANNELS] 2182*719f82d3SEliot Blennerhassett ) 2183*719f82d3SEliot Blennerhassett { 2184*719f82d3SEliot Blennerhassett struct hpi_message hm; 2185*719f82d3SEliot Blennerhassett struct hpi_response hr; 2186*719f82d3SEliot Blennerhassett 2187*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2188*719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 2189*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2190*719f82d3SEliot Blennerhassett memcpy(hm.u.c.an_log_value, an_gain0_01dB, 2191*719f82d3SEliot Blennerhassett sizeof(short) * HPI_MAX_CHANNELS); 2192*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_LEVEL_GAIN; 2193*719f82d3SEliot Blennerhassett 2194*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2195*719f82d3SEliot Blennerhassett 2196*719f82d3SEliot Blennerhassett return hr.error; 2197*719f82d3SEliot Blennerhassett } 2198*719f82d3SEliot Blennerhassett 2199*719f82d3SEliot Blennerhassett u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2200*719f82d3SEliot Blennerhassett short an_gain0_01dB[HPI_MAX_CHANNELS] 2201*719f82d3SEliot Blennerhassett ) 2202*719f82d3SEliot Blennerhassett { 2203*719f82d3SEliot Blennerhassett struct hpi_message hm; 2204*719f82d3SEliot Blennerhassett struct hpi_response hr; 2205*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2206*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2207*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2208*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_LEVEL_GAIN; 2209*719f82d3SEliot Blennerhassett 2210*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2211*719f82d3SEliot Blennerhassett 2212*719f82d3SEliot Blennerhassett memcpy(an_gain0_01dB, hr.u.c.an_log_value, 2213*719f82d3SEliot Blennerhassett sizeof(short) * HPI_MAX_CHANNELS); 2214*719f82d3SEliot Blennerhassett return hr.error; 2215*719f82d3SEliot Blennerhassett } 2216*719f82d3SEliot Blennerhassett 2217*719f82d3SEliot Blennerhassett u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys, 2218*719f82d3SEliot Blennerhassett const u32 h_meter, u32 *p_channels) 2219*719f82d3SEliot Blennerhassett { 2220*719f82d3SEliot Blennerhassett return hpi_control_query(ph_subsys, h_meter, HPI_METER_NUM_CHANNELS, 2221*719f82d3SEliot Blennerhassett 0, 0, p_channels); 2222*719f82d3SEliot Blennerhassett } 2223*719f82d3SEliot Blennerhassett 2224*719f82d3SEliot Blennerhassett u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2225*719f82d3SEliot Blennerhassett short an_peakdB[HPI_MAX_CHANNELS] 2226*719f82d3SEliot Blennerhassett ) 2227*719f82d3SEliot Blennerhassett { 2228*719f82d3SEliot Blennerhassett short i = 0; 2229*719f82d3SEliot Blennerhassett 2230*719f82d3SEliot Blennerhassett struct hpi_message hm; 2231*719f82d3SEliot Blennerhassett struct hpi_response hr; 2232*719f82d3SEliot Blennerhassett 2233*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2234*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2235*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2236*719f82d3SEliot Blennerhassett hm.obj_index = hm.obj_index; 2237*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_METER_PEAK; 2238*719f82d3SEliot Blennerhassett 2239*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2240*719f82d3SEliot Blennerhassett 2241*719f82d3SEliot Blennerhassett if (!hr.error) 2242*719f82d3SEliot Blennerhassett memcpy(an_peakdB, hr.u.c.an_log_value, 2243*719f82d3SEliot Blennerhassett sizeof(short) * HPI_MAX_CHANNELS); 2244*719f82d3SEliot Blennerhassett else 2245*719f82d3SEliot Blennerhassett for (i = 0; i < HPI_MAX_CHANNELS; i++) 2246*719f82d3SEliot Blennerhassett an_peakdB[i] = HPI_METER_MINIMUM; 2247*719f82d3SEliot Blennerhassett return hr.error; 2248*719f82d3SEliot Blennerhassett } 2249*719f82d3SEliot Blennerhassett 2250*719f82d3SEliot Blennerhassett u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2251*719f82d3SEliot Blennerhassett short an_rmsdB[HPI_MAX_CHANNELS] 2252*719f82d3SEliot Blennerhassett ) 2253*719f82d3SEliot Blennerhassett { 2254*719f82d3SEliot Blennerhassett short i = 0; 2255*719f82d3SEliot Blennerhassett 2256*719f82d3SEliot Blennerhassett struct hpi_message hm; 2257*719f82d3SEliot Blennerhassett struct hpi_response hr; 2258*719f82d3SEliot Blennerhassett 2259*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2260*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2261*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2262*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_METER_RMS; 2263*719f82d3SEliot Blennerhassett 2264*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2265*719f82d3SEliot Blennerhassett 2266*719f82d3SEliot Blennerhassett if (!hr.error) 2267*719f82d3SEliot Blennerhassett memcpy(an_rmsdB, hr.u.c.an_log_value, 2268*719f82d3SEliot Blennerhassett sizeof(short) * HPI_MAX_CHANNELS); 2269*719f82d3SEliot Blennerhassett else 2270*719f82d3SEliot Blennerhassett for (i = 0; i < HPI_MAX_CHANNELS; i++) 2271*719f82d3SEliot Blennerhassett an_rmsdB[i] = HPI_METER_MINIMUM; 2272*719f82d3SEliot Blennerhassett 2273*719f82d3SEliot Blennerhassett return hr.error; 2274*719f82d3SEliot Blennerhassett } 2275*719f82d3SEliot Blennerhassett 2276*719f82d3SEliot Blennerhassett u16 hpi_meter_set_rms_ballistics(const struct hpi_hsubsys *ph_subsys, 2277*719f82d3SEliot Blennerhassett u32 h_control, u16 attack, u16 decay) 2278*719f82d3SEliot Blennerhassett { 2279*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2280*719f82d3SEliot Blennerhassett HPI_METER_RMS_BALLISTICS, attack, decay); 2281*719f82d3SEliot Blennerhassett } 2282*719f82d3SEliot Blennerhassett 2283*719f82d3SEliot Blennerhassett u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys, 2284*719f82d3SEliot Blennerhassett u32 h_control, u16 *pn_attack, u16 *pn_decay) 2285*719f82d3SEliot Blennerhassett { 2286*719f82d3SEliot Blennerhassett u32 attack; 2287*719f82d3SEliot Blennerhassett u32 decay; 2288*719f82d3SEliot Blennerhassett u16 error; 2289*719f82d3SEliot Blennerhassett 2290*719f82d3SEliot Blennerhassett error = hpi_control_param2_get(ph_subsys, h_control, 2291*719f82d3SEliot Blennerhassett HPI_METER_RMS_BALLISTICS, &attack, &decay); 2292*719f82d3SEliot Blennerhassett 2293*719f82d3SEliot Blennerhassett if (pn_attack) 2294*719f82d3SEliot Blennerhassett *pn_attack = (unsigned short)attack; 2295*719f82d3SEliot Blennerhassett if (pn_decay) 2296*719f82d3SEliot Blennerhassett *pn_decay = (unsigned short)decay; 2297*719f82d3SEliot Blennerhassett 2298*719f82d3SEliot Blennerhassett return error; 2299*719f82d3SEliot Blennerhassett } 2300*719f82d3SEliot Blennerhassett 2301*719f82d3SEliot Blennerhassett u16 hpi_meter_set_peak_ballistics(const struct hpi_hsubsys *ph_subsys, 2302*719f82d3SEliot Blennerhassett u32 h_control, u16 attack, u16 decay) 2303*719f82d3SEliot Blennerhassett { 2304*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2305*719f82d3SEliot Blennerhassett HPI_METER_PEAK_BALLISTICS, attack, decay); 2306*719f82d3SEliot Blennerhassett } 2307*719f82d3SEliot Blennerhassett 2308*719f82d3SEliot Blennerhassett u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys, 2309*719f82d3SEliot Blennerhassett u32 h_control, u16 *pn_attack, u16 *pn_decay) 2310*719f82d3SEliot Blennerhassett { 2311*719f82d3SEliot Blennerhassett u32 attack; 2312*719f82d3SEliot Blennerhassett u32 decay; 2313*719f82d3SEliot Blennerhassett u16 error; 2314*719f82d3SEliot Blennerhassett 2315*719f82d3SEliot Blennerhassett error = hpi_control_param2_get(ph_subsys, h_control, 2316*719f82d3SEliot Blennerhassett HPI_METER_PEAK_BALLISTICS, &attack, &decay); 2317*719f82d3SEliot Blennerhassett 2318*719f82d3SEliot Blennerhassett if (pn_attack) 2319*719f82d3SEliot Blennerhassett *pn_attack = (short)attack; 2320*719f82d3SEliot Blennerhassett if (pn_decay) 2321*719f82d3SEliot Blennerhassett *pn_decay = (short)decay; 2322*719f82d3SEliot Blennerhassett 2323*719f82d3SEliot Blennerhassett return error; 2324*719f82d3SEliot Blennerhassett } 2325*719f82d3SEliot Blennerhassett 2326*719f82d3SEliot Blennerhassett u16 hpi_microphone_set_phantom_power(const struct hpi_hsubsys *ph_subsys, 2327*719f82d3SEliot Blennerhassett u32 h_control, u16 on_off) 2328*719f82d3SEliot Blennerhassett { 2329*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2330*719f82d3SEliot Blennerhassett HPI_MICROPHONE_PHANTOM_POWER, (u32)on_off, 0); 2331*719f82d3SEliot Blennerhassett } 2332*719f82d3SEliot Blennerhassett 2333*719f82d3SEliot Blennerhassett u16 hpi_microphone_get_phantom_power(const struct hpi_hsubsys *ph_subsys, 2334*719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_on_off) 2335*719f82d3SEliot Blennerhassett { 2336*719f82d3SEliot Blennerhassett u16 error = 0; 2337*719f82d3SEliot Blennerhassett u32 on_off = 0; 2338*719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, 2339*719f82d3SEliot Blennerhassett HPI_MICROPHONE_PHANTOM_POWER, &on_off); 2340*719f82d3SEliot Blennerhassett if (pw_on_off) 2341*719f82d3SEliot Blennerhassett *pw_on_off = (u16)on_off; 2342*719f82d3SEliot Blennerhassett return error; 2343*719f82d3SEliot Blennerhassett } 2344*719f82d3SEliot Blennerhassett 2345*719f82d3SEliot Blennerhassett u16 hpi_multiplexer_set_source(const struct hpi_hsubsys *ph_subsys, 2346*719f82d3SEliot Blennerhassett u32 h_control, u16 source_node_type, u16 source_node_index) 2347*719f82d3SEliot Blennerhassett { 2348*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2349*719f82d3SEliot Blennerhassett HPI_MULTIPLEXER_SOURCE, source_node_type, source_node_index); 2350*719f82d3SEliot Blennerhassett } 2351*719f82d3SEliot Blennerhassett 2352*719f82d3SEliot Blennerhassett u16 hpi_multiplexer_get_source(const struct hpi_hsubsys *ph_subsys, 2353*719f82d3SEliot Blennerhassett u32 h_control, u16 *source_node_type, u16 *source_node_index) 2354*719f82d3SEliot Blennerhassett { 2355*719f82d3SEliot Blennerhassett u32 node, index; 2356*719f82d3SEliot Blennerhassett u16 error = hpi_control_param2_get(ph_subsys, h_control, 2357*719f82d3SEliot Blennerhassett HPI_MULTIPLEXER_SOURCE, &node, 2358*719f82d3SEliot Blennerhassett &index); 2359*719f82d3SEliot Blennerhassett if (source_node_type) 2360*719f82d3SEliot Blennerhassett *source_node_type = (u16)node; 2361*719f82d3SEliot Blennerhassett if (source_node_index) 2362*719f82d3SEliot Blennerhassett *source_node_index = (u16)index; 2363*719f82d3SEliot Blennerhassett return error; 2364*719f82d3SEliot Blennerhassett } 2365*719f82d3SEliot Blennerhassett 2366*719f82d3SEliot Blennerhassett u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys, 2367*719f82d3SEliot Blennerhassett u32 h_control, u16 index, u16 *source_node_type, 2368*719f82d3SEliot Blennerhassett u16 *source_node_index) 2369*719f82d3SEliot Blennerhassett { 2370*719f82d3SEliot Blennerhassett struct hpi_message hm; 2371*719f82d3SEliot Blennerhassett struct hpi_response hr; 2372*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2373*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2374*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2375*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_MULTIPLEXER_QUERYSOURCE; 2376*719f82d3SEliot Blennerhassett hm.u.c.param1 = index; 2377*719f82d3SEliot Blennerhassett 2378*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2379*719f82d3SEliot Blennerhassett 2380*719f82d3SEliot Blennerhassett if (source_node_type) 2381*719f82d3SEliot Blennerhassett *source_node_type = (u16)hr.u.c.param1; 2382*719f82d3SEliot Blennerhassett if (source_node_index) 2383*719f82d3SEliot Blennerhassett *source_node_index = (u16)hr.u.c.param2; 2384*719f82d3SEliot Blennerhassett return hr.error; 2385*719f82d3SEliot Blennerhassett } 2386*719f82d3SEliot Blennerhassett 2387*719f82d3SEliot Blennerhassett u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys, 2388*719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_number_of_bands, u16 *pw_on_off) 2389*719f82d3SEliot Blennerhassett { 2390*719f82d3SEliot Blennerhassett u32 oB = 0; 2391*719f82d3SEliot Blennerhassett u32 oO = 0; 2392*719f82d3SEliot Blennerhassett u16 error = 0; 2393*719f82d3SEliot Blennerhassett 2394*719f82d3SEliot Blennerhassett error = hpi_control_param2_get(ph_subsys, h_control, 2395*719f82d3SEliot Blennerhassett HPI_EQUALIZER_NUM_FILTERS, &oO, &oB); 2396*719f82d3SEliot Blennerhassett if (pw_number_of_bands) 2397*719f82d3SEliot Blennerhassett *pw_number_of_bands = (u16)oB; 2398*719f82d3SEliot Blennerhassett if (pw_on_off) 2399*719f82d3SEliot Blennerhassett *pw_on_off = (u16)oO; 2400*719f82d3SEliot Blennerhassett return error; 2401*719f82d3SEliot Blennerhassett } 2402*719f82d3SEliot Blennerhassett 2403*719f82d3SEliot Blennerhassett u16 hpi_parametricEQ__set_state(const struct hpi_hsubsys *ph_subsys, 2404*719f82d3SEliot Blennerhassett u32 h_control, u16 on_off) 2405*719f82d3SEliot Blennerhassett { 2406*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2407*719f82d3SEliot Blennerhassett HPI_EQUALIZER_NUM_FILTERS, on_off, 0); 2408*719f82d3SEliot Blennerhassett } 2409*719f82d3SEliot Blennerhassett 2410*719f82d3SEliot Blennerhassett u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys, 2411*719f82d3SEliot Blennerhassett u32 h_control, u16 index, u16 *pn_type, u32 *pfrequency_hz, 2412*719f82d3SEliot Blennerhassett short *pnQ100, short *pn_gain0_01dB) 2413*719f82d3SEliot Blennerhassett { 2414*719f82d3SEliot Blennerhassett struct hpi_message hm; 2415*719f82d3SEliot Blennerhassett struct hpi_response hr; 2416*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2417*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2418*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2419*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_EQUALIZER_FILTER; 2420*719f82d3SEliot Blennerhassett hm.u.c.param2 = index; 2421*719f82d3SEliot Blennerhassett 2422*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2423*719f82d3SEliot Blennerhassett 2424*719f82d3SEliot Blennerhassett if (pfrequency_hz) 2425*719f82d3SEliot Blennerhassett *pfrequency_hz = hr.u.c.param1; 2426*719f82d3SEliot Blennerhassett if (pn_type) 2427*719f82d3SEliot Blennerhassett *pn_type = (u16)(hr.u.c.param2 >> 16); 2428*719f82d3SEliot Blennerhassett if (pnQ100) 2429*719f82d3SEliot Blennerhassett *pnQ100 = hr.u.c.an_log_value[1]; 2430*719f82d3SEliot Blennerhassett if (pn_gain0_01dB) 2431*719f82d3SEliot Blennerhassett *pn_gain0_01dB = hr.u.c.an_log_value[0]; 2432*719f82d3SEliot Blennerhassett 2433*719f82d3SEliot Blennerhassett return hr.error; 2434*719f82d3SEliot Blennerhassett } 2435*719f82d3SEliot Blennerhassett 2436*719f82d3SEliot Blennerhassett u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys, 2437*719f82d3SEliot Blennerhassett u32 h_control, u16 index, u16 type, u32 frequency_hz, short q100, 2438*719f82d3SEliot Blennerhassett short gain0_01dB) 2439*719f82d3SEliot Blennerhassett { 2440*719f82d3SEliot Blennerhassett struct hpi_message hm; 2441*719f82d3SEliot Blennerhassett struct hpi_response hr; 2442*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2443*719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 2444*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2445*719f82d3SEliot Blennerhassett 2446*719f82d3SEliot Blennerhassett hm.u.c.param1 = frequency_hz; 2447*719f82d3SEliot Blennerhassett hm.u.c.param2 = (index & 0xFFFFL) + ((u32)type << 16); 2448*719f82d3SEliot Blennerhassett hm.u.c.an_log_value[0] = gain0_01dB; 2449*719f82d3SEliot Blennerhassett hm.u.c.an_log_value[1] = q100; 2450*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_EQUALIZER_FILTER; 2451*719f82d3SEliot Blennerhassett 2452*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2453*719f82d3SEliot Blennerhassett 2454*719f82d3SEliot Blennerhassett return hr.error; 2455*719f82d3SEliot Blennerhassett } 2456*719f82d3SEliot Blennerhassett 2457*719f82d3SEliot Blennerhassett u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys, 2458*719f82d3SEliot Blennerhassett u32 h_control, u16 index, short coeffs[5] 2459*719f82d3SEliot Blennerhassett ) 2460*719f82d3SEliot Blennerhassett { 2461*719f82d3SEliot Blennerhassett struct hpi_message hm; 2462*719f82d3SEliot Blennerhassett struct hpi_response hr; 2463*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2464*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2465*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2466*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_EQUALIZER_COEFFICIENTS; 2467*719f82d3SEliot Blennerhassett hm.u.c.param2 = index; 2468*719f82d3SEliot Blennerhassett 2469*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2470*719f82d3SEliot Blennerhassett 2471*719f82d3SEliot Blennerhassett coeffs[0] = (short)hr.u.c.an_log_value[0]; 2472*719f82d3SEliot Blennerhassett coeffs[1] = (short)hr.u.c.an_log_value[1]; 2473*719f82d3SEliot Blennerhassett coeffs[2] = (short)hr.u.c.param1; 2474*719f82d3SEliot Blennerhassett coeffs[3] = (short)(hr.u.c.param1 >> 16); 2475*719f82d3SEliot Blennerhassett coeffs[4] = (short)hr.u.c.param2; 2476*719f82d3SEliot Blennerhassett 2477*719f82d3SEliot Blennerhassett return hr.error; 2478*719f82d3SEliot Blennerhassett } 2479*719f82d3SEliot Blennerhassett 2480*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_query_source(const struct hpi_hsubsys *ph_subsys, 2481*719f82d3SEliot Blennerhassett const u32 h_clock, const u32 index, u16 *pw_source) 2482*719f82d3SEliot Blennerhassett { 2483*719f82d3SEliot Blennerhassett u32 qr; 2484*719f82d3SEliot Blennerhassett u16 err; 2485*719f82d3SEliot Blennerhassett 2486*719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_clock, HPI_SAMPLECLOCK_SOURCE, 2487*719f82d3SEliot Blennerhassett index, 0, &qr); 2488*719f82d3SEliot Blennerhassett *pw_source = (u16)qr; 2489*719f82d3SEliot Blennerhassett return err; 2490*719f82d3SEliot Blennerhassett } 2491*719f82d3SEliot Blennerhassett 2492*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_set_source(const struct hpi_hsubsys *ph_subsys, 2493*719f82d3SEliot Blennerhassett u32 h_control, u16 source) 2494*719f82d3SEliot Blennerhassett { 2495*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2496*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_SOURCE, source, 0); 2497*719f82d3SEliot Blennerhassett } 2498*719f82d3SEliot Blennerhassett 2499*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_get_source(const struct hpi_hsubsys *ph_subsys, 2500*719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_source) 2501*719f82d3SEliot Blennerhassett { 2502*719f82d3SEliot Blennerhassett u16 error = 0; 2503*719f82d3SEliot Blennerhassett u32 source = 0; 2504*719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, 2505*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_SOURCE, &source); 2506*719f82d3SEliot Blennerhassett if (!error) 2507*719f82d3SEliot Blennerhassett if (pw_source) 2508*719f82d3SEliot Blennerhassett *pw_source = (u16)source; 2509*719f82d3SEliot Blennerhassett return error; 2510*719f82d3SEliot Blennerhassett } 2511*719f82d3SEliot Blennerhassett 2512*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_query_source_index(const struct hpi_hsubsys *ph_subsys, 2513*719f82d3SEliot Blennerhassett const u32 h_clock, const u32 index, const u32 source, 2514*719f82d3SEliot Blennerhassett u16 *pw_source_index) 2515*719f82d3SEliot Blennerhassett { 2516*719f82d3SEliot Blennerhassett u32 qr; 2517*719f82d3SEliot Blennerhassett u16 err; 2518*719f82d3SEliot Blennerhassett 2519*719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_clock, 2520*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_SOURCE_INDEX, index, source, &qr); 2521*719f82d3SEliot Blennerhassett *pw_source_index = (u16)qr; 2522*719f82d3SEliot Blennerhassett return err; 2523*719f82d3SEliot Blennerhassett } 2524*719f82d3SEliot Blennerhassett 2525*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_set_source_index(const struct hpi_hsubsys *ph_subsys, 2526*719f82d3SEliot Blennerhassett u32 h_control, u16 source_index) 2527*719f82d3SEliot Blennerhassett { 2528*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2529*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_SOURCE_INDEX, source_index, 0); 2530*719f82d3SEliot Blennerhassett } 2531*719f82d3SEliot Blennerhassett 2532*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_get_source_index(const struct hpi_hsubsys *ph_subsys, 2533*719f82d3SEliot Blennerhassett u32 h_control, u16 *pw_source_index) 2534*719f82d3SEliot Blennerhassett { 2535*719f82d3SEliot Blennerhassett u16 error = 0; 2536*719f82d3SEliot Blennerhassett u32 source_index = 0; 2537*719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, 2538*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_SOURCE_INDEX, &source_index); 2539*719f82d3SEliot Blennerhassett if (!error) 2540*719f82d3SEliot Blennerhassett if (pw_source_index) 2541*719f82d3SEliot Blennerhassett *pw_source_index = (u16)source_index; 2542*719f82d3SEliot Blennerhassett return error; 2543*719f82d3SEliot Blennerhassett } 2544*719f82d3SEliot Blennerhassett 2545*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_query_local_rate(const struct hpi_hsubsys *ph_subsys, 2546*719f82d3SEliot Blennerhassett const u32 h_clock, const u32 index, u32 *prate) 2547*719f82d3SEliot Blennerhassett { 2548*719f82d3SEliot Blennerhassett u16 err; 2549*719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_clock, 2550*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, index, 0, prate); 2551*719f82d3SEliot Blennerhassett 2552*719f82d3SEliot Blennerhassett return err; 2553*719f82d3SEliot Blennerhassett } 2554*719f82d3SEliot Blennerhassett 2555*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_set_local_rate(const struct hpi_hsubsys *ph_subsys, 2556*719f82d3SEliot Blennerhassett u32 h_control, u32 sample_rate) 2557*719f82d3SEliot Blennerhassett { 2558*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2559*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, sample_rate, 0); 2560*719f82d3SEliot Blennerhassett } 2561*719f82d3SEliot Blennerhassett 2562*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_get_local_rate(const struct hpi_hsubsys *ph_subsys, 2563*719f82d3SEliot Blennerhassett u32 h_control, u32 *psample_rate) 2564*719f82d3SEliot Blennerhassett { 2565*719f82d3SEliot Blennerhassett u16 error = 0; 2566*719f82d3SEliot Blennerhassett u32 sample_rate = 0; 2567*719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, 2568*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate); 2569*719f82d3SEliot Blennerhassett if (!error) 2570*719f82d3SEliot Blennerhassett if (psample_rate) 2571*719f82d3SEliot Blennerhassett *psample_rate = sample_rate; 2572*719f82d3SEliot Blennerhassett return error; 2573*719f82d3SEliot Blennerhassett } 2574*719f82d3SEliot Blennerhassett 2575*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_get_sample_rate(const struct hpi_hsubsys *ph_subsys, 2576*719f82d3SEliot Blennerhassett u32 h_control, u32 *psample_rate) 2577*719f82d3SEliot Blennerhassett { 2578*719f82d3SEliot Blennerhassett u16 error = 0; 2579*719f82d3SEliot Blennerhassett u32 sample_rate = 0; 2580*719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, 2581*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_SAMPLERATE, &sample_rate); 2582*719f82d3SEliot Blennerhassett if (!error) 2583*719f82d3SEliot Blennerhassett if (psample_rate) 2584*719f82d3SEliot Blennerhassett *psample_rate = sample_rate; 2585*719f82d3SEliot Blennerhassett return error; 2586*719f82d3SEliot Blennerhassett } 2587*719f82d3SEliot Blennerhassett 2588*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_set_auto(const struct hpi_hsubsys *ph_subsys, 2589*719f82d3SEliot Blennerhassett u32 h_control, u32 enable) 2590*719f82d3SEliot Blennerhassett { 2591*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2592*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_AUTO, enable, 0); 2593*719f82d3SEliot Blennerhassett } 2594*719f82d3SEliot Blennerhassett 2595*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_get_auto(const struct hpi_hsubsys *ph_subsys, 2596*719f82d3SEliot Blennerhassett u32 h_control, u32 *penable) 2597*719f82d3SEliot Blennerhassett { 2598*719f82d3SEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2599*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_AUTO, penable); 2600*719f82d3SEliot Blennerhassett } 2601*719f82d3SEliot Blennerhassett 2602*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_set_local_rate_lock(const struct hpi_hsubsys *ph_subsys, 2603*719f82d3SEliot Blennerhassett u32 h_control, u32 lock) 2604*719f82d3SEliot Blennerhassett { 2605*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2606*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_LOCAL_LOCK, lock, 0); 2607*719f82d3SEliot Blennerhassett } 2608*719f82d3SEliot Blennerhassett 2609*719f82d3SEliot Blennerhassett u16 hpi_sample_clock_get_local_rate_lock(const struct hpi_hsubsys *ph_subsys, 2610*719f82d3SEliot Blennerhassett u32 h_control, u32 *plock) 2611*719f82d3SEliot Blennerhassett { 2612*719f82d3SEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2613*719f82d3SEliot Blennerhassett HPI_SAMPLECLOCK_LOCAL_LOCK, plock); 2614*719f82d3SEliot Blennerhassett } 2615*719f82d3SEliot Blennerhassett 2616*719f82d3SEliot Blennerhassett u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys, 2617*719f82d3SEliot Blennerhassett u32 h_control, u32 index, u32 *frequency) 2618*719f82d3SEliot Blennerhassett { 2619*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2620*719f82d3SEliot Blennerhassett HPI_TONEDETECTOR_FREQUENCY, index, 0, frequency, NULL); 2621*719f82d3SEliot Blennerhassett } 2622*719f82d3SEliot Blennerhassett 2623*719f82d3SEliot Blennerhassett u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys, 2624*719f82d3SEliot Blennerhassett u32 h_control, u32 *state) 2625*719f82d3SEliot Blennerhassett { 2626*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2627*719f82d3SEliot Blennerhassett HPI_TONEDETECTOR_STATE, 0, 0, (u32 *)state, NULL); 2628*719f82d3SEliot Blennerhassett } 2629*719f82d3SEliot Blennerhassett 2630*719f82d3SEliot Blennerhassett u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys, 2631*719f82d3SEliot Blennerhassett u32 h_control, u32 enable) 2632*719f82d3SEliot Blennerhassett { 2633*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2634*719f82d3SEliot Blennerhassett (u32)enable, 0); 2635*719f82d3SEliot Blennerhassett } 2636*719f82d3SEliot Blennerhassett 2637*719f82d3SEliot Blennerhassett u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 2638*719f82d3SEliot Blennerhassett u32 h_control, u32 *enable) 2639*719f82d3SEliot Blennerhassett { 2640*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2641*719f82d3SEliot Blennerhassett 0, 0, (u32 *)enable, NULL); 2642*719f82d3SEliot Blennerhassett } 2643*719f82d3SEliot Blennerhassett 2644*719f82d3SEliot Blennerhassett u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, 2645*719f82d3SEliot Blennerhassett u32 h_control, u32 event_enable) 2646*719f82d3SEliot Blennerhassett { 2647*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2648*719f82d3SEliot Blennerhassett HPI_GENERIC_EVENT_ENABLE, (u32)event_enable, 0); 2649*719f82d3SEliot Blennerhassett } 2650*719f82d3SEliot Blennerhassett 2651*719f82d3SEliot Blennerhassett u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, 2652*719f82d3SEliot Blennerhassett u32 h_control, u32 *event_enable) 2653*719f82d3SEliot Blennerhassett { 2654*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2655*719f82d3SEliot Blennerhassett HPI_GENERIC_EVENT_ENABLE, 0, 0, (u32 *)event_enable, NULL); 2656*719f82d3SEliot Blennerhassett } 2657*719f82d3SEliot Blennerhassett 2658*719f82d3SEliot Blennerhassett u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, 2659*719f82d3SEliot Blennerhassett u32 h_control, int threshold) 2660*719f82d3SEliot Blennerhassett { 2661*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2662*719f82d3SEliot Blennerhassett HPI_TONEDETECTOR_THRESHOLD, (u32)threshold, 0); 2663*719f82d3SEliot Blennerhassett } 2664*719f82d3SEliot Blennerhassett 2665*719f82d3SEliot Blennerhassett u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, 2666*719f82d3SEliot Blennerhassett u32 h_control, int *threshold) 2667*719f82d3SEliot Blennerhassett { 2668*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2669*719f82d3SEliot Blennerhassett HPI_TONEDETECTOR_THRESHOLD, 0, 0, (u32 *)threshold, NULL); 2670*719f82d3SEliot Blennerhassett } 2671*719f82d3SEliot Blennerhassett 2672*719f82d3SEliot Blennerhassett u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys, 2673*719f82d3SEliot Blennerhassett u32 h_control, u32 *state) 2674*719f82d3SEliot Blennerhassett { 2675*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2676*719f82d3SEliot Blennerhassett HPI_SILENCEDETECTOR_STATE, 0, 0, (u32 *)state, NULL); 2677*719f82d3SEliot Blennerhassett } 2678*719f82d3SEliot Blennerhassett 2679*719f82d3SEliot Blennerhassett u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys, 2680*719f82d3SEliot Blennerhassett u32 h_control, u32 enable) 2681*719f82d3SEliot Blennerhassett { 2682*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2683*719f82d3SEliot Blennerhassett (u32)enable, 0); 2684*719f82d3SEliot Blennerhassett } 2685*719f82d3SEliot Blennerhassett 2686*719f82d3SEliot Blennerhassett u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 2687*719f82d3SEliot Blennerhassett u32 h_control, u32 *enable) 2688*719f82d3SEliot Blennerhassett { 2689*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2690*719f82d3SEliot Blennerhassett 0, 0, (u32 *)enable, NULL); 2691*719f82d3SEliot Blennerhassett } 2692*719f82d3SEliot Blennerhassett 2693*719f82d3SEliot Blennerhassett u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, 2694*719f82d3SEliot Blennerhassett u32 h_control, u32 event_enable) 2695*719f82d3SEliot Blennerhassett { 2696*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2697*719f82d3SEliot Blennerhassett HPI_GENERIC_EVENT_ENABLE, (u32)event_enable, 0); 2698*719f82d3SEliot Blennerhassett } 2699*719f82d3SEliot Blennerhassett 2700*719f82d3SEliot Blennerhassett u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, 2701*719f82d3SEliot Blennerhassett u32 h_control, u32 *event_enable) 2702*719f82d3SEliot Blennerhassett { 2703*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2704*719f82d3SEliot Blennerhassett HPI_GENERIC_EVENT_ENABLE, 0, 0, (u32 *)event_enable, NULL); 2705*719f82d3SEliot Blennerhassett } 2706*719f82d3SEliot Blennerhassett 2707*719f82d3SEliot Blennerhassett u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys, 2708*719f82d3SEliot Blennerhassett u32 h_control, u32 delay) 2709*719f82d3SEliot Blennerhassett { 2710*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2711*719f82d3SEliot Blennerhassett HPI_SILENCEDETECTOR_DELAY, (u32)delay, 0); 2712*719f82d3SEliot Blennerhassett } 2713*719f82d3SEliot Blennerhassett 2714*719f82d3SEliot Blennerhassett u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys, 2715*719f82d3SEliot Blennerhassett u32 h_control, u32 *delay) 2716*719f82d3SEliot Blennerhassett { 2717*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2718*719f82d3SEliot Blennerhassett HPI_SILENCEDETECTOR_DELAY, 0, 0, (u32 *)delay, NULL); 2719*719f82d3SEliot Blennerhassett } 2720*719f82d3SEliot Blennerhassett 2721*719f82d3SEliot Blennerhassett u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, 2722*719f82d3SEliot Blennerhassett u32 h_control, int threshold) 2723*719f82d3SEliot Blennerhassett { 2724*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2725*719f82d3SEliot Blennerhassett HPI_SILENCEDETECTOR_THRESHOLD, (u32)threshold, 0); 2726*719f82d3SEliot Blennerhassett } 2727*719f82d3SEliot Blennerhassett 2728*719f82d3SEliot Blennerhassett u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, 2729*719f82d3SEliot Blennerhassett u32 h_control, int *threshold) 2730*719f82d3SEliot Blennerhassett { 2731*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2732*719f82d3SEliot Blennerhassett HPI_SILENCEDETECTOR_THRESHOLD, 0, 0, (u32 *)threshold, NULL); 2733*719f82d3SEliot Blennerhassett } 2734*719f82d3SEliot Blennerhassett 2735*719f82d3SEliot Blennerhassett u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys, 2736*719f82d3SEliot Blennerhassett const u32 h_tuner, const u32 index, u16 *pw_band) 2737*719f82d3SEliot Blennerhassett { 2738*719f82d3SEliot Blennerhassett u32 qr; 2739*719f82d3SEliot Blennerhassett u16 err; 2740*719f82d3SEliot Blennerhassett 2741*719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0, 2742*719f82d3SEliot Blennerhassett &qr); 2743*719f82d3SEliot Blennerhassett *pw_band = (u16)qr; 2744*719f82d3SEliot Blennerhassett return err; 2745*719f82d3SEliot Blennerhassett } 2746*719f82d3SEliot Blennerhassett 2747*719f82d3SEliot Blennerhassett u16 hpi_tuner_set_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2748*719f82d3SEliot Blennerhassett u16 band) 2749*719f82d3SEliot Blennerhassett { 2750*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_BAND, 2751*719f82d3SEliot Blennerhassett band, 0); 2752*719f82d3SEliot Blennerhassett } 2753*719f82d3SEliot Blennerhassett 2754*719f82d3SEliot Blennerhassett u16 hpi_tuner_get_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2755*719f82d3SEliot Blennerhassett u16 *pw_band) 2756*719f82d3SEliot Blennerhassett { 2757*719f82d3SEliot Blennerhassett u32 band = 0; 2758*719f82d3SEliot Blennerhassett u16 error = 0; 2759*719f82d3SEliot Blennerhassett 2760*719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_BAND, 2761*719f82d3SEliot Blennerhassett &band); 2762*719f82d3SEliot Blennerhassett if (pw_band) 2763*719f82d3SEliot Blennerhassett *pw_band = (u16)band; 2764*719f82d3SEliot Blennerhassett return error; 2765*719f82d3SEliot Blennerhassett } 2766*719f82d3SEliot Blennerhassett 2767*719f82d3SEliot Blennerhassett u16 hpi_tuner_query_frequency(const struct hpi_hsubsys *ph_subsys, 2768*719f82d3SEliot Blennerhassett const u32 h_tuner, const u32 index, const u16 band, u32 *pfreq) 2769*719f82d3SEliot Blennerhassett { 2770*719f82d3SEliot Blennerhassett return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_FREQ, index, 2771*719f82d3SEliot Blennerhassett band, pfreq); 2772*719f82d3SEliot Blennerhassett } 2773*719f82d3SEliot Blennerhassett 2774*719f82d3SEliot Blennerhassett u16 hpi_tuner_set_frequency(const struct hpi_hsubsys *ph_subsys, 2775*719f82d3SEliot Blennerhassett u32 h_control, u32 freq_ink_hz) 2776*719f82d3SEliot Blennerhassett { 2777*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_FREQ, 2778*719f82d3SEliot Blennerhassett freq_ink_hz, 0); 2779*719f82d3SEliot Blennerhassett } 2780*719f82d3SEliot Blennerhassett 2781*719f82d3SEliot Blennerhassett u16 hpi_tuner_get_frequency(const struct hpi_hsubsys *ph_subsys, 2782*719f82d3SEliot Blennerhassett u32 h_control, u32 *pw_freq_ink_hz) 2783*719f82d3SEliot Blennerhassett { 2784*719f82d3SEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_FREQ, 2785*719f82d3SEliot Blennerhassett pw_freq_ink_hz); 2786*719f82d3SEliot Blennerhassett } 2787*719f82d3SEliot Blennerhassett 2788*719f82d3SEliot Blennerhassett u16 hpi_tuner_query_gain(const struct hpi_hsubsys *ph_subsys, 2789*719f82d3SEliot Blennerhassett const u32 h_tuner, const u32 index, u16 *pw_gain) 2790*719f82d3SEliot Blennerhassett { 2791*719f82d3SEliot Blennerhassett u32 qr; 2792*719f82d3SEliot Blennerhassett u16 err; 2793*719f82d3SEliot Blennerhassett 2794*719f82d3SEliot Blennerhassett err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0, 2795*719f82d3SEliot Blennerhassett &qr); 2796*719f82d3SEliot Blennerhassett *pw_gain = (u16)qr; 2797*719f82d3SEliot Blennerhassett return err; 2798*719f82d3SEliot Blennerhassett } 2799*719f82d3SEliot Blennerhassett 2800*719f82d3SEliot Blennerhassett u16 hpi_tuner_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2801*719f82d3SEliot Blennerhassett short gain) 2802*719f82d3SEliot Blennerhassett { 2803*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_GAIN, 2804*719f82d3SEliot Blennerhassett gain, 0); 2805*719f82d3SEliot Blennerhassett } 2806*719f82d3SEliot Blennerhassett 2807*719f82d3SEliot Blennerhassett u16 hpi_tuner_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2808*719f82d3SEliot Blennerhassett short *pn_gain) 2809*719f82d3SEliot Blennerhassett { 2810*719f82d3SEliot Blennerhassett u32 gain = 0; 2811*719f82d3SEliot Blennerhassett u16 error = 0; 2812*719f82d3SEliot Blennerhassett 2813*719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_GAIN, 2814*719f82d3SEliot Blennerhassett &gain); 2815*719f82d3SEliot Blennerhassett if (pn_gain) 2816*719f82d3SEliot Blennerhassett *pn_gain = (u16)gain; 2817*719f82d3SEliot Blennerhassett return error; 2818*719f82d3SEliot Blennerhassett } 2819*719f82d3SEliot Blennerhassett 2820*719f82d3SEliot Blennerhassett u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2821*719f82d3SEliot Blennerhassett short *pw_level) 2822*719f82d3SEliot Blennerhassett { 2823*719f82d3SEliot Blennerhassett struct hpi_message hm; 2824*719f82d3SEliot Blennerhassett struct hpi_response hr; 2825*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2826*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2827*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2828*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_TUNER_LEVEL; 2829*719f82d3SEliot Blennerhassett hm.u.c.param1 = HPI_TUNER_LEVEL_AVERAGE; 2830*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2831*719f82d3SEliot Blennerhassett if (pw_level) 2832*719f82d3SEliot Blennerhassett *pw_level = (short)hr.u.c.param1; 2833*719f82d3SEliot Blennerhassett return hr.error; 2834*719f82d3SEliot Blennerhassett } 2835*719f82d3SEliot Blennerhassett 2836*719f82d3SEliot Blennerhassett u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys, 2837*719f82d3SEliot Blennerhassett u32 h_control, short *pw_level) 2838*719f82d3SEliot Blennerhassett { 2839*719f82d3SEliot Blennerhassett struct hpi_message hm; 2840*719f82d3SEliot Blennerhassett struct hpi_response hr; 2841*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2842*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2843*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2844*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_TUNER_LEVEL; 2845*719f82d3SEliot Blennerhassett hm.u.c.param1 = HPI_TUNER_LEVEL_RAW; 2846*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2847*719f82d3SEliot Blennerhassett if (pw_level) 2848*719f82d3SEliot Blennerhassett *pw_level = (short)hr.u.c.param1; 2849*719f82d3SEliot Blennerhassett return hr.error; 2850*719f82d3SEliot Blennerhassett } 2851*719f82d3SEliot Blennerhassett 2852*719f82d3SEliot Blennerhassett u16 hpi_tuner_query_deemphasis(const struct hpi_hsubsys *ph_subsys, 2853*719f82d3SEliot Blennerhassett const u32 h_tuner, const u32 index, const u16 band, u32 *pdeemphasis) 2854*719f82d3SEliot Blennerhassett { 2855*719f82d3SEliot Blennerhassett return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_DEEMPHASIS, 2856*719f82d3SEliot Blennerhassett index, band, pdeemphasis); 2857*719f82d3SEliot Blennerhassett } 2858*719f82d3SEliot Blennerhassett 2859*719f82d3SEliot Blennerhassett u16 hpi_tuner_set_deemphasis(const struct hpi_hsubsys *ph_subsys, 2860*719f82d3SEliot Blennerhassett u32 h_control, u32 deemphasis) 2861*719f82d3SEliot Blennerhassett { 2862*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, 2863*719f82d3SEliot Blennerhassett HPI_TUNER_DEEMPHASIS, deemphasis, 0); 2864*719f82d3SEliot Blennerhassett } 2865*719f82d3SEliot Blennerhassett 2866*719f82d3SEliot Blennerhassett u16 hpi_tuner_get_deemphasis(const struct hpi_hsubsys *ph_subsys, 2867*719f82d3SEliot Blennerhassett u32 h_control, u32 *pdeemphasis) 2868*719f82d3SEliot Blennerhassett { 2869*719f82d3SEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, 2870*719f82d3SEliot Blennerhassett HPI_TUNER_DEEMPHASIS, pdeemphasis); 2871*719f82d3SEliot Blennerhassett } 2872*719f82d3SEliot Blennerhassett 2873*719f82d3SEliot Blennerhassett u16 hpi_tuner_query_program(const struct hpi_hsubsys *ph_subsys, 2874*719f82d3SEliot Blennerhassett const u32 h_tuner, u32 *pbitmap_program) 2875*719f82d3SEliot Blennerhassett { 2876*719f82d3SEliot Blennerhassett return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_PROGRAM, 0, 0, 2877*719f82d3SEliot Blennerhassett pbitmap_program); 2878*719f82d3SEliot Blennerhassett } 2879*719f82d3SEliot Blennerhassett 2880*719f82d3SEliot Blennerhassett u16 hpi_tuner_set_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2881*719f82d3SEliot Blennerhassett u32 program) 2882*719f82d3SEliot Blennerhassett { 2883*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_PROGRAM, 2884*719f82d3SEliot Blennerhassett program, 0); 2885*719f82d3SEliot Blennerhassett } 2886*719f82d3SEliot Blennerhassett 2887*719f82d3SEliot Blennerhassett u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2888*719f82d3SEliot Blennerhassett u32 *pprogram) 2889*719f82d3SEliot Blennerhassett { 2890*719f82d3SEliot Blennerhassett return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_PROGRAM, 2891*719f82d3SEliot Blennerhassett pprogram); 2892*719f82d3SEliot Blennerhassett } 2893*719f82d3SEliot Blennerhassett 2894*719f82d3SEliot Blennerhassett u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys, 2895*719f82d3SEliot Blennerhassett u32 h_control, char *psz_dsp_version, const u32 string_size) 2896*719f82d3SEliot Blennerhassett { 2897*719f82d3SEliot Blennerhassett return hpi_control_get_string(ph_subsys, h_control, 2898*719f82d3SEliot Blennerhassett HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size); 2899*719f82d3SEliot Blennerhassett } 2900*719f82d3SEliot Blennerhassett 2901*719f82d3SEliot Blennerhassett u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys, 2902*719f82d3SEliot Blennerhassett u32 h_control, char *psz_sdk_version, const u32 string_size) 2903*719f82d3SEliot Blennerhassett { 2904*719f82d3SEliot Blennerhassett return hpi_control_get_string(ph_subsys, h_control, 2905*719f82d3SEliot Blennerhassett HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size); 2906*719f82d3SEliot Blennerhassett } 2907*719f82d3SEliot Blennerhassett 2908*719f82d3SEliot Blennerhassett u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2909*719f82d3SEliot Blennerhassett u16 *pw_status_mask, u16 *pw_status) 2910*719f82d3SEliot Blennerhassett { 2911*719f82d3SEliot Blennerhassett u32 status = 0; 2912*719f82d3SEliot Blennerhassett u16 error = 0; 2913*719f82d3SEliot Blennerhassett 2914*719f82d3SEliot Blennerhassett error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_STATUS, 2915*719f82d3SEliot Blennerhassett &status); 2916*719f82d3SEliot Blennerhassett if (pw_status) { 2917*719f82d3SEliot Blennerhassett if (!error) { 2918*719f82d3SEliot Blennerhassett *pw_status_mask = (u16)(status >> 16); 2919*719f82d3SEliot Blennerhassett *pw_status = (u16)(status & 0xFFFF); 2920*719f82d3SEliot Blennerhassett } else { 2921*719f82d3SEliot Blennerhassett *pw_status_mask = 0; 2922*719f82d3SEliot Blennerhassett *pw_status = 0; 2923*719f82d3SEliot Blennerhassett } 2924*719f82d3SEliot Blennerhassett } 2925*719f82d3SEliot Blennerhassett return error; 2926*719f82d3SEliot Blennerhassett } 2927*719f82d3SEliot Blennerhassett 2928*719f82d3SEliot Blennerhassett u16 hpi_tuner_set_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2929*719f82d3SEliot Blennerhassett u32 mode, u32 value) 2930*719f82d3SEliot Blennerhassett { 2931*719f82d3SEliot Blennerhassett return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_MODE, 2932*719f82d3SEliot Blennerhassett mode, value); 2933*719f82d3SEliot Blennerhassett } 2934*719f82d3SEliot Blennerhassett 2935*719f82d3SEliot Blennerhassett u16 hpi_tuner_get_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2936*719f82d3SEliot Blennerhassett u32 mode, u32 *pn_value) 2937*719f82d3SEliot Blennerhassett { 2938*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, HPI_TUNER_MODE, 2939*719f82d3SEliot Blennerhassett mode, 0, pn_value, NULL); 2940*719f82d3SEliot Blennerhassett } 2941*719f82d3SEliot Blennerhassett 2942*719f82d3SEliot Blennerhassett u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys, 2943*719f82d3SEliot Blennerhassett u32 h_control, u32 *pquality) 2944*719f82d3SEliot Blennerhassett { 2945*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2946*719f82d3SEliot Blennerhassett HPI_TUNER_HDRADIO_SIGNAL_QUALITY, 0, 0, pquality, NULL); 2947*719f82d3SEliot Blennerhassett } 2948*719f82d3SEliot Blennerhassett 2949*719f82d3SEliot Blennerhassett u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2950*719f82d3SEliot Blennerhassett char *p_data) 2951*719f82d3SEliot Blennerhassett { 2952*719f82d3SEliot Blennerhassett struct hpi_message hm; 2953*719f82d3SEliot Blennerhassett struct hpi_response hr; 2954*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2955*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 2956*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2957*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_TUNER_RDS; 2958*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 2959*719f82d3SEliot Blennerhassett if (p_data) { 2960*719f82d3SEliot Blennerhassett *(u32 *)&p_data[0] = hr.u.cu.tuner.rds.data[0]; 2961*719f82d3SEliot Blennerhassett *(u32 *)&p_data[4] = hr.u.cu.tuner.rds.data[1]; 2962*719f82d3SEliot Blennerhassett *(u32 *)&p_data[8] = hr.u.cu.tuner.rds.bLER; 2963*719f82d3SEliot Blennerhassett } 2964*719f82d3SEliot Blennerhassett return hr.error; 2965*719f82d3SEliot Blennerhassett } 2966*719f82d3SEliot Blennerhassett 2967*719f82d3SEliot Blennerhassett u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys, 2968*719f82d3SEliot Blennerhassett u32 h_control, char *psz_string, const u32 data_length) 2969*719f82d3SEliot Blennerhassett { 2970*719f82d3SEliot Blennerhassett return hpi_control_get_string(ph_subsys, h_control, 2971*719f82d3SEliot Blennerhassett HPI_PAD_CHANNEL_NAME, psz_string, data_length); 2972*719f82d3SEliot Blennerhassett } 2973*719f82d3SEliot Blennerhassett 2974*719f82d3SEliot Blennerhassett u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2975*719f82d3SEliot Blennerhassett char *psz_string, const u32 data_length) 2976*719f82d3SEliot Blennerhassett { 2977*719f82d3SEliot Blennerhassett return hpi_control_get_string(ph_subsys, h_control, HPI_PAD_ARTIST, 2978*719f82d3SEliot Blennerhassett psz_string, data_length); 2979*719f82d3SEliot Blennerhassett } 2980*719f82d3SEliot Blennerhassett 2981*719f82d3SEliot Blennerhassett u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2982*719f82d3SEliot Blennerhassett char *psz_string, const u32 data_length) 2983*719f82d3SEliot Blennerhassett { 2984*719f82d3SEliot Blennerhassett return hpi_control_get_string(ph_subsys, h_control, HPI_PAD_TITLE, 2985*719f82d3SEliot Blennerhassett psz_string, data_length); 2986*719f82d3SEliot Blennerhassett } 2987*719f82d3SEliot Blennerhassett 2988*719f82d3SEliot Blennerhassett u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2989*719f82d3SEliot Blennerhassett char *psz_string, const u32 data_length) 2990*719f82d3SEliot Blennerhassett { 2991*719f82d3SEliot Blennerhassett return hpi_control_get_string(ph_subsys, h_control, HPI_PAD_COMMENT, 2992*719f82d3SEliot Blennerhassett psz_string, data_length); 2993*719f82d3SEliot Blennerhassett } 2994*719f82d3SEliot Blennerhassett 2995*719f82d3SEliot Blennerhassett u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys, 2996*719f82d3SEliot Blennerhassett u32 h_control, u32 *ppTY) 2997*719f82d3SEliot Blennerhassett { 2998*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, 2999*719f82d3SEliot Blennerhassett HPI_PAD_PROGRAM_TYPE, 0, 0, ppTY, NULL); 3000*719f82d3SEliot Blennerhassett } 3001*719f82d3SEliot Blennerhassett 3002*719f82d3SEliot Blennerhassett u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3003*719f82d3SEliot Blennerhassett u32 *ppI) 3004*719f82d3SEliot Blennerhassett { 3005*719f82d3SEliot Blennerhassett return hpi_control_param_get(ph_subsys, h_control, HPI_PAD_PROGRAM_ID, 3006*719f82d3SEliot Blennerhassett 0, 0, ppI, NULL); 3007*719f82d3SEliot Blennerhassett } 3008*719f82d3SEliot Blennerhassett 3009*719f82d3SEliot Blennerhassett u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys, 3010*719f82d3SEliot Blennerhassett const u32 h_volume, u32 *p_channels) 3011*719f82d3SEliot Blennerhassett { 3012*719f82d3SEliot Blennerhassett return hpi_control_query(ph_subsys, h_volume, HPI_VOLUME_NUM_CHANNELS, 3013*719f82d3SEliot Blennerhassett 0, 0, p_channels); 3014*719f82d3SEliot Blennerhassett } 3015*719f82d3SEliot Blennerhassett 3016*719f82d3SEliot Blennerhassett u16 hpi_volume_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3017*719f82d3SEliot Blennerhassett short an_log_gain[HPI_MAX_CHANNELS] 3018*719f82d3SEliot Blennerhassett ) 3019*719f82d3SEliot Blennerhassett { 3020*719f82d3SEliot Blennerhassett struct hpi_message hm; 3021*719f82d3SEliot Blennerhassett struct hpi_response hr; 3022*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3023*719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 3024*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3025*719f82d3SEliot Blennerhassett memcpy(hm.u.c.an_log_value, an_log_gain, 3026*719f82d3SEliot Blennerhassett sizeof(short) * HPI_MAX_CHANNELS); 3027*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_VOLUME_GAIN; 3028*719f82d3SEliot Blennerhassett 3029*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3030*719f82d3SEliot Blennerhassett 3031*719f82d3SEliot Blennerhassett return hr.error; 3032*719f82d3SEliot Blennerhassett } 3033*719f82d3SEliot Blennerhassett 3034*719f82d3SEliot Blennerhassett u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3035*719f82d3SEliot Blennerhassett short an_log_gain[HPI_MAX_CHANNELS] 3036*719f82d3SEliot Blennerhassett ) 3037*719f82d3SEliot Blennerhassett { 3038*719f82d3SEliot Blennerhassett struct hpi_message hm; 3039*719f82d3SEliot Blennerhassett struct hpi_response hr; 3040*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3041*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 3042*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3043*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_VOLUME_GAIN; 3044*719f82d3SEliot Blennerhassett 3045*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3046*719f82d3SEliot Blennerhassett 3047*719f82d3SEliot Blennerhassett memcpy(an_log_gain, hr.u.c.an_log_value, 3048*719f82d3SEliot Blennerhassett sizeof(short) * HPI_MAX_CHANNELS); 3049*719f82d3SEliot Blennerhassett return hr.error; 3050*719f82d3SEliot Blennerhassett } 3051*719f82d3SEliot Blennerhassett 3052*719f82d3SEliot Blennerhassett u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3053*719f82d3SEliot Blennerhassett short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB) 3054*719f82d3SEliot Blennerhassett { 3055*719f82d3SEliot Blennerhassett struct hpi_message hm; 3056*719f82d3SEliot Blennerhassett struct hpi_response hr; 3057*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3058*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 3059*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3060*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_VOLUME_RANGE; 3061*719f82d3SEliot Blennerhassett 3062*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3063*719f82d3SEliot Blennerhassett if (hr.error) { 3064*719f82d3SEliot Blennerhassett hr.u.c.an_log_value[0] = 0; 3065*719f82d3SEliot Blennerhassett hr.u.c.an_log_value[1] = 0; 3066*719f82d3SEliot Blennerhassett hr.u.c.param1 = 0; 3067*719f82d3SEliot Blennerhassett } 3068*719f82d3SEliot Blennerhassett if (min_gain_01dB) 3069*719f82d3SEliot Blennerhassett *min_gain_01dB = hr.u.c.an_log_value[0]; 3070*719f82d3SEliot Blennerhassett if (max_gain_01dB) 3071*719f82d3SEliot Blennerhassett *max_gain_01dB = hr.u.c.an_log_value[1]; 3072*719f82d3SEliot Blennerhassett if (step_gain_01dB) 3073*719f82d3SEliot Blennerhassett *step_gain_01dB = (short)hr.u.c.param1; 3074*719f82d3SEliot Blennerhassett return hr.error; 3075*719f82d3SEliot Blennerhassett } 3076*719f82d3SEliot Blennerhassett 3077*719f82d3SEliot Blennerhassett u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys, 3078*719f82d3SEliot Blennerhassett u32 h_control, short an_stop_gain0_01dB[HPI_MAX_CHANNELS], 3079*719f82d3SEliot Blennerhassett u32 duration_ms, u16 profile) 3080*719f82d3SEliot Blennerhassett { 3081*719f82d3SEliot Blennerhassett struct hpi_message hm; 3082*719f82d3SEliot Blennerhassett struct hpi_response hr; 3083*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3084*719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 3085*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3086*719f82d3SEliot Blennerhassett 3087*719f82d3SEliot Blennerhassett memcpy(hm.u.c.an_log_value, an_stop_gain0_01dB, 3088*719f82d3SEliot Blennerhassett sizeof(short) * HPI_MAX_CHANNELS); 3089*719f82d3SEliot Blennerhassett 3090*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_VOLUME_AUTOFADE; 3091*719f82d3SEliot Blennerhassett hm.u.c.param1 = duration_ms; 3092*719f82d3SEliot Blennerhassett hm.u.c.param2 = profile; 3093*719f82d3SEliot Blennerhassett 3094*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3095*719f82d3SEliot Blennerhassett 3096*719f82d3SEliot Blennerhassett return hr.error; 3097*719f82d3SEliot Blennerhassett } 3098*719f82d3SEliot Blennerhassett 3099*719f82d3SEliot Blennerhassett u16 hpi_volume_auto_fade(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3100*719f82d3SEliot Blennerhassett short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms) 3101*719f82d3SEliot Blennerhassett { 3102*719f82d3SEliot Blennerhassett return hpi_volume_auto_fade_profile(ph_subsys, h_control, 3103*719f82d3SEliot Blennerhassett an_stop_gain0_01dB, duration_ms, HPI_VOLUME_AUTOFADE_LOG); 3104*719f82d3SEliot Blennerhassett } 3105*719f82d3SEliot Blennerhassett 3106*719f82d3SEliot Blennerhassett u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3107*719f82d3SEliot Blennerhassett short an_gain0_01dB) 3108*719f82d3SEliot Blennerhassett { 3109*719f82d3SEliot Blennerhassett struct hpi_message hm; 3110*719f82d3SEliot Blennerhassett struct hpi_response hr; 3111*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3112*719f82d3SEliot Blennerhassett HPI_CONTROL_SET_STATE); 3113*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3114*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_VOX_THRESHOLD; 3115*719f82d3SEliot Blennerhassett 3116*719f82d3SEliot Blennerhassett hm.u.c.an_log_value[0] = an_gain0_01dB; 3117*719f82d3SEliot Blennerhassett 3118*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3119*719f82d3SEliot Blennerhassett 3120*719f82d3SEliot Blennerhassett return hr.error; 3121*719f82d3SEliot Blennerhassett } 3122*719f82d3SEliot Blennerhassett 3123*719f82d3SEliot Blennerhassett u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3124*719f82d3SEliot Blennerhassett short *an_gain0_01dB) 3125*719f82d3SEliot Blennerhassett { 3126*719f82d3SEliot Blennerhassett struct hpi_message hm; 3127*719f82d3SEliot Blennerhassett struct hpi_response hr; 3128*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3129*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 3130*719f82d3SEliot Blennerhassett u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3131*719f82d3SEliot Blennerhassett hm.u.c.attribute = HPI_VOX_THRESHOLD; 3132*719f82d3SEliot Blennerhassett 3133*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3134*719f82d3SEliot Blennerhassett 3135*719f82d3SEliot Blennerhassett *an_gain0_01dB = hr.u.c.an_log_value[0]; 3136*719f82d3SEliot Blennerhassett 3137*719f82d3SEliot Blennerhassett return hr.error; 3138*719f82d3SEliot Blennerhassett } 3139*719f82d3SEliot Blennerhassett 3140*719f82d3SEliot Blennerhassett static size_t strv_packet_size = MIN_STRV_PACKET_SIZE; 3141*719f82d3SEliot Blennerhassett 3142*719f82d3SEliot Blennerhassett static size_t entity_type_to_size[LAST_ENTITY_TYPE] = { 3143*719f82d3SEliot Blennerhassett 0, 3144*719f82d3SEliot Blennerhassett sizeof(struct hpi_entity), 3145*719f82d3SEliot Blennerhassett sizeof(void *), 3146*719f82d3SEliot Blennerhassett 3147*719f82d3SEliot Blennerhassett sizeof(int), 3148*719f82d3SEliot Blennerhassett sizeof(float), 3149*719f82d3SEliot Blennerhassett sizeof(double), 3150*719f82d3SEliot Blennerhassett 3151*719f82d3SEliot Blennerhassett sizeof(char), 3152*719f82d3SEliot Blennerhassett sizeof(char), 3153*719f82d3SEliot Blennerhassett 3154*719f82d3SEliot Blennerhassett 4 * sizeof(char), 3155*719f82d3SEliot Blennerhassett 16 * sizeof(char), 3156*719f82d3SEliot Blennerhassett 6 * sizeof(char), 3157*719f82d3SEliot Blennerhassett }; 3158*719f82d3SEliot Blennerhassett 3159*719f82d3SEliot Blennerhassett inline size_t hpi_entity_size(struct hpi_entity *entity_ptr) 3160*719f82d3SEliot Blennerhassett { 3161*719f82d3SEliot Blennerhassett return entity_ptr->header.size; 3162*719f82d3SEliot Blennerhassett } 3163*719f82d3SEliot Blennerhassett 3164*719f82d3SEliot Blennerhassett inline size_t hpi_entity_header_size(struct hpi_entity *entity_ptr) 3165*719f82d3SEliot Blennerhassett { 3166*719f82d3SEliot Blennerhassett return sizeof(entity_ptr->header); 3167*719f82d3SEliot Blennerhassett } 3168*719f82d3SEliot Blennerhassett 3169*719f82d3SEliot Blennerhassett inline size_t hpi_entity_value_size(struct hpi_entity *entity_ptr) 3170*719f82d3SEliot Blennerhassett { 3171*719f82d3SEliot Blennerhassett return hpi_entity_size(entity_ptr) - 3172*719f82d3SEliot Blennerhassett hpi_entity_header_size(entity_ptr); 3173*719f82d3SEliot Blennerhassett } 3174*719f82d3SEliot Blennerhassett 3175*719f82d3SEliot Blennerhassett inline size_t hpi_entity_item_count(struct hpi_entity *entity_ptr) 3176*719f82d3SEliot Blennerhassett { 3177*719f82d3SEliot Blennerhassett return hpi_entity_value_size(entity_ptr) / 3178*719f82d3SEliot Blennerhassett entity_type_to_size[entity_ptr->header.type]; 3179*719f82d3SEliot Blennerhassett } 3180*719f82d3SEliot Blennerhassett 3181*719f82d3SEliot Blennerhassett inline struct hpi_entity *hpi_entity_ptr_to_next(struct hpi_entity 3182*719f82d3SEliot Blennerhassett *entity_ptr) 3183*719f82d3SEliot Blennerhassett { 3184*719f82d3SEliot Blennerhassett return (void *)(((uint8_t *) entity_ptr) + 3185*719f82d3SEliot Blennerhassett hpi_entity_size(entity_ptr)); 3186*719f82d3SEliot Blennerhassett } 3187*719f82d3SEliot Blennerhassett 3188*719f82d3SEliot Blennerhassett inline u16 hpi_entity_check_type(const enum e_entity_type t) 3189*719f82d3SEliot Blennerhassett { 3190*719f82d3SEliot Blennerhassett if (t >= 0 && t < STR_TYPE_FIELD_MAX) 3191*719f82d3SEliot Blennerhassett return 0; 3192*719f82d3SEliot Blennerhassett return HPI_ERROR_ENTITY_TYPE_INVALID; 3193*719f82d3SEliot Blennerhassett } 3194*719f82d3SEliot Blennerhassett 3195*719f82d3SEliot Blennerhassett inline u16 hpi_entity_check_role(const enum e_entity_role r) 3196*719f82d3SEliot Blennerhassett { 3197*719f82d3SEliot Blennerhassett if (r >= 0 && r < STR_ROLE_FIELD_MAX) 3198*719f82d3SEliot Blennerhassett return 0; 3199*719f82d3SEliot Blennerhassett return HPI_ERROR_ENTITY_ROLE_INVALID; 3200*719f82d3SEliot Blennerhassett } 3201*719f82d3SEliot Blennerhassett 3202*719f82d3SEliot Blennerhassett static u16 hpi_entity_get_next(struct hpi_entity *entity, int recursive_flag, 3203*719f82d3SEliot Blennerhassett void *guard_p, struct hpi_entity **next) 3204*719f82d3SEliot Blennerhassett { 3205*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(entity != NULL); 3206*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(next != NULL); 3207*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(hpi_entity_size(entity) != 0); 3208*719f82d3SEliot Blennerhassett 3209*719f82d3SEliot Blennerhassett if (guard_p <= (void *)entity) { 3210*719f82d3SEliot Blennerhassett *next = NULL; 3211*719f82d3SEliot Blennerhassett return 0; 3212*719f82d3SEliot Blennerhassett } 3213*719f82d3SEliot Blennerhassett 3214*719f82d3SEliot Blennerhassett if (recursive_flag && entity->header.type == entity_type_sequence) 3215*719f82d3SEliot Blennerhassett *next = (struct hpi_entity *)entity->value; 3216*719f82d3SEliot Blennerhassett else 3217*719f82d3SEliot Blennerhassett *next = (struct hpi_entity *)hpi_entity_ptr_to_next(entity); 3218*719f82d3SEliot Blennerhassett 3219*719f82d3SEliot Blennerhassett if (guard_p <= (void *)*next) { 3220*719f82d3SEliot Blennerhassett *next = NULL; 3221*719f82d3SEliot Blennerhassett return 0; 3222*719f82d3SEliot Blennerhassett } 3223*719f82d3SEliot Blennerhassett 3224*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(guard_p >= (void *)hpi_entity_ptr_to_next(*next)); 3225*719f82d3SEliot Blennerhassett return 0; 3226*719f82d3SEliot Blennerhassett } 3227*719f82d3SEliot Blennerhassett 3228*719f82d3SEliot Blennerhassett u16 hpi_entity_find_next(struct hpi_entity *container_entity, 3229*719f82d3SEliot Blennerhassett enum e_entity_type type, enum e_entity_role role, int recursive_flag, 3230*719f82d3SEliot Blennerhassett struct hpi_entity **current_match) 3231*719f82d3SEliot Blennerhassett { 3232*719f82d3SEliot Blennerhassett struct hpi_entity *tmp = NULL; 3233*719f82d3SEliot Blennerhassett void *guard_p = NULL; 3234*719f82d3SEliot Blennerhassett 3235*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(container_entity != NULL); 3236*719f82d3SEliot Blennerhassett guard_p = hpi_entity_ptr_to_next(container_entity); 3237*719f82d3SEliot Blennerhassett 3238*719f82d3SEliot Blennerhassett if (*current_match != NULL) 3239*719f82d3SEliot Blennerhassett hpi_entity_get_next(*current_match, recursive_flag, guard_p, 3240*719f82d3SEliot Blennerhassett &tmp); 3241*719f82d3SEliot Blennerhassett else 3242*719f82d3SEliot Blennerhassett hpi_entity_get_next(container_entity, 1, guard_p, &tmp); 3243*719f82d3SEliot Blennerhassett 3244*719f82d3SEliot Blennerhassett while (tmp) { 3245*719f82d3SEliot Blennerhassett u16 err; 3246*719f82d3SEliot Blennerhassett 3247*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT((void *)tmp >= (void *)container_entity); 3248*719f82d3SEliot Blennerhassett 3249*719f82d3SEliot Blennerhassett if ((!type || tmp->header.type == type) && (!role 3250*719f82d3SEliot Blennerhassett || tmp->header.role == role)) { 3251*719f82d3SEliot Blennerhassett *current_match = tmp; 3252*719f82d3SEliot Blennerhassett return 0; 3253*719f82d3SEliot Blennerhassett } 3254*719f82d3SEliot Blennerhassett 3255*719f82d3SEliot Blennerhassett err = hpi_entity_get_next(tmp, recursive_flag, guard_p, 3256*719f82d3SEliot Blennerhassett current_match); 3257*719f82d3SEliot Blennerhassett if (err) 3258*719f82d3SEliot Blennerhassett return err; 3259*719f82d3SEliot Blennerhassett 3260*719f82d3SEliot Blennerhassett tmp = *current_match; 3261*719f82d3SEliot Blennerhassett } 3262*719f82d3SEliot Blennerhassett 3263*719f82d3SEliot Blennerhassett *current_match = NULL; 3264*719f82d3SEliot Blennerhassett return 0; 3265*719f82d3SEliot Blennerhassett } 3266*719f82d3SEliot Blennerhassett 3267*719f82d3SEliot Blennerhassett void hpi_entity_free(struct hpi_entity *entity) 3268*719f82d3SEliot Blennerhassett { 3269*719f82d3SEliot Blennerhassett if (entity != NULL) 3270*719f82d3SEliot Blennerhassett kfree(entity); 3271*719f82d3SEliot Blennerhassett } 3272*719f82d3SEliot Blennerhassett 3273*719f82d3SEliot Blennerhassett static u16 hpi_entity_alloc_and_copy(struct hpi_entity *src, 3274*719f82d3SEliot Blennerhassett struct hpi_entity **dst) 3275*719f82d3SEliot Blennerhassett { 3276*719f82d3SEliot Blennerhassett size_t buf_size; 3277*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(dst != NULL); 3278*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(src != NULL); 3279*719f82d3SEliot Blennerhassett 3280*719f82d3SEliot Blennerhassett buf_size = hpi_entity_size(src); 3281*719f82d3SEliot Blennerhassett *dst = kmalloc(buf_size, GFP_KERNEL); 3282*719f82d3SEliot Blennerhassett if (dst == NULL) 3283*719f82d3SEliot Blennerhassett return HPI_ERROR_MEMORY_ALLOC; 3284*719f82d3SEliot Blennerhassett memcpy(*dst, src, buf_size); 3285*719f82d3SEliot Blennerhassett return 0; 3286*719f82d3SEliot Blennerhassett } 3287*719f82d3SEliot Blennerhassett 3288*719f82d3SEliot Blennerhassett u16 hpi_universal_info(const struct hpi_hsubsys *ph_subsys, u32 hC, 3289*719f82d3SEliot Blennerhassett struct hpi_entity **info) 3290*719f82d3SEliot Blennerhassett { 3291*719f82d3SEliot Blennerhassett struct hpi_msg_strv hm; 3292*719f82d3SEliot Blennerhassett struct hpi_res_strv *phr; 3293*719f82d3SEliot Blennerhassett u16 hpi_err; 3294*719f82d3SEliot Blennerhassett int remaining_attempts = 2; 3295*719f82d3SEliot Blennerhassett size_t resp_packet_size = 1024; 3296*719f82d3SEliot Blennerhassett 3297*719f82d3SEliot Blennerhassett *info = NULL; 3298*719f82d3SEliot Blennerhassett 3299*719f82d3SEliot Blennerhassett while (remaining_attempts--) { 3300*719f82d3SEliot Blennerhassett phr = kmalloc(resp_packet_size, GFP_KERNEL); 3301*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(phr != NULL); 3302*719f82d3SEliot Blennerhassett 3303*719f82d3SEliot Blennerhassett hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h, 3304*719f82d3SEliot Blennerhassett (u16)resp_packet_size, HPI_OBJ_CONTROL, 3305*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_INFO); 3306*719f82d3SEliot Blennerhassett u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index); 3307*719f82d3SEliot Blennerhassett 3308*719f82d3SEliot Blennerhassett hm.strv.header.size = sizeof(hm.strv); 3309*719f82d3SEliot Blennerhassett phr->strv.header.size = resp_packet_size - sizeof(phr->h); 3310*719f82d3SEliot Blennerhassett 3311*719f82d3SEliot Blennerhassett hpi_send_recv((struct hpi_message *)&hm.h, 3312*719f82d3SEliot Blennerhassett (struct hpi_response *)&phr->h); 3313*719f82d3SEliot Blennerhassett if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) { 3314*719f82d3SEliot Blennerhassett 3315*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(phr->h.specific_error > 3316*719f82d3SEliot Blennerhassett MIN_STRV_PACKET_SIZE 3317*719f82d3SEliot Blennerhassett && phr->h.specific_error < 1500); 3318*719f82d3SEliot Blennerhassett resp_packet_size = phr->h.specific_error; 3319*719f82d3SEliot Blennerhassett } else { 3320*719f82d3SEliot Blennerhassett remaining_attempts = 0; 3321*719f82d3SEliot Blennerhassett if (!phr->h.error) 3322*719f82d3SEliot Blennerhassett hpi_entity_alloc_and_copy(&phr->strv, info); 3323*719f82d3SEliot Blennerhassett } 3324*719f82d3SEliot Blennerhassett 3325*719f82d3SEliot Blennerhassett hpi_err = phr->h.error; 3326*719f82d3SEliot Blennerhassett kfree(phr); 3327*719f82d3SEliot Blennerhassett } 3328*719f82d3SEliot Blennerhassett 3329*719f82d3SEliot Blennerhassett return hpi_err; 3330*719f82d3SEliot Blennerhassett } 3331*719f82d3SEliot Blennerhassett 3332*719f82d3SEliot Blennerhassett u16 hpi_universal_get(const struct hpi_hsubsys *ph_subsys, u32 hC, 3333*719f82d3SEliot Blennerhassett struct hpi_entity **value) 3334*719f82d3SEliot Blennerhassett { 3335*719f82d3SEliot Blennerhassett struct hpi_msg_strv hm; 3336*719f82d3SEliot Blennerhassett struct hpi_res_strv *phr; 3337*719f82d3SEliot Blennerhassett u16 hpi_err; 3338*719f82d3SEliot Blennerhassett int remaining_attempts = 2; 3339*719f82d3SEliot Blennerhassett 3340*719f82d3SEliot Blennerhassett *value = NULL; 3341*719f82d3SEliot Blennerhassett 3342*719f82d3SEliot Blennerhassett while (remaining_attempts--) { 3343*719f82d3SEliot Blennerhassett phr = kmalloc(strv_packet_size, GFP_KERNEL); 3344*719f82d3SEliot Blennerhassett if (!phr) 3345*719f82d3SEliot Blennerhassett return HPI_ERROR_MEMORY_ALLOC; 3346*719f82d3SEliot Blennerhassett 3347*719f82d3SEliot Blennerhassett hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h, 3348*719f82d3SEliot Blennerhassett (u16)strv_packet_size, HPI_OBJ_CONTROL, 3349*719f82d3SEliot Blennerhassett HPI_CONTROL_GET_STATE); 3350*719f82d3SEliot Blennerhassett u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index); 3351*719f82d3SEliot Blennerhassett 3352*719f82d3SEliot Blennerhassett hm.strv.header.size = sizeof(hm.strv); 3353*719f82d3SEliot Blennerhassett phr->strv.header.size = strv_packet_size - sizeof(phr->h); 3354*719f82d3SEliot Blennerhassett 3355*719f82d3SEliot Blennerhassett hpi_send_recv((struct hpi_message *)&hm.h, 3356*719f82d3SEliot Blennerhassett (struct hpi_response *)&phr->h); 3357*719f82d3SEliot Blennerhassett if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) { 3358*719f82d3SEliot Blennerhassett 3359*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(phr->h.specific_error > 3360*719f82d3SEliot Blennerhassett MIN_STRV_PACKET_SIZE 3361*719f82d3SEliot Blennerhassett && phr->h.specific_error < 1000); 3362*719f82d3SEliot Blennerhassett strv_packet_size = phr->h.specific_error; 3363*719f82d3SEliot Blennerhassett } else { 3364*719f82d3SEliot Blennerhassett remaining_attempts = 0; 3365*719f82d3SEliot Blennerhassett if (!phr->h.error) 3366*719f82d3SEliot Blennerhassett hpi_entity_alloc_and_copy(&phr->strv, value); 3367*719f82d3SEliot Blennerhassett } 3368*719f82d3SEliot Blennerhassett 3369*719f82d3SEliot Blennerhassett hpi_err = phr->h.error; 3370*719f82d3SEliot Blennerhassett kfree(phr); 3371*719f82d3SEliot Blennerhassett } 3372*719f82d3SEliot Blennerhassett 3373*719f82d3SEliot Blennerhassett return hpi_err; 3374*719f82d3SEliot Blennerhassett } 3375*719f82d3SEliot Blennerhassett 3376*719f82d3SEliot Blennerhassett u16 hpi_universal_set(const struct hpi_hsubsys *ph_subsys, u32 hC, 3377*719f82d3SEliot Blennerhassett struct hpi_entity *value) 3378*719f82d3SEliot Blennerhassett { 3379*719f82d3SEliot Blennerhassett struct hpi_msg_strv *phm; 3380*719f82d3SEliot Blennerhassett struct hpi_res_strv hr; 3381*719f82d3SEliot Blennerhassett 3382*719f82d3SEliot Blennerhassett phm = kmalloc(sizeof(phm->h) + value->header.size, GFP_KERNEL); 3383*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(phm != NULL); 3384*719f82d3SEliot Blennerhassett 3385*719f82d3SEliot Blennerhassett hpi_init_message_responseV1(&phm->h, 3386*719f82d3SEliot Blennerhassett sizeof(phm->h) + value->header.size, &hr.h, sizeof(hr), 3387*719f82d3SEliot Blennerhassett HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); 3388*719f82d3SEliot Blennerhassett u32TOINDEXES(hC, &phm->h.adapter_index, &phm->h.obj_index); 3389*719f82d3SEliot Blennerhassett hr.strv.header.size = sizeof(hr.strv); 3390*719f82d3SEliot Blennerhassett 3391*719f82d3SEliot Blennerhassett memcpy(&phm->strv, value, value->header.size); 3392*719f82d3SEliot Blennerhassett hpi_send_recv((struct hpi_message *)&phm->h, 3393*719f82d3SEliot Blennerhassett (struct hpi_response *)&hr.h); 3394*719f82d3SEliot Blennerhassett 3395*719f82d3SEliot Blennerhassett return hr.h.error; 3396*719f82d3SEliot Blennerhassett } 3397*719f82d3SEliot Blennerhassett 3398*719f82d3SEliot Blennerhassett u16 hpi_entity_alloc_and_pack(const enum e_entity_type type, 3399*719f82d3SEliot Blennerhassett const size_t item_count, const enum e_entity_role role, void *value, 3400*719f82d3SEliot Blennerhassett struct hpi_entity **entity) 3401*719f82d3SEliot Blennerhassett { 3402*719f82d3SEliot Blennerhassett size_t bytes_to_copy, total_size; 3403*719f82d3SEliot Blennerhassett u16 hE = 0; 3404*719f82d3SEliot Blennerhassett *entity = NULL; 3405*719f82d3SEliot Blennerhassett 3406*719f82d3SEliot Blennerhassett hE = hpi_entity_check_type(type); 3407*719f82d3SEliot Blennerhassett if (hE) 3408*719f82d3SEliot Blennerhassett return hE; 3409*719f82d3SEliot Blennerhassett 3410*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(role > entity_role_null && type < LAST_ENTITY_ROLE); 3411*719f82d3SEliot Blennerhassett 3412*719f82d3SEliot Blennerhassett bytes_to_copy = entity_type_to_size[type] * item_count; 3413*719f82d3SEliot Blennerhassett total_size = hpi_entity_header_size(*entity) + bytes_to_copy; 3414*719f82d3SEliot Blennerhassett 3415*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(total_size >= hpi_entity_header_size(*entity) 3416*719f82d3SEliot Blennerhassett && total_size < STR_SIZE_FIELD_MAX); 3417*719f82d3SEliot Blennerhassett 3418*719f82d3SEliot Blennerhassett *entity = kmalloc(total_size, GFP_KERNEL); 3419*719f82d3SEliot Blennerhassett if (*entity == NULL) 3420*719f82d3SEliot Blennerhassett return HPI_ERROR_MEMORY_ALLOC; 3421*719f82d3SEliot Blennerhassett memcpy((*entity)->value, value, bytes_to_copy); 3422*719f82d3SEliot Blennerhassett (*entity)->header.size = 3423*719f82d3SEliot Blennerhassett hpi_entity_header_size(*entity) + bytes_to_copy; 3424*719f82d3SEliot Blennerhassett (*entity)->header.type = type; 3425*719f82d3SEliot Blennerhassett (*entity)->header.role = role; 3426*719f82d3SEliot Blennerhassett return 0; 3427*719f82d3SEliot Blennerhassett } 3428*719f82d3SEliot Blennerhassett 3429*719f82d3SEliot Blennerhassett u16 hpi_entity_copy_value_from(struct hpi_entity *entity, 3430*719f82d3SEliot Blennerhassett enum e_entity_type type, size_t item_count, void *value_dst_p) 3431*719f82d3SEliot Blennerhassett { 3432*719f82d3SEliot Blennerhassett size_t bytes_to_copy; 3433*719f82d3SEliot Blennerhassett 3434*719f82d3SEliot Blennerhassett if (entity->header.type != type) 3435*719f82d3SEliot Blennerhassett return HPI_ERROR_ENTITY_TYPE_MISMATCH; 3436*719f82d3SEliot Blennerhassett 3437*719f82d3SEliot Blennerhassett if (hpi_entity_item_count(entity) != item_count) 3438*719f82d3SEliot Blennerhassett return HPI_ERROR_ENTITY_ITEM_COUNT; 3439*719f82d3SEliot Blennerhassett 3440*719f82d3SEliot Blennerhassett bytes_to_copy = entity_type_to_size[type] * item_count; 3441*719f82d3SEliot Blennerhassett memcpy(value_dst_p, entity->value, bytes_to_copy); 3442*719f82d3SEliot Blennerhassett return 0; 3443*719f82d3SEliot Blennerhassett } 3444*719f82d3SEliot Blennerhassett 3445*719f82d3SEliot Blennerhassett u16 hpi_entity_unpack(struct hpi_entity *entity, enum e_entity_type *type, 3446*719f82d3SEliot Blennerhassett size_t *item_count, enum e_entity_role *role, void **value) 3447*719f82d3SEliot Blennerhassett { 3448*719f82d3SEliot Blennerhassett u16 err = 0; 3449*719f82d3SEliot Blennerhassett HPI_DEBUG_ASSERT(entity != NULL); 3450*719f82d3SEliot Blennerhassett 3451*719f82d3SEliot Blennerhassett if (type) 3452*719f82d3SEliot Blennerhassett *type = entity->header.type; 3453*719f82d3SEliot Blennerhassett 3454*719f82d3SEliot Blennerhassett if (role) 3455*719f82d3SEliot Blennerhassett *role = entity->header.role; 3456*719f82d3SEliot Blennerhassett 3457*719f82d3SEliot Blennerhassett if (value) 3458*719f82d3SEliot Blennerhassett *value = entity->value; 3459*719f82d3SEliot Blennerhassett 3460*719f82d3SEliot Blennerhassett if (item_count != NULL) { 3461*719f82d3SEliot Blennerhassett if (entity->header.type == entity_type_sequence) { 3462*719f82d3SEliot Blennerhassett void *guard_p = hpi_entity_ptr_to_next(entity); 3463*719f82d3SEliot Blennerhassett struct hpi_entity *next = NULL; 3464*719f82d3SEliot Blennerhassett void *contents = entity->value; 3465*719f82d3SEliot Blennerhassett 3466*719f82d3SEliot Blennerhassett *item_count = 0; 3467*719f82d3SEliot Blennerhassett while (contents < guard_p) { 3468*719f82d3SEliot Blennerhassett (*item_count)++; 3469*719f82d3SEliot Blennerhassett err = hpi_entity_get_next(contents, 0, 3470*719f82d3SEliot Blennerhassett guard_p, &next); 3471*719f82d3SEliot Blennerhassett if (next == NULL || err) 3472*719f82d3SEliot Blennerhassett break; 3473*719f82d3SEliot Blennerhassett contents = next; 3474*719f82d3SEliot Blennerhassett } 3475*719f82d3SEliot Blennerhassett } else { 3476*719f82d3SEliot Blennerhassett *item_count = hpi_entity_item_count(entity); 3477*719f82d3SEliot Blennerhassett } 3478*719f82d3SEliot Blennerhassett } 3479*719f82d3SEliot Blennerhassett return err; 3480*719f82d3SEliot Blennerhassett } 3481*719f82d3SEliot Blennerhassett 3482*719f82d3SEliot Blennerhassett u16 hpi_gpio_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 3483*719f82d3SEliot Blennerhassett u32 *ph_gpio, u16 *pw_number_input_bits, u16 *pw_number_output_bits) 3484*719f82d3SEliot Blennerhassett { 3485*719f82d3SEliot Blennerhassett struct hpi_message hm; 3486*719f82d3SEliot Blennerhassett struct hpi_response hr; 3487*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_OPEN); 3488*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 3489*719f82d3SEliot Blennerhassett 3490*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3491*719f82d3SEliot Blennerhassett 3492*719f82d3SEliot Blennerhassett if (hr.error == 0) { 3493*719f82d3SEliot Blennerhassett *ph_gpio = 3494*719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_GPIO, adapter_index, 0); 3495*719f82d3SEliot Blennerhassett if (pw_number_input_bits) 3496*719f82d3SEliot Blennerhassett *pw_number_input_bits = hr.u.l.number_input_bits; 3497*719f82d3SEliot Blennerhassett if (pw_number_output_bits) 3498*719f82d3SEliot Blennerhassett *pw_number_output_bits = hr.u.l.number_output_bits; 3499*719f82d3SEliot Blennerhassett } else 3500*719f82d3SEliot Blennerhassett *ph_gpio = 0; 3501*719f82d3SEliot Blennerhassett return hr.error; 3502*719f82d3SEliot Blennerhassett } 3503*719f82d3SEliot Blennerhassett 3504*719f82d3SEliot Blennerhassett u16 hpi_gpio_read_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, 3505*719f82d3SEliot Blennerhassett u16 bit_index, u16 *pw_bit_data) 3506*719f82d3SEliot Blennerhassett { 3507*719f82d3SEliot Blennerhassett struct hpi_message hm; 3508*719f82d3SEliot Blennerhassett struct hpi_response hr; 3509*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_BIT); 3510*719f82d3SEliot Blennerhassett u32TOINDEX(h_gpio, &hm.adapter_index); 3511*719f82d3SEliot Blennerhassett hm.u.l.bit_index = bit_index; 3512*719f82d3SEliot Blennerhassett 3513*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3514*719f82d3SEliot Blennerhassett 3515*719f82d3SEliot Blennerhassett *pw_bit_data = hr.u.l.bit_data[0]; 3516*719f82d3SEliot Blennerhassett return hr.error; 3517*719f82d3SEliot Blennerhassett } 3518*719f82d3SEliot Blennerhassett 3519*719f82d3SEliot Blennerhassett u16 hpi_gpio_read_all_bits(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, 3520*719f82d3SEliot Blennerhassett u16 aw_all_bit_data[4] 3521*719f82d3SEliot Blennerhassett ) 3522*719f82d3SEliot Blennerhassett { 3523*719f82d3SEliot Blennerhassett struct hpi_message hm; 3524*719f82d3SEliot Blennerhassett struct hpi_response hr; 3525*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_ALL); 3526*719f82d3SEliot Blennerhassett u32TOINDEX(h_gpio, &hm.adapter_index); 3527*719f82d3SEliot Blennerhassett 3528*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3529*719f82d3SEliot Blennerhassett 3530*719f82d3SEliot Blennerhassett if (aw_all_bit_data) { 3531*719f82d3SEliot Blennerhassett aw_all_bit_data[0] = hr.u.l.bit_data[0]; 3532*719f82d3SEliot Blennerhassett aw_all_bit_data[1] = hr.u.l.bit_data[1]; 3533*719f82d3SEliot Blennerhassett aw_all_bit_data[2] = hr.u.l.bit_data[2]; 3534*719f82d3SEliot Blennerhassett aw_all_bit_data[3] = hr.u.l.bit_data[3]; 3535*719f82d3SEliot Blennerhassett } 3536*719f82d3SEliot Blennerhassett return hr.error; 3537*719f82d3SEliot Blennerhassett } 3538*719f82d3SEliot Blennerhassett 3539*719f82d3SEliot Blennerhassett u16 hpi_gpio_write_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, 3540*719f82d3SEliot Blennerhassett u16 bit_index, u16 bit_data) 3541*719f82d3SEliot Blennerhassett { 3542*719f82d3SEliot Blennerhassett struct hpi_message hm; 3543*719f82d3SEliot Blennerhassett struct hpi_response hr; 3544*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_WRITE_BIT); 3545*719f82d3SEliot Blennerhassett u32TOINDEX(h_gpio, &hm.adapter_index); 3546*719f82d3SEliot Blennerhassett hm.u.l.bit_index = bit_index; 3547*719f82d3SEliot Blennerhassett hm.u.l.bit_data = bit_data; 3548*719f82d3SEliot Blennerhassett 3549*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3550*719f82d3SEliot Blennerhassett 3551*719f82d3SEliot Blennerhassett return hr.error; 3552*719f82d3SEliot Blennerhassett } 3553*719f82d3SEliot Blennerhassett 3554*719f82d3SEliot Blennerhassett u16 hpi_gpio_write_status(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, 3555*719f82d3SEliot Blennerhassett u16 aw_all_bit_data[4] 3556*719f82d3SEliot Blennerhassett ) 3557*719f82d3SEliot Blennerhassett { 3558*719f82d3SEliot Blennerhassett struct hpi_message hm; 3559*719f82d3SEliot Blennerhassett struct hpi_response hr; 3560*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, 3561*719f82d3SEliot Blennerhassett HPI_GPIO_WRITE_STATUS); 3562*719f82d3SEliot Blennerhassett u32TOINDEX(h_gpio, &hm.adapter_index); 3563*719f82d3SEliot Blennerhassett 3564*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3565*719f82d3SEliot Blennerhassett 3566*719f82d3SEliot Blennerhassett if (aw_all_bit_data) { 3567*719f82d3SEliot Blennerhassett aw_all_bit_data[0] = hr.u.l.bit_data[0]; 3568*719f82d3SEliot Blennerhassett aw_all_bit_data[1] = hr.u.l.bit_data[1]; 3569*719f82d3SEliot Blennerhassett aw_all_bit_data[2] = hr.u.l.bit_data[2]; 3570*719f82d3SEliot Blennerhassett aw_all_bit_data[3] = hr.u.l.bit_data[3]; 3571*719f82d3SEliot Blennerhassett } 3572*719f82d3SEliot Blennerhassett return hr.error; 3573*719f82d3SEliot Blennerhassett } 3574*719f82d3SEliot Blennerhassett 3575*719f82d3SEliot Blennerhassett u16 hpi_async_event_open(const struct hpi_hsubsys *ph_subsys, 3576*719f82d3SEliot Blennerhassett u16 adapter_index, u32 *ph_async) 3577*719f82d3SEliot Blennerhassett { 3578*719f82d3SEliot Blennerhassett struct hpi_message hm; 3579*719f82d3SEliot Blennerhassett struct hpi_response hr; 3580*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT, 3581*719f82d3SEliot Blennerhassett HPI_ASYNCEVENT_OPEN); 3582*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 3583*719f82d3SEliot Blennerhassett 3584*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3585*719f82d3SEliot Blennerhassett 3586*719f82d3SEliot Blennerhassett if (hr.error == 0) 3587*719f82d3SEliot Blennerhassett 3588*719f82d3SEliot Blennerhassett *ph_async = 3589*719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_ASYNCEVENT, 3590*719f82d3SEliot Blennerhassett adapter_index, 0); 3591*719f82d3SEliot Blennerhassett else 3592*719f82d3SEliot Blennerhassett *ph_async = 0; 3593*719f82d3SEliot Blennerhassett return hr.error; 3594*719f82d3SEliot Blennerhassett 3595*719f82d3SEliot Blennerhassett } 3596*719f82d3SEliot Blennerhassett 3597*719f82d3SEliot Blennerhassett u16 hpi_async_event_close(const struct hpi_hsubsys *ph_subsys, u32 h_async) 3598*719f82d3SEliot Blennerhassett { 3599*719f82d3SEliot Blennerhassett struct hpi_message hm; 3600*719f82d3SEliot Blennerhassett struct hpi_response hr; 3601*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT, 3602*719f82d3SEliot Blennerhassett HPI_ASYNCEVENT_OPEN); 3603*719f82d3SEliot Blennerhassett u32TOINDEX(h_async, &hm.adapter_index); 3604*719f82d3SEliot Blennerhassett 3605*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3606*719f82d3SEliot Blennerhassett 3607*719f82d3SEliot Blennerhassett return hr.error; 3608*719f82d3SEliot Blennerhassett } 3609*719f82d3SEliot Blennerhassett 3610*719f82d3SEliot Blennerhassett u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async, 3611*719f82d3SEliot Blennerhassett u16 maximum_events, struct hpi_async_event *p_events, 3612*719f82d3SEliot Blennerhassett u16 *pw_number_returned) 3613*719f82d3SEliot Blennerhassett { 3614*719f82d3SEliot Blennerhassett return 0; 3615*719f82d3SEliot Blennerhassett } 3616*719f82d3SEliot Blennerhassett 3617*719f82d3SEliot Blennerhassett u16 hpi_async_event_get_count(const struct hpi_hsubsys *ph_subsys, 3618*719f82d3SEliot Blennerhassett u32 h_async, u16 *pw_count) 3619*719f82d3SEliot Blennerhassett { 3620*719f82d3SEliot Blennerhassett struct hpi_message hm; 3621*719f82d3SEliot Blennerhassett struct hpi_response hr; 3622*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT, 3623*719f82d3SEliot Blennerhassett HPI_ASYNCEVENT_GETCOUNT); 3624*719f82d3SEliot Blennerhassett u32TOINDEX(h_async, &hm.adapter_index); 3625*719f82d3SEliot Blennerhassett 3626*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3627*719f82d3SEliot Blennerhassett 3628*719f82d3SEliot Blennerhassett if (hr.error == 0) 3629*719f82d3SEliot Blennerhassett if (pw_count) 3630*719f82d3SEliot Blennerhassett *pw_count = hr.u.as.u.count.count; 3631*719f82d3SEliot Blennerhassett 3632*719f82d3SEliot Blennerhassett return hr.error; 3633*719f82d3SEliot Blennerhassett } 3634*719f82d3SEliot Blennerhassett 3635*719f82d3SEliot Blennerhassett u16 hpi_async_event_get(const struct hpi_hsubsys *ph_subsys, u32 h_async, 3636*719f82d3SEliot Blennerhassett u16 maximum_events, struct hpi_async_event *p_events, 3637*719f82d3SEliot Blennerhassett u16 *pw_number_returned) 3638*719f82d3SEliot Blennerhassett { 3639*719f82d3SEliot Blennerhassett struct hpi_message hm; 3640*719f82d3SEliot Blennerhassett struct hpi_response hr; 3641*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT, 3642*719f82d3SEliot Blennerhassett HPI_ASYNCEVENT_GET); 3643*719f82d3SEliot Blennerhassett u32TOINDEX(h_async, &hm.adapter_index); 3644*719f82d3SEliot Blennerhassett 3645*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3646*719f82d3SEliot Blennerhassett if (!hr.error) { 3647*719f82d3SEliot Blennerhassett memcpy(p_events, &hr.u.as.u.event, 3648*719f82d3SEliot Blennerhassett sizeof(struct hpi_async_event)); 3649*719f82d3SEliot Blennerhassett *pw_number_returned = 1; 3650*719f82d3SEliot Blennerhassett } 3651*719f82d3SEliot Blennerhassett 3652*719f82d3SEliot Blennerhassett return hr.error; 3653*719f82d3SEliot Blennerhassett } 3654*719f82d3SEliot Blennerhassett 3655*719f82d3SEliot Blennerhassett u16 hpi_nv_memory_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 3656*719f82d3SEliot Blennerhassett u32 *ph_nv_memory, u16 *pw_size_in_bytes) 3657*719f82d3SEliot Blennerhassett { 3658*719f82d3SEliot Blennerhassett struct hpi_message hm; 3659*719f82d3SEliot Blennerhassett struct hpi_response hr; 3660*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY, 3661*719f82d3SEliot Blennerhassett HPI_NVMEMORY_OPEN); 3662*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 3663*719f82d3SEliot Blennerhassett 3664*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3665*719f82d3SEliot Blennerhassett 3666*719f82d3SEliot Blennerhassett if (hr.error == 0) { 3667*719f82d3SEliot Blennerhassett *ph_nv_memory = 3668*719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_NVMEMORY, adapter_index, 3669*719f82d3SEliot Blennerhassett 0); 3670*719f82d3SEliot Blennerhassett if (pw_size_in_bytes) 3671*719f82d3SEliot Blennerhassett *pw_size_in_bytes = hr.u.n.size_in_bytes; 3672*719f82d3SEliot Blennerhassett } else 3673*719f82d3SEliot Blennerhassett *ph_nv_memory = 0; 3674*719f82d3SEliot Blennerhassett return hr.error; 3675*719f82d3SEliot Blennerhassett } 3676*719f82d3SEliot Blennerhassett 3677*719f82d3SEliot Blennerhassett u16 hpi_nv_memory_read_byte(const struct hpi_hsubsys *ph_subsys, 3678*719f82d3SEliot Blennerhassett u32 h_nv_memory, u16 index, u16 *pw_data) 3679*719f82d3SEliot Blennerhassett { 3680*719f82d3SEliot Blennerhassett struct hpi_message hm; 3681*719f82d3SEliot Blennerhassett struct hpi_response hr; 3682*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY, 3683*719f82d3SEliot Blennerhassett HPI_NVMEMORY_READ_BYTE); 3684*719f82d3SEliot Blennerhassett u32TOINDEX(h_nv_memory, &hm.adapter_index); 3685*719f82d3SEliot Blennerhassett hm.u.n.address = index; 3686*719f82d3SEliot Blennerhassett 3687*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3688*719f82d3SEliot Blennerhassett 3689*719f82d3SEliot Blennerhassett *pw_data = hr.u.n.data; 3690*719f82d3SEliot Blennerhassett return hr.error; 3691*719f82d3SEliot Blennerhassett } 3692*719f82d3SEliot Blennerhassett 3693*719f82d3SEliot Blennerhassett u16 hpi_nv_memory_write_byte(const struct hpi_hsubsys *ph_subsys, 3694*719f82d3SEliot Blennerhassett u32 h_nv_memory, u16 index, u16 data) 3695*719f82d3SEliot Blennerhassett { 3696*719f82d3SEliot Blennerhassett struct hpi_message hm; 3697*719f82d3SEliot Blennerhassett struct hpi_response hr; 3698*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY, 3699*719f82d3SEliot Blennerhassett HPI_NVMEMORY_WRITE_BYTE); 3700*719f82d3SEliot Blennerhassett u32TOINDEX(h_nv_memory, &hm.adapter_index); 3701*719f82d3SEliot Blennerhassett hm.u.n.address = index; 3702*719f82d3SEliot Blennerhassett hm.u.n.data = data; 3703*719f82d3SEliot Blennerhassett 3704*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3705*719f82d3SEliot Blennerhassett 3706*719f82d3SEliot Blennerhassett return hr.error; 3707*719f82d3SEliot Blennerhassett } 3708*719f82d3SEliot Blennerhassett 3709*719f82d3SEliot Blennerhassett u16 hpi_profile_open_all(const struct hpi_hsubsys *ph_subsys, 3710*719f82d3SEliot Blennerhassett u16 adapter_index, u16 profile_index, u32 *ph_profile, 3711*719f82d3SEliot Blennerhassett u16 *pw_max_profiles) 3712*719f82d3SEliot Blennerhassett { 3713*719f82d3SEliot Blennerhassett struct hpi_message hm; 3714*719f82d3SEliot Blennerhassett struct hpi_response hr; 3715*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, 3716*719f82d3SEliot Blennerhassett HPI_PROFILE_OPEN_ALL); 3717*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 3718*719f82d3SEliot Blennerhassett hm.obj_index = profile_index; 3719*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3720*719f82d3SEliot Blennerhassett 3721*719f82d3SEliot Blennerhassett *pw_max_profiles = hr.u.p.u.o.max_profiles; 3722*719f82d3SEliot Blennerhassett if (hr.error == 0) 3723*719f82d3SEliot Blennerhassett *ph_profile = 3724*719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_PROFILE, adapter_index, 3725*719f82d3SEliot Blennerhassett profile_index); 3726*719f82d3SEliot Blennerhassett else 3727*719f82d3SEliot Blennerhassett *ph_profile = 0; 3728*719f82d3SEliot Blennerhassett return hr.error; 3729*719f82d3SEliot Blennerhassett } 3730*719f82d3SEliot Blennerhassett 3731*719f82d3SEliot Blennerhassett u16 hpi_profile_get(const struct hpi_hsubsys *ph_subsys, u32 h_profile, 3732*719f82d3SEliot Blennerhassett u16 bin_index, u16 *pw_seconds, u32 *pmicro_seconds, u32 *pcall_count, 3733*719f82d3SEliot Blennerhassett u32 *pmax_micro_seconds, u32 *pmin_micro_seconds) 3734*719f82d3SEliot Blennerhassett { 3735*719f82d3SEliot Blennerhassett struct hpi_message hm; 3736*719f82d3SEliot Blennerhassett struct hpi_response hr; 3737*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_GET); 3738*719f82d3SEliot Blennerhassett u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index); 3739*719f82d3SEliot Blennerhassett hm.u.p.bin_index = bin_index; 3740*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3741*719f82d3SEliot Blennerhassett if (pw_seconds) 3742*719f82d3SEliot Blennerhassett *pw_seconds = hr.u.p.u.t.seconds; 3743*719f82d3SEliot Blennerhassett if (pmicro_seconds) 3744*719f82d3SEliot Blennerhassett *pmicro_seconds = hr.u.p.u.t.micro_seconds; 3745*719f82d3SEliot Blennerhassett if (pcall_count) 3746*719f82d3SEliot Blennerhassett *pcall_count = hr.u.p.u.t.call_count; 3747*719f82d3SEliot Blennerhassett if (pmax_micro_seconds) 3748*719f82d3SEliot Blennerhassett *pmax_micro_seconds = hr.u.p.u.t.max_micro_seconds; 3749*719f82d3SEliot Blennerhassett if (pmin_micro_seconds) 3750*719f82d3SEliot Blennerhassett *pmin_micro_seconds = hr.u.p.u.t.min_micro_seconds; 3751*719f82d3SEliot Blennerhassett return hr.error; 3752*719f82d3SEliot Blennerhassett } 3753*719f82d3SEliot Blennerhassett 3754*719f82d3SEliot Blennerhassett u16 hpi_profile_get_utilization(const struct hpi_hsubsys *ph_subsys, 3755*719f82d3SEliot Blennerhassett u32 h_profile, u32 *putilization) 3756*719f82d3SEliot Blennerhassett { 3757*719f82d3SEliot Blennerhassett struct hpi_message hm; 3758*719f82d3SEliot Blennerhassett struct hpi_response hr; 3759*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, 3760*719f82d3SEliot Blennerhassett HPI_PROFILE_GET_UTILIZATION); 3761*719f82d3SEliot Blennerhassett u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index); 3762*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3763*719f82d3SEliot Blennerhassett if (hr.error) { 3764*719f82d3SEliot Blennerhassett if (putilization) 3765*719f82d3SEliot Blennerhassett *putilization = 0; 3766*719f82d3SEliot Blennerhassett } else { 3767*719f82d3SEliot Blennerhassett if (putilization) 3768*719f82d3SEliot Blennerhassett *putilization = hr.u.p.u.t.call_count; 3769*719f82d3SEliot Blennerhassett } 3770*719f82d3SEliot Blennerhassett return hr.error; 3771*719f82d3SEliot Blennerhassett } 3772*719f82d3SEliot Blennerhassett 3773*719f82d3SEliot Blennerhassett u16 hpi_profile_get_name(const struct hpi_hsubsys *ph_subsys, u32 h_profile, 3774*719f82d3SEliot Blennerhassett u16 bin_index, char *sz_name, u16 name_length) 3775*719f82d3SEliot Blennerhassett { 3776*719f82d3SEliot Blennerhassett struct hpi_message hm; 3777*719f82d3SEliot Blennerhassett struct hpi_response hr; 3778*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, 3779*719f82d3SEliot Blennerhassett HPI_PROFILE_GET_NAME); 3780*719f82d3SEliot Blennerhassett u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index); 3781*719f82d3SEliot Blennerhassett hm.u.p.bin_index = bin_index; 3782*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3783*719f82d3SEliot Blennerhassett if (hr.error) { 3784*719f82d3SEliot Blennerhassett if (sz_name) 3785*719f82d3SEliot Blennerhassett strcpy(sz_name, "??"); 3786*719f82d3SEliot Blennerhassett } else { 3787*719f82d3SEliot Blennerhassett if (sz_name) 3788*719f82d3SEliot Blennerhassett memcpy(sz_name, (char *)hr.u.p.u.n.sz_name, 3789*719f82d3SEliot Blennerhassett name_length); 3790*719f82d3SEliot Blennerhassett } 3791*719f82d3SEliot Blennerhassett return hr.error; 3792*719f82d3SEliot Blennerhassett } 3793*719f82d3SEliot Blennerhassett 3794*719f82d3SEliot Blennerhassett u16 hpi_profile_start_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile) 3795*719f82d3SEliot Blennerhassett { 3796*719f82d3SEliot Blennerhassett struct hpi_message hm; 3797*719f82d3SEliot Blennerhassett struct hpi_response hr; 3798*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, 3799*719f82d3SEliot Blennerhassett HPI_PROFILE_START_ALL); 3800*719f82d3SEliot Blennerhassett u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index); 3801*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3802*719f82d3SEliot Blennerhassett 3803*719f82d3SEliot Blennerhassett return hr.error; 3804*719f82d3SEliot Blennerhassett } 3805*719f82d3SEliot Blennerhassett 3806*719f82d3SEliot Blennerhassett u16 hpi_profile_stop_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile) 3807*719f82d3SEliot Blennerhassett { 3808*719f82d3SEliot Blennerhassett struct hpi_message hm; 3809*719f82d3SEliot Blennerhassett struct hpi_response hr; 3810*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, 3811*719f82d3SEliot Blennerhassett HPI_PROFILE_STOP_ALL); 3812*719f82d3SEliot Blennerhassett u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index); 3813*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3814*719f82d3SEliot Blennerhassett 3815*719f82d3SEliot Blennerhassett return hr.error; 3816*719f82d3SEliot Blennerhassett } 3817*719f82d3SEliot Blennerhassett 3818*719f82d3SEliot Blennerhassett u16 hpi_watchdog_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 3819*719f82d3SEliot Blennerhassett u32 *ph_watchdog) 3820*719f82d3SEliot Blennerhassett { 3821*719f82d3SEliot Blennerhassett struct hpi_message hm; 3822*719f82d3SEliot Blennerhassett struct hpi_response hr; 3823*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG, 3824*719f82d3SEliot Blennerhassett HPI_WATCHDOG_OPEN); 3825*719f82d3SEliot Blennerhassett hm.adapter_index = adapter_index; 3826*719f82d3SEliot Blennerhassett 3827*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3828*719f82d3SEliot Blennerhassett 3829*719f82d3SEliot Blennerhassett if (hr.error == 0) 3830*719f82d3SEliot Blennerhassett *ph_watchdog = 3831*719f82d3SEliot Blennerhassett hpi_indexes_to_handle(HPI_OBJ_WATCHDOG, adapter_index, 3832*719f82d3SEliot Blennerhassett 0); 3833*719f82d3SEliot Blennerhassett else 3834*719f82d3SEliot Blennerhassett *ph_watchdog = 0; 3835*719f82d3SEliot Blennerhassett return hr.error; 3836*719f82d3SEliot Blennerhassett } 3837*719f82d3SEliot Blennerhassett 3838*719f82d3SEliot Blennerhassett u16 hpi_watchdog_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog, 3839*719f82d3SEliot Blennerhassett u32 time_millisec) 3840*719f82d3SEliot Blennerhassett { 3841*719f82d3SEliot Blennerhassett struct hpi_message hm; 3842*719f82d3SEliot Blennerhassett struct hpi_response hr; 3843*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG, 3844*719f82d3SEliot Blennerhassett HPI_WATCHDOG_SET_TIME); 3845*719f82d3SEliot Blennerhassett u32TOINDEX(h_watchdog, &hm.adapter_index); 3846*719f82d3SEliot Blennerhassett hm.u.w.time_ms = time_millisec; 3847*719f82d3SEliot Blennerhassett 3848*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3849*719f82d3SEliot Blennerhassett 3850*719f82d3SEliot Blennerhassett return hr.error; 3851*719f82d3SEliot Blennerhassett } 3852*719f82d3SEliot Blennerhassett 3853*719f82d3SEliot Blennerhassett u16 hpi_watchdog_ping(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog) 3854*719f82d3SEliot Blennerhassett { 3855*719f82d3SEliot Blennerhassett struct hpi_message hm; 3856*719f82d3SEliot Blennerhassett struct hpi_response hr; 3857*719f82d3SEliot Blennerhassett hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG, 3858*719f82d3SEliot Blennerhassett HPI_WATCHDOG_PING); 3859*719f82d3SEliot Blennerhassett u32TOINDEX(h_watchdog, &hm.adapter_index); 3860*719f82d3SEliot Blennerhassett 3861*719f82d3SEliot Blennerhassett hpi_send_recv(&hm, &hr); 3862*719f82d3SEliot Blennerhassett 3863*719f82d3SEliot Blennerhassett return hr.error; 3864*719f82d3SEliot Blennerhassett } 3865