~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/pci/asihpi/hpifunc.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/pci/asihpi/hpifunc.c (Version linux-6.12-rc7) and /sound/pci/asihpi/hpifunc.c (Version linux-2.4.37.11)


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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php