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