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