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