aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/asihpi/hpifunc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/asihpi/hpifunc.c')
-rw-r--r--sound/pci/asihpi/hpifunc.c2517
1 files changed, 721 insertions, 1796 deletions
diff --git a/sound/pci/asihpi/hpifunc.c b/sound/pci/asihpi/hpifunc.c
index 1e92eb6dd509..7397b169b89f 100644
--- a/sound/pci/asihpi/hpifunc.c
+++ b/sound/pci/asihpi/hpifunc.c
@@ -30,16 +30,25 @@ u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index,
30 return handle.w; 30 return handle.w;
31} 31}
32 32
33void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index, 33static u16 hpi_handle_indexes(const u32 h, u16 *p1, u16 *p2)
34 u16 *pw_object_index)
35{ 34{
36 union handle_word uhandle; 35 union handle_word uhandle;
37 uhandle.w = handle; 36 if (!h)
37 return HPI_ERROR_INVALID_HANDLE;
38
39 uhandle.w = h;
40
41 *p1 = (u16)uhandle.h.adapter_index;
42 if (p2)
43 *p2 = (u16)uhandle.h.obj_index;
38 44
39 if (pw_adapter_index) 45 return 0;
40 *pw_adapter_index = (u16)uhandle.h.adapter_index; 46}
41 if (pw_object_index) 47
42 *pw_object_index = (u16)uhandle.h.obj_index; 48void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index,
49 u16 *pw_object_index)
50{
51 hpi_handle_indexes(handle, pw_adapter_index, pw_object_index);
43} 52}
44 53
45char hpi_handle_object(const u32 handle) 54char hpi_handle_object(const u32 handle)
@@ -49,22 +58,6 @@ char hpi_handle_object(const u32 handle)
49 return (char)uhandle.h.obj_type; 58 return (char)uhandle.h.obj_type;
50} 59}
51 60
52#define u32TOINDEX(h, i1) \
53do {\
54 if (h == 0) \
55 return HPI_ERROR_INVALID_OBJ; \
56 else \
57 hpi_handle_to_indexes(h, i1, NULL); \
58} while (0)
59
60#define u32TOINDEXES(h, i1, i2) \
61do {\
62 if (h == 0) \
63 return HPI_ERROR_INVALID_OBJ; \
64 else \
65 hpi_handle_to_indexes(h, i1, i2);\
66} while (0)
67
68void hpi_format_to_msg(struct hpi_msg_format *pMF, 61void hpi_format_to_msg(struct hpi_msg_format *pMF,
69 const struct hpi_format *pF) 62 const struct hpi_format *pF)
70{ 63{
@@ -94,52 +87,13 @@ void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR)
94 pSR->u.legacy_stream_info.state = pSR->u.stream_info.state; 87 pSR->u.legacy_stream_info.state = pSR->u.stream_info.state;
95} 88}
96 89
97static struct hpi_hsubsys gh_subsys; 90static inline void hpi_send_recvV1(struct hpi_message_header *m,
98 91 struct hpi_response_header *r)
99struct hpi_hsubsys *hpi_subsys_create(void)
100{
101 struct hpi_message hm;
102 struct hpi_response hr;
103
104 memset(&gh_subsys, 0, sizeof(struct hpi_hsubsys));
105
106 {
107 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
108 HPI_SUBSYS_OPEN);
109 hpi_send_recv(&hm, &hr);
110
111 if (hr.error == 0)
112 return &gh_subsys;
113
114 }
115 return NULL;
116}
117
118void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys)
119{ 92{
120 struct hpi_message hm; 93 hpi_send_recv((struct hpi_message *)m, (struct hpi_response *)r);
121 struct hpi_response hr;
122
123 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
124 HPI_SUBSYS_CLOSE);
125 hpi_send_recv(&hm, &hr);
126
127}
128
129u16 hpi_subsys_get_version(const struct hpi_hsubsys *ph_subsys, u32 *pversion)
130{
131 struct hpi_message hm;
132 struct hpi_response hr;
133
134 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
135 HPI_SUBSYS_GET_VERSION);
136 hpi_send_recv(&hm, &hr);
137 *pversion = hr.u.s.version;
138 return hr.error;
139} 94}
140 95
141u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys, 96u16 hpi_subsys_get_version_ex(u32 *pversion_ex)
142 u32 *pversion_ex)
143{ 97{
144 struct hpi_message hm; 98 struct hpi_message hm;
145 struct hpi_response hr; 99 struct hpi_response hr;
@@ -151,79 +105,7 @@ u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys,
151 return hr.error; 105 return hr.error;
152} 106}
153 107
154u16 hpi_subsys_get_info(const struct hpi_hsubsys *ph_subsys, u32 *pversion, 108u16 hpi_subsys_get_num_adapters(int *pn_num_adapters)
155 u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length)
156{
157 struct hpi_message hm;
158 struct hpi_response hr;
159 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
160 HPI_SUBSYS_GET_INFO);
161
162 hpi_send_recv(&hm, &hr);
163
164 *pversion = hr.u.s.version;
165 if (list_length > HPI_MAX_ADAPTERS)
166 memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list,
167 HPI_MAX_ADAPTERS);
168 else
169 memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list, list_length);
170 *pw_num_adapters = hr.u.s.num_adapters;
171 return hr.error;
172}
173
174u16 hpi_subsys_find_adapters(const struct hpi_hsubsys *ph_subsys,
175 u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length)
176{
177 struct hpi_message hm;
178 struct hpi_response hr;
179 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
180 HPI_SUBSYS_FIND_ADAPTERS);
181
182 hpi_send_recv(&hm, &hr);
183
184 if (list_length > HPI_MAX_ADAPTERS) {
185 memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list,
186 HPI_MAX_ADAPTERS * sizeof(u16));
187 memset(&aw_adapter_list[HPI_MAX_ADAPTERS], 0,
188 (list_length - HPI_MAX_ADAPTERS) * sizeof(u16));
189 } else
190 memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list,
191 list_length * sizeof(u16));
192 *pw_num_adapters = hr.u.s.num_adapters;
193
194 return hr.error;
195}
196
197u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys,
198 const struct hpi_resource *p_resource, u16 *pw_adapter_index)
199{
200 struct hpi_message hm;
201 struct hpi_response hr;
202
203 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
204 HPI_SUBSYS_CREATE_ADAPTER);
205 hm.u.s.resource = *p_resource;
206
207 hpi_send_recv(&hm, &hr);
208
209 *pw_adapter_index = hr.u.s.adapter_index;
210 return hr.error;
211}
212
213u16 hpi_subsys_delete_adapter(const struct hpi_hsubsys *ph_subsys,
214 u16 adapter_index)
215{
216 struct hpi_message hm;
217 struct hpi_response hr;
218 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
219 HPI_SUBSYS_DELETE_ADAPTER);
220 hm.adapter_index = adapter_index;
221 hpi_send_recv(&hm, &hr);
222 return hr.error;
223}
224
225u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys,
226 int *pn_num_adapters)
227{ 109{
228 struct hpi_message hm; 110 struct hpi_message hm;
229 struct hpi_response hr; 111 struct hpi_response hr;
@@ -234,35 +116,22 @@ u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys,
234 return hr.error; 116 return hr.error;
235} 117}
236 118
237u16 hpi_subsys_get_adapter(const struct hpi_hsubsys *ph_subsys, int iterator, 119u16 hpi_subsys_get_adapter(int iterator, u32 *padapter_index,
238 u32 *padapter_index, u16 *pw_adapter_type) 120 u16 *pw_adapter_type)
239{ 121{
240 struct hpi_message hm; 122 struct hpi_message hm;
241 struct hpi_response hr; 123 struct hpi_response hr;
242 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 124 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
243 HPI_SUBSYS_GET_ADAPTER); 125 HPI_SUBSYS_GET_ADAPTER);
244 hm.adapter_index = (u16)iterator; 126 hm.obj_index = (u16)iterator;
245 hpi_send_recv(&hm, &hr); 127 hpi_send_recv(&hm, &hr);
246 *padapter_index = (int)hr.u.s.adapter_index; 128 *padapter_index = (int)hr.u.s.adapter_index;
247 *pw_adapter_type = hr.u.s.aw_adapter_list[0]; 129 *pw_adapter_type = hr.u.s.adapter_type;
248 return hr.error;
249}
250 130
251u16 hpi_subsys_set_host_network_interface(const struct hpi_hsubsys *ph_subsys,
252 const char *sz_interface)
253{
254 struct hpi_message hm;
255 struct hpi_response hr;
256 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
257 HPI_SUBSYS_SET_NETWORK_INTERFACE);
258 if (sz_interface == NULL)
259 return HPI_ERROR_INVALID_RESOURCE;
260 hm.u.s.resource.r.net_if = sz_interface;
261 hpi_send_recv(&hm, &hr);
262 return hr.error; 131 return hr.error;
263} 132}
264 133
265u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) 134u16 hpi_adapter_open(u16 adapter_index)
266{ 135{
267 struct hpi_message hm; 136 struct hpi_message hm;
268 struct hpi_response hr; 137 struct hpi_response hr;
@@ -276,7 +145,7 @@ u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index)
276 145
277} 146}
278 147
279u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) 148u16 hpi_adapter_close(u16 adapter_index)
280{ 149{
281 struct hpi_message hm; 150 struct hpi_message hm;
282 struct hpi_response hr; 151 struct hpi_response hr;
@@ -289,15 +158,14 @@ u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index)
289 return hr.error; 158 return hr.error;
290} 159}
291 160
292u16 hpi_adapter_set_mode(const struct hpi_hsubsys *ph_subsys, 161u16 hpi_adapter_set_mode(u16 adapter_index, u32 adapter_mode)
293 u16 adapter_index, u32 adapter_mode)
294{ 162{
295 return hpi_adapter_set_mode_ex(ph_subsys, adapter_index, adapter_mode, 163 return hpi_adapter_set_mode_ex(adapter_index, adapter_mode,
296 HPI_ADAPTER_MODE_SET); 164 HPI_ADAPTER_MODE_SET);
297} 165}
298 166
299u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys, 167u16 hpi_adapter_set_mode_ex(u16 adapter_index, u32 adapter_mode,
300 u16 adapter_index, u32 adapter_mode, u16 query_or_set) 168 u16 query_or_set)
301{ 169{
302 struct hpi_message hm; 170 struct hpi_message hm;
303 struct hpi_response hr; 171 struct hpi_response hr;
@@ -305,14 +173,13 @@ u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys,
305 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 173 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
306 HPI_ADAPTER_SET_MODE); 174 HPI_ADAPTER_SET_MODE);
307 hm.adapter_index = adapter_index; 175 hm.adapter_index = adapter_index;
308 hm.u.a.adapter_mode = adapter_mode; 176 hm.u.ax.mode.adapter_mode = adapter_mode;
309 hm.u.a.assert_id = query_or_set; 177 hm.u.ax.mode.query_or_set = query_or_set;
310 hpi_send_recv(&hm, &hr); 178 hpi_send_recv(&hm, &hr);
311 return hr.error; 179 return hr.error;
312} 180}
313 181
314u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys, 182u16 hpi_adapter_get_mode(u16 adapter_index, u32 *padapter_mode)
315 u16 adapter_index, u32 *padapter_mode)
316{ 183{
317 struct hpi_message hm; 184 struct hpi_message hm;
318 struct hpi_response hr; 185 struct hpi_response hr;
@@ -321,13 +188,13 @@ u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys,
321 hm.adapter_index = adapter_index; 188 hm.adapter_index = adapter_index;
322 hpi_send_recv(&hm, &hr); 189 hpi_send_recv(&hm, &hr);
323 if (padapter_mode) 190 if (padapter_mode)
324 *padapter_mode = hr.u.a.serial_number; 191 *padapter_mode = hr.u.ax.mode.adapter_mode;
325 return hr.error; 192 return hr.error;
326} 193}
327 194
328u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys, 195u16 hpi_adapter_get_info(u16 adapter_index, u16 *pw_num_outstreams,
329 u16 adapter_index, u16 *pw_num_outstreams, u16 *pw_num_instreams, 196 u16 *pw_num_instreams, u16 *pw_version, u32 *pserial_number,
330 u16 *pw_version, u32 *pserial_number, u16 *pw_adapter_type) 197 u16 *pw_adapter_type)
331{ 198{
332 struct hpi_message hm; 199 struct hpi_message hm;
333 struct hpi_response hr; 200 struct hpi_response hr;
@@ -337,18 +204,17 @@ u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys,
337 204
338 hpi_send_recv(&hm, &hr); 205 hpi_send_recv(&hm, &hr);
339 206
340 *pw_adapter_type = hr.u.a.adapter_type; 207 *pw_adapter_type = hr.u.ax.info.adapter_type;
341 *pw_num_outstreams = hr.u.a.num_outstreams; 208 *pw_num_outstreams = hr.u.ax.info.num_outstreams;
342 *pw_num_instreams = hr.u.a.num_instreams; 209 *pw_num_instreams = hr.u.ax.info.num_instreams;
343 *pw_version = hr.u.a.version; 210 *pw_version = hr.u.ax.info.version;
344 *pserial_number = hr.u.a.serial_number; 211 *pserial_number = hr.u.ax.info.serial_number;
345 return hr.error; 212 return hr.error;
346} 213}
347 214
348u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys, 215u16 hpi_adapter_get_module_by_index(u16 adapter_index, u16 module_index,
349 u16 adapter_index, u16 module_index, u16 *pw_num_outputs, 216 u16 *pw_num_outputs, u16 *pw_num_inputs, u16 *pw_version,
350 u16 *pw_num_inputs, u16 *pw_version, u32 *pserial_number, 217 u32 *pserial_number, u16 *pw_module_type, u32 *ph_module)
351 u16 *pw_module_type, u32 *ph_module)
352{ 218{
353 struct hpi_message hm; 219 struct hpi_message hm;
354 struct hpi_response hr; 220 struct hpi_response hr;
@@ -360,173 +226,18 @@ u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys,
360 226
361 hpi_send_recv(&hm, &hr); 227 hpi_send_recv(&hm, &hr);
362 228
363 *pw_module_type = hr.u.a.adapter_type; 229 *pw_module_type = hr.u.ax.info.adapter_type;
364 *pw_num_outputs = hr.u.a.num_outstreams; 230 *pw_num_outputs = hr.u.ax.info.num_outstreams;
365 *pw_num_inputs = hr.u.a.num_instreams; 231 *pw_num_inputs = hr.u.ax.info.num_instreams;
366 *pw_version = hr.u.a.version; 232 *pw_version = hr.u.ax.info.version;
367 *pserial_number = hr.u.a.serial_number; 233 *pserial_number = hr.u.ax.info.serial_number;
368 *ph_module = 0; 234 *ph_module = 0;
369 235
370 return hr.error; 236 return hr.error;
371} 237}
372 238
373u16 hpi_adapter_get_assert(const struct hpi_hsubsys *ph_subsys, 239u16 hpi_adapter_set_property(u16 adapter_index, u16 property, u16 parameter1,
374 u16 adapter_index, u16 *assert_present, char *psz_assert, 240 u16 parameter2)
375 u16 *pw_line_number)
376{
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);
383
384 *assert_present = 0;
385
386 if (!hr.error) {
387
388 *pw_line_number = (u16)hr.u.a.serial_number;
389 if (*pw_line_number) {
390
391 int i;
392 char *src = (char *)hr.u.a.sz_adapter_assert;
393 char *dst = psz_assert;
394
395 *assert_present = 1;
396
397 for (i = 0; i < HPI_STRING_LEN; i++) {
398 char c;
399 c = *src++;
400 *dst++ = c;
401 if (c == 0)
402 break;
403 }
404
405 }
406 }
407 return hr.error;
408}
409
410u16 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)
413{
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;
419
420 hpi_send_recv(&hm, &hr);
421
422 *assert_present = 0;
423
424 if (!hr.error) {
425
426 *pline_number = hr.u.a.serial_number;
427
428 *assert_present = hr.u.a.adapter_type;
429
430 *pw_assert_on_dsp = hr.u.a.adapter_index;
431
432 if (!*assert_present && *pline_number)
433
434 *assert_present = 1;
435
436 if (*assert_present) {
437
438 int i;
439 char *src = (char *)hr.u.a.sz_adapter_assert;
440 char *dst = psz_assert;
441
442 for (i = 0; i < HPI_STRING_LEN; i++) {
443 char c;
444 c = *src++;
445 *dst++ = c;
446 if (c == 0)
447 break;
448 }
449
450 } else {
451 *psz_assert = 0;
452 }
453 }
454 return hr.error;
455}
456
457u16 hpi_adapter_test_assert(const struct hpi_hsubsys *ph_subsys,
458 u16 adapter_index, u16 assert_id)
459{
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;
466
467 hpi_send_recv(&hm, &hr);
468
469 return hr.error;
470}
471
472u16 hpi_adapter_enable_capability(const struct hpi_hsubsys *ph_subsys,
473 u16 adapter_index, u16 capability, u32 key)
474{
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;
482
483 hpi_send_recv(&hm, &hr);
484
485 return hr.error;
486}
487
488u16 hpi_adapter_self_test(const struct hpi_hsubsys *ph_subsys,
489 u16 adapter_index)
490{
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);
497 return hr.error;
498}
499
500u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys,
501 u16 adapter_index, u32 dsp_address, char *p_buffer, int *count_bytes)
502{
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);
507
508 hr.size = sizeof(hr);
509
510 hm.adapter_index = adapter_index;
511 hm.u.ax.debug_read.dsp_address = dsp_address;
512
513 if (*count_bytes > (int)sizeof(hr.u.bytes))
514 *count_bytes = sizeof(hr.u.bytes);
515
516 hm.u.ax.debug_read.count_bytes = *count_bytes;
517
518 hpi_send_recv(&hm, &hr);
519
520 if (!hr.error) {
521 *count_bytes = hr.size - 12;
522 memcpy(p_buffer, &hr.u.bytes, *count_bytes);
523 } else
524 *count_bytes = 0;
525 return hr.error;
526}
527
528u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys,
529 u16 adapter_index, u16 property, u16 parameter1, u16 parameter2)
530{ 241{
531 struct hpi_message hm; 242 struct hpi_message hm;
532 struct hpi_response hr; 243 struct hpi_response hr;
@@ -542,9 +253,8 @@ u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys,
542 return hr.error; 253 return hr.error;
543} 254}
544 255
545u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys, 256u16 hpi_adapter_get_property(u16 adapter_index, u16 property,
546 u16 adapter_index, u16 property, u16 *pw_parameter1, 257 u16 *pw_parameter1, u16 *pw_parameter2)
547 u16 *pw_parameter2)
548{ 258{
549 struct hpi_message hm; 259 struct hpi_message hm;
550 struct hpi_response hr; 260 struct hpi_response hr;
@@ -564,9 +274,8 @@ u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys,
564 return hr.error; 274 return hr.error;
565} 275}
566 276
567u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys, 277u16 hpi_adapter_enumerate_property(u16 adapter_index, u16 index,
568 u16 adapter_index, u16 index, u16 what_to_enumerate, 278 u16 what_to_enumerate, u16 property_index, u32 *psetting)
569 u16 property_index, u32 *psetting)
570{ 279{
571 return 0; 280 return 0;
572} 281}
@@ -574,7 +283,7 @@ u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys,
574u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, 283u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
575 u32 sample_rate, u32 bit_rate, u32 attributes) 284 u32 sample_rate, u32 bit_rate, u32 attributes)
576{ 285{
577 u16 error = 0; 286 u16 err = 0;
578 struct hpi_msg_format fmt; 287 struct hpi_msg_format fmt;
579 288
580 switch (channels) { 289 switch (channels) {
@@ -586,8 +295,8 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
586 case 16: 295 case 16:
587 break; 296 break;
588 default: 297 default:
589 error = HPI_ERROR_INVALID_CHANNELS; 298 err = HPI_ERROR_INVALID_CHANNELS;
590 return error; 299 return err;
591 } 300 }
592 fmt.channels = channels; 301 fmt.channels = channels;
593 302
@@ -610,17 +319,17 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
610 case HPI_FORMAT_OEM2: 319 case HPI_FORMAT_OEM2:
611 break; 320 break;
612 default: 321 default:
613 error = HPI_ERROR_INVALID_FORMAT; 322 err = HPI_ERROR_INVALID_FORMAT;
614 return error; 323 return err;
615 } 324 }
616 fmt.format = format; 325 fmt.format = format;
617 326
618 if (sample_rate < 8000L) { 327 if (sample_rate < 8000L) {
619 error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; 328 err = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
620 sample_rate = 8000L; 329 sample_rate = 8000L;
621 } 330 }
622 if (sample_rate > 200000L) { 331 if (sample_rate > 200000L) {
623 error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; 332 err = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
624 sample_rate = 200000L; 333 sample_rate = 200000L;
625 } 334 }
626 fmt.sample_rate = sample_rate; 335 fmt.sample_rate = sample_rate;
@@ -651,10 +360,10 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
651 if ((channels == 1) 360 if ((channels == 1)
652 && (attributes != HPI_MPEG_MODE_DEFAULT)) { 361 && (attributes != HPI_MPEG_MODE_DEFAULT)) {
653 attributes = HPI_MPEG_MODE_DEFAULT; 362 attributes = HPI_MPEG_MODE_DEFAULT;
654 error = HPI_ERROR_INVALID_FORMAT; 363 err = HPI_ERROR_INVALID_FORMAT;
655 } else if (attributes > HPI_MPEG_MODE_DUALCHANNEL) { 364 } else if (attributes > HPI_MPEG_MODE_DUALCHANNEL) {
656 attributes = HPI_MPEG_MODE_DEFAULT; 365 attributes = HPI_MPEG_MODE_DEFAULT;
657 error = HPI_ERROR_INVALID_FORMAT; 366 err = HPI_ERROR_INVALID_FORMAT;
658 } 367 }
659 fmt.attributes = attributes; 368 fmt.attributes = attributes;
660 break; 369 break;
@@ -663,7 +372,7 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
663 } 372 }
664 373
665 hpi_msg_to_format(p_format, &fmt); 374 hpi_msg_to_format(p_format, &fmt);
666 return error; 375 return err;
667} 376}
668 377
669u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format, 378u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format,
@@ -712,8 +421,8 @@ u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format,
712 return 0; 421 return 0;
713} 422}
714 423
715u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 424u16 hpi_outstream_open(u16 adapter_index, u16 outstream_index,
716 u16 outstream_index, u32 *ph_outstream) 425 u32 *ph_outstream)
717{ 426{
718 struct hpi_message hm; 427 struct hpi_message hm;
719 struct hpi_response hr; 428 struct hpi_response hr;
@@ -733,38 +442,41 @@ u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
733 return hr.error; 442 return hr.error;
734} 443}
735 444
736u16 hpi_outstream_close(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 445u16 hpi_outstream_close(u32 h_outstream)
737{ 446{
738 struct hpi_message hm; 447 struct hpi_message hm;
739 struct hpi_response hr; 448 struct hpi_response hr;
740 449
741 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 450 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
742 HPI_OSTREAM_HOSTBUFFER_FREE); 451 HPI_OSTREAM_HOSTBUFFER_FREE);
743 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 452 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
453 return HPI_ERROR_INVALID_HANDLE;
454
744 hpi_send_recv(&hm, &hr); 455 hpi_send_recv(&hm, &hr);
745 456
746 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 457 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
747 HPI_OSTREAM_GROUP_RESET); 458 HPI_OSTREAM_GROUP_RESET);
748 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 459 hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index);
749 hpi_send_recv(&hm, &hr); 460 hpi_send_recv(&hm, &hr);
750 461
751 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 462 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
752 HPI_OSTREAM_CLOSE); 463 HPI_OSTREAM_CLOSE);
753 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 464 hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index);
754 hpi_send_recv(&hm, &hr); 465 hpi_send_recv(&hm, &hr);
755 466
756 return hr.error; 467 return hr.error;
757} 468}
758 469
759u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys, 470u16 hpi_outstream_get_info_ex(u32 h_outstream, u16 *pw_state,
760 u32 h_outstream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_to_play, 471 u32 *pbuffer_size, u32 *pdata_to_play, u32 *psamples_played,
761 u32 *psamples_played, u32 *pauxiliary_data_to_play) 472 u32 *pauxiliary_data_to_play)
762{ 473{
763 struct hpi_message hm; 474 struct hpi_message hm;
764 struct hpi_response hr; 475 struct hpi_response hr;
765 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 476 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
766 HPI_OSTREAM_GET_INFO); 477 HPI_OSTREAM_GET_INFO);
767 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 478 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
479 return HPI_ERROR_INVALID_HANDLE;
768 480
769 hpi_send_recv(&hm, &hr); 481 hpi_send_recv(&hm, &hr);
770 482
@@ -782,15 +494,15 @@ u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys,
782 return hr.error; 494 return hr.error;
783} 495}
784 496
785u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys, 497u16 hpi_outstream_write_buf(u32 h_outstream, const u8 *pb_data,
786 u32 h_outstream, const u8 *pb_data, u32 bytes_to_write, 498 u32 bytes_to_write, const struct hpi_format *p_format)
787 const struct hpi_format *p_format)
788{ 499{
789 struct hpi_message hm; 500 struct hpi_message hm;
790 struct hpi_response hr; 501 struct hpi_response hr;
791 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 502 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
792 HPI_OSTREAM_WRITE); 503 HPI_OSTREAM_WRITE);
793 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 504 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
505 return HPI_ERROR_INVALID_HANDLE;
794 hm.u.d.u.data.pb_data = (u8 *)pb_data; 506 hm.u.d.u.data.pb_data = (u8 *)pb_data;
795 hm.u.d.u.data.data_size = bytes_to_write; 507 hm.u.d.u.data.data_size = bytes_to_write;
796 508
@@ -801,82 +513,85 @@ u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys,
801 return hr.error; 513 return hr.error;
802} 514}
803 515
804u16 hpi_outstream_start(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 516u16 hpi_outstream_start(u32 h_outstream)
805{ 517{
806 struct hpi_message hm; 518 struct hpi_message hm;
807 struct hpi_response hr; 519 struct hpi_response hr;
808 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 520 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
809 HPI_OSTREAM_START); 521 HPI_OSTREAM_START);
810 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 522 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
523 return HPI_ERROR_INVALID_HANDLE;
811 524
812 hpi_send_recv(&hm, &hr); 525 hpi_send_recv(&hm, &hr);
813 526
814 return hr.error; 527 return hr.error;
815} 528}
816 529
817u16 hpi_outstream_wait_start(const struct hpi_hsubsys *ph_subsys, 530u16 hpi_outstream_wait_start(u32 h_outstream)
818 u32 h_outstream)
819{ 531{
820 struct hpi_message hm; 532 struct hpi_message hm;
821 struct hpi_response hr; 533 struct hpi_response hr;
822 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 534 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
823 HPI_OSTREAM_WAIT_START); 535 HPI_OSTREAM_WAIT_START);
824 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 536 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
537 return HPI_ERROR_INVALID_HANDLE;
825 538
826 hpi_send_recv(&hm, &hr); 539 hpi_send_recv(&hm, &hr);
827 540
828 return hr.error; 541 return hr.error;
829} 542}
830 543
831u16 hpi_outstream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 544u16 hpi_outstream_stop(u32 h_outstream)
832{ 545{
833 struct hpi_message hm; 546 struct hpi_message hm;
834 struct hpi_response hr; 547 struct hpi_response hr;
835 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 548 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
836 HPI_OSTREAM_STOP); 549 HPI_OSTREAM_STOP);
837 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 550 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
551 return HPI_ERROR_INVALID_HANDLE;
838 552
839 hpi_send_recv(&hm, &hr); 553 hpi_send_recv(&hm, &hr);
840 554
841 return hr.error; 555 return hr.error;
842} 556}
843 557
844u16 hpi_outstream_sinegen(const struct hpi_hsubsys *ph_subsys, 558u16 hpi_outstream_sinegen(u32 h_outstream)
845 u32 h_outstream)
846{ 559{
847 struct hpi_message hm; 560 struct hpi_message hm;
848 struct hpi_response hr; 561 struct hpi_response hr;
849 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 562 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
850 HPI_OSTREAM_SINEGEN); 563 HPI_OSTREAM_SINEGEN);
851 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 564 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
565 return HPI_ERROR_INVALID_HANDLE;
852 566
853 hpi_send_recv(&hm, &hr); 567 hpi_send_recv(&hm, &hr);
854 568
855 return hr.error; 569 return hr.error;
856} 570}
857 571
858u16 hpi_outstream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 572u16 hpi_outstream_reset(u32 h_outstream)
859{ 573{
860 struct hpi_message hm; 574 struct hpi_message hm;
861 struct hpi_response hr; 575 struct hpi_response hr;
862 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 576 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
863 HPI_OSTREAM_RESET); 577 HPI_OSTREAM_RESET);
864 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 578 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
579 return HPI_ERROR_INVALID_HANDLE;
865 580
866 hpi_send_recv(&hm, &hr); 581 hpi_send_recv(&hm, &hr);
867 582
868 return hr.error; 583 return hr.error;
869} 584}
870 585
871u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys, 586u16 hpi_outstream_query_format(u32 h_outstream, struct hpi_format *p_format)
872 u32 h_outstream, struct hpi_format *p_format)
873{ 587{
874 struct hpi_message hm; 588 struct hpi_message hm;
875 struct hpi_response hr; 589 struct hpi_response hr;
876 590
877 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 591 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
878 HPI_OSTREAM_QUERY_FORMAT); 592 HPI_OSTREAM_QUERY_FORMAT);
879 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 593 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
594 return HPI_ERROR_INVALID_HANDLE;
880 595
881 hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 596 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
882 597
@@ -885,15 +600,15 @@ u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys,
885 return hr.error; 600 return hr.error;
886} 601}
887 602
888u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys, 603u16 hpi_outstream_set_format(u32 h_outstream, struct hpi_format *p_format)
889 u32 h_outstream, struct hpi_format *p_format)
890{ 604{
891 struct hpi_message hm; 605 struct hpi_message hm;
892 struct hpi_response hr; 606 struct hpi_response hr;
893 607
894 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 608 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
895 HPI_OSTREAM_SET_FORMAT); 609 HPI_OSTREAM_SET_FORMAT);
896 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 610 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
611 return HPI_ERROR_INVALID_HANDLE;
897 612
898 hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 613 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
899 614
@@ -902,15 +617,15 @@ u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys,
902 return hr.error; 617 return hr.error;
903} 618}
904 619
905u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys, 620u16 hpi_outstream_set_velocity(u32 h_outstream, short velocity)
906 u32 h_outstream, short velocity)
907{ 621{
908 struct hpi_message hm; 622 struct hpi_message hm;
909 struct hpi_response hr; 623 struct hpi_response hr;
910 624
911 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 625 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
912 HPI_OSTREAM_SET_VELOCITY); 626 HPI_OSTREAM_SET_VELOCITY);
913 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 627 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
628 return HPI_ERROR_INVALID_HANDLE;
914 hm.u.d.u.velocity = velocity; 629 hm.u.d.u.velocity = velocity;
915 630
916 hpi_send_recv(&hm, &hr); 631 hpi_send_recv(&hm, &hr);
@@ -918,15 +633,16 @@ u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys,
918 return hr.error; 633 return hr.error;
919} 634}
920 635
921u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys, 636u16 hpi_outstream_set_punch_in_out(u32 h_outstream, u32 punch_in_sample,
922 u32 h_outstream, u32 punch_in_sample, u32 punch_out_sample) 637 u32 punch_out_sample)
923{ 638{
924 struct hpi_message hm; 639 struct hpi_message hm;
925 struct hpi_response hr; 640 struct hpi_response hr;
926 641
927 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 642 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
928 HPI_OSTREAM_SET_PUNCHINOUT); 643 HPI_OSTREAM_SET_PUNCHINOUT);
929 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 644 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
645 return HPI_ERROR_INVALID_HANDLE;
930 646
931 hm.u.d.u.pio.punch_in_sample = punch_in_sample; 647 hm.u.d.u.pio.punch_in_sample = punch_in_sample;
932 hm.u.d.u.pio.punch_out_sample = punch_out_sample; 648 hm.u.d.u.pio.punch_out_sample = punch_out_sample;
@@ -936,29 +652,29 @@ u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys,
936 return hr.error; 652 return hr.error;
937} 653}
938 654
939u16 hpi_outstream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, 655u16 hpi_outstream_ancillary_reset(u32 h_outstream, u16 mode)
940 u32 h_outstream, u16 mode)
941{ 656{
942 struct hpi_message hm; 657 struct hpi_message hm;
943 struct hpi_response hr; 658 struct hpi_response hr;
944 659
945 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 660 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
946 HPI_OSTREAM_ANC_RESET); 661 HPI_OSTREAM_ANC_RESET);
947 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 662 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
663 return HPI_ERROR_INVALID_HANDLE;
948 hm.u.d.u.data.format.channels = mode; 664 hm.u.d.u.data.format.channels = mode;
949 hpi_send_recv(&hm, &hr); 665 hpi_send_recv(&hm, &hr);
950 return hr.error; 666 return hr.error;
951} 667}
952 668
953u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, 669u16 hpi_outstream_ancillary_get_info(u32 h_outstream, u32 *pframes_available)
954 u32 h_outstream, u32 *pframes_available)
955{ 670{
956 struct hpi_message hm; 671 struct hpi_message hm;
957 struct hpi_response hr; 672 struct hpi_response hr;
958 673
959 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 674 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
960 HPI_OSTREAM_ANC_GET_INFO); 675 HPI_OSTREAM_ANC_GET_INFO);
961 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 676 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
677 return HPI_ERROR_INVALID_HANDLE;
962 hpi_send_recv(&hm, &hr); 678 hpi_send_recv(&hm, &hr);
963 if (hr.error == 0) { 679 if (hr.error == 0) {
964 if (pframes_available) 680 if (pframes_available)
@@ -969,8 +685,8 @@ u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys,
969 return hr.error; 685 return hr.error;
970} 686}
971 687
972u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys, 688u16 hpi_outstream_ancillary_read(u32 h_outstream,
973 u32 h_outstream, struct hpi_anc_frame *p_anc_frame_buffer, 689 struct hpi_anc_frame *p_anc_frame_buffer,
974 u32 anc_frame_buffer_size_in_bytes, 690 u32 anc_frame_buffer_size_in_bytes,
975 u32 number_of_ancillary_frames_to_read) 691 u32 number_of_ancillary_frames_to_read)
976{ 692{
@@ -979,7 +695,8 @@ u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys,
979 695
980 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 696 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
981 HPI_OSTREAM_ANC_READ); 697 HPI_OSTREAM_ANC_READ);
982 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 698 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
699 return HPI_ERROR_INVALID_HANDLE;
983 hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer; 700 hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer;
984 hm.u.d.u.data.data_size = 701 hm.u.d.u.data.data_size =
985 number_of_ancillary_frames_to_read * 702 number_of_ancillary_frames_to_read *
@@ -987,19 +704,19 @@ u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys,
987 if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes) 704 if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes)
988 hpi_send_recv(&hm, &hr); 705 hpi_send_recv(&hm, &hr);
989 else 706 else
990 hr.error = HPI_ERROR_INVALID_DATA_TRANSFER; 707 hr.error = HPI_ERROR_INVALID_DATASIZE;
991 return hr.error; 708 return hr.error;
992} 709}
993 710
994u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys, 711u16 hpi_outstream_set_time_scale(u32 h_outstream, u32 time_scale)
995 u32 h_outstream, u32 time_scale)
996{ 712{
997 struct hpi_message hm; 713 struct hpi_message hm;
998 struct hpi_response hr; 714 struct hpi_response hr;
999 715
1000 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 716 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1001 HPI_OSTREAM_SET_TIMESCALE); 717 HPI_OSTREAM_SET_TIMESCALE);
1002 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 718 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
719 return HPI_ERROR_INVALID_HANDLE;
1003 720
1004 hm.u.d.u.time_scale = time_scale; 721 hm.u.d.u.time_scale = time_scale;
1005 722
@@ -1008,22 +725,21 @@ u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys,
1008 return hr.error; 725 return hr.error;
1009} 726}
1010 727
1011u16 hpi_outstream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, 728u16 hpi_outstream_host_buffer_allocate(u32 h_outstream, u32 size_in_bytes)
1012 u32 h_outstream, u32 size_in_bytes)
1013{ 729{
1014 struct hpi_message hm; 730 struct hpi_message hm;
1015 struct hpi_response hr; 731 struct hpi_response hr;
1016 732
1017 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 733 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1018 HPI_OSTREAM_HOSTBUFFER_ALLOC); 734 HPI_OSTREAM_HOSTBUFFER_ALLOC);
1019 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 735 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
736 return HPI_ERROR_INVALID_HANDLE;
1020 hm.u.d.u.data.data_size = size_in_bytes; 737 hm.u.d.u.data.data_size = size_in_bytes;
1021 hpi_send_recv(&hm, &hr); 738 hpi_send_recv(&hm, &hr);
1022 return hr.error; 739 return hr.error;
1023} 740}
1024 741
1025u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, 742u16 hpi_outstream_host_buffer_get_info(u32 h_outstream, u8 **pp_buffer,
1026 u32 h_outstream, u8 **pp_buffer,
1027 struct hpi_hostbuffer_status **pp_status) 743 struct hpi_hostbuffer_status **pp_status)
1028{ 744{
1029 struct hpi_message hm; 745 struct hpi_message hm;
@@ -1031,7 +747,8 @@ u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1031 747
1032 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 748 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1033 HPI_OSTREAM_HOSTBUFFER_GET_INFO); 749 HPI_OSTREAM_HOSTBUFFER_GET_INFO);
1034 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 750 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
751 return HPI_ERROR_INVALID_HANDLE;
1035 hpi_send_recv(&hm, &hr); 752 hpi_send_recv(&hm, &hr);
1036 753
1037 if (hr.error == 0) { 754 if (hr.error == 0) {
@@ -1043,21 +760,20 @@ u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1043 return hr.error; 760 return hr.error;
1044} 761}
1045 762
1046u16 hpi_outstream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, 763u16 hpi_outstream_host_buffer_free(u32 h_outstream)
1047 u32 h_outstream)
1048{ 764{
1049 struct hpi_message hm; 765 struct hpi_message hm;
1050 struct hpi_response hr; 766 struct hpi_response hr;
1051 767
1052 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 768 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1053 HPI_OSTREAM_HOSTBUFFER_FREE); 769 HPI_OSTREAM_HOSTBUFFER_FREE);
1054 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 770 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
771 return HPI_ERROR_INVALID_HANDLE;
1055 hpi_send_recv(&hm, &hr); 772 hpi_send_recv(&hm, &hr);
1056 return hr.error; 773 return hr.error;
1057} 774}
1058 775
1059u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys, 776u16 hpi_outstream_group_add(u32 h_outstream, u32 h_stream)
1060 u32 h_outstream, u32 h_stream)
1061{ 777{
1062 struct hpi_message hm; 778 struct hpi_message hm;
1063 struct hpi_response hr; 779 struct hpi_response hr;
@@ -1066,22 +782,22 @@ u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys,
1066 782
1067 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 783 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1068 HPI_OSTREAM_GROUP_ADD); 784 HPI_OSTREAM_GROUP_ADD);
1069 hr.error = 0; 785
1070 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 786 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
787 return HPI_ERROR_INVALID_HANDLE;
788
789 if (hpi_handle_indexes(h_stream, &adapter,
790 &hm.u.d.u.stream.stream_index))
791 return HPI_ERROR_INVALID_HANDLE;
792
1071 c_obj_type = hpi_handle_object(h_stream); 793 c_obj_type = hpi_handle_object(h_stream);
1072 switch (c_obj_type) { 794 switch (c_obj_type) {
1073 case HPI_OBJ_OSTREAM: 795 case HPI_OBJ_OSTREAM:
1074 hm.u.d.u.stream.object_type = HPI_OBJ_OSTREAM;
1075 u32TOINDEXES(h_stream, &adapter,
1076 &hm.u.d.u.stream.stream_index);
1077 break;
1078 case HPI_OBJ_ISTREAM: 796 case HPI_OBJ_ISTREAM:
1079 hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM; 797 hm.u.d.u.stream.object_type = c_obj_type;
1080 u32TOINDEXES(h_stream, &adapter,
1081 &hm.u.d.u.stream.stream_index);
1082 break; 798 break;
1083 default: 799 default:
1084 return HPI_ERROR_INVALID_STREAM; 800 return HPI_ERROR_INVALID_OBJ;
1085 } 801 }
1086 if (adapter != hm.adapter_index) 802 if (adapter != hm.adapter_index)
1087 return HPI_ERROR_NO_INTERADAPTER_GROUPS; 803 return HPI_ERROR_NO_INTERADAPTER_GROUPS;
@@ -1090,15 +806,16 @@ u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys,
1090 return hr.error; 806 return hr.error;
1091} 807}
1092 808
1093u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys, 809u16 hpi_outstream_group_get_map(u32 h_outstream, u32 *poutstream_map,
1094 u32 h_outstream, u32 *poutstream_map, u32 *pinstream_map) 810 u32 *pinstream_map)
1095{ 811{
1096 struct hpi_message hm; 812 struct hpi_message hm;
1097 struct hpi_response hr; 813 struct hpi_response hr;
1098 814
1099 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 815 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1100 HPI_OSTREAM_GROUP_GETMAP); 816 HPI_OSTREAM_GROUP_GETMAP);
1101 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 817 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
818 return HPI_ERROR_INVALID_HANDLE;
1102 hpi_send_recv(&hm, &hr); 819 hpi_send_recv(&hm, &hr);
1103 820
1104 if (poutstream_map) 821 if (poutstream_map)
@@ -1109,21 +826,20 @@ u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys,
1109 return hr.error; 826 return hr.error;
1110} 827}
1111 828
1112u16 hpi_outstream_group_reset(const struct hpi_hsubsys *ph_subsys, 829u16 hpi_outstream_group_reset(u32 h_outstream)
1113 u32 h_outstream)
1114{ 830{
1115 struct hpi_message hm; 831 struct hpi_message hm;
1116 struct hpi_response hr; 832 struct hpi_response hr;
1117 833
1118 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 834 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1119 HPI_OSTREAM_GROUP_RESET); 835 HPI_OSTREAM_GROUP_RESET);
1120 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 836 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
837 return HPI_ERROR_INVALID_HANDLE;
1121 hpi_send_recv(&hm, &hr); 838 hpi_send_recv(&hm, &hr);
1122 return hr.error; 839 return hr.error;
1123} 840}
1124 841
1125u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 842u16 hpi_instream_open(u16 adapter_index, u16 instream_index, u32 *ph_instream)
1126 u16 instream_index, u32 *ph_instream)
1127{ 843{
1128 struct hpi_message hm; 844 struct hpi_message hm;
1129 struct hpi_response hr; 845 struct hpi_response hr;
@@ -1145,38 +861,40 @@ u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1145 return hr.error; 861 return hr.error;
1146} 862}
1147 863
1148u16 hpi_instream_close(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 864u16 hpi_instream_close(u32 h_instream)
1149{ 865{
1150 struct hpi_message hm; 866 struct hpi_message hm;
1151 struct hpi_response hr; 867 struct hpi_response hr;
1152 868
1153 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 869 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1154 HPI_ISTREAM_HOSTBUFFER_FREE); 870 HPI_ISTREAM_HOSTBUFFER_FREE);
1155 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 871 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
872 return HPI_ERROR_INVALID_HANDLE;
1156 hpi_send_recv(&hm, &hr); 873 hpi_send_recv(&hm, &hr);
1157 874
1158 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 875 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1159 HPI_ISTREAM_GROUP_RESET); 876 HPI_ISTREAM_GROUP_RESET);
1160 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 877 hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index);
1161 hpi_send_recv(&hm, &hr); 878 hpi_send_recv(&hm, &hr);
1162 879
1163 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 880 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1164 HPI_ISTREAM_CLOSE); 881 HPI_ISTREAM_CLOSE);
1165 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 882 hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index);
1166 hpi_send_recv(&hm, &hr); 883 hpi_send_recv(&hm, &hr);
1167 884
1168 return hr.error; 885 return hr.error;
1169} 886}
1170 887
1171u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys, 888u16 hpi_instream_query_format(u32 h_instream,
1172 u32 h_instream, const struct hpi_format *p_format) 889 const struct hpi_format *p_format)
1173{ 890{
1174 struct hpi_message hm; 891 struct hpi_message hm;
1175 struct hpi_response hr; 892 struct hpi_response hr;
1176 893
1177 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 894 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1178 HPI_ISTREAM_QUERY_FORMAT); 895 HPI_ISTREAM_QUERY_FORMAT);
1179 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 896 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
897 return HPI_ERROR_INVALID_HANDLE;
1180 hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 898 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
1181 899
1182 hpi_send_recv(&hm, &hr); 900 hpi_send_recv(&hm, &hr);
@@ -1184,15 +902,15 @@ u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys,
1184 return hr.error; 902 return hr.error;
1185} 903}
1186 904
1187u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys, 905u16 hpi_instream_set_format(u32 h_instream, const struct hpi_format *p_format)
1188 u32 h_instream, const struct hpi_format *p_format)
1189{ 906{
1190 struct hpi_message hm; 907 struct hpi_message hm;
1191 struct hpi_response hr; 908 struct hpi_response hr;
1192 909
1193 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 910 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1194 HPI_ISTREAM_SET_FORMAT); 911 HPI_ISTREAM_SET_FORMAT);
1195 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 912 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
913 return HPI_ERROR_INVALID_HANDLE;
1196 hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 914 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
1197 915
1198 hpi_send_recv(&hm, &hr); 916 hpi_send_recv(&hm, &hr);
@@ -1200,15 +918,15 @@ u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys,
1200 return hr.error; 918 return hr.error;
1201} 919}
1202 920
1203u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream, 921u16 hpi_instream_read_buf(u32 h_instream, u8 *pb_data, u32 bytes_to_read)
1204 u8 *pb_data, u32 bytes_to_read)
1205{ 922{
1206 struct hpi_message hm; 923 struct hpi_message hm;
1207 struct hpi_response hr; 924 struct hpi_response hr;
1208 925
1209 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 926 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1210 HPI_ISTREAM_READ); 927 HPI_ISTREAM_READ);
1211 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 928 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
929 return HPI_ERROR_INVALID_HANDLE;
1212 hm.u.d.u.data.data_size = bytes_to_read; 930 hm.u.d.u.data.data_size = bytes_to_read;
1213 hm.u.d.u.data.pb_data = pb_data; 931 hm.u.d.u.data.pb_data = pb_data;
1214 932
@@ -1217,72 +935,76 @@ u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream,
1217 return hr.error; 935 return hr.error;
1218} 936}
1219 937
1220u16 hpi_instream_start(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 938u16 hpi_instream_start(u32 h_instream)
1221{ 939{
1222 struct hpi_message hm; 940 struct hpi_message hm;
1223 struct hpi_response hr; 941 struct hpi_response hr;
1224 942
1225 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 943 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1226 HPI_ISTREAM_START); 944 HPI_ISTREAM_START);
1227 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 945 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
946 return HPI_ERROR_INVALID_HANDLE;
1228 947
1229 hpi_send_recv(&hm, &hr); 948 hpi_send_recv(&hm, &hr);
1230 949
1231 return hr.error; 950 return hr.error;
1232} 951}
1233 952
1234u16 hpi_instream_wait_start(const struct hpi_hsubsys *ph_subsys, 953u16 hpi_instream_wait_start(u32 h_instream)
1235 u32 h_instream)
1236{ 954{
1237 struct hpi_message hm; 955 struct hpi_message hm;
1238 struct hpi_response hr; 956 struct hpi_response hr;
1239 957
1240 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 958 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1241 HPI_ISTREAM_WAIT_START); 959 HPI_ISTREAM_WAIT_START);
1242 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 960 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
961 return HPI_ERROR_INVALID_HANDLE;
1243 962
1244 hpi_send_recv(&hm, &hr); 963 hpi_send_recv(&hm, &hr);
1245 964
1246 return hr.error; 965 return hr.error;
1247} 966}
1248 967
1249u16 hpi_instream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 968u16 hpi_instream_stop(u32 h_instream)
1250{ 969{
1251 struct hpi_message hm; 970 struct hpi_message hm;
1252 struct hpi_response hr; 971 struct hpi_response hr;
1253 972
1254 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 973 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1255 HPI_ISTREAM_STOP); 974 HPI_ISTREAM_STOP);
1256 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 975 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
976 return HPI_ERROR_INVALID_HANDLE;
1257 977
1258 hpi_send_recv(&hm, &hr); 978 hpi_send_recv(&hm, &hr);
1259 979
1260 return hr.error; 980 return hr.error;
1261} 981}
1262 982
1263u16 hpi_instream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 983u16 hpi_instream_reset(u32 h_instream)
1264{ 984{
1265 struct hpi_message hm; 985 struct hpi_message hm;
1266 struct hpi_response hr; 986 struct hpi_response hr;
1267 987
1268 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 988 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1269 HPI_ISTREAM_RESET); 989 HPI_ISTREAM_RESET);
1270 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 990 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
991 return HPI_ERROR_INVALID_HANDLE;
1271 992
1272 hpi_send_recv(&hm, &hr); 993 hpi_send_recv(&hm, &hr);
1273 994
1274 return hr.error; 995 return hr.error;
1275} 996}
1276 997
1277u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys, 998u16 hpi_instream_get_info_ex(u32 h_instream, u16 *pw_state, u32 *pbuffer_size,
1278 u32 h_instream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_recorded, 999 u32 *pdata_recorded, u32 *psamples_recorded,
1279 u32 *psamples_recorded, u32 *pauxiliary_data_recorded) 1000 u32 *pauxiliary_data_recorded)
1280{ 1001{
1281 struct hpi_message hm; 1002 struct hpi_message hm;
1282 struct hpi_response hr; 1003 struct hpi_response hr;
1283 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1004 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1284 HPI_ISTREAM_GET_INFO); 1005 HPI_ISTREAM_GET_INFO);
1285 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1006 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1007 return HPI_ERROR_INVALID_HANDLE;
1286 1008
1287 hpi_send_recv(&hm, &hr); 1009 hpi_send_recv(&hm, &hr);
1288 1010
@@ -1300,15 +1022,15 @@ u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys,
1300 return hr.error; 1022 return hr.error;
1301} 1023}
1302 1024
1303u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, 1025u16 hpi_instream_ancillary_reset(u32 h_instream, u16 bytes_per_frame,
1304 u32 h_instream, u16 bytes_per_frame, u16 mode, u16 alignment, 1026 u16 mode, u16 alignment, u16 idle_bit)
1305 u16 idle_bit)
1306{ 1027{
1307 struct hpi_message hm; 1028 struct hpi_message hm;
1308 struct hpi_response hr; 1029 struct hpi_response hr;
1309 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1030 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1310 HPI_ISTREAM_ANC_RESET); 1031 HPI_ISTREAM_ANC_RESET);
1311 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1032 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1033 return HPI_ERROR_INVALID_HANDLE;
1312 hm.u.d.u.data.format.attributes = bytes_per_frame; 1034 hm.u.d.u.data.format.attributes = bytes_per_frame;
1313 hm.u.d.u.data.format.format = (mode << 8) | (alignment & 0xff); 1035 hm.u.d.u.data.format.format = (mode << 8) | (alignment & 0xff);
1314 hm.u.d.u.data.format.channels = idle_bit; 1036 hm.u.d.u.data.format.channels = idle_bit;
@@ -1316,14 +1038,14 @@ u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys,
1316 return hr.error; 1038 return hr.error;
1317} 1039}
1318 1040
1319u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, 1041u16 hpi_instream_ancillary_get_info(u32 h_instream, u32 *pframe_space)
1320 u32 h_instream, u32 *pframe_space)
1321{ 1042{
1322 struct hpi_message hm; 1043 struct hpi_message hm;
1323 struct hpi_response hr; 1044 struct hpi_response hr;
1324 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1045 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1325 HPI_ISTREAM_ANC_GET_INFO); 1046 HPI_ISTREAM_ANC_GET_INFO);
1326 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1047 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1048 return HPI_ERROR_INVALID_HANDLE;
1327 hpi_send_recv(&hm, &hr); 1049 hpi_send_recv(&hm, &hr);
1328 if (pframe_space) 1050 if (pframe_space)
1329 *pframe_space = 1051 *pframe_space =
@@ -1333,8 +1055,8 @@ u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys,
1333 return hr.error; 1055 return hr.error;
1334} 1056}
1335 1057
1336u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys, 1058u16 hpi_instream_ancillary_write(u32 h_instream,
1337 u32 h_instream, const struct hpi_anc_frame *p_anc_frame_buffer, 1059 const struct hpi_anc_frame *p_anc_frame_buffer,
1338 u32 anc_frame_buffer_size_in_bytes, 1060 u32 anc_frame_buffer_size_in_bytes,
1339 u32 number_of_ancillary_frames_to_write) 1061 u32 number_of_ancillary_frames_to_write)
1340{ 1062{
@@ -1343,7 +1065,8 @@ u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys,
1343 1065
1344 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1066 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1345 HPI_ISTREAM_ANC_WRITE); 1067 HPI_ISTREAM_ANC_WRITE);
1346 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1068 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1069 return HPI_ERROR_INVALID_HANDLE;
1347 hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer; 1070 hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer;
1348 hm.u.d.u.data.data_size = 1071 hm.u.d.u.data.data_size =
1349 number_of_ancillary_frames_to_write * 1072 number_of_ancillary_frames_to_write *
@@ -1351,12 +1074,11 @@ u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys,
1351 if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes) 1074 if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes)
1352 hpi_send_recv(&hm, &hr); 1075 hpi_send_recv(&hm, &hr);
1353 else 1076 else
1354 hr.error = HPI_ERROR_INVALID_DATA_TRANSFER; 1077 hr.error = HPI_ERROR_INVALID_DATASIZE;
1355 return hr.error; 1078 return hr.error;
1356} 1079}
1357 1080
1358u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, 1081u16 hpi_instream_host_buffer_allocate(u32 h_instream, u32 size_in_bytes)
1359 u32 h_instream, u32 size_in_bytes)
1360{ 1082{
1361 1083
1362 struct hpi_message hm; 1084 struct hpi_message hm;
@@ -1364,14 +1086,14 @@ u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys,
1364 1086
1365 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1087 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1366 HPI_ISTREAM_HOSTBUFFER_ALLOC); 1088 HPI_ISTREAM_HOSTBUFFER_ALLOC);
1367 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1089 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1090 return HPI_ERROR_INVALID_HANDLE;
1368 hm.u.d.u.data.data_size = size_in_bytes; 1091 hm.u.d.u.data.data_size = size_in_bytes;
1369 hpi_send_recv(&hm, &hr); 1092 hpi_send_recv(&hm, &hr);
1370 return hr.error; 1093 return hr.error;
1371} 1094}
1372 1095
1373u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, 1096u16 hpi_instream_host_buffer_get_info(u32 h_instream, u8 **pp_buffer,
1374 u32 h_instream, u8 **pp_buffer,
1375 struct hpi_hostbuffer_status **pp_status) 1097 struct hpi_hostbuffer_status **pp_status)
1376{ 1098{
1377 struct hpi_message hm; 1099 struct hpi_message hm;
@@ -1379,7 +1101,8 @@ u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1379 1101
1380 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1102 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1381 HPI_ISTREAM_HOSTBUFFER_GET_INFO); 1103 HPI_ISTREAM_HOSTBUFFER_GET_INFO);
1382 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1104 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1105 return HPI_ERROR_INVALID_HANDLE;
1383 hpi_send_recv(&hm, &hr); 1106 hpi_send_recv(&hm, &hr);
1384 1107
1385 if (hr.error == 0) { 1108 if (hr.error == 0) {
@@ -1391,8 +1114,7 @@ u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1391 return hr.error; 1114 return hr.error;
1392} 1115}
1393 1116
1394u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, 1117u16 hpi_instream_host_buffer_free(u32 h_instream)
1395 u32 h_instream)
1396{ 1118{
1397 1119
1398 struct hpi_message hm; 1120 struct hpi_message hm;
@@ -1400,13 +1122,13 @@ u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys,
1400 1122
1401 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1123 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1402 HPI_ISTREAM_HOSTBUFFER_FREE); 1124 HPI_ISTREAM_HOSTBUFFER_FREE);
1403 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1125 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1126 return HPI_ERROR_INVALID_HANDLE;
1404 hpi_send_recv(&hm, &hr); 1127 hpi_send_recv(&hm, &hr);
1405 return hr.error; 1128 return hr.error;
1406} 1129}
1407 1130
1408u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys, 1131u16 hpi_instream_group_add(u32 h_instream, u32 h_stream)
1409 u32 h_instream, u32 h_stream)
1410{ 1132{
1411 struct hpi_message hm; 1133 struct hpi_message hm;
1412 struct hpi_response hr; 1134 struct hpi_response hr;
@@ -1416,22 +1138,23 @@ u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys,
1416 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1138 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1417 HPI_ISTREAM_GROUP_ADD); 1139 HPI_ISTREAM_GROUP_ADD);
1418 hr.error = 0; 1140 hr.error = 0;
1419 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1141
1142 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1143 return HPI_ERROR_INVALID_HANDLE;
1144
1145 if (hpi_handle_indexes(h_stream, &adapter,
1146 &hm.u.d.u.stream.stream_index))
1147 return HPI_ERROR_INVALID_HANDLE;
1148
1420 c_obj_type = hpi_handle_object(h_stream); 1149 c_obj_type = hpi_handle_object(h_stream);
1421 1150
1422 switch (c_obj_type) { 1151 switch (c_obj_type) {
1423 case HPI_OBJ_OSTREAM: 1152 case HPI_OBJ_OSTREAM:
1424 hm.u.d.u.stream.object_type = HPI_OBJ_OSTREAM;
1425 u32TOINDEXES(h_stream, &adapter,
1426 &hm.u.d.u.stream.stream_index);
1427 break;
1428 case HPI_OBJ_ISTREAM: 1153 case HPI_OBJ_ISTREAM:
1429 hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM; 1154 hm.u.d.u.stream.object_type = c_obj_type;
1430 u32TOINDEXES(h_stream, &adapter,
1431 &hm.u.d.u.stream.stream_index);
1432 break; 1155 break;
1433 default: 1156 default:
1434 return HPI_ERROR_INVALID_STREAM; 1157 return HPI_ERROR_INVALID_OBJ;
1435 } 1158 }
1436 1159
1437 if (adapter != hm.adapter_index) 1160 if (adapter != hm.adapter_index)
@@ -1441,15 +1164,16 @@ u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys,
1441 return hr.error; 1164 return hr.error;
1442} 1165}
1443 1166
1444u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys, 1167u16 hpi_instream_group_get_map(u32 h_instream, u32 *poutstream_map,
1445 u32 h_instream, u32 *poutstream_map, u32 *pinstream_map) 1168 u32 *pinstream_map)
1446{ 1169{
1447 struct hpi_message hm; 1170 struct hpi_message hm;
1448 struct hpi_response hr; 1171 struct hpi_response hr;
1449 1172
1450 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1173 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1451 HPI_ISTREAM_HOSTBUFFER_FREE); 1174 HPI_ISTREAM_HOSTBUFFER_FREE);
1452 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1175 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1176 return HPI_ERROR_INVALID_HANDLE;
1453 hpi_send_recv(&hm, &hr); 1177 hpi_send_recv(&hm, &hr);
1454 1178
1455 if (poutstream_map) 1179 if (poutstream_map)
@@ -1460,21 +1184,20 @@ u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys,
1460 return hr.error; 1184 return hr.error;
1461} 1185}
1462 1186
1463u16 hpi_instream_group_reset(const struct hpi_hsubsys *ph_subsys, 1187u16 hpi_instream_group_reset(u32 h_instream)
1464 u32 h_instream)
1465{ 1188{
1466 struct hpi_message hm; 1189 struct hpi_message hm;
1467 struct hpi_response hr; 1190 struct hpi_response hr;
1468 1191
1469 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1192 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1470 HPI_ISTREAM_GROUP_RESET); 1193 HPI_ISTREAM_GROUP_RESET);
1471 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1194 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1195 return HPI_ERROR_INVALID_HANDLE;
1472 hpi_send_recv(&hm, &hr); 1196 hpi_send_recv(&hm, &hr);
1473 return hr.error; 1197 return hr.error;
1474} 1198}
1475 1199
1476u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 1200u16 hpi_mixer_open(u16 adapter_index, u32 *ph_mixer)
1477 u32 *ph_mixer)
1478{ 1201{
1479 struct hpi_message hm; 1202 struct hpi_message hm;
1480 struct hpi_response hr; 1203 struct hpi_response hr;
@@ -1492,25 +1215,29 @@ u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1492 return hr.error; 1215 return hr.error;
1493} 1216}
1494 1217
1495u16 hpi_mixer_close(const struct hpi_hsubsys *ph_subsys, u32 h_mixer) 1218u16 hpi_mixer_close(u32 h_mixer)
1496{ 1219{
1497 struct hpi_message hm; 1220 struct hpi_message hm;
1498 struct hpi_response hr; 1221 struct hpi_response hr;
1222
1499 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE); 1223 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE);
1500 u32TOINDEX(h_mixer, &hm.adapter_index); 1224 if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1225 return HPI_ERROR_INVALID_HANDLE;
1226
1501 hpi_send_recv(&hm, &hr); 1227 hpi_send_recv(&hm, &hr);
1502 return hr.error; 1228 return hr.error;
1503} 1229}
1504 1230
1505u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, 1231u16 hpi_mixer_get_control(u32 h_mixer, u16 src_node_type,
1506 u16 src_node_type, u16 src_node_type_index, u16 dst_node_type, 1232 u16 src_node_type_index, u16 dst_node_type, u16 dst_node_type_index,
1507 u16 dst_node_type_index, u16 control_type, u32 *ph_control) 1233 u16 control_type, u32 *ph_control)
1508{ 1234{
1509 struct hpi_message hm; 1235 struct hpi_message hm;
1510 struct hpi_response hr; 1236 struct hpi_response hr;
1511 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, 1237 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER,
1512 HPI_MIXER_GET_CONTROL); 1238 HPI_MIXER_GET_CONTROL);
1513 u32TOINDEX(h_mixer, &hm.adapter_index); 1239 if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1240 return HPI_ERROR_INVALID_HANDLE;
1514 hm.u.m.node_type1 = src_node_type; 1241 hm.u.m.node_type1 = src_node_type;
1515 hm.u.m.node_index1 = src_node_type_index; 1242 hm.u.m.node_index1 = src_node_type_index;
1516 hm.u.m.node_type2 = dst_node_type; 1243 hm.u.m.node_type2 = dst_node_type;
@@ -1528,16 +1255,16 @@ u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer,
1528 return hr.error; 1255 return hr.error;
1529} 1256}
1530 1257
1531u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys, 1258u16 hpi_mixer_get_control_by_index(u32 h_mixer, u16 control_index,
1532 u32 h_mixer, u16 control_index, u16 *pw_src_node_type, 1259 u16 *pw_src_node_type, u16 *pw_src_node_index, u16 *pw_dst_node_type,
1533 u16 *pw_src_node_index, u16 *pw_dst_node_type, u16 *pw_dst_node_index, 1260 u16 *pw_dst_node_index, u16 *pw_control_type, u32 *ph_control)
1534 u16 *pw_control_type, u32 *ph_control)
1535{ 1261{
1536 struct hpi_message hm; 1262 struct hpi_message hm;
1537 struct hpi_response hr; 1263 struct hpi_response hr;
1538 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, 1264 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER,
1539 HPI_MIXER_GET_CONTROL_BY_INDEX); 1265 HPI_MIXER_GET_CONTROL_BY_INDEX);
1540 u32TOINDEX(h_mixer, &hm.adapter_index); 1266 if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1267 return HPI_ERROR_INVALID_HANDLE;
1541 hm.u.m.control_index = control_index; 1268 hm.u.m.control_index = control_index;
1542 hpi_send_recv(&hm, &hr); 1269 hpi_send_recv(&hm, &hr);
1543 1270
@@ -1562,13 +1289,14 @@ u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys,
1562 return hr.error; 1289 return hr.error;
1563} 1290}
1564 1291
1565u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, 1292u16 hpi_mixer_store(u32 h_mixer, enum HPI_MIXER_STORE_COMMAND command,
1566 enum HPI_MIXER_STORE_COMMAND command, u16 index) 1293 u16 index)
1567{ 1294{
1568 struct hpi_message hm; 1295 struct hpi_message hm;
1569 struct hpi_response hr; 1296 struct hpi_response hr;
1570 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_STORE); 1297 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_STORE);
1571 u32TOINDEX(h_mixer, &hm.adapter_index); 1298 if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1299 return HPI_ERROR_INVALID_HANDLE;
1572 hm.u.mx.store.command = command; 1300 hm.u.mx.store.command = command;
1573 hm.u.mx.store.index = index; 1301 hm.u.mx.store.index = index;
1574 hpi_send_recv(&hm, &hr); 1302 hpi_send_recv(&hm, &hr);
@@ -1576,16 +1304,16 @@ u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer,
1576} 1304}
1577 1305
1578static 1306static
1579u16 hpi_control_param_set(const struct hpi_hsubsys *ph_subsys, 1307u16 hpi_control_param_set(const u32 h_control, const u16 attrib,
1580 const u32 h_control, const u16 attrib, const u32 param1, 1308 const u32 param1, const u32 param2)
1581 const u32 param2)
1582{ 1309{
1583 struct hpi_message hm; 1310 struct hpi_message hm;
1584 struct hpi_response hr; 1311 struct hpi_response hr;
1585 1312
1586 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1313 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1587 HPI_CONTROL_SET_STATE); 1314 HPI_CONTROL_SET_STATE);
1588 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1315 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1316 return HPI_ERROR_INVALID_HANDLE;
1589 hm.u.c.attribute = attrib; 1317 hm.u.c.attribute = attrib;
1590 hm.u.c.param1 = param1; 1318 hm.u.c.param1 = param1;
1591 hm.u.c.param2 = param2; 1319 hm.u.c.param2 = param2;
@@ -1601,7 +1329,8 @@ static u16 hpi_control_log_set2(u32 h_control, u16 attrib, short sv0,
1601 1329
1602 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1330 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1603 HPI_CONTROL_SET_STATE); 1331 HPI_CONTROL_SET_STATE);
1604 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1332 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1333 return HPI_ERROR_INVALID_HANDLE;
1605 hm.u.c.attribute = attrib; 1334 hm.u.c.attribute = attrib;
1606 hm.u.c.an_log_value[0] = sv0; 1335 hm.u.c.an_log_value[0] = sv0;
1607 hm.u.c.an_log_value[1] = sv1; 1336 hm.u.c.an_log_value[1] = sv1;
@@ -1610,16 +1339,16 @@ static u16 hpi_control_log_set2(u32 h_control, u16 attrib, short sv0,
1610} 1339}
1611 1340
1612static 1341static
1613u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys, 1342u16 hpi_control_param_get(const u32 h_control, const u16 attrib, u32 param1,
1614 const u32 h_control, const u16 attrib, u32 param1, u32 param2, 1343 u32 param2, u32 *pparam1, u32 *pparam2)
1615 u32 *pparam1, u32 *pparam2)
1616{ 1344{
1617 struct hpi_message hm; 1345 struct hpi_message hm;
1618 struct hpi_response hr; 1346 struct hpi_response hr;
1619 1347
1620 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1348 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1621 HPI_CONTROL_GET_STATE); 1349 HPI_CONTROL_GET_STATE);
1622 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1350 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1351 return HPI_ERROR_INVALID_HANDLE;
1623 hm.u.c.attribute = attrib; 1352 hm.u.c.attribute = attrib;
1624 hm.u.c.param1 = param1; 1353 hm.u.c.param1 = param1;
1625 hm.u.c.param2 = param2; 1354 hm.u.c.param2 = param2;
@@ -1632,19 +1361,20 @@ u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys,
1632 return hr.error; 1361 return hr.error;
1633} 1362}
1634 1363
1635#define hpi_control_param1_get(s, h, a, p1) \ 1364#define hpi_control_param1_get(h, a, p1) \
1636 hpi_control_param_get(s, h, a, 0, 0, p1, NULL) 1365 hpi_control_param_get(h, a, 0, 0, p1, NULL)
1637#define hpi_control_param2_get(s, h, a, p1, p2) \ 1366#define hpi_control_param2_get(h, a, p1, p2) \
1638 hpi_control_param_get(s, h, a, 0, 0, p1, p2) 1367 hpi_control_param_get(h, a, 0, 0, p1, p2)
1639 1368
1640static u16 hpi_control_log_get2(const struct hpi_hsubsys *ph_subsys, 1369static u16 hpi_control_log_get2(u32 h_control, u16 attrib, short *sv0,
1641 u32 h_control, u16 attrib, short *sv0, short *sv1) 1370 short *sv1)
1642{ 1371{
1643 struct hpi_message hm; 1372 struct hpi_message hm;
1644 struct hpi_response hr; 1373 struct hpi_response hr;
1645 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1374 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1646 HPI_CONTROL_GET_STATE); 1375 HPI_CONTROL_GET_STATE);
1647 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1376 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1377 return HPI_ERROR_INVALID_HANDLE;
1648 hm.u.c.attribute = attrib; 1378 hm.u.c.attribute = attrib;
1649 1379
1650 hpi_send_recv(&hm, &hr); 1380 hpi_send_recv(&hm, &hr);
@@ -1655,8 +1385,7 @@ static u16 hpi_control_log_get2(const struct hpi_hsubsys *ph_subsys,
1655} 1385}
1656 1386
1657static 1387static
1658u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys, 1388u16 hpi_control_query(const u32 h_control, const u16 attrib, const u32 index,
1659 const u32 h_control, const u16 attrib, const u32 index,
1660 const u32 param, u32 *psetting) 1389 const u32 param, u32 *psetting)
1661{ 1390{
1662 struct hpi_message hm; 1391 struct hpi_message hm;
@@ -1664,7 +1393,8 @@ u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys,
1664 1393
1665 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1394 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1666 HPI_CONTROL_GET_INFO); 1395 HPI_CONTROL_GET_INFO);
1667 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1396 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1397 return HPI_ERROR_INVALID_HANDLE;
1668 1398
1669 hm.u.c.attribute = attrib; 1399 hm.u.c.attribute = attrib;
1670 hm.u.c.param1 = index; 1400 hm.u.c.param1 = index;
@@ -1682,7 +1412,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1682 unsigned int sub_string_index = 0, j = 0; 1412 unsigned int sub_string_index = 0, j = 0;
1683 char c = 0; 1413 char c = 0;
1684 unsigned int n = 0; 1414 unsigned int n = 0;
1685 u16 hE = 0; 1415 u16 err = 0;
1686 1416
1687 if ((string_length < 1) || (string_length > 256)) 1417 if ((string_length < 1) || (string_length > 256))
1688 return HPI_ERROR_INVALID_CONTROL_VALUE; 1418 return HPI_ERROR_INVALID_CONTROL_VALUE;
@@ -1693,7 +1423,9 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1693 1423
1694 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1424 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1695 HPI_CONTROL_GET_STATE); 1425 HPI_CONTROL_GET_STATE);
1696 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1426 if (hpi_handle_indexes(h_control, &hm.adapter_index,
1427 &hm.obj_index))
1428 return HPI_ERROR_INVALID_HANDLE;
1697 hm.u.c.attribute = attribute; 1429 hm.u.c.attribute = attribute;
1698 hm.u.c.param1 = sub_string_index; 1430 hm.u.c.param1 = sub_string_index;
1699 hm.u.c.param2 = 0; 1431 hm.u.c.param2 = 0;
@@ -1705,7 +1437,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1705 return HPI_ERROR_INVALID_CONTROL_VALUE; 1437 return HPI_ERROR_INVALID_CONTROL_VALUE;
1706 1438
1707 if (hr.error) { 1439 if (hr.error) {
1708 hE = hr.error; 1440 err = hr.error;
1709 break; 1441 break;
1710 } 1442 }
1711 for (j = 0; j < 8; j++) { 1443 for (j = 0; j < 8; j++) {
@@ -1714,7 +1446,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1714 n++; 1446 n++;
1715 if (n >= string_length) { 1447 if (n >= string_length) {
1716 psz_string[string_length - 1] = 0; 1448 psz_string[string_length - 1] = 0;
1717 hE = HPI_ERROR_INVALID_CONTROL_VALUE; 1449 err = HPI_ERROR_INVALID_CONTROL_VALUE;
1718 break; 1450 break;
1719 } 1451 }
1720 if (c == 0) 1452 if (c == 0)
@@ -1730,57 +1462,52 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1730 if (c == 0) 1462 if (c == 0)
1731 break; 1463 break;
1732 } 1464 }
1733 return hE; 1465 return err;
1734} 1466}
1735 1467
1736u16 HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys *ph_subsys, 1468u16 hpi_aesebu_receiver_query_format(const u32 h_aes_rx, const u32 index,
1737 const u32 h_aes_rx, const u32 index, u16 *pw_format) 1469 u16 *pw_format)
1738{ 1470{
1739 u32 qr; 1471 u32 qr;
1740 u16 err; 1472 u16 err;
1741 1473
1742 err = hpi_control_query(ph_subsys, h_aes_rx, HPI_AESEBURX_FORMAT, 1474 err = hpi_control_query(h_aes_rx, HPI_AESEBURX_FORMAT, index, 0, &qr);
1743 index, 0, &qr);
1744 *pw_format = (u16)qr; 1475 *pw_format = (u16)qr;
1745 return err; 1476 return err;
1746} 1477}
1747 1478
1748u16 HPI_AESEBU__receiver_set_format(const struct hpi_hsubsys *ph_subsys, 1479u16 hpi_aesebu_receiver_set_format(u32 h_control, u16 format)
1749 u32 h_control, u16 format)
1750{ 1480{
1751 return hpi_control_param_set(ph_subsys, h_control, 1481 return hpi_control_param_set(h_control, HPI_AESEBURX_FORMAT, format,
1752 HPI_AESEBURX_FORMAT, format, 0); 1482 0);
1753} 1483}
1754 1484
1755u16 HPI_AESEBU__receiver_get_format(const struct hpi_hsubsys *ph_subsys, 1485u16 hpi_aesebu_receiver_get_format(u32 h_control, u16 *pw_format)
1756 u32 h_control, u16 *pw_format)
1757{ 1486{
1758 u16 err; 1487 u16 err;
1759 u32 param; 1488 u32 param;
1760 1489
1761 err = hpi_control_param1_get(ph_subsys, h_control, 1490 err = hpi_control_param1_get(h_control, HPI_AESEBURX_FORMAT, &param);
1762 HPI_AESEBURX_FORMAT, &param);
1763 if (!err && pw_format) 1491 if (!err && pw_format)
1764 *pw_format = (u16)param; 1492 *pw_format = (u16)param;
1765 1493
1766 return err; 1494 return err;
1767} 1495}
1768 1496
1769u16 HPI_AESEBU__receiver_get_sample_rate(const struct hpi_hsubsys *ph_subsys, 1497u16 hpi_aesebu_receiver_get_sample_rate(u32 h_control, u32 *psample_rate)
1770 u32 h_control, u32 *psample_rate)
1771{ 1498{
1772 return hpi_control_param1_get(ph_subsys, h_control, 1499 return hpi_control_param1_get(h_control, HPI_AESEBURX_SAMPLERATE,
1773 HPI_AESEBURX_SAMPLERATE, psample_rate); 1500 psample_rate);
1774} 1501}
1775 1502
1776u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys, 1503u16 hpi_aesebu_receiver_get_user_data(u32 h_control, u16 index, u16 *pw_data)
1777 u32 h_control, u16 index, u16 *pw_data)
1778{ 1504{
1779 struct hpi_message hm; 1505 struct hpi_message hm;
1780 struct hpi_response hr; 1506 struct hpi_response hr;
1781 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1507 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1782 HPI_CONTROL_GET_STATE); 1508 HPI_CONTROL_GET_STATE);
1783 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1509 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1510 return HPI_ERROR_INVALID_HANDLE;
1784 hm.u.c.attribute = HPI_AESEBURX_USERDATA; 1511 hm.u.c.attribute = HPI_AESEBURX_USERDATA;
1785 hm.u.c.param1 = index; 1512 hm.u.c.param1 = index;
1786 1513
@@ -1791,14 +1518,15 @@ u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys,
1791 return hr.error; 1518 return hr.error;
1792} 1519}
1793 1520
1794u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys 1521u16 hpi_aesebu_receiver_get_channel_status(u32 h_control, u16 index,
1795 *ph_subsys, u32 h_control, u16 index, u16 *pw_data) 1522 u16 *pw_data)
1796{ 1523{
1797 struct hpi_message hm; 1524 struct hpi_message hm;
1798 struct hpi_response hr; 1525 struct hpi_response hr;
1799 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1526 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1800 HPI_CONTROL_GET_STATE); 1527 HPI_CONTROL_GET_STATE);
1801 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1528 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1529 return HPI_ERROR_INVALID_HANDLE;
1802 hm.u.c.attribute = HPI_AESEBURX_CHANNELSTATUS; 1530 hm.u.c.attribute = HPI_AESEBURX_CHANNELSTATUS;
1803 hm.u.c.param1 = index; 1531 hm.u.c.param1 = index;
1804 1532
@@ -1809,101 +1537,93 @@ u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys
1809 return hr.error; 1537 return hr.error;
1810} 1538}
1811 1539
1812u16 HPI_AESEBU__receiver_get_error_status(const struct hpi_hsubsys *ph_subsys, 1540u16 hpi_aesebu_receiver_get_error_status(u32 h_control, u16 *pw_error_data)
1813 u32 h_control, u16 *pw_error_data)
1814{ 1541{
1815 u32 error_data = 0; 1542 u32 error_data = 0;
1816 u16 error = 0; 1543 u16 err = 0;
1817 1544
1818 error = hpi_control_param1_get(ph_subsys, h_control, 1545 err = hpi_control_param1_get(h_control, HPI_AESEBURX_ERRORSTATUS,
1819 HPI_AESEBURX_ERRORSTATUS, &error_data); 1546 &error_data);
1820 if (pw_error_data) 1547 if (pw_error_data)
1821 *pw_error_data = (u16)error_data; 1548 *pw_error_data = (u16)error_data;
1822 return error; 1549 return err;
1823} 1550}
1824 1551
1825u16 HPI_AESEBU__transmitter_set_sample_rate(const struct hpi_hsubsys 1552u16 hpi_aesebu_transmitter_set_sample_rate(u32 h_control, u32 sample_rate)
1826 *ph_subsys, u32 h_control, u32 sample_rate)
1827{ 1553{
1828 return hpi_control_param_set(ph_subsys, h_control, 1554 return hpi_control_param_set(h_control, HPI_AESEBUTX_SAMPLERATE,
1829 HPI_AESEBUTX_SAMPLERATE, sample_rate, 0); 1555 sample_rate, 0);
1830} 1556}
1831 1557
1832u16 HPI_AESEBU__transmitter_set_user_data(const struct hpi_hsubsys *ph_subsys, 1558u16 hpi_aesebu_transmitter_set_user_data(u32 h_control, u16 index, u16 data)
1833 u32 h_control, u16 index, u16 data)
1834{ 1559{
1835 return hpi_control_param_set(ph_subsys, h_control, 1560 return hpi_control_param_set(h_control, HPI_AESEBUTX_USERDATA, index,
1836 HPI_AESEBUTX_USERDATA, index, data); 1561 data);
1837} 1562}
1838 1563
1839u16 HPI_AESEBU__transmitter_set_channel_status(const struct hpi_hsubsys 1564u16 hpi_aesebu_transmitter_set_channel_status(u32 h_control, u16 index,
1840 *ph_subsys, u32 h_control, u16 index, u16 data) 1565 u16 data)
1841{ 1566{
1842 return hpi_control_param_set(ph_subsys, h_control, 1567 return hpi_control_param_set(h_control, HPI_AESEBUTX_CHANNELSTATUS,
1843 HPI_AESEBUTX_CHANNELSTATUS, index, data); 1568 index, data);
1844} 1569}
1845 1570
1846u16 HPI_AESEBU__transmitter_get_channel_status(const struct hpi_hsubsys 1571u16 hpi_aesebu_transmitter_get_channel_status(u32 h_control, u16 index,
1847 *ph_subsys, u32 h_control, u16 index, u16 *pw_data) 1572 u16 *pw_data)
1848{ 1573{
1849 return HPI_ERROR_INVALID_OPERATION; 1574 return HPI_ERROR_INVALID_OPERATION;
1850} 1575}
1851 1576
1852u16 HPI_AESEBU__transmitter_query_format(const struct hpi_hsubsys *ph_subsys, 1577u16 hpi_aesebu_transmitter_query_format(const u32 h_aes_tx, const u32 index,
1853 const u32 h_aes_tx, const u32 index, u16 *pw_format) 1578 u16 *pw_format)
1854{ 1579{
1855 u32 qr; 1580 u32 qr;
1856 u16 err; 1581 u16 err;
1857 1582
1858 err = hpi_control_query(ph_subsys, h_aes_tx, HPI_AESEBUTX_FORMAT, 1583 err = hpi_control_query(h_aes_tx, HPI_AESEBUTX_FORMAT, index, 0, &qr);
1859 index, 0, &qr);
1860 *pw_format = (u16)qr; 1584 *pw_format = (u16)qr;
1861 return err; 1585 return err;
1862} 1586}
1863 1587
1864u16 HPI_AESEBU__transmitter_set_format(const struct hpi_hsubsys *ph_subsys, 1588u16 hpi_aesebu_transmitter_set_format(u32 h_control, u16 output_format)
1865 u32 h_control, u16 output_format)
1866{ 1589{
1867 return hpi_control_param_set(ph_subsys, h_control, 1590 return hpi_control_param_set(h_control, HPI_AESEBUTX_FORMAT,
1868 HPI_AESEBUTX_FORMAT, output_format, 0); 1591 output_format, 0);
1869} 1592}
1870 1593
1871u16 HPI_AESEBU__transmitter_get_format(const struct hpi_hsubsys *ph_subsys, 1594u16 hpi_aesebu_transmitter_get_format(u32 h_control, u16 *pw_output_format)
1872 u32 h_control, u16 *pw_output_format)
1873{ 1595{
1874 u16 err; 1596 u16 err;
1875 u32 param; 1597 u32 param;
1876 1598
1877 err = hpi_control_param1_get(ph_subsys, h_control, 1599 err = hpi_control_param1_get(h_control, HPI_AESEBUTX_FORMAT, &param);
1878 HPI_AESEBUTX_FORMAT, &param);
1879 if (!err && pw_output_format) 1600 if (!err && pw_output_format)
1880 *pw_output_format = (u16)param; 1601 *pw_output_format = (u16)param;
1881 1602
1882 return err; 1603 return err;
1883} 1604}
1884 1605
1885u16 hpi_bitstream_set_clock_edge(const struct hpi_hsubsys *ph_subsys, 1606u16 hpi_bitstream_set_clock_edge(u32 h_control, u16 edge_type)
1886 u32 h_control, u16 edge_type)
1887{ 1607{
1888 return hpi_control_param_set(ph_subsys, h_control, 1608 return hpi_control_param_set(h_control, HPI_BITSTREAM_CLOCK_EDGE,
1889 HPI_BITSTREAM_CLOCK_EDGE, edge_type, 0); 1609 edge_type, 0);
1890} 1610}
1891 1611
1892u16 hpi_bitstream_set_data_polarity(const struct hpi_hsubsys *ph_subsys, 1612u16 hpi_bitstream_set_data_polarity(u32 h_control, u16 polarity)
1893 u32 h_control, u16 polarity)
1894{ 1613{
1895 return hpi_control_param_set(ph_subsys, h_control, 1614 return hpi_control_param_set(h_control, HPI_BITSTREAM_DATA_POLARITY,
1896 HPI_BITSTREAM_DATA_POLARITY, polarity, 0); 1615 polarity, 0);
1897} 1616}
1898 1617
1899u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys, 1618u16 hpi_bitstream_get_activity(u32 h_control, u16 *pw_clk_activity,
1900 u32 h_control, u16 *pw_clk_activity, u16 *pw_data_activity) 1619 u16 *pw_data_activity)
1901{ 1620{
1902 struct hpi_message hm; 1621 struct hpi_message hm;
1903 struct hpi_response hr; 1622 struct hpi_response hr;
1904 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1623 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1905 HPI_CONTROL_GET_STATE); 1624 HPI_CONTROL_GET_STATE);
1906 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1625 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1626 return HPI_ERROR_INVALID_HANDLE;
1907 hm.u.c.attribute = HPI_BITSTREAM_ACTIVITY; 1627 hm.u.c.attribute = HPI_BITSTREAM_ACTIVITY;
1908 hpi_send_recv(&hm, &hr); 1628 hpi_send_recv(&hm, &hr);
1909 if (pw_clk_activity) 1629 if (pw_clk_activity)
@@ -1913,45 +1633,43 @@ u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys,
1913 return hr.error; 1633 return hr.error;
1914} 1634}
1915 1635
1916u16 hpi_channel_mode_query_mode(const struct hpi_hsubsys *ph_subsys, 1636u16 hpi_channel_mode_query_mode(const u32 h_mode, const u32 index,
1917 const u32 h_mode, const u32 index, u16 *pw_mode) 1637 u16 *pw_mode)
1918{ 1638{
1919 u32 qr; 1639 u32 qr;
1920 u16 err; 1640 u16 err;
1921 1641
1922 err = hpi_control_query(ph_subsys, h_mode, HPI_CHANNEL_MODE_MODE, 1642 err = hpi_control_query(h_mode, HPI_CHANNEL_MODE_MODE, index, 0, &qr);
1923 index, 0, &qr);
1924 *pw_mode = (u16)qr; 1643 *pw_mode = (u16)qr;
1925 return err; 1644 return err;
1926} 1645}
1927 1646
1928u16 hpi_channel_mode_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1647u16 hpi_channel_mode_set(u32 h_control, u16 mode)
1929 u16 mode)
1930{ 1648{
1931 return hpi_control_param_set(ph_subsys, h_control, 1649 return hpi_control_param_set(h_control, HPI_CHANNEL_MODE_MODE, mode,
1932 HPI_CHANNEL_MODE_MODE, mode, 0); 1650 0);
1933} 1651}
1934 1652
1935u16 hpi_channel_mode_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1653u16 hpi_channel_mode_get(u32 h_control, u16 *mode)
1936 u16 *mode)
1937{ 1654{
1938 u32 mode32 = 0; 1655 u32 mode32 = 0;
1939 u16 error = hpi_control_param1_get(ph_subsys, h_control, 1656 u16 err = hpi_control_param1_get(h_control,
1940 HPI_CHANNEL_MODE_MODE, &mode32); 1657 HPI_CHANNEL_MODE_MODE, &mode32);
1941 if (mode) 1658 if (mode)
1942 *mode = (u16)mode32; 1659 *mode = (u16)mode32;
1943 return error; 1660 return err;
1944} 1661}
1945 1662
1946u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1663u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count,
1947 u32 hmi_address, u32 byte_count, u8 *pb_data) 1664 u8 *pb_data)
1948{ 1665{
1949 struct hpi_message hm; 1666 struct hpi_message hm;
1950 struct hpi_response hr; 1667 struct hpi_response hr;
1951 1668
1952 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1669 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
1953 HPI_CONTROL_SET_STATE); 1670 HPI_CONTROL_SET_STATE);
1954 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1671 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1672 return HPI_ERROR_INVALID_HANDLE;
1955 1673
1956 hm.u.cx.u.cobranet_data.byte_count = byte_count; 1674 hm.u.cx.u.cobranet_data.byte_count = byte_count;
1957 hm.u.cx.u.cobranet_data.hmi_address = hmi_address; 1675 hm.u.cx.u.cobranet_data.hmi_address = hmi_address;
@@ -1969,15 +1687,16 @@ u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1969 return hr.error; 1687 return hr.error;
1970} 1688}
1971 1689
1972u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1690u16 hpi_cobranet_hmi_read(u32 h_control, u32 hmi_address, u32 max_byte_count,
1973 u32 hmi_address, u32 max_byte_count, u32 *pbyte_count, u8 *pb_data) 1691 u32 *pbyte_count, u8 *pb_data)
1974{ 1692{
1975 struct hpi_message hm; 1693 struct hpi_message hm;
1976 struct hpi_response hr; 1694 struct hpi_response hr;
1977 1695
1978 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1696 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
1979 HPI_CONTROL_GET_STATE); 1697 HPI_CONTROL_GET_STATE);
1980 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1698 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1699 return HPI_ERROR_INVALID_HANDLE;
1981 1700
1982 hm.u.cx.u.cobranet_data.byte_count = max_byte_count; 1701 hm.u.cx.u.cobranet_data.byte_count = max_byte_count;
1983 hm.u.cx.u.cobranet_data.hmi_address = hmi_address; 1702 hm.u.cx.u.cobranet_data.hmi_address = hmi_address;
@@ -2008,16 +1727,16 @@ u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2008 return hr.error; 1727 return hr.error;
2009} 1728}
2010 1729
2011u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys, 1730u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus,
2012 u32 h_control, u32 *pstatus, u32 *preadable_size, 1731 u32 *preadable_size, u32 *pwriteable_size)
2013 u32 *pwriteable_size)
2014{ 1732{
2015 struct hpi_message hm; 1733 struct hpi_message hm;
2016 struct hpi_response hr; 1734 struct hpi_response hr;
2017 1735
2018 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1736 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
2019 HPI_CONTROL_GET_STATE); 1737 HPI_CONTROL_GET_STATE);
2020 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1738 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1739 return HPI_ERROR_INVALID_HANDLE;
2021 1740
2022 hm.u.cx.attribute = HPI_COBRANET_GET_STATUS; 1741 hm.u.cx.attribute = HPI_COBRANET_GET_STATUS;
2023 1742
@@ -2035,177 +1754,176 @@ u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys,
2035 return hr.error; 1754 return hr.error;
2036} 1755}
2037 1756
2038u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys, 1757u16 hpi_cobranet_get_ip_address(u32 h_control, u32 *pdw_ip_address)
2039 u32 h_control, u32 *pi_paddress)
2040{ 1758{
2041 u32 byte_count; 1759 u32 byte_count;
2042 u32 iP; 1760 u32 iP;
2043 u16 error; 1761 u16 err;
2044 1762
2045 error = hpi_cobranet_hmi_read(ph_subsys, h_control, 1763 err = hpi_cobranet_hmi_read(h_control,
2046 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count, 1764 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count,
2047 (u8 *)&iP); 1765 (u8 *)&iP);
2048 1766
2049 *pi_paddress = 1767 *pdw_ip_address =
2050 ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP & 1768 ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
2051 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8); 1769 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
2052 1770
2053 if (error) 1771 if (err)
2054 *pi_paddress = 0; 1772 *pdw_ip_address = 0;
2055 1773
2056 return error; 1774 return err;
2057 1775
2058} 1776}
2059 1777
2060u16 hpi_cobranet_setI_paddress(const struct hpi_hsubsys *ph_subsys, 1778u16 hpi_cobranet_set_ip_address(u32 h_control, u32 dw_ip_address)
2061 u32 h_control, u32 i_paddress)
2062{ 1779{
2063 u32 iP; 1780 u32 iP;
2064 u16 error; 1781 u16 err;
2065 1782
2066 iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) << 1783 iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
2067 8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress & 1784 0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
2068 0x000000ff) << 8); 1785 8) | ((dw_ip_address & 0x000000ff) << 8);
2069 1786
2070 error = hpi_cobranet_hmi_write(ph_subsys, h_control, 1787 err = hpi_cobranet_hmi_write(h_control,
2071 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, (u8 *)&iP); 1788 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, (u8 *)&iP);
2072 1789
2073 return error; 1790 return err;
2074 1791
2075} 1792}
2076 1793
2077u16 hpi_cobranet_get_staticI_paddress(const struct hpi_hsubsys *ph_subsys, 1794u16 hpi_cobranet_get_static_ip_address(u32 h_control, u32 *pdw_ip_address)
2078 u32 h_control, u32 *pi_paddress)
2079{ 1795{
2080 u32 byte_count; 1796 u32 byte_count;
2081 u32 iP; 1797 u32 iP;
2082 u16 error; 1798 u16 err;
2083 error = hpi_cobranet_hmi_read(ph_subsys, h_control, 1799 err = hpi_cobranet_hmi_read(h_control,
2084 HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count, 1800 HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count,
2085 (u8 *)&iP); 1801 (u8 *)&iP);
2086 1802
2087 *pi_paddress = 1803 *pdw_ip_address =
2088 ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP & 1804 ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
2089 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8); 1805 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
2090 1806
2091 if (error) 1807 if (err)
2092 *pi_paddress = 0; 1808 *pdw_ip_address = 0;
2093 1809
2094 return error; 1810 return err;
2095 1811
2096} 1812}
2097 1813
2098u16 hpi_cobranet_set_staticI_paddress(const struct hpi_hsubsys *ph_subsys, 1814u16 hpi_cobranet_set_static_ip_address(u32 h_control, u32 dw_ip_address)
2099 u32 h_control, u32 i_paddress)
2100{ 1815{
2101 u32 iP; 1816 u32 iP;
2102 u16 error; 1817 u16 err;
2103 1818
2104 iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) << 1819 iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
2105 8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress & 1820 0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
2106 0x000000ff) << 8); 1821 8) | ((dw_ip_address & 0x000000ff) << 8);
2107 1822
2108 error = hpi_cobranet_hmi_write(ph_subsys, h_control, 1823 err = hpi_cobranet_hmi_write(h_control,
2109 HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, (u8 *)&iP); 1824 HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, (u8 *)&iP);
2110 1825
2111 return error; 1826 return err;
2112 1827
2113} 1828}
2114 1829
2115u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys, 1830u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *p_mac_msbs,
2116 u32 h_control, u32 *pmAC_MS_bs, u32 *pmAC_LS_bs) 1831 u32 *p_mac_lsbs)
2117{ 1832{
2118 u32 byte_count; 1833 u32 byte_count;
2119 u16 error; 1834 u16 err;
2120 u32 mAC; 1835 u32 mac;
2121 1836
2122 error = hpi_cobranet_hmi_read(ph_subsys, h_control, 1837 err = hpi_cobranet_hmi_read(h_control,
2123 HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count, 1838 HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count,
2124 (u8 *)&mAC); 1839 (u8 *)&mac);
2125 *pmAC_MS_bs = 1840
2126 ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC 1841 if (!err) {
2127 & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8); 1842 *p_mac_msbs =
2128 error += hpi_cobranet_hmi_read(ph_subsys, h_control, 1843 ((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8)
2129 HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4, &byte_count, 1844 | ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) <<
2130 (u8 *)&mAC); 1845 8);
2131 *pmAC_LS_bs = 1846
2132 ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC 1847 err = hpi_cobranet_hmi_read(h_control,
2133 & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8); 1848 HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4,
2134 1849 &byte_count, (u8 *)&mac);
2135 if (error) {
2136 *pmAC_MS_bs = 0;
2137 *pmAC_LS_bs = 0;
2138 } 1850 }
2139 1851
2140 return error; 1852 if (!err) {
1853 *p_mac_lsbs =
1854 ((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8)
1855 | ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) <<
1856 8);
1857 } else {
1858 *p_mac_msbs = 0;
1859 *p_mac_lsbs = 0;
1860 }
1861
1862 return err;
2141} 1863}
2142 1864
2143u16 hpi_compander_set_enable(const struct hpi_hsubsys *ph_subsys, 1865u16 hpi_compander_set_enable(u32 h_control, u32 enable)
2144 u32 h_control, u32 enable)
2145{ 1866{
2146 return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 1867 return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
2147 enable, 0); 1868 0);
2148} 1869}
2149 1870
2150u16 hpi_compander_get_enable(const struct hpi_hsubsys *ph_subsys, 1871u16 hpi_compander_get_enable(u32 h_control, u32 *enable)
2151 u32 h_control, u32 *enable)
2152{ 1872{
2153 return hpi_control_param1_get(ph_subsys, h_control, 1873 return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
2154 HPI_GENERIC_ENABLE, enable);
2155} 1874}
2156 1875
2157u16 hpi_compander_set_makeup_gain(const struct hpi_hsubsys *ph_subsys, 1876u16 hpi_compander_set_makeup_gain(u32 h_control, short makeup_gain0_01dB)
2158 u32 h_control, short makeup_gain0_01dB)
2159{ 1877{
2160 return hpi_control_log_set2(h_control, HPI_COMPANDER_MAKEUPGAIN, 1878 return hpi_control_log_set2(h_control, HPI_COMPANDER_MAKEUPGAIN,
2161 makeup_gain0_01dB, 0); 1879 makeup_gain0_01dB, 0);
2162} 1880}
2163 1881
2164u16 hpi_compander_get_makeup_gain(const struct hpi_hsubsys *ph_subsys, 1882u16 hpi_compander_get_makeup_gain(u32 h_control, short *makeup_gain0_01dB)
2165 u32 h_control, short *makeup_gain0_01dB)
2166{ 1883{
2167 return hpi_control_log_get2(ph_subsys, h_control, 1884 return hpi_control_log_get2(h_control, HPI_COMPANDER_MAKEUPGAIN,
2168 HPI_COMPANDER_MAKEUPGAIN, makeup_gain0_01dB, NULL); 1885 makeup_gain0_01dB, NULL);
2169} 1886}
2170 1887
2171u16 hpi_compander_set_attack_time_constant(const struct hpi_hsubsys 1888u16 hpi_compander_set_attack_time_constant(u32 h_control, unsigned int index,
2172 *ph_subsys, u32 h_control, unsigned int index, u32 attack) 1889 u32 attack)
2173{ 1890{
2174 return hpi_control_param_set(ph_subsys, h_control, 1891 return hpi_control_param_set(h_control, HPI_COMPANDER_ATTACK, attack,
2175 HPI_COMPANDER_ATTACK, attack, index); 1892 index);
2176} 1893}
2177 1894
2178u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys 1895u16 hpi_compander_get_attack_time_constant(u32 h_control, unsigned int index,
2179 *ph_subsys, u32 h_control, unsigned int index, u32 *attack) 1896 u32 *attack)
2180{ 1897{
2181 return hpi_control_param_get(ph_subsys, h_control, 1898 return hpi_control_param_get(h_control, HPI_COMPANDER_ATTACK, 0,
2182 HPI_COMPANDER_ATTACK, 0, index, attack, NULL); 1899 index, attack, NULL);
2183} 1900}
2184 1901
2185u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys, 1902u16 hpi_compander_set_decay_time_constant(u32 h_control, unsigned int index,
2186 u32 h_control, unsigned int index, u32 decay) 1903 u32 decay)
2187{ 1904{
2188 return hpi_control_param_set(ph_subsys, h_control, 1905 return hpi_control_param_set(h_control, HPI_COMPANDER_DECAY, decay,
2189 HPI_COMPANDER_DECAY, decay, index); 1906 index);
2190} 1907}
2191 1908
2192u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys, 1909u16 hpi_compander_get_decay_time_constant(u32 h_control, unsigned int index,
2193 u32 h_control, unsigned int index, u32 *decay) 1910 u32 *decay)
2194{ 1911{
2195 return hpi_control_param_get(ph_subsys, h_control, 1912 return hpi_control_param_get(h_control, HPI_COMPANDER_DECAY, 0, index,
2196 HPI_COMPANDER_DECAY, 0, index, decay, NULL); 1913 decay, NULL);
2197 1914
2198} 1915}
2199 1916
2200u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys, 1917u16 hpi_compander_set_threshold(u32 h_control, unsigned int index,
2201 u32 h_control, unsigned int index, short threshold0_01dB) 1918 short threshold0_01dB)
2202{ 1919{
2203 struct hpi_message hm; 1920 struct hpi_message hm;
2204 struct hpi_response hr; 1921 struct hpi_response hr;
2205 1922
2206 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1923 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2207 HPI_CONTROL_SET_STATE); 1924 HPI_CONTROL_SET_STATE);
2208 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1925 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1926 return HPI_ERROR_INVALID_HANDLE;
2209 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD; 1927 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
2210 hm.u.c.param2 = index; 1928 hm.u.c.param2 = index;
2211 hm.u.c.an_log_value[0] = threshold0_01dB; 1929 hm.u.c.an_log_value[0] = threshold0_01dB;
@@ -2215,15 +1933,16 @@ u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys,
2215 return hr.error; 1933 return hr.error;
2216} 1934}
2217 1935
2218u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys, 1936u16 hpi_compander_get_threshold(u32 h_control, unsigned int index,
2219 u32 h_control, unsigned int index, short *threshold0_01dB) 1937 short *threshold0_01dB)
2220{ 1938{
2221 struct hpi_message hm; 1939 struct hpi_message hm;
2222 struct hpi_response hr; 1940 struct hpi_response hr;
2223 1941
2224 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1942 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2225 HPI_CONTROL_GET_STATE); 1943 HPI_CONTROL_GET_STATE);
2226 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1944 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1945 return HPI_ERROR_INVALID_HANDLE;
2227 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD; 1946 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
2228 hm.u.c.param2 = index; 1947 hm.u.c.param2 = index;
2229 1948
@@ -2233,29 +1952,28 @@ u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys,
2233 return hr.error; 1952 return hr.error;
2234} 1953}
2235 1954
2236u16 hpi_compander_set_ratio(const struct hpi_hsubsys *ph_subsys, 1955u16 hpi_compander_set_ratio(u32 h_control, u32 index, u32 ratio100)
2237 u32 h_control, u32 index, u32 ratio100)
2238{ 1956{
2239 return hpi_control_param_set(ph_subsys, h_control, 1957 return hpi_control_param_set(h_control, HPI_COMPANDER_RATIO, ratio100,
2240 HPI_COMPANDER_RATIO, ratio100, index); 1958 index);
2241} 1959}
2242 1960
2243u16 hpi_compander_get_ratio(const struct hpi_hsubsys *ph_subsys, 1961u16 hpi_compander_get_ratio(u32 h_control, u32 index, u32 *ratio100)
2244 u32 h_control, u32 index, u32 *ratio100)
2245{ 1962{
2246 return hpi_control_param_get(ph_subsys, h_control, 1963 return hpi_control_param_get(h_control, HPI_COMPANDER_RATIO, 0, index,
2247 HPI_COMPANDER_RATIO, 0, index, ratio100, NULL); 1964 ratio100, NULL);
2248} 1965}
2249 1966
2250u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1967u16 hpi_level_query_range(u32 h_control, short *min_gain_01dB,
2251 short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB) 1968 short *max_gain_01dB, short *step_gain_01dB)
2252{ 1969{
2253 struct hpi_message hm; 1970 struct hpi_message hm;
2254 struct hpi_response hr; 1971 struct hpi_response hr;
2255 1972
2256 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1973 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2257 HPI_CONTROL_GET_STATE); 1974 HPI_CONTROL_GET_STATE);
2258 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1975 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1976 return HPI_ERROR_INVALID_HANDLE;
2259 hm.u.c.attribute = HPI_LEVEL_RANGE; 1977 hm.u.c.attribute = HPI_LEVEL_RANGE;
2260 1978
2261 hpi_send_recv(&hm, &hr); 1979 hpi_send_recv(&hm, &hr);
@@ -2273,31 +1991,27 @@ u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2273 return hr.error; 1991 return hr.error;
2274} 1992}
2275 1993
2276u16 hpi_level_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1994u16 hpi_level_set_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
2277 short an_gain0_01dB[HPI_MAX_CHANNELS]
2278 ) 1995 )
2279{ 1996{
2280 return hpi_control_log_set2(h_control, HPI_LEVEL_GAIN, 1997 return hpi_control_log_set2(h_control, HPI_LEVEL_GAIN,
2281 an_gain0_01dB[0], an_gain0_01dB[1]); 1998 an_gain0_01dB[0], an_gain0_01dB[1]);
2282} 1999}
2283 2000
2284u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2001u16 hpi_level_get_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
2285 short an_gain0_01dB[HPI_MAX_CHANNELS]
2286 ) 2002 )
2287{ 2003{
2288 return hpi_control_log_get2(ph_subsys, h_control, HPI_LEVEL_GAIN, 2004 return hpi_control_log_get2(h_control, HPI_LEVEL_GAIN,
2289 &an_gain0_01dB[0], &an_gain0_01dB[1]); 2005 &an_gain0_01dB[0], &an_gain0_01dB[1]);
2290} 2006}
2291 2007
2292u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys, 2008u16 hpi_meter_query_channels(const u32 h_meter, u32 *p_channels)
2293 const u32 h_meter, u32 *p_channels)
2294{ 2009{
2295 return hpi_control_query(ph_subsys, h_meter, HPI_METER_NUM_CHANNELS, 2010 return hpi_control_query(h_meter, HPI_METER_NUM_CHANNELS, 0, 0,
2296 0, 0, p_channels); 2011 p_channels);
2297} 2012}
2298 2013
2299u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2014u16 hpi_meter_get_peak(u32 h_control, short an_peakdB[HPI_MAX_CHANNELS]
2300 short an_peakdB[HPI_MAX_CHANNELS]
2301 ) 2015 )
2302{ 2016{
2303 short i = 0; 2017 short i = 0;
@@ -2307,7 +2021,8 @@ u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2307 2021
2308 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2022 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2309 HPI_CONTROL_GET_STATE); 2023 HPI_CONTROL_GET_STATE);
2310 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2024 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2025 return HPI_ERROR_INVALID_HANDLE;
2311 hm.obj_index = hm.obj_index; 2026 hm.obj_index = hm.obj_index;
2312 hm.u.c.attribute = HPI_METER_PEAK; 2027 hm.u.c.attribute = HPI_METER_PEAK;
2313 2028
@@ -2322,8 +2037,7 @@ u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2322 return hr.error; 2037 return hr.error;
2323} 2038}
2324 2039
2325u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2040u16 hpi_meter_get_rms(u32 h_control, short an_rmsdB[HPI_MAX_CHANNELS]
2326 short an_rmsdB[HPI_MAX_CHANNELS]
2327 ) 2041 )
2328{ 2042{
2329 short i = 0; 2043 short i = 0;
@@ -2333,7 +2047,8 @@ u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2333 2047
2334 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2048 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2335 HPI_CONTROL_GET_STATE); 2049 HPI_CONTROL_GET_STATE);
2336 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2050 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2051 return HPI_ERROR_INVALID_HANDLE;
2337 hm.u.c.attribute = HPI_METER_RMS; 2052 hm.u.c.attribute = HPI_METER_RMS;
2338 2053
2339 hpi_send_recv(&hm, &hr); 2054 hpi_send_recv(&hm, &hr);
@@ -2348,22 +2063,20 @@ u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2348 return hr.error; 2063 return hr.error;
2349} 2064}
2350 2065
2351u16 hpi_meter_set_rms_ballistics(const struct hpi_hsubsys *ph_subsys, 2066u16 hpi_meter_set_rms_ballistics(u32 h_control, u16 attack, u16 decay)
2352 u32 h_control, u16 attack, u16 decay)
2353{ 2067{
2354 return hpi_control_param_set(ph_subsys, h_control, 2068 return hpi_control_param_set(h_control, HPI_METER_RMS_BALLISTICS,
2355 HPI_METER_RMS_BALLISTICS, attack, decay); 2069 attack, decay);
2356} 2070}
2357 2071
2358u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys, 2072u16 hpi_meter_get_rms_ballistics(u32 h_control, u16 *pn_attack, u16 *pn_decay)
2359 u32 h_control, u16 *pn_attack, u16 *pn_decay)
2360{ 2073{
2361 u32 attack; 2074 u32 attack;
2362 u32 decay; 2075 u32 decay;
2363 u16 error; 2076 u16 error;
2364 2077
2365 error = hpi_control_param2_get(ph_subsys, h_control, 2078 error = hpi_control_param2_get(h_control, HPI_METER_RMS_BALLISTICS,
2366 HPI_METER_RMS_BALLISTICS, &attack, &decay); 2079 &attack, &decay);
2367 2080
2368 if (pn_attack) 2081 if (pn_attack)
2369 *pn_attack = (unsigned short)attack; 2082 *pn_attack = (unsigned short)attack;
@@ -2373,22 +2086,21 @@ u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys,
2373 return error; 2086 return error;
2374} 2087}
2375 2088
2376u16 hpi_meter_set_peak_ballistics(const struct hpi_hsubsys *ph_subsys, 2089u16 hpi_meter_set_peak_ballistics(u32 h_control, u16 attack, u16 decay)
2377 u32 h_control, u16 attack, u16 decay)
2378{ 2090{
2379 return hpi_control_param_set(ph_subsys, h_control, 2091 return hpi_control_param_set(h_control, HPI_METER_PEAK_BALLISTICS,
2380 HPI_METER_PEAK_BALLISTICS, attack, decay); 2092 attack, decay);
2381} 2093}
2382 2094
2383u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys, 2095u16 hpi_meter_get_peak_ballistics(u32 h_control, u16 *pn_attack,
2384 u32 h_control, u16 *pn_attack, u16 *pn_decay) 2096 u16 *pn_decay)
2385{ 2097{
2386 u32 attack; 2098 u32 attack;
2387 u32 decay; 2099 u32 decay;
2388 u16 error; 2100 u16 error;
2389 2101
2390 error = hpi_control_param2_get(ph_subsys, h_control, 2102 error = hpi_control_param2_get(h_control, HPI_METER_PEAK_BALLISTICS,
2391 HPI_METER_PEAK_BALLISTICS, &attack, &decay); 2103 &attack, &decay);
2392 2104
2393 if (pn_attack) 2105 if (pn_attack)
2394 *pn_attack = (short)attack; 2106 *pn_attack = (short)attack;
@@ -2398,55 +2110,53 @@ u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys,
2398 return error; 2110 return error;
2399} 2111}
2400 2112
2401u16 hpi_microphone_set_phantom_power(const struct hpi_hsubsys *ph_subsys, 2113u16 hpi_microphone_set_phantom_power(u32 h_control, u16 on_off)
2402 u32 h_control, u16 on_off)
2403{ 2114{
2404 return hpi_control_param_set(ph_subsys, h_control, 2115 return hpi_control_param_set(h_control, HPI_MICROPHONE_PHANTOM_POWER,
2405 HPI_MICROPHONE_PHANTOM_POWER, (u32)on_off, 0); 2116 (u32)on_off, 0);
2406} 2117}
2407 2118
2408u16 hpi_microphone_get_phantom_power(const struct hpi_hsubsys *ph_subsys, 2119u16 hpi_microphone_get_phantom_power(u32 h_control, u16 *pw_on_off)
2409 u32 h_control, u16 *pw_on_off)
2410{ 2120{
2411 u16 error = 0; 2121 u16 error = 0;
2412 u32 on_off = 0; 2122 u32 on_off = 0;
2413 error = hpi_control_param1_get(ph_subsys, h_control, 2123 error = hpi_control_param1_get(h_control,
2414 HPI_MICROPHONE_PHANTOM_POWER, &on_off); 2124 HPI_MICROPHONE_PHANTOM_POWER, &on_off);
2415 if (pw_on_off) 2125 if (pw_on_off)
2416 *pw_on_off = (u16)on_off; 2126 *pw_on_off = (u16)on_off;
2417 return error; 2127 return error;
2418} 2128}
2419 2129
2420u16 hpi_multiplexer_set_source(const struct hpi_hsubsys *ph_subsys, 2130u16 hpi_multiplexer_set_source(u32 h_control, u16 source_node_type,
2421 u32 h_control, u16 source_node_type, u16 source_node_index) 2131 u16 source_node_index)
2422{ 2132{
2423 return hpi_control_param_set(ph_subsys, h_control, 2133 return hpi_control_param_set(h_control, HPI_MULTIPLEXER_SOURCE,
2424 HPI_MULTIPLEXER_SOURCE, source_node_type, source_node_index); 2134 source_node_type, source_node_index);
2425} 2135}
2426 2136
2427u16 hpi_multiplexer_get_source(const struct hpi_hsubsys *ph_subsys, 2137u16 hpi_multiplexer_get_source(u32 h_control, u16 *source_node_type,
2428 u32 h_control, u16 *source_node_type, u16 *source_node_index) 2138 u16 *source_node_index)
2429{ 2139{
2430 u32 node, index; 2140 u32 node, index;
2431 u16 error = hpi_control_param2_get(ph_subsys, h_control, 2141 u16 err = hpi_control_param2_get(h_control,
2432 HPI_MULTIPLEXER_SOURCE, &node, 2142 HPI_MULTIPLEXER_SOURCE, &node,
2433 &index); 2143 &index);
2434 if (source_node_type) 2144 if (source_node_type)
2435 *source_node_type = (u16)node; 2145 *source_node_type = (u16)node;
2436 if (source_node_index) 2146 if (source_node_index)
2437 *source_node_index = (u16)index; 2147 *source_node_index = (u16)index;
2438 return error; 2148 return err;
2439} 2149}
2440 2150
2441u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys, 2151u16 hpi_multiplexer_query_source(u32 h_control, u16 index,
2442 u32 h_control, u16 index, u16 *source_node_type, 2152 u16 *source_node_type, u16 *source_node_index)
2443 u16 *source_node_index)
2444{ 2153{
2445 struct hpi_message hm; 2154 struct hpi_message hm;
2446 struct hpi_response hr; 2155 struct hpi_response hr;
2447 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2156 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2448 HPI_CONTROL_GET_STATE); 2157 HPI_CONTROL_GET_STATE);
2449 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2158 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2159 return HPI_ERROR_INVALID_HANDLE;
2450 hm.u.c.attribute = HPI_MULTIPLEXER_QUERYSOURCE; 2160 hm.u.c.attribute = HPI_MULTIPLEXER_QUERYSOURCE;
2451 hm.u.c.param1 = index; 2161 hm.u.c.param1 = index;
2452 2162
@@ -2459,15 +2169,15 @@ u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys,
2459 return hr.error; 2169 return hr.error;
2460} 2170}
2461 2171
2462u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys, 2172u16 hpi_parametric_eq_get_info(u32 h_control, u16 *pw_number_of_bands,
2463 u32 h_control, u16 *pw_number_of_bands, u16 *pw_on_off) 2173 u16 *pw_on_off)
2464{ 2174{
2465 u32 oB = 0; 2175 u32 oB = 0;
2466 u32 oO = 0; 2176 u32 oO = 0;
2467 u16 error = 0; 2177 u16 error = 0;
2468 2178
2469 error = hpi_control_param2_get(ph_subsys, h_control, 2179 error = hpi_control_param2_get(h_control, HPI_EQUALIZER_NUM_FILTERS,
2470 HPI_EQUALIZER_NUM_FILTERS, &oO, &oB); 2180 &oO, &oB);
2471 if (pw_number_of_bands) 2181 if (pw_number_of_bands)
2472 *pw_number_of_bands = (u16)oB; 2182 *pw_number_of_bands = (u16)oB;
2473 if (pw_on_off) 2183 if (pw_on_off)
@@ -2475,23 +2185,22 @@ u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys,
2475 return error; 2185 return error;
2476} 2186}
2477 2187
2478u16 hpi_parametricEQ__set_state(const struct hpi_hsubsys *ph_subsys, 2188u16 hpi_parametric_eq_set_state(u32 h_control, u16 on_off)
2479 u32 h_control, u16 on_off)
2480{ 2189{
2481 return hpi_control_param_set(ph_subsys, h_control, 2190 return hpi_control_param_set(h_control, HPI_EQUALIZER_NUM_FILTERS,
2482 HPI_EQUALIZER_NUM_FILTERS, on_off, 0); 2191 on_off, 0);
2483} 2192}
2484 2193
2485u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys, 2194u16 hpi_parametric_eq_get_band(u32 h_control, u16 index, u16 *pn_type,
2486 u32 h_control, u16 index, u16 *pn_type, u32 *pfrequency_hz, 2195 u32 *pfrequency_hz, short *pnQ100, short *pn_gain0_01dB)
2487 short *pnQ100, short *pn_gain0_01dB)
2488{ 2196{
2489 struct hpi_message hm; 2197 struct hpi_message hm;
2490 struct hpi_response hr; 2198 struct hpi_response hr;
2491 2199
2492 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2200 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2493 HPI_CONTROL_GET_STATE); 2201 HPI_CONTROL_GET_STATE);
2494 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2202 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2203 return HPI_ERROR_INVALID_HANDLE;
2495 hm.u.c.attribute = HPI_EQUALIZER_FILTER; 2204 hm.u.c.attribute = HPI_EQUALIZER_FILTER;
2496 hm.u.c.param2 = index; 2205 hm.u.c.param2 = index;
2497 2206
@@ -2509,16 +2218,16 @@ u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys,
2509 return hr.error; 2218 return hr.error;
2510} 2219}
2511 2220
2512u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys, 2221u16 hpi_parametric_eq_set_band(u32 h_control, u16 index, u16 type,
2513 u32 h_control, u16 index, u16 type, u32 frequency_hz, short q100, 2222 u32 frequency_hz, short q100, short gain0_01dB)
2514 short gain0_01dB)
2515{ 2223{
2516 struct hpi_message hm; 2224 struct hpi_message hm;
2517 struct hpi_response hr; 2225 struct hpi_response hr;
2518 2226
2519 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2227 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2520 HPI_CONTROL_SET_STATE); 2228 HPI_CONTROL_SET_STATE);
2521 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2229 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2230 return HPI_ERROR_INVALID_HANDLE;
2522 2231
2523 hm.u.c.param1 = frequency_hz; 2232 hm.u.c.param1 = frequency_hz;
2524 hm.u.c.param2 = (index & 0xFFFFL) + ((u32)type << 16); 2233 hm.u.c.param2 = (index & 0xFFFFL) + ((u32)type << 16);
@@ -2531,8 +2240,7 @@ u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys,
2531 return hr.error; 2240 return hr.error;
2532} 2241}
2533 2242
2534u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys, 2243u16 hpi_parametric_eq_get_coeffs(u32 h_control, u16 index, short coeffs[5]
2535 u32 h_control, u16 index, short coeffs[5]
2536 ) 2244 )
2537{ 2245{
2538 struct hpi_message hm; 2246 struct hpi_message hm;
@@ -2540,7 +2248,8 @@ u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys,
2540 2248
2541 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2249 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2542 HPI_CONTROL_GET_STATE); 2250 HPI_CONTROL_GET_STATE);
2543 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2251 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2252 return HPI_ERROR_INVALID_HANDLE;
2544 hm.u.c.attribute = HPI_EQUALIZER_COEFFICIENTS; 2253 hm.u.c.attribute = HPI_EQUALIZER_COEFFICIENTS;
2545 hm.u.c.param2 = index; 2254 hm.u.c.param2 = index;
2546 2255
@@ -2555,444 +2264,388 @@ u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys,
2555 return hr.error; 2264 return hr.error;
2556} 2265}
2557 2266
2558u16 hpi_sample_clock_query_source(const struct hpi_hsubsys *ph_subsys, 2267u16 hpi_sample_clock_query_source(const u32 h_clock, const u32 index,
2559 const u32 h_clock, const u32 index, u16 *pw_source) 2268 u16 *pw_source)
2560{ 2269{
2561 u32 qr; 2270 u32 qr;
2562 u16 err; 2271 u16 err;
2563 2272
2564 err = hpi_control_query(ph_subsys, h_clock, HPI_SAMPLECLOCK_SOURCE, 2273 err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE, index, 0,
2565 index, 0, &qr); 2274 &qr);
2566 *pw_source = (u16)qr; 2275 *pw_source = (u16)qr;
2567 return err; 2276 return err;
2568} 2277}
2569 2278
2570u16 hpi_sample_clock_set_source(const struct hpi_hsubsys *ph_subsys, 2279u16 hpi_sample_clock_set_source(u32 h_control, u16 source)
2571 u32 h_control, u16 source)
2572{ 2280{
2573 return hpi_control_param_set(ph_subsys, h_control, 2281 return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE,
2574 HPI_SAMPLECLOCK_SOURCE, source, 0); 2282 source, 0);
2575} 2283}
2576 2284
2577u16 hpi_sample_clock_get_source(const struct hpi_hsubsys *ph_subsys, 2285u16 hpi_sample_clock_get_source(u32 h_control, u16 *pw_source)
2578 u32 h_control, u16 *pw_source)
2579{ 2286{
2580 u16 error = 0; 2287 u16 err = 0;
2581 u32 source = 0; 2288 u32 source = 0;
2582 error = hpi_control_param1_get(ph_subsys, h_control, 2289 err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE,
2583 HPI_SAMPLECLOCK_SOURCE, &source); 2290 &source);
2584 if (!error) 2291 if (!err)
2585 if (pw_source) 2292 if (pw_source)
2586 *pw_source = (u16)source; 2293 *pw_source = (u16)source;
2587 return error; 2294 return err;
2588} 2295}
2589 2296
2590u16 hpi_sample_clock_query_source_index(const struct hpi_hsubsys *ph_subsys, 2297u16 hpi_sample_clock_query_source_index(const u32 h_clock, const u32 index,
2591 const u32 h_clock, const u32 index, const u32 source, 2298 const u32 source, u16 *pw_source_index)
2592 u16 *pw_source_index)
2593{ 2299{
2594 u32 qr; 2300 u32 qr;
2595 u16 err; 2301 u16 err;
2596 2302
2597 err = hpi_control_query(ph_subsys, h_clock, 2303 err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE_INDEX, index,
2598 HPI_SAMPLECLOCK_SOURCE_INDEX, index, source, &qr); 2304 source, &qr);
2599 *pw_source_index = (u16)qr; 2305 *pw_source_index = (u16)qr;
2600 return err; 2306 return err;
2601} 2307}
2602 2308
2603u16 hpi_sample_clock_set_source_index(const struct hpi_hsubsys *ph_subsys, 2309u16 hpi_sample_clock_set_source_index(u32 h_control, u16 source_index)
2604 u32 h_control, u16 source_index)
2605{ 2310{
2606 return hpi_control_param_set(ph_subsys, h_control, 2311 return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
2607 HPI_SAMPLECLOCK_SOURCE_INDEX, source_index, 0); 2312 source_index, 0);
2608} 2313}
2609 2314
2610u16 hpi_sample_clock_get_source_index(const struct hpi_hsubsys *ph_subsys, 2315u16 hpi_sample_clock_get_source_index(u32 h_control, u16 *pw_source_index)
2611 u32 h_control, u16 *pw_source_index)
2612{ 2316{
2613 u16 error = 0; 2317 u16 err = 0;
2614 u32 source_index = 0; 2318 u32 source_index = 0;
2615 error = hpi_control_param1_get(ph_subsys, h_control, 2319 err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
2616 HPI_SAMPLECLOCK_SOURCE_INDEX, &source_index); 2320 &source_index);
2617 if (!error) 2321 if (!err)
2618 if (pw_source_index) 2322 if (pw_source_index)
2619 *pw_source_index = (u16)source_index; 2323 *pw_source_index = (u16)source_index;
2620 return error; 2324 return err;
2621} 2325}
2622 2326
2623u16 hpi_sample_clock_query_local_rate(const struct hpi_hsubsys *ph_subsys, 2327u16 hpi_sample_clock_query_local_rate(const u32 h_clock, const u32 index,
2624 const u32 h_clock, const u32 index, u32 *prate) 2328 u32 *prate)
2625{ 2329{
2626 u16 err; 2330 u16 err;
2627 err = hpi_control_query(ph_subsys, h_clock, 2331 err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_LOCAL_SAMPLERATE,
2628 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, index, 0, prate); 2332 index, 0, prate);
2629 2333
2630 return err; 2334 return err;
2631} 2335}
2632 2336
2633u16 hpi_sample_clock_set_local_rate(const struct hpi_hsubsys *ph_subsys, 2337u16 hpi_sample_clock_set_local_rate(u32 h_control, u32 sample_rate)
2634 u32 h_control, u32 sample_rate)
2635{ 2338{
2636 return hpi_control_param_set(ph_subsys, h_control, 2339 return hpi_control_param_set(h_control,
2637 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, sample_rate, 0); 2340 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, sample_rate, 0);
2638} 2341}
2639 2342
2640u16 hpi_sample_clock_get_local_rate(const struct hpi_hsubsys *ph_subsys, 2343u16 hpi_sample_clock_get_local_rate(u32 h_control, u32 *psample_rate)
2641 u32 h_control, u32 *psample_rate)
2642{ 2344{
2643 u16 error = 0; 2345 u16 err = 0;
2644 u32 sample_rate = 0; 2346 u32 sample_rate = 0;
2645 error = hpi_control_param1_get(ph_subsys, h_control, 2347 err = hpi_control_param1_get(h_control,
2646 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate); 2348 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate);
2647 if (!error) 2349 if (!err)
2648 if (psample_rate) 2350 if (psample_rate)
2649 *psample_rate = sample_rate; 2351 *psample_rate = sample_rate;
2650 return error; 2352 return err;
2651} 2353}
2652 2354
2653u16 hpi_sample_clock_get_sample_rate(const struct hpi_hsubsys *ph_subsys, 2355u16 hpi_sample_clock_get_sample_rate(u32 h_control, u32 *psample_rate)
2654 u32 h_control, u32 *psample_rate)
2655{ 2356{
2656 u16 error = 0; 2357 u16 err = 0;
2657 u32 sample_rate = 0; 2358 u32 sample_rate = 0;
2658 error = hpi_control_param1_get(ph_subsys, h_control, 2359 err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SAMPLERATE,
2659 HPI_SAMPLECLOCK_SAMPLERATE, &sample_rate); 2360 &sample_rate);
2660 if (!error) 2361 if (!err)
2661 if (psample_rate) 2362 if (psample_rate)
2662 *psample_rate = sample_rate; 2363 *psample_rate = sample_rate;
2663 return error; 2364 return err;
2664} 2365}
2665 2366
2666u16 hpi_sample_clock_set_auto(const struct hpi_hsubsys *ph_subsys, 2367u16 hpi_sample_clock_set_auto(u32 h_control, u32 enable)
2667 u32 h_control, u32 enable)
2668{ 2368{
2669 return hpi_control_param_set(ph_subsys, h_control, 2369 return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_AUTO, enable,
2670 HPI_SAMPLECLOCK_AUTO, enable, 0); 2370 0);
2671} 2371}
2672 2372
2673u16 hpi_sample_clock_get_auto(const struct hpi_hsubsys *ph_subsys, 2373u16 hpi_sample_clock_get_auto(u32 h_control, u32 *penable)
2674 u32 h_control, u32 *penable)
2675{ 2374{
2676 return hpi_control_param1_get(ph_subsys, h_control, 2375 return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_AUTO,
2677 HPI_SAMPLECLOCK_AUTO, penable); 2376 penable);
2678} 2377}
2679 2378
2680u16 hpi_sample_clock_set_local_rate_lock(const struct hpi_hsubsys *ph_subsys, 2379u16 hpi_sample_clock_set_local_rate_lock(u32 h_control, u32 lock)
2681 u32 h_control, u32 lock)
2682{ 2380{
2683 return hpi_control_param_set(ph_subsys, h_control, 2381 return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
2684 HPI_SAMPLECLOCK_LOCAL_LOCK, lock, 0); 2382 lock, 0);
2685} 2383}
2686 2384
2687u16 hpi_sample_clock_get_local_rate_lock(const struct hpi_hsubsys *ph_subsys, 2385u16 hpi_sample_clock_get_local_rate_lock(u32 h_control, u32 *plock)
2688 u32 h_control, u32 *plock)
2689{ 2386{
2690 return hpi_control_param1_get(ph_subsys, h_control, 2387 return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
2691 HPI_SAMPLECLOCK_LOCAL_LOCK, plock); 2388 plock);
2692} 2389}
2693 2390
2694u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys, 2391u16 hpi_tone_detector_get_frequency(u32 h_control, u32 index, u32 *frequency)
2695 u32 h_control, u32 index, u32 *frequency)
2696{ 2392{
2697 return hpi_control_param_get(ph_subsys, h_control, 2393 return hpi_control_param_get(h_control, HPI_TONEDETECTOR_FREQUENCY,
2698 HPI_TONEDETECTOR_FREQUENCY, index, 0, frequency, NULL); 2394 index, 0, frequency, NULL);
2699} 2395}
2700 2396
2701u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys, 2397u16 hpi_tone_detector_get_state(u32 h_control, u32 *state)
2702 u32 h_control, u32 *state)
2703{ 2398{
2704 return hpi_control_param1_get(ph_subsys, h_control, 2399 return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_STATE,
2705 HPI_TONEDETECTOR_STATE, state); 2400 state);
2706} 2401}
2707 2402
2708u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys, 2403u16 hpi_tone_detector_set_enable(u32 h_control, u32 enable)
2709 u32 h_control, u32 enable)
2710{ 2404{
2711 return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2405 return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
2712 (u32)enable, 0); 2406 0);
2713} 2407}
2714 2408
2715u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 2409u16 hpi_tone_detector_get_enable(u32 h_control, u32 *enable)
2716 u32 h_control, u32 *enable)
2717{ 2410{
2718 return hpi_control_param1_get(ph_subsys, h_control, 2411 return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
2719 HPI_GENERIC_ENABLE, enable);
2720} 2412}
2721 2413
2722u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, 2414u16 hpi_tone_detector_set_event_enable(u32 h_control, u32 event_enable)
2723 u32 h_control, u32 event_enable)
2724{ 2415{
2725 return hpi_control_param_set(ph_subsys, h_control, 2416 return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
2726 HPI_GENERIC_EVENT_ENABLE, (u32)event_enable, 0); 2417 (u32)event_enable, 0);
2727} 2418}
2728 2419
2729u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, 2420u16 hpi_tone_detector_get_event_enable(u32 h_control, u32 *event_enable)
2730 u32 h_control, u32 *event_enable)
2731{ 2421{
2732 return hpi_control_param1_get(ph_subsys, h_control, 2422 return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
2733 HPI_GENERIC_EVENT_ENABLE, event_enable); 2423 event_enable);
2734} 2424}
2735 2425
2736u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, 2426u16 hpi_tone_detector_set_threshold(u32 h_control, int threshold)
2737 u32 h_control, int threshold)
2738{ 2427{
2739 return hpi_control_param_set(ph_subsys, h_control, 2428 return hpi_control_param_set(h_control, HPI_TONEDETECTOR_THRESHOLD,
2740 HPI_TONEDETECTOR_THRESHOLD, (u32)threshold, 0); 2429 (u32)threshold, 0);
2741} 2430}
2742 2431
2743u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, 2432u16 hpi_tone_detector_get_threshold(u32 h_control, int *threshold)
2744 u32 h_control, int *threshold)
2745{ 2433{
2746 return hpi_control_param1_get(ph_subsys, h_control, 2434 return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_THRESHOLD,
2747 HPI_TONEDETECTOR_THRESHOLD, (u32 *)threshold); 2435 (u32 *)threshold);
2748} 2436}
2749 2437
2750u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys, 2438u16 hpi_silence_detector_get_state(u32 h_control, u32 *state)
2751 u32 h_control, u32 *state)
2752{ 2439{
2753 return hpi_control_param1_get(ph_subsys, h_control, 2440 return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_STATE,
2754 HPI_SILENCEDETECTOR_STATE, state); 2441 state);
2755} 2442}
2756 2443
2757u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys, 2444u16 hpi_silence_detector_set_enable(u32 h_control, u32 enable)
2758 u32 h_control, u32 enable)
2759{ 2445{
2760 return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2446 return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
2761 (u32)enable, 0); 2447 0);
2762} 2448}
2763 2449
2764u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 2450u16 hpi_silence_detector_get_enable(u32 h_control, u32 *enable)
2765 u32 h_control, u32 *enable)
2766{ 2451{
2767 return hpi_control_param1_get(ph_subsys, h_control, 2452 return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
2768 HPI_GENERIC_ENABLE, enable);
2769} 2453}
2770 2454
2771u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, 2455u16 hpi_silence_detector_set_event_enable(u32 h_control, u32 event_enable)
2772 u32 h_control, u32 event_enable)
2773{ 2456{
2774 return hpi_control_param_set(ph_subsys, h_control, 2457 return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
2775 HPI_GENERIC_EVENT_ENABLE, event_enable, 0); 2458 event_enable, 0);
2776} 2459}
2777 2460
2778u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, 2461u16 hpi_silence_detector_get_event_enable(u32 h_control, u32 *event_enable)
2779 u32 h_control, u32 *event_enable)
2780{ 2462{
2781 return hpi_control_param1_get(ph_subsys, h_control, 2463 return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
2782 HPI_GENERIC_EVENT_ENABLE, event_enable); 2464 event_enable);
2783} 2465}
2784 2466
2785u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys, 2467u16 hpi_silence_detector_set_delay(u32 h_control, u32 delay)
2786 u32 h_control, u32 delay)
2787{ 2468{
2788 return hpi_control_param_set(ph_subsys, h_control, 2469 return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_DELAY,
2789 HPI_SILENCEDETECTOR_DELAY, delay, 0); 2470 delay, 0);
2790} 2471}
2791 2472
2792u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys, 2473u16 hpi_silence_detector_get_delay(u32 h_control, u32 *delay)
2793 u32 h_control, u32 *delay)
2794{ 2474{
2795 return hpi_control_param1_get(ph_subsys, h_control, 2475 return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_DELAY,
2796 HPI_SILENCEDETECTOR_DELAY, delay); 2476 delay);
2797} 2477}
2798 2478
2799u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, 2479u16 hpi_silence_detector_set_threshold(u32 h_control, int threshold)
2800 u32 h_control, int threshold)
2801{ 2480{
2802 return hpi_control_param_set(ph_subsys, h_control, 2481 return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_THRESHOLD,
2803 HPI_SILENCEDETECTOR_THRESHOLD, threshold, 0); 2482 threshold, 0);
2804} 2483}
2805 2484
2806u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, 2485u16 hpi_silence_detector_get_threshold(u32 h_control, int *threshold)
2807 u32 h_control, int *threshold)
2808{ 2486{
2809 return hpi_control_param1_get(ph_subsys, h_control, 2487 return hpi_control_param1_get(h_control,
2810 HPI_SILENCEDETECTOR_THRESHOLD, (u32 *)threshold); 2488 HPI_SILENCEDETECTOR_THRESHOLD, (u32 *)threshold);
2811} 2489}
2812 2490
2813u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys, 2491u16 hpi_tuner_query_band(const u32 h_tuner, const u32 index, u16 *pw_band)
2814 const u32 h_tuner, const u32 index, u16 *pw_band)
2815{ 2492{
2816 u32 qr; 2493 u32 qr;
2817 u16 err; 2494 u16 err;
2818 2495
2819 err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0, 2496 err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
2820 &qr);
2821 *pw_band = (u16)qr; 2497 *pw_band = (u16)qr;
2822 return err; 2498 return err;
2823} 2499}
2824 2500
2825u16 hpi_tuner_set_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2501u16 hpi_tuner_set_band(u32 h_control, u16 band)
2826 u16 band)
2827{ 2502{
2828 return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_BAND, 2503 return hpi_control_param_set(h_control, HPI_TUNER_BAND, band, 0);
2829 band, 0);
2830} 2504}
2831 2505
2832u16 hpi_tuner_get_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2506u16 hpi_tuner_get_band(u32 h_control, u16 *pw_band)
2833 u16 *pw_band)
2834{ 2507{
2835 u32 band = 0; 2508 u32 band = 0;
2836 u16 error = 0; 2509 u16 error = 0;
2837 2510
2838 error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_BAND, 2511 error = hpi_control_param1_get(h_control, HPI_TUNER_BAND, &band);
2839 &band);
2840 if (pw_band) 2512 if (pw_band)
2841 *pw_band = (u16)band; 2513 *pw_band = (u16)band;
2842 return error; 2514 return error;
2843} 2515}
2844 2516
2845u16 hpi_tuner_query_frequency(const struct hpi_hsubsys *ph_subsys, 2517u16 hpi_tuner_query_frequency(const u32 h_tuner, const u32 index,
2846 const u32 h_tuner, const u32 index, const u16 band, u32 *pfreq) 2518 const u16 band, u32 *pfreq)
2847{ 2519{
2848 return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_FREQ, index, 2520 return hpi_control_query(h_tuner, HPI_TUNER_FREQ, index, band, pfreq);
2849 band, pfreq);
2850} 2521}
2851 2522
2852u16 hpi_tuner_set_frequency(const struct hpi_hsubsys *ph_subsys, 2523u16 hpi_tuner_set_frequency(u32 h_control, u32 freq_ink_hz)
2853 u32 h_control, u32 freq_ink_hz)
2854{ 2524{
2855 return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_FREQ, 2525 return hpi_control_param_set(h_control, HPI_TUNER_FREQ, freq_ink_hz,
2856 freq_ink_hz, 0); 2526 0);
2857} 2527}
2858 2528
2859u16 hpi_tuner_get_frequency(const struct hpi_hsubsys *ph_subsys, 2529u16 hpi_tuner_get_frequency(u32 h_control, u32 *pw_freq_ink_hz)
2860 u32 h_control, u32 *pw_freq_ink_hz)
2861{ 2530{
2862 return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_FREQ, 2531 return hpi_control_param1_get(h_control, HPI_TUNER_FREQ,
2863 pw_freq_ink_hz); 2532 pw_freq_ink_hz);
2864} 2533}
2865 2534
2866u16 hpi_tuner_query_gain(const struct hpi_hsubsys *ph_subsys, 2535u16 hpi_tuner_query_gain(const u32 h_tuner, const u32 index, u16 *pw_gain)
2867 const u32 h_tuner, const u32 index, u16 *pw_gain)
2868{ 2536{
2869 u32 qr; 2537 u32 qr;
2870 u16 err; 2538 u16 err;
2871 2539
2872 err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0, 2540 err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
2873 &qr);
2874 *pw_gain = (u16)qr; 2541 *pw_gain = (u16)qr;
2875 return err; 2542 return err;
2876} 2543}
2877 2544
2878u16 hpi_tuner_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2545u16 hpi_tuner_set_gain(u32 h_control, short gain)
2879 short gain)
2880{ 2546{
2881 return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_GAIN, 2547 return hpi_control_param_set(h_control, HPI_TUNER_GAIN, gain, 0);
2882 gain, 0);
2883} 2548}
2884 2549
2885u16 hpi_tuner_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2550u16 hpi_tuner_get_gain(u32 h_control, short *pn_gain)
2886 short *pn_gain)
2887{ 2551{
2888 u32 gain = 0; 2552 u32 gain = 0;
2889 u16 error = 0; 2553 u16 error = 0;
2890 2554
2891 error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_GAIN, 2555 error = hpi_control_param1_get(h_control, HPI_TUNER_GAIN, &gain);
2892 &gain);
2893 if (pn_gain) 2556 if (pn_gain)
2894 *pn_gain = (u16)gain; 2557 *pn_gain = (u16)gain;
2895 return error; 2558 return error;
2896} 2559}
2897 2560
2898u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2561u16 hpi_tuner_get_rf_level(u32 h_control, short *pw_level)
2899 short *pw_level)
2900{ 2562{
2901 struct hpi_message hm; 2563 struct hpi_message hm;
2902 struct hpi_response hr; 2564 struct hpi_response hr;
2903 2565
2904 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2566 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2905 HPI_CONTROL_GET_STATE); 2567 HPI_CONTROL_GET_STATE);
2906 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2568 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2907 hm.u.c.attribute = HPI_TUNER_LEVEL; 2569 return HPI_ERROR_INVALID_HANDLE;
2908 hm.u.c.param1 = HPI_TUNER_LEVEL_AVERAGE; 2570 hm.u.cu.attribute = HPI_TUNER_LEVEL_AVG;
2909 hpi_send_recv(&hm, &hr); 2571 hpi_send_recv(&hm, &hr);
2910 if (pw_level) 2572 if (pw_level)
2911 *pw_level = (short)hr.u.c.param1; 2573 *pw_level = hr.u.cu.tuner.s_level;
2912 return hr.error; 2574 return hr.error;
2913} 2575}
2914 2576
2915u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys, 2577u16 hpi_tuner_get_raw_rf_level(u32 h_control, short *pw_level)
2916 u32 h_control, short *pw_level)
2917{ 2578{
2918 struct hpi_message hm; 2579 struct hpi_message hm;
2919 struct hpi_response hr; 2580 struct hpi_response hr;
2920 2581
2921 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2582 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2922 HPI_CONTROL_GET_STATE); 2583 HPI_CONTROL_GET_STATE);
2923 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2584 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2924 hm.u.c.attribute = HPI_TUNER_LEVEL; 2585 return HPI_ERROR_INVALID_HANDLE;
2925 hm.u.c.param1 = HPI_TUNER_LEVEL_RAW; 2586 hm.u.cu.attribute = HPI_TUNER_LEVEL_RAW;
2926 hpi_send_recv(&hm, &hr); 2587 hpi_send_recv(&hm, &hr);
2927 if (pw_level) 2588 if (pw_level)
2928 *pw_level = (short)hr.u.c.param1; 2589 *pw_level = hr.u.cu.tuner.s_level;
2929 return hr.error; 2590 return hr.error;
2930} 2591}
2931 2592
2932u16 hpi_tuner_query_deemphasis(const struct hpi_hsubsys *ph_subsys, 2593u16 hpi_tuner_query_deemphasis(const u32 h_tuner, const u32 index,
2933 const u32 h_tuner, const u32 index, const u16 band, u32 *pdeemphasis) 2594 const u16 band, u32 *pdeemphasis)
2934{ 2595{
2935 return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_DEEMPHASIS, 2596 return hpi_control_query(h_tuner, HPI_TUNER_DEEMPHASIS, index, band,
2936 index, band, pdeemphasis); 2597 pdeemphasis);
2937} 2598}
2938 2599
2939u16 hpi_tuner_set_deemphasis(const struct hpi_hsubsys *ph_subsys, 2600u16 hpi_tuner_set_deemphasis(u32 h_control, u32 deemphasis)
2940 u32 h_control, u32 deemphasis)
2941{ 2601{
2942 return hpi_control_param_set(ph_subsys, h_control, 2602 return hpi_control_param_set(h_control, HPI_TUNER_DEEMPHASIS,
2943 HPI_TUNER_DEEMPHASIS, deemphasis, 0); 2603 deemphasis, 0);
2944} 2604}
2945 2605
2946u16 hpi_tuner_get_deemphasis(const struct hpi_hsubsys *ph_subsys, 2606u16 hpi_tuner_get_deemphasis(u32 h_control, u32 *pdeemphasis)
2947 u32 h_control, u32 *pdeemphasis)
2948{ 2607{
2949 return hpi_control_param1_get(ph_subsys, h_control, 2608 return hpi_control_param1_get(h_control, HPI_TUNER_DEEMPHASIS,
2950 HPI_TUNER_DEEMPHASIS, pdeemphasis); 2609 pdeemphasis);
2951} 2610}
2952 2611
2953u16 hpi_tuner_query_program(const struct hpi_hsubsys *ph_subsys, 2612u16 hpi_tuner_query_program(const u32 h_tuner, u32 *pbitmap_program)
2954 const u32 h_tuner, u32 *pbitmap_program)
2955{ 2613{
2956 return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_PROGRAM, 0, 0, 2614 return hpi_control_query(h_tuner, HPI_TUNER_PROGRAM, 0, 0,
2957 pbitmap_program); 2615 pbitmap_program);
2958} 2616}
2959 2617
2960u16 hpi_tuner_set_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2618u16 hpi_tuner_set_program(u32 h_control, u32 program)
2961 u32 program)
2962{ 2619{
2963 return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_PROGRAM, 2620 return hpi_control_param_set(h_control, HPI_TUNER_PROGRAM, program,
2964 program, 0); 2621 0);
2965} 2622}
2966 2623
2967u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2624u16 hpi_tuner_get_program(u32 h_control, u32 *pprogram)
2968 u32 *pprogram)
2969{ 2625{
2970 return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_PROGRAM, 2626 return hpi_control_param1_get(h_control, HPI_TUNER_PROGRAM, pprogram);
2971 pprogram);
2972} 2627}
2973 2628
2974u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys, 2629u16 hpi_tuner_get_hd_radio_dsp_version(u32 h_control, char *psz_dsp_version,
2975 u32 h_control, char *psz_dsp_version, const u32 string_size) 2630 const u32 string_size)
2976{ 2631{
2977 return hpi_control_get_string(h_control, 2632 return hpi_control_get_string(h_control,
2978 HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size); 2633 HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size);
2979} 2634}
2980 2635
2981u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys, 2636u16 hpi_tuner_get_hd_radio_sdk_version(u32 h_control, char *psz_sdk_version,
2982 u32 h_control, char *psz_sdk_version, const u32 string_size) 2637 const u32 string_size)
2983{ 2638{
2984 return hpi_control_get_string(h_control, 2639 return hpi_control_get_string(h_control,
2985 HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size); 2640 HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size);
2986} 2641}
2987 2642
2988u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2643u16 hpi_tuner_get_status(u32 h_control, u16 *pw_status_mask, u16 *pw_status)
2989 u16 *pw_status_mask, u16 *pw_status)
2990{ 2644{
2991 u32 status = 0; 2645 u32 status = 0;
2992 u16 error = 0; 2646 u16 error = 0;
2993 2647
2994 error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_STATUS, 2648 error = hpi_control_param1_get(h_control, HPI_TUNER_STATUS, &status);
2995 &status);
2996 if (pw_status) { 2649 if (pw_status) {
2997 if (!error) { 2650 if (!error) {
2998 *pw_status_mask = (u16)(status >> 16); 2651 *pw_status_mask = (u16)(status >> 16);
@@ -3005,50 +2658,44 @@ u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3005 return error; 2658 return error;
3006} 2659}
3007 2660
3008u16 hpi_tuner_set_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2661u16 hpi_tuner_set_mode(u32 h_control, u32 mode, u32 value)
3009 u32 mode, u32 value)
3010{ 2662{
3011 return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_MODE, 2663 return hpi_control_param_set(h_control, HPI_TUNER_MODE, mode, value);
3012 mode, value);
3013} 2664}
3014 2665
3015u16 hpi_tuner_get_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2666u16 hpi_tuner_get_mode(u32 h_control, u32 mode, u32 *pn_value)
3016 u32 mode, u32 *pn_value)
3017{ 2667{
3018 return hpi_control_param_get(ph_subsys, h_control, HPI_TUNER_MODE, 2668 return hpi_control_param_get(h_control, HPI_TUNER_MODE, mode, 0,
3019 mode, 0, pn_value, NULL); 2669 pn_value, NULL);
3020} 2670}
3021 2671
3022u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys, 2672u16 hpi_tuner_get_hd_radio_signal_quality(u32 h_control, u32 *pquality)
3023 u32 h_control, u32 *pquality)
3024{ 2673{
3025 return hpi_control_param1_get(ph_subsys, h_control, 2674 return hpi_control_param1_get(h_control,
3026 HPI_TUNER_HDRADIO_SIGNAL_QUALITY, pquality); 2675 HPI_TUNER_HDRADIO_SIGNAL_QUALITY, pquality);
3027} 2676}
3028 2677
3029u16 hpi_tuner_get_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys, 2678u16 hpi_tuner_get_hd_radio_signal_blend(u32 h_control, u32 *pblend)
3030 u32 h_control, u32 *pblend)
3031{ 2679{
3032 return hpi_control_param1_get(ph_subsys, h_control, 2680 return hpi_control_param1_get(h_control, HPI_TUNER_HDRADIO_BLEND,
3033 HPI_TUNER_HDRADIO_BLEND, pblend); 2681 pblend);
3034} 2682}
3035 2683
3036u16 hpi_tuner_set_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys, 2684u16 hpi_tuner_set_hd_radio_signal_blend(u32 h_control, const u32 blend)
3037 u32 h_control, const u32 blend)
3038{ 2685{
3039 return hpi_control_param_set(ph_subsys, h_control, 2686 return hpi_control_param_set(h_control, HPI_TUNER_HDRADIO_BLEND,
3040 HPI_TUNER_HDRADIO_BLEND, blend, 0); 2687 blend, 0);
3041} 2688}
3042 2689
3043u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2690u16 hpi_tuner_get_rds(u32 h_control, char *p_data)
3044 char *p_data)
3045{ 2691{
3046 struct hpi_message hm; 2692 struct hpi_message hm;
3047 struct hpi_response hr; 2693 struct hpi_response hr;
3048 2694
3049 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2695 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3050 HPI_CONTROL_GET_STATE); 2696 HPI_CONTROL_GET_STATE);
3051 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2697 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2698 return HPI_ERROR_INVALID_HANDLE;
3052 hm.u.c.attribute = HPI_TUNER_RDS; 2699 hm.u.c.attribute = HPI_TUNER_RDS;
3053 hpi_send_recv(&hm, &hr); 2700 hpi_send_recv(&hm, &hr);
3054 if (p_data) { 2701 if (p_data) {
@@ -3059,80 +2706,82 @@ u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3059 return hr.error; 2706 return hr.error;
3060} 2707}
3061 2708
3062u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys, 2709u16 hpi_pad_get_channel_name(u32 h_control, char *psz_string,
3063 u32 h_control, char *psz_string, const u32 data_length) 2710 const u32 data_length)
3064{ 2711{
3065 return hpi_control_get_string(h_control, HPI_PAD_CHANNEL_NAME, 2712 return hpi_control_get_string(h_control, HPI_PAD_CHANNEL_NAME,
3066 psz_string, data_length); 2713 psz_string, data_length);
3067} 2714}
3068 2715
3069u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2716u16 hpi_pad_get_artist(u32 h_control, char *psz_string, const u32 data_length)
3070 char *psz_string, const u32 data_length)
3071{ 2717{
3072 return hpi_control_get_string(h_control, HPI_PAD_ARTIST, psz_string, 2718 return hpi_control_get_string(h_control, HPI_PAD_ARTIST, psz_string,
3073 data_length); 2719 data_length);
3074} 2720}
3075 2721
3076u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2722u16 hpi_pad_get_title(u32 h_control, char *psz_string, const u32 data_length)
3077 char *psz_string, const u32 data_length)
3078{ 2723{
3079 return hpi_control_get_string(h_control, HPI_PAD_TITLE, psz_string, 2724 return hpi_control_get_string(h_control, HPI_PAD_TITLE, psz_string,
3080 data_length); 2725 data_length);
3081} 2726}
3082 2727
3083u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2728u16 hpi_pad_get_comment(u32 h_control, char *psz_string,
3084 char *psz_string, const u32 data_length) 2729 const u32 data_length)
3085{ 2730{
3086 return hpi_control_get_string(h_control, HPI_PAD_COMMENT, psz_string, 2731 return hpi_control_get_string(h_control, HPI_PAD_COMMENT, psz_string,
3087 data_length); 2732 data_length);
3088} 2733}
3089 2734
3090u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys, 2735u16 hpi_pad_get_program_type(u32 h_control, u32 *ppTY)
3091 u32 h_control, u32 *ppTY)
3092{ 2736{
3093 return hpi_control_param1_get(ph_subsys, h_control, 2737 return hpi_control_param1_get(h_control, HPI_PAD_PROGRAM_TYPE, ppTY);
3094 HPI_PAD_PROGRAM_TYPE, ppTY);
3095} 2738}
3096 2739
3097u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2740u16 hpi_pad_get_rdsPI(u32 h_control, u32 *ppI)
3098 u32 *ppI)
3099{ 2741{
3100 return hpi_control_param1_get(ph_subsys, h_control, 2742 return hpi_control_param1_get(h_control, HPI_PAD_PROGRAM_ID, ppI);
3101 HPI_PAD_PROGRAM_ID, ppI);
3102} 2743}
3103 2744
3104u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys, 2745u16 hpi_volume_query_channels(const u32 h_volume, u32 *p_channels)
3105 const u32 h_volume, u32 *p_channels)
3106{ 2746{
3107 return hpi_control_query(ph_subsys, h_volume, HPI_VOLUME_NUM_CHANNELS, 2747 return hpi_control_query(h_volume, HPI_VOLUME_NUM_CHANNELS, 0, 0,
3108 0, 0, p_channels); 2748 p_channels);
3109} 2749}
3110 2750
3111u16 hpi_volume_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2751u16 hpi_volume_set_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS]
3112 short an_log_gain[HPI_MAX_CHANNELS]
3113 ) 2752 )
3114{ 2753{
3115 return hpi_control_log_set2(h_control, HPI_VOLUME_GAIN, 2754 return hpi_control_log_set2(h_control, HPI_VOLUME_GAIN,
3116 an_log_gain[0], an_log_gain[1]); 2755 an_log_gain[0], an_log_gain[1]);
3117} 2756}
3118 2757
3119u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2758u16 hpi_volume_get_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS]
3120 short an_log_gain[HPI_MAX_CHANNELS]
3121 ) 2759 )
3122{ 2760{
3123 return hpi_control_log_get2(ph_subsys, h_control, HPI_VOLUME_GAIN, 2761 return hpi_control_log_get2(h_control, HPI_VOLUME_GAIN,
3124 &an_log_gain[0], &an_log_gain[1]); 2762 &an_log_gain[0], &an_log_gain[1]);
3125} 2763}
3126 2764
3127u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2765u16 hpi_volume_set_mute(u32 h_control, u32 mute)
3128 short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB) 2766{
2767 return hpi_control_param_set(h_control, HPI_VOLUME_MUTE, mute, 0);
2768}
2769
2770u16 hpi_volume_get_mute(u32 h_control, u32 *mute)
2771{
2772 return hpi_control_param1_get(h_control, HPI_VOLUME_MUTE, mute);
2773}
2774
2775u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB,
2776 short *max_gain_01dB, short *step_gain_01dB)
3129{ 2777{
3130 struct hpi_message hm; 2778 struct hpi_message hm;
3131 struct hpi_response hr; 2779 struct hpi_response hr;
3132 2780
3133 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2781 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3134 HPI_CONTROL_GET_STATE); 2782 HPI_CONTROL_GET_STATE);
3135 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2783 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2784 return HPI_ERROR_INVALID_HANDLE;
3136 hm.u.c.attribute = HPI_VOLUME_RANGE; 2785 hm.u.c.attribute = HPI_VOLUME_RANGE;
3137 2786
3138 hpi_send_recv(&hm, &hr); 2787 hpi_send_recv(&hm, &hr);
@@ -3150,16 +2799,17 @@ u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3150 return hr.error; 2799 return hr.error;
3151} 2800}
3152 2801
3153u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys, 2802u16 hpi_volume_auto_fade_profile(u32 h_control,
3154 u32 h_control, short an_stop_gain0_01dB[HPI_MAX_CHANNELS], 2803 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms,
3155 u32 duration_ms, u16 profile) 2804 u16 profile)
3156{ 2805{
3157 struct hpi_message hm; 2806 struct hpi_message hm;
3158 struct hpi_response hr; 2807 struct hpi_response hr;
3159 2808
3160 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2809 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3161 HPI_CONTROL_SET_STATE); 2810 HPI_CONTROL_SET_STATE);
3162 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2811 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2812 return HPI_ERROR_INVALID_HANDLE;
3163 2813
3164 memcpy(hm.u.c.an_log_value, an_stop_gain0_01dB, 2814 memcpy(hm.u.c.an_log_value, an_stop_gain0_01dB,
3165 sizeof(short) * HPI_MAX_CHANNELS); 2815 sizeof(short) * HPI_MAX_CHANNELS);
@@ -3173,21 +2823,21 @@ u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys,
3173 return hr.error; 2823 return hr.error;
3174} 2824}
3175 2825
3176u16 hpi_volume_auto_fade(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2826u16 hpi_volume_auto_fade(u32 h_control,
3177 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms) 2827 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms)
3178{ 2828{
3179 return hpi_volume_auto_fade_profile(ph_subsys, h_control, 2829 return hpi_volume_auto_fade_profile(h_control, an_stop_gain0_01dB,
3180 an_stop_gain0_01dB, duration_ms, HPI_VOLUME_AUTOFADE_LOG); 2830 duration_ms, HPI_VOLUME_AUTOFADE_LOG);
3181} 2831}
3182 2832
3183u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2833u16 hpi_vox_set_threshold(u32 h_control, short an_gain0_01dB)
3184 short an_gain0_01dB)
3185{ 2834{
3186 struct hpi_message hm; 2835 struct hpi_message hm;
3187 struct hpi_response hr; 2836 struct hpi_response hr;
3188 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2837 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3189 HPI_CONTROL_SET_STATE); 2838 HPI_CONTROL_SET_STATE);
3190 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2839 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2840 return HPI_ERROR_INVALID_HANDLE;
3191 hm.u.c.attribute = HPI_VOX_THRESHOLD; 2841 hm.u.c.attribute = HPI_VOX_THRESHOLD;
3192 2842
3193 hm.u.c.an_log_value[0] = an_gain0_01dB; 2843 hm.u.c.an_log_value[0] = an_gain0_01dB;
@@ -3197,14 +2847,14 @@ u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3197 return hr.error; 2847 return hr.error;
3198} 2848}
3199 2849
3200u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2850u16 hpi_vox_get_threshold(u32 h_control, short *an_gain0_01dB)
3201 short *an_gain0_01dB)
3202{ 2851{
3203 struct hpi_message hm; 2852 struct hpi_message hm;
3204 struct hpi_response hr; 2853 struct hpi_response hr;
3205 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2854 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3206 HPI_CONTROL_GET_STATE); 2855 HPI_CONTROL_GET_STATE);
3207 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2856 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2857 return HPI_ERROR_INVALID_HANDLE;
3208 hm.u.c.attribute = HPI_VOX_THRESHOLD; 2858 hm.u.c.attribute = HPI_VOX_THRESHOLD;
3209 2859
3210 hpi_send_recv(&hm, &hr); 2860 hpi_send_recv(&hm, &hr);
@@ -3213,728 +2863,3 @@ u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3213 2863
3214 return hr.error; 2864 return hr.error;
3215} 2865}
3216
3217static size_t strv_packet_size = MIN_STRV_PACKET_SIZE;
3218
3219static size_t entity_type_to_size[LAST_ENTITY_TYPE] = {
3220 0,
3221 sizeof(struct hpi_entity),
3222 sizeof(void *),
3223
3224 sizeof(int),
3225 sizeof(float),
3226 sizeof(double),
3227
3228 sizeof(char),
3229 sizeof(char),
3230
3231 4 * sizeof(char),
3232 16 * sizeof(char),
3233 6 * sizeof(char),
3234};
3235
3236static inline size_t hpi_entity_size(struct hpi_entity *entity_ptr)
3237{
3238 return entity_ptr->header.size;
3239}
3240
3241static inline size_t hpi_entity_header_size(struct hpi_entity *entity_ptr)
3242{
3243 return sizeof(entity_ptr->header);
3244}
3245
3246static inline size_t hpi_entity_value_size(struct hpi_entity *entity_ptr)
3247{
3248 return hpi_entity_size(entity_ptr) -
3249 hpi_entity_header_size(entity_ptr);
3250}
3251
3252static inline size_t hpi_entity_item_count(struct hpi_entity *entity_ptr)
3253{
3254 return hpi_entity_value_size(entity_ptr) /
3255 entity_type_to_size[entity_ptr->header.type];
3256}
3257
3258static inline struct hpi_entity *hpi_entity_ptr_to_next(struct hpi_entity
3259 *entity_ptr)
3260{
3261 return (void *)(((u8 *)entity_ptr) + hpi_entity_size(entity_ptr));
3262}
3263
3264static inline u16 hpi_entity_check_type(const enum e_entity_type t)
3265{
3266 if (t >= 0 && t < STR_TYPE_FIELD_MAX)
3267 return 0;
3268 return HPI_ERROR_ENTITY_TYPE_INVALID;
3269}
3270
3271static inline u16 hpi_entity_check_role(const enum e_entity_role r)
3272{
3273 if (r >= 0 && r < STR_ROLE_FIELD_MAX)
3274 return 0;
3275 return HPI_ERROR_ENTITY_ROLE_INVALID;
3276}
3277
3278static u16 hpi_entity_get_next(struct hpi_entity *entity, int recursive_flag,
3279 void *guard_p, struct hpi_entity **next)
3280{
3281 HPI_DEBUG_ASSERT(entity != NULL);
3282 HPI_DEBUG_ASSERT(next != NULL);
3283 HPI_DEBUG_ASSERT(hpi_entity_size(entity) != 0);
3284
3285 if (guard_p <= (void *)entity) {
3286 *next = NULL;
3287 return 0;
3288 }
3289
3290 if (recursive_flag && entity->header.type == entity_type_sequence)
3291 *next = (struct hpi_entity *)entity->value;
3292 else
3293 *next = (struct hpi_entity *)hpi_entity_ptr_to_next(entity);
3294
3295 if (guard_p <= (void *)*next) {
3296 *next = NULL;
3297 return 0;
3298 }
3299
3300 HPI_DEBUG_ASSERT(guard_p >= (void *)hpi_entity_ptr_to_next(*next));
3301 return 0;
3302}
3303
3304u16 hpi_entity_find_next(struct hpi_entity *container_entity,
3305 enum e_entity_type type, enum e_entity_role role, int recursive_flag,
3306 struct hpi_entity **current_match)
3307{
3308 struct hpi_entity *tmp = NULL;
3309 void *guard_p = NULL;
3310
3311 HPI_DEBUG_ASSERT(container_entity != NULL);
3312 guard_p = hpi_entity_ptr_to_next(container_entity);
3313
3314 if (*current_match != NULL)
3315 hpi_entity_get_next(*current_match, recursive_flag, guard_p,
3316 &tmp);
3317 else
3318 hpi_entity_get_next(container_entity, 1, guard_p, &tmp);
3319
3320 while (tmp) {
3321 u16 err;
3322
3323 HPI_DEBUG_ASSERT((void *)tmp >= (void *)container_entity);
3324
3325 if ((!type || tmp->header.type == type) && (!role
3326 || tmp->header.role == role)) {
3327 *current_match = tmp;
3328 return 0;
3329 }
3330
3331 err = hpi_entity_get_next(tmp, recursive_flag, guard_p,
3332 current_match);
3333 if (err)
3334 return err;
3335
3336 tmp = *current_match;
3337 }
3338
3339 *current_match = NULL;
3340 return 0;
3341}
3342
3343void hpi_entity_free(struct hpi_entity *entity)
3344{
3345 kfree(entity);
3346}
3347
3348static u16 hpi_entity_alloc_and_copy(struct hpi_entity *src,
3349 struct hpi_entity **dst)
3350{
3351 size_t buf_size;
3352 HPI_DEBUG_ASSERT(dst != NULL);
3353 HPI_DEBUG_ASSERT(src != NULL);
3354
3355 buf_size = hpi_entity_size(src);
3356 *dst = kmalloc(buf_size, GFP_KERNEL);
3357 if (*dst == NULL)
3358 return HPI_ERROR_MEMORY_ALLOC;
3359 memcpy(*dst, src, buf_size);
3360 return 0;
3361}
3362
3363u16 hpi_universal_info(const struct hpi_hsubsys *ph_subsys, u32 hC,
3364 struct hpi_entity **info)
3365{
3366 struct hpi_msg_strv hm;
3367 struct hpi_res_strv *phr;
3368 u16 hpi_err;
3369 int remaining_attempts = 2;
3370 size_t resp_packet_size = 1024;
3371
3372 *info = NULL;
3373
3374 while (remaining_attempts--) {
3375 phr = kmalloc(resp_packet_size, GFP_KERNEL);
3376 HPI_DEBUG_ASSERT(phr != NULL);
3377
3378 hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h,
3379 (u16)resp_packet_size, HPI_OBJ_CONTROL,
3380 HPI_CONTROL_GET_INFO);
3381 u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index);
3382
3383 hm.strv.header.size = sizeof(hm.strv);
3384 phr->strv.header.size = resp_packet_size - sizeof(phr->h);
3385
3386 hpi_send_recv((struct hpi_message *)&hm.h,
3387 (struct hpi_response *)&phr->h);
3388 if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) {
3389
3390 HPI_DEBUG_ASSERT(phr->h.specific_error >
3391 MIN_STRV_PACKET_SIZE
3392 && phr->h.specific_error < 1500);
3393 resp_packet_size = phr->h.specific_error;
3394 } else {
3395 remaining_attempts = 0;
3396 if (!phr->h.error)
3397 hpi_entity_alloc_and_copy(&phr->strv, info);
3398 }
3399
3400 hpi_err = phr->h.error;
3401 kfree(phr);
3402 }
3403
3404 return hpi_err;
3405}
3406
3407u16 hpi_universal_get(const struct hpi_hsubsys *ph_subsys, u32 hC,
3408 struct hpi_entity **value)
3409{
3410 struct hpi_msg_strv hm;
3411 struct hpi_res_strv *phr;
3412 u16 hpi_err;
3413 int remaining_attempts = 2;
3414
3415 *value = NULL;
3416
3417 while (remaining_attempts--) {
3418 phr = kmalloc(strv_packet_size, GFP_KERNEL);
3419 if (!phr)
3420 return HPI_ERROR_MEMORY_ALLOC;
3421
3422 hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h,
3423 (u16)strv_packet_size, HPI_OBJ_CONTROL,
3424 HPI_CONTROL_GET_STATE);
3425 u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index);
3426
3427 hm.strv.header.size = sizeof(hm.strv);
3428 phr->strv.header.size = strv_packet_size - sizeof(phr->h);
3429
3430 hpi_send_recv((struct hpi_message *)&hm.h,
3431 (struct hpi_response *)&phr->h);
3432 if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) {
3433
3434 HPI_DEBUG_ASSERT(phr->h.specific_error >
3435 MIN_STRV_PACKET_SIZE
3436 && phr->h.specific_error < 1000);
3437 strv_packet_size = phr->h.specific_error;
3438 } else {
3439 remaining_attempts = 0;
3440 if (!phr->h.error)
3441 hpi_entity_alloc_and_copy(&phr->strv, value);
3442 }
3443
3444 hpi_err = phr->h.error;
3445 kfree(phr);
3446 }
3447
3448 return hpi_err;
3449}
3450
3451u16 hpi_universal_set(const struct hpi_hsubsys *ph_subsys, u32 hC,
3452 struct hpi_entity *value)
3453{
3454 struct hpi_msg_strv *phm;
3455 struct hpi_res_strv hr;
3456
3457 phm = kmalloc(sizeof(phm->h) + value->header.size, GFP_KERNEL);
3458 HPI_DEBUG_ASSERT(phm != NULL);
3459
3460 hpi_init_message_responseV1(&phm->h,
3461 sizeof(phm->h) + value->header.size, &hr.h, sizeof(hr),
3462 HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE);
3463 u32TOINDEXES(hC, &phm->h.adapter_index, &phm->h.obj_index);
3464 hr.strv.header.size = sizeof(hr.strv);
3465
3466 memcpy(&phm->strv, value, value->header.size);
3467 hpi_send_recv((struct hpi_message *)&phm->h,
3468 (struct hpi_response *)&hr.h);
3469
3470 return hr.h.error;
3471}
3472
3473u16 hpi_entity_alloc_and_pack(const enum e_entity_type type,
3474 const size_t item_count, const enum e_entity_role role, void *value,
3475 struct hpi_entity **entity)
3476{
3477 size_t bytes_to_copy, total_size;
3478 u16 hE = 0;
3479 *entity = NULL;
3480
3481 hE = hpi_entity_check_type(type);
3482 if (hE)
3483 return hE;
3484
3485 HPI_DEBUG_ASSERT(role > entity_role_null && type < LAST_ENTITY_TYPE);
3486
3487 bytes_to_copy = entity_type_to_size[type] * item_count;
3488 total_size = hpi_entity_header_size(*entity) + bytes_to_copy;
3489
3490 HPI_DEBUG_ASSERT(total_size >= hpi_entity_header_size(*entity)
3491 && total_size < STR_SIZE_FIELD_MAX);
3492
3493 *entity = kmalloc(total_size, GFP_KERNEL);
3494 if (*entity == NULL)
3495 return HPI_ERROR_MEMORY_ALLOC;
3496 memcpy((*entity)->value, value, bytes_to_copy);
3497 (*entity)->header.size =
3498 hpi_entity_header_size(*entity) + bytes_to_copy;
3499 (*entity)->header.type = type;
3500 (*entity)->header.role = role;
3501 return 0;
3502}
3503
3504u16 hpi_entity_copy_value_from(struct hpi_entity *entity,
3505 enum e_entity_type type, size_t item_count, void *value_dst_p)
3506{
3507 size_t bytes_to_copy;
3508
3509 if (entity->header.type != type)
3510 return HPI_ERROR_ENTITY_TYPE_MISMATCH;
3511
3512 if (hpi_entity_item_count(entity) != item_count)
3513 return HPI_ERROR_ENTITY_ITEM_COUNT;
3514
3515 bytes_to_copy = entity_type_to_size[type] * item_count;
3516 memcpy(value_dst_p, entity->value, bytes_to_copy);
3517 return 0;
3518}
3519
3520u16 hpi_entity_unpack(struct hpi_entity *entity, enum e_entity_type *type,
3521 size_t *item_count, enum e_entity_role *role, void **value)
3522{
3523 u16 err = 0;
3524 HPI_DEBUG_ASSERT(entity != NULL);
3525
3526 if (type)
3527 *type = entity->header.type;
3528
3529 if (role)
3530 *role = entity->header.role;
3531
3532 if (value)
3533 *value = entity->value;
3534
3535 if (item_count != NULL) {
3536 if (entity->header.type == entity_type_sequence) {
3537 void *guard_p = hpi_entity_ptr_to_next(entity);
3538 struct hpi_entity *next = NULL;
3539 void *contents = entity->value;
3540
3541 *item_count = 0;
3542 while (contents < guard_p) {
3543 (*item_count)++;
3544 err = hpi_entity_get_next(contents, 0,
3545 guard_p, &next);
3546 if (next == NULL || err)
3547 break;
3548 contents = next;
3549 }
3550 } else {
3551 *item_count = hpi_entity_item_count(entity);
3552 }
3553 }
3554 return err;
3555}
3556
3557u16 hpi_gpio_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3558 u32 *ph_gpio, u16 *pw_number_input_bits, u16 *pw_number_output_bits)
3559{
3560 struct hpi_message hm;
3561 struct hpi_response hr;
3562 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_OPEN);
3563 hm.adapter_index = adapter_index;
3564
3565 hpi_send_recv(&hm, &hr);
3566
3567 if (hr.error == 0) {
3568 *ph_gpio =
3569 hpi_indexes_to_handle(HPI_OBJ_GPIO, adapter_index, 0);
3570 if (pw_number_input_bits)
3571 *pw_number_input_bits = hr.u.l.number_input_bits;
3572 if (pw_number_output_bits)
3573 *pw_number_output_bits = hr.u.l.number_output_bits;
3574 } else
3575 *ph_gpio = 0;
3576 return hr.error;
3577}
3578
3579u16 hpi_gpio_read_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3580 u16 bit_index, u16 *pw_bit_data)
3581{
3582 struct hpi_message hm;
3583 struct hpi_response hr;
3584 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_BIT);
3585 u32TOINDEX(h_gpio, &hm.adapter_index);
3586 hm.u.l.bit_index = bit_index;
3587
3588 hpi_send_recv(&hm, &hr);
3589
3590 *pw_bit_data = hr.u.l.bit_data[0];
3591 return hr.error;
3592}
3593
3594u16 hpi_gpio_read_all_bits(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3595 u16 aw_all_bit_data[4]
3596 )
3597{
3598 struct hpi_message hm;
3599 struct hpi_response hr;
3600 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_ALL);
3601 u32TOINDEX(h_gpio, &hm.adapter_index);
3602
3603 hpi_send_recv(&hm, &hr);
3604
3605 if (aw_all_bit_data) {
3606 aw_all_bit_data[0] = hr.u.l.bit_data[0];
3607 aw_all_bit_data[1] = hr.u.l.bit_data[1];
3608 aw_all_bit_data[2] = hr.u.l.bit_data[2];
3609 aw_all_bit_data[3] = hr.u.l.bit_data[3];
3610 }
3611 return hr.error;
3612}
3613
3614u16 hpi_gpio_write_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3615 u16 bit_index, u16 bit_data)
3616{
3617 struct hpi_message hm;
3618 struct hpi_response hr;
3619 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_WRITE_BIT);
3620 u32TOINDEX(h_gpio, &hm.adapter_index);
3621 hm.u.l.bit_index = bit_index;
3622 hm.u.l.bit_data = bit_data;
3623
3624 hpi_send_recv(&hm, &hr);
3625
3626 return hr.error;
3627}
3628
3629u16 hpi_gpio_write_status(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3630 u16 aw_all_bit_data[4]
3631 )
3632{
3633 struct hpi_message hm;
3634 struct hpi_response hr;
3635 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO,
3636 HPI_GPIO_WRITE_STATUS);
3637 u32TOINDEX(h_gpio, &hm.adapter_index);
3638
3639 hpi_send_recv(&hm, &hr);
3640
3641 if (aw_all_bit_data) {
3642 aw_all_bit_data[0] = hr.u.l.bit_data[0];
3643 aw_all_bit_data[1] = hr.u.l.bit_data[1];
3644 aw_all_bit_data[2] = hr.u.l.bit_data[2];
3645 aw_all_bit_data[3] = hr.u.l.bit_data[3];
3646 }
3647 return hr.error;
3648}
3649
3650u16 hpi_async_event_open(const struct hpi_hsubsys *ph_subsys,
3651 u16 adapter_index, u32 *ph_async)
3652{
3653 struct hpi_message hm;
3654 struct hpi_response hr;
3655 hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3656 HPI_ASYNCEVENT_OPEN);
3657 hm.adapter_index = adapter_index;
3658
3659 hpi_send_recv(&hm, &hr);
3660
3661 if (hr.error == 0)
3662
3663 *ph_async =
3664 hpi_indexes_to_handle(HPI_OBJ_ASYNCEVENT,
3665 adapter_index, 0);
3666 else
3667 *ph_async = 0;
3668 return hr.error;
3669
3670}
3671
3672u16 hpi_async_event_close(const struct hpi_hsubsys *ph_subsys, u32 h_async)
3673{
3674 struct hpi_message hm;
3675 struct hpi_response hr;
3676 hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3677 HPI_ASYNCEVENT_OPEN);
3678 u32TOINDEX(h_async, &hm.adapter_index);
3679
3680 hpi_send_recv(&hm, &hr);
3681
3682 return hr.error;
3683}
3684
3685u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async,
3686 u16 maximum_events, struct hpi_async_event *p_events,
3687 u16 *pw_number_returned)
3688{
3689
3690 return 0;
3691}
3692
3693u16 hpi_async_event_get_count(const struct hpi_hsubsys *ph_subsys,
3694 u32 h_async, u16 *pw_count)
3695{
3696 struct hpi_message hm;
3697 struct hpi_response hr;
3698 hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3699 HPI_ASYNCEVENT_GETCOUNT);
3700 u32TOINDEX(h_async, &hm.adapter_index);
3701
3702 hpi_send_recv(&hm, &hr);
3703
3704 if (hr.error == 0)
3705 if (pw_count)
3706 *pw_count = hr.u.as.u.count.count;
3707
3708 return hr.error;
3709}
3710
3711u16 hpi_async_event_get(const struct hpi_hsubsys *ph_subsys, u32 h_async,
3712 u16 maximum_events, struct hpi_async_event *p_events,
3713 u16 *pw_number_returned)
3714{
3715 struct hpi_message hm;
3716 struct hpi_response hr;
3717 hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3718 HPI_ASYNCEVENT_GET);
3719 u32TOINDEX(h_async, &hm.adapter_index);
3720
3721 hpi_send_recv(&hm, &hr);
3722 if (!hr.error) {
3723 memcpy(p_events, &hr.u.as.u.event,
3724 sizeof(struct hpi_async_event));
3725 *pw_number_returned = 1;
3726 }
3727
3728 return hr.error;
3729}
3730
3731u16 hpi_nv_memory_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3732 u32 *ph_nv_memory, u16 *pw_size_in_bytes)
3733{
3734 struct hpi_message hm;
3735 struct hpi_response hr;
3736 hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3737 HPI_NVMEMORY_OPEN);
3738 hm.adapter_index = adapter_index;
3739
3740 hpi_send_recv(&hm, &hr);
3741
3742 if (hr.error == 0) {
3743 *ph_nv_memory =
3744 hpi_indexes_to_handle(HPI_OBJ_NVMEMORY, adapter_index,
3745 0);
3746 if (pw_size_in_bytes)
3747 *pw_size_in_bytes = hr.u.n.size_in_bytes;
3748 } else
3749 *ph_nv_memory = 0;
3750 return hr.error;
3751}
3752
3753u16 hpi_nv_memory_read_byte(const struct hpi_hsubsys *ph_subsys,
3754 u32 h_nv_memory, u16 index, u16 *pw_data)
3755{
3756 struct hpi_message hm;
3757 struct hpi_response hr;
3758 hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3759 HPI_NVMEMORY_READ_BYTE);
3760 u32TOINDEX(h_nv_memory, &hm.adapter_index);
3761 hm.u.n.address = index;
3762
3763 hpi_send_recv(&hm, &hr);
3764
3765 *pw_data = hr.u.n.data;
3766 return hr.error;
3767}
3768
3769u16 hpi_nv_memory_write_byte(const struct hpi_hsubsys *ph_subsys,
3770 u32 h_nv_memory, u16 index, u16 data)
3771{
3772 struct hpi_message hm;
3773 struct hpi_response hr;
3774 hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3775 HPI_NVMEMORY_WRITE_BYTE);
3776 u32TOINDEX(h_nv_memory, &hm.adapter_index);
3777 hm.u.n.address = index;
3778 hm.u.n.data = data;
3779
3780 hpi_send_recv(&hm, &hr);
3781
3782 return hr.error;
3783}
3784
3785u16 hpi_profile_open_all(const struct hpi_hsubsys *ph_subsys,
3786 u16 adapter_index, u16 profile_index, u32 *ph_profile,
3787 u16 *pw_max_profiles)
3788{
3789 struct hpi_message hm;
3790 struct hpi_response hr;
3791 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3792 HPI_PROFILE_OPEN_ALL);
3793 hm.adapter_index = adapter_index;
3794 hm.obj_index = profile_index;
3795 hpi_send_recv(&hm, &hr);
3796
3797 *pw_max_profiles = hr.u.p.u.o.max_profiles;
3798 if (hr.error == 0)
3799 *ph_profile =
3800 hpi_indexes_to_handle(HPI_OBJ_PROFILE, adapter_index,
3801 profile_index);
3802 else
3803 *ph_profile = 0;
3804 return hr.error;
3805}
3806
3807u16 hpi_profile_get(const struct hpi_hsubsys *ph_subsys, u32 h_profile,
3808 u16 bin_index, u16 *pw_seconds, u32 *pmicro_seconds, u32 *pcall_count,
3809 u32 *pmax_micro_seconds, u32 *pmin_micro_seconds)
3810{
3811 struct hpi_message hm;
3812 struct hpi_response hr;
3813 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_GET);
3814 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3815 hm.u.p.bin_index = bin_index;
3816 hpi_send_recv(&hm, &hr);
3817 if (pw_seconds)
3818 *pw_seconds = hr.u.p.u.t.seconds;
3819 if (pmicro_seconds)
3820 *pmicro_seconds = hr.u.p.u.t.micro_seconds;
3821 if (pcall_count)
3822 *pcall_count = hr.u.p.u.t.call_count;
3823 if (pmax_micro_seconds)
3824 *pmax_micro_seconds = hr.u.p.u.t.max_micro_seconds;
3825 if (pmin_micro_seconds)
3826 *pmin_micro_seconds = hr.u.p.u.t.min_micro_seconds;
3827 return hr.error;
3828}
3829
3830u16 hpi_profile_get_utilization(const struct hpi_hsubsys *ph_subsys,
3831 u32 h_profile, u32 *putilization)
3832{
3833 struct hpi_message hm;
3834 struct hpi_response hr;
3835 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3836 HPI_PROFILE_GET_UTILIZATION);
3837 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3838 hpi_send_recv(&hm, &hr);
3839 if (hr.error) {
3840 if (putilization)
3841 *putilization = 0;
3842 } else {
3843 if (putilization)
3844 *putilization = hr.u.p.u.t.call_count;
3845 }
3846 return hr.error;
3847}
3848
3849u16 hpi_profile_get_name(const struct hpi_hsubsys *ph_subsys, u32 h_profile,
3850 u16 bin_index, char *sz_name, u16 name_length)
3851{
3852 struct hpi_message hm;
3853 struct hpi_response hr;
3854 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3855 HPI_PROFILE_GET_NAME);
3856 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3857 hm.u.p.bin_index = bin_index;
3858 hpi_send_recv(&hm, &hr);
3859 if (hr.error) {
3860 if (sz_name)
3861 strcpy(sz_name, "??");
3862 } else {
3863 if (sz_name)
3864 memcpy(sz_name, (char *)hr.u.p.u.n.sz_name,
3865 name_length);
3866 }
3867 return hr.error;
3868}
3869
3870u16 hpi_profile_start_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile)
3871{
3872 struct hpi_message hm;
3873 struct hpi_response hr;
3874 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3875 HPI_PROFILE_START_ALL);
3876 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3877 hpi_send_recv(&hm, &hr);
3878
3879 return hr.error;
3880}
3881
3882u16 hpi_profile_stop_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile)
3883{
3884 struct hpi_message hm;
3885 struct hpi_response hr;
3886 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3887 HPI_PROFILE_STOP_ALL);
3888 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3889 hpi_send_recv(&hm, &hr);
3890
3891 return hr.error;
3892}
3893
3894u16 hpi_watchdog_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3895 u32 *ph_watchdog)
3896{
3897 struct hpi_message hm;
3898 struct hpi_response hr;
3899 hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3900 HPI_WATCHDOG_OPEN);
3901 hm.adapter_index = adapter_index;
3902
3903 hpi_send_recv(&hm, &hr);
3904
3905 if (hr.error == 0)
3906 *ph_watchdog =
3907 hpi_indexes_to_handle(HPI_OBJ_WATCHDOG, adapter_index,
3908 0);
3909 else
3910 *ph_watchdog = 0;
3911 return hr.error;
3912}
3913
3914u16 hpi_watchdog_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog,
3915 u32 time_millisec)
3916{
3917 struct hpi_message hm;
3918 struct hpi_response hr;
3919 hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3920 HPI_WATCHDOG_SET_TIME);
3921 u32TOINDEX(h_watchdog, &hm.adapter_index);
3922 hm.u.w.time_ms = time_millisec;
3923
3924 hpi_send_recv(&hm, &hr);
3925
3926 return hr.error;
3927}
3928
3929u16 hpi_watchdog_ping(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog)
3930{
3931 struct hpi_message hm;
3932 struct hpi_response hr;
3933 hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3934 HPI_WATCHDOG_PING);
3935 u32TOINDEX(h_watchdog, &hm.adapter_index);
3936
3937 hpi_send_recv(&hm, &hr);
3938
3939 return hr.error;
3940}