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