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