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