2 #include "hpi_internal.h"
3 #include "hpimsginit.h"
8 unsigned int obj_index:12;
9 unsigned int obj_type:4;
10 unsigned int adapter_index:14;
12 unsigned int read_only:1;
20 u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index,
21 const u16 object_index)
23 union handle_word handle;
25 handle.h.adapter_index = adapter_index;
27 handle.h.read_only = 0;
28 handle.h.obj_type = c_object;
29 handle.h.obj_index = object_index;
33 static u16 hpi_handle_indexes(const u32 h, u16 *p1, u16 *p2)
35 union handle_word uhandle;
37 return HPI_ERROR_INVALID_HANDLE;
41 *p1 = (u16)uhandle.h.adapter_index;
43 *p2 = (u16)uhandle.h.obj_index;
48 void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index,
51 hpi_handle_indexes(handle, pw_adapter_index, pw_object_index);
54 char hpi_handle_object(const u32 handle)
56 union handle_word uhandle;
58 return (char)uhandle.h.obj_type;
61 void hpi_format_to_msg(struct hpi_msg_format *pMF,
62 const struct hpi_format *pF)
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;
71 static void hpi_msg_to_format(struct hpi_format *pF,
72 struct hpi_msg_format *pMF)
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;
83 void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR)
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;
90 static inline void hpi_send_recvV1(struct hpi_message_header *m,
91 struct hpi_response_header *r)
93 hpi_send_recv((struct hpi_message *)m, (struct hpi_response *)r);
96 u16 hpi_subsys_get_version_ex(u32 *pversion_ex)
98 struct hpi_message hm;
99 struct hpi_response hr;
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;
108 u16 hpi_subsys_create_adapter(const struct hpi_resource *p_resource,
109 u16 *pw_adapter_index)
111 struct hpi_message hm;
112 struct hpi_response hr;
114 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
115 HPI_SUBSYS_CREATE_ADAPTER);
116 hm.u.s.resource = *p_resource;
118 hpi_send_recv(&hm, &hr);
120 *pw_adapter_index = hr.u.s.adapter_index;
124 u16 hpi_subsys_delete_adapter(u16 adapter_index)
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);
130 hm.obj_index = adapter_index;
131 hpi_send_recv(&hm, &hr);
135 u16 hpi_subsys_get_num_adapters(int *pn_num_adapters)
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;
146 u16 hpi_subsys_get_adapter(int iterator, u32 *padapter_index,
147 u16 *pw_adapter_type)
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);
153 hm.obj_index = (u16)iterator;
154 hpi_send_recv(&hm, &hr);
155 *padapter_index = (int)hr.u.s.adapter_index;
156 *pw_adapter_type = hr.u.s.adapter_type;
161 u16 hpi_adapter_open(u16 adapter_index)
163 struct hpi_message hm;
164 struct hpi_response hr;
165 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
167 hm.adapter_index = adapter_index;
169 hpi_send_recv(&hm, &hr);
175 u16 hpi_adapter_close(u16 adapter_index)
177 struct hpi_message hm;
178 struct hpi_response hr;
179 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
181 hm.adapter_index = adapter_index;
183 hpi_send_recv(&hm, &hr);
188 u16 hpi_adapter_set_mode(u16 adapter_index, u32 adapter_mode)
190 return hpi_adapter_set_mode_ex(adapter_index, adapter_mode,
191 HPI_ADAPTER_MODE_SET);
194 u16 hpi_adapter_set_mode_ex(u16 adapter_index, u32 adapter_mode,
197 struct hpi_message hm;
198 struct hpi_response hr;
200 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
201 HPI_ADAPTER_SET_MODE);
202 hm.adapter_index = adapter_index;
203 hm.u.ax.mode.adapter_mode = adapter_mode;
204 hm.u.ax.mode.query_or_set = query_or_set;
205 hpi_send_recv(&hm, &hr);
209 u16 hpi_adapter_get_mode(u16 adapter_index, u32 *padapter_mode)
211 struct hpi_message hm;
212 struct hpi_response hr;
213 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
214 HPI_ADAPTER_GET_MODE);
215 hm.adapter_index = adapter_index;
216 hpi_send_recv(&hm, &hr);
218 *padapter_mode = hr.u.ax.mode.adapter_mode;
222 u16 hpi_adapter_get_info(u16 adapter_index, u16 *pw_num_outstreams,
223 u16 *pw_num_instreams, u16 *pw_version, u32 *pserial_number,
224 u16 *pw_adapter_type)
226 struct hpi_message hm;
227 struct hpi_response hr;
228 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
229 HPI_ADAPTER_GET_INFO);
230 hm.adapter_index = adapter_index;
232 hpi_send_recv(&hm, &hr);
234 *pw_adapter_type = hr.u.ax.info.adapter_type;
235 *pw_num_outstreams = hr.u.ax.info.num_outstreams;
236 *pw_num_instreams = hr.u.ax.info.num_instreams;
237 *pw_version = hr.u.ax.info.version;
238 *pserial_number = hr.u.ax.info.serial_number;
242 u16 hpi_adapter_get_module_by_index(u16 adapter_index, u16 module_index,
243 u16 *pw_num_outputs, u16 *pw_num_inputs, u16 *pw_version,
244 u32 *pserial_number, u16 *pw_module_type, u32 *ph_module)
246 struct hpi_message hm;
247 struct hpi_response hr;
249 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
250 HPI_ADAPTER_MODULE_INFO);
251 hm.adapter_index = adapter_index;
252 hm.u.ax.module_info.index = module_index;
254 hpi_send_recv(&hm, &hr);
256 *pw_module_type = hr.u.ax.info.adapter_type;
257 *pw_num_outputs = hr.u.ax.info.num_outstreams;
258 *pw_num_inputs = hr.u.ax.info.num_instreams;
259 *pw_version = hr.u.ax.info.version;
260 *pserial_number = hr.u.ax.info.serial_number;
266 u16 hpi_adapter_set_property(u16 adapter_index, u16 property, u16 parameter1,
269 struct hpi_message hm;
270 struct hpi_response hr;
271 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
272 HPI_ADAPTER_SET_PROPERTY);
273 hm.adapter_index = adapter_index;
274 hm.u.ax.property_set.property = property;
275 hm.u.ax.property_set.parameter1 = parameter1;
276 hm.u.ax.property_set.parameter2 = parameter2;
278 hpi_send_recv(&hm, &hr);
283 u16 hpi_adapter_get_property(u16 adapter_index, u16 property,
284 u16 *pw_parameter1, u16 *pw_parameter2)
286 struct hpi_message hm;
287 struct hpi_response hr;
288 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
289 HPI_ADAPTER_GET_PROPERTY);
290 hm.adapter_index = adapter_index;
291 hm.u.ax.property_set.property = property;
293 hpi_send_recv(&hm, &hr);
296 *pw_parameter1 = hr.u.ax.property_get.parameter1;
298 *pw_parameter2 = hr.u.ax.property_get.parameter2;
304 u16 hpi_adapter_enumerate_property(u16 adapter_index, u16 index,
305 u16 what_to_enumerate, u16 property_index, u32 *psetting)
310 u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
311 u32 sample_rate, u32 bit_rate, u32 attributes)
314 struct hpi_msg_format fmt;
325 error = HPI_ERROR_INVALID_CHANNELS;
328 fmt.channels = channels;
331 case HPI_FORMAT_PCM16_SIGNED:
332 case HPI_FORMAT_PCM24_SIGNED:
333 case HPI_FORMAT_PCM32_SIGNED:
334 case HPI_FORMAT_PCM32_FLOAT:
335 case HPI_FORMAT_PCM16_BIGENDIAN:
336 case HPI_FORMAT_PCM8_UNSIGNED:
337 case HPI_FORMAT_MPEG_L1:
338 case HPI_FORMAT_MPEG_L2:
339 case HPI_FORMAT_MPEG_L3:
340 case HPI_FORMAT_DOLBY_AC2:
341 case HPI_FORMAT_AA_TAGIT1_HITS:
342 case HPI_FORMAT_AA_TAGIT1_INSERTS:
343 case HPI_FORMAT_RAW_BITSTREAM:
344 case HPI_FORMAT_AA_TAGIT1_HITS_EX1:
345 case HPI_FORMAT_OEM1:
346 case HPI_FORMAT_OEM2:
349 error = HPI_ERROR_INVALID_FORMAT;
354 if (sample_rate < 8000L) {
355 error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
358 if (sample_rate > 200000L) {
359 error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
360 sample_rate = 200000L;
362 fmt.sample_rate = sample_rate;
365 case HPI_FORMAT_MPEG_L1:
366 case HPI_FORMAT_MPEG_L2:
367 case HPI_FORMAT_MPEG_L3:
368 fmt.bit_rate = bit_rate;
370 case HPI_FORMAT_PCM16_SIGNED:
371 case HPI_FORMAT_PCM16_BIGENDIAN:
372 fmt.bit_rate = channels * sample_rate * 2;
374 case HPI_FORMAT_PCM32_SIGNED:
375 case HPI_FORMAT_PCM32_FLOAT:
376 fmt.bit_rate = channels * sample_rate * 4;
378 case HPI_FORMAT_PCM8_UNSIGNED:
379 fmt.bit_rate = channels * sample_rate;
386 case HPI_FORMAT_MPEG_L2:
388 && (attributes != HPI_MPEG_MODE_DEFAULT)) {
389 attributes = HPI_MPEG_MODE_DEFAULT;
390 error = HPI_ERROR_INVALID_FORMAT;
391 } else if (attributes > HPI_MPEG_MODE_DUALCHANNEL) {
392 attributes = HPI_MPEG_MODE_DEFAULT;
393 error = HPI_ERROR_INVALID_FORMAT;
395 fmt.attributes = attributes;
398 fmt.attributes = attributes;
401 hpi_msg_to_format(p_format, &fmt);
405 u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format,
406 u32 host_polling_rate_in_milli_seconds, u32 *recommended_buffer_size)
409 u32 bytes_per_second;
412 struct hpi_format *pF = p_format;
414 channels = pF->channels;
416 switch (pF->format) {
417 case HPI_FORMAT_PCM16_BIGENDIAN:
418 case HPI_FORMAT_PCM16_SIGNED:
419 bytes_per_second = pF->sample_rate * 2L * channels;
421 case HPI_FORMAT_PCM24_SIGNED:
422 bytes_per_second = pF->sample_rate * 3L * channels;
424 case HPI_FORMAT_PCM32_SIGNED:
425 case HPI_FORMAT_PCM32_FLOAT:
426 bytes_per_second = pF->sample_rate * 4L * channels;
428 case HPI_FORMAT_PCM8_UNSIGNED:
429 bytes_per_second = pF->sample_rate * 1L * channels;
431 case HPI_FORMAT_MPEG_L1:
432 case HPI_FORMAT_MPEG_L2:
433 case HPI_FORMAT_MPEG_L3:
434 bytes_per_second = pF->bit_rate / 8L;
436 case HPI_FORMAT_DOLBY_AC2:
438 bytes_per_second = 256000L / 8L;
441 return HPI_ERROR_INVALID_FORMAT;
443 size = (bytes_per_second * host_polling_rate_in_milli_seconds * 2) /
446 *recommended_buffer_size =
447 roundup_pow_of_two(((size + 4095L) & ~4095L));
451 u16 hpi_outstream_open(u16 adapter_index, u16 outstream_index,
454 struct hpi_message hm;
455 struct hpi_response hr;
456 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
458 hm.adapter_index = adapter_index;
459 hm.obj_index = outstream_index;
461 hpi_send_recv(&hm, &hr);
465 hpi_indexes_to_handle(HPI_OBJ_OSTREAM, adapter_index,
472 u16 hpi_outstream_close(u32 h_outstream)
474 struct hpi_message hm;
475 struct hpi_response hr;
477 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
478 HPI_OSTREAM_HOSTBUFFER_FREE);
479 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
480 return HPI_ERROR_INVALID_HANDLE;
482 hpi_send_recv(&hm, &hr);
484 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
485 HPI_OSTREAM_GROUP_RESET);
486 hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index);
487 hpi_send_recv(&hm, &hr);
489 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
491 hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index);
492 hpi_send_recv(&hm, &hr);
497 u16 hpi_outstream_get_info_ex(u32 h_outstream, u16 *pw_state,
498 u32 *pbuffer_size, u32 *pdata_to_play, u32 *psamples_played,
499 u32 *pauxiliary_data_to_play)
501 struct hpi_message hm;
502 struct hpi_response hr;
503 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
504 HPI_OSTREAM_GET_INFO);
505 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
506 return HPI_ERROR_INVALID_HANDLE;
508 hpi_send_recv(&hm, &hr);
511 *pw_state = hr.u.d.u.stream_info.state;
513 *pbuffer_size = hr.u.d.u.stream_info.buffer_size;
515 *pdata_to_play = hr.u.d.u.stream_info.data_available;
517 *psamples_played = hr.u.d.u.stream_info.samples_transferred;
518 if (pauxiliary_data_to_play)
519 *pauxiliary_data_to_play =
520 hr.u.d.u.stream_info.auxiliary_data_available;
524 u16 hpi_outstream_write_buf(u32 h_outstream, const u8 *pb_data,
525 u32 bytes_to_write, const struct hpi_format *p_format)
527 struct hpi_message hm;
528 struct hpi_response hr;
529 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
531 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
532 return HPI_ERROR_INVALID_HANDLE;
533 hm.u.d.u.data.pb_data = (u8 *)pb_data;
534 hm.u.d.u.data.data_size = bytes_to_write;
536 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
538 hpi_send_recv(&hm, &hr);
543 u16 hpi_outstream_start(u32 h_outstream)
545 struct hpi_message hm;
546 struct hpi_response hr;
547 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
549 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
550 return HPI_ERROR_INVALID_HANDLE;
552 hpi_send_recv(&hm, &hr);
557 u16 hpi_outstream_wait_start(u32 h_outstream)
559 struct hpi_message hm;
560 struct hpi_response hr;
561 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
562 HPI_OSTREAM_WAIT_START);
563 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
564 return HPI_ERROR_INVALID_HANDLE;
566 hpi_send_recv(&hm, &hr);
571 u16 hpi_outstream_stop(u32 h_outstream)
573 struct hpi_message hm;
574 struct hpi_response hr;
575 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
577 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
578 return HPI_ERROR_INVALID_HANDLE;
580 hpi_send_recv(&hm, &hr);
585 u16 hpi_outstream_sinegen(u32 h_outstream)
587 struct hpi_message hm;
588 struct hpi_response hr;
589 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
590 HPI_OSTREAM_SINEGEN);
591 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
592 return HPI_ERROR_INVALID_HANDLE;
594 hpi_send_recv(&hm, &hr);
599 u16 hpi_outstream_reset(u32 h_outstream)
601 struct hpi_message hm;
602 struct hpi_response hr;
603 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
605 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
606 return HPI_ERROR_INVALID_HANDLE;
608 hpi_send_recv(&hm, &hr);
613 u16 hpi_outstream_query_format(u32 h_outstream, struct hpi_format *p_format)
615 struct hpi_message hm;
616 struct hpi_response hr;
618 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
619 HPI_OSTREAM_QUERY_FORMAT);
620 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
621 return HPI_ERROR_INVALID_HANDLE;
623 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
625 hpi_send_recv(&hm, &hr);
630 u16 hpi_outstream_set_format(u32 h_outstream, struct hpi_format *p_format)
632 struct hpi_message hm;
633 struct hpi_response hr;
635 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
636 HPI_OSTREAM_SET_FORMAT);
637 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
638 return HPI_ERROR_INVALID_HANDLE;
640 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
642 hpi_send_recv(&hm, &hr);
647 u16 hpi_outstream_set_velocity(u32 h_outstream, short velocity)
649 struct hpi_message hm;
650 struct hpi_response hr;
652 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
653 HPI_OSTREAM_SET_VELOCITY);
654 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
655 return HPI_ERROR_INVALID_HANDLE;
656 hm.u.d.u.velocity = velocity;
658 hpi_send_recv(&hm, &hr);
663 u16 hpi_outstream_set_punch_in_out(u32 h_outstream, u32 punch_in_sample,
664 u32 punch_out_sample)
666 struct hpi_message hm;
667 struct hpi_response hr;
669 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
670 HPI_OSTREAM_SET_PUNCHINOUT);
671 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
672 return HPI_ERROR_INVALID_HANDLE;
674 hm.u.d.u.pio.punch_in_sample = punch_in_sample;
675 hm.u.d.u.pio.punch_out_sample = punch_out_sample;
677 hpi_send_recv(&hm, &hr);
682 u16 hpi_outstream_ancillary_reset(u32 h_outstream, u16 mode)
684 struct hpi_message hm;
685 struct hpi_response hr;
687 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
688 HPI_OSTREAM_ANC_RESET);
689 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
690 return HPI_ERROR_INVALID_HANDLE;
691 hm.u.d.u.data.format.channels = mode;
692 hpi_send_recv(&hm, &hr);
696 u16 hpi_outstream_ancillary_get_info(u32 h_outstream, u32 *pframes_available)
698 struct hpi_message hm;
699 struct hpi_response hr;
701 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
702 HPI_OSTREAM_ANC_GET_INFO);
703 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
704 return HPI_ERROR_INVALID_HANDLE;
705 hpi_send_recv(&hm, &hr);
707 if (pframes_available)
709 hr.u.d.u.stream_info.data_available /
710 sizeof(struct hpi_anc_frame);
715 u16 hpi_outstream_ancillary_read(u32 h_outstream,
716 struct hpi_anc_frame *p_anc_frame_buffer,
717 u32 anc_frame_buffer_size_in_bytes,
718 u32 number_of_ancillary_frames_to_read)
720 struct hpi_message hm;
721 struct hpi_response hr;
723 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
724 HPI_OSTREAM_ANC_READ);
725 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
726 return HPI_ERROR_INVALID_HANDLE;
727 hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer;
728 hm.u.d.u.data.data_size =
729 number_of_ancillary_frames_to_read *
730 sizeof(struct hpi_anc_frame);
731 if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes)
732 hpi_send_recv(&hm, &hr);
734 hr.error = HPI_ERROR_INVALID_DATASIZE;
738 u16 hpi_outstream_set_time_scale(u32 h_outstream, u32 time_scale)
740 struct hpi_message hm;
741 struct hpi_response hr;
743 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
744 HPI_OSTREAM_SET_TIMESCALE);
745 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
746 return HPI_ERROR_INVALID_HANDLE;
748 hm.u.d.u.time_scale = time_scale;
750 hpi_send_recv(&hm, &hr);
755 u16 hpi_outstream_host_buffer_allocate(u32 h_outstream, u32 size_in_bytes)
757 struct hpi_message hm;
758 struct hpi_response hr;
760 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
761 HPI_OSTREAM_HOSTBUFFER_ALLOC);
762 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
763 return HPI_ERROR_INVALID_HANDLE;
764 hm.u.d.u.data.data_size = size_in_bytes;
765 hpi_send_recv(&hm, &hr);
769 u16 hpi_outstream_host_buffer_get_info(u32 h_outstream, u8 **pp_buffer,
770 struct hpi_hostbuffer_status **pp_status)
772 struct hpi_message hm;
773 struct hpi_response hr;
775 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
776 HPI_OSTREAM_HOSTBUFFER_GET_INFO);
777 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
778 return HPI_ERROR_INVALID_HANDLE;
779 hpi_send_recv(&hm, &hr);
783 *pp_buffer = hr.u.d.u.hostbuffer_info.p_buffer;
785 *pp_status = hr.u.d.u.hostbuffer_info.p_status;
790 u16 hpi_outstream_host_buffer_free(u32 h_outstream)
792 struct hpi_message hm;
793 struct hpi_response hr;
795 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
796 HPI_OSTREAM_HOSTBUFFER_FREE);
797 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
798 return HPI_ERROR_INVALID_HANDLE;
799 hpi_send_recv(&hm, &hr);
803 u16 hpi_outstream_group_add(u32 h_outstream, u32 h_stream)
805 struct hpi_message hm;
806 struct hpi_response hr;
810 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
811 HPI_OSTREAM_GROUP_ADD);
813 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
814 return HPI_ERROR_INVALID_HANDLE;
816 if (hpi_handle_indexes(h_stream, &adapter,
817 &hm.u.d.u.stream.stream_index))
818 return HPI_ERROR_INVALID_HANDLE;
820 c_obj_type = hpi_handle_object(h_stream);
821 switch (c_obj_type) {
822 case HPI_OBJ_OSTREAM:
823 case HPI_OBJ_ISTREAM:
824 hm.u.d.u.stream.object_type = c_obj_type;
827 return HPI_ERROR_INVALID_OBJ;
829 if (adapter != hm.adapter_index)
830 return HPI_ERROR_NO_INTERADAPTER_GROUPS;
832 hpi_send_recv(&hm, &hr);
836 u16 hpi_outstream_group_get_map(u32 h_outstream, u32 *poutstream_map,
839 struct hpi_message hm;
840 struct hpi_response hr;
842 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
843 HPI_OSTREAM_GROUP_GETMAP);
844 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
845 return HPI_ERROR_INVALID_HANDLE;
846 hpi_send_recv(&hm, &hr);
849 *poutstream_map = hr.u.d.u.group_info.outstream_group_map;
851 *pinstream_map = hr.u.d.u.group_info.instream_group_map;
856 u16 hpi_outstream_group_reset(u32 h_outstream)
858 struct hpi_message hm;
859 struct hpi_response hr;
861 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
862 HPI_OSTREAM_GROUP_RESET);
863 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
864 return HPI_ERROR_INVALID_HANDLE;
865 hpi_send_recv(&hm, &hr);
869 u16 hpi_instream_open(u16 adapter_index, u16 instream_index, u32 *ph_instream)
871 struct hpi_message hm;
872 struct hpi_response hr;
874 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
876 hm.adapter_index = adapter_index;
877 hm.obj_index = instream_index;
879 hpi_send_recv(&hm, &hr);
883 hpi_indexes_to_handle(HPI_OBJ_ISTREAM, adapter_index,
891 u16 hpi_instream_close(u32 h_instream)
893 struct hpi_message hm;
894 struct hpi_response hr;
896 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
897 HPI_ISTREAM_HOSTBUFFER_FREE);
898 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
899 return HPI_ERROR_INVALID_HANDLE;
900 hpi_send_recv(&hm, &hr);
902 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
903 HPI_ISTREAM_GROUP_RESET);
904 hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index);
905 hpi_send_recv(&hm, &hr);
907 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
909 hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index);
910 hpi_send_recv(&hm, &hr);
915 u16 hpi_instream_query_format(u32 h_instream,
916 const struct hpi_format *p_format)
918 struct hpi_message hm;
919 struct hpi_response hr;
921 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
922 HPI_ISTREAM_QUERY_FORMAT);
923 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
924 return HPI_ERROR_INVALID_HANDLE;
925 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
927 hpi_send_recv(&hm, &hr);
932 u16 hpi_instream_set_format(u32 h_instream, const struct hpi_format *p_format)
934 struct hpi_message hm;
935 struct hpi_response hr;
937 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
938 HPI_ISTREAM_SET_FORMAT);
939 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
940 return HPI_ERROR_INVALID_HANDLE;
941 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
943 hpi_send_recv(&hm, &hr);
948 u16 hpi_instream_read_buf(u32 h_instream, u8 *pb_data, u32 bytes_to_read)
950 struct hpi_message hm;
951 struct hpi_response hr;
953 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
955 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
956 return HPI_ERROR_INVALID_HANDLE;
957 hm.u.d.u.data.data_size = bytes_to_read;
958 hm.u.d.u.data.pb_data = pb_data;
960 hpi_send_recv(&hm, &hr);
965 u16 hpi_instream_start(u32 h_instream)
967 struct hpi_message hm;
968 struct hpi_response hr;
970 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
972 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
973 return HPI_ERROR_INVALID_HANDLE;
975 hpi_send_recv(&hm, &hr);
980 u16 hpi_instream_wait_start(u32 h_instream)
982 struct hpi_message hm;
983 struct hpi_response hr;
985 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
986 HPI_ISTREAM_WAIT_START);
987 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
988 return HPI_ERROR_INVALID_HANDLE;
990 hpi_send_recv(&hm, &hr);
995 u16 hpi_instream_stop(u32 h_instream)
997 struct hpi_message hm;
998 struct hpi_response hr;
1000 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1002 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1003 return HPI_ERROR_INVALID_HANDLE;
1005 hpi_send_recv(&hm, &hr);
1010 u16 hpi_instream_reset(u32 h_instream)
1012 struct hpi_message hm;
1013 struct hpi_response hr;
1015 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1017 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1018 return HPI_ERROR_INVALID_HANDLE;
1020 hpi_send_recv(&hm, &hr);
1025 u16 hpi_instream_get_info_ex(u32 h_instream, u16 *pw_state, u32 *pbuffer_size,
1026 u32 *pdata_recorded, u32 *psamples_recorded,
1027 u32 *pauxiliary_data_recorded)
1029 struct hpi_message hm;
1030 struct hpi_response hr;
1031 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1032 HPI_ISTREAM_GET_INFO);
1033 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1034 return HPI_ERROR_INVALID_HANDLE;
1036 hpi_send_recv(&hm, &hr);
1039 *pw_state = hr.u.d.u.stream_info.state;
1041 *pbuffer_size = hr.u.d.u.stream_info.buffer_size;
1043 *pdata_recorded = hr.u.d.u.stream_info.data_available;
1044 if (psamples_recorded)
1045 *psamples_recorded = hr.u.d.u.stream_info.samples_transferred;
1046 if (pauxiliary_data_recorded)
1047 *pauxiliary_data_recorded =
1048 hr.u.d.u.stream_info.auxiliary_data_available;
1052 u16 hpi_instream_ancillary_reset(u32 h_instream, u16 bytes_per_frame,
1053 u16 mode, u16 alignment, u16 idle_bit)
1055 struct hpi_message hm;
1056 struct hpi_response hr;
1057 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1058 HPI_ISTREAM_ANC_RESET);
1059 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1060 return HPI_ERROR_INVALID_HANDLE;
1061 hm.u.d.u.data.format.attributes = bytes_per_frame;
1062 hm.u.d.u.data.format.format = (mode << 8) | (alignment & 0xff);
1063 hm.u.d.u.data.format.channels = idle_bit;
1064 hpi_send_recv(&hm, &hr);
1068 u16 hpi_instream_ancillary_get_info(u32 h_instream, u32 *pframe_space)
1070 struct hpi_message hm;
1071 struct hpi_response hr;
1072 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1073 HPI_ISTREAM_ANC_GET_INFO);
1074 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1075 return HPI_ERROR_INVALID_HANDLE;
1076 hpi_send_recv(&hm, &hr);
1079 (hr.u.d.u.stream_info.buffer_size -
1080 hr.u.d.u.stream_info.data_available) /
1081 sizeof(struct hpi_anc_frame);
1085 u16 hpi_instream_ancillary_write(u32 h_instream,
1086 const struct hpi_anc_frame *p_anc_frame_buffer,
1087 u32 anc_frame_buffer_size_in_bytes,
1088 u32 number_of_ancillary_frames_to_write)
1090 struct hpi_message hm;
1091 struct hpi_response hr;
1093 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1094 HPI_ISTREAM_ANC_WRITE);
1095 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1096 return HPI_ERROR_INVALID_HANDLE;
1097 hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer;
1098 hm.u.d.u.data.data_size =
1099 number_of_ancillary_frames_to_write *
1100 sizeof(struct hpi_anc_frame);
1101 if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes)
1102 hpi_send_recv(&hm, &hr);
1104 hr.error = HPI_ERROR_INVALID_DATASIZE;
1108 u16 hpi_instream_host_buffer_allocate(u32 h_instream, u32 size_in_bytes)
1111 struct hpi_message hm;
1112 struct hpi_response hr;
1114 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1115 HPI_ISTREAM_HOSTBUFFER_ALLOC);
1116 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1117 return HPI_ERROR_INVALID_HANDLE;
1118 hm.u.d.u.data.data_size = size_in_bytes;
1119 hpi_send_recv(&hm, &hr);
1123 u16 hpi_instream_host_buffer_get_info(u32 h_instream, u8 **pp_buffer,
1124 struct hpi_hostbuffer_status **pp_status)
1126 struct hpi_message hm;
1127 struct hpi_response hr;
1129 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1130 HPI_ISTREAM_HOSTBUFFER_GET_INFO);
1131 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1132 return HPI_ERROR_INVALID_HANDLE;
1133 hpi_send_recv(&hm, &hr);
1135 if (hr.error == 0) {
1137 *pp_buffer = hr.u.d.u.hostbuffer_info.p_buffer;
1139 *pp_status = hr.u.d.u.hostbuffer_info.p_status;
1144 u16 hpi_instream_host_buffer_free(u32 h_instream)
1147 struct hpi_message hm;
1148 struct hpi_response hr;
1150 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1151 HPI_ISTREAM_HOSTBUFFER_FREE);
1152 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1153 return HPI_ERROR_INVALID_HANDLE;
1154 hpi_send_recv(&hm, &hr);
1158 u16 hpi_instream_group_add(u32 h_instream, u32 h_stream)
1160 struct hpi_message hm;
1161 struct hpi_response hr;
1165 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1166 HPI_ISTREAM_GROUP_ADD);
1169 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1170 return HPI_ERROR_INVALID_HANDLE;
1172 if (hpi_handle_indexes(h_stream, &adapter,
1173 &hm.u.d.u.stream.stream_index))
1174 return HPI_ERROR_INVALID_HANDLE;
1176 c_obj_type = hpi_handle_object(h_stream);
1178 switch (c_obj_type) {
1179 case HPI_OBJ_OSTREAM:
1180 case HPI_OBJ_ISTREAM:
1181 hm.u.d.u.stream.object_type = c_obj_type;
1184 return HPI_ERROR_INVALID_OBJ;
1187 if (adapter != hm.adapter_index)
1188 return HPI_ERROR_NO_INTERADAPTER_GROUPS;
1190 hpi_send_recv(&hm, &hr);
1194 u16 hpi_instream_group_get_map(u32 h_instream, u32 *poutstream_map,
1197 struct hpi_message hm;
1198 struct hpi_response hr;
1200 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1201 HPI_ISTREAM_HOSTBUFFER_FREE);
1202 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1203 return HPI_ERROR_INVALID_HANDLE;
1204 hpi_send_recv(&hm, &hr);
1207 *poutstream_map = hr.u.d.u.group_info.outstream_group_map;
1209 *pinstream_map = hr.u.d.u.group_info.instream_group_map;
1214 u16 hpi_instream_group_reset(u32 h_instream)
1216 struct hpi_message hm;
1217 struct hpi_response hr;
1219 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1220 HPI_ISTREAM_GROUP_RESET);
1221 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1222 return HPI_ERROR_INVALID_HANDLE;
1223 hpi_send_recv(&hm, &hr);
1227 u16 hpi_mixer_open(u16 adapter_index, u32 *ph_mixer)
1229 struct hpi_message hm;
1230 struct hpi_response hr;
1231 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN);
1232 hm.adapter_index = adapter_index;
1234 hpi_send_recv(&hm, &hr);
1238 hpi_indexes_to_handle(HPI_OBJ_MIXER, adapter_index,
1245 u16 hpi_mixer_close(u32 h_mixer)
1247 struct hpi_message hm;
1248 struct hpi_response hr;
1250 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE);
1251 if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1252 return HPI_ERROR_INVALID_HANDLE;
1254 hpi_send_recv(&hm, &hr);
1258 u16 hpi_mixer_get_control(u32 h_mixer, u16 src_node_type,
1259 u16 src_node_type_index, u16 dst_node_type, u16 dst_node_type_index,
1260 u16 control_type, u32 *ph_control)
1262 struct hpi_message hm;
1263 struct hpi_response hr;
1264 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER,
1265 HPI_MIXER_GET_CONTROL);
1266 if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1267 return HPI_ERROR_INVALID_HANDLE;
1268 hm.u.m.node_type1 = src_node_type;
1269 hm.u.m.node_index1 = src_node_type_index;
1270 hm.u.m.node_type2 = dst_node_type;
1271 hm.u.m.node_index2 = dst_node_type_index;
1272 hm.u.m.control_type = control_type;
1274 hpi_send_recv(&hm, &hr);
1278 hpi_indexes_to_handle(HPI_OBJ_CONTROL,
1279 hm.adapter_index, hr.u.m.control_index);
1285 u16 hpi_mixer_get_control_by_index(u32 h_mixer, u16 control_index,
1286 u16 *pw_src_node_type, u16 *pw_src_node_index, u16 *pw_dst_node_type,
1287 u16 *pw_dst_node_index, u16 *pw_control_type, u32 *ph_control)
1289 struct hpi_message hm;
1290 struct hpi_response hr;
1291 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER,
1292 HPI_MIXER_GET_CONTROL_BY_INDEX);
1293 if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1294 return HPI_ERROR_INVALID_HANDLE;
1295 hm.u.m.control_index = control_index;
1296 hpi_send_recv(&hm, &hr);
1298 if (pw_src_node_type) {
1300 hr.u.m.src_node_type + HPI_SOURCENODE_NONE;
1301 *pw_src_node_index = hr.u.m.src_node_index;
1302 *pw_dst_node_type = hr.u.m.dst_node_type + HPI_DESTNODE_NONE;
1303 *pw_dst_node_index = hr.u.m.dst_node_index;
1305 if (pw_control_type)
1306 *pw_control_type = hr.u.m.control_index;
1311 hpi_indexes_to_handle(HPI_OBJ_CONTROL,
1312 hm.adapter_index, control_index);
1319 u16 hpi_mixer_store(u32 h_mixer, enum HPI_MIXER_STORE_COMMAND command,
1322 struct hpi_message hm;
1323 struct hpi_response hr;
1324 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_STORE);
1325 if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1326 return HPI_ERROR_INVALID_HANDLE;
1327 hm.u.mx.store.command = command;
1328 hm.u.mx.store.index = index;
1329 hpi_send_recv(&hm, &hr);
1334 u16 hpi_control_param_set(const u32 h_control, const u16 attrib,
1335 const u32 param1, const u32 param2)
1337 struct hpi_message hm;
1338 struct hpi_response hr;
1340 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1341 HPI_CONTROL_SET_STATE);
1342 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1343 return HPI_ERROR_INVALID_HANDLE;
1344 hm.u.c.attribute = attrib;
1345 hm.u.c.param1 = param1;
1346 hm.u.c.param2 = param2;
1347 hpi_send_recv(&hm, &hr);
1351 static u16 hpi_control_log_set2(u32 h_control, u16 attrib, short sv0,
1354 struct hpi_message hm;
1355 struct hpi_response hr;
1357 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1358 HPI_CONTROL_SET_STATE);
1359 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1360 return HPI_ERROR_INVALID_HANDLE;
1361 hm.u.c.attribute = attrib;
1362 hm.u.c.an_log_value[0] = sv0;
1363 hm.u.c.an_log_value[1] = sv1;
1364 hpi_send_recv(&hm, &hr);
1369 u16 hpi_control_param_get(const u32 h_control, const u16 attrib, u32 param1,
1370 u32 param2, u32 *pparam1, u32 *pparam2)
1372 struct hpi_message hm;
1373 struct hpi_response hr;
1375 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1376 HPI_CONTROL_GET_STATE);
1377 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1378 return HPI_ERROR_INVALID_HANDLE;
1379 hm.u.c.attribute = attrib;
1380 hm.u.c.param1 = param1;
1381 hm.u.c.param2 = param2;
1382 hpi_send_recv(&hm, &hr);
1384 *pparam1 = hr.u.c.param1;
1386 *pparam2 = hr.u.c.param2;
1391 #define hpi_control_param1_get(h, a, p1) \
1392 hpi_control_param_get(h, a, 0, 0, p1, NULL)
1393 #define hpi_control_param2_get(h, a, p1, p2) \
1394 hpi_control_param_get(h, a, 0, 0, p1, p2)
1396 static u16 hpi_control_log_get2(u32 h_control, u16 attrib, short *sv0,
1399 struct hpi_message hm;
1400 struct hpi_response hr;
1401 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1402 HPI_CONTROL_GET_STATE);
1403 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1404 return HPI_ERROR_INVALID_HANDLE;
1405 hm.u.c.attribute = attrib;
1407 hpi_send_recv(&hm, &hr);
1408 *sv0 = hr.u.c.an_log_value[0];
1410 *sv1 = hr.u.c.an_log_value[1];
1415 u16 hpi_control_query(const u32 h_control, const u16 attrib, const u32 index,
1416 const u32 param, u32 *psetting)
1418 struct hpi_message hm;
1419 struct hpi_response hr;
1421 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1422 HPI_CONTROL_GET_INFO);
1423 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1424 return HPI_ERROR_INVALID_HANDLE;
1426 hm.u.c.attribute = attrib;
1427 hm.u.c.param1 = index;
1428 hm.u.c.param2 = param;
1430 hpi_send_recv(&hm, &hr);
1431 *psetting = hr.u.c.param1;
1436 static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1437 char *psz_string, const u32 string_length)
1439 unsigned int sub_string_index = 0, j = 0;
1444 if ((string_length < 1) || (string_length > 256))
1445 return HPI_ERROR_INVALID_CONTROL_VALUE;
1446 for (sub_string_index = 0; sub_string_index < string_length;
1447 sub_string_index += 8) {
1448 struct hpi_message hm;
1449 struct hpi_response hr;
1451 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1452 HPI_CONTROL_GET_STATE);
1453 if (hpi_handle_indexes(h_control, &hm.adapter_index,
1455 return HPI_ERROR_INVALID_HANDLE;
1456 hm.u.c.attribute = attribute;
1457 hm.u.c.param1 = sub_string_index;
1459 hpi_send_recv(&hm, &hr);
1461 if (sub_string_index == 0
1462 && (hr.u.cu.chars8.remaining_chars + 8) >
1464 return HPI_ERROR_INVALID_CONTROL_VALUE;
1470 for (j = 0; j < 8; j++) {
1471 c = hr.u.cu.chars8.sz_data[j];
1472 psz_string[sub_string_index + j] = c;
1474 if (n >= string_length) {
1475 psz_string[string_length - 1] = 0;
1476 err = HPI_ERROR_INVALID_CONTROL_VALUE;
1483 if ((hr.u.cu.chars8.remaining_chars == 0)
1484 && ((sub_string_index + j) < string_length)
1487 psz_string[sub_string_index + j] = c;
1495 u16 hpi_aesebu_receiver_query_format(const u32 h_aes_rx, const u32 index,
1501 err = hpi_control_query(h_aes_rx, HPI_AESEBURX_FORMAT, index, 0, &qr);
1502 *pw_format = (u16)qr;
1506 u16 hpi_aesebu_receiver_set_format(u32 h_control, u16 format)
1508 return hpi_control_param_set(h_control, HPI_AESEBURX_FORMAT, format,
1512 u16 hpi_aesebu_receiver_get_format(u32 h_control, u16 *pw_format)
1517 err = hpi_control_param1_get(h_control, HPI_AESEBURX_FORMAT, ¶m);
1518 if (!err && pw_format)
1519 *pw_format = (u16)param;
1524 u16 hpi_aesebu_receiver_get_sample_rate(u32 h_control, u32 *psample_rate)
1526 return hpi_control_param1_get(h_control, HPI_AESEBURX_SAMPLERATE,
1530 u16 hpi_aesebu_receiver_get_user_data(u32 h_control, u16 index, u16 *pw_data)
1532 struct hpi_message hm;
1533 struct hpi_response hr;
1534 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1535 HPI_CONTROL_GET_STATE);
1536 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1537 return HPI_ERROR_INVALID_HANDLE;
1538 hm.u.c.attribute = HPI_AESEBURX_USERDATA;
1539 hm.u.c.param1 = index;
1541 hpi_send_recv(&hm, &hr);
1544 *pw_data = (u16)hr.u.c.param2;
1548 u16 hpi_aesebu_receiver_get_channel_status(u32 h_control, u16 index,
1551 struct hpi_message hm;
1552 struct hpi_response hr;
1553 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1554 HPI_CONTROL_GET_STATE);
1555 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1556 return HPI_ERROR_INVALID_HANDLE;
1557 hm.u.c.attribute = HPI_AESEBURX_CHANNELSTATUS;
1558 hm.u.c.param1 = index;
1560 hpi_send_recv(&hm, &hr);
1563 *pw_data = (u16)hr.u.c.param2;
1567 u16 hpi_aesebu_receiver_get_error_status(u32 h_control, u16 *pw_error_data)
1572 error = hpi_control_param1_get(h_control, HPI_AESEBURX_ERRORSTATUS,
1575 *pw_error_data = (u16)error_data;
1579 u16 hpi_aesebu_transmitter_set_sample_rate(u32 h_control, u32 sample_rate)
1581 return hpi_control_param_set(h_control, HPI_AESEBUTX_SAMPLERATE,
1585 u16 hpi_aesebu_transmitter_set_user_data(u32 h_control, u16 index, u16 data)
1587 return hpi_control_param_set(h_control, HPI_AESEBUTX_USERDATA, index,
1591 u16 hpi_aesebu_transmitter_set_channel_status(u32 h_control, u16 index,
1594 return hpi_control_param_set(h_control, HPI_AESEBUTX_CHANNELSTATUS,
1598 u16 hpi_aesebu_transmitter_get_channel_status(u32 h_control, u16 index,
1601 return HPI_ERROR_INVALID_OPERATION;
1604 u16 hpi_aesebu_transmitter_query_format(const u32 h_aes_tx, const u32 index,
1610 err = hpi_control_query(h_aes_tx, HPI_AESEBUTX_FORMAT, index, 0, &qr);
1611 *pw_format = (u16)qr;
1615 u16 hpi_aesebu_transmitter_set_format(u32 h_control, u16 output_format)
1617 return hpi_control_param_set(h_control, HPI_AESEBUTX_FORMAT,
1621 u16 hpi_aesebu_transmitter_get_format(u32 h_control, u16 *pw_output_format)
1626 err = hpi_control_param1_get(h_control, HPI_AESEBUTX_FORMAT, ¶m);
1627 if (!err && pw_output_format)
1628 *pw_output_format = (u16)param;
1633 u16 hpi_bitstream_set_clock_edge(u32 h_control, u16 edge_type)
1635 return hpi_control_param_set(h_control, HPI_BITSTREAM_CLOCK_EDGE,
1639 u16 hpi_bitstream_set_data_polarity(u32 h_control, u16 polarity)
1641 return hpi_control_param_set(h_control, HPI_BITSTREAM_DATA_POLARITY,
1645 u16 hpi_bitstream_get_activity(u32 h_control, u16 *pw_clk_activity,
1646 u16 *pw_data_activity)
1648 struct hpi_message hm;
1649 struct hpi_response hr;
1650 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1651 HPI_CONTROL_GET_STATE);
1652 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1653 return HPI_ERROR_INVALID_HANDLE;
1654 hm.u.c.attribute = HPI_BITSTREAM_ACTIVITY;
1655 hpi_send_recv(&hm, &hr);
1656 if (pw_clk_activity)
1657 *pw_clk_activity = (u16)hr.u.c.param1;
1658 if (pw_data_activity)
1659 *pw_data_activity = (u16)hr.u.c.param2;
1663 u16 hpi_channel_mode_query_mode(const u32 h_mode, const u32 index,
1669 err = hpi_control_query(h_mode, HPI_CHANNEL_MODE_MODE, index, 0, &qr);
1674 u16 hpi_channel_mode_set(u32 h_control, u16 mode)
1676 return hpi_control_param_set(h_control, HPI_CHANNEL_MODE_MODE, mode,
1680 u16 hpi_channel_mode_get(u32 h_control, u16 *mode)
1683 u16 error = hpi_control_param1_get(h_control,
1684 HPI_CHANNEL_MODE_MODE, &mode32);
1686 *mode = (u16)mode32;
1690 u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count,
1693 struct hpi_message hm;
1694 struct hpi_response hr;
1696 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
1697 HPI_CONTROL_SET_STATE);
1698 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1699 return HPI_ERROR_INVALID_HANDLE;
1701 hm.u.cx.u.cobranet_data.byte_count = byte_count;
1702 hm.u.cx.u.cobranet_data.hmi_address = hmi_address;
1704 if (byte_count <= 8) {
1705 memcpy(hm.u.cx.u.cobranet_data.data, pb_data, byte_count);
1706 hm.u.cx.attribute = HPI_COBRANET_SET;
1708 hm.u.cx.u.cobranet_bigdata.pb_data = pb_data;
1709 hm.u.cx.attribute = HPI_COBRANET_SET_DATA;
1712 hpi_send_recv(&hm, &hr);
1717 u16 hpi_cobranet_hmi_read(u32 h_control, u32 hmi_address, u32 max_byte_count,
1718 u32 *pbyte_count, u8 *pb_data)
1720 struct hpi_message hm;
1721 struct hpi_response hr;
1723 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
1724 HPI_CONTROL_GET_STATE);
1725 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1726 return HPI_ERROR_INVALID_HANDLE;
1728 hm.u.cx.u.cobranet_data.byte_count = max_byte_count;
1729 hm.u.cx.u.cobranet_data.hmi_address = hmi_address;
1731 if (max_byte_count <= 8) {
1732 hm.u.cx.attribute = HPI_COBRANET_GET;
1734 hm.u.cx.u.cobranet_bigdata.pb_data = pb_data;
1735 hm.u.cx.attribute = HPI_COBRANET_GET_DATA;
1738 hpi_send_recv(&hm, &hr);
1739 if (!hr.error && pb_data) {
1741 *pbyte_count = hr.u.cx.u.cobranet_data.byte_count;
1743 if (*pbyte_count < max_byte_count)
1744 max_byte_count = *pbyte_count;
1746 if (hm.u.cx.attribute == HPI_COBRANET_GET) {
1747 memcpy(pb_data, hr.u.cx.u.cobranet_data.data,
1757 u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus,
1758 u32 *preadable_size, u32 *pwriteable_size)
1760 struct hpi_message hm;
1761 struct hpi_response hr;
1763 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
1764 HPI_CONTROL_GET_STATE);
1765 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1766 return HPI_ERROR_INVALID_HANDLE;
1768 hm.u.cx.attribute = HPI_COBRANET_GET_STATUS;
1770 hpi_send_recv(&hm, &hr);
1773 *pstatus = hr.u.cx.u.cobranet_status.status;
1776 hr.u.cx.u.cobranet_status.readable_size;
1777 if (pwriteable_size)
1779 hr.u.cx.u.cobranet_status.writeable_size;
1784 u16 hpi_cobranet_get_ip_address(u32 h_control, u32 *pdw_ip_address)
1790 error = hpi_cobranet_hmi_read(h_control,
1791 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count,
1795 ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
1796 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
1799 *pdw_ip_address = 0;
1805 u16 hpi_cobranet_set_ip_address(u32 h_control, u32 dw_ip_address)
1810 iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
1811 0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
1812 8) | ((dw_ip_address & 0x000000ff) << 8);
1814 error = hpi_cobranet_hmi_write(h_control,
1815 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, (u8 *)&iP);
1821 u16 hpi_cobranet_get_static_ip_address(u32 h_control, u32 *pdw_ip_address)
1826 error = hpi_cobranet_hmi_read(h_control,
1827 HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count,
1831 ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
1832 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
1835 *pdw_ip_address = 0;
1841 u16 hpi_cobranet_set_static_ip_address(u32 h_control, u32 dw_ip_address)
1846 iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
1847 0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
1848 8) | ((dw_ip_address & 0x000000ff) << 8);
1850 error = hpi_cobranet_hmi_write(h_control,
1851 HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, (u8 *)&iP);
1857 u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *pmAC_MS_bs,
1864 error = hpi_cobranet_hmi_read(h_control,
1865 HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count,
1868 ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC
1869 & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8);
1870 error += hpi_cobranet_hmi_read(h_control,
1871 HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4, &byte_count,
1874 ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC
1875 & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8);
1885 u16 hpi_compander_set_enable(u32 h_control, u32 enable)
1887 return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
1891 u16 hpi_compander_get_enable(u32 h_control, u32 *enable)
1893 return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
1896 u16 hpi_compander_set_makeup_gain(u32 h_control, short makeup_gain0_01dB)
1898 return hpi_control_log_set2(h_control, HPI_COMPANDER_MAKEUPGAIN,
1899 makeup_gain0_01dB, 0);
1902 u16 hpi_compander_get_makeup_gain(u32 h_control, short *makeup_gain0_01dB)
1904 return hpi_control_log_get2(h_control, HPI_COMPANDER_MAKEUPGAIN,
1905 makeup_gain0_01dB, NULL);
1908 u16 hpi_compander_set_attack_time_constant(u32 h_control, unsigned int index,
1911 return hpi_control_param_set(h_control, HPI_COMPANDER_ATTACK, attack,
1915 u16 hpi_compander_get_attack_time_constant(u32 h_control, unsigned int index,
1918 return hpi_control_param_get(h_control, HPI_COMPANDER_ATTACK, 0,
1919 index, attack, NULL);
1922 u16 hpi_compander_set_decay_time_constant(u32 h_control, unsigned int index,
1925 return hpi_control_param_set(h_control, HPI_COMPANDER_DECAY, decay,
1929 u16 hpi_compander_get_decay_time_constant(u32 h_control, unsigned int index,
1932 return hpi_control_param_get(h_control, HPI_COMPANDER_DECAY, 0, index,
1937 u16 hpi_compander_set_threshold(u32 h_control, unsigned int index,
1938 short threshold0_01dB)
1940 struct hpi_message hm;
1941 struct hpi_response hr;
1943 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1944 HPI_CONTROL_SET_STATE);
1945 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1946 return HPI_ERROR_INVALID_HANDLE;
1947 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
1948 hm.u.c.param2 = index;
1949 hm.u.c.an_log_value[0] = threshold0_01dB;
1951 hpi_send_recv(&hm, &hr);
1956 u16 hpi_compander_get_threshold(u32 h_control, unsigned int index,
1957 short *threshold0_01dB)
1959 struct hpi_message hm;
1960 struct hpi_response hr;
1962 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1963 HPI_CONTROL_GET_STATE);
1964 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1965 return HPI_ERROR_INVALID_HANDLE;
1966 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
1967 hm.u.c.param2 = index;
1969 hpi_send_recv(&hm, &hr);
1970 *threshold0_01dB = hr.u.c.an_log_value[0];
1975 u16 hpi_compander_set_ratio(u32 h_control, u32 index, u32 ratio100)
1977 return hpi_control_param_set(h_control, HPI_COMPANDER_RATIO, ratio100,
1981 u16 hpi_compander_get_ratio(u32 h_control, u32 index, u32 *ratio100)
1983 return hpi_control_param_get(h_control, HPI_COMPANDER_RATIO, 0, index,
1987 u16 hpi_level_query_range(u32 h_control, short *min_gain_01dB,
1988 short *max_gain_01dB, short *step_gain_01dB)
1990 struct hpi_message hm;
1991 struct hpi_response hr;
1993 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1994 HPI_CONTROL_GET_STATE);
1995 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1996 return HPI_ERROR_INVALID_HANDLE;
1997 hm.u.c.attribute = HPI_LEVEL_RANGE;
1999 hpi_send_recv(&hm, &hr);
2001 hr.u.c.an_log_value[0] = 0;
2002 hr.u.c.an_log_value[1] = 0;
2006 *min_gain_01dB = hr.u.c.an_log_value[0];
2008 *max_gain_01dB = hr.u.c.an_log_value[1];
2010 *step_gain_01dB = (short)hr.u.c.param1;
2014 u16 hpi_level_set_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
2017 return hpi_control_log_set2(h_control, HPI_LEVEL_GAIN,
2018 an_gain0_01dB[0], an_gain0_01dB[1]);
2021 u16 hpi_level_get_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
2024 return hpi_control_log_get2(h_control, HPI_LEVEL_GAIN,
2025 &an_gain0_01dB[0], &an_gain0_01dB[1]);
2028 u16 hpi_meter_query_channels(const u32 h_meter, u32 *p_channels)
2030 return hpi_control_query(h_meter, HPI_METER_NUM_CHANNELS, 0, 0,
2034 u16 hpi_meter_get_peak(u32 h_control, short an_peakdB[HPI_MAX_CHANNELS]
2039 struct hpi_message hm;
2040 struct hpi_response hr;
2042 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2043 HPI_CONTROL_GET_STATE);
2044 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2045 return HPI_ERROR_INVALID_HANDLE;
2046 hm.obj_index = hm.obj_index;
2047 hm.u.c.attribute = HPI_METER_PEAK;
2049 hpi_send_recv(&hm, &hr);
2052 memcpy(an_peakdB, hr.u.c.an_log_value,
2053 sizeof(short) * HPI_MAX_CHANNELS);
2055 for (i = 0; i < HPI_MAX_CHANNELS; i++)
2056 an_peakdB[i] = HPI_METER_MINIMUM;
2060 u16 hpi_meter_get_rms(u32 h_control, short an_rmsdB[HPI_MAX_CHANNELS]
2065 struct hpi_message hm;
2066 struct hpi_response hr;
2068 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2069 HPI_CONTROL_GET_STATE);
2070 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2071 return HPI_ERROR_INVALID_HANDLE;
2072 hm.u.c.attribute = HPI_METER_RMS;
2074 hpi_send_recv(&hm, &hr);
2077 memcpy(an_rmsdB, hr.u.c.an_log_value,
2078 sizeof(short) * HPI_MAX_CHANNELS);
2080 for (i = 0; i < HPI_MAX_CHANNELS; i++)
2081 an_rmsdB[i] = HPI_METER_MINIMUM;
2086 u16 hpi_meter_set_rms_ballistics(u32 h_control, u16 attack, u16 decay)
2088 return hpi_control_param_set(h_control, HPI_METER_RMS_BALLISTICS,
2092 u16 hpi_meter_get_rms_ballistics(u32 h_control, u16 *pn_attack, u16 *pn_decay)
2098 error = hpi_control_param2_get(h_control, HPI_METER_RMS_BALLISTICS,
2102 *pn_attack = (unsigned short)attack;
2104 *pn_decay = (unsigned short)decay;
2109 u16 hpi_meter_set_peak_ballistics(u32 h_control, u16 attack, u16 decay)
2111 return hpi_control_param_set(h_control, HPI_METER_PEAK_BALLISTICS,
2115 u16 hpi_meter_get_peak_ballistics(u32 h_control, u16 *pn_attack,
2122 error = hpi_control_param2_get(h_control, HPI_METER_PEAK_BALLISTICS,
2126 *pn_attack = (short)attack;
2128 *pn_decay = (short)decay;
2133 u16 hpi_microphone_set_phantom_power(u32 h_control, u16 on_off)
2135 return hpi_control_param_set(h_control, HPI_MICROPHONE_PHANTOM_POWER,
2139 u16 hpi_microphone_get_phantom_power(u32 h_control, u16 *pw_on_off)
2143 error = hpi_control_param1_get(h_control,
2144 HPI_MICROPHONE_PHANTOM_POWER, &on_off);
2146 *pw_on_off = (u16)on_off;
2150 u16 hpi_multiplexer_set_source(u32 h_control, u16 source_node_type,
2151 u16 source_node_index)
2153 return hpi_control_param_set(h_control, HPI_MULTIPLEXER_SOURCE,
2154 source_node_type, source_node_index);
2157 u16 hpi_multiplexer_get_source(u32 h_control, u16 *source_node_type,
2158 u16 *source_node_index)
2161 u16 error = hpi_control_param2_get(h_control,
2162 HPI_MULTIPLEXER_SOURCE, &node,
2164 if (source_node_type)
2165 *source_node_type = (u16)node;
2166 if (source_node_index)
2167 *source_node_index = (u16)index;
2171 u16 hpi_multiplexer_query_source(u32 h_control, u16 index,
2172 u16 *source_node_type, u16 *source_node_index)
2174 struct hpi_message hm;
2175 struct hpi_response hr;
2176 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2177 HPI_CONTROL_GET_STATE);
2178 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2179 return HPI_ERROR_INVALID_HANDLE;
2180 hm.u.c.attribute = HPI_MULTIPLEXER_QUERYSOURCE;
2181 hm.u.c.param1 = index;
2183 hpi_send_recv(&hm, &hr);
2185 if (source_node_type)
2186 *source_node_type = (u16)hr.u.c.param1;
2187 if (source_node_index)
2188 *source_node_index = (u16)hr.u.c.param2;
2192 u16 hpi_parametric_eq_get_info(u32 h_control, u16 *pw_number_of_bands,
2199 error = hpi_control_param2_get(h_control, HPI_EQUALIZER_NUM_FILTERS,
2201 if (pw_number_of_bands)
2202 *pw_number_of_bands = (u16)oB;
2204 *pw_on_off = (u16)oO;
2208 u16 hpi_parametric_eq_set_state(u32 h_control, u16 on_off)
2210 return hpi_control_param_set(h_control, HPI_EQUALIZER_NUM_FILTERS,
2214 u16 hpi_parametric_eq_get_band(u32 h_control, u16 index, u16 *pn_type,
2215 u32 *pfrequency_hz, short *pnQ100, short *pn_gain0_01dB)
2217 struct hpi_message hm;
2218 struct hpi_response hr;
2220 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2221 HPI_CONTROL_GET_STATE);
2222 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2223 return HPI_ERROR_INVALID_HANDLE;
2224 hm.u.c.attribute = HPI_EQUALIZER_FILTER;
2225 hm.u.c.param2 = index;
2227 hpi_send_recv(&hm, &hr);
2230 *pfrequency_hz = hr.u.c.param1;
2232 *pn_type = (u16)(hr.u.c.param2 >> 16);
2234 *pnQ100 = hr.u.c.an_log_value[1];
2236 *pn_gain0_01dB = hr.u.c.an_log_value[0];
2241 u16 hpi_parametric_eq_set_band(u32 h_control, u16 index, u16 type,
2242 u32 frequency_hz, short q100, short gain0_01dB)
2244 struct hpi_message hm;
2245 struct hpi_response hr;
2247 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2248 HPI_CONTROL_SET_STATE);
2249 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2250 return HPI_ERROR_INVALID_HANDLE;
2252 hm.u.c.param1 = frequency_hz;
2253 hm.u.c.param2 = (index & 0xFFFFL) + ((u32)type << 16);
2254 hm.u.c.an_log_value[0] = gain0_01dB;
2255 hm.u.c.an_log_value[1] = q100;
2256 hm.u.c.attribute = HPI_EQUALIZER_FILTER;
2258 hpi_send_recv(&hm, &hr);
2263 u16 hpi_parametric_eq_get_coeffs(u32 h_control, u16 index, short coeffs[5]
2266 struct hpi_message hm;
2267 struct hpi_response hr;
2269 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2270 HPI_CONTROL_GET_STATE);
2271 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2272 return HPI_ERROR_INVALID_HANDLE;
2273 hm.u.c.attribute = HPI_EQUALIZER_COEFFICIENTS;
2274 hm.u.c.param2 = index;
2276 hpi_send_recv(&hm, &hr);
2278 coeffs[0] = (short)hr.u.c.an_log_value[0];
2279 coeffs[1] = (short)hr.u.c.an_log_value[1];
2280 coeffs[2] = (short)hr.u.c.param1;
2281 coeffs[3] = (short)(hr.u.c.param1 >> 16);
2282 coeffs[4] = (short)hr.u.c.param2;
2287 u16 hpi_sample_clock_query_source(const u32 h_clock, const u32 index,
2293 err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE, index, 0,
2295 *pw_source = (u16)qr;
2299 u16 hpi_sample_clock_set_source(u32 h_control, u16 source)
2301 return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE,
2305 u16 hpi_sample_clock_get_source(u32 h_control, u16 *pw_source)
2309 error = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE,
2313 *pw_source = (u16)source;
2317 u16 hpi_sample_clock_query_source_index(const u32 h_clock, const u32 index,
2318 const u32 source, u16 *pw_source_index)
2323 err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE_INDEX, index,
2325 *pw_source_index = (u16)qr;
2329 u16 hpi_sample_clock_set_source_index(u32 h_control, u16 source_index)
2331 return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
2335 u16 hpi_sample_clock_get_source_index(u32 h_control, u16 *pw_source_index)
2338 u32 source_index = 0;
2339 error = hpi_control_param1_get(h_control,
2340 HPI_SAMPLECLOCK_SOURCE_INDEX, &source_index);
2342 if (pw_source_index)
2343 *pw_source_index = (u16)source_index;
2347 u16 hpi_sample_clock_query_local_rate(const u32 h_clock, const u32 index,
2351 err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_LOCAL_SAMPLERATE,
2357 u16 hpi_sample_clock_set_local_rate(u32 h_control, u32 sample_rate)
2359 return hpi_control_param_set(h_control,
2360 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, sample_rate, 0);
2363 u16 hpi_sample_clock_get_local_rate(u32 h_control, u32 *psample_rate)
2366 u32 sample_rate = 0;
2367 error = hpi_control_param1_get(h_control,
2368 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate);
2371 *psample_rate = sample_rate;
2375 u16 hpi_sample_clock_get_sample_rate(u32 h_control, u32 *psample_rate)
2378 u32 sample_rate = 0;
2379 error = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SAMPLERATE,
2383 *psample_rate = sample_rate;
2387 u16 hpi_sample_clock_set_auto(u32 h_control, u32 enable)
2389 return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_AUTO, enable,
2393 u16 hpi_sample_clock_get_auto(u32 h_control, u32 *penable)
2395 return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_AUTO,
2399 u16 hpi_sample_clock_set_local_rate_lock(u32 h_control, u32 lock)
2401 return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
2405 u16 hpi_sample_clock_get_local_rate_lock(u32 h_control, u32 *plock)
2407 return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
2411 u16 hpi_tone_detector_get_frequency(u32 h_control, u32 index, u32 *frequency)
2413 return hpi_control_param_get(h_control, HPI_TONEDETECTOR_FREQUENCY,
2414 index, 0, frequency, NULL);
2417 u16 hpi_tone_detector_get_state(u32 h_control, u32 *state)
2419 return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_STATE,
2423 u16 hpi_tone_detector_set_enable(u32 h_control, u32 enable)
2425 return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
2429 u16 hpi_tone_detector_get_enable(u32 h_control, u32 *enable)
2431 return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
2434 u16 hpi_tone_detector_set_event_enable(u32 h_control, u32 event_enable)
2436 return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
2437 (u32)event_enable, 0);
2440 u16 hpi_tone_detector_get_event_enable(u32 h_control, u32 *event_enable)
2442 return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
2446 u16 hpi_tone_detector_set_threshold(u32 h_control, int threshold)
2448 return hpi_control_param_set(h_control, HPI_TONEDETECTOR_THRESHOLD,
2452 u16 hpi_tone_detector_get_threshold(u32 h_control, int *threshold)
2454 return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_THRESHOLD,
2458 u16 hpi_silence_detector_get_state(u32 h_control, u32 *state)
2460 return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_STATE,
2464 u16 hpi_silence_detector_set_enable(u32 h_control, u32 enable)
2466 return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
2470 u16 hpi_silence_detector_get_enable(u32 h_control, u32 *enable)
2472 return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
2475 u16 hpi_silence_detector_set_event_enable(u32 h_control, u32 event_enable)
2477 return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
2481 u16 hpi_silence_detector_get_event_enable(u32 h_control, u32 *event_enable)
2483 return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
2487 u16 hpi_silence_detector_set_delay(u32 h_control, u32 delay)
2489 return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_DELAY,
2493 u16 hpi_silence_detector_get_delay(u32 h_control, u32 *delay)
2495 return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_DELAY,
2499 u16 hpi_silence_detector_set_threshold(u32 h_control, int threshold)
2501 return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_THRESHOLD,
2505 u16 hpi_silence_detector_get_threshold(u32 h_control, int *threshold)
2507 return hpi_control_param1_get(h_control,
2508 HPI_SILENCEDETECTOR_THRESHOLD, (u32 *)threshold);
2511 u16 hpi_tuner_query_band(const u32 h_tuner, const u32 index, u16 *pw_band)
2516 err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
2521 u16 hpi_tuner_set_band(u32 h_control, u16 band)
2523 return hpi_control_param_set(h_control, HPI_TUNER_BAND, band, 0);
2526 u16 hpi_tuner_get_band(u32 h_control, u16 *pw_band)
2531 error = hpi_control_param1_get(h_control, HPI_TUNER_BAND, &band);
2533 *pw_band = (u16)band;
2537 u16 hpi_tuner_query_frequency(const u32 h_tuner, const u32 index,
2538 const u16 band, u32 *pfreq)
2540 return hpi_control_query(h_tuner, HPI_TUNER_FREQ, index, band, pfreq);
2543 u16 hpi_tuner_set_frequency(u32 h_control, u32 freq_ink_hz)
2545 return hpi_control_param_set(h_control, HPI_TUNER_FREQ, freq_ink_hz,
2549 u16 hpi_tuner_get_frequency(u32 h_control, u32 *pw_freq_ink_hz)
2551 return hpi_control_param1_get(h_control, HPI_TUNER_FREQ,
2555 u16 hpi_tuner_query_gain(const u32 h_tuner, const u32 index, u16 *pw_gain)
2560 err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
2565 u16 hpi_tuner_set_gain(u32 h_control, short gain)
2567 return hpi_control_param_set(h_control, HPI_TUNER_GAIN, gain, 0);
2570 u16 hpi_tuner_get_gain(u32 h_control, short *pn_gain)
2575 error = hpi_control_param1_get(h_control, HPI_TUNER_GAIN, &gain);
2577 *pn_gain = (u16)gain;
2581 u16 hpi_tuner_get_rf_level(u32 h_control, short *pw_level)
2583 struct hpi_message hm;
2584 struct hpi_response hr;
2586 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2587 HPI_CONTROL_GET_STATE);
2588 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2589 return HPI_ERROR_INVALID_HANDLE;
2590 hm.u.cu.attribute = HPI_TUNER_LEVEL_AVG;
2591 hpi_send_recv(&hm, &hr);
2593 *pw_level = hr.u.cu.tuner.s_level;
2597 u16 hpi_tuner_get_raw_rf_level(u32 h_control, short *pw_level)
2599 struct hpi_message hm;
2600 struct hpi_response hr;
2602 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2603 HPI_CONTROL_GET_STATE);
2604 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2605 return HPI_ERROR_INVALID_HANDLE;
2606 hm.u.cu.attribute = HPI_TUNER_LEVEL_RAW;
2607 hpi_send_recv(&hm, &hr);
2609 *pw_level = hr.u.cu.tuner.s_level;
2613 u16 hpi_tuner_query_deemphasis(const u32 h_tuner, const u32 index,
2614 const u16 band, u32 *pdeemphasis)
2616 return hpi_control_query(h_tuner, HPI_TUNER_DEEMPHASIS, index, band,
2620 u16 hpi_tuner_set_deemphasis(u32 h_control, u32 deemphasis)
2622 return hpi_control_param_set(h_control, HPI_TUNER_DEEMPHASIS,
2626 u16 hpi_tuner_get_deemphasis(u32 h_control, u32 *pdeemphasis)
2628 return hpi_control_param1_get(h_control, HPI_TUNER_DEEMPHASIS,
2632 u16 hpi_tuner_query_program(const u32 h_tuner, u32 *pbitmap_program)
2634 return hpi_control_query(h_tuner, HPI_TUNER_PROGRAM, 0, 0,
2638 u16 hpi_tuner_set_program(u32 h_control, u32 program)
2640 return hpi_control_param_set(h_control, HPI_TUNER_PROGRAM, program,
2644 u16 hpi_tuner_get_program(u32 h_control, u32 *pprogram)
2646 return hpi_control_param1_get(h_control, HPI_TUNER_PROGRAM, pprogram);
2649 u16 hpi_tuner_get_hd_radio_dsp_version(u32 h_control, char *psz_dsp_version,
2650 const u32 string_size)
2652 return hpi_control_get_string(h_control,
2653 HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size);
2656 u16 hpi_tuner_get_hd_radio_sdk_version(u32 h_control, char *psz_sdk_version,
2657 const u32 string_size)
2659 return hpi_control_get_string(h_control,
2660 HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size);
2663 u16 hpi_tuner_get_status(u32 h_control, u16 *pw_status_mask, u16 *pw_status)
2668 error = hpi_control_param1_get(h_control, HPI_TUNER_STATUS, &status);
2671 *pw_status_mask = (u16)(status >> 16);
2672 *pw_status = (u16)(status & 0xFFFF);
2674 *pw_status_mask = 0;
2681 u16 hpi_tuner_set_mode(u32 h_control, u32 mode, u32 value)
2683 return hpi_control_param_set(h_control, HPI_TUNER_MODE, mode, value);
2686 u16 hpi_tuner_get_mode(u32 h_control, u32 mode, u32 *pn_value)
2688 return hpi_control_param_get(h_control, HPI_TUNER_MODE, mode, 0,
2692 u16 hpi_tuner_get_hd_radio_signal_quality(u32 h_control, u32 *pquality)
2694 return hpi_control_param1_get(h_control,
2695 HPI_TUNER_HDRADIO_SIGNAL_QUALITY, pquality);
2698 u16 hpi_tuner_get_hd_radio_signal_blend(u32 h_control, u32 *pblend)
2700 return hpi_control_param1_get(h_control, HPI_TUNER_HDRADIO_BLEND,
2704 u16 hpi_tuner_set_hd_radio_signal_blend(u32 h_control, const u32 blend)
2706 return hpi_control_param_set(h_control, HPI_TUNER_HDRADIO_BLEND,
2710 u16 hpi_tuner_get_rds(u32 h_control, char *p_data)
2712 struct hpi_message hm;
2713 struct hpi_response hr;
2715 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2716 HPI_CONTROL_GET_STATE);
2717 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2718 return HPI_ERROR_INVALID_HANDLE;
2719 hm.u.c.attribute = HPI_TUNER_RDS;
2720 hpi_send_recv(&hm, &hr);
2722 *(u32 *)&p_data[0] = hr.u.cu.tuner.rds.data[0];
2723 *(u32 *)&p_data[4] = hr.u.cu.tuner.rds.data[1];
2724 *(u32 *)&p_data[8] = hr.u.cu.tuner.rds.bLER;
2729 u16 hpi_pad_get_channel_name(u32 h_control, char *psz_string,
2730 const u32 data_length)
2732 return hpi_control_get_string(h_control, HPI_PAD_CHANNEL_NAME,
2733 psz_string, data_length);
2736 u16 hpi_pad_get_artist(u32 h_control, char *psz_string, const u32 data_length)
2738 return hpi_control_get_string(h_control, HPI_PAD_ARTIST, psz_string,
2742 u16 hpi_pad_get_title(u32 h_control, char *psz_string, const u32 data_length)
2744 return hpi_control_get_string(h_control, HPI_PAD_TITLE, psz_string,
2748 u16 hpi_pad_get_comment(u32 h_control, char *psz_string,
2749 const u32 data_length)
2751 return hpi_control_get_string(h_control, HPI_PAD_COMMENT, psz_string,
2755 u16 hpi_pad_get_program_type(u32 h_control, u32 *ppTY)
2757 return hpi_control_param1_get(h_control, HPI_PAD_PROGRAM_TYPE, ppTY);
2760 u16 hpi_pad_get_rdsPI(u32 h_control, u32 *ppI)
2762 return hpi_control_param1_get(h_control, HPI_PAD_PROGRAM_ID, ppI);
2765 u16 hpi_volume_query_channels(const u32 h_volume, u32 *p_channels)
2767 return hpi_control_query(h_volume, HPI_VOLUME_NUM_CHANNELS, 0, 0,
2771 u16 hpi_volume_set_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS]
2774 return hpi_control_log_set2(h_control, HPI_VOLUME_GAIN,
2775 an_log_gain[0], an_log_gain[1]);
2778 u16 hpi_volume_get_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS]
2781 return hpi_control_log_get2(h_control, HPI_VOLUME_GAIN,
2782 &an_log_gain[0], &an_log_gain[1]);
2785 u16 hpi_volume_set_mute(u32 h_control, u32 mute)
2787 return hpi_control_param_set(h_control, HPI_VOLUME_MUTE, mute, 0);
2790 u16 hpi_volume_get_mute(u32 h_control, u32 *mute)
2792 return hpi_control_param1_get(h_control, HPI_VOLUME_MUTE, mute);
2795 u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB,
2796 short *max_gain_01dB, short *step_gain_01dB)
2798 struct hpi_message hm;
2799 struct hpi_response hr;
2801 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2802 HPI_CONTROL_GET_STATE);
2803 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2804 return HPI_ERROR_INVALID_HANDLE;
2805 hm.u.c.attribute = HPI_VOLUME_RANGE;
2807 hpi_send_recv(&hm, &hr);
2809 hr.u.c.an_log_value[0] = 0;
2810 hr.u.c.an_log_value[1] = 0;
2814 *min_gain_01dB = hr.u.c.an_log_value[0];
2816 *max_gain_01dB = hr.u.c.an_log_value[1];
2818 *step_gain_01dB = (short)hr.u.c.param1;
2822 u16 hpi_volume_auto_fade_profile(u32 h_control,
2823 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms,
2826 struct hpi_message hm;
2827 struct hpi_response hr;
2829 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2830 HPI_CONTROL_SET_STATE);
2831 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2832 return HPI_ERROR_INVALID_HANDLE;
2834 memcpy(hm.u.c.an_log_value, an_stop_gain0_01dB,
2835 sizeof(short) * HPI_MAX_CHANNELS);
2837 hm.u.c.attribute = HPI_VOLUME_AUTOFADE;
2838 hm.u.c.param1 = duration_ms;
2839 hm.u.c.param2 = profile;
2841 hpi_send_recv(&hm, &hr);
2846 u16 hpi_volume_auto_fade(u32 h_control,
2847 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms)
2849 return hpi_volume_auto_fade_profile(h_control, an_stop_gain0_01dB,
2850 duration_ms, HPI_VOLUME_AUTOFADE_LOG);
2853 u16 hpi_vox_set_threshold(u32 h_control, short an_gain0_01dB)
2855 struct hpi_message hm;
2856 struct hpi_response hr;
2857 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2858 HPI_CONTROL_SET_STATE);
2859 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2860 return HPI_ERROR_INVALID_HANDLE;
2861 hm.u.c.attribute = HPI_VOX_THRESHOLD;
2863 hm.u.c.an_log_value[0] = an_gain0_01dB;
2865 hpi_send_recv(&hm, &hr);
2870 u16 hpi_vox_get_threshold(u32 h_control, short *an_gain0_01dB)
2872 struct hpi_message hm;
2873 struct hpi_response hr;
2874 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2875 HPI_CONTROL_GET_STATE);
2876 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2877 return HPI_ERROR_INVALID_HANDLE;
2878 hm.u.c.attribute = HPI_VOX_THRESHOLD;
2880 hpi_send_recv(&hm, &hr);
2882 *an_gain0_01dB = hr.u.c.an_log_value[0];