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 void hpi_handle_to_indexes(const u32 handle
, u16
*pw_adapter_index
,
36 union handle_word uhandle
;
40 *pw_adapter_index
= (u16
)uhandle
.h
.adapter_index
;
42 *pw_object_index
= (u16
)uhandle
.h
.obj_index
;
45 char hpi_handle_object(const u32 handle
)
47 union handle_word uhandle
;
49 return (char)uhandle
.h
.obj_type
;
52 #define u32TOINDEX(h, i1) \
55 return HPI_ERROR_INVALID_OBJ; \
57 hpi_handle_to_indexes(h, i1, NULL); \
60 #define u32TOINDEXES(h, i1, i2) \
63 return HPI_ERROR_INVALID_OBJ; \
65 hpi_handle_to_indexes(h, i1, i2);\
68 void hpi_format_to_msg(struct hpi_msg_format
*pMF
,
69 const struct hpi_format
*pF
)
71 pMF
->sample_rate
= pF
->sample_rate
;
72 pMF
->bit_rate
= pF
->bit_rate
;
73 pMF
->attributes
= pF
->attributes
;
74 pMF
->channels
= pF
->channels
;
75 pMF
->format
= pF
->format
;
78 static void hpi_msg_to_format(struct hpi_format
*pF
,
79 struct hpi_msg_format
*pMF
)
81 pF
->sample_rate
= pMF
->sample_rate
;
82 pF
->bit_rate
= pMF
->bit_rate
;
83 pF
->attributes
= pMF
->attributes
;
84 pF
->channels
= pMF
->channels
;
85 pF
->format
= pMF
->format
;
90 void hpi_stream_response_to_legacy(struct hpi_stream_res
*pSR
)
92 pSR
->u
.legacy_stream_info
.auxiliary_data_available
=
93 pSR
->u
.stream_info
.auxiliary_data_available
;
94 pSR
->u
.legacy_stream_info
.state
= pSR
->u
.stream_info
.state
;
97 static struct hpi_hsubsys gh_subsys
;
99 struct hpi_hsubsys
*hpi_subsys_create(void
102 struct hpi_message hm
;
103 struct hpi_response hr
;
105 memset(&gh_subsys
, 0, sizeof(struct hpi_hsubsys
));
108 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_SUBSYSTEM
,
110 hpi_send_recv(&hm
, &hr
);
119 void hpi_subsys_free(const struct hpi_hsubsys
*ph_subsys
)
121 struct hpi_message hm
;
122 struct hpi_response hr
;
124 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_SUBSYSTEM
,
126 hpi_send_recv(&hm
, &hr
);
130 u16
hpi_subsys_get_version(const struct hpi_hsubsys
*ph_subsys
, u32
*pversion
)
132 struct hpi_message hm
;
133 struct hpi_response hr
;
135 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_SUBSYSTEM
,
136 HPI_SUBSYS_GET_VERSION
);
137 hpi_send_recv(&hm
, &hr
);
138 *pversion
= hr
.u
.s
.version
;
142 u16
hpi_subsys_get_version_ex(const struct hpi_hsubsys
*ph_subsys
,
145 struct hpi_message hm
;
146 struct hpi_response hr
;
148 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_SUBSYSTEM
,
149 HPI_SUBSYS_GET_VERSION
);
150 hpi_send_recv(&hm
, &hr
);
151 *pversion_ex
= hr
.u
.s
.data
;
155 u16
hpi_subsys_get_info(const struct hpi_hsubsys
*ph_subsys
, u32
*pversion
,
156 u16
*pw_num_adapters
, u16 aw_adapter_list
[], u16 list_length
)
158 struct hpi_message hm
;
159 struct hpi_response hr
;
160 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_SUBSYSTEM
,
161 HPI_SUBSYS_GET_INFO
);
163 hpi_send_recv(&hm
, &hr
);
165 *pversion
= hr
.u
.s
.version
;
166 if (list_length
> HPI_MAX_ADAPTERS
)
167 memcpy(aw_adapter_list
, &hr
.u
.s
.aw_adapter_list
,
170 memcpy(aw_adapter_list
, &hr
.u
.s
.aw_adapter_list
, list_length
);
171 *pw_num_adapters
= hr
.u
.s
.num_adapters
;
175 u16
hpi_subsys_find_adapters(const struct hpi_hsubsys
*ph_subsys
,
176 u16
*pw_num_adapters
, u16 aw_adapter_list
[], u16 list_length
)
178 struct hpi_message hm
;
179 struct hpi_response hr
;
180 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_SUBSYSTEM
,
181 HPI_SUBSYS_FIND_ADAPTERS
);
183 hpi_send_recv(&hm
, &hr
);
185 if (list_length
> HPI_MAX_ADAPTERS
) {
186 memcpy(aw_adapter_list
, &hr
.u
.s
.aw_adapter_list
,
187 HPI_MAX_ADAPTERS
* sizeof(u16
));
188 memset(&aw_adapter_list
[HPI_MAX_ADAPTERS
], 0,
189 (list_length
- HPI_MAX_ADAPTERS
) * sizeof(u16
));
191 memcpy(aw_adapter_list
, &hr
.u
.s
.aw_adapter_list
,
192 list_length
* sizeof(u16
));
193 *pw_num_adapters
= hr
.u
.s
.num_adapters
;
198 u16
hpi_subsys_create_adapter(const struct hpi_hsubsys
*ph_subsys
,
199 const struct hpi_resource
*p_resource
, u16
*pw_adapter_index
)
201 struct hpi_message hm
;
202 struct hpi_response hr
;
204 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_SUBSYSTEM
,
205 HPI_SUBSYS_CREATE_ADAPTER
);
206 hm
.u
.s
.resource
= *p_resource
;
208 hpi_send_recv(&hm
, &hr
);
210 *pw_adapter_index
= hr
.u
.s
.adapter_index
;
214 u16
hpi_subsys_delete_adapter(const struct hpi_hsubsys
*ph_subsys
,
217 struct hpi_message hm
;
218 struct hpi_response hr
;
219 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_SUBSYSTEM
,
220 HPI_SUBSYS_DELETE_ADAPTER
);
221 hm
.adapter_index
= adapter_index
;
222 hpi_send_recv(&hm
, &hr
);
226 u16
hpi_subsys_get_num_adapters(const struct hpi_hsubsys
*ph_subsys
,
227 int *pn_num_adapters
)
229 struct hpi_message hm
;
230 struct hpi_response hr
;
231 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_SUBSYSTEM
,
232 HPI_SUBSYS_GET_NUM_ADAPTERS
);
233 hpi_send_recv(&hm
, &hr
);
234 *pn_num_adapters
= (int)hr
.u
.s
.num_adapters
;
238 u16
hpi_subsys_get_adapter(const struct hpi_hsubsys
*ph_subsys
, int iterator
,
239 u32
*padapter_index
, u16
*pw_adapter_type
)
241 struct hpi_message hm
;
242 struct hpi_response hr
;
243 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_SUBSYSTEM
,
244 HPI_SUBSYS_GET_ADAPTER
);
245 hm
.adapter_index
= (u16
)iterator
;
246 hpi_send_recv(&hm
, &hr
);
247 *padapter_index
= (int)hr
.u
.s
.adapter_index
;
248 *pw_adapter_type
= hr
.u
.s
.aw_adapter_list
[0];
252 u16
hpi_subsys_set_host_network_interface(const struct hpi_hsubsys
*ph_subsys
,
253 const char *sz_interface
)
255 struct hpi_message hm
;
256 struct hpi_response hr
;
257 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_SUBSYSTEM
,
258 HPI_SUBSYS_SET_NETWORK_INTERFACE
);
259 if (sz_interface
== NULL
)
260 return HPI_ERROR_INVALID_RESOURCE
;
261 hm
.u
.s
.resource
.r
.net_if
= sz_interface
;
262 hpi_send_recv(&hm
, &hr
);
266 u16
hpi_adapter_open(const struct hpi_hsubsys
*ph_subsys
, u16 adapter_index
)
268 struct hpi_message hm
;
269 struct hpi_response hr
;
270 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
272 hm
.adapter_index
= adapter_index
;
274 hpi_send_recv(&hm
, &hr
);
280 u16
hpi_adapter_close(const struct hpi_hsubsys
*ph_subsys
, u16 adapter_index
)
282 struct hpi_message hm
;
283 struct hpi_response hr
;
284 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
286 hm
.adapter_index
= adapter_index
;
288 hpi_send_recv(&hm
, &hr
);
293 u16
hpi_adapter_set_mode(const struct hpi_hsubsys
*ph_subsys
,
294 u16 adapter_index
, u32 adapter_mode
)
296 return hpi_adapter_set_mode_ex(ph_subsys
, adapter_index
, adapter_mode
,
297 HPI_ADAPTER_MODE_SET
);
300 u16
hpi_adapter_set_mode_ex(const struct hpi_hsubsys
*ph_subsys
,
301 u16 adapter_index
, u32 adapter_mode
, u16 query_or_set
)
303 struct hpi_message hm
;
304 struct hpi_response hr
;
305 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
306 HPI_ADAPTER_SET_MODE
);
307 hm
.adapter_index
= adapter_index
;
308 hm
.u
.a
.adapter_mode
= adapter_mode
;
309 hm
.u
.a
.assert_id
= query_or_set
;
310 hpi_send_recv(&hm
, &hr
);
314 u16
hpi_adapter_get_mode(const struct hpi_hsubsys
*ph_subsys
,
315 u16 adapter_index
, u32
*padapter_mode
)
317 struct hpi_message hm
;
318 struct hpi_response hr
;
319 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
320 HPI_ADAPTER_GET_MODE
);
321 hm
.adapter_index
= adapter_index
;
322 hpi_send_recv(&hm
, &hr
);
324 *padapter_mode
= hr
.u
.a
.serial_number
;
328 u16
hpi_adapter_get_info(const struct hpi_hsubsys
*ph_subsys
,
329 u16 adapter_index
, u16
*pw_num_outstreams
, u16
*pw_num_instreams
,
330 u16
*pw_version
, u32
*pserial_number
, u16
*pw_adapter_type
)
332 struct hpi_message hm
;
333 struct hpi_response hr
;
334 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
335 HPI_ADAPTER_GET_INFO
);
336 hm
.adapter_index
= adapter_index
;
338 hpi_send_recv(&hm
, &hr
);
340 *pw_adapter_type
= hr
.u
.a
.adapter_type
;
341 *pw_num_outstreams
= hr
.u
.a
.num_outstreams
;
342 *pw_num_instreams
= hr
.u
.a
.num_instreams
;
343 *pw_version
= hr
.u
.a
.version
;
344 *pserial_number
= hr
.u
.a
.serial_number
;
348 u16
hpi_adapter_get_module_by_index(const struct hpi_hsubsys
*ph_subsys
,
349 u16 adapter_index
, u16 module_index
, u16
*pw_num_outputs
,
350 u16
*pw_num_inputs
, u16
*pw_version
, u32
*pserial_number
,
351 u16
*pw_module_type
, u32
*ph_module
)
353 struct hpi_message hm
;
354 struct hpi_response hr
;
356 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
357 HPI_ADAPTER_MODULE_INFO
);
358 hm
.adapter_index
= adapter_index
;
359 hm
.u
.ax
.module_info
.index
= module_index
;
361 hpi_send_recv(&hm
, &hr
);
363 *pw_module_type
= hr
.u
.a
.adapter_type
;
364 *pw_num_outputs
= hr
.u
.a
.num_outstreams
;
365 *pw_num_inputs
= hr
.u
.a
.num_instreams
;
366 *pw_version
= hr
.u
.a
.version
;
367 *pserial_number
= hr
.u
.a
.serial_number
;
373 u16
hpi_adapter_get_assert(const struct hpi_hsubsys
*ph_subsys
,
374 u16 adapter_index
, u16
*assert_present
, char *psz_assert
,
377 struct hpi_message hm
;
378 struct hpi_response hr
;
379 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
380 HPI_ADAPTER_GET_ASSERT
);
381 hm
.adapter_index
= adapter_index
;
382 hpi_send_recv(&hm
, &hr
);
388 *pw_line_number
= (u16
)hr
.u
.a
.serial_number
;
389 if (*pw_line_number
) {
392 char *src
= (char *)hr
.u
.a
.sz_adapter_assert
;
393 char *dst
= psz_assert
;
397 for (i
= 0; i
< HPI_STRING_LEN
; i
++) {
410 u16
hpi_adapter_get_assert_ex(const struct hpi_hsubsys
*ph_subsys
,
411 u16 adapter_index
, u16
*assert_present
, char *psz_assert
,
412 u32
*pline_number
, u16
*pw_assert_on_dsp
)
414 struct hpi_message hm
;
415 struct hpi_response hr
;
416 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
417 HPI_ADAPTER_GET_ASSERT
);
418 hm
.adapter_index
= adapter_index
;
420 hpi_send_recv(&hm
, &hr
);
426 *pline_number
= hr
.u
.a
.serial_number
;
428 *assert_present
= hr
.u
.a
.adapter_type
;
430 *pw_assert_on_dsp
= hr
.u
.a
.adapter_index
;
432 if (!*assert_present
&& *pline_number
)
436 if (*assert_present
) {
439 char *src
= (char *)hr
.u
.a
.sz_adapter_assert
;
440 char *dst
= psz_assert
;
442 for (i
= 0; i
< HPI_STRING_LEN
; i
++) {
457 u16
hpi_adapter_test_assert(const struct hpi_hsubsys
*ph_subsys
,
458 u16 adapter_index
, u16 assert_id
)
460 struct hpi_message hm
;
461 struct hpi_response hr
;
462 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
463 HPI_ADAPTER_TEST_ASSERT
);
464 hm
.adapter_index
= adapter_index
;
465 hm
.u
.a
.assert_id
= assert_id
;
467 hpi_send_recv(&hm
, &hr
);
472 u16
hpi_adapter_enable_capability(const struct hpi_hsubsys
*ph_subsys
,
473 u16 adapter_index
, u16 capability
, u32 key
)
475 struct hpi_message hm
;
476 struct hpi_response hr
;
477 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
478 HPI_ADAPTER_ENABLE_CAPABILITY
);
479 hm
.adapter_index
= adapter_index
;
480 hm
.u
.a
.assert_id
= capability
;
481 hm
.u
.a
.adapter_mode
= key
;
483 hpi_send_recv(&hm
, &hr
);
488 u16
hpi_adapter_self_test(const struct hpi_hsubsys
*ph_subsys
,
491 struct hpi_message hm
;
492 struct hpi_response hr
;
493 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
494 HPI_ADAPTER_SELFTEST
);
495 hm
.adapter_index
= adapter_index
;
496 hpi_send_recv(&hm
, &hr
);
500 u16
hpi_adapter_debug_read(const struct hpi_hsubsys
*ph_subsys
,
501 u16 adapter_index
, u32 dsp_address
, char *p_buffer
, int *count_bytes
)
503 struct hpi_message hm
;
504 struct hpi_response hr
;
505 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
506 HPI_ADAPTER_DEBUG_READ
);
508 hr
.size
= sizeof(hr
);
510 hm
.adapter_index
= adapter_index
;
511 hm
.u
.ax
.debug_read
.dsp_address
= dsp_address
;
513 if (*count_bytes
> sizeof(hr
.u
.bytes
))
514 *count_bytes
= sizeof(hr
.u
.bytes
);
516 hm
.u
.ax
.debug_read
.count_bytes
= *count_bytes
;
518 hpi_send_recv(&hm
, &hr
);
521 *count_bytes
= hr
.size
- 12;
522 memcpy(p_buffer
, &hr
.u
.bytes
, *count_bytes
);
528 u16
hpi_adapter_set_property(const struct hpi_hsubsys
*ph_subsys
,
529 u16 adapter_index
, u16 property
, u16 parameter1
, u16 parameter2
)
531 struct hpi_message hm
;
532 struct hpi_response hr
;
533 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
534 HPI_ADAPTER_SET_PROPERTY
);
535 hm
.adapter_index
= adapter_index
;
536 hm
.u
.ax
.property_set
.property
= property
;
537 hm
.u
.ax
.property_set
.parameter1
= parameter1
;
538 hm
.u
.ax
.property_set
.parameter2
= parameter2
;
540 hpi_send_recv(&hm
, &hr
);
545 u16
hpi_adapter_get_property(const struct hpi_hsubsys
*ph_subsys
,
546 u16 adapter_index
, u16 property
, u16
*pw_parameter1
,
549 struct hpi_message hm
;
550 struct hpi_response hr
;
551 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ADAPTER
,
552 HPI_ADAPTER_GET_PROPERTY
);
553 hm
.adapter_index
= adapter_index
;
554 hm
.u
.ax
.property_set
.property
= property
;
556 hpi_send_recv(&hm
, &hr
);
559 *pw_parameter1
= hr
.u
.ax
.property_get
.parameter1
;
561 *pw_parameter2
= hr
.u
.ax
.property_get
.parameter2
;
567 u16
hpi_adapter_enumerate_property(const struct hpi_hsubsys
*ph_subsys
,
568 u16 adapter_index
, u16 index
, u16 what_to_enumerate
,
569 u16 property_index
, u32
*psetting
)
574 u16
hpi_format_create(struct hpi_format
*p_format
, u16 channels
, u16 format
,
575 u32 sample_rate
, u32 bit_rate
, u32 attributes
)
578 struct hpi_msg_format fmt
;
589 error
= HPI_ERROR_INVALID_CHANNELS
;
592 fmt
.channels
= channels
;
595 case HPI_FORMAT_PCM16_SIGNED
:
596 case HPI_FORMAT_PCM24_SIGNED
:
597 case HPI_FORMAT_PCM32_SIGNED
:
598 case HPI_FORMAT_PCM32_FLOAT
:
599 case HPI_FORMAT_PCM16_BIGENDIAN
:
600 case HPI_FORMAT_PCM8_UNSIGNED
:
601 case HPI_FORMAT_MPEG_L1
:
602 case HPI_FORMAT_MPEG_L2
:
603 case HPI_FORMAT_MPEG_L3
:
604 case HPI_FORMAT_DOLBY_AC2
:
605 case HPI_FORMAT_AA_TAGIT1_HITS
:
606 case HPI_FORMAT_AA_TAGIT1_INSERTS
:
607 case HPI_FORMAT_RAW_BITSTREAM
:
608 case HPI_FORMAT_AA_TAGIT1_HITS_EX1
:
609 case HPI_FORMAT_OEM1
:
610 case HPI_FORMAT_OEM2
:
613 error
= HPI_ERROR_INVALID_FORMAT
;
618 if (sample_rate
< 8000L) {
619 error
= HPI_ERROR_INCOMPATIBLE_SAMPLERATE
;
622 if (sample_rate
> 200000L) {
623 error
= HPI_ERROR_INCOMPATIBLE_SAMPLERATE
;
624 sample_rate
= 200000L;
626 fmt
.sample_rate
= sample_rate
;
629 case HPI_FORMAT_MPEG_L1
:
630 case HPI_FORMAT_MPEG_L2
:
631 case HPI_FORMAT_MPEG_L3
:
632 fmt
.bit_rate
= bit_rate
;
634 case HPI_FORMAT_PCM16_SIGNED
:
635 case HPI_FORMAT_PCM16_BIGENDIAN
:
636 fmt
.bit_rate
= channels
* sample_rate
* 2;
638 case HPI_FORMAT_PCM32_SIGNED
:
639 case HPI_FORMAT_PCM32_FLOAT
:
640 fmt
.bit_rate
= channels
* sample_rate
* 4;
642 case HPI_FORMAT_PCM8_UNSIGNED
:
643 fmt
.bit_rate
= channels
* sample_rate
;
650 case HPI_FORMAT_MPEG_L2
:
652 && (attributes
!= HPI_MPEG_MODE_DEFAULT
)) {
653 attributes
= HPI_MPEG_MODE_DEFAULT
;
654 error
= HPI_ERROR_INVALID_FORMAT
;
655 } else if (attributes
> HPI_MPEG_MODE_DUALCHANNEL
) {
656 attributes
= HPI_MPEG_MODE_DEFAULT
;
657 error
= HPI_ERROR_INVALID_FORMAT
;
659 fmt
.attributes
= attributes
;
662 fmt
.attributes
= attributes
;
665 hpi_msg_to_format(p_format
, &fmt
);
669 u16
hpi_stream_estimate_buffer_size(struct hpi_format
*p_format
,
670 u32 host_polling_rate_in_milli_seconds
, u32
*recommended_buffer_size
)
673 u32 bytes_per_second
;
676 struct hpi_format
*pF
= p_format
;
678 channels
= pF
->channels
;
680 switch (pF
->format
) {
681 case HPI_FORMAT_PCM16_BIGENDIAN
:
682 case HPI_FORMAT_PCM16_SIGNED
:
683 bytes_per_second
= pF
->sample_rate
* 2L * channels
;
685 case HPI_FORMAT_PCM24_SIGNED
:
686 bytes_per_second
= pF
->sample_rate
* 3L * channels
;
688 case HPI_FORMAT_PCM32_SIGNED
:
689 case HPI_FORMAT_PCM32_FLOAT
:
690 bytes_per_second
= pF
->sample_rate
* 4L * channels
;
692 case HPI_FORMAT_PCM8_UNSIGNED
:
693 bytes_per_second
= pF
->sample_rate
* 1L * channels
;
695 case HPI_FORMAT_MPEG_L1
:
696 case HPI_FORMAT_MPEG_L2
:
697 case HPI_FORMAT_MPEG_L3
:
698 bytes_per_second
= pF
->bit_rate
/ 8L;
700 case HPI_FORMAT_DOLBY_AC2
:
702 bytes_per_second
= 256000L / 8L;
705 return HPI_ERROR_INVALID_FORMAT
;
707 size
= (bytes_per_second
* host_polling_rate_in_milli_seconds
* 2) /
710 *recommended_buffer_size
=
711 roundup_pow_of_two(((size
+ 4095L) & ~4095L));
715 u16
hpi_outstream_open(const struct hpi_hsubsys
*ph_subsys
, u16 adapter_index
,
716 u16 outstream_index
, u32
*ph_outstream
)
718 struct hpi_message hm
;
719 struct hpi_response hr
;
720 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
722 hm
.adapter_index
= adapter_index
;
723 hm
.obj_index
= outstream_index
;
725 hpi_send_recv(&hm
, &hr
);
729 hpi_indexes_to_handle(HPI_OBJ_OSTREAM
, adapter_index
,
736 u16
hpi_outstream_close(const struct hpi_hsubsys
*ph_subsys
, u32 h_outstream
)
738 struct hpi_message hm
;
739 struct hpi_response hr
;
741 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
742 HPI_OSTREAM_HOSTBUFFER_FREE
);
743 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
744 hpi_send_recv(&hm
, &hr
);
746 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
747 HPI_OSTREAM_GROUP_RESET
);
748 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
749 hpi_send_recv(&hm
, &hr
);
751 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
753 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
754 hpi_send_recv(&hm
, &hr
);
759 u16
hpi_outstream_get_info_ex(const struct hpi_hsubsys
*ph_subsys
,
760 u32 h_outstream
, u16
*pw_state
, u32
*pbuffer_size
, u32
*pdata_to_play
,
761 u32
*psamples_played
, u32
*pauxiliary_data_to_play
)
763 struct hpi_message hm
;
764 struct hpi_response hr
;
765 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
766 HPI_OSTREAM_GET_INFO
);
767 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
769 hpi_send_recv(&hm
, &hr
);
772 *pw_state
= hr
.u
.d
.u
.stream_info
.state
;
774 *pbuffer_size
= hr
.u
.d
.u
.stream_info
.buffer_size
;
776 *pdata_to_play
= hr
.u
.d
.u
.stream_info
.data_available
;
778 *psamples_played
= hr
.u
.d
.u
.stream_info
.samples_transferred
;
779 if (pauxiliary_data_to_play
)
780 *pauxiliary_data_to_play
=
781 hr
.u
.d
.u
.stream_info
.auxiliary_data_available
;
785 u16
hpi_outstream_write_buf(const struct hpi_hsubsys
*ph_subsys
,
786 u32 h_outstream
, const u8
*pb_data
, u32 bytes_to_write
,
787 const struct hpi_format
*p_format
)
789 struct hpi_message hm
;
790 struct hpi_response hr
;
791 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
793 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
794 hm
.u
.d
.u
.data
.pb_data
= (u8
*)pb_data
;
795 hm
.u
.d
.u
.data
.data_size
= bytes_to_write
;
797 hpi_format_to_msg(&hm
.u
.d
.u
.data
.format
, p_format
);
799 hpi_send_recv(&hm
, &hr
);
804 u16
hpi_outstream_start(const struct hpi_hsubsys
*ph_subsys
, u32 h_outstream
)
806 struct hpi_message hm
;
807 struct hpi_response hr
;
808 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
810 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
812 hpi_send_recv(&hm
, &hr
);
817 u16
hpi_outstream_wait_start(const struct hpi_hsubsys
*ph_subsys
,
820 struct hpi_message hm
;
821 struct hpi_response hr
;
822 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
823 HPI_OSTREAM_WAIT_START
);
824 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
826 hpi_send_recv(&hm
, &hr
);
831 u16
hpi_outstream_stop(const struct hpi_hsubsys
*ph_subsys
, u32 h_outstream
)
833 struct hpi_message hm
;
834 struct hpi_response hr
;
835 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
837 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
839 hpi_send_recv(&hm
, &hr
);
844 u16
hpi_outstream_sinegen(const struct hpi_hsubsys
*ph_subsys
,
847 struct hpi_message hm
;
848 struct hpi_response hr
;
849 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
850 HPI_OSTREAM_SINEGEN
);
851 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
853 hpi_send_recv(&hm
, &hr
);
858 u16
hpi_outstream_reset(const struct hpi_hsubsys
*ph_subsys
, u32 h_outstream
)
860 struct hpi_message hm
;
861 struct hpi_response hr
;
862 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
864 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
866 hpi_send_recv(&hm
, &hr
);
871 u16
hpi_outstream_query_format(const struct hpi_hsubsys
*ph_subsys
,
872 u32 h_outstream
, struct hpi_format
*p_format
)
874 struct hpi_message hm
;
875 struct hpi_response hr
;
877 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
878 HPI_OSTREAM_QUERY_FORMAT
);
879 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
881 hpi_format_to_msg(&hm
.u
.d
.u
.data
.format
, p_format
);
883 hpi_send_recv(&hm
, &hr
);
888 u16
hpi_outstream_set_format(const struct hpi_hsubsys
*ph_subsys
,
889 u32 h_outstream
, struct hpi_format
*p_format
)
891 struct hpi_message hm
;
892 struct hpi_response hr
;
894 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
895 HPI_OSTREAM_SET_FORMAT
);
896 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
898 hpi_format_to_msg(&hm
.u
.d
.u
.data
.format
, p_format
);
900 hpi_send_recv(&hm
, &hr
);
905 u16
hpi_outstream_set_velocity(const struct hpi_hsubsys
*ph_subsys
,
906 u32 h_outstream
, short velocity
)
908 struct hpi_message hm
;
909 struct hpi_response hr
;
911 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
912 HPI_OSTREAM_SET_VELOCITY
);
913 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
914 hm
.u
.d
.u
.velocity
= velocity
;
916 hpi_send_recv(&hm
, &hr
);
921 u16
hpi_outstream_set_punch_in_out(const struct hpi_hsubsys
*ph_subsys
,
922 u32 h_outstream
, u32 punch_in_sample
, u32 punch_out_sample
)
924 struct hpi_message hm
;
925 struct hpi_response hr
;
927 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
928 HPI_OSTREAM_SET_PUNCHINOUT
);
929 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
931 hm
.u
.d
.u
.pio
.punch_in_sample
= punch_in_sample
;
932 hm
.u
.d
.u
.pio
.punch_out_sample
= punch_out_sample
;
934 hpi_send_recv(&hm
, &hr
);
939 u16
hpi_outstream_ancillary_reset(const struct hpi_hsubsys
*ph_subsys
,
940 u32 h_outstream
, u16 mode
)
942 struct hpi_message hm
;
943 struct hpi_response hr
;
945 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
946 HPI_OSTREAM_ANC_RESET
);
947 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
948 hm
.u
.d
.u
.data
.format
.channels
= mode
;
949 hpi_send_recv(&hm
, &hr
);
953 u16
hpi_outstream_ancillary_get_info(const struct hpi_hsubsys
*ph_subsys
,
954 u32 h_outstream
, u32
*pframes_available
)
956 struct hpi_message hm
;
957 struct hpi_response hr
;
959 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
960 HPI_OSTREAM_ANC_GET_INFO
);
961 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
962 hpi_send_recv(&hm
, &hr
);
964 if (pframes_available
)
966 hr
.u
.d
.u
.stream_info
.data_available
/
967 sizeof(struct hpi_anc_frame
);
972 u16
hpi_outstream_ancillary_read(const struct hpi_hsubsys
*ph_subsys
,
973 u32 h_outstream
, struct hpi_anc_frame
*p_anc_frame_buffer
,
974 u32 anc_frame_buffer_size_in_bytes
,
975 u32 number_of_ancillary_frames_to_read
)
977 struct hpi_message hm
;
978 struct hpi_response hr
;
979 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
980 HPI_OSTREAM_ANC_READ
);
981 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
982 hm
.u
.d
.u
.data
.pb_data
= (u8
*)p_anc_frame_buffer
;
983 hm
.u
.d
.u
.data
.data_size
=
984 number_of_ancillary_frames_to_read
*
985 sizeof(struct hpi_anc_frame
);
986 if (hm
.u
.d
.u
.data
.data_size
<= anc_frame_buffer_size_in_bytes
)
987 hpi_send_recv(&hm
, &hr
);
989 hr
.error
= HPI_ERROR_INVALID_DATA_TRANSFER
;
993 u16
hpi_outstream_set_time_scale(const struct hpi_hsubsys
*ph_subsys
,
994 u32 h_outstream
, u32 time_scale
)
996 struct hpi_message hm
;
997 struct hpi_response hr
;
999 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
1000 HPI_OSTREAM_SET_TIMESCALE
);
1001 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
1003 hm
.u
.d
.u
.time_scale
= time_scale
;
1005 hpi_send_recv(&hm
, &hr
);
1010 u16
hpi_outstream_host_buffer_allocate(const struct hpi_hsubsys
*ph_subsys
,
1011 u32 h_outstream
, u32 size_in_bytes
)
1013 struct hpi_message hm
;
1014 struct hpi_response hr
;
1016 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
1017 HPI_OSTREAM_HOSTBUFFER_ALLOC
);
1018 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
1019 hm
.u
.d
.u
.data
.data_size
= size_in_bytes
;
1020 hpi_send_recv(&hm
, &hr
);
1024 u16
hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys
*ph_subsys
,
1025 u32 h_outstream
, u8
**pp_buffer
,
1026 struct hpi_hostbuffer_status
**pp_status
)
1028 struct hpi_message hm
;
1029 struct hpi_response hr
;
1031 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
1032 HPI_OSTREAM_HOSTBUFFER_GET_INFO
);
1033 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
1034 hpi_send_recv(&hm
, &hr
);
1036 if (hr
.error
== 0) {
1038 *pp_buffer
= hr
.u
.d
.u
.hostbuffer_info
.p_buffer
;
1040 *pp_status
= hr
.u
.d
.u
.hostbuffer_info
.p_status
;
1045 u16
hpi_outstream_host_buffer_free(const struct hpi_hsubsys
*ph_subsys
,
1048 struct hpi_message hm
;
1049 struct hpi_response hr
;
1051 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
1052 HPI_OSTREAM_HOSTBUFFER_FREE
);
1053 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
1054 hpi_send_recv(&hm
, &hr
);
1058 u16
hpi_outstream_group_add(const struct hpi_hsubsys
*ph_subsys
,
1059 u32 h_outstream
, u32 h_stream
)
1061 struct hpi_message hm
;
1062 struct hpi_response hr
;
1066 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
1067 HPI_OSTREAM_GROUP_ADD
);
1069 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
1070 c_obj_type
= hpi_handle_object(h_stream
);
1071 switch (c_obj_type
) {
1072 case HPI_OBJ_OSTREAM
:
1073 hm
.u
.d
.u
.stream
.object_type
= HPI_OBJ_OSTREAM
;
1074 u32TOINDEXES(h_stream
, &adapter
,
1075 &hm
.u
.d
.u
.stream
.stream_index
);
1077 case HPI_OBJ_ISTREAM
:
1078 hm
.u
.d
.u
.stream
.object_type
= HPI_OBJ_ISTREAM
;
1079 u32TOINDEXES(h_stream
, &adapter
,
1080 &hm
.u
.d
.u
.stream
.stream_index
);
1083 return HPI_ERROR_INVALID_STREAM
;
1085 if (adapter
!= hm
.adapter_index
)
1086 return HPI_ERROR_NO_INTERADAPTER_GROUPS
;
1088 hpi_send_recv(&hm
, &hr
);
1092 u16
hpi_outstream_group_get_map(const struct hpi_hsubsys
*ph_subsys
,
1093 u32 h_outstream
, u32
*poutstream_map
, u32
*pinstream_map
)
1095 struct hpi_message hm
;
1096 struct hpi_response hr
;
1098 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
1099 HPI_OSTREAM_GROUP_GETMAP
);
1100 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
1101 hpi_send_recv(&hm
, &hr
);
1104 *poutstream_map
= hr
.u
.d
.u
.group_info
.outstream_group_map
;
1106 *pinstream_map
= hr
.u
.d
.u
.group_info
.instream_group_map
;
1111 u16
hpi_outstream_group_reset(const struct hpi_hsubsys
*ph_subsys
,
1114 struct hpi_message hm
;
1115 struct hpi_response hr
;
1117 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_OSTREAM
,
1118 HPI_OSTREAM_GROUP_RESET
);
1119 u32TOINDEXES(h_outstream
, &hm
.adapter_index
, &hm
.obj_index
);
1120 hpi_send_recv(&hm
, &hr
);
1124 u16
hpi_instream_open(const struct hpi_hsubsys
*ph_subsys
, u16 adapter_index
,
1125 u16 instream_index
, u32
*ph_instream
)
1127 struct hpi_message hm
;
1128 struct hpi_response hr
;
1130 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1132 hm
.adapter_index
= adapter_index
;
1133 hm
.obj_index
= instream_index
;
1135 hpi_send_recv(&hm
, &hr
);
1139 hpi_indexes_to_handle(HPI_OBJ_ISTREAM
, adapter_index
,
1147 u16
hpi_instream_close(const struct hpi_hsubsys
*ph_subsys
, u32 h_instream
)
1149 struct hpi_message hm
;
1150 struct hpi_response hr
;
1152 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1153 HPI_ISTREAM_HOSTBUFFER_FREE
);
1154 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1155 hpi_send_recv(&hm
, &hr
);
1157 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1158 HPI_ISTREAM_GROUP_RESET
);
1159 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1160 hpi_send_recv(&hm
, &hr
);
1162 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1164 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1165 hpi_send_recv(&hm
, &hr
);
1170 u16
hpi_instream_query_format(const struct hpi_hsubsys
*ph_subsys
,
1171 u32 h_instream
, const struct hpi_format
*p_format
)
1173 struct hpi_message hm
;
1174 struct hpi_response hr
;
1176 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1177 HPI_ISTREAM_QUERY_FORMAT
);
1178 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1179 hpi_format_to_msg(&hm
.u
.d
.u
.data
.format
, p_format
);
1181 hpi_send_recv(&hm
, &hr
);
1186 u16
hpi_instream_set_format(const struct hpi_hsubsys
*ph_subsys
,
1187 u32 h_instream
, const struct hpi_format
*p_format
)
1189 struct hpi_message hm
;
1190 struct hpi_response hr
;
1192 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1193 HPI_ISTREAM_SET_FORMAT
);
1194 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1195 hpi_format_to_msg(&hm
.u
.d
.u
.data
.format
, p_format
);
1197 hpi_send_recv(&hm
, &hr
);
1202 u16
hpi_instream_read_buf(const struct hpi_hsubsys
*ph_subsys
, u32 h_instream
,
1203 u8
*pb_data
, u32 bytes_to_read
)
1205 struct hpi_message hm
;
1206 struct hpi_response hr
;
1208 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1210 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1211 hm
.u
.d
.u
.data
.data_size
= bytes_to_read
;
1212 hm
.u
.d
.u
.data
.pb_data
= pb_data
;
1214 hpi_send_recv(&hm
, &hr
);
1219 u16
hpi_instream_start(const struct hpi_hsubsys
*ph_subsys
, u32 h_instream
)
1221 struct hpi_message hm
;
1222 struct hpi_response hr
;
1224 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1226 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1228 hpi_send_recv(&hm
, &hr
);
1233 u16
hpi_instream_wait_start(const struct hpi_hsubsys
*ph_subsys
,
1236 struct hpi_message hm
;
1237 struct hpi_response hr
;
1239 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1240 HPI_ISTREAM_WAIT_START
);
1241 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1243 hpi_send_recv(&hm
, &hr
);
1248 u16
hpi_instream_stop(const struct hpi_hsubsys
*ph_subsys
, u32 h_instream
)
1250 struct hpi_message hm
;
1251 struct hpi_response hr
;
1253 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1255 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1257 hpi_send_recv(&hm
, &hr
);
1262 u16
hpi_instream_reset(const struct hpi_hsubsys
*ph_subsys
, u32 h_instream
)
1264 struct hpi_message hm
;
1265 struct hpi_response hr
;
1267 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1269 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1271 hpi_send_recv(&hm
, &hr
);
1276 u16
hpi_instream_get_info_ex(const struct hpi_hsubsys
*ph_subsys
,
1277 u32 h_instream
, u16
*pw_state
, u32
*pbuffer_size
, u32
*pdata_recorded
,
1278 u32
*psamples_recorded
, u32
*pauxiliary_data_recorded
)
1280 struct hpi_message hm
;
1281 struct hpi_response hr
;
1282 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1283 HPI_ISTREAM_GET_INFO
);
1284 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1286 hpi_send_recv(&hm
, &hr
);
1289 *pw_state
= hr
.u
.d
.u
.stream_info
.state
;
1291 *pbuffer_size
= hr
.u
.d
.u
.stream_info
.buffer_size
;
1293 *pdata_recorded
= hr
.u
.d
.u
.stream_info
.data_available
;
1294 if (psamples_recorded
)
1295 *psamples_recorded
= hr
.u
.d
.u
.stream_info
.samples_transferred
;
1296 if (pauxiliary_data_recorded
)
1297 *pauxiliary_data_recorded
=
1298 hr
.u
.d
.u
.stream_info
.auxiliary_data_available
;
1302 u16
hpi_instream_ancillary_reset(const struct hpi_hsubsys
*ph_subsys
,
1303 u32 h_instream
, u16 bytes_per_frame
, u16 mode
, u16 alignment
,
1306 struct hpi_message hm
;
1307 struct hpi_response hr
;
1308 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1309 HPI_ISTREAM_ANC_RESET
);
1310 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1311 hm
.u
.d
.u
.data
.format
.attributes
= bytes_per_frame
;
1312 hm
.u
.d
.u
.data
.format
.format
= (mode
<< 8) | (alignment
& 0xff);
1313 hm
.u
.d
.u
.data
.format
.channels
= idle_bit
;
1314 hpi_send_recv(&hm
, &hr
);
1318 u16
hpi_instream_ancillary_get_info(const struct hpi_hsubsys
*ph_subsys
,
1319 u32 h_instream
, u32
*pframe_space
)
1321 struct hpi_message hm
;
1322 struct hpi_response hr
;
1323 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1324 HPI_ISTREAM_ANC_GET_INFO
);
1325 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1326 hpi_send_recv(&hm
, &hr
);
1329 (hr
.u
.d
.u
.stream_info
.buffer_size
-
1330 hr
.u
.d
.u
.stream_info
.data_available
) /
1331 sizeof(struct hpi_anc_frame
);
1335 u16
hpi_instream_ancillary_write(const struct hpi_hsubsys
*ph_subsys
,
1336 u32 h_instream
, const struct hpi_anc_frame
*p_anc_frame_buffer
,
1337 u32 anc_frame_buffer_size_in_bytes
,
1338 u32 number_of_ancillary_frames_to_write
)
1340 struct hpi_message hm
;
1341 struct hpi_response hr
;
1343 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1344 HPI_ISTREAM_ANC_WRITE
);
1345 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1346 hm
.u
.d
.u
.data
.pb_data
= (u8
*)p_anc_frame_buffer
;
1347 hm
.u
.d
.u
.data
.data_size
=
1348 number_of_ancillary_frames_to_write
*
1349 sizeof(struct hpi_anc_frame
);
1350 if (hm
.u
.d
.u
.data
.data_size
<= anc_frame_buffer_size_in_bytes
)
1351 hpi_send_recv(&hm
, &hr
);
1353 hr
.error
= HPI_ERROR_INVALID_DATA_TRANSFER
;
1357 u16
hpi_instream_host_buffer_allocate(const struct hpi_hsubsys
*ph_subsys
,
1358 u32 h_instream
, u32 size_in_bytes
)
1361 struct hpi_message hm
;
1362 struct hpi_response hr
;
1364 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1365 HPI_ISTREAM_HOSTBUFFER_ALLOC
);
1366 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1367 hm
.u
.d
.u
.data
.data_size
= size_in_bytes
;
1368 hpi_send_recv(&hm
, &hr
);
1372 u16
hpi_instream_host_buffer_get_info(const struct hpi_hsubsys
*ph_subsys
,
1373 u32 h_instream
, u8
**pp_buffer
,
1374 struct hpi_hostbuffer_status
**pp_status
)
1376 struct hpi_message hm
;
1377 struct hpi_response hr
;
1379 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1380 HPI_ISTREAM_HOSTBUFFER_GET_INFO
);
1381 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1382 hpi_send_recv(&hm
, &hr
);
1384 if (hr
.error
== 0) {
1386 *pp_buffer
= hr
.u
.d
.u
.hostbuffer_info
.p_buffer
;
1388 *pp_status
= hr
.u
.d
.u
.hostbuffer_info
.p_status
;
1393 u16
hpi_instream_host_buffer_free(const struct hpi_hsubsys
*ph_subsys
,
1397 struct hpi_message hm
;
1398 struct hpi_response hr
;
1400 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1401 HPI_ISTREAM_HOSTBUFFER_FREE
);
1402 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1403 hpi_send_recv(&hm
, &hr
);
1407 u16
hpi_instream_group_add(const struct hpi_hsubsys
*ph_subsys
,
1408 u32 h_instream
, u32 h_stream
)
1410 struct hpi_message hm
;
1411 struct hpi_response hr
;
1415 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1416 HPI_ISTREAM_GROUP_ADD
);
1418 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1419 c_obj_type
= hpi_handle_object(h_stream
);
1421 switch (c_obj_type
) {
1422 case HPI_OBJ_OSTREAM
:
1423 hm
.u
.d
.u
.stream
.object_type
= HPI_OBJ_OSTREAM
;
1424 u32TOINDEXES(h_stream
, &adapter
,
1425 &hm
.u
.d
.u
.stream
.stream_index
);
1427 case HPI_OBJ_ISTREAM
:
1428 hm
.u
.d
.u
.stream
.object_type
= HPI_OBJ_ISTREAM
;
1429 u32TOINDEXES(h_stream
, &adapter
,
1430 &hm
.u
.d
.u
.stream
.stream_index
);
1433 return HPI_ERROR_INVALID_STREAM
;
1436 if (adapter
!= hm
.adapter_index
)
1437 return HPI_ERROR_NO_INTERADAPTER_GROUPS
;
1439 hpi_send_recv(&hm
, &hr
);
1443 u16
hpi_instream_group_get_map(const struct hpi_hsubsys
*ph_subsys
,
1444 u32 h_instream
, u32
*poutstream_map
, u32
*pinstream_map
)
1446 struct hpi_message hm
;
1447 struct hpi_response hr
;
1449 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1450 HPI_ISTREAM_HOSTBUFFER_FREE
);
1451 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1452 hpi_send_recv(&hm
, &hr
);
1455 *poutstream_map
= hr
.u
.d
.u
.group_info
.outstream_group_map
;
1457 *pinstream_map
= hr
.u
.d
.u
.group_info
.instream_group_map
;
1462 u16
hpi_instream_group_reset(const struct hpi_hsubsys
*ph_subsys
,
1465 struct hpi_message hm
;
1466 struct hpi_response hr
;
1468 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ISTREAM
,
1469 HPI_ISTREAM_GROUP_RESET
);
1470 u32TOINDEXES(h_instream
, &hm
.adapter_index
, &hm
.obj_index
);
1471 hpi_send_recv(&hm
, &hr
);
1475 u16
hpi_mixer_open(const struct hpi_hsubsys
*ph_subsys
, u16 adapter_index
,
1478 struct hpi_message hm
;
1479 struct hpi_response hr
;
1480 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_MIXER
, HPI_MIXER_OPEN
);
1481 hm
.adapter_index
= adapter_index
;
1483 hpi_send_recv(&hm
, &hr
);
1487 hpi_indexes_to_handle(HPI_OBJ_MIXER
, adapter_index
,
1494 u16
hpi_mixer_close(const struct hpi_hsubsys
*ph_subsys
, u32 h_mixer
)
1496 struct hpi_message hm
;
1497 struct hpi_response hr
;
1498 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_MIXER
, HPI_MIXER_CLOSE
);
1499 u32TOINDEX(h_mixer
, &hm
.adapter_index
);
1500 hpi_send_recv(&hm
, &hr
);
1504 u16
hpi_mixer_get_control(const struct hpi_hsubsys
*ph_subsys
, u32 h_mixer
,
1505 u16 src_node_type
, u16 src_node_type_index
, u16 dst_node_type
,
1506 u16 dst_node_type_index
, u16 control_type
, u32
*ph_control
)
1508 struct hpi_message hm
;
1509 struct hpi_response hr
;
1510 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_MIXER
,
1511 HPI_MIXER_GET_CONTROL
);
1512 u32TOINDEX(h_mixer
, &hm
.adapter_index
);
1513 hm
.u
.m
.node_type1
= src_node_type
;
1514 hm
.u
.m
.node_index1
= src_node_type_index
;
1515 hm
.u
.m
.node_type2
= dst_node_type
;
1516 hm
.u
.m
.node_index2
= dst_node_type_index
;
1517 hm
.u
.m
.control_type
= control_type
;
1519 hpi_send_recv(&hm
, &hr
);
1523 hpi_indexes_to_handle(HPI_OBJ_CONTROL
,
1524 hm
.adapter_index
, hr
.u
.m
.control_index
);
1530 u16
hpi_mixer_get_control_by_index(const struct hpi_hsubsys
*ph_subsys
,
1531 u32 h_mixer
, u16 control_index
, u16
*pw_src_node_type
,
1532 u16
*pw_src_node_index
, u16
*pw_dst_node_type
, u16
*pw_dst_node_index
,
1533 u16
*pw_control_type
, u32
*ph_control
)
1535 struct hpi_message hm
;
1536 struct hpi_response hr
;
1537 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_MIXER
,
1538 HPI_MIXER_GET_CONTROL_BY_INDEX
);
1539 u32TOINDEX(h_mixer
, &hm
.adapter_index
);
1540 hm
.u
.m
.control_index
= control_index
;
1541 hpi_send_recv(&hm
, &hr
);
1543 if (pw_src_node_type
) {
1545 hr
.u
.m
.src_node_type
+ HPI_SOURCENODE_NONE
;
1546 *pw_src_node_index
= hr
.u
.m
.src_node_index
;
1547 *pw_dst_node_type
= hr
.u
.m
.dst_node_type
+ HPI_DESTNODE_NONE
;
1548 *pw_dst_node_index
= hr
.u
.m
.dst_node_index
;
1550 if (pw_control_type
)
1551 *pw_control_type
= hr
.u
.m
.control_index
;
1556 hpi_indexes_to_handle(HPI_OBJ_CONTROL
,
1557 hm
.adapter_index
, control_index
);
1564 u16
hpi_mixer_store(const struct hpi_hsubsys
*ph_subsys
, u32 h_mixer
,
1565 enum HPI_MIXER_STORE_COMMAND command
, u16 index
)
1567 struct hpi_message hm
;
1568 struct hpi_response hr
;
1569 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_MIXER
, HPI_MIXER_STORE
);
1570 u32TOINDEX(h_mixer
, &hm
.adapter_index
);
1571 hm
.u
.mx
.store
.command
= command
;
1572 hm
.u
.mx
.store
.index
= index
;
1573 hpi_send_recv(&hm
, &hr
);
1578 u16
hpi_control_param_set(const struct hpi_hsubsys
*ph_subsys
,
1579 const u32 h_control
, const u16 attrib
, const u32 param1
,
1582 struct hpi_message hm
;
1583 struct hpi_response hr
;
1584 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
1585 HPI_CONTROL_SET_STATE
);
1586 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
1587 hm
.u
.c
.attribute
= attrib
;
1588 hm
.u
.c
.param1
= param1
;
1589 hm
.u
.c
.param2
= param2
;
1590 hpi_send_recv(&hm
, &hr
);
1595 u16
hpi_control_param_get(const struct hpi_hsubsys
*ph_subsys
,
1596 const u32 h_control
, const u16 attrib
, u32 param1
, u32 param2
,
1597 u32
*pparam1
, u32
*pparam2
)
1599 struct hpi_message hm
;
1600 struct hpi_response hr
;
1601 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
1602 HPI_CONTROL_GET_STATE
);
1603 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
1604 hm
.u
.c
.attribute
= attrib
;
1605 hm
.u
.c
.param1
= param1
;
1606 hm
.u
.c
.param2
= param2
;
1607 hpi_send_recv(&hm
, &hr
);
1609 *pparam1
= hr
.u
.c
.param1
;
1611 *pparam2
= hr
.u
.c
.param2
;
1616 #define hpi_control_param1_get(s, h, a, p1) \
1617 hpi_control_param_get(s, h, a, 0, 0, p1, NULL)
1618 #define hpi_control_param2_get(s, h, a, p1, p2) \
1619 hpi_control_param_get(s, h, a, 0, 0, p1, p2)
1620 #define hpi_control_ex_param1_get(s, h, a, p1) \
1621 hpi_control_ex_param_get(s, h, a, 0, 0, p1, NULL)
1622 #define hpi_control_ex_param2_get(s, h, a, p1, p2) \
1623 hpi_control_ex_param_get(s, h, a, 0, 0, p1, p2)
1626 u16
hpi_control_query(const struct hpi_hsubsys
*ph_subsys
,
1627 const u32 h_control
, const u16 attrib
, const u32 index
,
1628 const u32 param
, u32
*psetting
)
1630 struct hpi_message hm
;
1631 struct hpi_response hr
;
1632 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
1633 HPI_CONTROL_GET_INFO
);
1634 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
1636 hm
.u
.c
.attribute
= attrib
;
1637 hm
.u
.c
.param1
= index
;
1638 hm
.u
.c
.param2
= param
;
1640 hpi_send_recv(&hm
, &hr
);
1641 *psetting
= hr
.u
.c
.param1
;
1646 static u16
hpi_control_get_string(const struct hpi_hsubsys
*ph_subsys
,
1647 const u32 h_control
, const u16 attribute
, char *psz_string
,
1648 const u32 string_length
)
1650 unsigned int sub_string_index
= 0, j
= 0;
1655 if ((string_length
< 1) || (string_length
> 256))
1656 return HPI_ERROR_INVALID_CONTROL_VALUE
;
1657 for (sub_string_index
= 0; sub_string_index
< string_length
;
1658 sub_string_index
+= 8) {
1659 struct hpi_message hm
;
1660 struct hpi_response hr
;
1662 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
1663 HPI_CONTROL_GET_STATE
);
1664 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
1665 hm
.u
.c
.attribute
= attribute
;
1666 hm
.u
.c
.param1
= sub_string_index
;
1668 hpi_send_recv(&hm
, &hr
);
1670 if (sub_string_index
== 0
1671 && (hr
.u
.cu
.chars8
.remaining_chars
+ 8) >
1673 return HPI_ERROR_INVALID_CONTROL_VALUE
;
1679 for (j
= 0; j
< 8; j
++) {
1680 c
= hr
.u
.cu
.chars8
.sz_data
[j
];
1681 psz_string
[sub_string_index
+ j
] = c
;
1683 if (n
>= string_length
) {
1684 psz_string
[string_length
- 1] = 0;
1685 hE
= HPI_ERROR_INVALID_CONTROL_VALUE
;
1692 if ((hr
.u
.cu
.chars8
.remaining_chars
== 0)
1693 && ((sub_string_index
+ j
) < string_length
)
1696 psz_string
[sub_string_index
+ j
] = c
;
1704 u16
HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys
*ph_subsys
,
1705 const u32 h_aes_rx
, const u32 index
, u16
*pw_format
)
1710 err
= hpi_control_query(ph_subsys
, h_aes_rx
, HPI_AESEBURX_FORMAT
,
1712 *pw_format
= (u16
)qr
;
1716 u16
HPI_AESEBU__receiver_set_format(const struct hpi_hsubsys
*ph_subsys
,
1717 u32 h_control
, u16 format
)
1719 return hpi_control_param_set(ph_subsys
, h_control
,
1720 HPI_AESEBURX_FORMAT
, format
, 0);
1723 u16
HPI_AESEBU__receiver_get_format(const struct hpi_hsubsys
*ph_subsys
,
1724 u32 h_control
, u16
*pw_format
)
1729 err
= hpi_control_param1_get(ph_subsys
, h_control
,
1730 HPI_AESEBURX_FORMAT
, ¶m
);
1731 if (!err
&& pw_format
)
1732 *pw_format
= (u16
)param
;
1737 u16
HPI_AESEBU__receiver_get_sample_rate(const struct hpi_hsubsys
*ph_subsys
,
1738 u32 h_control
, u32
*psample_rate
)
1740 return hpi_control_param1_get(ph_subsys
, h_control
,
1741 HPI_AESEBURX_SAMPLERATE
, psample_rate
);
1744 u16
HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys
*ph_subsys
,
1745 u32 h_control
, u16 index
, u16
*pw_data
)
1747 struct hpi_message hm
;
1748 struct hpi_response hr
;
1749 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
1750 HPI_CONTROL_GET_STATE
);
1751 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
1752 hm
.u
.c
.attribute
= HPI_AESEBURX_USERDATA
;
1753 hm
.u
.c
.param1
= index
;
1755 hpi_send_recv(&hm
, &hr
);
1758 *pw_data
= (u16
)hr
.u
.c
.param2
;
1762 u16
HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys
1763 *ph_subsys
, u32 h_control
, u16 index
, u16
*pw_data
)
1765 struct hpi_message hm
;
1766 struct hpi_response hr
;
1767 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
1768 HPI_CONTROL_GET_STATE
);
1769 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
1770 hm
.u
.c
.attribute
= HPI_AESEBURX_CHANNELSTATUS
;
1771 hm
.u
.c
.param1
= index
;
1773 hpi_send_recv(&hm
, &hr
);
1776 *pw_data
= (u16
)hr
.u
.c
.param2
;
1780 u16
HPI_AESEBU__receiver_get_error_status(const struct hpi_hsubsys
*ph_subsys
,
1781 u32 h_control
, u16
*pw_error_data
)
1786 error
= hpi_control_param1_get(ph_subsys
, h_control
,
1787 HPI_AESEBURX_ERRORSTATUS
, &error_data
);
1789 *pw_error_data
= (u16
)error_data
;
1793 u16
HPI_AESEBU__transmitter_set_sample_rate(const struct hpi_hsubsys
1794 *ph_subsys
, u32 h_control
, u32 sample_rate
)
1796 return hpi_control_param_set(ph_subsys
, h_control
,
1797 HPI_AESEBUTX_SAMPLERATE
, sample_rate
, 0);
1800 u16
HPI_AESEBU__transmitter_set_user_data(const struct hpi_hsubsys
*ph_subsys
,
1801 u32 h_control
, u16 index
, u16 data
)
1803 return hpi_control_param_set(ph_subsys
, h_control
,
1804 HPI_AESEBUTX_USERDATA
, index
, data
);
1807 u16
HPI_AESEBU__transmitter_set_channel_status(const struct hpi_hsubsys
1808 *ph_subsys
, u32 h_control
, u16 index
, u16 data
)
1810 return hpi_control_param_set(ph_subsys
, h_control
,
1811 HPI_AESEBUTX_CHANNELSTATUS
, index
, data
);
1814 u16
HPI_AESEBU__transmitter_get_channel_status(const struct hpi_hsubsys
1815 *ph_subsys
, u32 h_control
, u16 index
, u16
*pw_data
)
1817 return HPI_ERROR_INVALID_OPERATION
;
1820 u16
HPI_AESEBU__transmitter_query_format(const struct hpi_hsubsys
*ph_subsys
,
1821 const u32 h_aes_tx
, const u32 index
, u16
*pw_format
)
1826 err
= hpi_control_query(ph_subsys
, h_aes_tx
, HPI_AESEBUTX_FORMAT
,
1828 *pw_format
= (u16
)qr
;
1832 u16
HPI_AESEBU__transmitter_set_format(const struct hpi_hsubsys
*ph_subsys
,
1833 u32 h_control
, u16 output_format
)
1835 return hpi_control_param_set(ph_subsys
, h_control
,
1836 HPI_AESEBUTX_FORMAT
, output_format
, 0);
1839 u16
HPI_AESEBU__transmitter_get_format(const struct hpi_hsubsys
*ph_subsys
,
1840 u32 h_control
, u16
*pw_output_format
)
1845 err
= hpi_control_param1_get(ph_subsys
, h_control
,
1846 HPI_AESEBUTX_FORMAT
, ¶m
);
1847 if (!err
&& pw_output_format
)
1848 *pw_output_format
= (u16
)param
;
1853 u16
hpi_bitstream_set_clock_edge(const struct hpi_hsubsys
*ph_subsys
,
1854 u32 h_control
, u16 edge_type
)
1856 return hpi_control_param_set(ph_subsys
, h_control
,
1857 HPI_BITSTREAM_CLOCK_EDGE
, edge_type
, 0);
1860 u16
hpi_bitstream_set_data_polarity(const struct hpi_hsubsys
*ph_subsys
,
1861 u32 h_control
, u16 polarity
)
1863 return hpi_control_param_set(ph_subsys
, h_control
,
1864 HPI_BITSTREAM_DATA_POLARITY
, polarity
, 0);
1867 u16
hpi_bitstream_get_activity(const struct hpi_hsubsys
*ph_subsys
,
1868 u32 h_control
, u16
*pw_clk_activity
, u16
*pw_data_activity
)
1870 struct hpi_message hm
;
1871 struct hpi_response hr
;
1872 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
1873 HPI_CONTROL_GET_STATE
);
1874 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
1875 hm
.u
.c
.attribute
= HPI_BITSTREAM_ACTIVITY
;
1876 hpi_send_recv(&hm
, &hr
);
1877 if (pw_clk_activity
)
1878 *pw_clk_activity
= (u16
)hr
.u
.c
.param1
;
1879 if (pw_data_activity
)
1880 *pw_data_activity
= (u16
)hr
.u
.c
.param2
;
1884 u16
hpi_channel_mode_query_mode(const struct hpi_hsubsys
*ph_subsys
,
1885 const u32 h_mode
, const u32 index
, u16
*pw_mode
)
1890 err
= hpi_control_query(ph_subsys
, h_mode
, HPI_CHANNEL_MODE_MODE
,
1896 u16
hpi_channel_mode_set(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
1899 return hpi_control_param_set(ph_subsys
, h_control
,
1900 HPI_CHANNEL_MODE_MODE
, mode
, 0);
1903 u16
hpi_channel_mode_get(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
1907 u16 error
= hpi_control_param1_get(ph_subsys
, h_control
,
1908 HPI_CHANNEL_MODE_MODE
, &mode32
);
1910 *mode
= (u16
)mode32
;
1914 u16
hpi_cobranet_hmi_write(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
1915 u32 hmi_address
, u32 byte_count
, u8
*pb_data
)
1917 struct hpi_message hm
;
1918 struct hpi_response hr
;
1919 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROLEX
,
1920 HPI_CONTROL_SET_STATE
);
1921 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
1923 hm
.u
.cx
.u
.cobranet_data
.byte_count
= byte_count
;
1924 hm
.u
.cx
.u
.cobranet_data
.hmi_address
= hmi_address
;
1926 if (byte_count
<= 8) {
1927 memcpy(hm
.u
.cx
.u
.cobranet_data
.data
, pb_data
, byte_count
);
1928 hm
.u
.cx
.attribute
= HPI_COBRANET_SET
;
1930 hm
.u
.cx
.u
.cobranet_bigdata
.pb_data
= pb_data
;
1931 hm
.u
.cx
.attribute
= HPI_COBRANET_SET_DATA
;
1934 hpi_send_recv(&hm
, &hr
);
1939 u16
hpi_cobranet_hmi_read(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
1940 u32 hmi_address
, u32 max_byte_count
, u32
*pbyte_count
, u8
*pb_data
)
1942 struct hpi_message hm
;
1943 struct hpi_response hr
;
1944 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROLEX
,
1945 HPI_CONTROL_GET_STATE
);
1946 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
1948 hm
.u
.cx
.u
.cobranet_data
.byte_count
= max_byte_count
;
1949 hm
.u
.cx
.u
.cobranet_data
.hmi_address
= hmi_address
;
1951 if (max_byte_count
<= 8) {
1952 hm
.u
.cx
.attribute
= HPI_COBRANET_GET
;
1954 hm
.u
.cx
.u
.cobranet_bigdata
.pb_data
= pb_data
;
1955 hm
.u
.cx
.attribute
= HPI_COBRANET_GET_DATA
;
1958 hpi_send_recv(&hm
, &hr
);
1959 if (!hr
.error
&& pb_data
) {
1961 *pbyte_count
= hr
.u
.cx
.u
.cobranet_data
.byte_count
;
1963 if (*pbyte_count
< max_byte_count
)
1964 max_byte_count
= *pbyte_count
;
1966 if (hm
.u
.cx
.attribute
== HPI_COBRANET_GET
) {
1967 memcpy(pb_data
, hr
.u
.cx
.u
.cobranet_data
.data
,
1977 u16
hpi_cobranet_hmi_get_status(const struct hpi_hsubsys
*ph_subsys
,
1978 u32 h_control
, u32
*pstatus
, u32
*preadable_size
,
1979 u32
*pwriteable_size
)
1981 struct hpi_message hm
;
1982 struct hpi_response hr
;
1983 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROLEX
,
1984 HPI_CONTROL_GET_STATE
);
1985 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
1987 hm
.u
.cx
.attribute
= HPI_COBRANET_GET_STATUS
;
1989 hpi_send_recv(&hm
, &hr
);
1992 *pstatus
= hr
.u
.cx
.u
.cobranet_status
.status
;
1995 hr
.u
.cx
.u
.cobranet_status
.readable_size
;
1996 if (pwriteable_size
)
1998 hr
.u
.cx
.u
.cobranet_status
.writeable_size
;
2003 u16
hpi_cobranet_getI_paddress(const struct hpi_hsubsys
*ph_subsys
,
2004 u32 h_control
, u32
*pi_paddress
)
2009 error
= hpi_cobranet_hmi_read(ph_subsys
, h_control
,
2010 HPI_COBRANET_HMI_cobra_ip_mon_currentIP
, 4, &byte_count
,
2014 ((iP
& 0xff000000) >> 8) | ((iP
& 0x00ff0000) << 8) | ((iP
&
2015 0x0000ff00) >> 8) | ((iP
& 0x000000ff) << 8);
2024 u16
hpi_cobranet_setI_paddress(const struct hpi_hsubsys
*ph_subsys
,
2025 u32 h_control
, u32 i_paddress
)
2030 iP
= ((i_paddress
& 0xff000000) >> 8) | ((i_paddress
& 0x00ff0000) <<
2031 8) | ((i_paddress
& 0x0000ff00) >> 8) | ((i_paddress
&
2034 error
= hpi_cobranet_hmi_write(ph_subsys
, h_control
,
2035 HPI_COBRANET_HMI_cobra_ip_mon_currentIP
, 4, (u8
*)&iP
);
2041 u16
hpi_cobranet_get_staticI_paddress(const struct hpi_hsubsys
*ph_subsys
,
2042 u32 h_control
, u32
*pi_paddress
)
2047 error
= hpi_cobranet_hmi_read(ph_subsys
, h_control
,
2048 HPI_COBRANET_HMI_cobra_ip_mon_staticIP
, 4, &byte_count
,
2052 ((iP
& 0xff000000) >> 8) | ((iP
& 0x00ff0000) << 8) | ((iP
&
2053 0x0000ff00) >> 8) | ((iP
& 0x000000ff) << 8);
2062 u16
hpi_cobranet_set_staticI_paddress(const struct hpi_hsubsys
*ph_subsys
,
2063 u32 h_control
, u32 i_paddress
)
2068 iP
= ((i_paddress
& 0xff000000) >> 8) | ((i_paddress
& 0x00ff0000) <<
2069 8) | ((i_paddress
& 0x0000ff00) >> 8) | ((i_paddress
&
2072 error
= hpi_cobranet_hmi_write(ph_subsys
, h_control
,
2073 HPI_COBRANET_HMI_cobra_ip_mon_staticIP
, 4, (u8
*)&iP
);
2079 u16
hpi_cobranet_getMA_caddress(const struct hpi_hsubsys
*ph_subsys
,
2080 u32 h_control
, u32
*pmAC_MS_bs
, u32
*pmAC_LS_bs
)
2085 error
= hpi_cobranet_hmi_read(ph_subsys
, h_control
,
2086 HPI_COBRANET_HMI_cobra_if_phy_address
, 4, &byte_count
,
2089 ((mAC
& 0xff000000) >> 8) | ((mAC
& 0x00ff0000) << 8) | ((mAC
2090 & 0x0000ff00) >> 8) | ((mAC
& 0x000000ff) << 8);
2091 error
+= hpi_cobranet_hmi_read(ph_subsys
, h_control
,
2092 HPI_COBRANET_HMI_cobra_if_phy_address
+ 1, 4, &byte_count
,
2095 ((mAC
& 0xff000000) >> 8) | ((mAC
& 0x00ff0000) << 8) | ((mAC
2096 & 0x0000ff00) >> 8) | ((mAC
& 0x000000ff) << 8);
2106 u16
hpi_compander_set(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2107 u16 attack
, u16 decay
, short ratio100
, short threshold0_01dB
,
2108 short makeup_gain0_01dB
)
2110 struct hpi_message hm
;
2111 struct hpi_response hr
;
2112 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2113 HPI_CONTROL_SET_STATE
);
2114 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2116 hm
.u
.c
.param1
= attack
+ ((u32
)ratio100
<< 16);
2117 hm
.u
.c
.param2
= (decay
& 0xFFFFL
);
2118 hm
.u
.c
.an_log_value
[0] = threshold0_01dB
;
2119 hm
.u
.c
.an_log_value
[1] = makeup_gain0_01dB
;
2120 hm
.u
.c
.attribute
= HPI_COMPANDER_PARAMS
;
2122 hpi_send_recv(&hm
, &hr
);
2127 u16
hpi_compander_get(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2128 u16
*pw_attack
, u16
*pw_decay
, short *pw_ratio100
,
2129 short *pn_threshold0_01dB
, short *pn_makeup_gain0_01dB
)
2131 struct hpi_message hm
;
2132 struct hpi_response hr
;
2133 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2134 HPI_CONTROL_GET_STATE
);
2135 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2136 hm
.u
.c
.attribute
= HPI_COMPANDER_PARAMS
;
2138 hpi_send_recv(&hm
, &hr
);
2141 *pw_attack
= (short)(hr
.u
.c
.param1
& 0xFFFF);
2143 *pw_decay
= (short)(hr
.u
.c
.param2
& 0xFFFF);
2145 *pw_ratio100
= (short)(hr
.u
.c
.param1
>> 16);
2147 if (pn_threshold0_01dB
)
2148 *pn_threshold0_01dB
= hr
.u
.c
.an_log_value
[0];
2149 if (pn_makeup_gain0_01dB
)
2150 *pn_makeup_gain0_01dB
= hr
.u
.c
.an_log_value
[1];
2155 u16
hpi_level_query_range(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2156 short *min_gain_01dB
, short *max_gain_01dB
, short *step_gain_01dB
)
2158 struct hpi_message hm
;
2159 struct hpi_response hr
;
2160 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2161 HPI_CONTROL_GET_STATE
);
2162 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2163 hm
.u
.c
.attribute
= HPI_LEVEL_RANGE
;
2165 hpi_send_recv(&hm
, &hr
);
2167 hr
.u
.c
.an_log_value
[0] = 0;
2168 hr
.u
.c
.an_log_value
[1] = 0;
2172 *min_gain_01dB
= hr
.u
.c
.an_log_value
[0];
2174 *max_gain_01dB
= hr
.u
.c
.an_log_value
[1];
2176 *step_gain_01dB
= (short)hr
.u
.c
.param1
;
2180 u16
hpi_level_set_gain(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2181 short an_gain0_01dB
[HPI_MAX_CHANNELS
]
2184 struct hpi_message hm
;
2185 struct hpi_response hr
;
2187 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2188 HPI_CONTROL_SET_STATE
);
2189 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2190 memcpy(hm
.u
.c
.an_log_value
, an_gain0_01dB
,
2191 sizeof(short) * HPI_MAX_CHANNELS
);
2192 hm
.u
.c
.attribute
= HPI_LEVEL_GAIN
;
2194 hpi_send_recv(&hm
, &hr
);
2199 u16
hpi_level_get_gain(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2200 short an_gain0_01dB
[HPI_MAX_CHANNELS
]
2203 struct hpi_message hm
;
2204 struct hpi_response hr
;
2205 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2206 HPI_CONTROL_GET_STATE
);
2207 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2208 hm
.u
.c
.attribute
= HPI_LEVEL_GAIN
;
2210 hpi_send_recv(&hm
, &hr
);
2212 memcpy(an_gain0_01dB
, hr
.u
.c
.an_log_value
,
2213 sizeof(short) * HPI_MAX_CHANNELS
);
2217 u16
hpi_meter_query_channels(const struct hpi_hsubsys
*ph_subsys
,
2218 const u32 h_meter
, u32
*p_channels
)
2220 return hpi_control_query(ph_subsys
, h_meter
, HPI_METER_NUM_CHANNELS
,
2224 u16
hpi_meter_get_peak(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2225 short an_peakdB
[HPI_MAX_CHANNELS
]
2230 struct hpi_message hm
;
2231 struct hpi_response hr
;
2233 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2234 HPI_CONTROL_GET_STATE
);
2235 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2236 hm
.obj_index
= hm
.obj_index
;
2237 hm
.u
.c
.attribute
= HPI_METER_PEAK
;
2239 hpi_send_recv(&hm
, &hr
);
2242 memcpy(an_peakdB
, hr
.u
.c
.an_log_value
,
2243 sizeof(short) * HPI_MAX_CHANNELS
);
2245 for (i
= 0; i
< HPI_MAX_CHANNELS
; i
++)
2246 an_peakdB
[i
] = HPI_METER_MINIMUM
;
2250 u16
hpi_meter_get_rms(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2251 short an_rmsdB
[HPI_MAX_CHANNELS
]
2256 struct hpi_message hm
;
2257 struct hpi_response hr
;
2259 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2260 HPI_CONTROL_GET_STATE
);
2261 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2262 hm
.u
.c
.attribute
= HPI_METER_RMS
;
2264 hpi_send_recv(&hm
, &hr
);
2267 memcpy(an_rmsdB
, hr
.u
.c
.an_log_value
,
2268 sizeof(short) * HPI_MAX_CHANNELS
);
2270 for (i
= 0; i
< HPI_MAX_CHANNELS
; i
++)
2271 an_rmsdB
[i
] = HPI_METER_MINIMUM
;
2276 u16
hpi_meter_set_rms_ballistics(const struct hpi_hsubsys
*ph_subsys
,
2277 u32 h_control
, u16 attack
, u16 decay
)
2279 return hpi_control_param_set(ph_subsys
, h_control
,
2280 HPI_METER_RMS_BALLISTICS
, attack
, decay
);
2283 u16
hpi_meter_get_rms_ballistics(const struct hpi_hsubsys
*ph_subsys
,
2284 u32 h_control
, u16
*pn_attack
, u16
*pn_decay
)
2290 error
= hpi_control_param2_get(ph_subsys
, h_control
,
2291 HPI_METER_RMS_BALLISTICS
, &attack
, &decay
);
2294 *pn_attack
= (unsigned short)attack
;
2296 *pn_decay
= (unsigned short)decay
;
2301 u16
hpi_meter_set_peak_ballistics(const struct hpi_hsubsys
*ph_subsys
,
2302 u32 h_control
, u16 attack
, u16 decay
)
2304 return hpi_control_param_set(ph_subsys
, h_control
,
2305 HPI_METER_PEAK_BALLISTICS
, attack
, decay
);
2308 u16
hpi_meter_get_peak_ballistics(const struct hpi_hsubsys
*ph_subsys
,
2309 u32 h_control
, u16
*pn_attack
, u16
*pn_decay
)
2315 error
= hpi_control_param2_get(ph_subsys
, h_control
,
2316 HPI_METER_PEAK_BALLISTICS
, &attack
, &decay
);
2319 *pn_attack
= (short)attack
;
2321 *pn_decay
= (short)decay
;
2326 u16
hpi_microphone_set_phantom_power(const struct hpi_hsubsys
*ph_subsys
,
2327 u32 h_control
, u16 on_off
)
2329 return hpi_control_param_set(ph_subsys
, h_control
,
2330 HPI_MICROPHONE_PHANTOM_POWER
, (u32
)on_off
, 0);
2333 u16
hpi_microphone_get_phantom_power(const struct hpi_hsubsys
*ph_subsys
,
2334 u32 h_control
, u16
*pw_on_off
)
2338 error
= hpi_control_param1_get(ph_subsys
, h_control
,
2339 HPI_MICROPHONE_PHANTOM_POWER
, &on_off
);
2341 *pw_on_off
= (u16
)on_off
;
2345 u16
hpi_multiplexer_set_source(const struct hpi_hsubsys
*ph_subsys
,
2346 u32 h_control
, u16 source_node_type
, u16 source_node_index
)
2348 return hpi_control_param_set(ph_subsys
, h_control
,
2349 HPI_MULTIPLEXER_SOURCE
, source_node_type
, source_node_index
);
2352 u16
hpi_multiplexer_get_source(const struct hpi_hsubsys
*ph_subsys
,
2353 u32 h_control
, u16
*source_node_type
, u16
*source_node_index
)
2356 u16 error
= hpi_control_param2_get(ph_subsys
, h_control
,
2357 HPI_MULTIPLEXER_SOURCE
, &node
,
2359 if (source_node_type
)
2360 *source_node_type
= (u16
)node
;
2361 if (source_node_index
)
2362 *source_node_index
= (u16
)index
;
2366 u16
hpi_multiplexer_query_source(const struct hpi_hsubsys
*ph_subsys
,
2367 u32 h_control
, u16 index
, u16
*source_node_type
,
2368 u16
*source_node_index
)
2370 struct hpi_message hm
;
2371 struct hpi_response hr
;
2372 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2373 HPI_CONTROL_GET_STATE
);
2374 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2375 hm
.u
.c
.attribute
= HPI_MULTIPLEXER_QUERYSOURCE
;
2376 hm
.u
.c
.param1
= index
;
2378 hpi_send_recv(&hm
, &hr
);
2380 if (source_node_type
)
2381 *source_node_type
= (u16
)hr
.u
.c
.param1
;
2382 if (source_node_index
)
2383 *source_node_index
= (u16
)hr
.u
.c
.param2
;
2387 u16
hpi_parametricEQ__get_info(const struct hpi_hsubsys
*ph_subsys
,
2388 u32 h_control
, u16
*pw_number_of_bands
, u16
*pw_on_off
)
2394 error
= hpi_control_param2_get(ph_subsys
, h_control
,
2395 HPI_EQUALIZER_NUM_FILTERS
, &oO
, &oB
);
2396 if (pw_number_of_bands
)
2397 *pw_number_of_bands
= (u16
)oB
;
2399 *pw_on_off
= (u16
)oO
;
2403 u16
hpi_parametricEQ__set_state(const struct hpi_hsubsys
*ph_subsys
,
2404 u32 h_control
, u16 on_off
)
2406 return hpi_control_param_set(ph_subsys
, h_control
,
2407 HPI_EQUALIZER_NUM_FILTERS
, on_off
, 0);
2410 u16
hpi_parametricEQ__get_band(const struct hpi_hsubsys
*ph_subsys
,
2411 u32 h_control
, u16 index
, u16
*pn_type
, u32
*pfrequency_hz
,
2412 short *pnQ100
, short *pn_gain0_01dB
)
2414 struct hpi_message hm
;
2415 struct hpi_response hr
;
2416 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2417 HPI_CONTROL_GET_STATE
);
2418 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2419 hm
.u
.c
.attribute
= HPI_EQUALIZER_FILTER
;
2420 hm
.u
.c
.param2
= index
;
2422 hpi_send_recv(&hm
, &hr
);
2425 *pfrequency_hz
= hr
.u
.c
.param1
;
2427 *pn_type
= (u16
)(hr
.u
.c
.param2
>> 16);
2429 *pnQ100
= hr
.u
.c
.an_log_value
[1];
2431 *pn_gain0_01dB
= hr
.u
.c
.an_log_value
[0];
2436 u16
hpi_parametricEQ__set_band(const struct hpi_hsubsys
*ph_subsys
,
2437 u32 h_control
, u16 index
, u16 type
, u32 frequency_hz
, short q100
,
2440 struct hpi_message hm
;
2441 struct hpi_response hr
;
2442 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2443 HPI_CONTROL_SET_STATE
);
2444 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2446 hm
.u
.c
.param1
= frequency_hz
;
2447 hm
.u
.c
.param2
= (index
& 0xFFFFL
) + ((u32
)type
<< 16);
2448 hm
.u
.c
.an_log_value
[0] = gain0_01dB
;
2449 hm
.u
.c
.an_log_value
[1] = q100
;
2450 hm
.u
.c
.attribute
= HPI_EQUALIZER_FILTER
;
2452 hpi_send_recv(&hm
, &hr
);
2457 u16
hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys
*ph_subsys
,
2458 u32 h_control
, u16 index
, short coeffs
[5]
2461 struct hpi_message hm
;
2462 struct hpi_response hr
;
2463 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2464 HPI_CONTROL_GET_STATE
);
2465 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2466 hm
.u
.c
.attribute
= HPI_EQUALIZER_COEFFICIENTS
;
2467 hm
.u
.c
.param2
= index
;
2469 hpi_send_recv(&hm
, &hr
);
2471 coeffs
[0] = (short)hr
.u
.c
.an_log_value
[0];
2472 coeffs
[1] = (short)hr
.u
.c
.an_log_value
[1];
2473 coeffs
[2] = (short)hr
.u
.c
.param1
;
2474 coeffs
[3] = (short)(hr
.u
.c
.param1
>> 16);
2475 coeffs
[4] = (short)hr
.u
.c
.param2
;
2480 u16
hpi_sample_clock_query_source(const struct hpi_hsubsys
*ph_subsys
,
2481 const u32 h_clock
, const u32 index
, u16
*pw_source
)
2486 err
= hpi_control_query(ph_subsys
, h_clock
, HPI_SAMPLECLOCK_SOURCE
,
2488 *pw_source
= (u16
)qr
;
2492 u16
hpi_sample_clock_set_source(const struct hpi_hsubsys
*ph_subsys
,
2493 u32 h_control
, u16 source
)
2495 return hpi_control_param_set(ph_subsys
, h_control
,
2496 HPI_SAMPLECLOCK_SOURCE
, source
, 0);
2499 u16
hpi_sample_clock_get_source(const struct hpi_hsubsys
*ph_subsys
,
2500 u32 h_control
, u16
*pw_source
)
2504 error
= hpi_control_param1_get(ph_subsys
, h_control
,
2505 HPI_SAMPLECLOCK_SOURCE
, &source
);
2508 *pw_source
= (u16
)source
;
2512 u16
hpi_sample_clock_query_source_index(const struct hpi_hsubsys
*ph_subsys
,
2513 const u32 h_clock
, const u32 index
, const u32 source
,
2514 u16
*pw_source_index
)
2519 err
= hpi_control_query(ph_subsys
, h_clock
,
2520 HPI_SAMPLECLOCK_SOURCE_INDEX
, index
, source
, &qr
);
2521 *pw_source_index
= (u16
)qr
;
2525 u16
hpi_sample_clock_set_source_index(const struct hpi_hsubsys
*ph_subsys
,
2526 u32 h_control
, u16 source_index
)
2528 return hpi_control_param_set(ph_subsys
, h_control
,
2529 HPI_SAMPLECLOCK_SOURCE_INDEX
, source_index
, 0);
2532 u16
hpi_sample_clock_get_source_index(const struct hpi_hsubsys
*ph_subsys
,
2533 u32 h_control
, u16
*pw_source_index
)
2536 u32 source_index
= 0;
2537 error
= hpi_control_param1_get(ph_subsys
, h_control
,
2538 HPI_SAMPLECLOCK_SOURCE_INDEX
, &source_index
);
2540 if (pw_source_index
)
2541 *pw_source_index
= (u16
)source_index
;
2545 u16
hpi_sample_clock_query_local_rate(const struct hpi_hsubsys
*ph_subsys
,
2546 const u32 h_clock
, const u32 index
, u32
*prate
)
2549 err
= hpi_control_query(ph_subsys
, h_clock
,
2550 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE
, index
, 0, prate
);
2555 u16
hpi_sample_clock_set_local_rate(const struct hpi_hsubsys
*ph_subsys
,
2556 u32 h_control
, u32 sample_rate
)
2558 return hpi_control_param_set(ph_subsys
, h_control
,
2559 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE
, sample_rate
, 0);
2562 u16
hpi_sample_clock_get_local_rate(const struct hpi_hsubsys
*ph_subsys
,
2563 u32 h_control
, u32
*psample_rate
)
2566 u32 sample_rate
= 0;
2567 error
= hpi_control_param1_get(ph_subsys
, h_control
,
2568 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE
, &sample_rate
);
2571 *psample_rate
= sample_rate
;
2575 u16
hpi_sample_clock_get_sample_rate(const struct hpi_hsubsys
*ph_subsys
,
2576 u32 h_control
, u32
*psample_rate
)
2579 u32 sample_rate
= 0;
2580 error
= hpi_control_param1_get(ph_subsys
, h_control
,
2581 HPI_SAMPLECLOCK_SAMPLERATE
, &sample_rate
);
2584 *psample_rate
= sample_rate
;
2588 u16
hpi_sample_clock_set_auto(const struct hpi_hsubsys
*ph_subsys
,
2589 u32 h_control
, u32 enable
)
2591 return hpi_control_param_set(ph_subsys
, h_control
,
2592 HPI_SAMPLECLOCK_AUTO
, enable
, 0);
2595 u16
hpi_sample_clock_get_auto(const struct hpi_hsubsys
*ph_subsys
,
2596 u32 h_control
, u32
*penable
)
2598 return hpi_control_param1_get(ph_subsys
, h_control
,
2599 HPI_SAMPLECLOCK_AUTO
, penable
);
2602 u16
hpi_sample_clock_set_local_rate_lock(const struct hpi_hsubsys
*ph_subsys
,
2603 u32 h_control
, u32 lock
)
2605 return hpi_control_param_set(ph_subsys
, h_control
,
2606 HPI_SAMPLECLOCK_LOCAL_LOCK
, lock
, 0);
2609 u16
hpi_sample_clock_get_local_rate_lock(const struct hpi_hsubsys
*ph_subsys
,
2610 u32 h_control
, u32
*plock
)
2612 return hpi_control_param1_get(ph_subsys
, h_control
,
2613 HPI_SAMPLECLOCK_LOCAL_LOCK
, plock
);
2616 u16
hpi_tone_detector_get_frequency(const struct hpi_hsubsys
*ph_subsys
,
2617 u32 h_control
, u32 index
, u32
*frequency
)
2619 return hpi_control_param_get(ph_subsys
, h_control
,
2620 HPI_TONEDETECTOR_FREQUENCY
, index
, 0, frequency
, NULL
);
2623 u16
hpi_tone_detector_get_state(const struct hpi_hsubsys
*ph_subsys
,
2624 u32 h_control
, u32
*state
)
2626 return hpi_control_param_get(ph_subsys
, h_control
,
2627 HPI_TONEDETECTOR_STATE
, 0, 0, (u32
*)state
, NULL
);
2630 u16
hpi_tone_detector_set_enable(const struct hpi_hsubsys
*ph_subsys
,
2631 u32 h_control
, u32 enable
)
2633 return hpi_control_param_set(ph_subsys
, h_control
, HPI_GENERIC_ENABLE
,
2637 u16
hpi_tone_detector_get_enable(const struct hpi_hsubsys
*ph_subsys
,
2638 u32 h_control
, u32
*enable
)
2640 return hpi_control_param_get(ph_subsys
, h_control
, HPI_GENERIC_ENABLE
,
2641 0, 0, (u32
*)enable
, NULL
);
2644 u16
hpi_tone_detector_set_event_enable(const struct hpi_hsubsys
*ph_subsys
,
2645 u32 h_control
, u32 event_enable
)
2647 return hpi_control_param_set(ph_subsys
, h_control
,
2648 HPI_GENERIC_EVENT_ENABLE
, (u32
)event_enable
, 0);
2651 u16
hpi_tone_detector_get_event_enable(const struct hpi_hsubsys
*ph_subsys
,
2652 u32 h_control
, u32
*event_enable
)
2654 return hpi_control_param_get(ph_subsys
, h_control
,
2655 HPI_GENERIC_EVENT_ENABLE
, 0, 0, (u32
*)event_enable
, NULL
);
2658 u16
hpi_tone_detector_set_threshold(const struct hpi_hsubsys
*ph_subsys
,
2659 u32 h_control
, int threshold
)
2661 return hpi_control_param_set(ph_subsys
, h_control
,
2662 HPI_TONEDETECTOR_THRESHOLD
, (u32
)threshold
, 0);
2665 u16
hpi_tone_detector_get_threshold(const struct hpi_hsubsys
*ph_subsys
,
2666 u32 h_control
, int *threshold
)
2668 return hpi_control_param_get(ph_subsys
, h_control
,
2669 HPI_TONEDETECTOR_THRESHOLD
, 0, 0, (u32
*)threshold
, NULL
);
2672 u16
hpi_silence_detector_get_state(const struct hpi_hsubsys
*ph_subsys
,
2673 u32 h_control
, u32
*state
)
2675 return hpi_control_param_get(ph_subsys
, h_control
,
2676 HPI_SILENCEDETECTOR_STATE
, 0, 0, (u32
*)state
, NULL
);
2679 u16
hpi_silence_detector_set_enable(const struct hpi_hsubsys
*ph_subsys
,
2680 u32 h_control
, u32 enable
)
2682 return hpi_control_param_set(ph_subsys
, h_control
, HPI_GENERIC_ENABLE
,
2686 u16
hpi_silence_detector_get_enable(const struct hpi_hsubsys
*ph_subsys
,
2687 u32 h_control
, u32
*enable
)
2689 return hpi_control_param_get(ph_subsys
, h_control
, HPI_GENERIC_ENABLE
,
2690 0, 0, (u32
*)enable
, NULL
);
2693 u16
hpi_silence_detector_set_event_enable(const struct hpi_hsubsys
*ph_subsys
,
2694 u32 h_control
, u32 event_enable
)
2696 return hpi_control_param_set(ph_subsys
, h_control
,
2697 HPI_GENERIC_EVENT_ENABLE
, (u32
)event_enable
, 0);
2700 u16
hpi_silence_detector_get_event_enable(const struct hpi_hsubsys
*ph_subsys
,
2701 u32 h_control
, u32
*event_enable
)
2703 return hpi_control_param_get(ph_subsys
, h_control
,
2704 HPI_GENERIC_EVENT_ENABLE
, 0, 0, (u32
*)event_enable
, NULL
);
2707 u16
hpi_silence_detector_set_delay(const struct hpi_hsubsys
*ph_subsys
,
2708 u32 h_control
, u32 delay
)
2710 return hpi_control_param_set(ph_subsys
, h_control
,
2711 HPI_SILENCEDETECTOR_DELAY
, (u32
)delay
, 0);
2714 u16
hpi_silence_detector_get_delay(const struct hpi_hsubsys
*ph_subsys
,
2715 u32 h_control
, u32
*delay
)
2717 return hpi_control_param_get(ph_subsys
, h_control
,
2718 HPI_SILENCEDETECTOR_DELAY
, 0, 0, (u32
*)delay
, NULL
);
2721 u16
hpi_silence_detector_set_threshold(const struct hpi_hsubsys
*ph_subsys
,
2722 u32 h_control
, int threshold
)
2724 return hpi_control_param_set(ph_subsys
, h_control
,
2725 HPI_SILENCEDETECTOR_THRESHOLD
, (u32
)threshold
, 0);
2728 u16
hpi_silence_detector_get_threshold(const struct hpi_hsubsys
*ph_subsys
,
2729 u32 h_control
, int *threshold
)
2731 return hpi_control_param_get(ph_subsys
, h_control
,
2732 HPI_SILENCEDETECTOR_THRESHOLD
, 0, 0, (u32
*)threshold
, NULL
);
2735 u16
hpi_tuner_query_band(const struct hpi_hsubsys
*ph_subsys
,
2736 const u32 h_tuner
, const u32 index
, u16
*pw_band
)
2741 err
= hpi_control_query(ph_subsys
, h_tuner
, HPI_TUNER_BAND
, index
, 0,
2747 u16
hpi_tuner_set_band(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2750 return hpi_control_param_set(ph_subsys
, h_control
, HPI_TUNER_BAND
,
2754 u16
hpi_tuner_get_band(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2760 error
= hpi_control_param1_get(ph_subsys
, h_control
, HPI_TUNER_BAND
,
2763 *pw_band
= (u16
)band
;
2767 u16
hpi_tuner_query_frequency(const struct hpi_hsubsys
*ph_subsys
,
2768 const u32 h_tuner
, const u32 index
, const u16 band
, u32
*pfreq
)
2770 return hpi_control_query(ph_subsys
, h_tuner
, HPI_TUNER_FREQ
, index
,
2774 u16
hpi_tuner_set_frequency(const struct hpi_hsubsys
*ph_subsys
,
2775 u32 h_control
, u32 freq_ink_hz
)
2777 return hpi_control_param_set(ph_subsys
, h_control
, HPI_TUNER_FREQ
,
2781 u16
hpi_tuner_get_frequency(const struct hpi_hsubsys
*ph_subsys
,
2782 u32 h_control
, u32
*pw_freq_ink_hz
)
2784 return hpi_control_param1_get(ph_subsys
, h_control
, HPI_TUNER_FREQ
,
2788 u16
hpi_tuner_query_gain(const struct hpi_hsubsys
*ph_subsys
,
2789 const u32 h_tuner
, const u32 index
, u16
*pw_gain
)
2794 err
= hpi_control_query(ph_subsys
, h_tuner
, HPI_TUNER_BAND
, index
, 0,
2800 u16
hpi_tuner_set_gain(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2803 return hpi_control_param_set(ph_subsys
, h_control
, HPI_TUNER_GAIN
,
2807 u16
hpi_tuner_get_gain(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2813 error
= hpi_control_param1_get(ph_subsys
, h_control
, HPI_TUNER_GAIN
,
2816 *pn_gain
= (u16
)gain
;
2820 u16
hpi_tuner_getRF_level(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2823 struct hpi_message hm
;
2824 struct hpi_response hr
;
2825 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2826 HPI_CONTROL_GET_STATE
);
2827 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2828 hm
.u
.c
.attribute
= HPI_TUNER_LEVEL
;
2829 hm
.u
.c
.param1
= HPI_TUNER_LEVEL_AVERAGE
;
2830 hpi_send_recv(&hm
, &hr
);
2832 *pw_level
= (short)hr
.u
.c
.param1
;
2836 u16
hpi_tuner_get_rawRF_level(const struct hpi_hsubsys
*ph_subsys
,
2837 u32 h_control
, short *pw_level
)
2839 struct hpi_message hm
;
2840 struct hpi_response hr
;
2841 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2842 HPI_CONTROL_GET_STATE
);
2843 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2844 hm
.u
.c
.attribute
= HPI_TUNER_LEVEL
;
2845 hm
.u
.c
.param1
= HPI_TUNER_LEVEL_RAW
;
2846 hpi_send_recv(&hm
, &hr
);
2848 *pw_level
= (short)hr
.u
.c
.param1
;
2852 u16
hpi_tuner_query_deemphasis(const struct hpi_hsubsys
*ph_subsys
,
2853 const u32 h_tuner
, const u32 index
, const u16 band
, u32
*pdeemphasis
)
2855 return hpi_control_query(ph_subsys
, h_tuner
, HPI_TUNER_DEEMPHASIS
,
2856 index
, band
, pdeemphasis
);
2859 u16
hpi_tuner_set_deemphasis(const struct hpi_hsubsys
*ph_subsys
,
2860 u32 h_control
, u32 deemphasis
)
2862 return hpi_control_param_set(ph_subsys
, h_control
,
2863 HPI_TUNER_DEEMPHASIS
, deemphasis
, 0);
2866 u16
hpi_tuner_get_deemphasis(const struct hpi_hsubsys
*ph_subsys
,
2867 u32 h_control
, u32
*pdeemphasis
)
2869 return hpi_control_param1_get(ph_subsys
, h_control
,
2870 HPI_TUNER_DEEMPHASIS
, pdeemphasis
);
2873 u16
hpi_tuner_query_program(const struct hpi_hsubsys
*ph_subsys
,
2874 const u32 h_tuner
, u32
*pbitmap_program
)
2876 return hpi_control_query(ph_subsys
, h_tuner
, HPI_TUNER_PROGRAM
, 0, 0,
2880 u16
hpi_tuner_set_program(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2883 return hpi_control_param_set(ph_subsys
, h_control
, HPI_TUNER_PROGRAM
,
2887 u16
hpi_tuner_get_program(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2890 return hpi_control_param1_get(ph_subsys
, h_control
, HPI_TUNER_PROGRAM
,
2894 u16
hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys
*ph_subsys
,
2895 u32 h_control
, char *psz_dsp_version
, const u32 string_size
)
2897 return hpi_control_get_string(ph_subsys
, h_control
,
2898 HPI_TUNER_HDRADIO_DSP_VERSION
, psz_dsp_version
, string_size
);
2901 u16
hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys
*ph_subsys
,
2902 u32 h_control
, char *psz_sdk_version
, const u32 string_size
)
2904 return hpi_control_get_string(ph_subsys
, h_control
,
2905 HPI_TUNER_HDRADIO_SDK_VERSION
, psz_sdk_version
, string_size
);
2908 u16
hpi_tuner_get_status(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2909 u16
*pw_status_mask
, u16
*pw_status
)
2914 error
= hpi_control_param1_get(ph_subsys
, h_control
, HPI_TUNER_STATUS
,
2918 *pw_status_mask
= (u16
)(status
>> 16);
2919 *pw_status
= (u16
)(status
& 0xFFFF);
2921 *pw_status_mask
= 0;
2928 u16
hpi_tuner_set_mode(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2929 u32 mode
, u32 value
)
2931 return hpi_control_param_set(ph_subsys
, h_control
, HPI_TUNER_MODE
,
2935 u16
hpi_tuner_get_mode(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2936 u32 mode
, u32
*pn_value
)
2938 return hpi_control_param_get(ph_subsys
, h_control
, HPI_TUNER_MODE
,
2939 mode
, 0, pn_value
, NULL
);
2942 u16
hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys
*ph_subsys
,
2943 u32 h_control
, u32
*pquality
)
2945 return hpi_control_param_get(ph_subsys
, h_control
,
2946 HPI_TUNER_HDRADIO_SIGNAL_QUALITY
, 0, 0, pquality
, NULL
);
2949 u16
hpi_tuner_get_hd_radio_signal_blend(const struct hpi_hsubsys
*ph_subsys
,
2950 u32 h_control
, u32
*pblend
)
2952 return hpi_control_param_get(ph_subsys
, h_control
,
2953 HPI_TUNER_HDRADIO_BLEND
, 0, 0, pblend
, NULL
);
2956 u16
hpi_tuner_set_hd_radio_signal_blend(const struct hpi_hsubsys
*ph_subsys
,
2957 u32 h_control
, const u32 blend
)
2959 return hpi_control_param_set(ph_subsys
, h_control
,
2960 HPI_TUNER_HDRADIO_BLEND
, blend
, 0);
2963 u16
hpi_tuner_getRDS(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2966 struct hpi_message hm
;
2967 struct hpi_response hr
;
2968 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
2969 HPI_CONTROL_GET_STATE
);
2970 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
2971 hm
.u
.c
.attribute
= HPI_TUNER_RDS
;
2972 hpi_send_recv(&hm
, &hr
);
2974 *(u32
*)&p_data
[0] = hr
.u
.cu
.tuner
.rds
.data
[0];
2975 *(u32
*)&p_data
[4] = hr
.u
.cu
.tuner
.rds
.data
[1];
2976 *(u32
*)&p_data
[8] = hr
.u
.cu
.tuner
.rds
.bLER
;
2981 u16
HPI_PAD__get_channel_name(const struct hpi_hsubsys
*ph_subsys
,
2982 u32 h_control
, char *psz_string
, const u32 data_length
)
2984 return hpi_control_get_string(ph_subsys
, h_control
,
2985 HPI_PAD_CHANNEL_NAME
, psz_string
, data_length
);
2988 u16
HPI_PAD__get_artist(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2989 char *psz_string
, const u32 data_length
)
2991 return hpi_control_get_string(ph_subsys
, h_control
, HPI_PAD_ARTIST
,
2992 psz_string
, data_length
);
2995 u16
HPI_PAD__get_title(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
2996 char *psz_string
, const u32 data_length
)
2998 return hpi_control_get_string(ph_subsys
, h_control
, HPI_PAD_TITLE
,
2999 psz_string
, data_length
);
3002 u16
HPI_PAD__get_comment(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
3003 char *psz_string
, const u32 data_length
)
3005 return hpi_control_get_string(ph_subsys
, h_control
, HPI_PAD_COMMENT
,
3006 psz_string
, data_length
);
3009 u16
HPI_PAD__get_program_type(const struct hpi_hsubsys
*ph_subsys
,
3010 u32 h_control
, u32
*ppTY
)
3012 return hpi_control_param_get(ph_subsys
, h_control
,
3013 HPI_PAD_PROGRAM_TYPE
, 0, 0, ppTY
, NULL
);
3016 u16
HPI_PAD__get_rdsPI(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
3019 return hpi_control_param_get(ph_subsys
, h_control
, HPI_PAD_PROGRAM_ID
,
3023 u16
hpi_volume_query_channels(const struct hpi_hsubsys
*ph_subsys
,
3024 const u32 h_volume
, u32
*p_channels
)
3026 return hpi_control_query(ph_subsys
, h_volume
, HPI_VOLUME_NUM_CHANNELS
,
3030 u16
hpi_volume_set_gain(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
3031 short an_log_gain
[HPI_MAX_CHANNELS
]
3034 struct hpi_message hm
;
3035 struct hpi_response hr
;
3036 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
3037 HPI_CONTROL_SET_STATE
);
3038 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
3039 memcpy(hm
.u
.c
.an_log_value
, an_log_gain
,
3040 sizeof(short) * HPI_MAX_CHANNELS
);
3041 hm
.u
.c
.attribute
= HPI_VOLUME_GAIN
;
3043 hpi_send_recv(&hm
, &hr
);
3048 u16
hpi_volume_get_gain(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
3049 short an_log_gain
[HPI_MAX_CHANNELS
]
3052 struct hpi_message hm
;
3053 struct hpi_response hr
;
3054 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
3055 HPI_CONTROL_GET_STATE
);
3056 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
3057 hm
.u
.c
.attribute
= HPI_VOLUME_GAIN
;
3059 hpi_send_recv(&hm
, &hr
);
3061 memcpy(an_log_gain
, hr
.u
.c
.an_log_value
,
3062 sizeof(short) * HPI_MAX_CHANNELS
);
3066 u16
hpi_volume_query_range(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
3067 short *min_gain_01dB
, short *max_gain_01dB
, short *step_gain_01dB
)
3069 struct hpi_message hm
;
3070 struct hpi_response hr
;
3071 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
3072 HPI_CONTROL_GET_STATE
);
3073 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
3074 hm
.u
.c
.attribute
= HPI_VOLUME_RANGE
;
3076 hpi_send_recv(&hm
, &hr
);
3078 hr
.u
.c
.an_log_value
[0] = 0;
3079 hr
.u
.c
.an_log_value
[1] = 0;
3083 *min_gain_01dB
= hr
.u
.c
.an_log_value
[0];
3085 *max_gain_01dB
= hr
.u
.c
.an_log_value
[1];
3087 *step_gain_01dB
= (short)hr
.u
.c
.param1
;
3091 u16
hpi_volume_auto_fade_profile(const struct hpi_hsubsys
*ph_subsys
,
3092 u32 h_control
, short an_stop_gain0_01dB
[HPI_MAX_CHANNELS
],
3093 u32 duration_ms
, u16 profile
)
3095 struct hpi_message hm
;
3096 struct hpi_response hr
;
3097 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
3098 HPI_CONTROL_SET_STATE
);
3099 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
3101 memcpy(hm
.u
.c
.an_log_value
, an_stop_gain0_01dB
,
3102 sizeof(short) * HPI_MAX_CHANNELS
);
3104 hm
.u
.c
.attribute
= HPI_VOLUME_AUTOFADE
;
3105 hm
.u
.c
.param1
= duration_ms
;
3106 hm
.u
.c
.param2
= profile
;
3108 hpi_send_recv(&hm
, &hr
);
3113 u16
hpi_volume_auto_fade(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
3114 short an_stop_gain0_01dB
[HPI_MAX_CHANNELS
], u32 duration_ms
)
3116 return hpi_volume_auto_fade_profile(ph_subsys
, h_control
,
3117 an_stop_gain0_01dB
, duration_ms
, HPI_VOLUME_AUTOFADE_LOG
);
3120 u16
hpi_vox_set_threshold(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
3121 short an_gain0_01dB
)
3123 struct hpi_message hm
;
3124 struct hpi_response hr
;
3125 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
3126 HPI_CONTROL_SET_STATE
);
3127 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
3128 hm
.u
.c
.attribute
= HPI_VOX_THRESHOLD
;
3130 hm
.u
.c
.an_log_value
[0] = an_gain0_01dB
;
3132 hpi_send_recv(&hm
, &hr
);
3137 u16
hpi_vox_get_threshold(const struct hpi_hsubsys
*ph_subsys
, u32 h_control
,
3138 short *an_gain0_01dB
)
3140 struct hpi_message hm
;
3141 struct hpi_response hr
;
3142 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_CONTROL
,
3143 HPI_CONTROL_GET_STATE
);
3144 u32TOINDEXES(h_control
, &hm
.adapter_index
, &hm
.obj_index
);
3145 hm
.u
.c
.attribute
= HPI_VOX_THRESHOLD
;
3147 hpi_send_recv(&hm
, &hr
);
3149 *an_gain0_01dB
= hr
.u
.c
.an_log_value
[0];
3154 static size_t strv_packet_size
= MIN_STRV_PACKET_SIZE
;
3156 static size_t entity_type_to_size
[LAST_ENTITY_TYPE
] = {
3158 sizeof(struct hpi_entity
),
3173 inline size_t hpi_entity_size(struct hpi_entity
*entity_ptr
)
3175 return entity_ptr
->header
.size
;
3178 inline size_t hpi_entity_header_size(struct hpi_entity
*entity_ptr
)
3180 return sizeof(entity_ptr
->header
);
3183 inline size_t hpi_entity_value_size(struct hpi_entity
*entity_ptr
)
3185 return hpi_entity_size(entity_ptr
) -
3186 hpi_entity_header_size(entity_ptr
);
3189 inline size_t hpi_entity_item_count(struct hpi_entity
*entity_ptr
)
3191 return hpi_entity_value_size(entity_ptr
) /
3192 entity_type_to_size
[entity_ptr
->header
.type
];
3195 inline struct hpi_entity
*hpi_entity_ptr_to_next(struct hpi_entity
3198 return (void *)(((uint8_t *) entity_ptr
) +
3199 hpi_entity_size(entity_ptr
));
3202 inline u16
hpi_entity_check_type(const enum e_entity_type t
)
3204 if (t
>= 0 && t
< STR_TYPE_FIELD_MAX
)
3206 return HPI_ERROR_ENTITY_TYPE_INVALID
;
3209 inline u16
hpi_entity_check_role(const enum e_entity_role r
)
3211 if (r
>= 0 && r
< STR_ROLE_FIELD_MAX
)
3213 return HPI_ERROR_ENTITY_ROLE_INVALID
;
3216 static u16
hpi_entity_get_next(struct hpi_entity
*entity
, int recursive_flag
,
3217 void *guard_p
, struct hpi_entity
**next
)
3219 HPI_DEBUG_ASSERT(entity
!= NULL
);
3220 HPI_DEBUG_ASSERT(next
!= NULL
);
3221 HPI_DEBUG_ASSERT(hpi_entity_size(entity
) != 0);
3223 if (guard_p
<= (void *)entity
) {
3228 if (recursive_flag
&& entity
->header
.type
== entity_type_sequence
)
3229 *next
= (struct hpi_entity
*)entity
->value
;
3231 *next
= (struct hpi_entity
*)hpi_entity_ptr_to_next(entity
);
3233 if (guard_p
<= (void *)*next
) {
3238 HPI_DEBUG_ASSERT(guard_p
>= (void *)hpi_entity_ptr_to_next(*next
));
3242 u16
hpi_entity_find_next(struct hpi_entity
*container_entity
,
3243 enum e_entity_type type
, enum e_entity_role role
, int recursive_flag
,
3244 struct hpi_entity
**current_match
)
3246 struct hpi_entity
*tmp
= NULL
;
3247 void *guard_p
= NULL
;
3249 HPI_DEBUG_ASSERT(container_entity
!= NULL
);
3250 guard_p
= hpi_entity_ptr_to_next(container_entity
);
3252 if (*current_match
!= NULL
)
3253 hpi_entity_get_next(*current_match
, recursive_flag
, guard_p
,
3256 hpi_entity_get_next(container_entity
, 1, guard_p
, &tmp
);
3261 HPI_DEBUG_ASSERT((void *)tmp
>= (void *)container_entity
);
3263 if ((!type
|| tmp
->header
.type
== type
) && (!role
3264 || tmp
->header
.role
== role
)) {
3265 *current_match
= tmp
;
3269 err
= hpi_entity_get_next(tmp
, recursive_flag
, guard_p
,
3274 tmp
= *current_match
;
3277 *current_match
= NULL
;
3281 void hpi_entity_free(struct hpi_entity
*entity
)
3286 static u16
hpi_entity_alloc_and_copy(struct hpi_entity
*src
,
3287 struct hpi_entity
**dst
)
3290 HPI_DEBUG_ASSERT(dst
!= NULL
);
3291 HPI_DEBUG_ASSERT(src
!= NULL
);
3293 buf_size
= hpi_entity_size(src
);
3294 *dst
= kmalloc(buf_size
, GFP_KERNEL
);
3296 return HPI_ERROR_MEMORY_ALLOC
;
3297 memcpy(*dst
, src
, buf_size
);
3301 u16
hpi_universal_info(const struct hpi_hsubsys
*ph_subsys
, u32 hC
,
3302 struct hpi_entity
**info
)
3304 struct hpi_msg_strv hm
;
3305 struct hpi_res_strv
*phr
;
3307 int remaining_attempts
= 2;
3308 size_t resp_packet_size
= 1024;
3312 while (remaining_attempts
--) {
3313 phr
= kmalloc(resp_packet_size
, GFP_KERNEL
);
3314 HPI_DEBUG_ASSERT(phr
!= NULL
);
3316 hpi_init_message_responseV1(&hm
.h
, (u16
)sizeof(hm
), &phr
->h
,
3317 (u16
)resp_packet_size
, HPI_OBJ_CONTROL
,
3318 HPI_CONTROL_GET_INFO
);
3319 u32TOINDEXES(hC
, &hm
.h
.adapter_index
, &hm
.h
.obj_index
);
3321 hm
.strv
.header
.size
= sizeof(hm
.strv
);
3322 phr
->strv
.header
.size
= resp_packet_size
- sizeof(phr
->h
);
3324 hpi_send_recv((struct hpi_message
*)&hm
.h
,
3325 (struct hpi_response
*)&phr
->h
);
3326 if (phr
->h
.error
== HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL
) {
3328 HPI_DEBUG_ASSERT(phr
->h
.specific_error
>
3329 MIN_STRV_PACKET_SIZE
3330 && phr
->h
.specific_error
< 1500);
3331 resp_packet_size
= phr
->h
.specific_error
;
3333 remaining_attempts
= 0;
3335 hpi_entity_alloc_and_copy(&phr
->strv
, info
);
3338 hpi_err
= phr
->h
.error
;
3345 u16
hpi_universal_get(const struct hpi_hsubsys
*ph_subsys
, u32 hC
,
3346 struct hpi_entity
**value
)
3348 struct hpi_msg_strv hm
;
3349 struct hpi_res_strv
*phr
;
3351 int remaining_attempts
= 2;
3355 while (remaining_attempts
--) {
3356 phr
= kmalloc(strv_packet_size
, GFP_KERNEL
);
3358 return HPI_ERROR_MEMORY_ALLOC
;
3360 hpi_init_message_responseV1(&hm
.h
, (u16
)sizeof(hm
), &phr
->h
,
3361 (u16
)strv_packet_size
, HPI_OBJ_CONTROL
,
3362 HPI_CONTROL_GET_STATE
);
3363 u32TOINDEXES(hC
, &hm
.h
.adapter_index
, &hm
.h
.obj_index
);
3365 hm
.strv
.header
.size
= sizeof(hm
.strv
);
3366 phr
->strv
.header
.size
= strv_packet_size
- sizeof(phr
->h
);
3368 hpi_send_recv((struct hpi_message
*)&hm
.h
,
3369 (struct hpi_response
*)&phr
->h
);
3370 if (phr
->h
.error
== HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL
) {
3372 HPI_DEBUG_ASSERT(phr
->h
.specific_error
>
3373 MIN_STRV_PACKET_SIZE
3374 && phr
->h
.specific_error
< 1000);
3375 strv_packet_size
= phr
->h
.specific_error
;
3377 remaining_attempts
= 0;
3379 hpi_entity_alloc_and_copy(&phr
->strv
, value
);
3382 hpi_err
= phr
->h
.error
;
3389 u16
hpi_universal_set(const struct hpi_hsubsys
*ph_subsys
, u32 hC
,
3390 struct hpi_entity
*value
)
3392 struct hpi_msg_strv
*phm
;
3393 struct hpi_res_strv hr
;
3395 phm
= kmalloc(sizeof(phm
->h
) + value
->header
.size
, GFP_KERNEL
);
3396 HPI_DEBUG_ASSERT(phm
!= NULL
);
3398 hpi_init_message_responseV1(&phm
->h
,
3399 sizeof(phm
->h
) + value
->header
.size
, &hr
.h
, sizeof(hr
),
3400 HPI_OBJ_CONTROL
, HPI_CONTROL_SET_STATE
);
3401 u32TOINDEXES(hC
, &phm
->h
.adapter_index
, &phm
->h
.obj_index
);
3402 hr
.strv
.header
.size
= sizeof(hr
.strv
);
3404 memcpy(&phm
->strv
, value
, value
->header
.size
);
3405 hpi_send_recv((struct hpi_message
*)&phm
->h
,
3406 (struct hpi_response
*)&hr
.h
);
3411 u16
hpi_entity_alloc_and_pack(const enum e_entity_type type
,
3412 const size_t item_count
, const enum e_entity_role role
, void *value
,
3413 struct hpi_entity
**entity
)
3415 size_t bytes_to_copy
, total_size
;
3419 hE
= hpi_entity_check_type(type
);
3423 HPI_DEBUG_ASSERT(role
> entity_role_null
&& type
< LAST_ENTITY_TYPE
);
3425 bytes_to_copy
= entity_type_to_size
[type
] * item_count
;
3426 total_size
= hpi_entity_header_size(*entity
) + bytes_to_copy
;
3428 HPI_DEBUG_ASSERT(total_size
>= hpi_entity_header_size(*entity
)
3429 && total_size
< STR_SIZE_FIELD_MAX
);
3431 *entity
= kmalloc(total_size
, GFP_KERNEL
);
3432 if (*entity
== NULL
)
3433 return HPI_ERROR_MEMORY_ALLOC
;
3434 memcpy((*entity
)->value
, value
, bytes_to_copy
);
3435 (*entity
)->header
.size
=
3436 hpi_entity_header_size(*entity
) + bytes_to_copy
;
3437 (*entity
)->header
.type
= type
;
3438 (*entity
)->header
.role
= role
;
3442 u16
hpi_entity_copy_value_from(struct hpi_entity
*entity
,
3443 enum e_entity_type type
, size_t item_count
, void *value_dst_p
)
3445 size_t bytes_to_copy
;
3447 if (entity
->header
.type
!= type
)
3448 return HPI_ERROR_ENTITY_TYPE_MISMATCH
;
3450 if (hpi_entity_item_count(entity
) != item_count
)
3451 return HPI_ERROR_ENTITY_ITEM_COUNT
;
3453 bytes_to_copy
= entity_type_to_size
[type
] * item_count
;
3454 memcpy(value_dst_p
, entity
->value
, bytes_to_copy
);
3458 u16
hpi_entity_unpack(struct hpi_entity
*entity
, enum e_entity_type
*type
,
3459 size_t *item_count
, enum e_entity_role
*role
, void **value
)
3462 HPI_DEBUG_ASSERT(entity
!= NULL
);
3465 *type
= entity
->header
.type
;
3468 *role
= entity
->header
.role
;
3471 *value
= entity
->value
;
3473 if (item_count
!= NULL
) {
3474 if (entity
->header
.type
== entity_type_sequence
) {
3475 void *guard_p
= hpi_entity_ptr_to_next(entity
);
3476 struct hpi_entity
*next
= NULL
;
3477 void *contents
= entity
->value
;
3480 while (contents
< guard_p
) {
3482 err
= hpi_entity_get_next(contents
, 0,
3484 if (next
== NULL
|| err
)
3489 *item_count
= hpi_entity_item_count(entity
);
3495 u16
hpi_gpio_open(const struct hpi_hsubsys
*ph_subsys
, u16 adapter_index
,
3496 u32
*ph_gpio
, u16
*pw_number_input_bits
, u16
*pw_number_output_bits
)
3498 struct hpi_message hm
;
3499 struct hpi_response hr
;
3500 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_GPIO
, HPI_GPIO_OPEN
);
3501 hm
.adapter_index
= adapter_index
;
3503 hpi_send_recv(&hm
, &hr
);
3505 if (hr
.error
== 0) {
3507 hpi_indexes_to_handle(HPI_OBJ_GPIO
, adapter_index
, 0);
3508 if (pw_number_input_bits
)
3509 *pw_number_input_bits
= hr
.u
.l
.number_input_bits
;
3510 if (pw_number_output_bits
)
3511 *pw_number_output_bits
= hr
.u
.l
.number_output_bits
;
3517 u16
hpi_gpio_read_bit(const struct hpi_hsubsys
*ph_subsys
, u32 h_gpio
,
3518 u16 bit_index
, u16
*pw_bit_data
)
3520 struct hpi_message hm
;
3521 struct hpi_response hr
;
3522 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_GPIO
, HPI_GPIO_READ_BIT
);
3523 u32TOINDEX(h_gpio
, &hm
.adapter_index
);
3524 hm
.u
.l
.bit_index
= bit_index
;
3526 hpi_send_recv(&hm
, &hr
);
3528 *pw_bit_data
= hr
.u
.l
.bit_data
[0];
3532 u16
hpi_gpio_read_all_bits(const struct hpi_hsubsys
*ph_subsys
, u32 h_gpio
,
3533 u16 aw_all_bit_data
[4]
3536 struct hpi_message hm
;
3537 struct hpi_response hr
;
3538 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_GPIO
, HPI_GPIO_READ_ALL
);
3539 u32TOINDEX(h_gpio
, &hm
.adapter_index
);
3541 hpi_send_recv(&hm
, &hr
);
3543 if (aw_all_bit_data
) {
3544 aw_all_bit_data
[0] = hr
.u
.l
.bit_data
[0];
3545 aw_all_bit_data
[1] = hr
.u
.l
.bit_data
[1];
3546 aw_all_bit_data
[2] = hr
.u
.l
.bit_data
[2];
3547 aw_all_bit_data
[3] = hr
.u
.l
.bit_data
[3];
3552 u16
hpi_gpio_write_bit(const struct hpi_hsubsys
*ph_subsys
, u32 h_gpio
,
3553 u16 bit_index
, u16 bit_data
)
3555 struct hpi_message hm
;
3556 struct hpi_response hr
;
3557 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_GPIO
, HPI_GPIO_WRITE_BIT
);
3558 u32TOINDEX(h_gpio
, &hm
.adapter_index
);
3559 hm
.u
.l
.bit_index
= bit_index
;
3560 hm
.u
.l
.bit_data
= bit_data
;
3562 hpi_send_recv(&hm
, &hr
);
3567 u16
hpi_gpio_write_status(const struct hpi_hsubsys
*ph_subsys
, u32 h_gpio
,
3568 u16 aw_all_bit_data
[4]
3571 struct hpi_message hm
;
3572 struct hpi_response hr
;
3573 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_GPIO
,
3574 HPI_GPIO_WRITE_STATUS
);
3575 u32TOINDEX(h_gpio
, &hm
.adapter_index
);
3577 hpi_send_recv(&hm
, &hr
);
3579 if (aw_all_bit_data
) {
3580 aw_all_bit_data
[0] = hr
.u
.l
.bit_data
[0];
3581 aw_all_bit_data
[1] = hr
.u
.l
.bit_data
[1];
3582 aw_all_bit_data
[2] = hr
.u
.l
.bit_data
[2];
3583 aw_all_bit_data
[3] = hr
.u
.l
.bit_data
[3];
3588 u16
hpi_async_event_open(const struct hpi_hsubsys
*ph_subsys
,
3589 u16 adapter_index
, u32
*ph_async
)
3591 struct hpi_message hm
;
3592 struct hpi_response hr
;
3593 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ASYNCEVENT
,
3594 HPI_ASYNCEVENT_OPEN
);
3595 hm
.adapter_index
= adapter_index
;
3597 hpi_send_recv(&hm
, &hr
);
3602 hpi_indexes_to_handle(HPI_OBJ_ASYNCEVENT
,
3610 u16
hpi_async_event_close(const struct hpi_hsubsys
*ph_subsys
, u32 h_async
)
3612 struct hpi_message hm
;
3613 struct hpi_response hr
;
3614 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ASYNCEVENT
,
3615 HPI_ASYNCEVENT_OPEN
);
3616 u32TOINDEX(h_async
, &hm
.adapter_index
);
3618 hpi_send_recv(&hm
, &hr
);
3623 u16
hpi_async_event_wait(const struct hpi_hsubsys
*ph_subsys
, u32 h_async
,
3624 u16 maximum_events
, struct hpi_async_event
*p_events
,
3625 u16
*pw_number_returned
)
3630 u16
hpi_async_event_get_count(const struct hpi_hsubsys
*ph_subsys
,
3631 u32 h_async
, u16
*pw_count
)
3633 struct hpi_message hm
;
3634 struct hpi_response hr
;
3635 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ASYNCEVENT
,
3636 HPI_ASYNCEVENT_GETCOUNT
);
3637 u32TOINDEX(h_async
, &hm
.adapter_index
);
3639 hpi_send_recv(&hm
, &hr
);
3643 *pw_count
= hr
.u
.as
.u
.count
.count
;
3648 u16
hpi_async_event_get(const struct hpi_hsubsys
*ph_subsys
, u32 h_async
,
3649 u16 maximum_events
, struct hpi_async_event
*p_events
,
3650 u16
*pw_number_returned
)
3652 struct hpi_message hm
;
3653 struct hpi_response hr
;
3654 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_ASYNCEVENT
,
3655 HPI_ASYNCEVENT_GET
);
3656 u32TOINDEX(h_async
, &hm
.adapter_index
);
3658 hpi_send_recv(&hm
, &hr
);
3660 memcpy(p_events
, &hr
.u
.as
.u
.event
,
3661 sizeof(struct hpi_async_event
));
3662 *pw_number_returned
= 1;
3668 u16
hpi_nv_memory_open(const struct hpi_hsubsys
*ph_subsys
, u16 adapter_index
,
3669 u32
*ph_nv_memory
, u16
*pw_size_in_bytes
)
3671 struct hpi_message hm
;
3672 struct hpi_response hr
;
3673 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_NVMEMORY
,
3675 hm
.adapter_index
= adapter_index
;
3677 hpi_send_recv(&hm
, &hr
);
3679 if (hr
.error
== 0) {
3681 hpi_indexes_to_handle(HPI_OBJ_NVMEMORY
, adapter_index
,
3683 if (pw_size_in_bytes
)
3684 *pw_size_in_bytes
= hr
.u
.n
.size_in_bytes
;
3690 u16
hpi_nv_memory_read_byte(const struct hpi_hsubsys
*ph_subsys
,
3691 u32 h_nv_memory
, u16 index
, u16
*pw_data
)
3693 struct hpi_message hm
;
3694 struct hpi_response hr
;
3695 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_NVMEMORY
,
3696 HPI_NVMEMORY_READ_BYTE
);
3697 u32TOINDEX(h_nv_memory
, &hm
.adapter_index
);
3698 hm
.u
.n
.address
= index
;
3700 hpi_send_recv(&hm
, &hr
);
3702 *pw_data
= hr
.u
.n
.data
;
3706 u16
hpi_nv_memory_write_byte(const struct hpi_hsubsys
*ph_subsys
,
3707 u32 h_nv_memory
, u16 index
, u16 data
)
3709 struct hpi_message hm
;
3710 struct hpi_response hr
;
3711 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_NVMEMORY
,
3712 HPI_NVMEMORY_WRITE_BYTE
);
3713 u32TOINDEX(h_nv_memory
, &hm
.adapter_index
);
3714 hm
.u
.n
.address
= index
;
3717 hpi_send_recv(&hm
, &hr
);
3722 u16
hpi_profile_open_all(const struct hpi_hsubsys
*ph_subsys
,
3723 u16 adapter_index
, u16 profile_index
, u32
*ph_profile
,
3724 u16
*pw_max_profiles
)
3726 struct hpi_message hm
;
3727 struct hpi_response hr
;
3728 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_PROFILE
,
3729 HPI_PROFILE_OPEN_ALL
);
3730 hm
.adapter_index
= adapter_index
;
3731 hm
.obj_index
= profile_index
;
3732 hpi_send_recv(&hm
, &hr
);
3734 *pw_max_profiles
= hr
.u
.p
.u
.o
.max_profiles
;
3737 hpi_indexes_to_handle(HPI_OBJ_PROFILE
, adapter_index
,
3744 u16
hpi_profile_get(const struct hpi_hsubsys
*ph_subsys
, u32 h_profile
,
3745 u16 bin_index
, u16
*pw_seconds
, u32
*pmicro_seconds
, u32
*pcall_count
,
3746 u32
*pmax_micro_seconds
, u32
*pmin_micro_seconds
)
3748 struct hpi_message hm
;
3749 struct hpi_response hr
;
3750 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_PROFILE
, HPI_PROFILE_GET
);
3751 u32TOINDEXES(h_profile
, &hm
.adapter_index
, &hm
.obj_index
);
3752 hm
.u
.p
.bin_index
= bin_index
;
3753 hpi_send_recv(&hm
, &hr
);
3755 *pw_seconds
= hr
.u
.p
.u
.t
.seconds
;
3757 *pmicro_seconds
= hr
.u
.p
.u
.t
.micro_seconds
;
3759 *pcall_count
= hr
.u
.p
.u
.t
.call_count
;
3760 if (pmax_micro_seconds
)
3761 *pmax_micro_seconds
= hr
.u
.p
.u
.t
.max_micro_seconds
;
3762 if (pmin_micro_seconds
)
3763 *pmin_micro_seconds
= hr
.u
.p
.u
.t
.min_micro_seconds
;
3767 u16
hpi_profile_get_utilization(const struct hpi_hsubsys
*ph_subsys
,
3768 u32 h_profile
, u32
*putilization
)
3770 struct hpi_message hm
;
3771 struct hpi_response hr
;
3772 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_PROFILE
,
3773 HPI_PROFILE_GET_UTILIZATION
);
3774 u32TOINDEXES(h_profile
, &hm
.adapter_index
, &hm
.obj_index
);
3775 hpi_send_recv(&hm
, &hr
);
3781 *putilization
= hr
.u
.p
.u
.t
.call_count
;
3786 u16
hpi_profile_get_name(const struct hpi_hsubsys
*ph_subsys
, u32 h_profile
,
3787 u16 bin_index
, char *sz_name
, u16 name_length
)
3789 struct hpi_message hm
;
3790 struct hpi_response hr
;
3791 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_PROFILE
,
3792 HPI_PROFILE_GET_NAME
);
3793 u32TOINDEXES(h_profile
, &hm
.adapter_index
, &hm
.obj_index
);
3794 hm
.u
.p
.bin_index
= bin_index
;
3795 hpi_send_recv(&hm
, &hr
);
3798 strcpy(sz_name
, "??");
3801 memcpy(sz_name
, (char *)hr
.u
.p
.u
.n
.sz_name
,
3807 u16
hpi_profile_start_all(const struct hpi_hsubsys
*ph_subsys
, u32 h_profile
)
3809 struct hpi_message hm
;
3810 struct hpi_response hr
;
3811 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_PROFILE
,
3812 HPI_PROFILE_START_ALL
);
3813 u32TOINDEXES(h_profile
, &hm
.adapter_index
, &hm
.obj_index
);
3814 hpi_send_recv(&hm
, &hr
);
3819 u16
hpi_profile_stop_all(const struct hpi_hsubsys
*ph_subsys
, u32 h_profile
)
3821 struct hpi_message hm
;
3822 struct hpi_response hr
;
3823 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_PROFILE
,
3824 HPI_PROFILE_STOP_ALL
);
3825 u32TOINDEXES(h_profile
, &hm
.adapter_index
, &hm
.obj_index
);
3826 hpi_send_recv(&hm
, &hr
);
3831 u16
hpi_watchdog_open(const struct hpi_hsubsys
*ph_subsys
, u16 adapter_index
,
3834 struct hpi_message hm
;
3835 struct hpi_response hr
;
3836 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_WATCHDOG
,
3838 hm
.adapter_index
= adapter_index
;
3840 hpi_send_recv(&hm
, &hr
);
3844 hpi_indexes_to_handle(HPI_OBJ_WATCHDOG
, adapter_index
,
3851 u16
hpi_watchdog_set_time(const struct hpi_hsubsys
*ph_subsys
, u32 h_watchdog
,
3854 struct hpi_message hm
;
3855 struct hpi_response hr
;
3856 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_WATCHDOG
,
3857 HPI_WATCHDOG_SET_TIME
);
3858 u32TOINDEX(h_watchdog
, &hm
.adapter_index
);
3859 hm
.u
.w
.time_ms
= time_millisec
;
3861 hpi_send_recv(&hm
, &hr
);
3866 u16
hpi_watchdog_ping(const struct hpi_hsubsys
*ph_subsys
, u32 h_watchdog
)
3868 struct hpi_message hm
;
3869 struct hpi_response hr
;
3870 hpi_init_message_response(&hm
, &hr
, HPI_OBJ_WATCHDOG
,
3872 u32TOINDEX(h_watchdog
, &hm
.adapter_index
);
3874 hpi_send_recv(&hm
, &hr
);