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