~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to sound/pci/asihpi/hpifunc.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
        return handle.w;
31
31
}
32
32
 
 
33
static u16 hpi_handle_indexes(const u32 h, u16 *p1, u16 *p2)
 
34
{
 
35
        union handle_word uhandle;
 
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;
 
44
 
 
45
        return 0;
 
46
}
 
47
 
33
48
void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index,
34
49
        u16 *pw_object_index)
35
50
{
36
 
        union handle_word uhandle;
37
 
        uhandle.w = handle;
38
 
 
39
 
        if (pw_adapter_index)
40
 
                *pw_adapter_index = (u16)uhandle.h.adapter_index;
41
 
        if (pw_object_index)
42
 
                *pw_object_index = (u16)uhandle.h.obj_index;
 
51
        hpi_handle_indexes(handle, pw_adapter_index, pw_object_index);
43
52
}
44
53
 
45
54
char hpi_handle_object(const u32 handle)
49
58
        return (char)uhandle.h.obj_type;
50
59
}
51
60
 
52
 
#define u32TOINDEX(h, i1) \
53
 
do {\
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) \
61
 
do {\
62
 
        if (h == 0) \
63
 
                return HPI_ERROR_INVALID_OBJ; \
64
 
        else \
65
 
                hpi_handle_to_indexes(h, i1, i2);\
66
 
} while (0)
67
 
 
68
61
void hpi_format_to_msg(struct hpi_msg_format *pMF,
69
62
        const struct hpi_format *pF)
70
63
{
94
87
        pSR->u.legacy_stream_info.state = pSR->u.stream_info.state;
95
88
}
96
89
 
97
 
static struct hpi_hsubsys gh_subsys;
98
 
 
99
 
struct 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
 
 
118
 
void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys)
119
 
{
120
 
        struct hpi_message hm;
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
 
 
129
 
u16 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
 
}
140
 
 
141
 
u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys,
142
 
        u32 *pversion_ex)
 
90
static inline void hpi_send_recvV1(struct hpi_message_header *m,
 
91
        struct hpi_response_header *r)
 
92
{
 
93
        hpi_send_recv((struct hpi_message *)m, (struct hpi_response *)r);
 
94
}
 
95
 
 
96
u16 hpi_subsys_get_version_ex(u32 *pversion_ex)
143
97
{
144
98
        struct hpi_message hm;
145
99
        struct hpi_response hr;
151
105
        return hr.error;
152
106
}
153
107
 
154
 
u16 hpi_subsys_get_info(const struct hpi_hsubsys *ph_subsys, u32 *pversion,
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
 
 
174
 
u16 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
 
 
197
 
u16 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
 
 
213
 
u16 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
 
 
225
 
u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys,
226
 
        int *pn_num_adapters)
 
108
u16 hpi_subsys_get_num_adapters(int *pn_num_adapters)
227
109
{
228
110
        struct hpi_message hm;
229
111
        struct hpi_response hr;
234
116
        return hr.error;
235
117
}
236
118
 
237
 
u16 hpi_subsys_get_adapter(const struct hpi_hsubsys *ph_subsys, int iterator,
238
 
        u32 *padapter_index, u16 *pw_adapter_type)
 
119
u16 hpi_subsys_get_adapter(int iterator, u32 *padapter_index,
 
120
        u16 *pw_adapter_type)
239
121
{
240
122
        struct hpi_message hm;
241
123
        struct hpi_response hr;
242
124
        hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
243
125
                HPI_SUBSYS_GET_ADAPTER);
244
 
        hm.adapter_index = (u16)iterator;
 
126
        hm.obj_index = (u16)iterator;
245
127
        hpi_send_recv(&hm, &hr);
246
128
        *padapter_index = (int)hr.u.s.adapter_index;
247
 
        *pw_adapter_type = hr.u.s.aw_adapter_list[0];
248
 
        return hr.error;
249
 
}
250
 
 
251
 
u16 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;
263
 
}
264
 
 
265
 
u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index)
 
129
        *pw_adapter_type = hr.u.s.adapter_type;
 
130
 
 
131
        return hr.error;
 
132
}
 
133
 
 
134
u16 hpi_adapter_open(u16 adapter_index)
266
135
{
267
136
        struct hpi_message hm;
268
137
        struct hpi_response hr;
276
145
 
277
146
}
278
147
 
279
 
u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index)
 
148
u16 hpi_adapter_close(u16 adapter_index)
280
149
{
281
150
        struct hpi_message hm;
282
151
        struct hpi_response hr;
289
158
        return hr.error;
290
159
}
291
160
 
292
 
u16 hpi_adapter_set_mode(const struct hpi_hsubsys *ph_subsys,
293
 
        u16 adapter_index, u32 adapter_mode)
 
161
u16 hpi_adapter_set_mode(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
164
                HPI_ADAPTER_MODE_SET);
297
165
}
298
166
 
299
 
u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys,
300
 
        u16 adapter_index, u32 adapter_mode, u16 query_or_set)
 
167
u16 hpi_adapter_set_mode_ex(u16 adapter_index, u32 adapter_mode,
 
168
        u16 query_or_set)
301
169
{
302
170
        struct hpi_message hm;
303
171
        struct hpi_response hr;
305
173
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
306
174
                HPI_ADAPTER_SET_MODE);
307
175
        hm.adapter_index = adapter_index;
308
 
        hm.u.a.adapter_mode = adapter_mode;
309
 
        hm.u.a.assert_id = query_or_set;
 
176
        hm.u.ax.mode.adapter_mode = adapter_mode;
 
177
        hm.u.ax.mode.query_or_set = query_or_set;
310
178
        hpi_send_recv(&hm, &hr);
311
179
        return hr.error;
312
180
}
313
181
 
314
 
u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys,
315
 
        u16 adapter_index, u32 *padapter_mode)
 
182
u16 hpi_adapter_get_mode(u16 adapter_index, u32 *padapter_mode)
316
183
{
317
184
        struct hpi_message hm;
318
185
        struct hpi_response hr;
321
188
        hm.adapter_index = adapter_index;
322
189
        hpi_send_recv(&hm, &hr);
323
190
        if (padapter_mode)
324
 
                *padapter_mode = hr.u.a.serial_number;
 
191
                *padapter_mode = hr.u.ax.mode.adapter_mode;
325
192
        return hr.error;
326
193
}
327
194
 
328
 
u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys,
329
 
        u16 adapter_index, u16 *pw_num_outstreams, u16 *pw_num_instreams,
330
 
        u16 *pw_version, u32 *pserial_number, u16 *pw_adapter_type)
 
195
u16 hpi_adapter_get_info(u16 adapter_index, u16 *pw_num_outstreams,
 
196
        u16 *pw_num_instreams, u16 *pw_version, u32 *pserial_number,
 
197
        u16 *pw_adapter_type)
331
198
{
332
199
        struct hpi_message hm;
333
200
        struct hpi_response hr;
337
204
 
338
205
        hpi_send_recv(&hm, &hr);
339
206
 
340
 
        *pw_adapter_type = hr.u.a.adapter_type;
341
 
        *pw_num_outstreams = hr.u.a.num_outstreams;
342
 
        *pw_num_instreams = hr.u.a.num_instreams;
343
 
        *pw_version = hr.u.a.version;
344
 
        *pserial_number = hr.u.a.serial_number;
 
207
        *pw_adapter_type = hr.u.ax.info.adapter_type;
 
208
        *pw_num_outstreams = hr.u.ax.info.num_outstreams;
 
209
        *pw_num_instreams = hr.u.ax.info.num_instreams;
 
210
        *pw_version = hr.u.ax.info.version;
 
211
        *pserial_number = hr.u.ax.info.serial_number;
345
212
        return hr.error;
346
213
}
347
214
 
348
 
u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys,
349
 
        u16 adapter_index, u16 module_index, u16 *pw_num_outputs,
350
 
        u16 *pw_num_inputs, u16 *pw_version, u32 *pserial_number,
351
 
        u16 *pw_module_type, u32 *ph_module)
 
215
u16 hpi_adapter_get_module_by_index(u16 adapter_index, u16 module_index,
 
216
        u16 *pw_num_outputs, u16 *pw_num_inputs, u16 *pw_version,
 
217
        u32 *pserial_number, u16 *pw_module_type, u32 *ph_module)
352
218
{
353
219
        struct hpi_message hm;
354
220
        struct hpi_response hr;
360
226
 
361
227
        hpi_send_recv(&hm, &hr);
362
228
 
363
 
        *pw_module_type = hr.u.a.adapter_type;
364
 
        *pw_num_outputs = hr.u.a.num_outstreams;
365
 
        *pw_num_inputs = hr.u.a.num_instreams;
366
 
        *pw_version = hr.u.a.version;
367
 
        *pserial_number = hr.u.a.serial_number;
 
229
        *pw_module_type = hr.u.ax.info.adapter_type;
 
230
        *pw_num_outputs = hr.u.ax.info.num_outstreams;
 
231
        *pw_num_inputs = hr.u.ax.info.num_instreams;
 
232
        *pw_version = hr.u.ax.info.version;
 
233
        *pserial_number = hr.u.ax.info.serial_number;
368
234
        *ph_module = 0;
369
235
 
370
236
        return hr.error;
371
237
}
372
238
 
373
 
u16 hpi_adapter_get_assert(const struct hpi_hsubsys *ph_subsys,
374
 
        u16 adapter_index, u16 *assert_present, char *psz_assert,
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
 
 
410
 
u16 hpi_adapter_get_assert_ex(const struct hpi_hsubsys *ph_subsys,
411
 
        u16 adapter_index, u16 *assert_present, char *psz_assert,
412
 
        u32 *pline_number, u16 *pw_assert_on_dsp)
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
 
 
457
 
u16 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
 
 
472
 
u16 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
 
 
488
 
u16 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
 
 
500
 
u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys,
501
 
        u16 adapter_index, u32 dsp_address, char *p_buffer, int *count_bytes)
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
 
 
528
 
u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys,
529
 
        u16 adapter_index, u16 property, u16 parameter1, u16 parameter2)
 
239
u16 hpi_adapter_set_property(u16 adapter_index, u16 property, u16 parameter1,
 
240
        u16 parameter2)
530
241
{
531
242
        struct hpi_message hm;
532
243
        struct hpi_response hr;
542
253
        return hr.error;
543
254
}
544
255
 
545
 
u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys,
546
 
        u16 adapter_index, u16 property, u16 *pw_parameter1,
547
 
        u16 *pw_parameter2)
 
256
u16 hpi_adapter_get_property(u16 adapter_index, u16 property,
 
257
        u16 *pw_parameter1, u16 *pw_parameter2)
548
258
{
549
259
        struct hpi_message hm;
550
260
        struct hpi_response hr;
564
274
        return hr.error;
565
275
}
566
276
 
567
 
u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys,
568
 
        u16 adapter_index, u16 index, u16 what_to_enumerate,
569
 
        u16 property_index, u32 *psetting)
 
277
u16 hpi_adapter_enumerate_property(u16 adapter_index, u16 index,
 
278
        u16 what_to_enumerate, u16 property_index, u32 *psetting)
570
279
{
571
280
        return 0;
572
281
}
574
283
u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
575
284
        u32 sample_rate, u32 bit_rate, u32 attributes)
576
285
{
577
 
        u16 error = 0;
 
286
        u16 err = 0;
578
287
        struct hpi_msg_format fmt;
579
288
 
580
289
        switch (channels) {
586
295
        case 16:
587
296
                break;
588
297
        default:
589
 
                error = HPI_ERROR_INVALID_CHANNELS;
590
 
                return error;
 
298
                err = HPI_ERROR_INVALID_CHANNELS;
 
299
                return err;
591
300
        }
592
301
        fmt.channels = channels;
593
302
 
610
319
        case HPI_FORMAT_OEM2:
611
320
                break;
612
321
        default:
613
 
                error = HPI_ERROR_INVALID_FORMAT;
614
 
                return error;
 
322
                err = HPI_ERROR_INVALID_FORMAT;
 
323
                return err;
615
324
        }
616
325
        fmt.format = format;
617
326
 
618
327
        if (sample_rate < 8000L) {
619
 
                error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
 
328
                err = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
620
329
                sample_rate = 8000L;
621
330
        }
622
331
        if (sample_rate > 200000L) {
623
 
                error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
 
332
                err = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
624
333
                sample_rate = 200000L;
625
334
        }
626
335
        fmt.sample_rate = sample_rate;
651
360
                if ((channels == 1)
652
361
                        && (attributes != HPI_MPEG_MODE_DEFAULT)) {
653
362
                        attributes = HPI_MPEG_MODE_DEFAULT;
654
 
                        error = HPI_ERROR_INVALID_FORMAT;
 
363
                        err = HPI_ERROR_INVALID_FORMAT;
655
364
                } else if (attributes > HPI_MPEG_MODE_DUALCHANNEL) {
656
365
                        attributes = HPI_MPEG_MODE_DEFAULT;
657
 
                        error = HPI_ERROR_INVALID_FORMAT;
 
366
                        err = HPI_ERROR_INVALID_FORMAT;
658
367
                }
659
368
                fmt.attributes = attributes;
660
369
                break;
663
372
        }
664
373
 
665
374
        hpi_msg_to_format(p_format, &fmt);
666
 
        return error;
 
375
        return err;
667
376
}
668
377
 
669
378
u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format,
712
421
        return 0;
713
422
}
714
423
 
715
 
u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
716
 
        u16 outstream_index, u32 *ph_outstream)
 
424
u16 hpi_outstream_open(u16 adapter_index, u16 outstream_index,
 
425
        u32 *ph_outstream)
717
426
{
718
427
        struct hpi_message hm;
719
428
        struct hpi_response hr;
733
442
        return hr.error;
734
443
}
735
444
 
736
 
u16 hpi_outstream_close(const struct hpi_hsubsys *ph_subsys, u32 h_outstream)
 
445
u16 hpi_outstream_close(u32 h_outstream)
737
446
{
738
447
        struct hpi_message hm;
739
448
        struct hpi_response hr;
740
449
 
741
450
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
742
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
455
        hpi_send_recv(&hm, &hr);
745
456
 
746
457
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
747
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
460
        hpi_send_recv(&hm, &hr);
750
461
 
751
462
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
752
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
465
        hpi_send_recv(&hm, &hr);
755
466
 
756
467
        return hr.error;
757
468
}
758
469
 
759
 
u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys,
760
 
        u32 h_outstream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_to_play,
761
 
        u32 *psamples_played, u32 *pauxiliary_data_to_play)
 
470
u16 hpi_outstream_get_info_ex(u32 h_outstream, u16 *pw_state,
 
471
        u32 *pbuffer_size, u32 *pdata_to_play, u32 *psamples_played,
 
472
        u32 *pauxiliary_data_to_play)
762
473
{
763
474
        struct hpi_message hm;
764
475
        struct hpi_response hr;
765
476
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
766
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
481
        hpi_send_recv(&hm, &hr);
770
482
 
782
494
        return hr.error;
783
495
}
784
496
 
785
 
u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys,
786
 
        u32 h_outstream, const u8 *pb_data, u32 bytes_to_write,
787
 
        const struct hpi_format *p_format)
 
497
u16 hpi_outstream_write_buf(u32 h_outstream, const u8 *pb_data,
 
498
        u32 bytes_to_write, const struct hpi_format *p_format)
788
499
{
789
500
        struct hpi_message hm;
790
501
        struct hpi_response hr;
791
502
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
792
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
506
        hm.u.d.u.data.pb_data = (u8 *)pb_data;
795
507
        hm.u.d.u.data.data_size = bytes_to_write;
796
508
 
801
513
        return hr.error;
802
514
}
803
515
 
804
 
u16 hpi_outstream_start(const struct hpi_hsubsys *ph_subsys, u32 h_outstream)
 
516
u16 hpi_outstream_start(u32 h_outstream)
805
517
{
806
518
        struct hpi_message hm;
807
519
        struct hpi_response hr;
808
520
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
809
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
525
        hpi_send_recv(&hm, &hr);
813
526
 
814
527
        return hr.error;
815
528
}
816
529
 
817
 
u16 hpi_outstream_wait_start(const struct hpi_hsubsys *ph_subsys,
818
 
        u32 h_outstream)
 
530
u16 hpi_outstream_wait_start(u32 h_outstream)
819
531
{
820
532
        struct hpi_message hm;
821
533
        struct hpi_response hr;
822
534
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
823
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
539
        hpi_send_recv(&hm, &hr);
827
540
 
828
541
        return hr.error;
829
542
}
830
543
 
831
 
u16 hpi_outstream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_outstream)
 
544
u16 hpi_outstream_stop(u32 h_outstream)
832
545
{
833
546
        struct hpi_message hm;
834
547
        struct hpi_response hr;
835
548
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
836
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
553
        hpi_send_recv(&hm, &hr);
840
554
 
841
555
        return hr.error;
842
556
}
843
557
 
844
 
u16 hpi_outstream_sinegen(const struct hpi_hsubsys *ph_subsys,
845
 
        u32 h_outstream)
 
558
u16 hpi_outstream_sinegen(u32 h_outstream)
846
559
{
847
560
        struct hpi_message hm;
848
561
        struct hpi_response hr;
849
562
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
850
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
567
        hpi_send_recv(&hm, &hr);
854
568
 
855
569
        return hr.error;
856
570
}
857
571
 
858
 
u16 hpi_outstream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_outstream)
 
572
u16 hpi_outstream_reset(u32 h_outstream)
859
573
{
860
574
        struct hpi_message hm;
861
575
        struct hpi_response hr;
862
576
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
863
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
581
        hpi_send_recv(&hm, &hr);
867
582
 
868
583
        return hr.error;
869
584
}
870
585
 
871
 
u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys,
872
 
        u32 h_outstream, struct hpi_format *p_format)
 
586
u16 hpi_outstream_query_format(u32 h_outstream, struct hpi_format *p_format)
873
587
{
874
588
        struct hpi_message hm;
875
589
        struct hpi_response hr;
876
590
 
877
591
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
878
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
596
        hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
882
597
 
885
600
        return hr.error;
886
601
}
887
602
 
888
 
u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys,
889
 
        u32 h_outstream, struct hpi_format *p_format)
 
603
u16 hpi_outstream_set_format(u32 h_outstream, struct hpi_format *p_format)
890
604
{
891
605
        struct hpi_message hm;
892
606
        struct hpi_response hr;
893
607
 
894
608
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
895
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
613
        hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
899
614
 
902
617
        return hr.error;
903
618
}
904
619
 
905
 
u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys,
906
 
        u32 h_outstream, short velocity)
 
620
u16 hpi_outstream_set_velocity(u32 h_outstream, short velocity)
907
621
{
908
622
        struct hpi_message hm;
909
623
        struct hpi_response hr;
910
624
 
911
625
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
912
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
629
        hm.u.d.u.velocity = velocity;
915
630
 
916
631
        hpi_send_recv(&hm, &hr);
918
633
        return hr.error;
919
634
}
920
635
 
921
 
u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys,
922
 
        u32 h_outstream, u32 punch_in_sample, u32 punch_out_sample)
 
636
u16 hpi_outstream_set_punch_in_out(u32 h_outstream, u32 punch_in_sample,
 
637
        u32 punch_out_sample)
923
638
{
924
639
        struct hpi_message hm;
925
640
        struct hpi_response hr;
926
641
 
927
642
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
928
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
647
        hm.u.d.u.pio.punch_in_sample = punch_in_sample;
932
648
        hm.u.d.u.pio.punch_out_sample = punch_out_sample;
936
652
        return hr.error;
937
653
}
938
654
 
939
 
u16 hpi_outstream_ancillary_reset(const struct hpi_hsubsys *ph_subsys,
940
 
        u32 h_outstream, u16 mode)
 
655
u16 hpi_outstream_ancillary_reset(u32 h_outstream, u16 mode)
941
656
{
942
657
        struct hpi_message hm;
943
658
        struct hpi_response hr;
944
659
 
945
660
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
946
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
664
        hm.u.d.u.data.format.channels = mode;
949
665
        hpi_send_recv(&hm, &hr);
950
666
        return hr.error;
951
667
}
952
668
 
953
 
u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys,
954
 
        u32 h_outstream, u32 *pframes_available)
 
669
u16 hpi_outstream_ancillary_get_info(u32 h_outstream, u32 *pframes_available)
955
670
{
956
671
        struct hpi_message hm;
957
672
        struct hpi_response hr;
958
673
 
959
674
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
960
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
678
        hpi_send_recv(&hm, &hr);
963
679
        if (hr.error == 0) {
964
680
                if (pframes_available)
969
685
        return hr.error;
970
686
}
971
687
 
972
 
u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys,
973
 
        u32 h_outstream, struct hpi_anc_frame *p_anc_frame_buffer,
 
688
u16 hpi_outstream_ancillary_read(u32 h_outstream,
 
689
        struct hpi_anc_frame *p_anc_frame_buffer,
974
690
        u32 anc_frame_buffer_size_in_bytes,
975
691
        u32 number_of_ancillary_frames_to_read)
976
692
{
979
695
 
980
696
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
981
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
700
        hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer;
984
701
        hm.u.d.u.data.data_size =
985
702
                number_of_ancillary_frames_to_read *
987
704
        if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes)
988
705
                hpi_send_recv(&hm, &hr);
989
706
        else
990
 
                hr.error = HPI_ERROR_INVALID_DATA_TRANSFER;
 
707
                hr.error = HPI_ERROR_INVALID_DATASIZE;
991
708
        return hr.error;
992
709
}
993
710
 
994
 
u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys,
995
 
        u32 h_outstream, u32 time_scale)
 
711
u16 hpi_outstream_set_time_scale(u32 h_outstream, u32 time_scale)
996
712
{
997
713
        struct hpi_message hm;
998
714
        struct hpi_response hr;
999
715
 
1000
716
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1001
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
721
        hm.u.d.u.time_scale = time_scale;
1005
722
 
1008
725
        return hr.error;
1009
726
}
1010
727
 
1011
 
u16 hpi_outstream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys,
1012
 
        u32 h_outstream, u32 size_in_bytes)
 
728
u16 hpi_outstream_host_buffer_allocate(u32 h_outstream, u32 size_in_bytes)
1013
729
{
1014
730
        struct hpi_message hm;
1015
731
        struct hpi_response hr;
1016
732
 
1017
733
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1018
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
737
        hm.u.d.u.data.data_size = size_in_bytes;
1021
738
        hpi_send_recv(&hm, &hr);
1022
739
        return hr.error;
1023
740
}
1024
741
 
1025
 
u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1026
 
        u32 h_outstream, u8 **pp_buffer,
 
742
u16 hpi_outstream_host_buffer_get_info(u32 h_outstream, u8 **pp_buffer,
1027
743
        struct hpi_hostbuffer_status **pp_status)
1028
744
{
1029
745
        struct hpi_message hm;
1031
747
 
1032
748
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1033
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
752
        hpi_send_recv(&hm, &hr);
1036
753
 
1037
754
        if (hr.error == 0) {
1043
760
        return hr.error;
1044
761
}
1045
762
 
1046
 
u16 hpi_outstream_host_buffer_free(const struct hpi_hsubsys *ph_subsys,
1047
 
        u32 h_outstream)
 
763
u16 hpi_outstream_host_buffer_free(u32 h_outstream)
1048
764
{
1049
765
        struct hpi_message hm;
1050
766
        struct hpi_response hr;
1051
767
 
1052
768
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1053
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
772
        hpi_send_recv(&hm, &hr);
1056
773
        return hr.error;
1057
774
}
1058
775
 
1059
 
u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys,
1060
 
        u32 h_outstream, u32 h_stream)
 
776
u16 hpi_outstream_group_add(u32 h_outstream, u32 h_stream)
1061
777
{
1062
778
        struct hpi_message hm;
1063
779
        struct hpi_response hr;
1066
782
 
1067
783
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1068
784
                HPI_OSTREAM_GROUP_ADD);
1069
 
        hr.error = 0;
1070
 
        u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
 
785
 
 
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
793
        c_obj_type = hpi_handle_object(h_stream);
1072
794
        switch (c_obj_type) {
1073
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
796
        case HPI_OBJ_ISTREAM:
1079
 
                hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM;
1080
 
                u32TOINDEXES(h_stream, &adapter,
1081
 
                        &hm.u.d.u.stream.stream_index);
 
797
                hm.u.d.u.stream.object_type = c_obj_type;
1082
798
                break;
1083
799
        default:
1084
 
                return HPI_ERROR_INVALID_STREAM;
 
800
                return HPI_ERROR_INVALID_OBJ;
1085
801
        }
1086
802
        if (adapter != hm.adapter_index)
1087
803
                return HPI_ERROR_NO_INTERADAPTER_GROUPS;
1090
806
        return hr.error;
1091
807
}
1092
808
 
1093
 
u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys,
1094
 
        u32 h_outstream, u32 *poutstream_map, u32 *pinstream_map)
 
809
u16 hpi_outstream_group_get_map(u32 h_outstream, u32 *poutstream_map,
 
810
        u32 *pinstream_map)
1095
811
{
1096
812
        struct hpi_message hm;
1097
813
        struct hpi_response hr;
1098
814
 
1099
815
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1100
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
819
        hpi_send_recv(&hm, &hr);
1103
820
 
1104
821
        if (poutstream_map)
1109
826
        return hr.error;
1110
827
}
1111
828
 
1112
 
u16 hpi_outstream_group_reset(const struct hpi_hsubsys *ph_subsys,
1113
 
        u32 h_outstream)
 
829
u16 hpi_outstream_group_reset(u32 h_outstream)
1114
830
{
1115
831
        struct hpi_message hm;
1116
832
        struct hpi_response hr;
1117
833
 
1118
834
        hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1119
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
838
        hpi_send_recv(&hm, &hr);
1122
839
        return hr.error;
1123
840
}
1124
841
 
1125
 
u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1126
 
        u16 instream_index, u32 *ph_instream)
 
842
u16 hpi_instream_open(u16 adapter_index, u16 instream_index, u32 *ph_instream)
1127
843
{
1128
844
        struct hpi_message hm;
1129
845
        struct hpi_response hr;
1145
861
        return hr.error;
1146
862
}
1147
863
 
1148
 
u16 hpi_instream_close(const struct hpi_hsubsys *ph_subsys, u32 h_instream)
 
864
u16 hpi_instream_close(u32 h_instream)
1149
865
{
1150
866
        struct hpi_message hm;
1151
867
        struct hpi_response hr;
1152
868
 
1153
869
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1154
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
873
        hpi_send_recv(&hm, &hr);
1157
874
 
1158
875
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1159
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
878
        hpi_send_recv(&hm, &hr);
1162
879
 
1163
880
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1164
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
883
        hpi_send_recv(&hm, &hr);
1167
884
 
1168
885
        return hr.error;
1169
886
}
1170
887
 
1171
 
u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys,
1172
 
        u32 h_instream, const struct hpi_format *p_format)
 
888
u16 hpi_instream_query_format(u32 h_instream,
 
889
        const struct hpi_format *p_format)
1173
890
{
1174
891
        struct hpi_message hm;
1175
892
        struct hpi_response hr;
1176
893
 
1177
894
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1178
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
898
        hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
1181
899
 
1182
900
        hpi_send_recv(&hm, &hr);
1184
902
        return hr.error;
1185
903
}
1186
904
 
1187
 
u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys,
1188
 
        u32 h_instream, const struct hpi_format *p_format)
 
905
u16 hpi_instream_set_format(u32 h_instream, const struct hpi_format *p_format)
1189
906
{
1190
907
        struct hpi_message hm;
1191
908
        struct hpi_response hr;
1192
909
 
1193
910
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1194
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
914
        hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
1197
915
 
1198
916
        hpi_send_recv(&hm, &hr);
1200
918
        return hr.error;
1201
919
}
1202
920
 
1203
 
u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream,
1204
 
        u8 *pb_data, u32 bytes_to_read)
 
921
u16 hpi_instream_read_buf(u32 h_instream, u8 *pb_data, u32 bytes_to_read)
1205
922
{
1206
923
        struct hpi_message hm;
1207
924
        struct hpi_response hr;
1208
925
 
1209
926
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1210
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
930
        hm.u.d.u.data.data_size = bytes_to_read;
1213
931
        hm.u.d.u.data.pb_data = pb_data;
1214
932
 
1217
935
        return hr.error;
1218
936
}
1219
937
 
1220
 
u16 hpi_instream_start(const struct hpi_hsubsys *ph_subsys, u32 h_instream)
 
938
u16 hpi_instream_start(u32 h_instream)
1221
939
{
1222
940
        struct hpi_message hm;
1223
941
        struct hpi_response hr;
1224
942
 
1225
943
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1226
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
948
        hpi_send_recv(&hm, &hr);
1230
949
 
1231
950
        return hr.error;
1232
951
}
1233
952
 
1234
 
u16 hpi_instream_wait_start(const struct hpi_hsubsys *ph_subsys,
1235
 
        u32 h_instream)
 
953
u16 hpi_instream_wait_start(u32 h_instream)
1236
954
{
1237
955
        struct hpi_message hm;
1238
956
        struct hpi_response hr;
1239
957
 
1240
958
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1241
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
963
        hpi_send_recv(&hm, &hr);
1245
964
 
1246
965
        return hr.error;
1247
966
}
1248
967
 
1249
 
u16 hpi_instream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_instream)
 
968
u16 hpi_instream_stop(u32 h_instream)
1250
969
{
1251
970
        struct hpi_message hm;
1252
971
        struct hpi_response hr;
1253
972
 
1254
973
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1255
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
978
        hpi_send_recv(&hm, &hr);
1259
979
 
1260
980
        return hr.error;
1261
981
}
1262
982
 
1263
 
u16 hpi_instream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_instream)
 
983
u16 hpi_instream_reset(u32 h_instream)
1264
984
{
1265
985
        struct hpi_message hm;
1266
986
        struct hpi_response hr;
1267
987
 
1268
988
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1269
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
993
        hpi_send_recv(&hm, &hr);
1273
994
 
1274
995
        return hr.error;
1275
996
}
1276
997
 
1277
 
u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys,
1278
 
        u32 h_instream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_recorded,
1279
 
        u32 *psamples_recorded, u32 *pauxiliary_data_recorded)
 
998
u16 hpi_instream_get_info_ex(u32 h_instream, u16 *pw_state, u32 *pbuffer_size,
 
999
        u32 *pdata_recorded, u32 *psamples_recorded,
 
1000
        u32 *pauxiliary_data_recorded)
1280
1001
{
1281
1002
        struct hpi_message hm;
1282
1003
        struct hpi_response hr;
1283
1004
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1284
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
1009
        hpi_send_recv(&hm, &hr);
1288
1010
 
1300
1022
        return hr.error;
1301
1023
}
1302
1024
 
1303
 
u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys,
1304
 
        u32 h_instream, u16 bytes_per_frame, u16 mode, u16 alignment,
1305
 
        u16 idle_bit)
 
1025
u16 hpi_instream_ancillary_reset(u32 h_instream, u16 bytes_per_frame,
 
1026
        u16 mode, u16 alignment, u16 idle_bit)
1306
1027
{
1307
1028
        struct hpi_message hm;
1308
1029
        struct hpi_response hr;
1309
1030
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1310
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
1034
        hm.u.d.u.data.format.attributes = bytes_per_frame;
1313
1035
        hm.u.d.u.data.format.format = (mode << 8) | (alignment & 0xff);
1314
1036
        hm.u.d.u.data.format.channels = idle_bit;
1316
1038
        return hr.error;
1317
1039
}
1318
1040
 
1319
 
u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys,
1320
 
        u32 h_instream, u32 *pframe_space)
 
1041
u16 hpi_instream_ancillary_get_info(u32 h_instream, u32 *pframe_space)
1321
1042
{
1322
1043
        struct hpi_message hm;
1323
1044
        struct hpi_response hr;
1324
1045
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1325
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
1049
        hpi_send_recv(&hm, &hr);
1328
1050
        if (pframe_space)
1329
1051
                *pframe_space =
1333
1055
        return hr.error;
1334
1056
}
1335
1057
 
1336
 
u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys,
1337
 
        u32 h_instream, const struct hpi_anc_frame *p_anc_frame_buffer,
 
1058
u16 hpi_instream_ancillary_write(u32 h_instream,
 
1059
        const struct hpi_anc_frame *p_anc_frame_buffer,
1338
1060
        u32 anc_frame_buffer_size_in_bytes,
1339
1061
        u32 number_of_ancillary_frames_to_write)
1340
1062
{
1343
1065
 
1344
1066
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1345
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
1070
        hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer;
1348
1071
        hm.u.d.u.data.data_size =
1349
1072
                number_of_ancillary_frames_to_write *
1351
1074
        if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes)
1352
1075
                hpi_send_recv(&hm, &hr);
1353
1076
        else
1354
 
                hr.error = HPI_ERROR_INVALID_DATA_TRANSFER;
 
1077
                hr.error = HPI_ERROR_INVALID_DATASIZE;
1355
1078
        return hr.error;
1356
1079
}
1357
1080
 
1358
 
u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys,
1359
 
        u32 h_instream, u32 size_in_bytes)
 
1081
u16 hpi_instream_host_buffer_allocate(u32 h_instream, u32 size_in_bytes)
1360
1082
{
1361
1083
 
1362
1084
        struct hpi_message hm;
1364
1086
 
1365
1087
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1366
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
1091
        hm.u.d.u.data.data_size = size_in_bytes;
1369
1092
        hpi_send_recv(&hm, &hr);
1370
1093
        return hr.error;
1371
1094
}
1372
1095
 
1373
 
u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1374
 
        u32 h_instream, u8 **pp_buffer,
 
1096
u16 hpi_instream_host_buffer_get_info(u32 h_instream, u8 **pp_buffer,
1375
1097
        struct hpi_hostbuffer_status **pp_status)
1376
1098
{
1377
1099
        struct hpi_message hm;
1379
1101
 
1380
1102
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1381
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
1106
        hpi_send_recv(&hm, &hr);
1384
1107
 
1385
1108
        if (hr.error == 0) {
1391
1114
        return hr.error;
1392
1115
}
1393
1116
 
1394
 
u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys,
1395
 
        u32 h_instream)
 
1117
u16 hpi_instream_host_buffer_free(u32 h_instream)
1396
1118
{
1397
1119
 
1398
1120
        struct hpi_message hm;
1400
1122
 
1401
1123
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1402
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
1127
        hpi_send_recv(&hm, &hr);
1405
1128
        return hr.error;
1406
1129
}
1407
1130
 
1408
 
u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys,
1409
 
        u32 h_instream, u32 h_stream)
 
1131
u16 hpi_instream_group_add(u32 h_instream, u32 h_stream)
1410
1132
{
1411
1133
        struct hpi_message hm;
1412
1134
        struct hpi_response hr;
1416
1138
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1417
1139
                HPI_ISTREAM_GROUP_ADD);
1418
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
1149
        c_obj_type = hpi_handle_object(h_stream);
1421
1150
 
1422
1151
        switch (c_obj_type) {
1423
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
1153
        case HPI_OBJ_ISTREAM:
1429
 
                hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM;
1430
 
                u32TOINDEXES(h_stream, &adapter,
1431
 
                        &hm.u.d.u.stream.stream_index);
 
1154
                hm.u.d.u.stream.object_type = c_obj_type;
1432
1155
                break;
1433
1156
        default:
1434
 
                return HPI_ERROR_INVALID_STREAM;
 
1157
                return HPI_ERROR_INVALID_OBJ;
1435
1158
        }
1436
1159
 
1437
1160
        if (adapter != hm.adapter_index)
1441
1164
        return hr.error;
1442
1165
}
1443
1166
 
1444
 
u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys,
1445
 
        u32 h_instream, u32 *poutstream_map, u32 *pinstream_map)
 
1167
u16 hpi_instream_group_get_map(u32 h_instream, u32 *poutstream_map,
 
1168
        u32 *pinstream_map)
1446
1169
{
1447
1170
        struct hpi_message hm;
1448
1171
        struct hpi_response hr;
1449
1172
 
1450
1173
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1451
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
1177
        hpi_send_recv(&hm, &hr);
1454
1178
 
1455
1179
        if (poutstream_map)
1460
1184
        return hr.error;
1461
1185
}
1462
1186
 
1463
 
u16 hpi_instream_group_reset(const struct hpi_hsubsys *ph_subsys,
1464
 
        u32 h_instream)
 
1187
u16 hpi_instream_group_reset(u32 h_instream)
1465
1188
{
1466
1189
        struct hpi_message hm;
1467
1190
        struct hpi_response hr;
1468
1191
 
1469
1192
        hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1470
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
1196
        hpi_send_recv(&hm, &hr);
1473
1197
        return hr.error;
1474
1198
}
1475
1199
 
1476
 
u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1477
 
        u32 *ph_mixer)
 
1200
u16 hpi_mixer_open(u16 adapter_index, u32 *ph_mixer)
1478
1201
{
1479
1202
        struct hpi_message hm;
1480
1203
        struct hpi_response hr;
1492
1215
        return hr.error;
1493
1216
}
1494
1217
 
1495
 
u16 hpi_mixer_close(const struct hpi_hsubsys *ph_subsys, u32 h_mixer)
 
1218
u16 hpi_mixer_close(u32 h_mixer)
1496
1219
{
1497
1220
        struct hpi_message hm;
1498
1221
        struct hpi_response hr;
 
1222
 
1499
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
1227
        hpi_send_recv(&hm, &hr);
1502
1228
        return hr.error;
1503
1229
}
1504
1230
 
1505
 
u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer,
1506
 
        u16 src_node_type, u16 src_node_type_index, u16 dst_node_type,
1507
 
        u16 dst_node_type_index, u16 control_type, u32 *ph_control)
 
1231
u16 hpi_mixer_get_control(u32 h_mixer, u16 src_node_type,
 
1232
        u16 src_node_type_index, u16 dst_node_type, u16 dst_node_type_index,
 
1233
        u16 control_type, u32 *ph_control)
1508
1234
{
1509
1235
        struct hpi_message hm;
1510
1236
        struct hpi_response hr;
1511
1237
        hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER,
1512
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
1241
        hm.u.m.node_type1 = src_node_type;
1515
1242
        hm.u.m.node_index1 = src_node_type_index;
1516
1243
        hm.u.m.node_type2 = dst_node_type;
1528
1255
        return hr.error;
1529
1256
}
1530
1257
 
1531
 
u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys,
1532
 
        u32 h_mixer, u16 control_index, u16 *pw_src_node_type,
1533
 
        u16 *pw_src_node_index, u16 *pw_dst_node_type, u16 *pw_dst_node_index,
1534
 
        u16 *pw_control_type, u32 *ph_control)
 
1258
u16 hpi_mixer_get_control_by_index(u32 h_mixer, u16 control_index,
 
1259
        u16 *pw_src_node_type, u16 *pw_src_node_index, u16 *pw_dst_node_type,
 
1260
        u16 *pw_dst_node_index, u16 *pw_control_type, u32 *ph_control)
1535
1261
{
1536
1262
        struct hpi_message hm;
1537
1263
        struct hpi_response hr;
1538
1264
        hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER,
1539
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
1268
        hm.u.m.control_index = control_index;
1542
1269
        hpi_send_recv(&hm, &hr);
1543
1270
 
1562
1289
        return hr.error;
1563
1290
}
1564
1291
 
1565
 
u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer,
1566
 
        enum HPI_MIXER_STORE_COMMAND command, u16 index)
 
1292
u16 hpi_mixer_store(u32 h_mixer, enum HPI_MIXER_STORE_COMMAND command,
 
1293
        u16 index)
1567
1294
{
1568
1295
        struct hpi_message hm;
1569
1296
        struct hpi_response hr;
1570
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
1300
        hm.u.mx.store.command = command;
1573
1301
        hm.u.mx.store.index = index;
1574
1302
        hpi_send_recv(&hm, &hr);
1576
1304
}
1577
1305
 
1578
1306
static
1579
 
u16 hpi_control_param_set(const struct hpi_hsubsys *ph_subsys,
1580
 
        const u32 h_control, const u16 attrib, const u32 param1,
1581
 
        const u32 param2)
 
1307
u16 hpi_control_param_set(const u32 h_control, const u16 attrib,
 
1308
        const u32 param1, const u32 param2)
1582
1309
{
1583
1310
        struct hpi_message hm;
1584
1311
        struct hpi_response hr;
1585
1312
 
1586
1313
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1587
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
1317
        hm.u.c.attribute = attrib;
1590
1318
        hm.u.c.param1 = param1;
1591
1319
        hm.u.c.param2 = param2;
1601
1329
 
1602
1330
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1603
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
1334
        hm.u.c.attribute = attrib;
1606
1335
        hm.u.c.an_log_value[0] = sv0;
1607
1336
        hm.u.c.an_log_value[1] = sv1;
1610
1339
}
1611
1340
 
1612
1341
static
1613
 
u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys,
1614
 
        const u32 h_control, const u16 attrib, u32 param1, u32 param2,
1615
 
        u32 *pparam1, u32 *pparam2)
 
1342
u16 hpi_control_param_get(const u32 h_control, const u16 attrib, u32 param1,
 
1343
        u32 param2, u32 *pparam1, u32 *pparam2)
1616
1344
{
1617
1345
        struct hpi_message hm;
1618
1346
        struct hpi_response hr;
1619
1347
 
1620
1348
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1621
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
1352
        hm.u.c.attribute = attrib;
1624
1353
        hm.u.c.param1 = param1;
1625
1354
        hm.u.c.param2 = param2;
1632
1361
        return hr.error;
1633
1362
}
1634
1363
 
1635
 
#define hpi_control_param1_get(s, h, a, p1) \
1636
 
                hpi_control_param_get(s, h, a, 0, 0, p1, NULL)
1637
 
#define hpi_control_param2_get(s, h, a, p1, p2) \
1638
 
                hpi_control_param_get(s, h, a, 0, 0, p1, p2)
 
1364
#define hpi_control_param1_get(h, a, p1) \
 
1365
                hpi_control_param_get(h, a, 0, 0, p1, NULL)
 
1366
#define hpi_control_param2_get(h, a, p1, p2) \
 
1367
                hpi_control_param_get(h, a, 0, 0, p1, p2)
1639
1368
 
1640
 
static u16 hpi_control_log_get2(const struct hpi_hsubsys *ph_subsys,
1641
 
        u32 h_control, u16 attrib, short *sv0, short *sv1)
 
1369
static u16 hpi_control_log_get2(u32 h_control, u16 attrib, short *sv0,
 
1370
        short *sv1)
1642
1371
{
1643
1372
        struct hpi_message hm;
1644
1373
        struct hpi_response hr;
1645
1374
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1646
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
1378
        hm.u.c.attribute = attrib;
1649
1379
 
1650
1380
        hpi_send_recv(&hm, &hr);
1655
1385
}
1656
1386
 
1657
1387
static
1658
 
u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys,
1659
 
        const u32 h_control, const u16 attrib, const u32 index,
 
1388
u16 hpi_control_query(const u32 h_control, const u16 attrib, const u32 index,
1660
1389
        const u32 param, u32 *psetting)
1661
1390
{
1662
1391
        struct hpi_message hm;
1664
1393
 
1665
1394
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1666
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
1399
        hm.u.c.attribute = attrib;
1670
1400
        hm.u.c.param1 = index;
1682
1412
        unsigned int sub_string_index = 0, j = 0;
1683
1413
        char c = 0;
1684
1414
        unsigned int n = 0;
1685
 
        u16 hE = 0;
 
1415
        u16 err = 0;
1686
1416
 
1687
1417
        if ((string_length < 1) || (string_length > 256))
1688
1418
                return HPI_ERROR_INVALID_CONTROL_VALUE;
1693
1423
 
1694
1424
                hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1695
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
1429
                hm.u.c.attribute = attribute;
1698
1430
                hm.u.c.param1 = sub_string_index;
1699
1431
                hm.u.c.param2 = 0;
1705
1437
                        return HPI_ERROR_INVALID_CONTROL_VALUE;
1706
1438
 
1707
1439
                if (hr.error) {
1708
 
                        hE = hr.error;
 
1440
                        err = hr.error;
1709
1441
                        break;
1710
1442
                }
1711
1443
                for (j = 0; j < 8; j++) {
1714
1446
                        n++;
1715
1447
                        if (n >= string_length) {
1716
1448
                                psz_string[string_length - 1] = 0;
1717
 
                                hE = HPI_ERROR_INVALID_CONTROL_VALUE;
 
1449
                                err = HPI_ERROR_INVALID_CONTROL_VALUE;
1718
1450
                                break;
1719
1451
                        }
1720
1452
                        if (c == 0)
1730
1462
                if (c == 0)
1731
1463
                        break;
1732
1464
        }
1733
 
        return hE;
 
1465
        return err;
1734
1466
}
1735
1467
 
1736
 
u16 HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys *ph_subsys,
1737
 
        const u32 h_aes_rx, const u32 index, u16 *pw_format)
 
1468
u16 hpi_aesebu_receiver_query_format(const u32 h_aes_rx, const u32 index,
 
1469
        u16 *pw_format)
1738
1470
{
1739
1471
        u32 qr;
1740
1472
        u16 err;
1741
1473
 
1742
 
        err = hpi_control_query(ph_subsys, h_aes_rx, HPI_AESEBURX_FORMAT,
1743
 
                index, 0, &qr);
 
1474
        err = hpi_control_query(h_aes_rx, HPI_AESEBURX_FORMAT, index, 0, &qr);
1744
1475
        *pw_format = (u16)qr;
1745
1476
        return err;
1746
1477
}
1747
1478
 
1748
 
u16 HPI_AESEBU__receiver_set_format(const struct hpi_hsubsys *ph_subsys,
1749
 
        u32 h_control, u16 format)
 
1479
u16 hpi_aesebu_receiver_set_format(u32 h_control, u16 format)
1750
1480
{
1751
 
        return hpi_control_param_set(ph_subsys, h_control,
1752
 
                HPI_AESEBURX_FORMAT, format, 0);
 
1481
        return hpi_control_param_set(h_control, HPI_AESEBURX_FORMAT, format,
 
1482
                0);
1753
1483
}
1754
1484
 
1755
 
u16 HPI_AESEBU__receiver_get_format(const struct hpi_hsubsys *ph_subsys,
1756
 
        u32 h_control, u16 *pw_format)
 
1485
u16 hpi_aesebu_receiver_get_format(u32 h_control, u16 *pw_format)
1757
1486
{
1758
1487
        u16 err;
1759
1488
        u32 param;
1760
1489
 
1761
 
        err = hpi_control_param1_get(ph_subsys, h_control,
1762
 
                HPI_AESEBURX_FORMAT, &param);
 
1490
        err = hpi_control_param1_get(h_control, HPI_AESEBURX_FORMAT, &param);
1763
1491
        if (!err && pw_format)
1764
1492
                *pw_format = (u16)param;
1765
1493
 
1766
1494
        return err;
1767
1495
}
1768
1496
 
1769
 
u16 HPI_AESEBU__receiver_get_sample_rate(const struct hpi_hsubsys *ph_subsys,
1770
 
        u32 h_control, u32 *psample_rate)
 
1497
u16 hpi_aesebu_receiver_get_sample_rate(u32 h_control, u32 *psample_rate)
1771
1498
{
1772
 
        return hpi_control_param1_get(ph_subsys, h_control,
1773
 
                HPI_AESEBURX_SAMPLERATE, psample_rate);
 
1499
        return hpi_control_param1_get(h_control, HPI_AESEBURX_SAMPLERATE,
 
1500
                psample_rate);
1774
1501
}
1775
1502
 
1776
 
u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys,
1777
 
        u32 h_control, u16 index, u16 *pw_data)
 
1503
u16 hpi_aesebu_receiver_get_user_data(u32 h_control, u16 index, u16 *pw_data)
1778
1504
{
1779
1505
        struct hpi_message hm;
1780
1506
        struct hpi_response hr;
1781
1507
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1782
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
1511
        hm.u.c.attribute = HPI_AESEBURX_USERDATA;
1785
1512
        hm.u.c.param1 = index;
1786
1513
 
1791
1518
        return hr.error;
1792
1519
}
1793
1520
 
1794
 
u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys
1795
 
        *ph_subsys, u32 h_control, u16 index, u16 *pw_data)
 
1521
u16 hpi_aesebu_receiver_get_channel_status(u32 h_control, u16 index,
 
1522
        u16 *pw_data)
1796
1523
{
1797
1524
        struct hpi_message hm;
1798
1525
        struct hpi_response hr;
1799
1526
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1800
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
1530
        hm.u.c.attribute = HPI_AESEBURX_CHANNELSTATUS;
1803
1531
        hm.u.c.param1 = index;
1804
1532
 
1809
1537
        return hr.error;
1810
1538
}
1811
1539
 
1812
 
u16 HPI_AESEBU__receiver_get_error_status(const struct hpi_hsubsys *ph_subsys,
1813
 
        u32 h_control, u16 *pw_error_data)
 
1540
u16 hpi_aesebu_receiver_get_error_status(u32 h_control, u16 *pw_error_data)
1814
1541
{
1815
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,
1819
 
                HPI_AESEBURX_ERRORSTATUS, &error_data);
 
1545
        err = hpi_control_param1_get(h_control, HPI_AESEBURX_ERRORSTATUS,
 
1546
                &error_data);
1820
1547
        if (pw_error_data)
1821
1548
                *pw_error_data = (u16)error_data;
1822
 
        return error;
1823
 
}
1824
 
 
1825
 
u16 HPI_AESEBU__transmitter_set_sample_rate(const struct hpi_hsubsys
1826
 
        *ph_subsys, u32 h_control, u32 sample_rate)
1827
 
{
1828
 
        return hpi_control_param_set(ph_subsys, h_control,
1829
 
                HPI_AESEBUTX_SAMPLERATE, sample_rate, 0);
1830
 
}
1831
 
 
1832
 
u16 HPI_AESEBU__transmitter_set_user_data(const struct hpi_hsubsys *ph_subsys,
1833
 
        u32 h_control, u16 index, u16 data)
1834
 
{
1835
 
        return hpi_control_param_set(ph_subsys, h_control,
1836
 
                HPI_AESEBUTX_USERDATA, index, data);
1837
 
}
1838
 
 
1839
 
u16 HPI_AESEBU__transmitter_set_channel_status(const struct hpi_hsubsys
1840
 
        *ph_subsys, u32 h_control, u16 index, u16 data)
1841
 
{
1842
 
        return hpi_control_param_set(ph_subsys, h_control,
1843
 
                HPI_AESEBUTX_CHANNELSTATUS, index, data);
1844
 
}
1845
 
 
1846
 
u16 HPI_AESEBU__transmitter_get_channel_status(const struct hpi_hsubsys
1847
 
        *ph_subsys, u32 h_control, u16 index, u16 *pw_data)
 
1549
        return err;
 
1550
}
 
1551
 
 
1552
u16 hpi_aesebu_transmitter_set_sample_rate(u32 h_control, u32 sample_rate)
 
1553
{
 
1554
        return hpi_control_param_set(h_control, HPI_AESEBUTX_SAMPLERATE,
 
1555
                sample_rate, 0);
 
1556
}
 
1557
 
 
1558
u16 hpi_aesebu_transmitter_set_user_data(u32 h_control, u16 index, u16 data)
 
1559
{
 
1560
        return hpi_control_param_set(h_control, HPI_AESEBUTX_USERDATA, index,
 
1561
                data);
 
1562
}
 
1563
 
 
1564
u16 hpi_aesebu_transmitter_set_channel_status(u32 h_control, u16 index,
 
1565
        u16 data)
 
1566
{
 
1567
        return hpi_control_param_set(h_control, HPI_AESEBUTX_CHANNELSTATUS,
 
1568
                index, data);
 
1569
}
 
1570
 
 
1571
u16 hpi_aesebu_transmitter_get_channel_status(u32 h_control, u16 index,
 
1572
        u16 *pw_data)
1848
1573
{
1849
1574
        return HPI_ERROR_INVALID_OPERATION;
1850
1575
}
1851
1576
 
1852
 
u16 HPI_AESEBU__transmitter_query_format(const struct hpi_hsubsys *ph_subsys,
1853
 
        const u32 h_aes_tx, const u32 index, u16 *pw_format)
 
1577
u16 hpi_aesebu_transmitter_query_format(const u32 h_aes_tx, const u32 index,
 
1578
        u16 *pw_format)
1854
1579
{
1855
1580
        u32 qr;
1856
1581
        u16 err;
1857
1582
 
1858
 
        err = hpi_control_query(ph_subsys, h_aes_tx, HPI_AESEBUTX_FORMAT,
1859
 
                index, 0, &qr);
 
1583
        err = hpi_control_query(h_aes_tx, HPI_AESEBUTX_FORMAT, index, 0, &qr);
1860
1584
        *pw_format = (u16)qr;
1861
1585
        return err;
1862
1586
}
1863
1587
 
1864
 
u16 HPI_AESEBU__transmitter_set_format(const struct hpi_hsubsys *ph_subsys,
1865
 
        u32 h_control, u16 output_format)
 
1588
u16 hpi_aesebu_transmitter_set_format(u32 h_control, u16 output_format)
1866
1589
{
1867
 
        return hpi_control_param_set(ph_subsys, h_control,
1868
 
                HPI_AESEBUTX_FORMAT, output_format, 0);
 
1590
        return hpi_control_param_set(h_control, HPI_AESEBUTX_FORMAT,
 
1591
                output_format, 0);
1869
1592
}
1870
1593
 
1871
 
u16 HPI_AESEBU__transmitter_get_format(const struct hpi_hsubsys *ph_subsys,
1872
 
        u32 h_control, u16 *pw_output_format)
 
1594
u16 hpi_aesebu_transmitter_get_format(u32 h_control, u16 *pw_output_format)
1873
1595
{
1874
1596
        u16 err;
1875
1597
        u32 param;
1876
1598
 
1877
 
        err = hpi_control_param1_get(ph_subsys, h_control,
1878
 
                HPI_AESEBUTX_FORMAT, &param);
 
1599
        err = hpi_control_param1_get(h_control, HPI_AESEBUTX_FORMAT, &param);
1879
1600
        if (!err && pw_output_format)
1880
1601
                *pw_output_format = (u16)param;
1881
1602
 
1882
1603
        return err;
1883
1604
}
1884
1605
 
1885
 
u16 hpi_bitstream_set_clock_edge(const struct hpi_hsubsys *ph_subsys,
1886
 
        u32 h_control, u16 edge_type)
1887
 
{
1888
 
        return hpi_control_param_set(ph_subsys, h_control,
1889
 
                HPI_BITSTREAM_CLOCK_EDGE, edge_type, 0);
1890
 
}
1891
 
 
1892
 
u16 hpi_bitstream_set_data_polarity(const struct hpi_hsubsys *ph_subsys,
1893
 
        u32 h_control, u16 polarity)
1894
 
{
1895
 
        return hpi_control_param_set(ph_subsys, h_control,
1896
 
                HPI_BITSTREAM_DATA_POLARITY, polarity, 0);
1897
 
}
1898
 
 
1899
 
u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys,
1900
 
        u32 h_control, u16 *pw_clk_activity, u16 *pw_data_activity)
 
1606
u16 hpi_bitstream_set_clock_edge(u32 h_control, u16 edge_type)
 
1607
{
 
1608
        return hpi_control_param_set(h_control, HPI_BITSTREAM_CLOCK_EDGE,
 
1609
                edge_type, 0);
 
1610
}
 
1611
 
 
1612
u16 hpi_bitstream_set_data_polarity(u32 h_control, u16 polarity)
 
1613
{
 
1614
        return hpi_control_param_set(h_control, HPI_BITSTREAM_DATA_POLARITY,
 
1615
                polarity, 0);
 
1616
}
 
1617
 
 
1618
u16 hpi_bitstream_get_activity(u32 h_control, u16 *pw_clk_activity,
 
1619
        u16 *pw_data_activity)
1901
1620
{
1902
1621
        struct hpi_message hm;
1903
1622
        struct hpi_response hr;
1904
1623
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1905
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
1627
        hm.u.c.attribute = HPI_BITSTREAM_ACTIVITY;
1908
1628
        hpi_send_recv(&hm, &hr);
1909
1629
        if (pw_clk_activity)
1913
1633
        return hr.error;
1914
1634
}
1915
1635
 
1916
 
u16 hpi_channel_mode_query_mode(const struct hpi_hsubsys *ph_subsys,
1917
 
        const u32 h_mode, const u32 index, u16 *pw_mode)
 
1636
u16 hpi_channel_mode_query_mode(const u32 h_mode, const u32 index,
 
1637
        u16 *pw_mode)
1918
1638
{
1919
1639
        u32 qr;
1920
1640
        u16 err;
1921
1641
 
1922
 
        err = hpi_control_query(ph_subsys, h_mode, HPI_CHANNEL_MODE_MODE,
1923
 
                index, 0, &qr);
 
1642
        err = hpi_control_query(h_mode, HPI_CHANNEL_MODE_MODE, index, 0, &qr);
1924
1643
        *pw_mode = (u16)qr;
1925
1644
        return err;
1926
1645
}
1927
1646
 
1928
 
u16 hpi_channel_mode_set(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1929
 
        u16 mode)
 
1647
u16 hpi_channel_mode_set(u32 h_control, u16 mode)
1930
1648
{
1931
 
        return hpi_control_param_set(ph_subsys, h_control,
1932
 
                HPI_CHANNEL_MODE_MODE, mode, 0);
 
1649
        return hpi_control_param_set(h_control, HPI_CHANNEL_MODE_MODE, mode,
 
1650
                0);
1933
1651
}
1934
1652
 
1935
 
u16 hpi_channel_mode_get(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1936
 
        u16 *mode)
 
1653
u16 hpi_channel_mode_get(u32 h_control, u16 *mode)
1937
1654
{
1938
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
1657
                HPI_CHANNEL_MODE_MODE, &mode32);
1941
1658
        if (mode)
1942
1659
                *mode = (u16)mode32;
1943
 
        return error;
 
1660
        return err;
1944
1661
}
1945
1662
 
1946
 
u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1947
 
        u32 hmi_address, u32 byte_count, u8 *pb_data)
 
1663
u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count,
 
1664
        u8 *pb_data)
1948
1665
{
1949
1666
        struct hpi_message hm;
1950
1667
        struct hpi_response hr;
1951
1668
 
1952
1669
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
1953
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
1674
        hm.u.cx.u.cobranet_data.byte_count = byte_count;
1957
1675
        hm.u.cx.u.cobranet_data.hmi_address = hmi_address;
1969
1687
        return hr.error;
1970
1688
}
1971
1689
 
1972
 
u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1973
 
        u32 hmi_address, u32 max_byte_count, u32 *pbyte_count, u8 *pb_data)
 
1690
u16 hpi_cobranet_hmi_read(u32 h_control, u32 hmi_address, u32 max_byte_count,
 
1691
        u32 *pbyte_count, u8 *pb_data)
1974
1692
{
1975
1693
        struct hpi_message hm;
1976
1694
        struct hpi_response hr;
1977
1695
 
1978
1696
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
1979
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
1701
        hm.u.cx.u.cobranet_data.byte_count = max_byte_count;
1983
1702
        hm.u.cx.u.cobranet_data.hmi_address = hmi_address;
2008
1727
        return hr.error;
2009
1728
}
2010
1729
 
2011
 
u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys,
2012
 
        u32 h_control, u32 *pstatus, u32 *preadable_size,
2013
 
        u32 *pwriteable_size)
 
1730
u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus,
 
1731
        u32 *preadable_size, u32 *pwriteable_size)
2014
1732
{
2015
1733
        struct hpi_message hm;
2016
1734
        struct hpi_response hr;
2017
1735
 
2018
1736
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
2019
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
1741
        hm.u.cx.attribute = HPI_COBRANET_GET_STATUS;
2023
1742
 
2035
1754
        return hr.error;
2036
1755
}
2037
1756
 
2038
 
u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys,
2039
 
        u32 h_control, u32 *pi_paddress)
 
1757
u16 hpi_cobranet_get_ip_address(u32 h_control, u32 *pdw_ip_address)
2040
1758
{
2041
1759
        u32 byte_count;
2042
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
1764
                HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count,
2047
1765
                (u8 *)&iP);
2048
1766
 
2049
 
        *pi_paddress =
 
1767
        *pdw_ip_address =
2050
1768
                ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
2051
1769
                        0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
2052
1770
 
2053
 
        if (error)
2054
 
                *pi_paddress = 0;
 
1771
        if (err)
 
1772
                *pdw_ip_address = 0;
2055
1773
 
2056
 
        return error;
 
1774
        return err;
2057
1775
 
2058
1776
}
2059
1777
 
2060
 
u16 hpi_cobranet_setI_paddress(const struct hpi_hsubsys *ph_subsys,
2061
 
        u32 h_control, u32 i_paddress)
 
1778
u16 hpi_cobranet_set_ip_address(u32 h_control, u32 dw_ip_address)
2062
1779
{
2063
1780
        u32 iP;
2064
 
        u16 error;
2065
 
 
2066
 
        iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) <<
2067
 
                8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress &
2068
 
                        0x000000ff) << 8);
2069
 
 
2070
 
        error = hpi_cobranet_hmi_write(ph_subsys, h_control,
 
1781
        u16 err;
 
1782
 
 
1783
        iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
 
1784
                        0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
 
1785
                8) | ((dw_ip_address & 0x000000ff) << 8);
 
1786
 
 
1787
        err = hpi_cobranet_hmi_write(h_control,
2071
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
 
2077
 
u16 hpi_cobranet_get_staticI_paddress(const struct hpi_hsubsys *ph_subsys,
2078
 
        u32 h_control, u32 *pi_paddress)
 
1794
u16 hpi_cobranet_get_static_ip_address(u32 h_control, u32 *pdw_ip_address)
2079
1795
{
2080
1796
        u32 byte_count;
2081
1797
        u32 iP;
2082
 
        u16 error;
2083
 
        error = hpi_cobranet_hmi_read(ph_subsys, h_control,
 
1798
        u16 err;
 
1799
        err = hpi_cobranet_hmi_read(h_control,
2084
1800
                HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count,
2085
1801
                (u8 *)&iP);
2086
1802
 
2087
 
        *pi_paddress =
 
1803
        *pdw_ip_address =
2088
1804
                ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
2089
1805
                        0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
2090
1806
 
2091
 
        if (error)
2092
 
                *pi_paddress = 0;
 
1807
        if (err)
 
1808
                *pdw_ip_address = 0;
2093
1809
 
2094
 
        return error;
 
1810
        return err;
2095
1811
 
2096
1812
}
2097
1813
 
2098
 
u16 hpi_cobranet_set_staticI_paddress(const struct hpi_hsubsys *ph_subsys,
2099
 
        u32 h_control, u32 i_paddress)
 
1814
u16 hpi_cobranet_set_static_ip_address(u32 h_control, u32 dw_ip_address)
2100
1815
{
2101
1816
        u32 iP;
2102
 
        u16 error;
2103
 
 
2104
 
        iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) <<
2105
 
                8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress &
2106
 
                        0x000000ff) << 8);
2107
 
 
2108
 
        error = hpi_cobranet_hmi_write(ph_subsys, h_control,
 
1817
        u16 err;
 
1818
 
 
1819
        iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
 
1820
                        0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
 
1821
                8) | ((dw_ip_address & 0x000000ff) << 8);
 
1822
 
 
1823
        err = hpi_cobranet_hmi_write(h_control,
2109
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
 
2115
 
u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys,
2116
 
        u32 h_control, u32 *pmAC_MS_bs, u32 *pmAC_LS_bs)
 
1830
u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *p_mac_msbs,
 
1831
        u32 *p_mac_lsbs)
2117
1832
{
2118
1833
        u32 byte_count;
2119
 
        u16 error;
2120
 
        u32 mAC;
 
1834
        u16 err;
 
1835
        u32 mac;
2121
1836
 
2122
 
        error = hpi_cobranet_hmi_read(ph_subsys, h_control,
 
1837
        err = hpi_cobranet_hmi_read(h_control,
2123
1838
                HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count,
2124
 
                (u8 *)&mAC);
2125
 
        *pmAC_MS_bs =
2126
 
                ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC
2127
 
                        & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8);
2128
 
        error += hpi_cobranet_hmi_read(ph_subsys, h_control,
2129
 
                HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4, &byte_count,
2130
 
                (u8 *)&mAC);
2131
 
        *pmAC_LS_bs =
2132
 
                ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC
2133
 
                        & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8);
2134
 
 
2135
 
        if (error) {
2136
 
                *pmAC_MS_bs = 0;
2137
 
                *pmAC_LS_bs = 0;
2138
 
        }
2139
 
 
2140
 
        return error;
2141
 
}
2142
 
 
2143
 
u16 hpi_compander_set_enable(const struct hpi_hsubsys *ph_subsys,
2144
 
        u32 h_control, u32 enable)
2145
 
{
2146
 
        return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE,
2147
 
                enable, 0);
2148
 
}
2149
 
 
2150
 
u16 hpi_compander_get_enable(const struct hpi_hsubsys *ph_subsys,
2151
 
        u32 h_control, u32 *enable)
2152
 
{
2153
 
        return hpi_control_param1_get(ph_subsys, h_control,
2154
 
                HPI_GENERIC_ENABLE, enable);
2155
 
}
2156
 
 
2157
 
u16 hpi_compander_set_makeup_gain(const struct hpi_hsubsys *ph_subsys,
2158
 
        u32 h_control, short makeup_gain0_01dB)
 
1839
                (u8 *)&mac);
 
1840
 
 
1841
        if (!err) {
 
1842
                *p_mac_msbs =
 
1843
                        ((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8)
 
1844
                        | ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) <<
 
1845
                        8);
 
1846
 
 
1847
                err = hpi_cobranet_hmi_read(h_control,
 
1848
                        HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4,
 
1849
                        &byte_count, (u8 *)&mac);
 
1850
        }
 
1851
 
 
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;
 
1863
}
 
1864
 
 
1865
u16 hpi_compander_set_enable(u32 h_control, u32 enable)
 
1866
{
 
1867
        return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
 
1868
                0);
 
1869
}
 
1870
 
 
1871
u16 hpi_compander_get_enable(u32 h_control, u32 *enable)
 
1872
{
 
1873
        return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
 
1874
}
 
1875
 
 
1876
u16 hpi_compander_set_makeup_gain(u32 h_control, short makeup_gain0_01dB)
2159
1877
{
2160
1878
        return hpi_control_log_set2(h_control, HPI_COMPANDER_MAKEUPGAIN,
2161
1879
                makeup_gain0_01dB, 0);
2162
1880
}
2163
1881
 
2164
 
u16 hpi_compander_get_makeup_gain(const struct hpi_hsubsys *ph_subsys,
2165
 
        u32 h_control, short *makeup_gain0_01dB)
2166
 
{
2167
 
        return hpi_control_log_get2(ph_subsys, h_control,
2168
 
                HPI_COMPANDER_MAKEUPGAIN, makeup_gain0_01dB, NULL);
2169
 
}
2170
 
 
2171
 
u16 hpi_compander_set_attack_time_constant(const struct hpi_hsubsys
2172
 
        *ph_subsys, u32 h_control, unsigned int index, u32 attack)
2173
 
{
2174
 
        return hpi_control_param_set(ph_subsys, h_control,
2175
 
                HPI_COMPANDER_ATTACK, attack, index);
2176
 
}
2177
 
 
2178
 
u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys
2179
 
        *ph_subsys, u32 h_control, unsigned int index, u32 *attack)
2180
 
{
2181
 
        return hpi_control_param_get(ph_subsys, h_control,
2182
 
                HPI_COMPANDER_ATTACK, 0, index, attack, NULL);
2183
 
}
2184
 
 
2185
 
u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
2186
 
        u32 h_control, unsigned int index, u32 decay)
2187
 
{
2188
 
        return hpi_control_param_set(ph_subsys, h_control,
2189
 
                HPI_COMPANDER_DECAY, decay, index);
2190
 
}
2191
 
 
2192
 
u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
2193
 
        u32 h_control, unsigned int index, u32 *decay)
2194
 
{
2195
 
        return hpi_control_param_get(ph_subsys, h_control,
2196
 
                HPI_COMPANDER_DECAY, 0, index, decay, NULL);
2197
 
 
2198
 
}
2199
 
 
2200
 
u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys,
2201
 
        u32 h_control, unsigned int index, short threshold0_01dB)
 
1882
u16 hpi_compander_get_makeup_gain(u32 h_control, short *makeup_gain0_01dB)
 
1883
{
 
1884
        return hpi_control_log_get2(h_control, HPI_COMPANDER_MAKEUPGAIN,
 
1885
                makeup_gain0_01dB, NULL);
 
1886
}
 
1887
 
 
1888
u16 hpi_compander_set_attack_time_constant(u32 h_control, unsigned int index,
 
1889
        u32 attack)
 
1890
{
 
1891
        return hpi_control_param_set(h_control, HPI_COMPANDER_ATTACK, attack,
 
1892
                index);
 
1893
}
 
1894
 
 
1895
u16 hpi_compander_get_attack_time_constant(u32 h_control, unsigned int index,
 
1896
        u32 *attack)
 
1897
{
 
1898
        return hpi_control_param_get(h_control, HPI_COMPANDER_ATTACK, 0,
 
1899
                index, attack, NULL);
 
1900
}
 
1901
 
 
1902
u16 hpi_compander_set_decay_time_constant(u32 h_control, unsigned int index,
 
1903
        u32 decay)
 
1904
{
 
1905
        return hpi_control_param_set(h_control, HPI_COMPANDER_DECAY, decay,
 
1906
                index);
 
1907
}
 
1908
 
 
1909
u16 hpi_compander_get_decay_time_constant(u32 h_control, unsigned int index,
 
1910
        u32 *decay)
 
1911
{
 
1912
        return hpi_control_param_get(h_control, HPI_COMPANDER_DECAY, 0, index,
 
1913
                decay, NULL);
 
1914
 
 
1915
}
 
1916
 
 
1917
u16 hpi_compander_set_threshold(u32 h_control, unsigned int index,
 
1918
        short threshold0_01dB)
2202
1919
{
2203
1920
        struct hpi_message hm;
2204
1921
        struct hpi_response hr;
2205
1922
 
2206
1923
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2207
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
1927
        hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
2210
1928
        hm.u.c.param2 = index;
2211
1929
        hm.u.c.an_log_value[0] = threshold0_01dB;
2215
1933
        return hr.error;
2216
1934
}
2217
1935
 
2218
 
u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys,
2219
 
        u32 h_control, unsigned int index, short *threshold0_01dB)
 
1936
u16 hpi_compander_get_threshold(u32 h_control, unsigned int index,
 
1937
        short *threshold0_01dB)
2220
1938
{
2221
1939
        struct hpi_message hm;
2222
1940
        struct hpi_response hr;
2223
1941
 
2224
1942
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2225
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
1946
        hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
2228
1947
        hm.u.c.param2 = index;
2229
1948
 
2233
1952
        return hr.error;
2234
1953
}
2235
1954
 
2236
 
u16 hpi_compander_set_ratio(const struct hpi_hsubsys *ph_subsys,
2237
 
        u32 h_control, u32 index, u32 ratio100)
2238
 
{
2239
 
        return hpi_control_param_set(ph_subsys, h_control,
2240
 
                HPI_COMPANDER_RATIO, ratio100, index);
2241
 
}
2242
 
 
2243
 
u16 hpi_compander_get_ratio(const struct hpi_hsubsys *ph_subsys,
2244
 
        u32 h_control, u32 index, u32 *ratio100)
2245
 
{
2246
 
        return hpi_control_param_get(ph_subsys, h_control,
2247
 
                HPI_COMPANDER_RATIO, 0, index, ratio100, NULL);
2248
 
}
2249
 
 
2250
 
u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2251
 
        short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB)
 
1955
u16 hpi_compander_set_ratio(u32 h_control, u32 index, u32 ratio100)
 
1956
{
 
1957
        return hpi_control_param_set(h_control, HPI_COMPANDER_RATIO, ratio100,
 
1958
                index);
 
1959
}
 
1960
 
 
1961
u16 hpi_compander_get_ratio(u32 h_control, u32 index, u32 *ratio100)
 
1962
{
 
1963
        return hpi_control_param_get(h_control, HPI_COMPANDER_RATIO, 0, index,
 
1964
                ratio100, NULL);
 
1965
}
 
1966
 
 
1967
u16 hpi_level_query_range(u32 h_control, short *min_gain_01dB,
 
1968
        short *max_gain_01dB, short *step_gain_01dB)
2252
1969
{
2253
1970
        struct hpi_message hm;
2254
1971
        struct hpi_response hr;
2255
1972
 
2256
1973
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2257
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
1977
        hm.u.c.attribute = HPI_LEVEL_RANGE;
2260
1978
 
2261
1979
        hpi_send_recv(&hm, &hr);
2273
1991
        return hr.error;
2274
1992
}
2275
1993
 
2276
 
u16 hpi_level_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2277
 
        short an_gain0_01dB[HPI_MAX_CHANNELS]
 
1994
u16 hpi_level_set_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
2278
1995
        )
2279
1996
{
2280
1997
        return hpi_control_log_set2(h_control, HPI_LEVEL_GAIN,
2281
1998
                an_gain0_01dB[0], an_gain0_01dB[1]);
2282
1999
}
2283
2000
 
2284
 
u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2285
 
        short an_gain0_01dB[HPI_MAX_CHANNELS]
 
2001
u16 hpi_level_get_gain(u32 h_control, 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
2005
                &an_gain0_01dB[0], &an_gain0_01dB[1]);
2290
2006
}
2291
2007
 
2292
 
u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys,
2293
 
        const u32 h_meter, u32 *p_channels)
 
2008
u16 hpi_meter_query_channels(const u32 h_meter, u32 *p_channels)
2294
2009
{
2295
 
        return hpi_control_query(ph_subsys, h_meter, HPI_METER_NUM_CHANNELS,
2296
 
                0, 0, p_channels);
 
2010
        return hpi_control_query(h_meter, HPI_METER_NUM_CHANNELS, 0, 0,
 
2011
                p_channels);
2297
2012
}
2298
2013
 
2299
 
u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2300
 
        short an_peakdB[HPI_MAX_CHANNELS]
 
2014
u16 hpi_meter_get_peak(u32 h_control, short an_peakdB[HPI_MAX_CHANNELS]
2301
2015
        )
2302
2016
{
2303
2017
        short i = 0;
2307
2021
 
2308
2022
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2309
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
2026
        hm.obj_index = hm.obj_index;
2312
2027
        hm.u.c.attribute = HPI_METER_PEAK;
2313
2028
 
2322
2037
        return hr.error;
2323
2038
}
2324
2039
 
2325
 
u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2326
 
        short an_rmsdB[HPI_MAX_CHANNELS]
 
2040
u16 hpi_meter_get_rms(u32 h_control, short an_rmsdB[HPI_MAX_CHANNELS]
2327
2041
        )
2328
2042
{
2329
2043
        short i = 0;
2333
2047
 
2334
2048
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2335
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
2052
        hm.u.c.attribute = HPI_METER_RMS;
2338
2053
 
2339
2054
        hpi_send_recv(&hm, &hr);
2348
2063
        return hr.error;
2349
2064
}
2350
2065
 
2351
 
u16 hpi_meter_set_rms_ballistics(const struct hpi_hsubsys *ph_subsys,
2352
 
        u32 h_control, u16 attack, u16 decay)
 
2066
u16 hpi_meter_set_rms_ballistics(u32 h_control, u16 attack, u16 decay)
2353
2067
{
2354
 
        return hpi_control_param_set(ph_subsys, h_control,
2355
 
                HPI_METER_RMS_BALLISTICS, attack, decay);
 
2068
        return hpi_control_param_set(h_control, HPI_METER_RMS_BALLISTICS,
 
2069
                attack, decay);
2356
2070
}
2357
2071
 
2358
 
u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys,
2359
 
        u32 h_control, u16 *pn_attack, u16 *pn_decay)
 
2072
u16 hpi_meter_get_rms_ballistics(u32 h_control, u16 *pn_attack, u16 *pn_decay)
2360
2073
{
2361
2074
        u32 attack;
2362
2075
        u32 decay;
2363
2076
        u16 error;
2364
2077
 
2365
 
        error = hpi_control_param2_get(ph_subsys, h_control,
2366
 
                HPI_METER_RMS_BALLISTICS, &attack, &decay);
 
2078
        error = hpi_control_param2_get(h_control, HPI_METER_RMS_BALLISTICS,
 
2079
                &attack, &decay);
2367
2080
 
2368
2081
        if (pn_attack)
2369
2082
                *pn_attack = (unsigned short)attack;
2373
2086
        return error;
2374
2087
}
2375
2088
 
2376
 
u16 hpi_meter_set_peak_ballistics(const struct hpi_hsubsys *ph_subsys,
2377
 
        u32 h_control, u16 attack, u16 decay)
 
2089
u16 hpi_meter_set_peak_ballistics(u32 h_control, u16 attack, u16 decay)
2378
2090
{
2379
 
        return hpi_control_param_set(ph_subsys, h_control,
2380
 
                HPI_METER_PEAK_BALLISTICS, attack, decay);
 
2091
        return hpi_control_param_set(h_control, HPI_METER_PEAK_BALLISTICS,
 
2092
                attack, decay);
2381
2093
}
2382
2094
 
2383
 
u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys,
2384
 
        u32 h_control, u16 *pn_attack, u16 *pn_decay)
 
2095
u16 hpi_meter_get_peak_ballistics(u32 h_control, u16 *pn_attack,
 
2096
        u16 *pn_decay)
2385
2097
{
2386
2098
        u32 attack;
2387
2099
        u32 decay;
2388
2100
        u16 error;
2389
2101
 
2390
 
        error = hpi_control_param2_get(ph_subsys, h_control,
2391
 
                HPI_METER_PEAK_BALLISTICS, &attack, &decay);
 
2102
        error = hpi_control_param2_get(h_control, HPI_METER_PEAK_BALLISTICS,
 
2103
                &attack, &decay);
2392
2104
 
2393
2105
        if (pn_attack)
2394
2106
                *pn_attack = (short)attack;
2398
2110
        return error;
2399
2111
}
2400
2112
 
2401
 
u16 hpi_microphone_set_phantom_power(const struct hpi_hsubsys *ph_subsys,
2402
 
        u32 h_control, u16 on_off)
 
2113
u16 hpi_microphone_set_phantom_power(u32 h_control, u16 on_off)
2403
2114
{
2404
 
        return hpi_control_param_set(ph_subsys, h_control,
2405
 
                HPI_MICROPHONE_PHANTOM_POWER, (u32)on_off, 0);
 
2115
        return hpi_control_param_set(h_control, HPI_MICROPHONE_PHANTOM_POWER,
 
2116
                (u32)on_off, 0);
2406
2117
}
2407
2118
 
2408
 
u16 hpi_microphone_get_phantom_power(const struct hpi_hsubsys *ph_subsys,
2409
 
        u32 h_control, u16 *pw_on_off)
 
2119
u16 hpi_microphone_get_phantom_power(u32 h_control, u16 *pw_on_off)
2410
2120
{
2411
2121
        u16 error = 0;
2412
2122
        u32 on_off = 0;
2413
 
        error = hpi_control_param1_get(ph_subsys, h_control,
 
2123
        error = hpi_control_param1_get(h_control,
2414
2124
                HPI_MICROPHONE_PHANTOM_POWER, &on_off);
2415
2125
        if (pw_on_off)
2416
2126
                *pw_on_off = (u16)on_off;
2417
2127
        return error;
2418
2128
}
2419
2129
 
2420
 
u16 hpi_multiplexer_set_source(const struct hpi_hsubsys *ph_subsys,
2421
 
        u32 h_control, u16 source_node_type, u16 source_node_index)
 
2130
u16 hpi_multiplexer_set_source(u32 h_control, u16 source_node_type,
 
2131
        u16 source_node_index)
2422
2132
{
2423
 
        return hpi_control_param_set(ph_subsys, h_control,
2424
 
                HPI_MULTIPLEXER_SOURCE, source_node_type, source_node_index);
 
2133
        return hpi_control_param_set(h_control, HPI_MULTIPLEXER_SOURCE,
 
2134
                source_node_type, source_node_index);
2425
2135
}
2426
2136
 
2427
 
u16 hpi_multiplexer_get_source(const struct hpi_hsubsys *ph_subsys,
2428
 
        u32 h_control, u16 *source_node_type, u16 *source_node_index)
 
2137
u16 hpi_multiplexer_get_source(u32 h_control, u16 *source_node_type,
 
2138
        u16 *source_node_index)
2429
2139
{
2430
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
2142
                HPI_MULTIPLEXER_SOURCE, &node,
2433
2143
                &index);
2434
2144
        if (source_node_type)
2435
2145
                *source_node_type = (u16)node;
2436
2146
        if (source_node_index)
2437
2147
                *source_node_index = (u16)index;
2438
 
        return error;
 
2148
        return err;
2439
2149
}
2440
2150
 
2441
 
u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys,
2442
 
        u32 h_control, u16 index, u16 *source_node_type,
2443
 
        u16 *source_node_index)
 
2151
u16 hpi_multiplexer_query_source(u32 h_control, u16 index,
 
2152
        u16 *source_node_type, u16 *source_node_index)
2444
2153
{
2445
2154
        struct hpi_message hm;
2446
2155
        struct hpi_response hr;
2447
2156
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2448
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
2160
        hm.u.c.attribute = HPI_MULTIPLEXER_QUERYSOURCE;
2451
2161
        hm.u.c.param1 = index;
2452
2162
 
2459
2169
        return hr.error;
2460
2170
}
2461
2171
 
2462
 
u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys,
2463
 
        u32 h_control, u16 *pw_number_of_bands, u16 *pw_on_off)
 
2172
u16 hpi_parametric_eq_get_info(u32 h_control, u16 *pw_number_of_bands,
 
2173
        u16 *pw_on_off)
2464
2174
{
2465
2175
        u32 oB = 0;
2466
2176
        u32 oO = 0;
2467
2177
        u16 error = 0;
2468
2178
 
2469
 
        error = hpi_control_param2_get(ph_subsys, h_control,
2470
 
                HPI_EQUALIZER_NUM_FILTERS, &oO, &oB);
 
2179
        error = hpi_control_param2_get(h_control, HPI_EQUALIZER_NUM_FILTERS,
 
2180
                &oO, &oB);
2471
2181
        if (pw_number_of_bands)
2472
2182
                *pw_number_of_bands = (u16)oB;
2473
2183
        if (pw_on_off)
2475
2185
        return error;
2476
2186
}
2477
2187
 
2478
 
u16 hpi_parametricEQ__set_state(const struct hpi_hsubsys *ph_subsys,
2479
 
        u32 h_control, u16 on_off)
 
2188
u16 hpi_parametric_eq_set_state(u32 h_control, u16 on_off)
2480
2189
{
2481
 
        return hpi_control_param_set(ph_subsys, h_control,
2482
 
                HPI_EQUALIZER_NUM_FILTERS, on_off, 0);
 
2190
        return hpi_control_param_set(h_control, HPI_EQUALIZER_NUM_FILTERS,
 
2191
                on_off, 0);
2483
2192
}
2484
2193
 
2485
 
u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys,
2486
 
        u32 h_control, u16 index, u16 *pn_type, u32 *pfrequency_hz,
2487
 
        short *pnQ100, short *pn_gain0_01dB)
 
2194
u16 hpi_parametric_eq_get_band(u32 h_control, u16 index, u16 *pn_type,
 
2195
        u32 *pfrequency_hz, short *pnQ100, short *pn_gain0_01dB)
2488
2196
{
2489
2197
        struct hpi_message hm;
2490
2198
        struct hpi_response hr;
2491
2199
 
2492
2200
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2493
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
2204
        hm.u.c.attribute = HPI_EQUALIZER_FILTER;
2496
2205
        hm.u.c.param2 = index;
2497
2206
 
2509
2218
        return hr.error;
2510
2219
}
2511
2220
 
2512
 
u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys,
2513
 
        u32 h_control, u16 index, u16 type, u32 frequency_hz, short q100,
2514
 
        short gain0_01dB)
 
2221
u16 hpi_parametric_eq_set_band(u32 h_control, u16 index, u16 type,
 
2222
        u32 frequency_hz, short q100, short gain0_01dB)
2515
2223
{
2516
2224
        struct hpi_message hm;
2517
2225
        struct hpi_response hr;
2518
2226
 
2519
2227
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2520
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
2232
        hm.u.c.param1 = frequency_hz;
2524
2233
        hm.u.c.param2 = (index & 0xFFFFL) + ((u32)type << 16);
2531
2240
        return hr.error;
2532
2241
}
2533
2242
 
2534
 
u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys,
2535
 
        u32 h_control, u16 index, short coeffs[5]
 
2243
u16 hpi_parametric_eq_get_coeffs(u32 h_control, u16 index, short coeffs[5]
2536
2244
        )
2537
2245
{
2538
2246
        struct hpi_message hm;
2540
2248
 
2541
2249
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2542
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
2253
        hm.u.c.attribute = HPI_EQUALIZER_COEFFICIENTS;
2545
2254
        hm.u.c.param2 = index;
2546
2255
 
2555
2264
        return hr.error;
2556
2265
}
2557
2266
 
2558
 
u16 hpi_sample_clock_query_source(const struct hpi_hsubsys *ph_subsys,
2559
 
        const u32 h_clock, const u32 index, u16 *pw_source)
 
2267
u16 hpi_sample_clock_query_source(const u32 h_clock, const u32 index,
 
2268
        u16 *pw_source)
2560
2269
{
2561
2270
        u32 qr;
2562
2271
        u16 err;
2563
2272
 
2564
 
        err = hpi_control_query(ph_subsys, h_clock, HPI_SAMPLECLOCK_SOURCE,
2565
 
                index, 0, &qr);
 
2273
        err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE, index, 0,
 
2274
                &qr);
2566
2275
        *pw_source = (u16)qr;
2567
2276
        return err;
2568
2277
}
2569
2278
 
2570
 
u16 hpi_sample_clock_set_source(const struct hpi_hsubsys *ph_subsys,
2571
 
        u32 h_control, u16 source)
 
2279
u16 hpi_sample_clock_set_source(u32 h_control, u16 source)
2572
2280
{
2573
 
        return hpi_control_param_set(ph_subsys, h_control,
2574
 
                HPI_SAMPLECLOCK_SOURCE, source, 0);
 
2281
        return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE,
 
2282
                source, 0);
2575
2283
}
2576
2284
 
2577
 
u16 hpi_sample_clock_get_source(const struct hpi_hsubsys *ph_subsys,
2578
 
        u32 h_control, u16 *pw_source)
 
2285
u16 hpi_sample_clock_get_source(u32 h_control, u16 *pw_source)
2579
2286
{
2580
 
        u16 error = 0;
 
2287
        u16 err = 0;
2581
2288
        u32 source = 0;
2582
 
        error = hpi_control_param1_get(ph_subsys, h_control,
2583
 
                HPI_SAMPLECLOCK_SOURCE, &source);
2584
 
        if (!error)
 
2289
        err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE,
 
2290
                &source);
 
2291
        if (!err)
2585
2292
                if (pw_source)
2586
2293
                        *pw_source = (u16)source;
2587
 
        return error;
 
2294
        return err;
2588
2295
}
2589
2296
 
2590
 
u16 hpi_sample_clock_query_source_index(const struct hpi_hsubsys *ph_subsys,
2591
 
        const u32 h_clock, const u32 index, const u32 source,
2592
 
        u16 *pw_source_index)
 
2297
u16 hpi_sample_clock_query_source_index(const u32 h_clock, const u32 index,
 
2298
        const u32 source, u16 *pw_source_index)
2593
2299
{
2594
2300
        u32 qr;
2595
2301
        u16 err;
2596
2302
 
2597
 
        err = hpi_control_query(ph_subsys, h_clock,
2598
 
                HPI_SAMPLECLOCK_SOURCE_INDEX, index, source, &qr);
 
2303
        err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE_INDEX, index,
 
2304
                source, &qr);
2599
2305
        *pw_source_index = (u16)qr;
2600
2306
        return err;
2601
2307
}
2602
2308
 
2603
 
u16 hpi_sample_clock_set_source_index(const struct hpi_hsubsys *ph_subsys,
2604
 
        u32 h_control, u16 source_index)
 
2309
u16 hpi_sample_clock_set_source_index(u32 h_control, u16 source_index)
2605
2310
{
2606
 
        return hpi_control_param_set(ph_subsys, h_control,
2607
 
                HPI_SAMPLECLOCK_SOURCE_INDEX, source_index, 0);
 
2311
        return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
 
2312
                source_index, 0);
2608
2313
}
2609
2314
 
2610
 
u16 hpi_sample_clock_get_source_index(const struct hpi_hsubsys *ph_subsys,
2611
 
        u32 h_control, u16 *pw_source_index)
 
2315
u16 hpi_sample_clock_get_source_index(u32 h_control, u16 *pw_source_index)
2612
2316
{
2613
 
        u16 error = 0;
 
2317
        u16 err = 0;
2614
2318
        u32 source_index = 0;
2615
 
        error = hpi_control_param1_get(ph_subsys, h_control,
2616
 
                HPI_SAMPLECLOCK_SOURCE_INDEX, &source_index);
2617
 
        if (!error)
 
2319
        err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
 
2320
                &source_index);
 
2321
        if (!err)
2618
2322
                if (pw_source_index)
2619
2323
                        *pw_source_index = (u16)source_index;
2620
 
        return error;
 
2324
        return err;
2621
2325
}
2622
2326
 
2623
 
u16 hpi_sample_clock_query_local_rate(const struct hpi_hsubsys *ph_subsys,
2624
 
        const u32 h_clock, const u32 index, u32 *prate)
 
2327
u16 hpi_sample_clock_query_local_rate(const u32 h_clock, const u32 index,
 
2328
        u32 *prate)
2625
2329
{
2626
2330
        u16 err;
2627
 
        err = hpi_control_query(ph_subsys, h_clock,
2628
 
                HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, index, 0, prate);
 
2331
        err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_LOCAL_SAMPLERATE,
 
2332
                index, 0, prate);
2629
2333
 
2630
2334
        return err;
2631
2335
}
2632
2336
 
2633
 
u16 hpi_sample_clock_set_local_rate(const struct hpi_hsubsys *ph_subsys,
2634
 
        u32 h_control, u32 sample_rate)
 
2337
u16 hpi_sample_clock_set_local_rate(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
2340
                HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, sample_rate, 0);
2638
2341
}
2639
2342
 
2640
 
u16 hpi_sample_clock_get_local_rate(const struct hpi_hsubsys *ph_subsys,
2641
 
        u32 h_control, u32 *psample_rate)
 
2343
u16 hpi_sample_clock_get_local_rate(u32 h_control, u32 *psample_rate)
2642
2344
{
2643
 
        u16 error = 0;
 
2345
        u16 err = 0;
2644
2346
        u32 sample_rate = 0;
2645
 
        error = hpi_control_param1_get(ph_subsys, h_control,
 
2347
        err = hpi_control_param1_get(h_control,
2646
2348
                HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate);
2647
 
        if (!error)
 
2349
        if (!err)
2648
2350
                if (psample_rate)
2649
2351
                        *psample_rate = sample_rate;
2650
 
        return error;
 
2352
        return err;
2651
2353
}
2652
2354
 
2653
 
u16 hpi_sample_clock_get_sample_rate(const struct hpi_hsubsys *ph_subsys,
2654
 
        u32 h_control, u32 *psample_rate)
 
2355
u16 hpi_sample_clock_get_sample_rate(u32 h_control, u32 *psample_rate)
2655
2356
{
2656
 
        u16 error = 0;
 
2357
        u16 err = 0;
2657
2358
        u32 sample_rate = 0;
2658
 
        error = hpi_control_param1_get(ph_subsys, h_control,
2659
 
                HPI_SAMPLECLOCK_SAMPLERATE, &sample_rate);
2660
 
        if (!error)
 
2359
        err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SAMPLERATE,
 
2360
                &sample_rate);
 
2361
        if (!err)
2661
2362
                if (psample_rate)
2662
2363
                        *psample_rate = sample_rate;
2663
 
        return error;
2664
 
}
2665
 
 
2666
 
u16 hpi_sample_clock_set_auto(const struct hpi_hsubsys *ph_subsys,
2667
 
        u32 h_control, u32 enable)
2668
 
{
2669
 
        return hpi_control_param_set(ph_subsys, h_control,
2670
 
                HPI_SAMPLECLOCK_AUTO, enable, 0);
2671
 
}
2672
 
 
2673
 
u16 hpi_sample_clock_get_auto(const struct hpi_hsubsys *ph_subsys,
2674
 
        u32 h_control, u32 *penable)
2675
 
{
2676
 
        return hpi_control_param1_get(ph_subsys, h_control,
2677
 
                HPI_SAMPLECLOCK_AUTO, penable);
2678
 
}
2679
 
 
2680
 
u16 hpi_sample_clock_set_local_rate_lock(const struct hpi_hsubsys *ph_subsys,
2681
 
        u32 h_control, u32 lock)
2682
 
{
2683
 
        return hpi_control_param_set(ph_subsys, h_control,
2684
 
                HPI_SAMPLECLOCK_LOCAL_LOCK, lock, 0);
2685
 
}
2686
 
 
2687
 
u16 hpi_sample_clock_get_local_rate_lock(const struct hpi_hsubsys *ph_subsys,
2688
 
        u32 h_control, u32 *plock)
2689
 
{
2690
 
        return hpi_control_param1_get(ph_subsys, h_control,
2691
 
                HPI_SAMPLECLOCK_LOCAL_LOCK, plock);
2692
 
}
2693
 
 
2694
 
u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys,
2695
 
        u32 h_control, u32 index, u32 *frequency)
2696
 
{
2697
 
        return hpi_control_param_get(ph_subsys, h_control,
2698
 
                HPI_TONEDETECTOR_FREQUENCY, index, 0, frequency, NULL);
2699
 
}
2700
 
 
2701
 
u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys,
2702
 
        u32 h_control, u32 *state)
2703
 
{
2704
 
        return hpi_control_param1_get(ph_subsys, h_control,
2705
 
                HPI_TONEDETECTOR_STATE, state);
2706
 
}
2707
 
 
2708
 
u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
2709
 
        u32 h_control, u32 enable)
2710
 
{
2711
 
        return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE,
2712
 
                (u32)enable, 0);
2713
 
}
2714
 
 
2715
 
u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys,
2716
 
        u32 h_control, u32 *enable)
2717
 
{
2718
 
        return hpi_control_param1_get(ph_subsys, h_control,
2719
 
                HPI_GENERIC_ENABLE, enable);
2720
 
}
2721
 
 
2722
 
u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys,
2723
 
        u32 h_control, u32 event_enable)
2724
 
{
2725
 
        return hpi_control_param_set(ph_subsys, h_control,
2726
 
                HPI_GENERIC_EVENT_ENABLE, (u32)event_enable, 0);
2727
 
}
2728
 
 
2729
 
u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys,
2730
 
        u32 h_control, u32 *event_enable)
2731
 
{
2732
 
        return hpi_control_param1_get(ph_subsys, h_control,
2733
 
                HPI_GENERIC_EVENT_ENABLE, event_enable);
2734
 
}
2735
 
 
2736
 
u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys,
2737
 
        u32 h_control, int threshold)
2738
 
{
2739
 
        return hpi_control_param_set(ph_subsys, h_control,
2740
 
                HPI_TONEDETECTOR_THRESHOLD, (u32)threshold, 0);
2741
 
}
2742
 
 
2743
 
u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys,
2744
 
        u32 h_control, int *threshold)
2745
 
{
2746
 
        return hpi_control_param1_get(ph_subsys, h_control,
2747
 
                HPI_TONEDETECTOR_THRESHOLD, (u32 *)threshold);
2748
 
}
2749
 
 
2750
 
u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys,
2751
 
        u32 h_control, u32 *state)
2752
 
{
2753
 
        return hpi_control_param1_get(ph_subsys, h_control,
2754
 
                HPI_SILENCEDETECTOR_STATE, state);
2755
 
}
2756
 
 
2757
 
u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
2758
 
        u32 h_control, u32 enable)
2759
 
{
2760
 
        return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE,
2761
 
                (u32)enable, 0);
2762
 
}
2763
 
 
2764
 
u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys,
2765
 
        u32 h_control, u32 *enable)
2766
 
{
2767
 
        return hpi_control_param1_get(ph_subsys, h_control,
2768
 
                HPI_GENERIC_ENABLE, enable);
2769
 
}
2770
 
 
2771
 
u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys,
2772
 
        u32 h_control, u32 event_enable)
2773
 
{
2774
 
        return hpi_control_param_set(ph_subsys, h_control,
2775
 
                HPI_GENERIC_EVENT_ENABLE, event_enable, 0);
2776
 
}
2777
 
 
2778
 
u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys,
2779
 
        u32 h_control, u32 *event_enable)
2780
 
{
2781
 
        return hpi_control_param1_get(ph_subsys, h_control,
2782
 
                HPI_GENERIC_EVENT_ENABLE, event_enable);
2783
 
}
2784
 
 
2785
 
u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys,
2786
 
        u32 h_control, u32 delay)
2787
 
{
2788
 
        return hpi_control_param_set(ph_subsys, h_control,
2789
 
                HPI_SILENCEDETECTOR_DELAY, delay, 0);
2790
 
}
2791
 
 
2792
 
u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys,
2793
 
        u32 h_control, u32 *delay)
2794
 
{
2795
 
        return hpi_control_param1_get(ph_subsys, h_control,
2796
 
                HPI_SILENCEDETECTOR_DELAY, delay);
2797
 
}
2798
 
 
2799
 
u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys,
2800
 
        u32 h_control, int threshold)
2801
 
{
2802
 
        return hpi_control_param_set(ph_subsys, h_control,
2803
 
                HPI_SILENCEDETECTOR_THRESHOLD, threshold, 0);
2804
 
}
2805
 
 
2806
 
u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys,
2807
 
        u32 h_control, int *threshold)
2808
 
{
2809
 
        return hpi_control_param1_get(ph_subsys, h_control,
 
2364
        return err;
 
2365
}
 
2366
 
 
2367
u16 hpi_sample_clock_set_auto(u32 h_control, u32 enable)
 
2368
{
 
2369
        return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_AUTO, enable,
 
2370
                0);
 
2371
}
 
2372
 
 
2373
u16 hpi_sample_clock_get_auto(u32 h_control, u32 *penable)
 
2374
{
 
2375
        return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_AUTO,
 
2376
                penable);
 
2377
}
 
2378
 
 
2379
u16 hpi_sample_clock_set_local_rate_lock(u32 h_control, u32 lock)
 
2380
{
 
2381
        return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
 
2382
                lock, 0);
 
2383
}
 
2384
 
 
2385
u16 hpi_sample_clock_get_local_rate_lock(u32 h_control, u32 *plock)
 
2386
{
 
2387
        return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
 
2388
                plock);
 
2389
}
 
2390
 
 
2391
u16 hpi_tone_detector_get_frequency(u32 h_control, u32 index, u32 *frequency)
 
2392
{
 
2393
        return hpi_control_param_get(h_control, HPI_TONEDETECTOR_FREQUENCY,
 
2394
                index, 0, frequency, NULL);
 
2395
}
 
2396
 
 
2397
u16 hpi_tone_detector_get_state(u32 h_control, u32 *state)
 
2398
{
 
2399
        return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_STATE,
 
2400
                state);
 
2401
}
 
2402
 
 
2403
u16 hpi_tone_detector_set_enable(u32 h_control, u32 enable)
 
2404
{
 
2405
        return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
 
2406
                0);
 
2407
}
 
2408
 
 
2409
u16 hpi_tone_detector_get_enable(u32 h_control, u32 *enable)
 
2410
{
 
2411
        return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
 
2412
}
 
2413
 
 
2414
u16 hpi_tone_detector_set_event_enable(u32 h_control, u32 event_enable)
 
2415
{
 
2416
        return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
 
2417
                (u32)event_enable, 0);
 
2418
}
 
2419
 
 
2420
u16 hpi_tone_detector_get_event_enable(u32 h_control, u32 *event_enable)
 
2421
{
 
2422
        return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
 
2423
                event_enable);
 
2424
}
 
2425
 
 
2426
u16 hpi_tone_detector_set_threshold(u32 h_control, int threshold)
 
2427
{
 
2428
        return hpi_control_param_set(h_control, HPI_TONEDETECTOR_THRESHOLD,
 
2429
                (u32)threshold, 0);
 
2430
}
 
2431
 
 
2432
u16 hpi_tone_detector_get_threshold(u32 h_control, int *threshold)
 
2433
{
 
2434
        return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_THRESHOLD,
 
2435
                (u32 *)threshold);
 
2436
}
 
2437
 
 
2438
u16 hpi_silence_detector_get_state(u32 h_control, u32 *state)
 
2439
{
 
2440
        return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_STATE,
 
2441
                state);
 
2442
}
 
2443
 
 
2444
u16 hpi_silence_detector_set_enable(u32 h_control, u32 enable)
 
2445
{
 
2446
        return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
 
2447
                0);
 
2448
}
 
2449
 
 
2450
u16 hpi_silence_detector_get_enable(u32 h_control, u32 *enable)
 
2451
{
 
2452
        return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
 
2453
}
 
2454
 
 
2455
u16 hpi_silence_detector_set_event_enable(u32 h_control, u32 event_enable)
 
2456
{
 
2457
        return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
 
2458
                event_enable, 0);
 
2459
}
 
2460
 
 
2461
u16 hpi_silence_detector_get_event_enable(u32 h_control, u32 *event_enable)
 
2462
{
 
2463
        return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
 
2464
                event_enable);
 
2465
}
 
2466
 
 
2467
u16 hpi_silence_detector_set_delay(u32 h_control, u32 delay)
 
2468
{
 
2469
        return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_DELAY,
 
2470
                delay, 0);
 
2471
}
 
2472
 
 
2473
u16 hpi_silence_detector_get_delay(u32 h_control, u32 *delay)
 
2474
{
 
2475
        return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_DELAY,
 
2476
                delay);
 
2477
}
 
2478
 
 
2479
u16 hpi_silence_detector_set_threshold(u32 h_control, int threshold)
 
2480
{
 
2481
        return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_THRESHOLD,
 
2482
                threshold, 0);
 
2483
}
 
2484
 
 
2485
u16 hpi_silence_detector_get_threshold(u32 h_control, int *threshold)
 
2486
{
 
2487
        return hpi_control_param1_get(h_control,
2810
2488
                HPI_SILENCEDETECTOR_THRESHOLD, (u32 *)threshold);
2811
2489
}
2812
2490
 
2813
 
u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys,
2814
 
        const u32 h_tuner, const u32 index, u16 *pw_band)
 
2491
u16 hpi_tuner_query_band(const u32 h_tuner, const u32 index, u16 *pw_band)
2815
2492
{
2816
2493
        u32 qr;
2817
2494
        u16 err;
2818
2495
 
2819
 
        err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0,
2820
 
                &qr);
 
2496
        err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
2821
2497
        *pw_band = (u16)qr;
2822
2498
        return err;
2823
2499
}
2824
2500
 
2825
 
u16 hpi_tuner_set_band(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2826
 
        u16 band)
 
2501
u16 hpi_tuner_set_band(u32 h_control, u16 band)
2827
2502
{
2828
 
        return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_BAND,
2829
 
                band, 0);
 
2503
        return hpi_control_param_set(h_control, HPI_TUNER_BAND, band, 0);
2830
2504
}
2831
2505
 
2832
 
u16 hpi_tuner_get_band(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2833
 
        u16 *pw_band)
 
2506
u16 hpi_tuner_get_band(u32 h_control, u16 *pw_band)
2834
2507
{
2835
2508
        u32 band = 0;
2836
2509
        u16 error = 0;
2837
2510
 
2838
 
        error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_BAND,
2839
 
                &band);
 
2511
        error = hpi_control_param1_get(h_control, HPI_TUNER_BAND, &band);
2840
2512
        if (pw_band)
2841
2513
                *pw_band = (u16)band;
2842
2514
        return error;
2843
2515
}
2844
2516
 
2845
 
u16 hpi_tuner_query_frequency(const struct hpi_hsubsys *ph_subsys,
2846
 
        const u32 h_tuner, const u32 index, const u16 band, u32 *pfreq)
2847
 
{
2848
 
        return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_FREQ, index,
2849
 
                band, pfreq);
2850
 
}
2851
 
 
2852
 
u16 hpi_tuner_set_frequency(const struct hpi_hsubsys *ph_subsys,
2853
 
        u32 h_control, u32 freq_ink_hz)
2854
 
{
2855
 
        return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_FREQ,
2856
 
                freq_ink_hz, 0);
2857
 
}
2858
 
 
2859
 
u16 hpi_tuner_get_frequency(const struct hpi_hsubsys *ph_subsys,
2860
 
        u32 h_control, u32 *pw_freq_ink_hz)
2861
 
{
2862
 
        return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_FREQ,
 
2517
u16 hpi_tuner_query_frequency(const u32 h_tuner, const u32 index,
 
2518
        const u16 band, u32 *pfreq)
 
2519
{
 
2520
        return hpi_control_query(h_tuner, HPI_TUNER_FREQ, index, band, pfreq);
 
2521
}
 
2522
 
 
2523
u16 hpi_tuner_set_frequency(u32 h_control, u32 freq_ink_hz)
 
2524
{
 
2525
        return hpi_control_param_set(h_control, HPI_TUNER_FREQ, freq_ink_hz,
 
2526
                0);
 
2527
}
 
2528
 
 
2529
u16 hpi_tuner_get_frequency(u32 h_control, u32 *pw_freq_ink_hz)
 
2530
{
 
2531
        return hpi_control_param1_get(h_control, HPI_TUNER_FREQ,
2863
2532
                pw_freq_ink_hz);
2864
2533
}
2865
2534
 
2866
 
u16 hpi_tuner_query_gain(const struct hpi_hsubsys *ph_subsys,
2867
 
        const u32 h_tuner, const u32 index, u16 *pw_gain)
 
2535
u16 hpi_tuner_query_gain(const u32 h_tuner, const u32 index, u16 *pw_gain)
2868
2536
{
2869
2537
        u32 qr;
2870
2538
        u16 err;
2871
2539
 
2872
 
        err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0,
2873
 
                &qr);
 
2540
        err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
2874
2541
        *pw_gain = (u16)qr;
2875
2542
        return err;
2876
2543
}
2877
2544
 
2878
 
u16 hpi_tuner_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2879
 
        short gain)
 
2545
u16 hpi_tuner_set_gain(u32 h_control, short gain)
2880
2546
{
2881
 
        return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_GAIN,
2882
 
                gain, 0);
 
2547
        return hpi_control_param_set(h_control, HPI_TUNER_GAIN, gain, 0);
2883
2548
}
2884
2549
 
2885
 
u16 hpi_tuner_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2886
 
        short *pn_gain)
 
2550
u16 hpi_tuner_get_gain(u32 h_control, short *pn_gain)
2887
2551
{
2888
2552
        u32 gain = 0;
2889
2553
        u16 error = 0;
2890
2554
 
2891
 
        error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_GAIN,
2892
 
                &gain);
 
2555
        error = hpi_control_param1_get(h_control, HPI_TUNER_GAIN, &gain);
2893
2556
        if (pn_gain)
2894
2557
                *pn_gain = (u16)gain;
2895
2558
        return error;
2896
2559
}
2897
2560
 
2898
 
u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2899
 
        short *pw_level)
2900
 
{
2901
 
        struct hpi_message hm;
2902
 
        struct hpi_response hr;
2903
 
 
2904
 
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2905
 
                HPI_CONTROL_GET_STATE);
2906
 
        u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2907
 
        hm.u.c.attribute = HPI_TUNER_LEVEL;
2908
 
        hm.u.c.param1 = HPI_TUNER_LEVEL_AVERAGE;
2909
 
        hpi_send_recv(&hm, &hr);
2910
 
        if (pw_level)
2911
 
                *pw_level = (short)hr.u.c.param1;
2912
 
        return hr.error;
2913
 
}
2914
 
 
2915
 
u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys,
2916
 
        u32 h_control, short *pw_level)
2917
 
{
2918
 
        struct hpi_message hm;
2919
 
        struct hpi_response hr;
2920
 
 
2921
 
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2922
 
                HPI_CONTROL_GET_STATE);
2923
 
        u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2924
 
        hm.u.c.attribute = HPI_TUNER_LEVEL;
2925
 
        hm.u.c.param1 = HPI_TUNER_LEVEL_RAW;
2926
 
        hpi_send_recv(&hm, &hr);
2927
 
        if (pw_level)
2928
 
                *pw_level = (short)hr.u.c.param1;
2929
 
        return hr.error;
2930
 
}
2931
 
 
2932
 
u16 hpi_tuner_query_deemphasis(const struct hpi_hsubsys *ph_subsys,
2933
 
        const u32 h_tuner, const u32 index, const u16 band, u32 *pdeemphasis)
2934
 
{
2935
 
        return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_DEEMPHASIS,
2936
 
                index, band, pdeemphasis);
2937
 
}
2938
 
 
2939
 
u16 hpi_tuner_set_deemphasis(const struct hpi_hsubsys *ph_subsys,
2940
 
        u32 h_control, u32 deemphasis)
2941
 
{
2942
 
        return hpi_control_param_set(ph_subsys, h_control,
2943
 
                HPI_TUNER_DEEMPHASIS, deemphasis, 0);
2944
 
}
2945
 
 
2946
 
u16 hpi_tuner_get_deemphasis(const struct hpi_hsubsys *ph_subsys,
2947
 
        u32 h_control, u32 *pdeemphasis)
2948
 
{
2949
 
        return hpi_control_param1_get(ph_subsys, h_control,
2950
 
                HPI_TUNER_DEEMPHASIS, pdeemphasis);
2951
 
}
2952
 
 
2953
 
u16 hpi_tuner_query_program(const struct hpi_hsubsys *ph_subsys,
2954
 
        const u32 h_tuner, u32 *pbitmap_program)
2955
 
{
2956
 
        return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_PROGRAM, 0, 0,
 
2561
u16 hpi_tuner_get_rf_level(u32 h_control, short *pw_level)
 
2562
{
 
2563
        struct hpi_message hm;
 
2564
        struct hpi_response hr;
 
2565
 
 
2566
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
 
2567
                HPI_CONTROL_GET_STATE);
 
2568
        if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
 
2569
                return HPI_ERROR_INVALID_HANDLE;
 
2570
        hm.u.cu.attribute = HPI_TUNER_LEVEL_AVG;
 
2571
        hpi_send_recv(&hm, &hr);
 
2572
        if (pw_level)
 
2573
                *pw_level = hr.u.cu.tuner.s_level;
 
2574
        return hr.error;
 
2575
}
 
2576
 
 
2577
u16 hpi_tuner_get_raw_rf_level(u32 h_control, short *pw_level)
 
2578
{
 
2579
        struct hpi_message hm;
 
2580
        struct hpi_response hr;
 
2581
 
 
2582
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
 
2583
                HPI_CONTROL_GET_STATE);
 
2584
        if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
 
2585
                return HPI_ERROR_INVALID_HANDLE;
 
2586
        hm.u.cu.attribute = HPI_TUNER_LEVEL_RAW;
 
2587
        hpi_send_recv(&hm, &hr);
 
2588
        if (pw_level)
 
2589
                *pw_level = hr.u.cu.tuner.s_level;
 
2590
        return hr.error;
 
2591
}
 
2592
 
 
2593
u16 hpi_tuner_query_deemphasis(const u32 h_tuner, const u32 index,
 
2594
        const u16 band, u32 *pdeemphasis)
 
2595
{
 
2596
        return hpi_control_query(h_tuner, HPI_TUNER_DEEMPHASIS, index, band,
 
2597
                pdeemphasis);
 
2598
}
 
2599
 
 
2600
u16 hpi_tuner_set_deemphasis(u32 h_control, u32 deemphasis)
 
2601
{
 
2602
        return hpi_control_param_set(h_control, HPI_TUNER_DEEMPHASIS,
 
2603
                deemphasis, 0);
 
2604
}
 
2605
 
 
2606
u16 hpi_tuner_get_deemphasis(u32 h_control, u32 *pdeemphasis)
 
2607
{
 
2608
        return hpi_control_param1_get(h_control, HPI_TUNER_DEEMPHASIS,
 
2609
                pdeemphasis);
 
2610
}
 
2611
 
 
2612
u16 hpi_tuner_query_program(const u32 h_tuner, u32 *pbitmap_program)
 
2613
{
 
2614
        return hpi_control_query(h_tuner, HPI_TUNER_PROGRAM, 0, 0,
2957
2615
                pbitmap_program);
2958
2616
}
2959
2617
 
2960
 
u16 hpi_tuner_set_program(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2961
 
        u32 program)
2962
 
{
2963
 
        return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_PROGRAM,
2964
 
                program, 0);
2965
 
}
2966
 
 
2967
 
u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2968
 
        u32 *pprogram)
2969
 
{
2970
 
        return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_PROGRAM,
2971
 
                pprogram);
2972
 
}
2973
 
 
2974
 
u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys,
2975
 
        u32 h_control, char *psz_dsp_version, const u32 string_size)
 
2618
u16 hpi_tuner_set_program(u32 h_control, u32 program)
 
2619
{
 
2620
        return hpi_control_param_set(h_control, HPI_TUNER_PROGRAM, program,
 
2621
                0);
 
2622
}
 
2623
 
 
2624
u16 hpi_tuner_get_program(u32 h_control, u32 *pprogram)
 
2625
{
 
2626
        return hpi_control_param1_get(h_control, HPI_TUNER_PROGRAM, pprogram);
 
2627
}
 
2628
 
 
2629
u16 hpi_tuner_get_hd_radio_dsp_version(u32 h_control, char *psz_dsp_version,
 
2630
        const u32 string_size)
2976
2631
{
2977
2632
        return hpi_control_get_string(h_control,
2978
2633
                HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size);
2979
2634
}
2980
2635
 
2981
 
u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys,
2982
 
        u32 h_control, char *psz_sdk_version, const u32 string_size)
 
2636
u16 hpi_tuner_get_hd_radio_sdk_version(u32 h_control, char *psz_sdk_version,
 
2637
        const u32 string_size)
2983
2638
{
2984
2639
        return hpi_control_get_string(h_control,
2985
2640
                HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size);
2986
2641
}
2987
2642
 
2988
 
u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2989
 
        u16 *pw_status_mask, u16 *pw_status)
 
2643
u16 hpi_tuner_get_status(u32 h_control, u16 *pw_status_mask, u16 *pw_status)
2990
2644
{
2991
2645
        u32 status = 0;
2992
2646
        u16 error = 0;
2993
2647
 
2994
 
        error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_STATUS,
2995
 
                &status);
 
2648
        error = hpi_control_param1_get(h_control, HPI_TUNER_STATUS, &status);
2996
2649
        if (pw_status) {
2997
2650
                if (!error) {
2998
2651
                        *pw_status_mask = (u16)(status >> 16);
3005
2658
        return error;
3006
2659
}
3007
2660
 
3008
 
u16 hpi_tuner_set_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3009
 
        u32 mode, u32 value)
3010
 
{
3011
 
        return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_MODE,
3012
 
                mode, value);
3013
 
}
3014
 
 
3015
 
u16 hpi_tuner_get_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3016
 
        u32 mode, u32 *pn_value)
3017
 
{
3018
 
        return hpi_control_param_get(ph_subsys, h_control, HPI_TUNER_MODE,
3019
 
                mode, 0, pn_value, NULL);
3020
 
}
3021
 
 
3022
 
u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys,
3023
 
        u32 h_control, u32 *pquality)
3024
 
{
3025
 
        return hpi_control_param1_get(ph_subsys, h_control,
 
2661
u16 hpi_tuner_set_mode(u32 h_control, u32 mode, u32 value)
 
2662
{
 
2663
        return hpi_control_param_set(h_control, HPI_TUNER_MODE, mode, value);
 
2664
}
 
2665
 
 
2666
u16 hpi_tuner_get_mode(u32 h_control, u32 mode, u32 *pn_value)
 
2667
{
 
2668
        return hpi_control_param_get(h_control, HPI_TUNER_MODE, mode, 0,
 
2669
                pn_value, NULL);
 
2670
}
 
2671
 
 
2672
u16 hpi_tuner_get_hd_radio_signal_quality(u32 h_control, u32 *pquality)
 
2673
{
 
2674
        return hpi_control_param1_get(h_control,
3026
2675
                HPI_TUNER_HDRADIO_SIGNAL_QUALITY, pquality);
3027
2676
}
3028
2677
 
3029
 
u16 hpi_tuner_get_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys,
3030
 
        u32 h_control, u32 *pblend)
3031
 
{
3032
 
        return hpi_control_param1_get(ph_subsys, h_control,
3033
 
                HPI_TUNER_HDRADIO_BLEND, pblend);
3034
 
}
3035
 
 
3036
 
u16 hpi_tuner_set_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys,
3037
 
        u32 h_control, const u32 blend)
3038
 
{
3039
 
        return hpi_control_param_set(ph_subsys, h_control,
3040
 
                HPI_TUNER_HDRADIO_BLEND, blend, 0);
3041
 
}
3042
 
 
3043
 
u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3044
 
        char *p_data)
 
2678
u16 hpi_tuner_get_hd_radio_signal_blend(u32 h_control, u32 *pblend)
 
2679
{
 
2680
        return hpi_control_param1_get(h_control, HPI_TUNER_HDRADIO_BLEND,
 
2681
                pblend);
 
2682
}
 
2683
 
 
2684
u16 hpi_tuner_set_hd_radio_signal_blend(u32 h_control, const u32 blend)
 
2685
{
 
2686
        return hpi_control_param_set(h_control, HPI_TUNER_HDRADIO_BLEND,
 
2687
                blend, 0);
 
2688
}
 
2689
 
 
2690
u16 hpi_tuner_get_rds(u32 h_control, char *p_data)
3045
2691
{
3046
2692
        struct hpi_message hm;
3047
2693
        struct hpi_response hr;
3048
2694
 
3049
2695
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3050
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
2699
        hm.u.c.attribute = HPI_TUNER_RDS;
3053
2700
        hpi_send_recv(&hm, &hr);
3054
2701
        if (p_data) {
3059
2706
        return hr.error;
3060
2707
}
3061
2708
 
3062
 
u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys,
3063
 
        u32 h_control, char *psz_string, const u32 data_length)
 
2709
u16 hpi_pad_get_channel_name(u32 h_control, char *psz_string,
 
2710
        const u32 data_length)
3064
2711
{
3065
2712
        return hpi_control_get_string(h_control, HPI_PAD_CHANNEL_NAME,
3066
2713
                psz_string, data_length);
3067
2714
}
3068
2715
 
3069
 
u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3070
 
        char *psz_string, const u32 data_length)
 
2716
u16 hpi_pad_get_artist(u32 h_control, char *psz_string, const u32 data_length)
3071
2717
{
3072
2718
        return hpi_control_get_string(h_control, HPI_PAD_ARTIST, psz_string,
3073
2719
                data_length);
3074
2720
}
3075
2721
 
3076
 
u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3077
 
        char *psz_string, const u32 data_length)
 
2722
u16 hpi_pad_get_title(u32 h_control, char *psz_string, const u32 data_length)
3078
2723
{
3079
2724
        return hpi_control_get_string(h_control, HPI_PAD_TITLE, psz_string,
3080
2725
                data_length);
3081
2726
}
3082
2727
 
3083
 
u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3084
 
        char *psz_string, const u32 data_length)
 
2728
u16 hpi_pad_get_comment(u32 h_control, char *psz_string,
 
2729
        const u32 data_length)
3085
2730
{
3086
2731
        return hpi_control_get_string(h_control, HPI_PAD_COMMENT, psz_string,
3087
2732
                data_length);
3088
2733
}
3089
2734
 
3090
 
u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys,
3091
 
        u32 h_control, u32 *ppTY)
3092
 
{
3093
 
        return hpi_control_param1_get(ph_subsys, h_control,
3094
 
                HPI_PAD_PROGRAM_TYPE, ppTY);
3095
 
}
3096
 
 
3097
 
u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3098
 
        u32 *ppI)
3099
 
{
3100
 
        return hpi_control_param1_get(ph_subsys, h_control,
3101
 
                HPI_PAD_PROGRAM_ID, ppI);
3102
 
}
3103
 
 
3104
 
u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys,
3105
 
        const u32 h_volume, u32 *p_channels)
3106
 
{
3107
 
        return hpi_control_query(ph_subsys, h_volume, HPI_VOLUME_NUM_CHANNELS,
3108
 
                0, 0, p_channels);
3109
 
}
3110
 
 
3111
 
u16 hpi_volume_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3112
 
        short an_log_gain[HPI_MAX_CHANNELS]
 
2735
u16 hpi_pad_get_program_type(u32 h_control, u32 *ppTY)
 
2736
{
 
2737
        return hpi_control_param1_get(h_control, HPI_PAD_PROGRAM_TYPE, ppTY);
 
2738
}
 
2739
 
 
2740
u16 hpi_pad_get_rdsPI(u32 h_control, u32 *ppI)
 
2741
{
 
2742
        return hpi_control_param1_get(h_control, HPI_PAD_PROGRAM_ID, ppI);
 
2743
}
 
2744
 
 
2745
u16 hpi_volume_query_channels(const u32 h_volume, u32 *p_channels)
 
2746
{
 
2747
        return hpi_control_query(h_volume, HPI_VOLUME_NUM_CHANNELS, 0, 0,
 
2748
                p_channels);
 
2749
}
 
2750
 
 
2751
u16 hpi_volume_set_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS]
3113
2752
        )
3114
2753
{
3115
2754
        return hpi_control_log_set2(h_control, HPI_VOLUME_GAIN,
3116
2755
                an_log_gain[0], an_log_gain[1]);
3117
2756
}
3118
2757
 
3119
 
u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3120
 
        short an_log_gain[HPI_MAX_CHANNELS]
 
2758
u16 hpi_volume_get_gain(u32 h_control, 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
2762
                &an_log_gain[0], &an_log_gain[1]);
3125
2763
}
3126
2764
 
3127
 
u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3128
 
        short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB)
 
2765
u16 hpi_volume_set_mute(u32 h_control, u32 mute)
 
2766
{
 
2767
        return hpi_control_param_set(h_control, HPI_VOLUME_MUTE, mute, 0);
 
2768
}
 
2769
 
 
2770
u16 hpi_volume_get_mute(u32 h_control, u32 *mute)
 
2771
{
 
2772
        return hpi_control_param1_get(h_control, HPI_VOLUME_MUTE, mute);
 
2773
}
 
2774
 
 
2775
u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB,
 
2776
        short *max_gain_01dB, short *step_gain_01dB)
3129
2777
{
3130
2778
        struct hpi_message hm;
3131
2779
        struct hpi_response hr;
3132
2780
 
3133
2781
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3134
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
2785
        hm.u.c.attribute = HPI_VOLUME_RANGE;
3137
2786
 
3138
2787
        hpi_send_recv(&hm, &hr);
3150
2799
        return hr.error;
3151
2800
}
3152
2801
 
3153
 
u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys,
3154
 
        u32 h_control, short an_stop_gain0_01dB[HPI_MAX_CHANNELS],
3155
 
        u32 duration_ms, u16 profile)
 
2802
u16 hpi_volume_auto_fade_profile(u32 h_control,
 
2803
        short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms,
 
2804
        u16 profile)
3156
2805
{
3157
2806
        struct hpi_message hm;
3158
2807
        struct hpi_response hr;
3159
2808
 
3160
2809
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3161
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
2814
        memcpy(hm.u.c.an_log_value, an_stop_gain0_01dB,
3165
2815
                sizeof(short) * HPI_MAX_CHANNELS);
3173
2823
        return hr.error;
3174
2824
}
3175
2825
 
3176
 
u16 hpi_volume_auto_fade(const struct hpi_hsubsys *ph_subsys, u32 h_control,
 
2826
u16 hpi_volume_auto_fade(u32 h_control,
3177
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,
3180
 
                an_stop_gain0_01dB, duration_ms, HPI_VOLUME_AUTOFADE_LOG);
 
2829
        return hpi_volume_auto_fade_profile(h_control, an_stop_gain0_01dB,
 
2830
                duration_ms, HPI_VOLUME_AUTOFADE_LOG);
3181
2831
}
3182
2832
 
3183
 
u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3184
 
        short an_gain0_01dB)
 
2833
u16 hpi_vox_set_threshold(u32 h_control, short an_gain0_01dB)
3185
2834
{
3186
2835
        struct hpi_message hm;
3187
2836
        struct hpi_response hr;
3188
2837
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3189
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
2841
        hm.u.c.attribute = HPI_VOX_THRESHOLD;
3192
2842
 
3193
2843
        hm.u.c.an_log_value[0] = an_gain0_01dB;
3197
2847
        return hr.error;
3198
2848
}
3199
2849
 
3200
 
u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3201
 
        short *an_gain0_01dB)
 
2850
u16 hpi_vox_get_threshold(u32 h_control, short *an_gain0_01dB)
3202
2851
{
3203
2852
        struct hpi_message hm;
3204
2853
        struct hpi_response hr;
3205
2854
        hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3206
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
2858
        hm.u.c.attribute = HPI_VOX_THRESHOLD;
3209
2859
 
3210
2860
        hpi_send_recv(&hm, &hr);
3213
2863
 
3214
2864
        return hr.error;
3215
2865
}
3216
 
 
3217
 
static size_t strv_packet_size = MIN_STRV_PACKET_SIZE;
3218
 
 
3219
 
static 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
 
 
3236
 
static inline size_t hpi_entity_size(struct hpi_entity *entity_ptr)
3237
 
{
3238
 
        return entity_ptr->header.size;
3239
 
}
3240
 
 
3241
 
static inline size_t hpi_entity_header_size(struct hpi_entity *entity_ptr)
3242
 
{
3243
 
        return sizeof(entity_ptr->header);
3244
 
}
3245
 
 
3246
 
static 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
 
 
3252
 
static 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
 
 
3258
 
static 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
 
 
3264
 
static 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
 
 
3271
 
static 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
 
 
3278
 
static 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
 
 
3304
 
u16 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
 
 
3343
 
void hpi_entity_free(struct hpi_entity *entity)
3344
 
{
3345
 
        kfree(entity);
3346
 
}
3347
 
 
3348
 
static 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
 
 
3363
 
u16 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
 
 
3407
 
u16 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
 
 
3451
 
u16 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
 
 
3473
 
u16 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
 
 
3504
 
u16 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
 
 
3520
 
u16 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
 
 
3557
 
u16 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
 
 
3579
 
u16 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
 
 
3594
 
u16 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
 
 
3614
 
u16 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
 
 
3629
 
u16 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
 
 
3650
 
u16 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
 
 
3672
 
u16 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
 
 
3685
 
u16 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
 
 
3693
 
u16 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
 
 
3711
 
u16 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
 
 
3731
 
u16 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
 
 
3753
 
u16 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
 
 
3769
 
u16 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
 
 
3785
 
u16 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
 
 
3807
 
u16 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
 
 
3830
 
u16 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
 
 
3849
 
u16 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
 
 
3870
 
u16 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
 
 
3882
 
u16 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
 
 
3894
 
u16 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
 
 
3914
 
u16 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
 
 
3929
 
u16 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
 
}