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