aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/asihpi
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /sound/pci/asihpi
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'sound/pci/asihpi')
-rw-r--r--sound/pci/asihpi/asihpi.c1054
-rw-r--r--sound/pci/asihpi/hpi.h1216
-rw-r--r--sound/pci/asihpi/hpi6000.c332
-rw-r--r--sound/pci/asihpi/hpi6205.c696
-rw-r--r--sound/pci/asihpi/hpi6205.h7
-rw-r--r--sound/pci/asihpi/hpi_internal.h1127
-rw-r--r--sound/pci/asihpi/hpicmn.c496
-rw-r--r--sound/pci/asihpi/hpicmn.h26
-rw-r--r--sound/pci/asihpi/hpidebug.c157
-rw-r--r--sound/pci/asihpi/hpidebug.h323
-rw-r--r--sound/pci/asihpi/hpidspcd.c39
-rw-r--r--sound/pci/asihpi/hpidspcd.h2
-rw-r--r--sound/pci/asihpi/hpifunc.c2517
-rw-r--r--sound/pci/asihpi/hpimsginit.c18
-rw-r--r--sound/pci/asihpi/hpimsginit.h12
-rw-r--r--sound/pci/asihpi/hpimsgx.c218
-rw-r--r--sound/pci/asihpi/hpioctl.c147
-rw-r--r--sound/pci/asihpi/hpios.h10
18 files changed, 3135 insertions, 5262 deletions
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index c80b0b863c54..e3569bdd3b64 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -21,25 +21,6 @@
21 * would appreciate it if you grant us the right to use those modifications 21 * would appreciate it if you grant us the right to use those modifications
22 * for any purpose including commercial applications. 22 * for any purpose including commercial applications.
23 */ 23 */
24/* >0: print Hw params, timer vars. >1: print stream write/copy sizes */
25#define REALLY_VERBOSE_LOGGING 0
26
27#if REALLY_VERBOSE_LOGGING
28#define VPRINTK1 snd_printd
29#else
30#define VPRINTK1(...)
31#endif
32
33#if REALLY_VERBOSE_LOGGING > 1
34#define VPRINTK2 snd_printd
35#else
36#define VPRINTK2(...)
37#endif
38
39#ifndef ASI_STYLE_NAMES
40/* not sure how ALSA style name should look */
41#define ASI_STYLE_NAMES 1
42#endif
43 24
44#include "hpi_internal.h" 25#include "hpi_internal.h"
45#include "hpimsginit.h" 26#include "hpimsginit.h"
@@ -65,6 +46,39 @@ MODULE_LICENSE("GPL");
65MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>"); 46MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>");
66MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx"); 47MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx");
67 48
49#if defined CONFIG_SND_DEBUG
50/* copied from pcm_lib.c, hope later patch will make that version public
51and this copy can be removed */
52static void pcm_debug_name(struct snd_pcm_substream *substream,
53 char *name, size_t len)
54{
55 snprintf(name, len, "pcmC%dD%d%c:%d",
56 substream->pcm->card->number,
57 substream->pcm->device,
58 substream->stream ? 'c' : 'p',
59 substream->number);
60}
61#define DEBUG_NAME(substream, name) char name[16]; pcm_debug_name(substream, name, sizeof(name))
62#else
63#define pcm_debug_name(s, n, l) do { } while (0)
64#define DEBUG_NAME(name, substream) do { } while (0)
65#endif
66
67#if defined CONFIG_SND_DEBUG_VERBOSE
68/**
69 * snd_printddd - very verbose debug printk
70 * @format: format string
71 *
72 * Works like snd_printk() for debugging purposes.
73 * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set.
74 * Must set snd module debug parameter to 3 to enable at runtime.
75 */
76#define snd_printddd(format, args...) \
77 __snd_printk(3, __FILE__, __LINE__, format, ##args)
78#else
79#define snd_printddd(format, args...) do { } while (0)
80#endif
81
68static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */ 82static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */
69static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 83static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
70static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 84static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
@@ -85,11 +99,11 @@ MODULE_PARM_DESC(enable_hpi_hwdep,
85 99
86/* identify driver */ 100/* identify driver */
87#ifdef KERNEL_ALSA_BUILD 101#ifdef KERNEL_ALSA_BUILD
88static char *build_info = "built using headers from kernel source"; 102static char *build_info = "Built using headers from kernel source";
89module_param(build_info, charp, S_IRUGO); 103module_param(build_info, charp, S_IRUGO);
90MODULE_PARM_DESC(build_info, "built using headers from kernel source"); 104MODULE_PARM_DESC(build_info, "built using headers from kernel source");
91#else 105#else
92static char *build_info = "built within ALSA source"; 106static char *build_info = "Built within ALSA source";
93module_param(build_info, charp, S_IRUGO); 107module_param(build_info, charp, S_IRUGO);
94MODULE_PARM_DESC(build_info, "built within ALSA source"); 108MODULE_PARM_DESC(build_info, "built within ALSA source");
95#endif 109#endif
@@ -100,17 +114,11 @@ static const int mixer_dump;
100#define DEFAULT_SAMPLERATE 44100 114#define DEFAULT_SAMPLERATE 44100
101static int adapter_fs = DEFAULT_SAMPLERATE; 115static int adapter_fs = DEFAULT_SAMPLERATE;
102 116
103static struct hpi_hsubsys *ss; /* handle to HPI audio subsystem */
104
105/* defaults */ 117/* defaults */
106#define PERIODS_MIN 2 118#define PERIODS_MIN 2
107#define PERIOD_BYTES_MIN 2304 119#define PERIOD_BYTES_MIN 2048
108#define BUFFER_BYTES_MAX (512 * 1024) 120#define BUFFER_BYTES_MAX (512 * 1024)
109 121
110/*#define TIMER_MILLISECONDS 20
111#define FORCE_TIMER_JIFFIES ((TIMER_MILLISECONDS * HZ + 999)/1000)
112*/
113
114#define MAX_CLOCKSOURCES (HPI_SAMPLECLOCK_SOURCE_LAST + 1 + 7) 122#define MAX_CLOCKSOURCES (HPI_SAMPLECLOCK_SOURCE_LAST + 1 + 7)
115 123
116struct clk_source { 124struct clk_source {
@@ -139,7 +147,7 @@ struct snd_card_asihpi {
139 u32 h_mixer; 147 u32 h_mixer;
140 struct clk_cache cc; 148 struct clk_cache cc;
141 149
142 u16 support_mmap; 150 u16 can_dma;
143 u16 support_grouping; 151 u16 support_grouping;
144 u16 support_mrx; 152 u16 support_mrx;
145 u16 update_interval_frames; 153 u16 update_interval_frames;
@@ -152,11 +160,13 @@ struct snd_card_asihpi_pcm {
152 struct timer_list timer; 160 struct timer_list timer;
153 unsigned int respawn_timer; 161 unsigned int respawn_timer;
154 unsigned int hpi_buffer_attached; 162 unsigned int hpi_buffer_attached;
155 unsigned int pcm_size; 163 unsigned int buffer_bytes;
156 unsigned int pcm_count; 164 unsigned int period_bytes;
157 unsigned int bytes_per_sec; 165 unsigned int bytes_per_sec;
158 unsigned int pcm_irq_pos; /* IRQ position */ 166 unsigned int pcm_buf_host_rw_ofs; /* Host R/W pos */
159 unsigned int pcm_buf_pos; /* position in buffer */ 167 unsigned int pcm_buf_dma_ofs; /* DMA R/W offset in buffer */
168 unsigned int pcm_buf_elapsed_dma_ofs; /* DMA R/W offset in buffer */
169 unsigned int drained_count;
160 struct snd_pcm_substream *substream; 170 struct snd_pcm_substream *substream;
161 u32 h_stream; 171 u32 h_stream;
162 struct hpi_format format; 172 struct hpi_format format;
@@ -167,7 +177,6 @@ struct snd_card_asihpi_pcm {
167/* Functions to allow driver to give a buffer to HPI for busmastering */ 177/* Functions to allow driver to give a buffer to HPI for busmastering */
168 178
169static u16 hpi_stream_host_buffer_attach( 179static u16 hpi_stream_host_buffer_attach(
170 struct hpi_hsubsys *hS,
171 u32 h_stream, /* handle to outstream. */ 180 u32 h_stream, /* handle to outstream. */
172 u32 size_in_bytes, /* size in bytes of bus mastering buffer */ 181 u32 size_in_bytes, /* size in bytes of bus mastering buffer */
173 u32 pci_address 182 u32 pci_address
@@ -194,10 +203,7 @@ static u16 hpi_stream_host_buffer_attach(
194 return hr.error; 203 return hr.error;
195} 204}
196 205
197static u16 hpi_stream_host_buffer_detach( 206static u16 hpi_stream_host_buffer_detach(u32 h_stream)
198 struct hpi_hsubsys *hS,
199 u32 h_stream
200)
201{ 207{
202 struct hpi_message hm; 208 struct hpi_message hm;
203 struct hpi_response hr; 209 struct hpi_response hr;
@@ -218,24 +224,23 @@ static u16 hpi_stream_host_buffer_detach(
218 return hr.error; 224 return hr.error;
219} 225}
220 226
221static inline u16 hpi_stream_start(struct hpi_hsubsys *hS, u32 h_stream) 227static inline u16 hpi_stream_start(u32 h_stream)
222{ 228{
223 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) 229 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM)
224 return hpi_outstream_start(hS, h_stream); 230 return hpi_outstream_start(h_stream);
225 else 231 else
226 return hpi_instream_start(hS, h_stream); 232 return hpi_instream_start(h_stream);
227} 233}
228 234
229static inline u16 hpi_stream_stop(struct hpi_hsubsys *hS, u32 h_stream) 235static inline u16 hpi_stream_stop(u32 h_stream)
230{ 236{
231 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) 237 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM)
232 return hpi_outstream_stop(hS, h_stream); 238 return hpi_outstream_stop(h_stream);
233 else 239 else
234 return hpi_instream_stop(hS, h_stream); 240 return hpi_instream_stop(h_stream);
235} 241}
236 242
237static inline u16 hpi_stream_get_info_ex( 243static inline u16 hpi_stream_get_info_ex(
238 struct hpi_hsubsys *hS,
239 u32 h_stream, 244 u32 h_stream,
240 u16 *pw_state, 245 u16 *pw_state,
241 u32 *pbuffer_size, 246 u32 *pbuffer_size,
@@ -244,42 +249,43 @@ static inline u16 hpi_stream_get_info_ex(
244 u32 *pauxiliary_data 249 u32 *pauxiliary_data
245) 250)
246{ 251{
252 u16 e;
247 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) 253 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM)
248 return hpi_outstream_get_info_ex(hS, h_stream, pw_state, 254 e = hpi_outstream_get_info_ex(h_stream, pw_state,
249 pbuffer_size, pdata_in_buffer, 255 pbuffer_size, pdata_in_buffer,
250 psample_count, pauxiliary_data); 256 psample_count, pauxiliary_data);
251 else 257 else
252 return hpi_instream_get_info_ex(hS, h_stream, pw_state, 258 e = hpi_instream_get_info_ex(h_stream, pw_state,
253 pbuffer_size, pdata_in_buffer, 259 pbuffer_size, pdata_in_buffer,
254 psample_count, pauxiliary_data); 260 psample_count, pauxiliary_data);
261 return e;
255} 262}
256 263
257static inline u16 hpi_stream_group_add(struct hpi_hsubsys *hS, 264static inline u16 hpi_stream_group_add(
258 u32 h_master, 265 u32 h_master,
259 u32 h_stream) 266 u32 h_stream)
260{ 267{
261 if (hpi_handle_object(h_master) == HPI_OBJ_OSTREAM) 268 if (hpi_handle_object(h_master) == HPI_OBJ_OSTREAM)
262 return hpi_outstream_group_add(hS, h_master, h_stream); 269 return hpi_outstream_group_add(h_master, h_stream);
263 else 270 else
264 return hpi_instream_group_add(hS, h_master, h_stream); 271 return hpi_instream_group_add(h_master, h_stream);
265} 272}
266 273
267static inline u16 hpi_stream_group_reset(struct hpi_hsubsys *hS, 274static inline u16 hpi_stream_group_reset(u32 h_stream)
268 u32 h_stream)
269{ 275{
270 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) 276 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM)
271 return hpi_outstream_group_reset(hS, h_stream); 277 return hpi_outstream_group_reset(h_stream);
272 else 278 else
273 return hpi_instream_group_reset(hS, h_stream); 279 return hpi_instream_group_reset(h_stream);
274} 280}
275 281
276static inline u16 hpi_stream_group_get_map(struct hpi_hsubsys *hS, 282static inline u16 hpi_stream_group_get_map(
277 u32 h_stream, u32 *mo, u32 *mi) 283 u32 h_stream, u32 *mo, u32 *mi)
278{ 284{
279 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) 285 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM)
280 return hpi_outstream_group_get_map(hS, h_stream, mo, mi); 286 return hpi_outstream_group_get_map(h_stream, mo, mi);
281 else 287 else
282 return hpi_instream_group_get_map(hS, h_stream, mo, mi); 288 return hpi_instream_group_get_map(h_stream, mo, mi);
283} 289}
284 290
285static u16 handle_error(u16 err, int line, char *filename) 291static u16 handle_error(u16 err, int line, char *filename)
@@ -294,24 +300,27 @@ static u16 handle_error(u16 err, int line, char *filename)
294#define hpi_handle_error(x) handle_error(x, __LINE__, __FILE__) 300#define hpi_handle_error(x) handle_error(x, __LINE__, __FILE__)
295 301
296/***************************** GENERAL PCM ****************/ 302/***************************** GENERAL PCM ****************/
297#if REALLY_VERBOSE_LOGGING 303
298static void print_hwparams(struct snd_pcm_hw_params *p) 304static void print_hwparams(struct snd_pcm_substream *substream,
299{ 305 struct snd_pcm_hw_params *p)
300 snd_printd("HWPARAMS \n"); 306{
301 snd_printd("samplerate %d \n", params_rate(p)); 307 DEBUG_NAME(substream, name);
302 snd_printd("channels %d \n", params_channels(p)); 308 snd_printd("%s HWPARAMS\n", name);
303 snd_printd("format %d \n", params_format(p)); 309 snd_printd(" samplerate %d Hz\n", params_rate(p));
304 snd_printd("subformat %d \n", params_subformat(p)); 310 snd_printd(" channels %d\n", params_channels(p));
305 snd_printd("buffer bytes %d \n", params_buffer_bytes(p)); 311 snd_printd(" format %d\n", params_format(p));
306 snd_printd("period bytes %d \n", params_period_bytes(p)); 312 snd_printd(" subformat %d\n", params_subformat(p));
307 snd_printd("access %d \n", params_access(p)); 313 snd_printd(" buffer %d B\n", params_buffer_bytes(p));
308 snd_printd("period_size %d \n", params_period_size(p)); 314 snd_printd(" period %d B\n", params_period_bytes(p));
309 snd_printd("periods %d \n", params_periods(p)); 315 snd_printd(" access %d\n", params_access(p));
310 snd_printd("buffer_size %d \n", params_buffer_size(p)); 316 snd_printd(" period_size %d\n", params_period_size(p));
317 snd_printd(" periods %d\n", params_periods(p));
318 snd_printd(" buffer_size %d\n", params_buffer_size(p));
319 snd_printd(" %d B/s\n", params_rate(p) *
320 params_channels(p) *
321 snd_pcm_format_width(params_format(p)) / 8);
322
311} 323}
312#else
313#define print_hwparams(x)
314#endif
315 324
316static snd_pcm_format_t hpi_to_alsa_formats[] = { 325static snd_pcm_format_t hpi_to_alsa_formats[] = {
317 -1, /* INVALID */ 326 -1, /* INVALID */
@@ -335,7 +344,7 @@ static snd_pcm_format_t hpi_to_alsa_formats[] = {
335 */ 344 */
336 -1 345 -1
337#else 346#else
338 /* SNDRV_PCM_FORMAT_S24_3LE */ /* { HPI_FORMAT_PCM24_SIGNED 15 */ 347 /* SNDRV_PCM_FORMAT_S24_3LE */ /* HPI_FORMAT_PCM24_SIGNED 15 */
339#endif 348#endif
340}; 349};
341 350
@@ -378,21 +387,21 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi,
378 } else { 387 } else {
379 /* on cards without SRC, 388 /* on cards without SRC,
380 valid rates are determined by sampleclock */ 389 valid rates are determined by sampleclock */
381 err = hpi_mixer_get_control(ss, asihpi->h_mixer, 390 err = hpi_mixer_get_control(asihpi->h_mixer,
382 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, 391 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0,
383 HPI_CONTROL_SAMPLECLOCK, &h_control); 392 HPI_CONTROL_SAMPLECLOCK, &h_control);
384 if (err) { 393 if (err) {
385 snd_printk(KERN_ERR 394 snd_printk(KERN_ERR
386 "no local sampleclock, err %d\n", err); 395 "No local sampleclock, err %d\n", err);
387 } 396 }
388 397
389 for (idx = 0; idx < 100; idx++) { 398 for (idx = -1; idx < 100; idx++) {
390 if (hpi_sample_clock_query_local_rate(ss, 399 if (idx == -1) {
391 h_control, idx, &sample_rate)) { 400 if (hpi_sample_clock_get_sample_rate(h_control,
392 if (!idx) 401 &sample_rate))
393 snd_printk(KERN_ERR 402 continue;
394 "local rate query failed\n"); 403 } else if (hpi_sample_clock_query_local_rate(h_control,
395 404 idx, &sample_rate)) {
396 break; 405 break;
397 } 406 }
398 407
@@ -445,8 +454,6 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi,
445 } 454 }
446 } 455 }
447 456
448 /* printk(KERN_INFO "Supported rates %X %d %d\n",
449 rates, rate_min, rate_max); */
450 pcmhw->rates = rates; 457 pcmhw->rates = rates;
451 pcmhw->rate_min = rate_min; 458 pcmhw->rate_min = rate_min;
452 pcmhw->rate_max = rate_max; 459 pcmhw->rate_max = rate_max;
@@ -463,7 +470,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
463 int width; 470 int width;
464 unsigned int bytes_per_sec; 471 unsigned int bytes_per_sec;
465 472
466 print_hwparams(params); 473 print_hwparams(substream, params);
467 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); 474 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
468 if (err < 0) 475 if (err < 0)
469 return err; 476 return err;
@@ -471,45 +478,39 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
471 if (err) 478 if (err)
472 return err; 479 return err;
473 480
474 VPRINTK1(KERN_INFO "format %d, %d chans, %d_hz\n",
475 format, params_channels(params),
476 params_rate(params));
477
478 hpi_handle_error(hpi_format_create(&dpcm->format, 481 hpi_handle_error(hpi_format_create(&dpcm->format,
479 params_channels(params), 482 params_channels(params),
480 format, params_rate(params), 0, 0)); 483 format, params_rate(params), 0, 0));
481 484
482 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { 485 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
483 if (hpi_instream_reset(ss, dpcm->h_stream) != 0) 486 if (hpi_instream_reset(dpcm->h_stream) != 0)
484 return -EINVAL; 487 return -EINVAL;
485 488
486 if (hpi_instream_set_format(ss, 489 if (hpi_instream_set_format(
487 dpcm->h_stream, &dpcm->format) != 0) 490 dpcm->h_stream, &dpcm->format) != 0)
488 return -EINVAL; 491 return -EINVAL;
489 } 492 }
490 493
491 dpcm->hpi_buffer_attached = 0; 494 dpcm->hpi_buffer_attached = 0;
492 if (card->support_mmap) { 495 if (card->can_dma) {
493 496 err = hpi_stream_host_buffer_attach(dpcm->h_stream,
494 err = hpi_stream_host_buffer_attach(ss, dpcm->h_stream,
495 params_buffer_bytes(params), runtime->dma_addr); 497 params_buffer_bytes(params), runtime->dma_addr);
496 if (err == 0) { 498 if (err == 0) {
497 snd_printd(KERN_INFO 499 snd_printdd(
498 "stream_host_buffer_attach succeeded %u %lu\n", 500 "stream_host_buffer_attach succeeded %u %lu\n",
499 params_buffer_bytes(params), 501 params_buffer_bytes(params),
500 (unsigned long)runtime->dma_addr); 502 (unsigned long)runtime->dma_addr);
501 } else { 503 } else {
502 snd_printd(KERN_INFO 504 snd_printd("stream_host_buffer_attach error %d\n",
503 "stream_host_buffer_attach error %d\n",
504 err); 505 err);
505 return -ENOMEM; 506 return -ENOMEM;
506 } 507 }
507 508
508 err = hpi_stream_get_info_ex(ss, dpcm->h_stream, NULL, 509 err = hpi_stream_get_info_ex(dpcm->h_stream, NULL,
509 &dpcm->hpi_buffer_attached, 510 &dpcm->hpi_buffer_attached,
510 NULL, NULL, NULL); 511 NULL, NULL, NULL);
511 512
512 snd_printd(KERN_INFO "stream_host_buffer_attach status 0x%x\n", 513 snd_printdd("stream_host_buffer_attach status 0x%x\n",
513 dpcm->hpi_buffer_attached); 514 dpcm->hpi_buffer_attached);
514 } 515 }
515 bytes_per_sec = params_rate(params) * params_channels(params); 516 bytes_per_sec = params_rate(params) * params_channels(params);
@@ -520,16 +521,30 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
520 return -EINVAL; 521 return -EINVAL;
521 522
522 dpcm->bytes_per_sec = bytes_per_sec; 523 dpcm->bytes_per_sec = bytes_per_sec;
523 dpcm->pcm_size = params_buffer_bytes(params); 524 dpcm->buffer_bytes = params_buffer_bytes(params);
524 dpcm->pcm_count = params_period_bytes(params); 525 dpcm->period_bytes = params_period_bytes(params);
525 snd_printd(KERN_INFO "pcm_size=%d, pcm_count=%d, bps=%d\n",
526 dpcm->pcm_size, dpcm->pcm_count, bytes_per_sec);
527 526
528 dpcm->pcm_irq_pos = 0;
529 dpcm->pcm_buf_pos = 0;
530 return 0; 527 return 0;
531} 528}
532 529
530static int
531snd_card_asihpi_hw_free(struct snd_pcm_substream *substream)
532{
533 struct snd_pcm_runtime *runtime = substream->runtime;
534 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
535 if (dpcm->hpi_buffer_attached)
536 hpi_stream_host_buffer_detach(dpcm->h_stream);
537
538 snd_pcm_lib_free_pages(substream);
539 return 0;
540}
541
542static void snd_card_asihpi_runtime_free(struct snd_pcm_runtime *runtime)
543{
544 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
545 kfree(dpcm);
546}
547
533static void snd_card_asihpi_pcm_timer_start(struct snd_pcm_substream * 548static void snd_card_asihpi_pcm_timer_start(struct snd_pcm_substream *
534 substream) 549 substream)
535{ 550{
@@ -537,9 +552,9 @@ static void snd_card_asihpi_pcm_timer_start(struct snd_pcm_substream *
537 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 552 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
538 int expiry; 553 int expiry;
539 554
540 expiry = (dpcm->pcm_count * HZ / dpcm->bytes_per_sec); 555 expiry = HZ / 200;
541 /* wait longer the first time, for samples to propagate */ 556 /*? (dpcm->period_bytes * HZ / dpcm->bytes_per_sec); */
542 expiry = max(expiry, 20); 557 expiry = max(expiry, 1); /* don't let it be zero! */
543 dpcm->timer.expires = jiffies + expiry; 558 dpcm->timer.expires = jiffies + expiry;
544 dpcm->respawn_timer = 1; 559 dpcm->respawn_timer = 1;
545 add_timer(&dpcm->timer); 560 add_timer(&dpcm->timer);
@@ -561,38 +576,44 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
561 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); 576 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream);
562 struct snd_pcm_substream *s; 577 struct snd_pcm_substream *s;
563 u16 e; 578 u16 e;
579 DEBUG_NAME(substream, name);
580
581 snd_printdd("%s trigger\n", name);
564 582
565 snd_printd("trigger %dstream %d\n",
566 substream->stream, substream->number);
567 switch (cmd) { 583 switch (cmd) {
568 case SNDRV_PCM_TRIGGER_START: 584 case SNDRV_PCM_TRIGGER_START:
569 snd_pcm_group_for_each_entry(s, substream) { 585 snd_pcm_group_for_each_entry(s, substream) {
570 struct snd_card_asihpi_pcm *ds; 586 struct snd_pcm_runtime *runtime = s->runtime;
571 ds = s->runtime->private_data; 587 struct snd_card_asihpi_pcm *ds = runtime->private_data;
572 588
573 if (snd_pcm_substream_chip(s) != card) 589 if (snd_pcm_substream_chip(s) != card)
574 continue; 590 continue;
575 591
576 if ((s->stream == SNDRV_PCM_STREAM_PLAYBACK) && 592 /* don't link Cap and Play */
577 (card->support_mmap)) { 593 if (substream->stream != s->stream)
594 continue;
595
596 ds->drained_count = 0;
597 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
578 /* How do I know how much valid data is present 598 /* How do I know how much valid data is present
579 * in buffer? Just guessing 2 periods, but if 599 * in buffer? Must be at least one period!
600 * Guessing 2 periods, but if
580 * buffer is bigger it may contain even more 601 * buffer is bigger it may contain even more
581 * data?? 602 * data??
582 */ 603 */
583 unsigned int preload = ds->pcm_count * 2; 604 unsigned int preload = ds->period_bytes * 1;
584 VPRINTK2("preload %d\n", preload); 605 snd_printddd("%d preload x%x\n", s->number, preload);
585 hpi_handle_error(hpi_outstream_write_buf( 606 hpi_handle_error(hpi_outstream_write_buf(
586 ss, ds->h_stream, 607 ds->h_stream,
587 &s->runtime->dma_area[0], 608 &runtime->dma_area[0],
588 preload, 609 preload,
589 &ds->format)); 610 &ds->format));
611 ds->pcm_buf_host_rw_ofs = preload;
590 } 612 }
591 613
592 if (card->support_grouping) { 614 if (card->support_grouping) {
593 VPRINTK1("\t_group %dstream %d\n", s->stream, 615 snd_printdd("%d group\n", s->number);
594 s->number); 616 e = hpi_stream_group_add(
595 e = hpi_stream_group_add(ss,
596 dpcm->h_stream, 617 dpcm->h_stream,
597 ds->h_stream); 618 ds->h_stream);
598 if (!e) { 619 if (!e) {
@@ -604,10 +625,12 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
604 } else 625 } else
605 break; 626 break;
606 } 627 }
607 snd_printd("start\n"); 628 snd_printdd("start\n");
608 /* start the master stream */ 629 /* start the master stream */
609 snd_card_asihpi_pcm_timer_start(substream); 630 snd_card_asihpi_pcm_timer_start(substream);
610 hpi_handle_error(hpi_stream_start(ss, dpcm->h_stream)); 631 if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) ||
632 !card->can_dma)
633 hpi_handle_error(hpi_stream_start(dpcm->h_stream));
611 break; 634 break;
612 635
613 case SNDRV_PCM_TRIGGER_STOP: 636 case SNDRV_PCM_TRIGGER_STOP:
@@ -615,88 +638,71 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
615 snd_pcm_group_for_each_entry(s, substream) { 638 snd_pcm_group_for_each_entry(s, substream) {
616 if (snd_pcm_substream_chip(s) != card) 639 if (snd_pcm_substream_chip(s) != card)
617 continue; 640 continue;
641 /* don't link Cap and Play */
642 if (substream->stream != s->stream)
643 continue;
618 644
619 /*? workaround linked streams don't 645 /*? workaround linked streams don't
620 transition to SETUP 20070706*/ 646 transition to SETUP 20070706*/
621 s->runtime->status->state = SNDRV_PCM_STATE_SETUP; 647 s->runtime->status->state = SNDRV_PCM_STATE_SETUP;
622 648
623 if (card->support_grouping) { 649 if (card->support_grouping) {
624 VPRINTK1("\t_group %dstream %d\n", s->stream, 650 snd_printdd("%d group\n", s->number);
625 s->number);
626 snd_pcm_trigger_done(s, substream); 651 snd_pcm_trigger_done(s, substream);
627 } else 652 } else
628 break; 653 break;
629 } 654 }
630 snd_printd("stop\n"); 655 snd_printdd("stop\n");
631 656
632 /* _prepare and _hwparams reset the stream */ 657 /* _prepare and _hwparams reset the stream */
633 hpi_handle_error(hpi_stream_stop(ss, dpcm->h_stream)); 658 hpi_handle_error(hpi_stream_stop(dpcm->h_stream));
634 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 659 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
635 hpi_handle_error( 660 hpi_handle_error(
636 hpi_outstream_reset(ss, dpcm->h_stream)); 661 hpi_outstream_reset(dpcm->h_stream));
637 662
638 if (card->support_grouping) 663 if (card->support_grouping)
639 hpi_handle_error(hpi_stream_group_reset(ss, 664 hpi_handle_error(hpi_stream_group_reset(dpcm->h_stream));
640 dpcm->h_stream));
641 break; 665 break;
642 666
643 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 667 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
644 snd_printd("pause release\n"); 668 snd_printdd("pause release\n");
645 hpi_handle_error(hpi_stream_start(ss, dpcm->h_stream)); 669 hpi_handle_error(hpi_stream_start(dpcm->h_stream));
646 snd_card_asihpi_pcm_timer_start(substream); 670 snd_card_asihpi_pcm_timer_start(substream);
647 break; 671 break;
648 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 672 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
649 snd_printd("pause\n"); 673 snd_printdd("pause\n");
650 snd_card_asihpi_pcm_timer_stop(substream); 674 snd_card_asihpi_pcm_timer_stop(substream);
651 hpi_handle_error(hpi_stream_stop(ss, dpcm->h_stream)); 675 hpi_handle_error(hpi_stream_stop(dpcm->h_stream));
652 break; 676 break;
653 default: 677 default:
654 snd_printd("\tINVALID\n"); 678 snd_printd(KERN_ERR "\tINVALID\n");
655 return -EINVAL; 679 return -EINVAL;
656 } 680 }
657 681
658 return 0; 682 return 0;
659} 683}
660 684
661static int
662snd_card_asihpi_hw_free(struct snd_pcm_substream *substream)
663{
664 struct snd_pcm_runtime *runtime = substream->runtime;
665 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
666 if (dpcm->hpi_buffer_attached)
667 hpi_stream_host_buffer_detach(ss, dpcm->h_stream);
668
669 snd_pcm_lib_free_pages(substream);
670 return 0;
671}
672
673static void snd_card_asihpi_runtime_free(struct snd_pcm_runtime *runtime)
674{
675 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
676 kfree(dpcm);
677}
678
679/*algorithm outline 685/*algorithm outline
680 Without linking degenerates to getting single stream pos etc 686 Without linking degenerates to getting single stream pos etc
681 Without mmap 2nd loop degenerates to snd_pcm_period_elapsed 687 Without mmap 2nd loop degenerates to snd_pcm_period_elapsed
682*/ 688*/
683/* 689/*
684buf_pos=get_buf_pos(s); 690pcm_buf_dma_ofs=get_buf_pos(s);
685for_each_linked_stream(s) { 691for_each_linked_stream(s) {
686 buf_pos=get_buf_pos(s); 692 pcm_buf_dma_ofs=get_buf_pos(s);
687 min_buf_pos = modulo_min(min_buf_pos, buf_pos, pcm_size) 693 min_buf_pos = modulo_min(min_buf_pos, pcm_buf_dma_ofs, buffer_bytes)
688 new_data = min(new_data, calc_new_data(buf_pos,irq_pos) 694 new_data = min(new_data, calc_new_data(pcm_buf_dma_ofs,irq_pos)
689} 695}
690timer.expires = jiffies + predict_next_period_ready(min_buf_pos); 696timer.expires = jiffies + predict_next_period_ready(min_buf_pos);
691for_each_linked_stream(s) { 697for_each_linked_stream(s) {
692 s->buf_pos = min_buf_pos; 698 s->pcm_buf_dma_ofs = min_buf_pos;
693 if (new_data > pcm_count) { 699 if (new_data > period_bytes) {
694 if (mmap) { 700 if (mmap) {
695 irq_pos = (irq_pos + pcm_count) % pcm_size; 701 irq_pos = (irq_pos + period_bytes) % buffer_bytes;
696 if (playback) { 702 if (playback) {
697 write(pcm_count); 703 write(period_bytes);
698 } else { 704 } else {
699 read(pcm_count); 705 read(period_bytes);
700 } 706 }
701 } 707 }
702 snd_pcm_period_elapsed(s); 708 snd_pcm_period_elapsed(s);
@@ -724,105 +730,180 @@ static inline unsigned int modulo_min(unsigned int a, unsigned int b,
724static void snd_card_asihpi_timer_function(unsigned long data) 730static void snd_card_asihpi_timer_function(unsigned long data)
725{ 731{
726 struct snd_card_asihpi_pcm *dpcm = (struct snd_card_asihpi_pcm *)data; 732 struct snd_card_asihpi_pcm *dpcm = (struct snd_card_asihpi_pcm *)data;
727 struct snd_card_asihpi *card = snd_pcm_substream_chip(dpcm->substream); 733 struct snd_pcm_substream *substream = dpcm->substream;
734 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream);
728 struct snd_pcm_runtime *runtime; 735 struct snd_pcm_runtime *runtime;
729 struct snd_pcm_substream *s; 736 struct snd_pcm_substream *s;
730 unsigned int newdata = 0; 737 unsigned int newdata = 0;
731 unsigned int buf_pos, min_buf_pos = 0; 738 unsigned int pcm_buf_dma_ofs, min_buf_pos = 0;
732 unsigned int remdata, xfercount, next_jiffies; 739 unsigned int remdata, xfercount, next_jiffies;
733 int first = 1; 740 int first = 1;
741 int loops = 0;
734 u16 state; 742 u16 state;
735 u32 buffer_size, data_avail, samples_played, aux; 743 u32 buffer_size, bytes_avail, samples_played, on_card_bytes;
744 DEBUG_NAME(substream, name);
745
746 snd_printdd("%s snd_card_asihpi_timer_function\n", name);
736 747
737 /* find minimum newdata and buffer pos in group */ 748 /* find minimum newdata and buffer pos in group */
738 snd_pcm_group_for_each_entry(s, dpcm->substream) { 749 snd_pcm_group_for_each_entry(s, substream) {
739 struct snd_card_asihpi_pcm *ds = s->runtime->private_data; 750 struct snd_card_asihpi_pcm *ds = s->runtime->private_data;
740 runtime = s->runtime; 751 runtime = s->runtime;
741 752
742 if (snd_pcm_substream_chip(s) != card) 753 if (snd_pcm_substream_chip(s) != card)
743 continue; 754 continue;
744 755
745 hpi_handle_error(hpi_stream_get_info_ex(ss, 756 /* don't link Cap and Play */
757 if (substream->stream != s->stream)
758 continue;
759
760 hpi_handle_error(hpi_stream_get_info_ex(
746 ds->h_stream, &state, 761 ds->h_stream, &state,
747 &buffer_size, &data_avail, 762 &buffer_size, &bytes_avail,
748 &samples_played, &aux)); 763 &samples_played, &on_card_bytes));
749 764
750 /* number of bytes in on-card buffer */ 765 /* number of bytes in on-card buffer */
751 runtime->delay = aux; 766 runtime->delay = on_card_bytes;
752 767
753 if (state == HPI_STATE_DRAINED) { 768 if (!card->can_dma)
754 snd_printd(KERN_WARNING "outstream %d drained\n", 769 on_card_bytes = bytes_avail;
755 s->number);
756 snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN);
757 return;
758 }
759 770
760 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { 771 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
761 buf_pos = frames_to_bytes(runtime, samples_played); 772 pcm_buf_dma_ofs = ds->pcm_buf_host_rw_ofs - bytes_avail;
762 } else { 773 if (state == HPI_STATE_STOPPED) {
763 buf_pos = data_avail + ds->pcm_irq_pos; 774 if ((bytes_avail == 0) &&
764 } 775 (on_card_bytes < ds->pcm_buf_host_rw_ofs)) {
776 hpi_handle_error(hpi_stream_start(ds->h_stream));
777 snd_printdd("P%d start\n", s->number);
778 ds->drained_count = 0;
779 }
780 } else if (state == HPI_STATE_DRAINED) {
781 snd_printd(KERN_WARNING "P%d drained\n",
782 s->number);
783 ds->drained_count++;
784 if (ds->drained_count > 2) {
785 snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN);
786 continue;
787 }
788 } else {
789 ds->drained_count = 0;
790 }
791 } else
792 pcm_buf_dma_ofs = bytes_avail + ds->pcm_buf_host_rw_ofs;
765 793
766 if (first) { 794 if (first) {
767 /* can't statically init min when wrap is involved */ 795 /* can't statically init min when wrap is involved */
768 min_buf_pos = buf_pos; 796 min_buf_pos = pcm_buf_dma_ofs;
769 newdata = (buf_pos - ds->pcm_irq_pos) % ds->pcm_size; 797 newdata = (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->buffer_bytes;
770 first = 0; 798 first = 0;
771 } else { 799 } else {
772 min_buf_pos = 800 min_buf_pos =
773 modulo_min(min_buf_pos, buf_pos, UINT_MAX+1L); 801 modulo_min(min_buf_pos, pcm_buf_dma_ofs, UINT_MAX+1L);
774 newdata = min( 802 newdata = min(
775 (buf_pos - ds->pcm_irq_pos) % ds->pcm_size, 803 (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->buffer_bytes,
776 newdata); 804 newdata);
777 } 805 }
778 806
779 VPRINTK1("PB timer hw_ptr x%04lX, appl_ptr x%04lX\n", 807 snd_printdd("hw_ptr 0x%04lX, appl_ptr 0x%04lX\n",
780 (unsigned long)frames_to_bytes(runtime, 808 (unsigned long)frames_to_bytes(runtime,
781 runtime->status->hw_ptr), 809 runtime->status->hw_ptr),
782 (unsigned long)frames_to_bytes(runtime, 810 (unsigned long)frames_to_bytes(runtime,
783 runtime->control->appl_ptr)); 811 runtime->control->appl_ptr));
784 VPRINTK1("%d S=%d, irq=%04X, pos=x%04X, left=x%04X," 812
785 " aux=x%04X space=x%04X\n", s->number, 813 snd_printdd("%d S=%d, "
786 state, ds->pcm_irq_pos, buf_pos, (int)data_avail, 814 "rw=0x%04X, dma=0x%04X, left=0x%04X, "
787 (int)aux, buffer_size-data_avail); 815 "aux=0x%04X space=0x%04X\n",
816 s->number, state,
817 ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs,
818 (int)bytes_avail,
819 (int)on_card_bytes, buffer_size-bytes_avail);
820 loops++;
788 } 821 }
822 pcm_buf_dma_ofs = min_buf_pos;
823
824 remdata = newdata % dpcm->period_bytes;
825 xfercount = newdata - remdata; /* a multiple of period_bytes */
826 /* come back when on_card_bytes has decreased enough to allow
827 write to happen, or when data has been consumed to make another
828 period
829 */
830 if (xfercount && (on_card_bytes > dpcm->period_bytes))
831 next_jiffies = ((on_card_bytes - dpcm->period_bytes) * HZ / dpcm->bytes_per_sec);
832 else
833 next_jiffies = ((dpcm->period_bytes - remdata) * HZ / dpcm->bytes_per_sec);
789 834
790 remdata = newdata % dpcm->pcm_count; 835 next_jiffies = max(next_jiffies, 1U);
791 xfercount = newdata - remdata; /* a multiple of pcm_count */
792 next_jiffies = ((dpcm->pcm_count-remdata) * HZ / dpcm->bytes_per_sec)+1;
793 next_jiffies = max(next_jiffies, 2U * HZ / 1000U);
794 dpcm->timer.expires = jiffies + next_jiffies; 836 dpcm->timer.expires = jiffies + next_jiffies;
795 VPRINTK1("jif %d buf pos x%04X newdata x%04X xc x%04X\n", 837 snd_printdd("jif %d buf pos 0x%04X newdata 0x%04X xfer 0x%04X\n",
796 next_jiffies, min_buf_pos, newdata, xfercount); 838 next_jiffies, pcm_buf_dma_ofs, newdata, xfercount);
797 839
798 snd_pcm_group_for_each_entry(s, dpcm->substream) { 840 snd_pcm_group_for_each_entry(s, substream) {
799 struct snd_card_asihpi_pcm *ds = s->runtime->private_data; 841 struct snd_card_asihpi_pcm *ds = s->runtime->private_data;
800 ds->pcm_buf_pos = min_buf_pos;
801 842
802 if (xfercount) { 843 /* don't link Cap and Play */
803 if (card->support_mmap) { 844 if (substream->stream != s->stream)
804 ds->pcm_irq_pos = ds->pcm_irq_pos + xfercount; 845 continue;
805 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { 846
806 VPRINTK2("write OS%d x%04x\n", 847 ds->pcm_buf_dma_ofs = pcm_buf_dma_ofs;
848
849 if (xfercount &&
850 /* Limit use of on card fifo for playback */
851 ((on_card_bytes <= ds->period_bytes) ||
852 (s->stream == SNDRV_PCM_STREAM_CAPTURE)))
853
854 {
855
856 unsigned int buf_ofs = ds->pcm_buf_host_rw_ofs % ds->buffer_bytes;
857 unsigned int xfer1, xfer2;
858 char *pd = &s->runtime->dma_area[buf_ofs];
859
860 if (card->can_dma) { /* buffer wrap is handled at lower level */
861 xfer1 = xfercount;
862 xfer2 = 0;
863 } else {
864 xfer1 = min(xfercount, ds->buffer_bytes - buf_ofs);
865 xfer2 = xfercount - xfer1;
866 }
867
868 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
869 snd_printddd("P%d write1 0x%04X 0x%04X\n",
870 s->number, xfer1, buf_ofs);
871 hpi_handle_error(
872 hpi_outstream_write_buf(
873 ds->h_stream, pd, xfer1,
874 &ds->format));
875
876 if (xfer2) {
877 pd = s->runtime->dma_area;
878
879 snd_printddd("P%d write2 0x%04X 0x%04X\n",
807 s->number, 880 s->number,
808 ds->pcm_count); 881 xfercount - xfer1, buf_ofs);
809 hpi_handle_error( 882 hpi_handle_error(
810 hpi_outstream_write_buf( 883 hpi_outstream_write_buf(
811 ss, ds->h_stream, 884 ds->h_stream, pd,
812 &s->runtime-> 885 xfercount - xfer1,
813 dma_area[0],
814 xfercount,
815 &ds->format)); 886 &ds->format));
816 } else { 887 }
817 VPRINTK2("read IS%d x%04x\n", 888 } else {
818 s->number, 889 snd_printddd("C%d read1 0x%04x\n",
819 dpcm->pcm_count); 890 s->number, xfer1);
891 hpi_handle_error(
892 hpi_instream_read_buf(
893 ds->h_stream,
894 pd, xfer1));
895 if (xfer2) {
896 pd = s->runtime->dma_area;
897 snd_printddd("C%d read2 0x%04x\n",
898 s->number, xfer2);
820 hpi_handle_error( 899 hpi_handle_error(
821 hpi_instream_read_buf( 900 hpi_instream_read_buf(
822 ss, ds->h_stream, 901 ds->h_stream,
823 NULL, xfercount)); 902 pd, xfer2));
824 } 903 }
825 } /* else R/W will be handled by read/write callbacks */ 904 }
905 ds->pcm_buf_host_rw_ofs = ds->pcm_buf_host_rw_ofs + xfercount;
906 ds->pcm_buf_elapsed_dma_ofs = pcm_buf_dma_ofs;
826 snd_pcm_period_elapsed(s); 907 snd_pcm_period_elapsed(s);
827 } 908 }
828 } 909 }
@@ -835,7 +916,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
835static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream, 916static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream,
836 unsigned int cmd, void *arg) 917 unsigned int cmd, void *arg)
837{ 918{
838 /* snd_printd(KERN_INFO "Playback ioctl %d\n", cmd); */ 919 snd_printddd(KERN_INFO "P%d ioctl %d\n", substream->number, cmd);
839 return snd_pcm_lib_ioctl(substream, cmd, arg); 920 return snd_pcm_lib_ioctl(substream, cmd, arg);
840} 921}
841 922
@@ -845,12 +926,12 @@ static int snd_card_asihpi_playback_prepare(struct snd_pcm_substream *
845 struct snd_pcm_runtime *runtime = substream->runtime; 926 struct snd_pcm_runtime *runtime = substream->runtime;
846 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 927 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
847 928
848 snd_printd(KERN_INFO "playback prepare %d\n", substream->number); 929 snd_printdd("P%d prepare\n", substream->number);
849
850 hpi_handle_error(hpi_outstream_reset(ss, dpcm->h_stream));
851 dpcm->pcm_irq_pos = 0;
852 dpcm->pcm_buf_pos = 0;
853 930
931 hpi_handle_error(hpi_outstream_reset(dpcm->h_stream));
932 dpcm->pcm_buf_host_rw_ofs = 0;
933 dpcm->pcm_buf_dma_ofs = 0;
934 dpcm->pcm_buf_elapsed_dma_ofs = 0;
854 return 0; 935 return 0;
855} 936}
856 937
@@ -861,27 +942,8 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream)
861 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 942 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
862 snd_pcm_uframes_t ptr; 943 snd_pcm_uframes_t ptr;
863 944
864 u32 samples_played; 945 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes);
865 u16 err; 946 snd_printddd("P%d pointer = 0x%04lx\n", substream->number, (unsigned long)ptr);
866
867 if (!snd_pcm_stream_linked(substream)) {
868 /* NOTE, can use samples played for playback position here and
869 * in timer fn because it LAGS the actual read pointer, and is a
870 * better representation of actual playout position
871 */
872 err = hpi_outstream_get_info_ex(ss, dpcm->h_stream, NULL,
873 NULL, NULL,
874 &samples_played, NULL);
875 hpi_handle_error(err);
876
877 dpcm->pcm_buf_pos = frames_to_bytes(runtime, samples_played);
878 }
879 /* else must return most conservative value found in timer func
880 * by looping over all streams
881 */
882
883 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_pos % dpcm->pcm_size);
884 VPRINTK2("playback_pointer=%04ld\n", (unsigned long)ptr);
885 return ptr; 947 return ptr;
886} 948}
887 949
@@ -898,12 +960,12 @@ static void snd_card_asihpi_playback_format(struct snd_card_asihpi *asihpi,
898 /* on cards without SRC, must query at valid rate, 960 /* on cards without SRC, must query at valid rate,
899 * maybe set by external sync 961 * maybe set by external sync
900 */ 962 */
901 err = hpi_mixer_get_control(ss, asihpi->h_mixer, 963 err = hpi_mixer_get_control(asihpi->h_mixer,
902 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, 964 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0,
903 HPI_CONTROL_SAMPLECLOCK, &h_control); 965 HPI_CONTROL_SAMPLECLOCK, &h_control);
904 966
905 if (!err) 967 if (!err)
906 err = hpi_sample_clock_get_sample_rate(ss, h_control, 968 err = hpi_sample_clock_get_sample_rate(h_control,
907 &sample_rate); 969 &sample_rate);
908 970
909 for (format = HPI_FORMAT_PCM8_UNSIGNED; 971 for (format = HPI_FORMAT_PCM8_UNSIGNED;
@@ -911,7 +973,7 @@ static void snd_card_asihpi_playback_format(struct snd_card_asihpi *asihpi,
911 err = hpi_format_create(&hpi_format, 973 err = hpi_format_create(&hpi_format,
912 2, format, sample_rate, 128000, 0); 974 2, format, sample_rate, 128000, 0);
913 if (!err) 975 if (!err)
914 err = hpi_outstream_query_format(ss, h_stream, 976 err = hpi_outstream_query_format(h_stream,
915 &hpi_format); 977 &hpi_format);
916 if (!err && (hpi_to_alsa_formats[format] != -1)) 978 if (!err && (hpi_to_alsa_formats[format] != -1))
917 pcmhw->formats |= 979 pcmhw->formats |=
@@ -942,7 +1004,7 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
942 return -ENOMEM; 1004 return -ENOMEM;
943 1005
944 err = 1006 err =
945 hpi_outstream_open(ss, card->adapter_index, 1007 hpi_outstream_open(card->adapter_index,
946 substream->number, &dpcm->h_stream); 1008 substream->number, &dpcm->h_stream);
947 hpi_handle_error(err); 1009 hpi_handle_error(err);
948 if (err) 1010 if (err)
@@ -954,7 +1016,7 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
954 1016
955 /*? also check ASI5000 samplerate source 1017 /*? also check ASI5000 samplerate source
956 If external, only support external rate. 1018 If external, only support external rate.
957 If internal and other stream playing, cant switch 1019 If internal and other stream playing, can't switch
958 */ 1020 */
959 1021
960 init_timer(&dpcm->timer); 1022 init_timer(&dpcm->timer);
@@ -977,11 +1039,9 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
977 SNDRV_PCM_INFO_DOUBLE | 1039 SNDRV_PCM_INFO_DOUBLE |
978 SNDRV_PCM_INFO_BATCH | 1040 SNDRV_PCM_INFO_BATCH |
979 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1041 SNDRV_PCM_INFO_BLOCK_TRANSFER |
980 SNDRV_PCM_INFO_PAUSE; 1042 SNDRV_PCM_INFO_PAUSE |
981 1043 SNDRV_PCM_INFO_MMAP |
982 if (card->support_mmap) 1044 SNDRV_PCM_INFO_MMAP_VALID;
983 snd_card_asihpi_playback.info |= SNDRV_PCM_INFO_MMAP |
984 SNDRV_PCM_INFO_MMAP_VALID;
985 1045
986 if (card->support_grouping) 1046 if (card->support_grouping)
987 snd_card_asihpi_playback.info |= SNDRV_PCM_INFO_SYNC_START; 1047 snd_card_asihpi_playback.info |= SNDRV_PCM_INFO_SYNC_START;
@@ -989,7 +1049,7 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
989 /* struct is copied, so can create initializer dynamically */ 1049 /* struct is copied, so can create initializer dynamically */
990 runtime->hw = snd_card_asihpi_playback; 1050 runtime->hw = snd_card_asihpi_playback;
991 1051
992 if (card->support_mmap) 1052 if (card->can_dma)
993 err = snd_pcm_hw_constraint_pow2(runtime, 0, 1053 err = snd_pcm_hw_constraint_pow2(runtime, 0,
994 SNDRV_PCM_HW_PARAM_BUFFER_BYTES); 1054 SNDRV_PCM_HW_PARAM_BUFFER_BYTES);
995 if (err < 0) 1055 if (err < 0)
@@ -997,12 +1057,13 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
997 1057
998 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 1058 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
999 card->update_interval_frames); 1059 card->update_interval_frames);
1060
1000 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 1061 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
1001 card->update_interval_frames * 4, UINT_MAX); 1062 card->update_interval_frames * 2, UINT_MAX);
1002 1063
1003 snd_pcm_set_sync(substream); 1064 snd_pcm_set_sync(substream);
1004 1065
1005 snd_printd(KERN_INFO "playback open\n"); 1066 snd_printdd("playback open\n");
1006 1067
1007 return 0; 1068 return 0;
1008} 1069}
@@ -1012,67 +1073,12 @@ static int snd_card_asihpi_playback_close(struct snd_pcm_substream *substream)
1012 struct snd_pcm_runtime *runtime = substream->runtime; 1073 struct snd_pcm_runtime *runtime = substream->runtime;
1013 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 1074 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
1014 1075
1015 hpi_handle_error(hpi_outstream_close(ss, dpcm->h_stream)); 1076 hpi_handle_error(hpi_outstream_close(dpcm->h_stream));
1016 snd_printd(KERN_INFO "playback close\n"); 1077 snd_printdd("playback close\n");
1017
1018 return 0;
1019}
1020
1021static int snd_card_asihpi_playback_copy(struct snd_pcm_substream *substream,
1022 int channel,
1023 snd_pcm_uframes_t pos,
1024 void __user *src,
1025 snd_pcm_uframes_t count)
1026{
1027 struct snd_pcm_runtime *runtime = substream->runtime;
1028 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
1029 unsigned int len;
1030
1031 len = frames_to_bytes(runtime, count);
1032
1033 if (copy_from_user(runtime->dma_area, src, len))
1034 return -EFAULT;
1035
1036 VPRINTK2(KERN_DEBUG "playback copy%d %u bytes\n",
1037 substream->number, len);
1038
1039 hpi_handle_error(hpi_outstream_write_buf(ss, dpcm->h_stream,
1040 runtime->dma_area, len, &dpcm->format));
1041
1042 return 0;
1043}
1044
1045static int snd_card_asihpi_playback_silence(struct snd_pcm_substream *
1046 substream, int channel,
1047 snd_pcm_uframes_t pos,
1048 snd_pcm_uframes_t count)
1049{
1050 unsigned int len;
1051 struct snd_pcm_runtime *runtime = substream->runtime;
1052 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
1053
1054 len = frames_to_bytes(runtime, count);
1055 snd_printd(KERN_INFO "playback silence %u bytes\n", len);
1056 1078
1057 memset(runtime->dma_area, 0, len);
1058 hpi_handle_error(hpi_outstream_write_buf(ss, dpcm->h_stream,
1059 runtime->dma_area, len, &dpcm->format));
1060 return 0; 1079 return 0;
1061} 1080}
1062 1081
1063static struct snd_pcm_ops snd_card_asihpi_playback_ops = {
1064 .open = snd_card_asihpi_playback_open,
1065 .close = snd_card_asihpi_playback_close,
1066 .ioctl = snd_card_asihpi_playback_ioctl,
1067 .hw_params = snd_card_asihpi_pcm_hw_params,
1068 .hw_free = snd_card_asihpi_hw_free,
1069 .prepare = snd_card_asihpi_playback_prepare,
1070 .trigger = snd_card_asihpi_trigger,
1071 .pointer = snd_card_asihpi_playback_pointer,
1072 .copy = snd_card_asihpi_playback_copy,
1073 .silence = snd_card_asihpi_playback_silence,
1074};
1075
1076static struct snd_pcm_ops snd_card_asihpi_playback_mmap_ops = { 1082static struct snd_pcm_ops snd_card_asihpi_playback_mmap_ops = {
1077 .open = snd_card_asihpi_playback_open, 1083 .open = snd_card_asihpi_playback_open,
1078 .close = snd_card_asihpi_playback_close, 1084 .close = snd_card_asihpi_playback_close,
@@ -1091,13 +1097,13 @@ snd_card_asihpi_capture_pointer(struct snd_pcm_substream *substream)
1091 struct snd_pcm_runtime *runtime = substream->runtime; 1097 struct snd_pcm_runtime *runtime = substream->runtime;
1092 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 1098 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
1093 1099
1094 VPRINTK2("capture pointer %d=%d\n", 1100 snd_printddd("capture pointer %d=%d\n",
1095 substream->number, dpcm->pcm_buf_pos); 1101 substream->number, dpcm->pcm_buf_dma_ofs);
1096 /* NOTE Unlike playback can't use actual dwSamplesPlayed 1102 /* NOTE Unlike playback can't use actual samples_played
1097 for the capture position, because those samples aren't yet in 1103 for the capture position, because those samples aren't yet in
1098 the local buffer available for reading. 1104 the local buffer available for reading.
1099 */ 1105 */
1100 return bytes_to_frames(runtime, dpcm->pcm_buf_pos % dpcm->pcm_size); 1106 return bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes);
1101} 1107}
1102 1108
1103static int snd_card_asihpi_capture_ioctl(struct snd_pcm_substream *substream, 1109static int snd_card_asihpi_capture_ioctl(struct snd_pcm_substream *substream,
@@ -1111,11 +1117,12 @@ static int snd_card_asihpi_capture_prepare(struct snd_pcm_substream *substream)
1111 struct snd_pcm_runtime *runtime = substream->runtime; 1117 struct snd_pcm_runtime *runtime = substream->runtime;
1112 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 1118 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
1113 1119
1114 hpi_handle_error(hpi_instream_reset(ss, dpcm->h_stream)); 1120 hpi_handle_error(hpi_instream_reset(dpcm->h_stream));
1115 dpcm->pcm_irq_pos = 0; 1121 dpcm->pcm_buf_host_rw_ofs = 0;
1116 dpcm->pcm_buf_pos = 0; 1122 dpcm->pcm_buf_dma_ofs = 0;
1123 dpcm->pcm_buf_elapsed_dma_ofs = 0;
1117 1124
1118 snd_printd("capture prepare %d\n", substream->number); 1125 snd_printdd("Capture Prepare %d\n", substream->number);
1119 return 0; 1126 return 0;
1120} 1127}
1121 1128
@@ -1133,12 +1140,12 @@ static void snd_card_asihpi_capture_format(struct snd_card_asihpi *asihpi,
1133 1140
1134 /* on cards without SRC, must query at valid rate, 1141 /* on cards without SRC, must query at valid rate,
1135 maybe set by external sync */ 1142 maybe set by external sync */
1136 err = hpi_mixer_get_control(ss, asihpi->h_mixer, 1143 err = hpi_mixer_get_control(asihpi->h_mixer,
1137 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, 1144 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0,
1138 HPI_CONTROL_SAMPLECLOCK, &h_control); 1145 HPI_CONTROL_SAMPLECLOCK, &h_control);
1139 1146
1140 if (!err) 1147 if (!err)
1141 err = hpi_sample_clock_get_sample_rate(ss, h_control, 1148 err = hpi_sample_clock_get_sample_rate(h_control,
1142 &sample_rate); 1149 &sample_rate);
1143 1150
1144 for (format = HPI_FORMAT_PCM8_UNSIGNED; 1151 for (format = HPI_FORMAT_PCM8_UNSIGNED;
@@ -1147,7 +1154,7 @@ static void snd_card_asihpi_capture_format(struct snd_card_asihpi *asihpi,
1147 err = hpi_format_create(&hpi_format, 2, format, 1154 err = hpi_format_create(&hpi_format, 2, format,
1148 sample_rate, 128000, 0); 1155 sample_rate, 128000, 0);
1149 if (!err) 1156 if (!err)
1150 err = hpi_instream_query_format(ss, h_stream, 1157 err = hpi_instream_query_format(h_stream,
1151 &hpi_format); 1158 &hpi_format);
1152 if (!err) 1159 if (!err)
1153 pcmhw->formats |= 1160 pcmhw->formats |=
@@ -1178,11 +1185,11 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
1178 if (dpcm == NULL) 1185 if (dpcm == NULL)
1179 return -ENOMEM; 1186 return -ENOMEM;
1180 1187
1181 snd_printd("hpi_instream_open adapter %d stream %d\n", 1188 snd_printdd("capture open adapter %d stream %d\n",
1182 card->adapter_index, substream->number); 1189 card->adapter_index, substream->number);
1183 1190
1184 err = hpi_handle_error( 1191 err = hpi_handle_error(
1185 hpi_instream_open(ss, card->adapter_index, 1192 hpi_instream_open(card->adapter_index,
1186 substream->number, &dpcm->h_stream)); 1193 substream->number, &dpcm->h_stream));
1187 if (err) 1194 if (err)
1188 kfree(dpcm); 1195 kfree(dpcm);
@@ -1203,15 +1210,16 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
1203 snd_card_asihpi_capture_format(card, dpcm->h_stream, 1210 snd_card_asihpi_capture_format(card, dpcm->h_stream,
1204 &snd_card_asihpi_capture); 1211 &snd_card_asihpi_capture);
1205 snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_capture); 1212 snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_capture);
1206 snd_card_asihpi_capture.info = SNDRV_PCM_INFO_INTERLEAVED; 1213 snd_card_asihpi_capture.info = SNDRV_PCM_INFO_INTERLEAVED |
1214 SNDRV_PCM_INFO_MMAP |
1215 SNDRV_PCM_INFO_MMAP_VALID;
1207 1216
1208 if (card->support_mmap) 1217 if (card->support_grouping)
1209 snd_card_asihpi_capture.info |= SNDRV_PCM_INFO_MMAP | 1218 snd_card_asihpi_capture.info |= SNDRV_PCM_INFO_SYNC_START;
1210 SNDRV_PCM_INFO_MMAP_VALID;
1211 1219
1212 runtime->hw = snd_card_asihpi_capture; 1220 runtime->hw = snd_card_asihpi_capture;
1213 1221
1214 if (card->support_mmap) 1222 if (card->can_dma)
1215 err = snd_pcm_hw_constraint_pow2(runtime, 0, 1223 err = snd_pcm_hw_constraint_pow2(runtime, 0,
1216 SNDRV_PCM_HW_PARAM_BUFFER_BYTES); 1224 SNDRV_PCM_HW_PARAM_BUFFER_BYTES);
1217 if (err < 0) 1225 if (err < 0)
@@ -1231,30 +1239,7 @@ static int snd_card_asihpi_capture_close(struct snd_pcm_substream *substream)
1231{ 1239{
1232 struct snd_card_asihpi_pcm *dpcm = substream->runtime->private_data; 1240 struct snd_card_asihpi_pcm *dpcm = substream->runtime->private_data;
1233 1241
1234 hpi_handle_error(hpi_instream_close(ss, dpcm->h_stream)); 1242 hpi_handle_error(hpi_instream_close(dpcm->h_stream));
1235 return 0;
1236}
1237
1238static int snd_card_asihpi_capture_copy(struct snd_pcm_substream *substream,
1239 int channel, snd_pcm_uframes_t pos,
1240 void __user *dst, snd_pcm_uframes_t count)
1241{
1242 struct snd_pcm_runtime *runtime = substream->runtime;
1243 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
1244 u32 data_size;
1245
1246 data_size = frames_to_bytes(runtime, count);
1247
1248 VPRINTK2("capture copy%d %d bytes\n", substream->number, data_size);
1249 hpi_handle_error(hpi_instream_read_buf(ss, dpcm->h_stream,
1250 runtime->dma_area, data_size));
1251
1252 /* Used by capture_pointer */
1253 dpcm->pcm_irq_pos = dpcm->pcm_irq_pos + data_size;
1254
1255 if (copy_to_user(dst, runtime->dma_area, data_size))
1256 return -EFAULT;
1257
1258 return 0; 1243 return 0;
1259} 1244}
1260 1245
@@ -1269,45 +1254,26 @@ static struct snd_pcm_ops snd_card_asihpi_capture_mmap_ops = {
1269 .pointer = snd_card_asihpi_capture_pointer, 1254 .pointer = snd_card_asihpi_capture_pointer,
1270}; 1255};
1271 1256
1272static struct snd_pcm_ops snd_card_asihpi_capture_ops = {
1273 .open = snd_card_asihpi_capture_open,
1274 .close = snd_card_asihpi_capture_close,
1275 .ioctl = snd_card_asihpi_capture_ioctl,
1276 .hw_params = snd_card_asihpi_pcm_hw_params,
1277 .hw_free = snd_card_asihpi_hw_free,
1278 .prepare = snd_card_asihpi_capture_prepare,
1279 .trigger = snd_card_asihpi_trigger,
1280 .pointer = snd_card_asihpi_capture_pointer,
1281 .copy = snd_card_asihpi_capture_copy
1282};
1283
1284static int __devinit snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, 1257static int __devinit snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi,
1285 int device, int substreams) 1258 int device, int substreams)
1286{ 1259{
1287 struct snd_pcm *pcm; 1260 struct snd_pcm *pcm;
1288 int err; 1261 int err;
1289 1262
1290 err = snd_pcm_new(asihpi->card, "asihpi PCM", device, 1263 err = snd_pcm_new(asihpi->card, "Asihpi PCM", device,
1291 asihpi->num_outstreams, asihpi->num_instreams, 1264 asihpi->num_outstreams, asihpi->num_instreams,
1292 &pcm); 1265 &pcm);
1293 if (err < 0) 1266 if (err < 0)
1294 return err; 1267 return err;
1295 /* pointer to ops struct is stored, dont change ops afterwards! */ 1268 /* pointer to ops struct is stored, dont change ops afterwards! */
1296 if (asihpi->support_mmap) {
1297 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1269 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
1298 &snd_card_asihpi_playback_mmap_ops); 1270 &snd_card_asihpi_playback_mmap_ops);
1299 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, 1271 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
1300 &snd_card_asihpi_capture_mmap_ops); 1272 &snd_card_asihpi_capture_mmap_ops);
1301 } else {
1302 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
1303 &snd_card_asihpi_playback_ops);
1304 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
1305 &snd_card_asihpi_capture_ops);
1306 }
1307 1273
1308 pcm->private_data = asihpi; 1274 pcm->private_data = asihpi;
1309 pcm->info_flags = 0; 1275 pcm->info_flags = 0;
1310 strcpy(pcm->name, "asihpi PCM"); 1276 strcpy(pcm->name, "Asihpi PCM");
1311 1277
1312 /*? do we want to emulate MMAP for non-BBM cards? 1278 /*? do we want to emulate MMAP for non-BBM cards?
1313 Jack doesn't work with ALSAs MMAP emulation - WHY NOT? */ 1279 Jack doesn't work with ALSAs MMAP emulation - WHY NOT? */
@@ -1330,8 +1296,7 @@ struct hpi_control {
1330 char name[44]; /* copied to snd_ctl_elem_id.name[44]; */ 1296 char name[44]; /* copied to snd_ctl_elem_id.name[44]; */
1331}; 1297};
1332 1298
1333static char *asihpi_tuner_band_names[] = 1299static const char * const asihpi_tuner_band_names[] = {
1334{
1335 "invalid", 1300 "invalid",
1336 "AM", 1301 "AM",
1337 "FM mono", 1302 "FM mono",
@@ -1349,70 +1314,36 @@ compile_time_assert(
1349 (HPI_TUNER_BAND_LAST+1)), 1314 (HPI_TUNER_BAND_LAST+1)),
1350 assert_tuner_band_names_size); 1315 assert_tuner_band_names_size);
1351 1316
1352#if ASI_STYLE_NAMES 1317static const char * const asihpi_src_names[] = {
1353static char *asihpi_src_names[] =
1354{
1355 "no source",
1356 "outstream",
1357 "line_in",
1358 "aes_in",
1359 "tuner",
1360 "RF",
1361 "clock",
1362 "bitstr",
1363 "mic",
1364 "cobranet",
1365 "analog_in",
1366 "adapter",
1367};
1368#else
1369static char *asihpi_src_names[] =
1370{
1371 "no source", 1318 "no source",
1372 "PCM playback", 1319 "PCM",
1373 "line in", 1320 "Line",
1374 "digital in", 1321 "Digital",
1375 "tuner", 1322 "Tuner",
1376 "RF", 1323 "RF",
1377 "clock", 1324 "Clock",
1378 "bitstream", 1325 "Bitstream",
1379 "mic", 1326 "Microphone",
1380 "cobranet in", 1327 "Cobranet",
1381 "analog in", 1328 "Analog",
1382 "adapter", 1329 "Adapter",
1383}; 1330};
1384#endif
1385 1331
1386compile_time_assert( 1332compile_time_assert(
1387 (ARRAY_SIZE(asihpi_src_names) == 1333 (ARRAY_SIZE(asihpi_src_names) ==
1388 (HPI_SOURCENODE_LAST_INDEX-HPI_SOURCENODE_NONE+1)), 1334 (HPI_SOURCENODE_LAST_INDEX-HPI_SOURCENODE_NONE+1)),
1389 assert_src_names_size); 1335 assert_src_names_size);
1390 1336
1391#if ASI_STYLE_NAMES 1337static const char * const asihpi_dst_names[] = {
1392static char *asihpi_dst_names[] =
1393{
1394 "no destination", 1338 "no destination",
1395 "instream", 1339 "PCM",
1396 "line_out", 1340 "Line",
1397 "aes_out", 1341 "Digital",
1398 "RF", 1342 "RF",
1399 "speaker" , 1343 "Speaker",
1400 "cobranet", 1344 "Cobranet Out",
1401 "analog_out", 1345 "Analog"
1402}; 1346};
1403#else
1404static char *asihpi_dst_names[] =
1405{
1406 "no destination",
1407 "PCM capture",
1408 "line out",
1409 "digital out",
1410 "RF",
1411 "speaker",
1412 "cobranet out",
1413 "analog out"
1414};
1415#endif
1416 1347
1417compile_time_assert( 1348compile_time_assert(
1418 (ARRAY_SIZE(asihpi_dst_names) == 1349 (ARRAY_SIZE(asihpi_dst_names) ==
@@ -1438,30 +1369,47 @@ static void asihpi_ctl_init(struct snd_kcontrol_new *snd_control,
1438 struct hpi_control *hpi_ctl, 1369 struct hpi_control *hpi_ctl,
1439 char *name) 1370 char *name)
1440{ 1371{
1372 char *dir;
1441 memset(snd_control, 0, sizeof(*snd_control)); 1373 memset(snd_control, 0, sizeof(*snd_control));
1442 snd_control->name = hpi_ctl->name; 1374 snd_control->name = hpi_ctl->name;
1443 snd_control->private_value = hpi_ctl->h_control; 1375 snd_control->private_value = hpi_ctl->h_control;
1444 snd_control->iface = SNDRV_CTL_ELEM_IFACE_MIXER; 1376 snd_control->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1445 snd_control->index = 0; 1377 snd_control->index = 0;
1446 1378
1379 if (hpi_ctl->src_node_type + HPI_SOURCENODE_NONE == HPI_SOURCENODE_CLOCK_SOURCE)
1380 dir = ""; /* clock is neither capture nor playback */
1381 else if (hpi_ctl->dst_node_type + HPI_DESTNODE_NONE == HPI_DESTNODE_ISTREAM)
1382 dir = "Capture "; /* On or towards a PCM capture destination*/
1383 else if ((hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) &&
1384 (!hpi_ctl->dst_node_type))
1385 dir = "Capture "; /* On a source node that is not PCM playback */
1386 else if (hpi_ctl->src_node_type &&
1387 (hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) &&
1388 (hpi_ctl->dst_node_type))
1389 dir = "Monitor Playback "; /* Between an input and an output */
1390 else
1391 dir = "Playback "; /* PCM Playback source, or output node */
1392
1447 if (hpi_ctl->src_node_type && hpi_ctl->dst_node_type) 1393 if (hpi_ctl->src_node_type && hpi_ctl->dst_node_type)
1448 sprintf(hpi_ctl->name, "%s%d to %s%d %s", 1394 sprintf(hpi_ctl->name, "%s %d %s %d %s%s",
1449 asihpi_src_names[hpi_ctl->src_node_type], 1395 asihpi_src_names[hpi_ctl->src_node_type],
1450 hpi_ctl->src_node_index, 1396 hpi_ctl->src_node_index,
1451 asihpi_dst_names[hpi_ctl->dst_node_type], 1397 asihpi_dst_names[hpi_ctl->dst_node_type],
1452 hpi_ctl->dst_node_index, 1398 hpi_ctl->dst_node_index,
1453 name); 1399 dir, name);
1454 else if (hpi_ctl->dst_node_type) { 1400 else if (hpi_ctl->dst_node_type) {
1455 sprintf(hpi_ctl->name, "%s%d %s", 1401 sprintf(hpi_ctl->name, "%s %d %s%s",
1456 asihpi_dst_names[hpi_ctl->dst_node_type], 1402 asihpi_dst_names[hpi_ctl->dst_node_type],
1457 hpi_ctl->dst_node_index, 1403 hpi_ctl->dst_node_index,
1458 name); 1404 dir, name);
1459 } else { 1405 } else {
1460 sprintf(hpi_ctl->name, "%s%d %s", 1406 sprintf(hpi_ctl->name, "%s %d %s%s",
1461 asihpi_src_names[hpi_ctl->src_node_type], 1407 asihpi_src_names[hpi_ctl->src_node_type],
1462 hpi_ctl->src_node_index, 1408 hpi_ctl->src_node_index,
1463 name); 1409 dir, name);
1464 } 1410 }
1411 /* printk(KERN_INFO "Adding %s %d to %d ", hpi_ctl->name,
1412 hpi_ctl->wSrcNodeType, hpi_ctl->wDstNodeType); */
1465} 1413}
1466 1414
1467/*------------------------------------------------------------ 1415/*------------------------------------------------------------
@@ -1478,7 +1426,7 @@ static int snd_asihpi_volume_info(struct snd_kcontrol *kcontrol,
1478 short max_gain_mB; 1426 short max_gain_mB;
1479 short step_gain_mB; 1427 short step_gain_mB;
1480 1428
1481 err = hpi_volume_query_range(ss, h_control, 1429 err = hpi_volume_query_range(h_control,
1482 &min_gain_mB, &max_gain_mB, &step_gain_mB); 1430 &min_gain_mB, &max_gain_mB, &step_gain_mB);
1483 if (err) { 1431 if (err) {
1484 max_gain_mB = 0; 1432 max_gain_mB = 0;
@@ -1500,7 +1448,7 @@ static int snd_asihpi_volume_get(struct snd_kcontrol *kcontrol,
1500 u32 h_control = kcontrol->private_value; 1448 u32 h_control = kcontrol->private_value;
1501 short an_gain_mB[HPI_MAX_CHANNELS]; 1449 short an_gain_mB[HPI_MAX_CHANNELS];
1502 1450
1503 hpi_handle_error(hpi_volume_get_gain(ss, h_control, an_gain_mB)); 1451 hpi_handle_error(hpi_volume_get_gain(h_control, an_gain_mB));
1504 ucontrol->value.integer.value[0] = an_gain_mB[0] / VOL_STEP_mB; 1452 ucontrol->value.integer.value[0] = an_gain_mB[0] / VOL_STEP_mB;
1505 ucontrol->value.integer.value[1] = an_gain_mB[1] / VOL_STEP_mB; 1453 ucontrol->value.integer.value[1] = an_gain_mB[1] / VOL_STEP_mB;
1506 1454
@@ -1522,7 +1470,7 @@ static int snd_asihpi_volume_put(struct snd_kcontrol *kcontrol,
1522 asihpi->mixer_volume[addr][1] != right; 1470 asihpi->mixer_volume[addr][1] != right;
1523 */ 1471 */
1524 change = 1; 1472 change = 1;
1525 hpi_handle_error(hpi_volume_set_gain(ss, h_control, an_gain_mB)); 1473 hpi_handle_error(hpi_volume_set_gain(h_control, an_gain_mB));
1526 return change; 1474 return change;
1527} 1475}
1528 1476
@@ -1534,7 +1482,7 @@ static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi,
1534 struct snd_card *card = asihpi->card; 1482 struct snd_card *card = asihpi->card;
1535 struct snd_kcontrol_new snd_control; 1483 struct snd_kcontrol_new snd_control;
1536 1484
1537 asihpi_ctl_init(&snd_control, hpi_ctl, "volume"); 1485 asihpi_ctl_init(&snd_control, hpi_ctl, "Volume");
1538 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | 1486 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
1539 SNDRV_CTL_ELEM_ACCESS_TLV_READ; 1487 SNDRV_CTL_ELEM_ACCESS_TLV_READ;
1540 snd_control.info = snd_asihpi_volume_info; 1488 snd_control.info = snd_asihpi_volume_info;
@@ -1558,7 +1506,7 @@ static int snd_asihpi_level_info(struct snd_kcontrol *kcontrol,
1558 short step_gain_mB; 1506 short step_gain_mB;
1559 1507
1560 err = 1508 err =
1561 hpi_level_query_range(ss, h_control, &min_gain_mB, 1509 hpi_level_query_range(h_control, &min_gain_mB,
1562 &max_gain_mB, &step_gain_mB); 1510 &max_gain_mB, &step_gain_mB);
1563 if (err) { 1511 if (err) {
1564 max_gain_mB = 2400; 1512 max_gain_mB = 2400;
@@ -1580,7 +1528,7 @@ static int snd_asihpi_level_get(struct snd_kcontrol *kcontrol,
1580 u32 h_control = kcontrol->private_value; 1528 u32 h_control = kcontrol->private_value;
1581 short an_gain_mB[HPI_MAX_CHANNELS]; 1529 short an_gain_mB[HPI_MAX_CHANNELS];
1582 1530
1583 hpi_handle_error(hpi_level_get_gain(ss, h_control, an_gain_mB)); 1531 hpi_handle_error(hpi_level_get_gain(h_control, an_gain_mB));
1584 ucontrol->value.integer.value[0] = 1532 ucontrol->value.integer.value[0] =
1585 an_gain_mB[0] / HPI_UNITS_PER_dB; 1533 an_gain_mB[0] / HPI_UNITS_PER_dB;
1586 ucontrol->value.integer.value[1] = 1534 ucontrol->value.integer.value[1] =
@@ -1604,7 +1552,7 @@ static int snd_asihpi_level_put(struct snd_kcontrol *kcontrol,
1604 asihpi->mixer_level[addr][1] != right; 1552 asihpi->mixer_level[addr][1] != right;
1605 */ 1553 */
1606 change = 1; 1554 change = 1;
1607 hpi_handle_error(hpi_level_set_gain(ss, h_control, an_gain_mB)); 1555 hpi_handle_error(hpi_level_set_gain(h_control, an_gain_mB));
1608 return change; 1556 return change;
1609} 1557}
1610 1558
@@ -1617,7 +1565,7 @@ static int __devinit snd_asihpi_level_add(struct snd_card_asihpi *asihpi,
1617 struct snd_kcontrol_new snd_control; 1565 struct snd_kcontrol_new snd_control;
1618 1566
1619 /* can't use 'volume' cos some nodes have volume as well */ 1567 /* can't use 'volume' cos some nodes have volume as well */
1620 asihpi_ctl_init(&snd_control, hpi_ctl, "level"); 1568 asihpi_ctl_init(&snd_control, hpi_ctl, "Level");
1621 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | 1569 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
1622 SNDRV_CTL_ELEM_ACCESS_TLV_READ; 1570 SNDRV_CTL_ELEM_ACCESS_TLV_READ;
1623 snd_control.info = snd_asihpi_level_info; 1571 snd_control.info = snd_asihpi_level_info;
@@ -1633,12 +1581,8 @@ static int __devinit snd_asihpi_level_add(struct snd_card_asihpi *asihpi,
1633 ------------------------------------------------------------*/ 1581 ------------------------------------------------------------*/
1634 1582
1635/* AESEBU format */ 1583/* AESEBU format */
1636static char *asihpi_aesebu_format_names[] = 1584static const char * const asihpi_aesebu_format_names[] = {
1637{ 1585 "N/A", "S/PDIF", "AES/EBU" };
1638 "N/A",
1639 "S/PDIF",
1640 "AES/EBU",
1641};
1642 1586
1643static int snd_asihpi_aesebu_format_info(struct snd_kcontrol *kcontrol, 1587static int snd_asihpi_aesebu_format_info(struct snd_kcontrol *kcontrol,
1644 struct snd_ctl_elem_info *uinfo) 1588 struct snd_ctl_elem_info *uinfo)
@@ -1659,12 +1603,12 @@ static int snd_asihpi_aesebu_format_info(struct snd_kcontrol *kcontrol,
1659 1603
1660static int snd_asihpi_aesebu_format_get(struct snd_kcontrol *kcontrol, 1604static int snd_asihpi_aesebu_format_get(struct snd_kcontrol *kcontrol,
1661 struct snd_ctl_elem_value *ucontrol, 1605 struct snd_ctl_elem_value *ucontrol,
1662 u16 (*func)(const struct hpi_hsubsys *, u32, u16 *)) 1606 u16 (*func)(u32, u16 *))
1663{ 1607{
1664 u32 h_control = kcontrol->private_value; 1608 u32 h_control = kcontrol->private_value;
1665 u16 source, err; 1609 u16 source, err;
1666 1610
1667 err = func(ss, h_control, &source); 1611 err = func(h_control, &source);
1668 1612
1669 /* default to N/A */ 1613 /* default to N/A */
1670 ucontrol->value.enumerated.item[0] = 0; 1614 ucontrol->value.enumerated.item[0] = 0;
@@ -1681,7 +1625,7 @@ static int snd_asihpi_aesebu_format_get(struct snd_kcontrol *kcontrol,
1681 1625
1682static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol, 1626static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol,
1683 struct snd_ctl_elem_value *ucontrol, 1627 struct snd_ctl_elem_value *ucontrol,
1684 u16 (*func)(const struct hpi_hsubsys *, u32, u16)) 1628 u16 (*func)(u32, u16))
1685{ 1629{
1686 u32 h_control = kcontrol->private_value; 1630 u32 h_control = kcontrol->private_value;
1687 1631
@@ -1693,7 +1637,7 @@ static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol,
1693 if (ucontrol->value.enumerated.item[0] == 2) 1637 if (ucontrol->value.enumerated.item[0] == 2)
1694 source = HPI_AESEBU_FORMAT_AESEBU; 1638 source = HPI_AESEBU_FORMAT_AESEBU;
1695 1639
1696 if (func(ss, h_control, source) != 0) 1640 if (func(h_control, source) != 0)
1697 return -EINVAL; 1641 return -EINVAL;
1698 1642
1699 return 1; 1643 return 1;
@@ -1702,13 +1646,13 @@ static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol,
1702static int snd_asihpi_aesebu_rx_format_get(struct snd_kcontrol *kcontrol, 1646static int snd_asihpi_aesebu_rx_format_get(struct snd_kcontrol *kcontrol,
1703 struct snd_ctl_elem_value *ucontrol) { 1647 struct snd_ctl_elem_value *ucontrol) {
1704 return snd_asihpi_aesebu_format_get(kcontrol, ucontrol, 1648 return snd_asihpi_aesebu_format_get(kcontrol, ucontrol,
1705 HPI_AESEBU__receiver_get_format); 1649 hpi_aesebu_receiver_get_format);
1706} 1650}
1707 1651
1708static int snd_asihpi_aesebu_rx_format_put(struct snd_kcontrol *kcontrol, 1652static int snd_asihpi_aesebu_rx_format_put(struct snd_kcontrol *kcontrol,
1709 struct snd_ctl_elem_value *ucontrol) { 1653 struct snd_ctl_elem_value *ucontrol) {
1710 return snd_asihpi_aesebu_format_put(kcontrol, ucontrol, 1654 return snd_asihpi_aesebu_format_put(kcontrol, ucontrol,
1711 HPI_AESEBU__receiver_set_format); 1655 hpi_aesebu_receiver_set_format);
1712} 1656}
1713 1657
1714static int snd_asihpi_aesebu_rxstatus_info(struct snd_kcontrol *kcontrol, 1658static int snd_asihpi_aesebu_rxstatus_info(struct snd_kcontrol *kcontrol,
@@ -1730,8 +1674,8 @@ static int snd_asihpi_aesebu_rxstatus_get(struct snd_kcontrol *kcontrol,
1730 u32 h_control = kcontrol->private_value; 1674 u32 h_control = kcontrol->private_value;
1731 u16 status; 1675 u16 status;
1732 1676
1733 hpi_handle_error(HPI_AESEBU__receiver_get_error_status( 1677 hpi_handle_error(hpi_aesebu_receiver_get_error_status(
1734 ss, h_control, &status)); 1678 h_control, &status));
1735 ucontrol->value.integer.value[0] = status; 1679 ucontrol->value.integer.value[0] = status;
1736 return 0; 1680 return 0;
1737} 1681}
@@ -1742,7 +1686,7 @@ static int __devinit snd_asihpi_aesebu_rx_add(struct snd_card_asihpi *asihpi,
1742 struct snd_card *card = asihpi->card; 1686 struct snd_card *card = asihpi->card;
1743 struct snd_kcontrol_new snd_control; 1687 struct snd_kcontrol_new snd_control;
1744 1688
1745 asihpi_ctl_init(&snd_control, hpi_ctl, "format"); 1689 asihpi_ctl_init(&snd_control, hpi_ctl, "Format");
1746 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; 1690 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
1747 snd_control.info = snd_asihpi_aesebu_format_info; 1691 snd_control.info = snd_asihpi_aesebu_format_info;
1748 snd_control.get = snd_asihpi_aesebu_rx_format_get; 1692 snd_control.get = snd_asihpi_aesebu_rx_format_get;
@@ -1752,7 +1696,7 @@ static int __devinit snd_asihpi_aesebu_rx_add(struct snd_card_asihpi *asihpi,
1752 if (ctl_add(card, &snd_control, asihpi) < 0) 1696 if (ctl_add(card, &snd_control, asihpi) < 0)
1753 return -EINVAL; 1697 return -EINVAL;
1754 1698
1755 asihpi_ctl_init(&snd_control, hpi_ctl, "status"); 1699 asihpi_ctl_init(&snd_control, hpi_ctl, "Status");
1756 snd_control.access = 1700 snd_control.access =
1757 SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ; 1701 SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ;
1758 snd_control.info = snd_asihpi_aesebu_rxstatus_info; 1702 snd_control.info = snd_asihpi_aesebu_rxstatus_info;
@@ -1764,13 +1708,13 @@ static int __devinit snd_asihpi_aesebu_rx_add(struct snd_card_asihpi *asihpi,
1764static int snd_asihpi_aesebu_tx_format_get(struct snd_kcontrol *kcontrol, 1708static int snd_asihpi_aesebu_tx_format_get(struct snd_kcontrol *kcontrol,
1765 struct snd_ctl_elem_value *ucontrol) { 1709 struct snd_ctl_elem_value *ucontrol) {
1766 return snd_asihpi_aesebu_format_get(kcontrol, ucontrol, 1710 return snd_asihpi_aesebu_format_get(kcontrol, ucontrol,
1767 HPI_AESEBU__transmitter_get_format); 1711 hpi_aesebu_transmitter_get_format);
1768} 1712}
1769 1713
1770static int snd_asihpi_aesebu_tx_format_put(struct snd_kcontrol *kcontrol, 1714static int snd_asihpi_aesebu_tx_format_put(struct snd_kcontrol *kcontrol,
1771 struct snd_ctl_elem_value *ucontrol) { 1715 struct snd_ctl_elem_value *ucontrol) {
1772 return snd_asihpi_aesebu_format_put(kcontrol, ucontrol, 1716 return snd_asihpi_aesebu_format_put(kcontrol, ucontrol,
1773 HPI_AESEBU__transmitter_set_format); 1717 hpi_aesebu_transmitter_set_format);
1774} 1718}
1775 1719
1776 1720
@@ -1780,7 +1724,7 @@ static int __devinit snd_asihpi_aesebu_tx_add(struct snd_card_asihpi *asihpi,
1780 struct snd_card *card = asihpi->card; 1724 struct snd_card *card = asihpi->card;
1781 struct snd_kcontrol_new snd_control; 1725 struct snd_kcontrol_new snd_control;
1782 1726
1783 asihpi_ctl_init(&snd_control, hpi_ctl, "format"); 1727 asihpi_ctl_init(&snd_control, hpi_ctl, "Format");
1784 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; 1728 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
1785 snd_control.info = snd_asihpi_aesebu_format_info; 1729 snd_control.info = snd_asihpi_aesebu_format_info;
1786 snd_control.get = snd_asihpi_aesebu_tx_format_get; 1730 snd_control.get = snd_asihpi_aesebu_tx_format_get;
@@ -1804,7 +1748,7 @@ static int snd_asihpi_tuner_gain_info(struct snd_kcontrol *kcontrol,
1804 u16 gain_range[3]; 1748 u16 gain_range[3];
1805 1749
1806 for (idx = 0; idx < 3; idx++) { 1750 for (idx = 0; idx < 3; idx++) {
1807 err = hpi_tuner_query_gain(ss, h_control, 1751 err = hpi_tuner_query_gain(h_control,
1808 idx, &gain_range[idx]); 1752 idx, &gain_range[idx]);
1809 if (err != 0) 1753 if (err != 0)
1810 return err; 1754 return err;
@@ -1827,7 +1771,7 @@ static int snd_asihpi_tuner_gain_get(struct snd_kcontrol *kcontrol,
1827 u32 h_control = kcontrol->private_value; 1771 u32 h_control = kcontrol->private_value;
1828 short gain; 1772 short gain;
1829 1773
1830 hpi_handle_error(hpi_tuner_get_gain(ss, h_control, &gain)); 1774 hpi_handle_error(hpi_tuner_get_gain(h_control, &gain));
1831 ucontrol->value.integer.value[0] = gain / HPI_UNITS_PER_dB; 1775 ucontrol->value.integer.value[0] = gain / HPI_UNITS_PER_dB;
1832 1776
1833 return 0; 1777 return 0;
@@ -1843,7 +1787,7 @@ static int snd_asihpi_tuner_gain_put(struct snd_kcontrol *kcontrol,
1843 short gain; 1787 short gain;
1844 1788
1845 gain = (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB; 1789 gain = (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB;
1846 hpi_handle_error(hpi_tuner_set_gain(ss, h_control, gain)); 1790 hpi_handle_error(hpi_tuner_set_gain(h_control, gain));
1847 1791
1848 return 1; 1792 return 1;
1849} 1793}
@@ -1857,7 +1801,7 @@ static int asihpi_tuner_band_query(struct snd_kcontrol *kcontrol,
1857 u32 i; 1801 u32 i;
1858 1802
1859 for (i = 0; i < len; i++) { 1803 for (i = 0; i < len; i++) {
1860 err = hpi_tuner_query_band(ss, 1804 err = hpi_tuner_query_band(
1861 h_control, i, &band_list[i]); 1805 h_control, i, &band_list[i]);
1862 if (err != 0) 1806 if (err != 0)
1863 break; 1807 break;
@@ -1913,7 +1857,7 @@ static int snd_asihpi_tuner_band_get(struct snd_kcontrol *kcontrol,
1913 num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands, 1857 num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands,
1914 HPI_TUNER_BAND_LAST); 1858 HPI_TUNER_BAND_LAST);
1915 1859
1916 hpi_handle_error(hpi_tuner_get_band(ss, h_control, &band)); 1860 hpi_handle_error(hpi_tuner_get_band(h_control, &band));
1917 1861
1918 ucontrol->value.enumerated.item[0] = -1; 1862 ucontrol->value.enumerated.item[0] = -1;
1919 for (idx = 0; idx < HPI_TUNER_BAND_LAST; idx++) 1863 for (idx = 0; idx < HPI_TUNER_BAND_LAST; idx++)
@@ -1940,7 +1884,7 @@ static int snd_asihpi_tuner_band_put(struct snd_kcontrol *kcontrol,
1940 HPI_TUNER_BAND_LAST); 1884 HPI_TUNER_BAND_LAST);
1941 1885
1942 band = tuner_bands[ucontrol->value.enumerated.item[0]]; 1886 band = tuner_bands[ucontrol->value.enumerated.item[0]];
1943 hpi_handle_error(hpi_tuner_set_band(ss, h_control, band)); 1887 hpi_handle_error(hpi_tuner_set_band(h_control, band));
1944 1888
1945 return 1; 1889 return 1;
1946} 1890}
@@ -1965,7 +1909,7 @@ static int snd_asihpi_tuner_freq_info(struct snd_kcontrol *kcontrol,
1965 1909
1966 for (band_iter = 0; band_iter < num_bands; band_iter++) { 1910 for (band_iter = 0; band_iter < num_bands; band_iter++) {
1967 for (idx = 0; idx < 3; idx++) { 1911 for (idx = 0; idx < 3; idx++) {
1968 err = hpi_tuner_query_frequency(ss, h_control, 1912 err = hpi_tuner_query_frequency(h_control,
1969 idx, tuner_bands[band_iter], 1913 idx, tuner_bands[band_iter],
1970 &temp_freq_range[idx]); 1914 &temp_freq_range[idx]);
1971 if (err != 0) 1915 if (err != 0)
@@ -1998,7 +1942,7 @@ static int snd_asihpi_tuner_freq_get(struct snd_kcontrol *kcontrol,
1998 u32 h_control = kcontrol->private_value; 1942 u32 h_control = kcontrol->private_value;
1999 u32 freq; 1943 u32 freq;
2000 1944
2001 hpi_handle_error(hpi_tuner_get_frequency(ss, h_control, &freq)); 1945 hpi_handle_error(hpi_tuner_get_frequency(h_control, &freq));
2002 ucontrol->value.integer.value[0] = freq; 1946 ucontrol->value.integer.value[0] = freq;
2003 1947
2004 return 0; 1948 return 0;
@@ -2011,7 +1955,7 @@ static int snd_asihpi_tuner_freq_put(struct snd_kcontrol *kcontrol,
2011 u32 freq; 1955 u32 freq;
2012 1956
2013 freq = ucontrol->value.integer.value[0]; 1957 freq = ucontrol->value.integer.value[0];
2014 hpi_handle_error(hpi_tuner_set_frequency(ss, h_control, freq)); 1958 hpi_handle_error(hpi_tuner_set_frequency(h_control, freq));
2015 1959
2016 return 1; 1960 return 1;
2017} 1961}
@@ -2026,8 +1970,8 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi,
2026 snd_control.private_value = hpi_ctl->h_control; 1970 snd_control.private_value = hpi_ctl->h_control;
2027 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; 1971 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
2028 1972
2029 if (!hpi_tuner_get_gain(ss, hpi_ctl->h_control, NULL)) { 1973 if (!hpi_tuner_get_gain(hpi_ctl->h_control, NULL)) {
2030 asihpi_ctl_init(&snd_control, hpi_ctl, "gain"); 1974 asihpi_ctl_init(&snd_control, hpi_ctl, "Gain");
2031 snd_control.info = snd_asihpi_tuner_gain_info; 1975 snd_control.info = snd_asihpi_tuner_gain_info;
2032 snd_control.get = snd_asihpi_tuner_gain_get; 1976 snd_control.get = snd_asihpi_tuner_gain_get;
2033 snd_control.put = snd_asihpi_tuner_gain_put; 1977 snd_control.put = snd_asihpi_tuner_gain_put;
@@ -2036,7 +1980,7 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi,
2036 return -EINVAL; 1980 return -EINVAL;
2037 } 1981 }
2038 1982
2039 asihpi_ctl_init(&snd_control, hpi_ctl, "band"); 1983 asihpi_ctl_init(&snd_control, hpi_ctl, "Band");
2040 snd_control.info = snd_asihpi_tuner_band_info; 1984 snd_control.info = snd_asihpi_tuner_band_info;
2041 snd_control.get = snd_asihpi_tuner_band_get; 1985 snd_control.get = snd_asihpi_tuner_band_get;
2042 snd_control.put = snd_asihpi_tuner_band_put; 1986 snd_control.put = snd_asihpi_tuner_band_put;
@@ -2044,7 +1988,7 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi,
2044 if (ctl_add(card, &snd_control, asihpi) < 0) 1988 if (ctl_add(card, &snd_control, asihpi) < 0)
2045 return -EINVAL; 1989 return -EINVAL;
2046 1990
2047 asihpi_ctl_init(&snd_control, hpi_ctl, "freq"); 1991 asihpi_ctl_init(&snd_control, hpi_ctl, "Freq");
2048 snd_control.info = snd_asihpi_tuner_freq_info; 1992 snd_control.info = snd_asihpi_tuner_freq_info;
2049 snd_control.get = snd_asihpi_tuner_freq_get; 1993 snd_control.get = snd_asihpi_tuner_freq_get;
2050 snd_control.put = snd_asihpi_tuner_freq_put; 1994 snd_control.put = snd_asihpi_tuner_freq_put;
@@ -2095,7 +2039,7 @@ static int snd_asihpi_meter_get(struct snd_kcontrol *kcontrol,
2095 short an_gain_mB[HPI_MAX_CHANNELS], i; 2039 short an_gain_mB[HPI_MAX_CHANNELS], i;
2096 u16 err; 2040 u16 err;
2097 2041
2098 err = hpi_meter_get_peak(ss, h_control, an_gain_mB); 2042 err = hpi_meter_get_peak(h_control, an_gain_mB);
2099 2043
2100 for (i = 0; i < HPI_MAX_CHANNELS; i++) { 2044 for (i = 0; i < HPI_MAX_CHANNELS; i++) {
2101 if (err) { 2045 if (err) {
@@ -2120,7 +2064,7 @@ static int __devinit snd_asihpi_meter_add(struct snd_card_asihpi *asihpi,
2120 struct snd_card *card = asihpi->card; 2064 struct snd_card *card = asihpi->card;
2121 struct snd_kcontrol_new snd_control; 2065 struct snd_kcontrol_new snd_control;
2122 2066
2123 asihpi_ctl_init(&snd_control, hpi_ctl, "meter"); 2067 asihpi_ctl_init(&snd_control, hpi_ctl, "Meter");
2124 snd_control.access = 2068 snd_control.access =
2125 SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ; 2069 SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ;
2126 snd_control.info = snd_asihpi_meter_info; 2070 snd_control.info = snd_asihpi_meter_info;
@@ -2140,7 +2084,7 @@ static int snd_card_asihpi_mux_count_sources(struct snd_kcontrol *snd_control)
2140 struct hpi_control hpi_ctl; 2084 struct hpi_control hpi_ctl;
2141 int s, err; 2085 int s, err;
2142 for (s = 0; s < 32; s++) { 2086 for (s = 0; s < 32; s++) {
2143 err = hpi_multiplexer_query_source(ss, h_control, s, 2087 err = hpi_multiplexer_query_source(h_control, s,
2144 &hpi_ctl. 2088 &hpi_ctl.
2145 src_node_type, 2089 src_node_type,
2146 &hpi_ctl. 2090 &hpi_ctl.
@@ -2168,7 +2112,7 @@ static int snd_asihpi_mux_info(struct snd_kcontrol *kcontrol,
2168 uinfo->value.enumerated.items - 1; 2112 uinfo->value.enumerated.items - 1;
2169 2113
2170 err = 2114 err =
2171 hpi_multiplexer_query_source(ss, h_control, 2115 hpi_multiplexer_query_source(h_control,
2172 uinfo->value.enumerated.item, 2116 uinfo->value.enumerated.item,
2173 &src_node_type, &src_node_index); 2117 &src_node_type, &src_node_index);
2174 2118
@@ -2186,11 +2130,11 @@ static int snd_asihpi_mux_get(struct snd_kcontrol *kcontrol,
2186 u16 src_node_type, src_node_index; 2130 u16 src_node_type, src_node_index;
2187 int s; 2131 int s;
2188 2132
2189 hpi_handle_error(hpi_multiplexer_get_source(ss, h_control, 2133 hpi_handle_error(hpi_multiplexer_get_source(h_control,
2190 &source_type, &source_index)); 2134 &source_type, &source_index));
2191 /* Should cache this search result! */ 2135 /* Should cache this search result! */
2192 for (s = 0; s < 256; s++) { 2136 for (s = 0; s < 256; s++) {
2193 if (hpi_multiplexer_query_source(ss, h_control, s, 2137 if (hpi_multiplexer_query_source(h_control, s,
2194 &src_node_type, &src_node_index)) 2138 &src_node_type, &src_node_index))
2195 break; 2139 break;
2196 2140
@@ -2201,7 +2145,7 @@ static int snd_asihpi_mux_get(struct snd_kcontrol *kcontrol,
2201 } 2145 }
2202 } 2146 }
2203 snd_printd(KERN_WARNING 2147 snd_printd(KERN_WARNING
2204 "control %x failed to match mux source %hu %hu\n", 2148 "Control %x failed to match mux source %hu %hu\n",
2205 h_control, source_type, source_index); 2149 h_control, source_type, source_index);
2206 ucontrol->value.enumerated.item[0] = 0; 2150 ucontrol->value.enumerated.item[0] = 0;
2207 return 0; 2151 return 0;
@@ -2217,12 +2161,12 @@ static int snd_asihpi_mux_put(struct snd_kcontrol *kcontrol,
2217 2161
2218 change = 1; 2162 change = 1;
2219 2163
2220 e = hpi_multiplexer_query_source(ss, h_control, 2164 e = hpi_multiplexer_query_source(h_control,
2221 ucontrol->value.enumerated.item[0], 2165 ucontrol->value.enumerated.item[0],
2222 &source_type, &source_index); 2166 &source_type, &source_index);
2223 if (!e) 2167 if (!e)
2224 hpi_handle_error( 2168 hpi_handle_error(
2225 hpi_multiplexer_set_source(ss, h_control, 2169 hpi_multiplexer_set_source(h_control,
2226 source_type, source_index)); 2170 source_type, source_index));
2227 return change; 2171 return change;
2228} 2172}
@@ -2234,11 +2178,7 @@ static int __devinit snd_asihpi_mux_add(struct snd_card_asihpi *asihpi,
2234 struct snd_card *card = asihpi->card; 2178 struct snd_card *card = asihpi->card;
2235 struct snd_kcontrol_new snd_control; 2179 struct snd_kcontrol_new snd_control;
2236 2180
2237#if ASI_STYLE_NAMES 2181 asihpi_ctl_init(&snd_control, hpi_ctl, "Route");
2238 asihpi_ctl_init(&snd_control, hpi_ctl, "multiplexer");
2239#else
2240 asihpi_ctl_init(&snd_control, hpi_ctl, "route");
2241#endif
2242 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; 2182 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
2243 snd_control.info = snd_asihpi_mux_info; 2183 snd_control.info = snd_asihpi_mux_info;
2244 snd_control.get = snd_asihpi_mux_get; 2184 snd_control.get = snd_asihpi_mux_get;
@@ -2254,33 +2194,38 @@ static int __devinit snd_asihpi_mux_add(struct snd_card_asihpi *asihpi,
2254static int snd_asihpi_cmode_info(struct snd_kcontrol *kcontrol, 2194static int snd_asihpi_cmode_info(struct snd_kcontrol *kcontrol,
2255 struct snd_ctl_elem_info *uinfo) 2195 struct snd_ctl_elem_info *uinfo)
2256{ 2196{
2257 static char *mode_names[HPI_CHANNEL_MODE_LAST] = { 2197 static const char * const mode_names[HPI_CHANNEL_MODE_LAST + 1] = {
2258 "normal", "swap", 2198 "invalid",
2259 "from_left", "from_right", 2199 "Normal", "Swap",
2260 "to_left", "to_right" 2200 "From Left", "From Right",
2201 "To Left", "To Right"
2261 }; 2202 };
2262 2203
2263 u32 h_control = kcontrol->private_value; 2204 u32 h_control = kcontrol->private_value;
2264 u16 mode; 2205 u16 mode;
2265 int i; 2206 int i;
2207 u16 mode_map[6];
2208 int valid_modes = 0;
2266 2209
2267 /* HPI channel mode values can be from 1 to 6 2210 /* HPI channel mode values can be from 1 to 6
2268 Some adapters only support a contiguous subset 2211 Some adapters only support a contiguous subset
2269 */ 2212 */
2270 for (i = 0; i < HPI_CHANNEL_MODE_LAST; i++) 2213 for (i = 0; i < HPI_CHANNEL_MODE_LAST; i++)
2271 if (hpi_channel_mode_query_mode( 2214 if (!hpi_channel_mode_query_mode(
2272 ss, h_control, i, &mode)) 2215 h_control, i, &mode)) {
2273 break; 2216 mode_map[valid_modes] = mode;
2217 valid_modes++;
2218 }
2274 2219
2275 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2220 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2276 uinfo->count = 1; 2221 uinfo->count = 1;
2277 uinfo->value.enumerated.items = i; 2222 uinfo->value.enumerated.items = valid_modes;
2278 2223
2279 if (uinfo->value.enumerated.item >= i) 2224 if (uinfo->value.enumerated.item >= valid_modes)
2280 uinfo->value.enumerated.item = i - 1; 2225 uinfo->value.enumerated.item = valid_modes - 1;
2281 2226
2282 strcpy(uinfo->value.enumerated.name, 2227 strcpy(uinfo->value.enumerated.name,
2283 mode_names[uinfo->value.enumerated.item]); 2228 mode_names[mode_map[uinfo->value.enumerated.item]]);
2284 2229
2285 return 0; 2230 return 0;
2286} 2231}
@@ -2291,7 +2236,7 @@ static int snd_asihpi_cmode_get(struct snd_kcontrol *kcontrol,
2291 u32 h_control = kcontrol->private_value; 2236 u32 h_control = kcontrol->private_value;
2292 u16 mode; 2237 u16 mode;
2293 2238
2294 if (hpi_channel_mode_get(ss, h_control, &mode)) 2239 if (hpi_channel_mode_get(h_control, &mode))
2295 mode = 1; 2240 mode = 1;
2296 2241
2297 ucontrol->value.enumerated.item[0] = mode - 1; 2242 ucontrol->value.enumerated.item[0] = mode - 1;
@@ -2307,7 +2252,7 @@ static int snd_asihpi_cmode_put(struct snd_kcontrol *kcontrol,
2307 2252
2308 change = 1; 2253 change = 1;
2309 2254
2310 hpi_handle_error(hpi_channel_mode_set(ss, h_control, 2255 hpi_handle_error(hpi_channel_mode_set(h_control,
2311 ucontrol->value.enumerated.item[0] + 1)); 2256 ucontrol->value.enumerated.item[0] + 1));
2312 return change; 2257 return change;
2313} 2258}
@@ -2319,7 +2264,7 @@ static int __devinit snd_asihpi_cmode_add(struct snd_card_asihpi *asihpi,
2319 struct snd_card *card = asihpi->card; 2264 struct snd_card *card = asihpi->card;
2320 struct snd_kcontrol_new snd_control; 2265 struct snd_kcontrol_new snd_control;
2321 2266
2322 asihpi_ctl_init(&snd_control, hpi_ctl, "channel mode"); 2267 asihpi_ctl_init(&snd_control, hpi_ctl, "Mode");
2323 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; 2268 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
2324 snd_control.info = snd_asihpi_cmode_info; 2269 snd_control.info = snd_asihpi_cmode_info;
2325 snd_control.get = snd_asihpi_cmode_get; 2270 snd_control.get = snd_asihpi_cmode_get;
@@ -2331,15 +2276,12 @@ static int __devinit snd_asihpi_cmode_add(struct snd_card_asihpi *asihpi,
2331/*------------------------------------------------------------ 2276/*------------------------------------------------------------
2332 Sampleclock source controls 2277 Sampleclock source controls
2333 ------------------------------------------------------------*/ 2278 ------------------------------------------------------------*/
2334 2279static char *sampleclock_sources[MAX_CLOCKSOURCES] = {
2335static char *sampleclock_sources[MAX_CLOCKSOURCES] = 2280 "N/A", "Local PLL", "Digital Sync", "Word External", "Word Header",
2336 { "N/A", "local PLL", "AES/EBU sync", "word external", "word header", 2281 "SMPTE", "Digital1", "Auto", "Network", "Invalid",
2337 "SMPTE", "AES/EBU in1", "auto", "network", "invalid", 2282 "Prev Module",
2338 "prev module", 2283 "Digital2", "Digital3", "Digital4", "Digital5",
2339 "AES/EBU in2", "AES/EBU in3", "AES/EBU in4", "AES/EBU in5", 2284 "Digital6", "Digital7", "Digital8"};
2340 "AES/EBU in6", "AES/EBU in7", "AES/EBU in8"};
2341
2342
2343 2285
2344static int snd_asihpi_clksrc_info(struct snd_kcontrol *kcontrol, 2286static int snd_asihpi_clksrc_info(struct snd_kcontrol *kcontrol,
2345 struct snd_ctl_elem_info *uinfo) 2287 struct snd_ctl_elem_info *uinfo)
@@ -2371,11 +2313,11 @@ static int snd_asihpi_clksrc_get(struct snd_kcontrol *kcontrol,
2371 int i; 2313 int i;
2372 2314
2373 ucontrol->value.enumerated.item[0] = 0; 2315 ucontrol->value.enumerated.item[0] = 0;
2374 if (hpi_sample_clock_get_source(ss, h_control, &source)) 2316 if (hpi_sample_clock_get_source(h_control, &source))
2375 source = 0; 2317 source = 0;
2376 2318
2377 if (source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) 2319 if (source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT)
2378 if (hpi_sample_clock_get_source_index(ss, h_control, &srcindex)) 2320 if (hpi_sample_clock_get_source_index(h_control, &srcindex))
2379 srcindex = 0; 2321 srcindex = 0;
2380 2322
2381 for (i = 0; i < clkcache->count; i++) 2323 for (i = 0; i < clkcache->count; i++)
@@ -2402,11 +2344,11 @@ static int snd_asihpi_clksrc_put(struct snd_kcontrol *kcontrol,
2402 if (item >= clkcache->count) 2344 if (item >= clkcache->count)
2403 item = clkcache->count-1; 2345 item = clkcache->count-1;
2404 2346
2405 hpi_handle_error(hpi_sample_clock_set_source(ss, 2347 hpi_handle_error(hpi_sample_clock_set_source(
2406 h_control, clkcache->s[item].source)); 2348 h_control, clkcache->s[item].source));
2407 2349
2408 if (clkcache->s[item].source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) 2350 if (clkcache->s[item].source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT)
2409 hpi_handle_error(hpi_sample_clock_set_source_index(ss, 2351 hpi_handle_error(hpi_sample_clock_set_source_index(
2410 h_control, clkcache->s[item].index)); 2352 h_control, clkcache->s[item].index));
2411 return change; 2353 return change;
2412} 2354}
@@ -2434,7 +2376,7 @@ static int snd_asihpi_clklocal_get(struct snd_kcontrol *kcontrol,
2434 u32 rate; 2376 u32 rate;
2435 u16 e; 2377 u16 e;
2436 2378
2437 e = hpi_sample_clock_get_local_rate(ss, h_control, &rate); 2379 e = hpi_sample_clock_get_local_rate(h_control, &rate);
2438 if (!e) 2380 if (!e)
2439 ucontrol->value.integer.value[0] = rate; 2381 ucontrol->value.integer.value[0] = rate;
2440 else 2382 else
@@ -2452,7 +2394,7 @@ static int snd_asihpi_clklocal_put(struct snd_kcontrol *kcontrol,
2452 asihpi->mixer_clkrate[addr][1] != right; 2394 asihpi->mixer_clkrate[addr][1] != right;
2453 */ 2395 */
2454 change = 1; 2396 change = 1;
2455 hpi_handle_error(hpi_sample_clock_set_local_rate(ss, h_control, 2397 hpi_handle_error(hpi_sample_clock_set_local_rate(h_control,
2456 ucontrol->value.integer.value[0])); 2398 ucontrol->value.integer.value[0]));
2457 return change; 2399 return change;
2458} 2400}
@@ -2476,7 +2418,7 @@ static int snd_asihpi_clkrate_get(struct snd_kcontrol *kcontrol,
2476 u32 rate; 2418 u32 rate;
2477 u16 e; 2419 u16 e;
2478 2420
2479 e = hpi_sample_clock_get_sample_rate(ss, h_control, &rate); 2421 e = hpi_sample_clock_get_sample_rate(h_control, &rate);
2480 if (!e) 2422 if (!e)
2481 ucontrol->value.integer.value[0] = rate; 2423 ucontrol->value.integer.value[0] = rate;
2482 else 2424 else
@@ -2501,7 +2443,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi,
2501 clkcache->has_local = 0; 2443 clkcache->has_local = 0;
2502 2444
2503 for (i = 0; i <= HPI_SAMPLECLOCK_SOURCE_LAST; i++) { 2445 for (i = 0; i <= HPI_SAMPLECLOCK_SOURCE_LAST; i++) {
2504 if (hpi_sample_clock_query_source(ss, hSC, 2446 if (hpi_sample_clock_query_source(hSC,
2505 i, &source)) 2447 i, &source))
2506 break; 2448 break;
2507 clkcache->s[i].source = source; 2449 clkcache->s[i].source = source;
@@ -2515,7 +2457,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi,
2515 if (has_aes_in) 2457 if (has_aes_in)
2516 /* already will have picked up index 0 above */ 2458 /* already will have picked up index 0 above */
2517 for (j = 1; j < 8; j++) { 2459 for (j = 1; j < 8; j++) {
2518 if (hpi_sample_clock_query_source_index(ss, hSC, 2460 if (hpi_sample_clock_query_source_index(hSC,
2519 j, HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT, 2461 j, HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT,
2520 &source)) 2462 &source))
2521 break; 2463 break;
@@ -2528,7 +2470,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi,
2528 } 2470 }
2529 clkcache->count = i; 2471 clkcache->count = i;
2530 2472
2531 asihpi_ctl_init(&snd_control, hpi_ctl, "source"); 2473 asihpi_ctl_init(&snd_control, hpi_ctl, "Source");
2532 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE ; 2474 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE ;
2533 snd_control.info = snd_asihpi_clksrc_info; 2475 snd_control.info = snd_asihpi_clksrc_info;
2534 snd_control.get = snd_asihpi_clksrc_get; 2476 snd_control.get = snd_asihpi_clksrc_get;
@@ -2538,7 +2480,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi,
2538 2480
2539 2481
2540 if (clkcache->has_local) { 2482 if (clkcache->has_local) {
2541 asihpi_ctl_init(&snd_control, hpi_ctl, "local_rate"); 2483 asihpi_ctl_init(&snd_control, hpi_ctl, "Localrate");
2542 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE ; 2484 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE ;
2543 snd_control.info = snd_asihpi_clklocal_info; 2485 snd_control.info = snd_asihpi_clklocal_info;
2544 snd_control.get = snd_asihpi_clklocal_get; 2486 snd_control.get = snd_asihpi_clklocal_get;
@@ -2549,7 +2491,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi,
2549 return -EINVAL; 2491 return -EINVAL;
2550 } 2492 }
2551 2493
2552 asihpi_ctl_init(&snd_control, hpi_ctl, "rate"); 2494 asihpi_ctl_init(&snd_control, hpi_ctl, "Rate");
2553 snd_control.access = 2495 snd_control.access =
2554 SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ; 2496 SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ;
2555 snd_control.info = snd_asihpi_clkrate_info; 2497 snd_control.info = snd_asihpi_clkrate_info;
@@ -2571,10 +2513,10 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi)
2571 2513
2572 if (snd_BUG_ON(!asihpi)) 2514 if (snd_BUG_ON(!asihpi))
2573 return -EINVAL; 2515 return -EINVAL;
2574 strcpy(card->mixername, "asihpi mixer"); 2516 strcpy(card->mixername, "Asihpi Mixer");
2575 2517
2576 err = 2518 err =
2577 hpi_mixer_open(ss, asihpi->adapter_index, 2519 hpi_mixer_open(asihpi->adapter_index,
2578 &asihpi->h_mixer); 2520 &asihpi->h_mixer);
2579 hpi_handle_error(err); 2521 hpi_handle_error(err);
2580 if (err) 2522 if (err)
@@ -2585,7 +2527,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi)
2585 2527
2586 for (idx = 0; idx < 2000; idx++) { 2528 for (idx = 0; idx < 2000; idx++) {
2587 err = hpi_mixer_get_control_by_index( 2529 err = hpi_mixer_get_control_by_index(
2588 ss, asihpi->h_mixer, 2530 asihpi->h_mixer,
2589 idx, 2531 idx,
2590 &hpi_ctl.src_node_type, 2532 &hpi_ctl.src_node_type,
2591 &hpi_ctl.src_node_index, 2533 &hpi_ctl.src_node_index,
@@ -2597,7 +2539,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi)
2597 if (err == HPI_ERROR_CONTROL_DISABLED) { 2539 if (err == HPI_ERROR_CONTROL_DISABLED) {
2598 if (mixer_dump) 2540 if (mixer_dump)
2599 snd_printk(KERN_INFO 2541 snd_printk(KERN_INFO
2600 "disabled HPI control(%d)\n", 2542 "Disabled HPI Control(%d)\n",
2601 idx); 2543 idx);
2602 continue; 2544 continue;
2603 } else 2545 } else
@@ -2662,7 +2604,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi)
2662 default: 2604 default:
2663 if (mixer_dump) 2605 if (mixer_dump)
2664 snd_printk(KERN_INFO 2606 snd_printk(KERN_INFO
2665 "untranslated HPI control" 2607 "Untranslated HPI Control"
2666 "(%d) %d %d %d %d %d\n", 2608 "(%d) %d %d %d %d %d\n",
2667 idx, 2609 idx,
2668 hpi_ctl.control_type, 2610 hpi_ctl.control_type,
@@ -2712,14 +2654,14 @@ snd_asihpi_proc_read(struct snd_info_entry *entry,
2712 version & 0x7, 2654 version & 0x7,
2713 ((version >> 13) * 100) + ((version >> 7) & 0x3f)); 2655 ((version >> 13) * 100) + ((version >> 7) & 0x3f));
2714 2656
2715 err = hpi_mixer_get_control(ss, asihpi->h_mixer, 2657 err = hpi_mixer_get_control(asihpi->h_mixer,
2716 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, 2658 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0,
2717 HPI_CONTROL_SAMPLECLOCK, &h_control); 2659 HPI_CONTROL_SAMPLECLOCK, &h_control);
2718 2660
2719 if (!err) { 2661 if (!err) {
2720 err = hpi_sample_clock_get_sample_rate(ss, 2662 err = hpi_sample_clock_get_sample_rate(
2721 h_control, &rate); 2663 h_control, &rate);
2722 err += hpi_sample_clock_get_source(ss, h_control, &source); 2664 err += hpi_sample_clock_get_source(h_control, &source);
2723 2665
2724 if (!err) 2666 if (!err)
2725 snd_iprintf(buffer, "sample_clock=%d_hz, source %s\n", 2667 snd_iprintf(buffer, "sample_clock=%d_hz, source %s\n",
@@ -2841,15 +2783,17 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2841 if (err < 0) 2783 if (err < 0)
2842 return err; 2784 return err;
2843 snd_printk(KERN_WARNING 2785 snd_printk(KERN_WARNING
2844 "**** WARNING **** adapter index %d->ALSA index %d\n", 2786 "**** WARNING **** Adapter index %d->ALSA index %d\n",
2845 hpi_card->index, card->number); 2787 hpi_card->index, card->number);
2846 } 2788 }
2847 2789
2790 snd_card_set_dev(card, &pci_dev->dev);
2791
2848 asihpi = (struct snd_card_asihpi *) card->private_data; 2792 asihpi = (struct snd_card_asihpi *) card->private_data;
2849 asihpi->card = card; 2793 asihpi->card = card;
2850 asihpi->pci = hpi_card->pci; 2794 asihpi->pci = pci_dev;
2851 asihpi->adapter_index = hpi_card->index; 2795 asihpi->adapter_index = hpi_card->index;
2852 hpi_handle_error(hpi_adapter_get_info(ss, 2796 hpi_handle_error(hpi_adapter_get_info(
2853 asihpi->adapter_index, 2797 asihpi->adapter_index,
2854 &asihpi->num_outstreams, 2798 &asihpi->num_outstreams,
2855 &asihpi->num_instreams, 2799 &asihpi->num_instreams,
@@ -2859,7 +2803,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2859 version = asihpi->version; 2803 version = asihpi->version;
2860 snd_printk(KERN_INFO "adapter ID=%4X index=%d num_outstreams=%d " 2804 snd_printk(KERN_INFO "adapter ID=%4X index=%d num_outstreams=%d "
2861 "num_instreams=%d S/N=%d\n" 2805 "num_instreams=%d S/N=%d\n"
2862 "hw version %c%d DSP code version %03d\n", 2806 "Hw Version %c%d DSP code version %03d\n",
2863 asihpi->type, asihpi->adapter_index, 2807 asihpi->type, asihpi->adapter_index,
2864 asihpi->num_outstreams, 2808 asihpi->num_outstreams,
2865 asihpi->num_instreams, asihpi->serial_number, 2809 asihpi->num_instreams, asihpi->serial_number,
@@ -2871,33 +2815,36 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2871 if (pcm_substreams < asihpi->num_instreams) 2815 if (pcm_substreams < asihpi->num_instreams)
2872 pcm_substreams = asihpi->num_instreams; 2816 pcm_substreams = asihpi->num_instreams;
2873 2817
2874 err = hpi_adapter_get_property(ss, asihpi->adapter_index, 2818 err = hpi_adapter_get_property(asihpi->adapter_index,
2875 HPI_ADAPTER_PROPERTY_CAPS1, 2819 HPI_ADAPTER_PROPERTY_CAPS1,
2876 NULL, &asihpi->support_grouping); 2820 NULL, &asihpi->support_grouping);
2877 if (err) 2821 if (err)
2878 asihpi->support_grouping = 0; 2822 asihpi->support_grouping = 0;
2879 2823
2880 err = hpi_adapter_get_property(ss, asihpi->adapter_index, 2824 err = hpi_adapter_get_property(asihpi->adapter_index,
2881 HPI_ADAPTER_PROPERTY_CAPS2, 2825 HPI_ADAPTER_PROPERTY_CAPS2,
2882 &asihpi->support_mrx, NULL); 2826 &asihpi->support_mrx, NULL);
2883 if (err) 2827 if (err)
2884 asihpi->support_mrx = 0; 2828 asihpi->support_mrx = 0;
2885 2829
2886 err = hpi_adapter_get_property(ss, asihpi->adapter_index, 2830 err = hpi_adapter_get_property(asihpi->adapter_index,
2887 HPI_ADAPTER_PROPERTY_INTERVAL, 2831 HPI_ADAPTER_PROPERTY_INTERVAL,
2888 NULL, &asihpi->update_interval_frames); 2832 NULL, &asihpi->update_interval_frames);
2889 if (err) 2833 if (err)
2890 asihpi->update_interval_frames = 512; 2834 asihpi->update_interval_frames = 512;
2891 2835
2892 hpi_handle_error(hpi_instream_open(ss, asihpi->adapter_index, 2836 if (!asihpi->can_dma)
2837 asihpi->update_interval_frames *= 2;
2838
2839 hpi_handle_error(hpi_instream_open(asihpi->adapter_index,
2893 0, &h_stream)); 2840 0, &h_stream));
2894 2841
2895 err = hpi_instream_host_buffer_free(ss, h_stream); 2842 err = hpi_instream_host_buffer_free(h_stream);
2896 asihpi->support_mmap = (!err); 2843 asihpi->can_dma = (!err);
2897 2844
2898 hpi_handle_error(hpi_instream_close(ss, h_stream)); 2845 hpi_handle_error(hpi_instream_close(h_stream));
2899 2846
2900 err = hpi_adapter_get_property(ss, asihpi->adapter_index, 2847 err = hpi_adapter_get_property(asihpi->adapter_index,
2901 HPI_ADAPTER_PROPERTY_CURCHANNELS, 2848 HPI_ADAPTER_PROPERTY_CURCHANNELS,
2902 &asihpi->in_max_chans, &asihpi->out_max_chans); 2849 &asihpi->in_max_chans, &asihpi->out_max_chans);
2903 if (err) { 2850 if (err) {
@@ -2905,13 +2852,12 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2905 asihpi->out_max_chans = 2; 2852 asihpi->out_max_chans = 2;
2906 } 2853 }
2907 2854
2908 snd_printk(KERN_INFO "supports mmap:%d grouping:%d mrx:%d\n", 2855 snd_printk(KERN_INFO "has dma:%d, grouping:%d, mrx:%d\n",
2909 asihpi->support_mmap, 2856 asihpi->can_dma,
2910 asihpi->support_grouping, 2857 asihpi->support_grouping,
2911 asihpi->support_mrx 2858 asihpi->support_mrx
2912 ); 2859 );
2913 2860
2914
2915 err = snd_card_asihpi_pcm_new(asihpi, 0, pcm_substreams); 2861 err = snd_card_asihpi_pcm_new(asihpi, 0, pcm_substreams);
2916 if (err < 0) { 2862 if (err < 0) {
2917 snd_printk(KERN_ERR "pcm_new failed\n"); 2863 snd_printk(KERN_ERR "pcm_new failed\n");
@@ -2923,13 +2869,13 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2923 goto __nodev; 2869 goto __nodev;
2924 } 2870 }
2925 2871
2926 err = hpi_mixer_get_control(ss, asihpi->h_mixer, 2872 err = hpi_mixer_get_control(asihpi->h_mixer,
2927 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, 2873 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0,
2928 HPI_CONTROL_SAMPLECLOCK, &h_control); 2874 HPI_CONTROL_SAMPLECLOCK, &h_control);
2929 2875
2930 if (!err) 2876 if (!err)
2931 err = hpi_sample_clock_set_local_rate( 2877 err = hpi_sample_clock_set_local_rate(
2932 ss, h_control, adapter_fs); 2878 h_control, adapter_fs);
2933 2879
2934 snd_asihpi_proc_init(asihpi); 2880 snd_asihpi_proc_init(asihpi);
2935 2881
@@ -2937,15 +2883,13 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2937 by enable_hwdep module param*/ 2883 by enable_hwdep module param*/
2938 snd_asihpi_hpi_new(asihpi, 0, NULL); 2884 snd_asihpi_hpi_new(asihpi, 0, NULL);
2939 2885
2940 if (asihpi->support_mmap) 2886 strcpy(card->driver, "ASIHPI");
2941 strcpy(card->driver, "ASIHPI-MMAP");
2942 else
2943 strcpy(card->driver, "ASIHPI");
2944 2887
2945 sprintf(card->shortname, "AudioScience ASI%4X", asihpi->type); 2888 sprintf(card->shortname, "AudioScience ASI%4X", asihpi->type);
2946 sprintf(card->longname, "%s %i", 2889 sprintf(card->longname, "%s %i",
2947 card->shortname, asihpi->adapter_index); 2890 card->shortname, asihpi->adapter_index);
2948 err = snd_card_register(card); 2891 err = snd_card_register(card);
2892
2949 if (!err) { 2893 if (!err) {
2950 hpi_card->snd_card_asihpi = card; 2894 hpi_card->snd_card_asihpi = card;
2951 dev++; 2895 dev++;
diff --git a/sound/pci/asihpi/hpi.h b/sound/pci/asihpi/hpi.h
index 23399d02f666..255429c32c1c 100644
--- a/sound/pci/asihpi/hpi.h
+++ b/sound/pci/asihpi/hpi.h
@@ -24,17 +24,10 @@
24 24
25 The HPI is a low-level hardware abstraction layer to all 25 The HPI is a low-level hardware abstraction layer to all
26 AudioScience digital audio adapters 26 AudioScience digital audio adapters
27*/
28/*
29 You must define one operating system that the HPI is to be compiled under
30 HPI_OS_WIN32_USER 32bit Windows
31 HPI_OS_DSP_C6000 DSP TI C6000 (automatically set)
32 HPI_OS_WDM Windows WDM kernel driver
33 HPI_OS_LINUX Linux userspace
34 HPI_OS_LINUX_KERNEL Linux kernel (automatically set)
35 27
36(C) Copyright AudioScience Inc. 1998-2010 28(C) Copyright AudioScience Inc. 1998-2010
37******************************************************************************/ 29*/
30
38#ifndef _HPI_H_ 31#ifndef _HPI_H_
39#define _HPI_H_ 32#define _HPI_H_
40/* HPI Version 33/* HPI Version
@@ -50,20 +43,20 @@ i.e 3.05.02 is a development version
50#define HPI_VER_RELEASE(v) ((int)(v & 0xFF)) 43#define HPI_VER_RELEASE(v) ((int)(v & 0xFF))
51 44
52/* Use single digits for versions less that 10 to avoid octal. */ 45/* Use single digits for versions less that 10 to avoid octal. */
53#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 4, 1) 46#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 6, 0)
54#define HPI_VER_STRING "4.04.01" 47#define HPI_VER_STRING "4.06.00"
55 48
56/* Library version as documented in hpi-api-versions.txt */ 49/* Library version as documented in hpi-api-versions.txt */
57#define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0) 50#define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0)
58 51
59#include <linux/types.h> 52#include <linux/types.h>
60#define HPI_EXCLUDE_DEPRECATED 53#define HPI_BUILD_EXCLUDE_DEPRECATED
54#define HPI_BUILD_KERNEL_MODE
61 55
62/******************************************************************************/ 56/******************************************************************************/
63/******************************************************************************/
64/******** HPI API DEFINITIONS *****/ 57/******** HPI API DEFINITIONS *****/
65/******************************************************************************/ 58/******************************************************************************/
66/******************************************************************************/ 59
67/*******************************************/ 60/*******************************************/
68/** Audio format types 61/** Audio format types
69\ingroup stream 62\ingroup stream
@@ -174,7 +167,6 @@ The range is +1.0 to -1.0, which corresponds to digital fullscale.
174 HPI_FORMAT_UNDEFINED = 0xffff 167 HPI_FORMAT_UNDEFINED = 0xffff
175}; 168};
176 169
177/******************************************* in/out Stream states */
178/*******************************************/ 170/*******************************************/
179/** Stream States 171/** Stream States
180\ingroup stream 172\ingroup stream
@@ -194,7 +186,7 @@ enum HPI_STREAM_STATES {
194 cards to be ready. */ 186 cards to be ready. */
195 HPI_STATE_WAIT = 6 187 HPI_STATE_WAIT = 6
196}; 188};
197/******************************************* mixer source node types */ 189/*******************************************/
198/** Source node types 190/** Source node types
199\ingroup mixer 191\ingroup mixer
200*/ 192*/
@@ -224,7 +216,7 @@ enum HPI_SOURCENODES {
224 /* AX6 max sourcenode types = 15 */ 216 /* AX6 max sourcenode types = 15 */
225}; 217};
226 218
227/******************************************* mixer dest node types */ 219/*******************************************/
228/** Destination node types 220/** Destination node types
229\ingroup mixer 221\ingroup mixer
230*/ 222*/
@@ -262,11 +254,11 @@ enum HPI_CONTROLS {
262 HPI_CONTROL_MUTE = 4, /*mute control - not used at present. */ 254 HPI_CONTROL_MUTE = 4, /*mute control - not used at present. */
263 HPI_CONTROL_MULTIPLEXER = 5, /**< multiplexer control. */ 255 HPI_CONTROL_MULTIPLEXER = 5, /**< multiplexer control. */
264 256
265 HPI_CONTROL_AESEBU_TRANSMITTER = 6, /**< AES/EBU transmitter control. */ 257 HPI_CONTROL_AESEBU_TRANSMITTER = 6, /**< AES/EBU transmitter control */
266 HPI_CONTROL_AESEBUTX = HPI_CONTROL_AESEBU_TRANSMITTER, 258 HPI_CONTROL_AESEBUTX = 6, /* HPI_CONTROL_AESEBU_TRANSMITTER */
267 259
268 HPI_CONTROL_AESEBU_RECEIVER = 7, /**< AES/EBU receiver control. */ 260 HPI_CONTROL_AESEBU_RECEIVER = 7, /**< AES/EBU receiver control. */
269 HPI_CONTROL_AESEBURX = HPI_CONTROL_AESEBU_RECEIVER, 261 HPI_CONTROL_AESEBURX = 7, /* HPI_CONTROL_AESEBU_RECEIVER */
270 262
271 HPI_CONTROL_LEVEL = 8, /**< level/trim control - works in d_bu. */ 263 HPI_CONTROL_LEVEL = 8, /**< level/trim control - works in d_bu. */
272 HPI_CONTROL_TUNER = 9, /**< tuner control. */ 264 HPI_CONTROL_TUNER = 9, /**< tuner control. */
@@ -281,7 +273,7 @@ enum HPI_CONTROLS {
281 HPI_CONTROL_SAMPLECLOCK = 17, /**< sample clock control. */ 273 HPI_CONTROL_SAMPLECLOCK = 17, /**< sample clock control. */
282 HPI_CONTROL_MICROPHONE = 18, /**< microphone control. */ 274 HPI_CONTROL_MICROPHONE = 18, /**< microphone control. */
283 HPI_CONTROL_PARAMETRIC_EQ = 19, /**< parametric EQ control. */ 275 HPI_CONTROL_PARAMETRIC_EQ = 19, /**< parametric EQ control. */
284 HPI_CONTROL_EQUALIZER = HPI_CONTROL_PARAMETRIC_EQ, 276 HPI_CONTROL_EQUALIZER = 19, /*HPI_CONTROL_PARAMETRIC_EQ */
285 277
286 HPI_CONTROL_COMPANDER = 20, /**< compander control. */ 278 HPI_CONTROL_COMPANDER = 20, /**< compander control. */
287 HPI_CONTROL_COBRANET = 21, /**< cobranet control. */ 279 HPI_CONTROL_COBRANET = 21, /**< cobranet control. */
@@ -296,10 +288,7 @@ enum HPI_CONTROLS {
296/* WARNING types 256 or greater impact bit packing in all AX6 DSP code */ 288/* WARNING types 256 or greater impact bit packing in all AX6 DSP code */
297}; 289};
298 290
299/* Shorthand names that match attribute names */ 291/*******************************************/
300
301/******************************************* ADAPTER ATTRIBUTES ****/
302
303/** Adapter properties 292/** Adapter properties
304These are used in HPI_AdapterSetProperty() and HPI_AdapterGetProperty() 293These are used in HPI_AdapterSetProperty() and HPI_AdapterGetProperty()
305\ingroup adapter 294\ingroup adapter
@@ -330,12 +319,21 @@ by the driver and is not passed on to the DSP at all.
330Indicates the state of the adapter's SSX2 setting. This setting is stored in 319Indicates the state of the adapter's SSX2 setting. This setting is stored in
331non-volatile memory on the adapter. A typical call sequence would be to use 320non-volatile memory on the adapter. A typical call sequence would be to use
332HPI_ADAPTER_PROPERTY_SSX2_SETTING to set SSX2 on the adapter and then to reload 321HPI_ADAPTER_PROPERTY_SSX2_SETTING to set SSX2 on the adapter and then to reload
333the driver. The driver would query HPI_ADAPTER_PROPERTY_SSX2_SETTING during startup 322the driver. The driver would query HPI_ADAPTER_PROPERTY_SSX2_SETTING during
334and if SSX2 is set, it would then call HPI_ADAPTER_PROPERTY_ENABLE_SSX2 to enable 323startup and if SSX2 is set, it would then call HPI_ADAPTER_PROPERTY_ENABLE_SSX2
335SSX2 stream mapping within the kernel level of the driver. 324to enable SSX2 stream mapping within the kernel level of the driver.
336*/ 325*/
337 HPI_ADAPTER_PROPERTY_SSX2_SETTING = 4, 326 HPI_ADAPTER_PROPERTY_SSX2_SETTING = 4,
338 327
328/** Enables/disables PCI(e) IRQ.
329A setting of 0 indicates that no interrupts are being generated. A DSP boot
330this property is set to 0. Setting to a non-zero value specifies the number
331of frames of audio that should be processed between interrupts. This property
332should be set to multiple of the mixer interval as read back from the
333HPI_ADAPTER_PROPERTY_INTERVAL property.
334*/
335 HPI_ADAPTER_PROPERTY_IRQ_RATE = 5,
336
339/** Base number for readonly properties */ 337/** Base number for readonly properties */
340 HPI_ADAPTER_PROPERTY_READONLYBASE = 256, 338 HPI_ADAPTER_PROPERTY_READONLYBASE = 256,
341 339
@@ -440,21 +438,30 @@ return value is true (1) or false (0). If the current adapter
440mode is MONO SSX2 is disabled, even though this property will 438mode is MONO SSX2 is disabled, even though this property will
441return true. 439return true.
442*/ 440*/
443 HPI_ADAPTER_PROPERTY_SUPPORTS_SSX2 = 271 441 HPI_ADAPTER_PROPERTY_SUPPORTS_SSX2 = 271,
442/** Readonly supports PCI(e) IRQ.
443Indicates that the adapter in it's current mode supports interrupts
444across the host bus. Note, this does not imply that interrupts are
445enabled. Instead it indicates that they can be enabled.
446*/
447 HPI_ADAPTER_PROPERTY_SUPPORTS_IRQ = 272
444}; 448};
445 449
446/** Adapter mode commands 450/** Adapter mode commands
447 451
448Used in wQueryOrSet field of HPI_AdapterSetModeEx(). 452Used in wQueryOrSet parameter of HPI_AdapterSetModeEx().
449\ingroup adapter 453\ingroup adapter
450*/ 454*/
451enum HPI_ADAPTER_MODE_CMDS { 455enum HPI_ADAPTER_MODE_CMDS {
456 /** Set the mode to the given parameter */
452 HPI_ADAPTER_MODE_SET = 0, 457 HPI_ADAPTER_MODE_SET = 0,
458 /** Return 0 or error depending whether mode is valid,
459 but don't set the mode */
453 HPI_ADAPTER_MODE_QUERY = 1 460 HPI_ADAPTER_MODE_QUERY = 1
454}; 461};
455 462
456/** Adapter Modes 463/** Adapter Modes
457 These are used by HPI_AdapterSetModeEx() 464 These are used by HPI_AdapterSetModeEx()
458 465
459\warning - more than 16 possible modes breaks 466\warning - more than 16 possible modes breaks
460a bitmask in the Windows WAVE DLL 467a bitmask in the Windows WAVE DLL
@@ -629,10 +636,13 @@ enum HPI_MIXER_STORE_COMMAND {
629 HPI_MIXER_STORE_SAVE_SINGLE = 6 636 HPI_MIXER_STORE_SAVE_SINGLE = 6
630}; 637};
631 638
632/************************************* CONTROL ATTRIBUTE VALUES ****/ 639/****************************/
640/* CONTROL ATTRIBUTE VALUES */
641/****************************/
642
633/** Used by mixer plugin enable functions 643/** Used by mixer plugin enable functions
634 644
635E.g. HPI_ParametricEQ_SetState() 645E.g. HPI_ParametricEq_SetState()
636\ingroup mixer 646\ingroup mixer
637*/ 647*/
638enum HPI_SWITCH_STATES { 648enum HPI_SWITCH_STATES {
@@ -641,6 +651,7 @@ enum HPI_SWITCH_STATES {
641}; 651};
642 652
643/* Volume control special gain values */ 653/* Volume control special gain values */
654
644/** volumes units are 100ths of a dB 655/** volumes units are 100ths of a dB
645\ingroup volume 656\ingroup volume
646*/ 657*/
@@ -650,6 +661,11 @@ enum HPI_SWITCH_STATES {
650*/ 661*/
651#define HPI_GAIN_OFF (-100 * HPI_UNITS_PER_dB) 662#define HPI_GAIN_OFF (-100 * HPI_UNITS_PER_dB)
652 663
664/** channel mask specifying all channels
665\ingroup volume
666*/
667#define HPI_BITMASK_ALL_CHANNELS (0xFFFFFFFF)
668
653/** value returned for no signal 669/** value returned for no signal
654\ingroup meter 670\ingroup meter
655*/ 671*/
@@ -667,7 +683,7 @@ enum HPI_VOLUME_AUTOFADES {
667 683
668/** The physical encoding format of the AESEBU I/O. 684/** The physical encoding format of the AESEBU I/O.
669 685
670Used in HPI_AESEBU_Transmitter_SetFormat(), HPI_AESEBU_Receiver_SetFormat() 686Used in HPI_Aesebu_Transmitter_SetFormat(), HPI_Aesebu_Receiver_SetFormat()
671along with related Get and Query functions 687along with related Get and Query functions
672\ingroup aestx 688\ingroup aestx
673*/ 689*/
@@ -680,7 +696,7 @@ enum HPI_AESEBU_FORMATS {
680 696
681/** AES/EBU error status bits 697/** AES/EBU error status bits
682 698
683Returned by HPI_AESEBU_Receiver_GetErrorStatus() 699Returned by HPI_Aesebu_Receiver_GetErrorStatus()
684\ingroup aesrx 700\ingroup aesrx
685*/ 701*/
686enum HPI_AESEBU_ERRORS { 702enum HPI_AESEBU_ERRORS {
@@ -709,7 +725,7 @@ enum HPI_AESEBU_ERRORS {
709#define HPI_PAD_TITLE_LEN 64 725#define HPI_PAD_TITLE_LEN 64
710/** The text string containing the comment. */ 726/** The text string containing the comment. */
711#define HPI_PAD_COMMENT_LEN 256 727#define HPI_PAD_COMMENT_LEN 256
712/** The PTY when the tuner has not recieved any PTY. */ 728/** The PTY when the tuner has not received any PTY. */
713#define HPI_PAD_PROGRAM_TYPE_INVALID 0xffff 729#define HPI_PAD_PROGRAM_TYPE_INVALID 0xffff
714/** \} */ 730/** \} */
715 731
@@ -767,14 +783,6 @@ enum HPI_TUNER_MODE_VALUES {
767 HPI_TUNER_MODE_RDS_RBDS = 2 /**< RDS - RBDS mode */ 783 HPI_TUNER_MODE_RDS_RBDS = 2 /**< RDS - RBDS mode */
768}; 784};
769 785
770/** Tuner Level settings
771\ingroup tuner
772*/
773enum HPI_TUNER_LEVEL {
774 HPI_TUNER_LEVEL_AVERAGE = 0,
775 HPI_TUNER_LEVEL_RAW = 1
776};
777
778/** Tuner Status Bits 786/** Tuner Status Bits
779 787
780These bitfield values are returned by a call to HPI_Tuner_GetStatus(). 788These bitfield values are returned by a call to HPI_Tuner_GetStatus().
@@ -783,13 +791,13 @@ Multiple fields are returned from a single call.
783*/ 791*/
784enum HPI_TUNER_STATUS_BITS { 792enum HPI_TUNER_STATUS_BITS {
785 HPI_TUNER_VIDEO_COLOR_PRESENT = 0x0001, /**< video color is present. */ 793 HPI_TUNER_VIDEO_COLOR_PRESENT = 0x0001, /**< video color is present. */
786 HPI_TUNER_VIDEO_IS_60HZ = 0x0020, /**< 60 hz video detected. */ 794 HPI_TUNER_VIDEO_IS_60HZ = 0x0020, /**< 60 hz video detected. */
787 HPI_TUNER_VIDEO_HORZ_SYNC_MISSING = 0x0040, /**< video HSYNC is missing. */ 795 HPI_TUNER_VIDEO_HORZ_SYNC_MISSING = 0x0040, /**< video HSYNC is missing. */
788 HPI_TUNER_VIDEO_STATUS_VALID = 0x0100, /**< video status is valid. */ 796 HPI_TUNER_VIDEO_STATUS_VALID = 0x0100, /**< video status is valid. */
789 HPI_TUNER_PLL_LOCKED = 0x1000, /**< the tuner's PLL is locked. */ 797 HPI_TUNER_DIGITAL = 0x0200, /**< tuner reports digital programming. */
790 HPI_TUNER_FM_STEREO = 0x2000, /**< tuner reports back FM stereo. */ 798 HPI_TUNER_MULTIPROGRAM = 0x0400, /**< tuner reports multiple programs. */
791 HPI_TUNER_DIGITAL = 0x0200, /**< tuner reports digital programming. */ 799 HPI_TUNER_PLL_LOCKED = 0x1000, /**< the tuner's PLL is locked. */
792 HPI_TUNER_MULTIPROGRAM = 0x0400 /**< tuner reports multiple programs. */ 800 HPI_TUNER_FM_STEREO = 0x2000 /**< tuner reports back FM stereo. */
793}; 801};
794 802
795/** Channel Modes 803/** Channel Modes
@@ -839,7 +847,7 @@ enum HPI_SAMPLECLOCK_SOURCES {
839 HPI_SAMPLECLOCK_SOURCE_LAST = 10 847 HPI_SAMPLECLOCK_SOURCE_LAST = 10
840}; 848};
841 849
842/** Equalizer filter types. Used by HPI_ParametricEQ_SetBand() 850/** Equalizer filter types. Used by HPI_ParametricEq_SetBand()
843\ingroup parmeq 851\ingroup parmeq
844*/ 852*/
845enum HPI_FILTER_TYPE { 853enum HPI_FILTER_TYPE {
@@ -882,7 +890,7 @@ enum HPI_ERROR_CODES {
882 HPI_ERROR_INVALID_OBJ = 101, 890 HPI_ERROR_INVALID_OBJ = 101,
883 /** Function does not exist. */ 891 /** Function does not exist. */
884 HPI_ERROR_INVALID_FUNC = 102, 892 HPI_ERROR_INVALID_FUNC = 102,
885 /** The specified object (adapter/Stream) does not exist. */ 893 /** The specified object does not exist. */
886 HPI_ERROR_INVALID_OBJ_INDEX = 103, 894 HPI_ERROR_INVALID_OBJ_INDEX = 103,
887 /** Trying to access an object that has not been opened yet. */ 895 /** Trying to access an object that has not been opened yet. */
888 HPI_ERROR_OBJ_NOT_OPEN = 104, 896 HPI_ERROR_OBJ_NOT_OPEN = 104,
@@ -890,8 +898,7 @@ enum HPI_ERROR_CODES {
890 HPI_ERROR_OBJ_ALREADY_OPEN = 105, 898 HPI_ERROR_OBJ_ALREADY_OPEN = 105,
891 /** PCI, ISA resource not valid. */ 899 /** PCI, ISA resource not valid. */
892 HPI_ERROR_INVALID_RESOURCE = 106, 900 HPI_ERROR_INVALID_RESOURCE = 106,
893 /** GetInfo call from SubSysFindAdapters failed. */ 901 /* HPI_ERROR_SUBSYSFINDADAPTERS_GETINFO= 107 */
894 HPI_ERROR_SUBSYSFINDADAPTERS_GETINFO = 107,
895 /** Default response was never updated with actual error code. */ 902 /** Default response was never updated with actual error code. */
896 HPI_ERROR_INVALID_RESPONSE = 108, 903 HPI_ERROR_INVALID_RESPONSE = 108,
897 /** wSize field of response was not updated, 904 /** wSize field of response was not updated,
@@ -899,38 +906,44 @@ enum HPI_ERROR_CODES {
899 HPI_ERROR_PROCESSING_MESSAGE = 109, 906 HPI_ERROR_PROCESSING_MESSAGE = 109,
900 /** The network did not respond in a timely manner. */ 907 /** The network did not respond in a timely manner. */
901 HPI_ERROR_NETWORK_TIMEOUT = 110, 908 HPI_ERROR_NETWORK_TIMEOUT = 110,
902 /** An HPI handle is invalid (uninitialised?). */ 909 /* An HPI handle is invalid (uninitialised?). */
903 HPI_ERROR_INVALID_HANDLE = 111, 910 HPI_ERROR_INVALID_HANDLE = 111,
904 /** A function or attribute has not been implemented yet. */ 911 /** A function or attribute has not been implemented yet. */
905 HPI_ERROR_UNIMPLEMENTED = 112, 912 HPI_ERROR_UNIMPLEMENTED = 112,
906 /** There are too many clients attempting to access a network resource. */ 913 /** There are too many clients attempting
914 to access a network resource. */
907 HPI_ERROR_NETWORK_TOO_MANY_CLIENTS = 113, 915 HPI_ERROR_NETWORK_TOO_MANY_CLIENTS = 113,
908 /** Response buffer passed to HPI_Message was smaller than returned response */ 916 /** Response buffer passed to HPI_Message
917 was smaller than returned response.
918 wSpecificError field of hpi response contains the required size.
919 */
909 HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL = 114, 920 HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL = 114,
910 /** The returned response did not match the sent message */ 921 /** The returned response did not match the sent message */
911 HPI_ERROR_RESPONSE_MISMATCH = 115, 922 HPI_ERROR_RESPONSE_MISMATCH = 115,
923 /** A control setting that should have been cached was not. */
924 HPI_ERROR_CONTROL_CACHING = 116,
925 /** A message buffer in the path to the adapter was smaller
926 than the message size.
927 wSpecificError field of hpi response contains the actual size.
928 */
929 HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL = 117,
912 930
913 /** Too many adapters.*/ 931 /* HPI_ERROR_TOO_MANY_ADAPTERS= 200 */
914 HPI_ERROR_TOO_MANY_ADAPTERS = 200,
915 /** Bad adpater. */ 932 /** Bad adpater. */
916 HPI_ERROR_BAD_ADAPTER = 201, 933 HPI_ERROR_BAD_ADAPTER = 201,
917 /** Adapter number out of range or not set properly. */ 934 /** Adapter number out of range or not set properly. */
918 HPI_ERROR_BAD_ADAPTER_NUMBER = 202, 935 HPI_ERROR_BAD_ADAPTER_NUMBER = 202,
919 /** 2 adapters with the same adapter number. */ 936 /** 2 adapters with the same adapter number. */
920 HPI_DUPLICATE_ADAPTER_NUMBER = 203, 937 HPI_ERROR_DUPLICATE_ADAPTER_NUMBER = 203,
921 /** DSP code failed to bootload. */ 938 /** DSP code failed to bootload. (unused?) */
922 HPI_ERROR_DSP_BOOTLOAD = 204, 939 HPI_ERROR_DSP_BOOTLOAD = 204,
923 /** Adapter failed DSP code self test. */
924 HPI_ERROR_DSP_SELFTEST = 205,
925 /** Couldn't find or open the DSP code file. */ 940 /** Couldn't find or open the DSP code file. */
926 HPI_ERROR_DSP_FILE_NOT_FOUND = 206, 941 HPI_ERROR_DSP_FILE_NOT_FOUND = 206,
927 /** Internal DSP hardware error. */ 942 /** Internal DSP hardware error. */
928 HPI_ERROR_DSP_HARDWARE = 207, 943 HPI_ERROR_DSP_HARDWARE = 207,
929 /** Could not allocate memory in DOS. */
930 HPI_ERROR_DOS_MEMORY_ALLOC = 208,
931 /** Could not allocate memory */ 944 /** Could not allocate memory */
932 HPI_ERROR_MEMORY_ALLOC = 208, 945 HPI_ERROR_MEMORY_ALLOC = 208,
933 /** Failed to correctly load/config PLD .*/ 946 /** Failed to correctly load/config PLD. (unused) */
934 HPI_ERROR_PLD_LOAD = 209, 947 HPI_ERROR_PLD_LOAD = 209,
935 /** Unexpected end of file, block length too big etc. */ 948 /** Unexpected end of file, block length too big etc. */
936 HPI_ERROR_DSP_FILE_FORMAT = 210, 949 HPI_ERROR_DSP_FILE_FORMAT = 210,
@@ -939,8 +952,7 @@ enum HPI_ERROR_CODES {
939 HPI_ERROR_DSP_FILE_ACCESS_DENIED = 211, 952 HPI_ERROR_DSP_FILE_ACCESS_DENIED = 211,
940 /** First DSP code section header not found in DSP file. */ 953 /** First DSP code section header not found in DSP file. */
941 HPI_ERROR_DSP_FILE_NO_HEADER = 212, 954 HPI_ERROR_DSP_FILE_NO_HEADER = 212,
942 /** File read operation on DSP code file failed. */ 955 /* HPI_ERROR_DSP_FILE_READ_ERROR= 213, */
943 HPI_ERROR_DSP_FILE_READ_ERROR = 213,
944 /** DSP code for adapter family not found. */ 956 /** DSP code for adapter family not found. */
945 HPI_ERROR_DSP_SECTION_NOT_FOUND = 214, 957 HPI_ERROR_DSP_SECTION_NOT_FOUND = 214,
946 /** Other OS specific error opening DSP file. */ 958 /** Other OS specific error opening DSP file. */
@@ -950,23 +962,21 @@ enum HPI_ERROR_CODES {
950 /** DSP code section header had size == 0. */ 962 /** DSP code section header had size == 0. */
951 HPI_ERROR_DSP_FILE_NULL_HEADER = 217, 963 HPI_ERROR_DSP_FILE_NULL_HEADER = 217,
952 964
953 /** Base number for flash errors. */ 965 /* HPI_ERROR_FLASH = 220, */
954 HPI_ERROR_FLASH = 220,
955 966
956 /** Flash has bad checksum */ 967 /** Flash has bad checksum */
957 HPI_ERROR_BAD_CHECKSUM = (HPI_ERROR_FLASH + 1), 968 HPI_ERROR_BAD_CHECKSUM = 221,
958 HPI_ERROR_BAD_SEQUENCE = (HPI_ERROR_FLASH + 2), 969 HPI_ERROR_BAD_SEQUENCE = 222,
959 HPI_ERROR_FLASH_ERASE = (HPI_ERROR_FLASH + 3), 970 HPI_ERROR_FLASH_ERASE = 223,
960 HPI_ERROR_FLASH_PROGRAM = (HPI_ERROR_FLASH + 4), 971 HPI_ERROR_FLASH_PROGRAM = 224,
961 HPI_ERROR_FLASH_VERIFY = (HPI_ERROR_FLASH + 5), 972 HPI_ERROR_FLASH_VERIFY = 225,
962 HPI_ERROR_FLASH_TYPE = (HPI_ERROR_FLASH + 6), 973 HPI_ERROR_FLASH_TYPE = 226,
963 HPI_ERROR_FLASH_START = (HPI_ERROR_FLASH + 7), 974 HPI_ERROR_FLASH_START = 227,
964 975
965 /** Reserved for OEMs. */ 976 /** Reserved for OEMs. */
966 HPI_ERROR_RESERVED_1 = 290, 977 HPI_ERROR_RESERVED_1 = 290,
967 978
968 /** Stream does not exist. */ 979 /* HPI_ERROR_INVALID_STREAM = 300 use HPI_ERROR_INVALID_OBJ_INDEX */
969 HPI_ERROR_INVALID_STREAM = 300,
970 /** Invalid compression format. */ 980 /** Invalid compression format. */
971 HPI_ERROR_INVALID_FORMAT = 301, 981 HPI_ERROR_INVALID_FORMAT = 301,
972 /** Invalid format samplerate */ 982 /** Invalid format samplerate */
@@ -977,21 +987,19 @@ enum HPI_ERROR_CODES {
977 HPI_ERROR_INVALID_BITRATE = 304, 987 HPI_ERROR_INVALID_BITRATE = 304,
978 /** Invalid datasize used for stream read/write. */ 988 /** Invalid datasize used for stream read/write. */
979 HPI_ERROR_INVALID_DATASIZE = 305, 989 HPI_ERROR_INVALID_DATASIZE = 305,
980 /** Stream buffer is full during stream write. */ 990 /* HPI_ERROR_BUFFER_FULL = 306 use HPI_ERROR_INVALID_DATASIZE */
981 HPI_ERROR_BUFFER_FULL = 306, 991 /* HPI_ERROR_BUFFER_EMPTY = 307 use HPI_ERROR_INVALID_DATASIZE */
982 /** Stream buffer is empty during stream read. */ 992 /** Null data pointer used for stream read/write. */
983 HPI_ERROR_BUFFER_EMPTY = 307, 993 HPI_ERROR_INVALID_DATA_POINTER = 308,
984 /** Invalid datasize used for stream read/write. */
985 HPI_ERROR_INVALID_DATA_TRANSFER = 308,
986 /** Packet ordering error for stream read/write. */ 994 /** Packet ordering error for stream read/write. */
987 HPI_ERROR_INVALID_PACKET_ORDER = 309, 995 HPI_ERROR_INVALID_PACKET_ORDER = 309,
988 996
989 /** Object can't do requested operation in its current 997 /** Object can't do requested operation in its current
990 state, eg set format, change rec mux state while recording.*/ 998 state, eg set format, change rec mux state while recording.*/
991 HPI_ERROR_INVALID_OPERATION = 310, 999 HPI_ERROR_INVALID_OPERATION = 310,
992 1000
993 /** Where an SRG is shared amongst streams, an incompatible samplerate is one 1001 /** Where a SRG is shared amongst streams, an incompatible samplerate
994 that is different to any currently playing or recording stream. */ 1002 is one that is different to any currently active stream. */
995 HPI_ERROR_INCOMPATIBLE_SAMPLERATE = 311, 1003 HPI_ERROR_INCOMPATIBLE_SAMPLERATE = 311,
996 /** Adapter mode is illegal.*/ 1004 /** Adapter mode is illegal.*/
997 HPI_ERROR_BAD_ADAPTER_MODE = 312, 1005 HPI_ERROR_BAD_ADAPTER_MODE = 312,
@@ -1004,6 +1012,8 @@ enum HPI_ERROR_CODES {
1004 HPI_ERROR_NO_INTERADAPTER_GROUPS = 314, 1012 HPI_ERROR_NO_INTERADAPTER_GROUPS = 314,
1005 /** Streams on different DSPs cannot be grouped. */ 1013 /** Streams on different DSPs cannot be grouped. */
1006 HPI_ERROR_NO_INTERDSP_GROUPS = 315, 1014 HPI_ERROR_NO_INTERDSP_GROUPS = 315,
1015 /** Stream wait cancelled before threshold reached. */
1016 HPI_ERROR_WAIT_CANCELLED = 316,
1007 1017
1008 /** Invalid mixer node for this adapter. */ 1018 /** Invalid mixer node for this adapter. */
1009 HPI_ERROR_INVALID_NODE = 400, 1019 HPI_ERROR_INVALID_NODE = 400,
@@ -1017,6 +1027,7 @@ enum HPI_ERROR_CODES {
1017 HPI_ERROR_CONTROL_DISABLED = 404, 1027 HPI_ERROR_CONTROL_DISABLED = 404,
1018 /** I2C transaction failed due to a missing ACK. */ 1028 /** I2C transaction failed due to a missing ACK. */
1019 HPI_ERROR_CONTROL_I2C_MISSING_ACK = 405, 1029 HPI_ERROR_CONTROL_I2C_MISSING_ACK = 405,
1030 HPI_ERROR_I2C_MISSING_ACK = 405,
1020 /** Control is busy, or coming out of 1031 /** Control is busy, or coming out of
1021 reset and cannot be accessed at this time. */ 1032 reset and cannot be accessed at this time. */
1022 HPI_ERROR_CONTROL_NOT_READY = 407, 1033 HPI_ERROR_CONTROL_NOT_READY = 407,
@@ -1027,7 +1038,6 @@ enum HPI_ERROR_CODES {
1027 HPI_ERROR_NVMEM_FAIL = 452, 1038 HPI_ERROR_NVMEM_FAIL = 452,
1028 1039
1029 /** I2C */ 1040 /** I2C */
1030 HPI_ERROR_I2C_MISSING_ACK = HPI_ERROR_CONTROL_I2C_MISSING_ACK,
1031 HPI_ERROR_I2C_BAD_ADR = 460, 1041 HPI_ERROR_I2C_BAD_ADR = 460,
1032 1042
1033 /** Entity errors */ 1043 /** Entity errors */
@@ -1035,6 +1045,7 @@ enum HPI_ERROR_CODES {
1035 HPI_ERROR_ENTITY_ITEM_COUNT = 471, 1045 HPI_ERROR_ENTITY_ITEM_COUNT = 471,
1036 HPI_ERROR_ENTITY_TYPE_INVALID = 472, 1046 HPI_ERROR_ENTITY_TYPE_INVALID = 472,
1037 HPI_ERROR_ENTITY_ROLE_INVALID = 473, 1047 HPI_ERROR_ENTITY_ROLE_INVALID = 473,
1048 HPI_ERROR_ENTITY_SIZE_MISMATCH = 474,
1038 1049
1039 /* AES18 specific errors were 500..507 */ 1050 /* AES18 specific errors were 500..507 */
1040 1051
@@ -1044,11 +1055,18 @@ enum HPI_ERROR_CODES {
1044 /** hpioct32.c can't obtain mutex */ 1055 /** hpioct32.c can't obtain mutex */
1045 HPI_ERROR_MUTEX_TIMEOUT = 700, 1056 HPI_ERROR_MUTEX_TIMEOUT = 700,
1046 1057
1047 /** errors from HPI backends have values >= this */ 1058 /** Backend errors used to be greater than this.
1059 \deprecated Now, all backends return only errors defined here in hpi.h
1060 */
1048 HPI_ERROR_BACKEND_BASE = 900, 1061 HPI_ERROR_BACKEND_BASE = 900,
1049 1062
1050 /** indicates a cached u16 value is invalid. */ 1063 /** Communication with DSP failed */
1051 HPI_ERROR_ILLEGAL_CACHE_VALUE = 0xffff 1064 HPI_ERROR_DSP_COMMUNICATION = 900
1065 /* Note that the dsp communication error is set to this value so that
1066 it remains compatible with any software that expects such errors
1067 to be backend errors i.e. >= 900.
1068 Do not define any new error codes with values > 900.
1069 */
1052}; 1070};
1053 1071
1054/** \defgroup maximums HPI maximum values 1072/** \defgroup maximums HPI maximum values
@@ -1075,7 +1093,7 @@ enum HPI_ERROR_CODES {
1075 1093
1076/**\}*/ 1094/**\}*/
1077 1095
1078/* ////////////////////////////////////////////////////////////////////// */ 1096/**************/
1079/* STRUCTURES */ 1097/* STRUCTURES */
1080#ifndef DISABLE_PRAGMA_PACK1 1098#ifndef DISABLE_PRAGMA_PACK1
1081#pragma pack(push, 1) 1099#pragma pack(push, 1)
@@ -1092,7 +1110,7 @@ struct hpi_format {
1092 /**< Stereo/JointStereo/Mono */ 1110 /**< Stereo/JointStereo/Mono */
1093 u16 mode_legacy; 1111 u16 mode_legacy;
1094 /**< Legacy ancillary mode or idle bit */ 1112 /**< Legacy ancillary mode or idle bit */
1095 u16 unused; /**< unused */ 1113 u16 unused; /**< Unused */
1096 u16 channels; /**< 1,2..., (or ancillary mode or idle bit */ 1114 u16 channels; /**< 1,2..., (or ancillary mode or idle bit */
1097 u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see #HPI_FORMATS. */ 1115 u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see #HPI_FORMATS. */
1098}; 1116};
@@ -1106,930 +1124,594 @@ struct hpi_anc_frame {
1106*/ 1124*/
1107struct hpi_async_event { 1125struct hpi_async_event {
1108 u16 event_type; /**< type of event. \sa async_event */ 1126 u16 event_type; /**< type of event. \sa async_event */
1109 u16 sequence; /**< sequence number, allows lost event detection */ 1127 u16 sequence; /**< Sequence number, allows lost event detection */
1110 u32 state; /**< new state */ 1128 u32 state; /**< New state */
1111 u32 h_object; /**< handle to the object returning the event. */ 1129 u32 h_object; /**< handle to the object returning the event. */
1112 union { 1130 union {
1113 struct { 1131 struct {
1114 u16 index; /**< GPIO bit index. */ 1132 u16 index; /**< GPIO bit index. */
1115 } gpio; 1133 } gpio;
1116 struct { 1134 struct {
1117 u16 node_index; /**< what node is the control on ? */ 1135 u16 node_index; /**< what node is the control on ? */
1118 u16 node_type; /**< what type of node is the control on ? */ 1136 u16 node_type; /**< what type of node is the control on ? */
1119 } control; 1137 } control;
1120 } u; 1138 } u;
1121}; 1139};
1122 1140
1123/*/////////////////////////////////////////////////////////////////////////// */
1124/* Public HPI Entity related definitions */
1125
1126struct hpi_entity;
1127
1128enum e_entity_type {
1129 entity_type_null,
1130 entity_type_sequence, /* sequence of potentially heterogeneous TLV entities */
1131
1132 entity_type_reference, /* refers to a TLV entity or NULL */
1133
1134 entity_type_int, /* 32 bit */
1135 entity_type_float, /* ieee754 binary 32 bit encoding */
1136 entity_type_double,
1137
1138 entity_type_cstring,
1139 entity_type_octet,
1140 entity_type_ip4_address,
1141 entity_type_ip6_address,
1142 entity_type_mac_address,
1143
1144 LAST_ENTITY_TYPE
1145};
1146
1147enum e_entity_role {
1148 entity_role_null,
1149 entity_role_value,
1150 entity_role_classname,
1151
1152 entity_role_units,
1153 entity_role_flags,
1154 entity_role_range,
1155
1156 entity_role_mapping,
1157 entity_role_enum,
1158
1159 entity_role_instance_of,
1160 entity_role_depends_on,
1161 entity_role_member_of_group,
1162 entity_role_value_constraint,
1163 entity_role_parameter_port,
1164
1165 entity_role_block,
1166 entity_role_node_group,
1167 entity_role_audio_port,
1168 entity_role_clock_port,
1169 LAST_ENTITY_ROLE
1170};
1171
1172/* skip host side function declarations for 1141/* skip host side function declarations for
1173 DSP compile and documentation extraction */ 1142 DSP compile and documentation extraction */
1174 1143
1175struct hpi_hsubsys {
1176 int not_really_used;
1177};
1178
1179#ifndef DISABLE_PRAGMA_PACK1 1144#ifndef DISABLE_PRAGMA_PACK1
1180#pragma pack(pop) 1145#pragma pack(pop)
1181#endif 1146#endif
1182 1147
1183/*////////////////////////////////////////////////////////////////////////// */ 1148/*****************/
1184/* HPI FUNCTIONS */ 1149/* HPI FUNCTIONS */
1150/*****************/
1185 1151
1186/*/////////////////////////// */ 1152/* Stream */
1187/* DATA and FORMAT and STREAM */
1188
1189u16 hpi_stream_estimate_buffer_size(struct hpi_format *pF, 1153u16 hpi_stream_estimate_buffer_size(struct hpi_format *pF,
1190 u32 host_polling_rate_in_milli_seconds, u32 *recommended_buffer_size); 1154 u32 host_polling_rate_in_milli_seconds, u32 *recommended_buffer_size);
1191 1155
1192/*/////////// */ 1156/*************/
1193/* SUB SYSTEM */ 1157/* SubSystem */
1194struct hpi_hsubsys *hpi_subsys_create(void 1158/*************/
1195 );
1196
1197void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys);
1198
1199u16 hpi_subsys_get_version(const struct hpi_hsubsys *ph_subsys,
1200 u32 *pversion);
1201
1202u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys,
1203 u32 *pversion_ex);
1204
1205u16 hpi_subsys_get_info(const struct hpi_hsubsys *ph_subsys, u32 *pversion,
1206 u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length);
1207
1208u16 hpi_subsys_find_adapters(const struct hpi_hsubsys *ph_subsys,
1209 u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length);
1210
1211u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys,
1212 int *pn_num_adapters);
1213
1214u16 hpi_subsys_get_adapter(const struct hpi_hsubsys *ph_subsys, int iterator,
1215 u32 *padapter_index, u16 *pw_adapter_type);
1216
1217u16 hpi_subsys_ssx2_bypass(const struct hpi_hsubsys *ph_subsys, u16 bypass);
1218 1159
1219u16 hpi_subsys_set_host_network_interface(const struct hpi_hsubsys *ph_subsys, 1160u16 hpi_subsys_get_version_ex(u32 *pversion_ex);
1220 const char *sz_interface);
1221 1161
1222/*///////// */ 1162u16 hpi_subsys_get_num_adapters(int *pn_num_adapters);
1223/* ADAPTER */
1224 1163
1225u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index); 1164u16 hpi_subsys_get_adapter(int iterator, u32 *padapter_index,
1165 u16 *pw_adapter_type);
1226 1166
1227u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index); 1167/***********/
1168/* Adapter */
1169/***********/
1228 1170
1229u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys, 1171u16 hpi_adapter_open(u16 adapter_index);
1230 u16 adapter_index, u16 *pw_num_outstreams, u16 *pw_num_instreams,
1231 u16 *pw_version, u32 *pserial_number, u16 *pw_adapter_type);
1232 1172
1233u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys, 1173u16 hpi_adapter_close(u16 adapter_index);
1234 u16 adapter_index, u16 module_index, u16 *pw_num_outputs,
1235 u16 *pw_num_inputs, u16 *pw_version, u32 *pserial_number,
1236 u16 *pw_module_type, u32 *ph_module);
1237 1174
1238u16 hpi_adapter_set_mode(const struct hpi_hsubsys *ph_subsys, 1175u16 hpi_adapter_get_info(u16 adapter_index, u16 *pw_num_outstreams,
1239 u16 adapter_index, u32 adapter_mode); 1176 u16 *pw_num_instreams, u16 *pw_version, u32 *pserial_number,
1177 u16 *pw_adapter_type);
1240 1178
1241u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys, 1179u16 hpi_adapter_get_module_by_index(u16 adapter_index, u16 module_index,
1242 u16 adapter_index, u32 adapter_mode, u16 query_or_set); 1180 u16 *pw_num_outputs, u16 *pw_num_inputs, u16 *pw_version,
1243 1181 u32 *pserial_number, u16 *pw_module_type, u32 *ph_module);
1244u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys,
1245 u16 adapter_index, u32 *padapter_mode);
1246
1247u16 hpi_adapter_get_assert(const struct hpi_hsubsys *ph_subsys,
1248 u16 adapter_index, u16 *assert_present, char *psz_assert,
1249 u16 *pw_line_number);
1250
1251u16 hpi_adapter_get_assert_ex(const struct hpi_hsubsys *ph_subsys,
1252 u16 adapter_index, u16 *assert_present, char *psz_assert,
1253 u32 *pline_number, u16 *pw_assert_on_dsp);
1254
1255u16 hpi_adapter_test_assert(const struct hpi_hsubsys *ph_subsys,
1256 u16 adapter_index, u16 assert_id);
1257
1258u16 hpi_adapter_enable_capability(const struct hpi_hsubsys *ph_subsys,
1259 u16 adapter_index, u16 capability, u32 key);
1260
1261u16 hpi_adapter_self_test(const struct hpi_hsubsys *ph_subsys,
1262 u16 adapter_index);
1263
1264u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys,
1265 u16 adapter_index, u32 dsp_address, char *p_bytes, int *count_bytes);
1266
1267u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys,
1268 u16 adapter_index, u16 property, u16 paramter1, u16 paramter2);
1269
1270u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys,
1271 u16 adapter_index, u16 property, u16 *pw_paramter1,
1272 u16 *pw_paramter2);
1273
1274u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys,
1275 u16 adapter_index, u16 index, u16 what_to_enumerate,
1276 u16 property_index, u32 *psetting);
1277
1278/*////////////// */
1279/* NonVol Memory */
1280u16 hpi_nv_memory_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1281 u32 *ph_nv_memory, u16 *pw_size_in_bytes);
1282
1283u16 hpi_nv_memory_read_byte(const struct hpi_hsubsys *ph_subsys,
1284 u32 h_nv_memory, u16 index, u16 *pw_data);
1285
1286u16 hpi_nv_memory_write_byte(const struct hpi_hsubsys *ph_subsys,
1287 u32 h_nv_memory, u16 index, u16 data);
1288
1289/*////////////// */
1290/* Digital I/O */
1291u16 hpi_gpio_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1292 u32 *ph_gpio, u16 *pw_number_input_bits, u16 *pw_number_output_bits);
1293
1294u16 hpi_gpio_read_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
1295 u16 bit_index, u16 *pw_bit_data);
1296
1297u16 hpi_gpio_read_all_bits(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
1298 u16 aw_all_bit_data[4]
1299 );
1300 1182
1301u16 hpi_gpio_write_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, 1183u16 hpi_adapter_set_mode(u16 adapter_index, u32 adapter_mode);
1302 u16 bit_index, u16 bit_data);
1303 1184
1304u16 hpi_gpio_write_status(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, 1185u16 hpi_adapter_set_mode_ex(u16 adapter_index, u32 adapter_mode,
1305 u16 aw_all_bit_data[4] 1186 u16 query_or_set);
1306 );
1307 1187
1308/**********************/ 1188u16 hpi_adapter_get_mode(u16 adapter_index, u32 *padapter_mode);
1309/* Async Event Object */
1310/**********************/
1311u16 hpi_async_event_open(const struct hpi_hsubsys *ph_subsys,
1312 u16 adapter_index, u32 *ph_async);
1313 1189
1314u16 hpi_async_event_close(const struct hpi_hsubsys *ph_subsys, u32 h_async); 1190u16 hpi_adapter_get_assert2(u16 adapter_index, u16 *p_assert_count,
1191 char *psz_assert, u32 *p_param1, u32 *p_param2,
1192 u32 *p_dsp_string_addr, u16 *p_processor_id);
1315 1193
1316u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async, 1194u16 hpi_adapter_test_assert(u16 adapter_index, u16 assert_id);
1317 u16 maximum_events, struct hpi_async_event *p_events,
1318 u16 *pw_number_returned);
1319 1195
1320u16 hpi_async_event_get_count(const struct hpi_hsubsys *ph_subsys, 1196u16 hpi_adapter_enable_capability(u16 adapter_index, u16 capability, u32 key);
1321 u32 h_async, u16 *pw_count);
1322 1197
1323u16 hpi_async_event_get(const struct hpi_hsubsys *ph_subsys, u32 h_async, 1198u16 hpi_adapter_self_test(u16 adapter_index);
1324 u16 maximum_events, struct hpi_async_event *p_events,
1325 u16 *pw_number_returned);
1326 1199
1327/*/////////// */ 1200u16 hpi_adapter_debug_read(u16 adapter_index, u32 dsp_address, char *p_bytes,
1328/* WATCH-DOG */ 1201 int *count_bytes);
1329u16 hpi_watchdog_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1330 u32 *ph_watchdog);
1331 1202
1332u16 hpi_watchdog_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog, 1203u16 hpi_adapter_set_property(u16 adapter_index, u16 property, u16 paramter1,
1333 u32 time_millisec); 1204 u16 paramter2);
1334 1205
1335u16 hpi_watchdog_ping(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog); 1206u16 hpi_adapter_get_property(u16 adapter_index, u16 property,
1207 u16 *pw_paramter1, u16 *pw_paramter2);
1336 1208
1337/**************/ 1209u16 hpi_adapter_enumerate_property(u16 adapter_index, u16 index,
1338/* OUT STREAM */ 1210 u16 what_to_enumerate, u16 property_index, u32 *psetting);
1339/**************/ 1211/*************/
1340u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 1212/* OutStream */
1341 u16 outstream_index, u32 *ph_outstream); 1213/*************/
1214u16 hpi_outstream_open(u16 adapter_index, u16 outstream_index,
1215 u32 *ph_outstream);
1342 1216
1343u16 hpi_outstream_close(const struct hpi_hsubsys *ph_subsys, u32 h_outstream); 1217u16 hpi_outstream_close(u32 h_outstream);
1344 1218
1345u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys, 1219u16 hpi_outstream_get_info_ex(u32 h_outstream, u16 *pw_state,
1346 u32 h_outstream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_to_play, 1220 u32 *pbuffer_size, u32 *pdata_to_play, u32 *psamples_played,
1347 u32 *psamples_played, u32 *pauxiliary_data_to_play); 1221 u32 *pauxiliary_data_to_play);
1348 1222
1349u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys, 1223u16 hpi_outstream_write_buf(u32 h_outstream, const u8 *pb_write_buf,
1350 u32 h_outstream, const u8 *pb_write_buf, u32 bytes_to_write, 1224 u32 bytes_to_write, const struct hpi_format *p_format);
1351 const struct hpi_format *p_format);
1352 1225
1353u16 hpi_outstream_start(const struct hpi_hsubsys *ph_subsys, u32 h_outstream); 1226u16 hpi_outstream_start(u32 h_outstream);
1354 1227
1355u16 hpi_outstream_wait_start(const struct hpi_hsubsys *ph_subsys, 1228u16 hpi_outstream_wait_start(u32 h_outstream);
1356 u32 h_outstream);
1357 1229
1358u16 hpi_outstream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_outstream); 1230u16 hpi_outstream_stop(u32 h_outstream);
1359 1231
1360u16 hpi_outstream_sinegen(const struct hpi_hsubsys *ph_subsys, 1232u16 hpi_outstream_sinegen(u32 h_outstream);
1361 u32 h_outstream);
1362 1233
1363u16 hpi_outstream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_outstream); 1234u16 hpi_outstream_reset(u32 h_outstream);
1364 1235
1365u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys, 1236u16 hpi_outstream_query_format(u32 h_outstream, struct hpi_format *p_format);
1366 u32 h_outstream, struct hpi_format *p_format);
1367 1237
1368u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys, 1238u16 hpi_outstream_set_format(u32 h_outstream, struct hpi_format *p_format);
1369 u32 h_outstream, struct hpi_format *p_format);
1370 1239
1371u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys, 1240u16 hpi_outstream_set_punch_in_out(u32 h_outstream, u32 punch_in_sample,
1372 u32 h_outstream, u32 punch_in_sample, u32 punch_out_sample); 1241 u32 punch_out_sample);
1373 1242
1374u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys, 1243u16 hpi_outstream_set_velocity(u32 h_outstream, short velocity);
1375 u32 h_outstream, short velocity);
1376 1244
1377u16 hpi_outstream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, 1245u16 hpi_outstream_ancillary_reset(u32 h_outstream, u16 mode);
1378 u32 h_outstream, u16 mode);
1379 1246
1380u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, 1247u16 hpi_outstream_ancillary_get_info(u32 h_outstream, u32 *pframes_available);
1381 u32 h_outstream, u32 *pframes_available);
1382 1248
1383u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys, 1249u16 hpi_outstream_ancillary_read(u32 h_outstream,
1384 u32 h_outstream, struct hpi_anc_frame *p_anc_frame_buffer, 1250 struct hpi_anc_frame *p_anc_frame_buffer,
1385 u32 anc_frame_buffer_size_in_bytes, 1251 u32 anc_frame_buffer_size_in_bytes,
1386 u32 number_of_ancillary_frames_to_read); 1252 u32 number_of_ancillary_frames_to_read);
1387 1253
1388u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys, 1254u16 hpi_outstream_set_time_scale(u32 h_outstream, u32 time_scaleX10000);
1389 u32 h_outstream, u32 time_scaleX10000);
1390 1255
1391u16 hpi_outstream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, 1256u16 hpi_outstream_host_buffer_allocate(u32 h_outstream, u32 size_in_bytes);
1392 u32 h_outstream, u32 size_in_bytes);
1393 1257
1394u16 hpi_outstream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, 1258u16 hpi_outstream_host_buffer_free(u32 h_outstream);
1395 u32 h_outstream);
1396 1259
1397u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys, 1260u16 hpi_outstream_group_add(u32 h_outstream, u32 h_stream);
1398 u32 h_outstream, u32 h_stream);
1399 1261
1400u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys, 1262u16 hpi_outstream_group_get_map(u32 h_outstream, u32 *poutstream_map,
1401 u32 h_outstream, u32 *poutstream_map, u32 *pinstream_map); 1263 u32 *pinstream_map);
1402 1264
1403u16 hpi_outstream_group_reset(const struct hpi_hsubsys *ph_subsys, 1265u16 hpi_outstream_group_reset(u32 h_outstream);
1404 u32 h_outstream);
1405 1266
1406/*////////// */ 1267/************/
1407/* IN_STREAM */ 1268/* InStream */
1408u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 1269/************/
1409 u16 instream_index, u32 *ph_instream); 1270u16 hpi_instream_open(u16 adapter_index, u16 instream_index,
1271 u32 *ph_instream);
1410 1272
1411u16 hpi_instream_close(const struct hpi_hsubsys *ph_subsys, u32 h_instream); 1273u16 hpi_instream_close(u32 h_instream);
1412 1274
1413u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys, 1275u16 hpi_instream_query_format(u32 h_instream,
1414 u32 h_instream, const struct hpi_format *p_format); 1276 const struct hpi_format *p_format);
1415 1277
1416u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys, 1278u16 hpi_instream_set_format(u32 h_instream,
1417 u32 h_instream, const struct hpi_format *p_format); 1279 const struct hpi_format *p_format);
1418 1280
1419u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream, 1281u16 hpi_instream_read_buf(u32 h_instream, u8 *pb_read_buf, u32 bytes_to_read);
1420 u8 *pb_read_buf, u32 bytes_to_read);
1421 1282
1422u16 hpi_instream_start(const struct hpi_hsubsys *ph_subsys, u32 h_instream); 1283u16 hpi_instream_start(u32 h_instream);
1423 1284
1424u16 hpi_instream_wait_start(const struct hpi_hsubsys *ph_subsys, 1285u16 hpi_instream_wait_start(u32 h_instream);
1425 u32 h_instream);
1426 1286
1427u16 hpi_instream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_instream); 1287u16 hpi_instream_stop(u32 h_instream);
1428 1288
1429u16 hpi_instream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_instream); 1289u16 hpi_instream_reset(u32 h_instream);
1430 1290
1431u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys, 1291u16 hpi_instream_get_info_ex(u32 h_instream, u16 *pw_state, u32 *pbuffer_size,
1432 u32 h_instream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_recorded, 1292 u32 *pdata_recorded, u32 *psamples_recorded,
1433 u32 *psamples_recorded, u32 *pauxiliary_data_recorded); 1293 u32 *pauxiliary_data_recorded);
1434 1294
1435u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, 1295u16 hpi_instream_ancillary_reset(u32 h_instream, u16 bytes_per_frame,
1436 u32 h_instream, u16 bytes_per_frame, u16 mode, u16 alignment, 1296 u16 mode, u16 alignment, u16 idle_bit);
1437 u16 idle_bit);
1438 1297
1439u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, 1298u16 hpi_instream_ancillary_get_info(u32 h_instream, u32 *pframe_space);
1440 u32 h_instream, u32 *pframe_space);
1441 1299
1442u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys, 1300u16 hpi_instream_ancillary_write(u32 h_instream,
1443 u32 h_instream, const struct hpi_anc_frame *p_anc_frame_buffer, 1301 const struct hpi_anc_frame *p_anc_frame_buffer,
1444 u32 anc_frame_buffer_size_in_bytes, 1302 u32 anc_frame_buffer_size_in_bytes,
1445 u32 number_of_ancillary_frames_to_write); 1303 u32 number_of_ancillary_frames_to_write);
1446 1304
1447u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, 1305u16 hpi_instream_host_buffer_allocate(u32 h_instream, u32 size_in_bytes);
1448 u32 h_instream, u32 size_in_bytes);
1449 1306
1450u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, 1307u16 hpi_instream_host_buffer_free(u32 h_instream);
1451 u32 h_instream);
1452 1308
1453u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys, 1309u16 hpi_instream_group_add(u32 h_instream, u32 h_stream);
1454 u32 h_instream, u32 h_stream);
1455 1310
1456u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys, 1311u16 hpi_instream_group_get_map(u32 h_instream, u32 *poutstream_map,
1457 u32 h_instream, u32 *poutstream_map, u32 *pinstream_map); 1312 u32 *pinstream_map);
1458 1313
1459u16 hpi_instream_group_reset(const struct hpi_hsubsys *ph_subsys, 1314u16 hpi_instream_group_reset(u32 h_instream);
1460 u32 h_instream);
1461 1315
1462/*********/ 1316/*********/
1463/* MIXER */ 1317/* Mixer */
1464/*********/ 1318/*********/
1465u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 1319u16 hpi_mixer_open(u16 adapter_index, u32 *ph_mixer);
1466 u32 *ph_mixer); 1320
1467 1321u16 hpi_mixer_close(u32 h_mixer);
1468u16 hpi_mixer_close(const struct hpi_hsubsys *ph_subsys, u32 h_mixer); 1322
1469 1323u16 hpi_mixer_get_control(u32 h_mixer, u16 src_node_type,
1470u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, 1324 u16 src_node_type_index, u16 dst_node_type, u16 dst_node_type_index,
1471 u16 src_node_type, u16 src_node_type_index, u16 dst_node_type, 1325 u16 control_type, u32 *ph_control);
1472 u16 dst_node_type_index, u16 control_type, u32 *ph_control); 1326
1473 1327u16 hpi_mixer_get_control_by_index(u32 h_mixer, u16 control_index,
1474u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys, 1328 u16 *pw_src_node_type, u16 *pw_src_node_index, u16 *pw_dst_node_type,
1475 u32 h_mixer, u16 control_index, u16 *pw_src_node_type, 1329 u16 *pw_dst_node_index, u16 *pw_control_type, u32 *ph_control);
1476 u16 *pw_src_node_index, u16 *pw_dst_node_type, u16 *pw_dst_node_index, 1330
1477 u16 *pw_control_type, u32 *ph_control); 1331u16 hpi_mixer_store(u32 h_mixer, enum HPI_MIXER_STORE_COMMAND command,
1478 1332 u16 index);
1479u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, 1333/************/
1480 enum HPI_MIXER_STORE_COMMAND command, u16 index); 1334/* Controls */
1481/*************************/ 1335/************/
1482/* mixer CONTROLS */ 1336/******************/
1483/*************************/ 1337/* Volume control */
1484/*************************/ 1338/******************/
1485/* volume control */ 1339u16 hpi_volume_set_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
1486/*************************/
1487u16 hpi_volume_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1488 short an_gain0_01dB[HPI_MAX_CHANNELS]
1489 ); 1340 );
1490 1341
1491u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1342u16 hpi_volume_get_gain(u32 h_control,
1492 short an_gain0_01dB_out[HPI_MAX_CHANNELS] 1343 short an_gain0_01dB_out[HPI_MAX_CHANNELS]
1493 ); 1344 );
1494 1345
1346u16 hpi_volume_set_mute(u32 h_control, u32 mute);
1347
1348u16 hpi_volume_get_mute(u32 h_control, u32 *mute);
1349
1495#define hpi_volume_get_range hpi_volume_query_range 1350#define hpi_volume_get_range hpi_volume_query_range
1496u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1351u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB,
1497 short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB); 1352 short *max_gain_01dB, short *step_gain_01dB);
1498 1353
1499u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys, 1354u16 hpi_volume_query_channels(const u32 h_volume, u32 *p_channels);
1500 const u32 h_volume, u32 *p_channels);
1501 1355
1502u16 hpi_volume_auto_fade(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1356u16 hpi_volume_auto_fade(u32 h_control,
1503 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms); 1357 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms);
1504 1358
1505u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys, 1359u16 hpi_volume_auto_fade_profile(u32 h_control,
1506 u32 h_control, short an_stop_gain0_01dB[HPI_MAX_CHANNELS], 1360 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms,
1507 u32 duration_ms, u16 profile); 1361 u16 profile);
1508 1362
1509/*************************/ 1363/*****************/
1510/* level control */ 1364/* Level control */
1511/*************************/ 1365/*****************/
1512u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1366u16 hpi_level_query_range(u32 h_control, short *min_gain_01dB,
1513 short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB); 1367 short *max_gain_01dB, short *step_gain_01dB);
1514 1368
1515u16 hpi_level_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1369u16 hpi_level_set_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
1516 short an_gain0_01dB[HPI_MAX_CHANNELS]
1517 ); 1370 );
1518 1371
1519u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1372u16 hpi_level_get_gain(u32 h_control,
1520 short an_gain0_01dB_out[HPI_MAX_CHANNELS] 1373 short an_gain0_01dB_out[HPI_MAX_CHANNELS]
1521 ); 1374 );
1522 1375
1523/*************************/ 1376/*****************/
1524/* meter control */ 1377/* Meter control */
1525/*************************/ 1378/*****************/
1526u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys, 1379u16 hpi_meter_query_channels(const u32 h_meter, u32 *p_channels);
1527 const u32 h_meter, u32 *p_channels);
1528 1380
1529u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1381u16 hpi_meter_get_peak(u32 h_control,
1530 short an_peak0_01dB_out[HPI_MAX_CHANNELS] 1382 short an_peak0_01dB_out[HPI_MAX_CHANNELS]
1531 ); 1383 );
1532 1384
1533u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1385u16 hpi_meter_get_rms(u32 h_control, short an_peak0_01dB_out[HPI_MAX_CHANNELS]
1534 short an_peak0_01dB_out[HPI_MAX_CHANNELS]
1535 ); 1386 );
1536 1387
1537u16 hpi_meter_set_peak_ballistics(const struct hpi_hsubsys *ph_subsys, 1388u16 hpi_meter_set_peak_ballistics(u32 h_control, u16 attack, u16 decay);
1538 u32 h_control, u16 attack, u16 decay);
1539 1389
1540u16 hpi_meter_set_rms_ballistics(const struct hpi_hsubsys *ph_subsys, 1390u16 hpi_meter_set_rms_ballistics(u32 h_control, u16 attack, u16 decay);
1541 u32 h_control, u16 attack, u16 decay);
1542 1391
1543u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys, 1392u16 hpi_meter_get_peak_ballistics(u32 h_control, u16 *attack, u16 *decay);
1544 u32 h_control, u16 *attack, u16 *decay);
1545 1393
1546u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys, 1394u16 hpi_meter_get_rms_ballistics(u32 h_control, u16 *attack, u16 *decay);
1547 u32 h_control, u16 *attack, u16 *decay);
1548 1395
1549/*************************/ 1396/************************/
1550/* channel mode control */ 1397/* ChannelMode control */
1551/*************************/ 1398/************************/
1552u16 hpi_channel_mode_query_mode(const struct hpi_hsubsys *ph_subsys, 1399u16 hpi_channel_mode_query_mode(const u32 h_mode, const u32 index,
1553 const u32 h_mode, const u32 index, u16 *pw_mode); 1400 u16 *pw_mode);
1554 1401
1555u16 hpi_channel_mode_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1402u16 hpi_channel_mode_set(u32 h_control, u16 mode);
1556 u16 mode);
1557 1403
1558u16 hpi_channel_mode_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1404u16 hpi_channel_mode_get(u32 h_control, u16 *mode);
1559 u16 *mode);
1560 1405
1561/*************************/ 1406/*****************/
1562/* Tuner control */ 1407/* Tuner control */
1563/*************************/ 1408/*****************/
1564u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys, 1409u16 hpi_tuner_query_band(const u32 h_tuner, const u32 index, u16 *pw_band);
1565 const u32 h_tuner, const u32 index, u16 *pw_band);
1566 1410
1567u16 hpi_tuner_set_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1411u16 hpi_tuner_set_band(u32 h_control, u16 band);
1568 u16 band);
1569 1412
1570u16 hpi_tuner_get_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1413u16 hpi_tuner_get_band(u32 h_control, u16 *pw_band);
1571 u16 *pw_band);
1572 1414
1573u16 hpi_tuner_query_frequency(const struct hpi_hsubsys *ph_subsys, 1415u16 hpi_tuner_query_frequency(const u32 h_tuner, const u32 index,
1574 const u32 h_tuner, const u32 index, const u16 band, u32 *pfreq); 1416 const u16 band, u32 *pfreq);
1575 1417
1576u16 hpi_tuner_set_frequency(const struct hpi_hsubsys *ph_subsys, 1418u16 hpi_tuner_set_frequency(u32 h_control, u32 freq_ink_hz);
1577 u32 h_control, u32 freq_ink_hz);
1578 1419
1579u16 hpi_tuner_get_frequency(const struct hpi_hsubsys *ph_subsys, 1420u16 hpi_tuner_get_frequency(u32 h_control, u32 *pw_freq_ink_hz);
1580 u32 h_control, u32 *pw_freq_ink_hz);
1581 1421
1582u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1422u16 hpi_tuner_get_rf_level(u32 h_control, short *pw_level);
1583 short *pw_level);
1584 1423
1585u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys, 1424u16 hpi_tuner_get_raw_rf_level(u32 h_control, short *pw_level);
1586 u32 h_control, short *pw_level);
1587 1425
1588u16 hpi_tuner_query_gain(const struct hpi_hsubsys *ph_subsys, 1426u16 hpi_tuner_query_gain(const u32 h_tuner, const u32 index, u16 *pw_gain);
1589 const u32 h_tuner, const u32 index, u16 *pw_gain);
1590 1427
1591u16 hpi_tuner_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1428u16 hpi_tuner_set_gain(u32 h_control, short gain);
1592 short gain);
1593 1429
1594u16 hpi_tuner_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1430u16 hpi_tuner_get_gain(u32 h_control, short *pn_gain);
1595 short *pn_gain);
1596 1431
1597u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1432u16 hpi_tuner_get_status(u32 h_control, u16 *pw_status_mask, u16 *pw_status);
1598 u16 *pw_status_mask, u16 *pw_status);
1599 1433
1600u16 hpi_tuner_set_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1434u16 hpi_tuner_set_mode(u32 h_control, u32 mode, u32 value);
1601 u32 mode, u32 value);
1602 1435
1603u16 hpi_tuner_get_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1436u16 hpi_tuner_get_mode(u32 h_control, u32 mode, u32 *pn_value);
1604 u32 mode, u32 *pn_value);
1605 1437
1606u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1438u16 hpi_tuner_get_rds(u32 h_control, char *p_rds_data);
1607 char *p_rds_data);
1608 1439
1609u16 hpi_tuner_query_deemphasis(const struct hpi_hsubsys *ph_subsys, 1440u16 hpi_tuner_query_deemphasis(const u32 h_tuner, const u32 index,
1610 const u32 h_tuner, const u32 index, const u16 band, u32 *pdeemphasis); 1441 const u16 band, u32 *pdeemphasis);
1611 1442
1612u16 hpi_tuner_set_deemphasis(const struct hpi_hsubsys *ph_subsys, 1443u16 hpi_tuner_set_deemphasis(u32 h_control, u32 deemphasis);
1613 u32 h_control, u32 deemphasis); 1444u16 hpi_tuner_get_deemphasis(u32 h_control, u32 *pdeemphasis);
1614u16 hpi_tuner_get_deemphasis(const struct hpi_hsubsys *ph_subsys,
1615 u32 h_control, u32 *pdeemphasis);
1616 1445
1617u16 hpi_tuner_query_program(const struct hpi_hsubsys *ph_subsys, 1446u16 hpi_tuner_query_program(const u32 h_tuner, u32 *pbitmap_program);
1618 const u32 h_tuner, u32 *pbitmap_program);
1619 1447
1620u16 hpi_tuner_set_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1448u16 hpi_tuner_set_program(u32 h_control, u32 program);
1621 u32 program);
1622 1449
1623u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1450u16 hpi_tuner_get_program(u32 h_control, u32 *pprogram);
1624 u32 *pprogram);
1625 1451
1626u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys, 1452u16 hpi_tuner_get_hd_radio_dsp_version(u32 h_control, char *psz_dsp_version,
1627 u32 h_control, char *psz_dsp_version, const u32 string_size); 1453 const u32 string_size);
1628 1454
1629u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys, 1455u16 hpi_tuner_get_hd_radio_sdk_version(u32 h_control, char *psz_sdk_version,
1630 u32 h_control, char *psz_sdk_version, const u32 string_size); 1456 const u32 string_size);
1631 1457
1632u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys, 1458u16 hpi_tuner_get_hd_radio_signal_quality(u32 h_control, u32 *pquality);
1633 u32 h_control, u32 *pquality);
1634 1459
1635u16 hpi_tuner_get_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys, 1460u16 hpi_tuner_get_hd_radio_signal_blend(u32 h_control, u32 *pblend);
1636 u32 h_control, u32 *pblend);
1637 1461
1638u16 hpi_tuner_set_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys, 1462u16 hpi_tuner_set_hd_radio_signal_blend(u32 h_control, const u32 blend);
1639 u32 h_control, const u32 blend);
1640 1463
1641/****************************/ 1464/***************/
1642/* PADs control */ 1465/* PAD control */
1643/****************************/ 1466/***************/
1644 1467
1645u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys, 1468u16 hpi_pad_get_channel_name(u32 h_control, char *psz_string,
1646 u32 h_control, char *psz_string, const u32 string_length); 1469 const u32 string_length);
1647 1470
1648u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1471u16 hpi_pad_get_artist(u32 h_control, char *psz_string,
1649 char *psz_string, const u32 string_length); 1472 const u32 string_length);
1650 1473
1651u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1474u16 hpi_pad_get_title(u32 h_control, char *psz_string,
1652 char *psz_string, const u32 string_length); 1475 const u32 string_length);
1653 1476
1654u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1477u16 hpi_pad_get_comment(u32 h_control, char *psz_string,
1655 char *psz_string, const u32 string_length); 1478 const u32 string_length);
1656 1479
1657u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys, 1480u16 hpi_pad_get_program_type(u32 h_control, u32 *ppTY);
1658 u32 h_control, u32 *ppTY);
1659 1481
1660u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1482u16 hpi_pad_get_rdsPI(u32 h_control, u32 *ppI);
1661 u32 *ppI);
1662 1483
1663u16 HPI_PAD__get_program_type_string(const struct hpi_hsubsys *ph_subsys, 1484u16 hpi_pad_get_program_type_string(u32 h_control, const u32 data_type,
1664 u32 h_control, const u32 data_type, const u32 pTY, char *psz_string, 1485 const u32 pTY, char *psz_string, const u32 string_length);
1665 const u32 string_length);
1666 1486
1667/****************************/ 1487/****************************/
1668/* AES/EBU Receiver control */ 1488/* AES/EBU Receiver control */
1669/****************************/ 1489/****************************/
1670u16 HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys *ph_subsys, 1490u16 hpi_aesebu_receiver_query_format(const u32 h_aes_rx, const u32 index,
1671 const u32 h_aes_rx, const u32 index, u16 *pw_format); 1491 u16 *pw_format);
1672 1492
1673u16 HPI_AESEBU__receiver_set_format(const struct hpi_hsubsys *ph_subsys, 1493u16 hpi_aesebu_receiver_set_format(u32 h_control, u16 source);
1674 u32 h_control, u16 source);
1675 1494
1676u16 HPI_AESEBU__receiver_get_format(const struct hpi_hsubsys *ph_subsys, 1495u16 hpi_aesebu_receiver_get_format(u32 h_control, u16 *pw_source);
1677 u32 h_control, u16 *pw_source);
1678 1496
1679u16 HPI_AESEBU__receiver_get_sample_rate(const struct hpi_hsubsys *ph_subsys, 1497u16 hpi_aesebu_receiver_get_sample_rate(u32 h_control, u32 *psample_rate);
1680 u32 h_control, u32 *psample_rate);
1681 1498
1682u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys, 1499u16 hpi_aesebu_receiver_get_user_data(u32 h_control, u16 index, u16 *pw_data);
1683 u32 h_control, u16 index, u16 *pw_data);
1684 1500
1685u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys 1501u16 hpi_aesebu_receiver_get_channel_status(u32 h_control, u16 index,
1686 *ph_subsys, u32 h_control, u16 index, u16 *pw_data); 1502 u16 *pw_data);
1687 1503
1688u16 HPI_AESEBU__receiver_get_error_status(const struct hpi_hsubsys *ph_subsys, 1504u16 hpi_aesebu_receiver_get_error_status(u32 h_control, u16 *pw_error_data);
1689 u32 h_control, u16 *pw_error_data);
1690 1505
1691/*******************************/ 1506/*******************************/
1692/* AES/EBU Transmitter control */ 1507/* AES/EBU Transmitter control */
1693/*******************************/ 1508/*******************************/
1694u16 HPI_AESEBU__transmitter_set_sample_rate(const struct hpi_hsubsys 1509u16 hpi_aesebu_transmitter_set_sample_rate(u32 h_control, u32 sample_rate);
1695 *ph_subsys, u32 h_control, u32 sample_rate);
1696 1510
1697u16 HPI_AESEBU__transmitter_set_user_data(const struct hpi_hsubsys *ph_subsys, 1511u16 hpi_aesebu_transmitter_set_user_data(u32 h_control, u16 index, u16 data);
1698 u32 h_control, u16 index, u16 data);
1699 1512
1700u16 HPI_AESEBU__transmitter_set_channel_status(const struct hpi_hsubsys 1513u16 hpi_aesebu_transmitter_set_channel_status(u32 h_control, u16 index,
1701 *ph_subsys, u32 h_control, u16 index, u16 data); 1514 u16 data);
1702 1515
1703u16 HPI_AESEBU__transmitter_get_channel_status(const struct hpi_hsubsys 1516u16 hpi_aesebu_transmitter_get_channel_status(u32 h_control, u16 index,
1704 *ph_subsys, u32 h_control, u16 index, u16 *pw_data); 1517 u16 *pw_data);
1705 1518
1706u16 HPI_AESEBU__transmitter_query_format(const struct hpi_hsubsys *ph_subsys, 1519u16 hpi_aesebu_transmitter_query_format(const u32 h_aes_tx, const u32 index,
1707 const u32 h_aes_tx, const u32 index, u16 *pw_format); 1520 u16 *pw_format);
1708 1521
1709u16 HPI_AESEBU__transmitter_set_format(const struct hpi_hsubsys *ph_subsys, 1522u16 hpi_aesebu_transmitter_set_format(u32 h_control, u16 output_format);
1710 u32 h_control, u16 output_format);
1711 1523
1712u16 HPI_AESEBU__transmitter_get_format(const struct hpi_hsubsys *ph_subsys, 1524u16 hpi_aesebu_transmitter_get_format(u32 h_control, u16 *pw_output_format);
1713 u32 h_control, u16 *pw_output_format);
1714 1525
1715/***********************/ 1526/***********************/
1716/* multiplexer control */ 1527/* Multiplexer control */
1717/***********************/ 1528/***********************/
1718u16 hpi_multiplexer_set_source(const struct hpi_hsubsys *ph_subsys, 1529u16 hpi_multiplexer_set_source(u32 h_control, u16 source_node_type,
1719 u32 h_control, u16 source_node_type, u16 source_node_index); 1530 u16 source_node_index);
1720
1721u16 hpi_multiplexer_get_source(const struct hpi_hsubsys *ph_subsys,
1722 u32 h_control, u16 *source_node_type, u16 *source_node_index);
1723 1531
1724u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys, 1532u16 hpi_multiplexer_get_source(u32 h_control, u16 *source_node_type,
1725 u32 h_control, u16 index, u16 *source_node_type,
1726 u16 *source_node_index); 1533 u16 *source_node_index);
1727 1534
1535u16 hpi_multiplexer_query_source(u32 h_control, u16 index,
1536 u16 *source_node_type, u16 *source_node_index);
1537
1728/***************/ 1538/***************/
1729/* VOX control */ 1539/* Vox control */
1730/***************/ 1540/***************/
1731u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1541u16 hpi_vox_set_threshold(u32 h_control, short an_gain0_01dB);
1732 short an_gain0_01dB);
1733 1542
1734u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1543u16 hpi_vox_get_threshold(u32 h_control, short *an_gain0_01dB);
1735 short *an_gain0_01dB);
1736 1544
1737/*********************/ 1545/*********************/
1738/* Bitstream control */ 1546/* Bitstream control */
1739/*********************/ 1547/*********************/
1740u16 hpi_bitstream_set_clock_edge(const struct hpi_hsubsys *ph_subsys, 1548u16 hpi_bitstream_set_clock_edge(u32 h_control, u16 edge_type);
1741 u32 h_control, u16 edge_type);
1742 1549
1743u16 hpi_bitstream_set_data_polarity(const struct hpi_hsubsys *ph_subsys, 1550u16 hpi_bitstream_set_data_polarity(u32 h_control, u16 polarity);
1744 u32 h_control, u16 polarity);
1745 1551
1746u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys, 1552u16 hpi_bitstream_get_activity(u32 h_control, u16 *pw_clk_activity,
1747 u32 h_control, u16 *pw_clk_activity, u16 *pw_data_activity); 1553 u16 *pw_data_activity);
1748 1554
1749/***********************/ 1555/***********************/
1750/* SampleClock control */ 1556/* SampleClock control */
1751/***********************/ 1557/***********************/
1752 1558
1753u16 hpi_sample_clock_query_source(const struct hpi_hsubsys *ph_subsys, 1559u16 hpi_sample_clock_query_source(const u32 h_clock, const u32 index,
1754 const u32 h_clock, const u32 index, u16 *pw_source); 1560 u16 *pw_source);
1755 1561
1756u16 hpi_sample_clock_set_source(const struct hpi_hsubsys *ph_subsys, 1562u16 hpi_sample_clock_set_source(u32 h_control, u16 source);
1757 u32 h_control, u16 source);
1758 1563
1759u16 hpi_sample_clock_get_source(const struct hpi_hsubsys *ph_subsys, 1564u16 hpi_sample_clock_get_source(u32 h_control, u16 *pw_source);
1760 u32 h_control, u16 *pw_source);
1761 1565
1762u16 hpi_sample_clock_query_source_index(const struct hpi_hsubsys *ph_subsys, 1566u16 hpi_sample_clock_query_source_index(const u32 h_clock, const u32 index,
1763 const u32 h_clock, const u32 index, const u32 source, 1567 const u32 source, u16 *pw_source_index);
1764 u16 *pw_source_index);
1765 1568
1766u16 hpi_sample_clock_set_source_index(const struct hpi_hsubsys *ph_subsys, 1569u16 hpi_sample_clock_set_source_index(u32 h_control, u16 source_index);
1767 u32 h_control, u16 source_index);
1768 1570
1769u16 hpi_sample_clock_get_source_index(const struct hpi_hsubsys *ph_subsys, 1571u16 hpi_sample_clock_get_source_index(u32 h_control, u16 *pw_source_index);
1770 u32 h_control, u16 *pw_source_index);
1771 1572
1772u16 hpi_sample_clock_get_sample_rate(const struct hpi_hsubsys *ph_subsys, 1573u16 hpi_sample_clock_get_sample_rate(u32 h_control, u32 *psample_rate);
1773 u32 h_control, u32 *psample_rate);
1774 1574
1775u16 hpi_sample_clock_query_local_rate(const struct hpi_hsubsys *ph_subsys, 1575u16 hpi_sample_clock_query_local_rate(const u32 h_clock, const u32 index,
1776 const u32 h_clock, const u32 index, u32 *psource); 1576 u32 *psource);
1777 1577
1778u16 hpi_sample_clock_set_local_rate(const struct hpi_hsubsys *ph_subsys, 1578u16 hpi_sample_clock_set_local_rate(u32 h_control, u32 sample_rate);
1779 u32 h_control, u32 sample_rate);
1780 1579
1781u16 hpi_sample_clock_get_local_rate(const struct hpi_hsubsys *ph_subsys, 1580u16 hpi_sample_clock_get_local_rate(u32 h_control, u32 *psample_rate);
1782 u32 h_control, u32 *psample_rate);
1783 1581
1784u16 hpi_sample_clock_set_auto(const struct hpi_hsubsys *ph_subsys, 1582u16 hpi_sample_clock_set_auto(u32 h_control, u32 enable);
1785 u32 h_control, u32 enable);
1786 1583
1787u16 hpi_sample_clock_get_auto(const struct hpi_hsubsys *ph_subsys, 1584u16 hpi_sample_clock_get_auto(u32 h_control, u32 *penable);
1788 u32 h_control, u32 *penable);
1789 1585
1790u16 hpi_sample_clock_set_local_rate_lock(const struct hpi_hsubsys *ph_subsys, 1586u16 hpi_sample_clock_set_local_rate_lock(u32 h_control, u32 lock);
1791 u32 h_control, u32 lock);
1792 1587
1793u16 hpi_sample_clock_get_local_rate_lock(const struct hpi_hsubsys *ph_subsys, 1588u16 hpi_sample_clock_get_local_rate_lock(u32 h_control, u32 *plock);
1794 u32 h_control, u32 *plock);
1795 1589
1796/***********************/ 1590/***********************/
1797/* Microphone control */ 1591/* Microphone control */
1798/***********************/ 1592/***********************/
1799u16 hpi_microphone_set_phantom_power(const struct hpi_hsubsys *ph_subsys, 1593u16 hpi_microphone_set_phantom_power(u32 h_control, u16 on_off);
1800 u32 h_control, u16 on_off);
1801 1594
1802u16 hpi_microphone_get_phantom_power(const struct hpi_hsubsys *ph_subsys, 1595u16 hpi_microphone_get_phantom_power(u32 h_control, u16 *pw_on_off);
1803 u32 h_control, u16 *pw_on_off);
1804 1596
1805/******************************* 1597/********************************/
1806 Parametric Equalizer control 1598/* Parametric Equalizer control */
1807*******************************/ 1599/********************************/
1808u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys, 1600u16 hpi_parametric_eq_get_info(u32 h_control, u16 *pw_number_of_bands,
1809 u32 h_control, u16 *pw_number_of_bands, u16 *pw_enabled); 1601 u16 *pw_enabled);
1810 1602
1811u16 hpi_parametricEQ__set_state(const struct hpi_hsubsys *ph_subsys, 1603u16 hpi_parametric_eq_set_state(u32 h_control, u16 on_off);
1812 u32 h_control, u16 on_off);
1813 1604
1814u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys, 1605u16 hpi_parametric_eq_set_band(u32 h_control, u16 index, u16 type,
1815 u32 h_control, u16 index, u16 type, u32 frequency_hz, short q100, 1606 u32 frequency_hz, short q100, short gain0_01dB);
1816 short gain0_01dB);
1817 1607
1818u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys, 1608u16 hpi_parametric_eq_get_band(u32 h_control, u16 index, u16 *pn_type,
1819 u32 h_control, u16 index, u16 *pn_type, u32 *pfrequency_hz, 1609 u32 *pfrequency_hz, short *pnQ100, short *pn_gain0_01dB);
1820 short *pnQ100, short *pn_gain0_01dB);
1821 1610
1822u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys, 1611u16 hpi_parametric_eq_get_coeffs(u32 h_control, u16 index, short coeffs[5]
1823 u32 h_control, u16 index, short coeffs[5]
1824 ); 1612 );
1825 1613
1826/******************************* 1614/*******************************/
1827 Compressor Expander control 1615/* Compressor Expander control */
1828*******************************/ 1616/*******************************/
1829
1830u16 hpi_compander_set_enable(const struct hpi_hsubsys *ph_subsys,
1831 u32 h_control, u32 on);
1832
1833u16 hpi_compander_get_enable(const struct hpi_hsubsys *ph_subsys,
1834 u32 h_control, u32 *pon);
1835
1836u16 hpi_compander_set_makeup_gain(const struct hpi_hsubsys *ph_subsys,
1837 u32 h_control, short makeup_gain0_01dB);
1838
1839u16 hpi_compander_get_makeup_gain(const struct hpi_hsubsys *ph_subsys,
1840 u32 h_control, short *pn_makeup_gain0_01dB);
1841
1842u16 hpi_compander_set_attack_time_constant(const struct hpi_hsubsys
1843 *ph_subsys, u32 h_control, u32 index, u32 attack);
1844
1845u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys
1846 *ph_subsys, u32 h_control, u32 index, u32 *pw_attack);
1847
1848u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
1849 u32 h_control, u32 index, u32 decay);
1850
1851u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
1852 u32 h_control, u32 index, u32 *pw_decay);
1853
1854u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys,
1855 u32 h_control, u32 index, short threshold0_01dB);
1856
1857u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys,
1858 u32 h_control, u32 index, short *pn_threshold0_01dB);
1859
1860u16 hpi_compander_set_ratio(const struct hpi_hsubsys *ph_subsys,
1861 u32 h_control, u32 index, u32 ratio100);
1862
1863u16 hpi_compander_get_ratio(const struct hpi_hsubsys *ph_subsys,
1864 u32 h_control, u32 index, u32 *pw_ratio100);
1865
1866/*******************************
1867 Cobranet HMI control
1868*******************************/
1869u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1870 u32 hmi_address, u32 byte_count, u8 *pb_data);
1871
1872u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1873 u32 hmi_address, u32 max_byte_count, u32 *pbyte_count, u8 *pb_data);
1874
1875u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys,
1876 u32 h_control, u32 *pstatus, u32 *preadable_size,
1877 u32 *pwriteable_size);
1878
1879/*Read the current IP address
1880*/
1881u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys,
1882 u32 h_control, u32 *pi_paddress);
1883
1884/* Write the current IP address
1885*/
1886u16 hpi_cobranet_setI_paddress(const struct hpi_hsubsys *ph_subsys,
1887 u32 h_control, u32 i_paddress);
1888
1889/* Read the static IP address
1890*/
1891u16 hpi_cobranet_get_staticI_paddress(const struct hpi_hsubsys *ph_subsys,
1892 u32 h_control, u32 *pi_paddress);
1893 1617
1894/* Write the static IP address 1618u16 hpi_compander_set_enable(u32 h_control, u32 on);
1895*/
1896u16 hpi_cobranet_set_staticI_paddress(const struct hpi_hsubsys *ph_subsys,
1897 u32 h_control, u32 i_paddress);
1898 1619
1899/* Read the MAC address 1620u16 hpi_compander_get_enable(u32 h_control, u32 *pon);
1900*/
1901u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys,
1902 u32 h_control, u32 *pmAC_MS_bs, u32 *pmAC_LS_bs);
1903 1621
1904/******************************* 1622u16 hpi_compander_set_makeup_gain(u32 h_control, short makeup_gain0_01dB);
1905 Tone Detector control
1906*******************************/
1907u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys, u32 hC,
1908 u32 *state);
1909 1623
1910u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys, u32 hC, 1624u16 hpi_compander_get_makeup_gain(u32 h_control, short *pn_makeup_gain0_01dB);
1911 u32 enable);
1912 1625
1913u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys, u32 hC, 1626u16 hpi_compander_set_attack_time_constant(u32 h_control, u32 index,
1914 u32 *enable); 1627 u32 attack);
1915 1628
1916u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, 1629u16 hpi_compander_get_attack_time_constant(u32 h_control, u32 index,
1917 u32 hC, u32 event_enable); 1630 u32 *pw_attack);
1918 1631
1919u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, 1632u16 hpi_compander_set_decay_time_constant(u32 h_control, u32 index,
1920 u32 hC, u32 *event_enable); 1633 u32 decay);
1921 1634
1922u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, 1635u16 hpi_compander_get_decay_time_constant(u32 h_control, u32 index,
1923 u32 hC, int threshold); 1636 u32 *pw_decay);
1924 1637
1925u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, 1638u16 hpi_compander_set_threshold(u32 h_control, u32 index,
1926 u32 hC, int *threshold); 1639 short threshold0_01dB);
1927 1640
1928u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys, 1641u16 hpi_compander_get_threshold(u32 h_control, u32 index,
1929 u32 hC, u32 index, u32 *frequency); 1642 short *pn_threshold0_01dB);
1930 1643
1931/******************************* 1644u16 hpi_compander_set_ratio(u32 h_control, u32 index, u32 ratio100);
1932 Silence Detector control
1933*******************************/
1934u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys,
1935 u32 hC, u32 *state);
1936 1645
1937u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys, 1646u16 hpi_compander_get_ratio(u32 h_control, u32 index, u32 *pw_ratio100);
1938 u32 hC, u32 enable);
1939 1647
1940u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 1648/********************/
1941 u32 hC, u32 *enable); 1649/* Cobranet control */
1650/********************/
1651u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count,
1652 u8 *pb_data);
1942 1653
1943u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, 1654u16 hpi_cobranet_hmi_read(u32 h_control, u32 hmi_address, u32 max_byte_count,
1944 u32 hC, u32 event_enable); 1655 u32 *pbyte_count, u8 *pb_data);
1945 1656
1946u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, 1657u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus,
1947 u32 hC, u32 *event_enable); 1658 u32 *preadable_size, u32 *pwriteable_size);
1948 1659
1949u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys, 1660u16 hpi_cobranet_get_ip_address(u32 h_control, u32 *pdw_ip_address);
1950 u32 hC, u32 delay);
1951 1661
1952u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys, 1662u16 hpi_cobranet_set_ip_address(u32 h_control, u32 dw_ip_address);
1953 u32 hC, u32 *delay);
1954 1663
1955u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, 1664u16 hpi_cobranet_get_static_ip_address(u32 h_control, u32 *pdw_ip_address);
1956 u32 hC, int threshold);
1957 1665
1958u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, 1666u16 hpi_cobranet_set_static_ip_address(u32 h_control, u32 dw_ip_address);
1959 u32 hC, int *threshold);
1960 1667
1961/******************************* 1668u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *p_mac_msbs,
1962 Universal control 1669 u32 *p_mac_lsbs);
1963*******************************/
1964u16 hpi_entity_find_next(struct hpi_entity *container_entity,
1965 enum e_entity_type type, enum e_entity_role role, int recursive_flag,
1966 struct hpi_entity **current_match);
1967 1670
1968u16 hpi_entity_copy_value_from(struct hpi_entity *entity, 1671/*************************/
1969 enum e_entity_type type, size_t item_count, void *value_dst_p); 1672/* Tone Detector control */
1673/*************************/
1674u16 hpi_tone_detector_get_state(u32 hC, u32 *state);
1970 1675
1971u16 hpi_entity_unpack(struct hpi_entity *entity, enum e_entity_type *type, 1676u16 hpi_tone_detector_set_enable(u32 hC, u32 enable);
1972 size_t *items, enum e_entity_role *role, void **value);
1973 1677
1974u16 hpi_entity_alloc_and_pack(const enum e_entity_type type, 1678u16 hpi_tone_detector_get_enable(u32 hC, u32 *enable);
1975 const size_t item_count, const enum e_entity_role role, void *value,
1976 struct hpi_entity **entity);
1977 1679
1978void hpi_entity_free(struct hpi_entity *entity); 1680u16 hpi_tone_detector_set_event_enable(u32 hC, u32 event_enable);
1979 1681
1980u16 hpi_universal_info(const struct hpi_hsubsys *ph_subsys, u32 hC, 1682u16 hpi_tone_detector_get_event_enable(u32 hC, u32 *event_enable);
1981 struct hpi_entity **info);
1982 1683
1983u16 hpi_universal_get(const struct hpi_hsubsys *ph_subsys, u32 hC, 1684u16 hpi_tone_detector_set_threshold(u32 hC, int threshold);
1984 struct hpi_entity **value);
1985 1685
1986u16 hpi_universal_set(const struct hpi_hsubsys *ph_subsys, u32 hC, 1686u16 hpi_tone_detector_get_threshold(u32 hC, int *threshold);
1987 struct hpi_entity *value);
1988 1687
1989/*/////////// */ 1688u16 hpi_tone_detector_get_frequency(u32 hC, u32 index, u32 *frequency);
1990/* DSP CLOCK */
1991/*/////////// */
1992u16 hpi_clock_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1993 u32 *ph_dsp_clock);
1994 1689
1995u16 hpi_clock_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_clock, 1690/****************************/
1996 u16 hour, u16 minute, u16 second, u16 milli_second); 1691/* Silence Detector control */
1692/****************************/
1693u16 hpi_silence_detector_get_state(u32 hC, u32 *state);
1997 1694
1998u16 hpi_clock_get_time(const struct hpi_hsubsys *ph_subsys, u32 h_clock, 1695u16 hpi_silence_detector_set_enable(u32 hC, u32 enable);
1999 u16 *pw_hour, u16 *pw_minute, u16 *pw_second, u16 *pw_milli_second);
2000 1696
2001/*/////////// */ 1697u16 hpi_silence_detector_get_enable(u32 hC, u32 *enable);
2002/* PROFILE */
2003/*/////////// */
2004u16 hpi_profile_open_all(const struct hpi_hsubsys *ph_subsys,
2005 u16 adapter_index, u16 profile_index, u32 *ph_profile,
2006 u16 *pw_max_profiles);
2007 1698
2008u16 hpi_profile_get(const struct hpi_hsubsys *ph_subsys, u32 h_profile, 1699u16 hpi_silence_detector_set_event_enable(u32 hC, u32 event_enable);
2009 u16 index, u16 *pw_seconds, u32 *pmicro_seconds, u32 *pcall_count,
2010 u32 *pmax_micro_seconds, u32 *pmin_micro_seconds);
2011 1700
2012u16 hpi_profile_start_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile); 1701u16 hpi_silence_detector_get_event_enable(u32 hC, u32 *event_enable);
2013 1702
2014u16 hpi_profile_stop_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile); 1703u16 hpi_silence_detector_set_delay(u32 hC, u32 delay);
2015 1704
2016u16 hpi_profile_get_name(const struct hpi_hsubsys *ph_subsys, u32 h_profile, 1705u16 hpi_silence_detector_get_delay(u32 hC, u32 *delay);
2017 u16 index, char *sz_profile_name, u16 profile_name_length);
2018 1706
2019u16 hpi_profile_get_utilization(const struct hpi_hsubsys *ph_subsys, 1707u16 hpi_silence_detector_set_threshold(u32 hC, int threshold);
2020 u32 h_profile, u32 *putilization);
2021 1708
2022/*//////////////////// */ 1709u16 hpi_silence_detector_get_threshold(u32 hC, int *threshold);
2023/* UTILITY functions */ 1710/*********************/
1711/* Utility functions */
1712/*********************/
2024 1713
2025u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, 1714u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
2026 u32 sample_rate, u32 bit_rate, u32 attributes); 1715 u32 sample_rate, u32 bit_rate, u32 attributes);
2027 1716
2028/* Until it's verified, this function is for Windows OSs only */ 1717#endif /*_HPI_H_ */
2029
2030#endif /*_H_HPI_ */
2031/*
2032///////////////////////////////////////////////////////////////////////////////
2033// See CVS for history. Last complete set in rev 1.146
2034////////////////////////////////////////////////////////////////////////////////
2035*/
diff --git a/sound/pci/asihpi/hpi6000.c b/sound/pci/asihpi/hpi6000.c
index f7e374ec4414..df4aed5295dd 100644
--- a/sound/pci/asihpi/hpi6000.c
+++ b/sound/pci/asihpi/hpi6000.c
@@ -43,16 +43,17 @@
43#define HPI_HIF_ERROR_MASK 0x4000 43#define HPI_HIF_ERROR_MASK 0x4000
44 44
45/* HPI6000 specific error codes */ 45/* HPI6000 specific error codes */
46#define HPI6000_ERROR_BASE 900 /* not actually used anywhere */
46 47
47#define HPI6000_ERROR_BASE 900 48/* operational/messaging errors */
48#define HPI6000_ERROR_MSG_RESP_IDLE_TIMEOUT 901 49#define HPI6000_ERROR_MSG_RESP_IDLE_TIMEOUT 901
49#define HPI6000_ERROR_MSG_RESP_SEND_MSG_ACK 902 50
50#define HPI6000_ERROR_MSG_RESP_GET_RESP_ACK 903 51#define HPI6000_ERROR_MSG_RESP_GET_RESP_ACK 903
51#define HPI6000_ERROR_MSG_GET_ADR 904 52#define HPI6000_ERROR_MSG_GET_ADR 904
52#define HPI6000_ERROR_RESP_GET_ADR 905 53#define HPI6000_ERROR_RESP_GET_ADR 905
53#define HPI6000_ERROR_MSG_RESP_BLOCKWRITE32 906 54#define HPI6000_ERROR_MSG_RESP_BLOCKWRITE32 906
54#define HPI6000_ERROR_MSG_RESP_BLOCKREAD32 907 55#define HPI6000_ERROR_MSG_RESP_BLOCKREAD32 907
55#define HPI6000_ERROR_MSG_INVALID_DSP_INDEX 908 56
56#define HPI6000_ERROR_CONTROL_CACHE_PARAMS 909 57#define HPI6000_ERROR_CONTROL_CACHE_PARAMS 909
57 58
58#define HPI6000_ERROR_SEND_DATA_IDLE_TIMEOUT 911 59#define HPI6000_ERROR_SEND_DATA_IDLE_TIMEOUT 911
@@ -62,7 +63,6 @@
62#define HPI6000_ERROR_SEND_DATA_CMD 915 63#define HPI6000_ERROR_SEND_DATA_CMD 915
63#define HPI6000_ERROR_SEND_DATA_WRITE 916 64#define HPI6000_ERROR_SEND_DATA_WRITE 916
64#define HPI6000_ERROR_SEND_DATA_IDLECMD 917 65#define HPI6000_ERROR_SEND_DATA_IDLECMD 917
65#define HPI6000_ERROR_SEND_DATA_VERIFY 918
66 66
67#define HPI6000_ERROR_GET_DATA_IDLE_TIMEOUT 921 67#define HPI6000_ERROR_GET_DATA_IDLE_TIMEOUT 921
68#define HPI6000_ERROR_GET_DATA_ACK 922 68#define HPI6000_ERROR_GET_DATA_ACK 922
@@ -76,9 +76,8 @@
76 76
77#define HPI6000_ERROR_MSG_RESP_GETRESPCMD 961 77#define HPI6000_ERROR_MSG_RESP_GETRESPCMD 961
78#define HPI6000_ERROR_MSG_RESP_IDLECMD 962 78#define HPI6000_ERROR_MSG_RESP_IDLECMD 962
79#define HPI6000_ERROR_MSG_RESP_BLOCKVERIFY32 963
80 79
81/* adapter init errors */ 80/* Initialisation/bootload errors */
82#define HPI6000_ERROR_UNHANDLED_SUBSYS_ID 930 81#define HPI6000_ERROR_UNHANDLED_SUBSYS_ID 930
83 82
84/* can't access PCI2040 */ 83/* can't access PCI2040 */
@@ -201,8 +200,8 @@ static void hpi_read_block(struct dsp_obj *pdo, u32 address, u32 *pdata,
201static void subsys_create_adapter(struct hpi_message *phm, 200static void subsys_create_adapter(struct hpi_message *phm,
202 struct hpi_response *phr); 201 struct hpi_response *phr);
203 202
204static void subsys_delete_adapter(struct hpi_message *phm, 203static void adapter_delete(struct hpi_adapter_obj *pao,
205 struct hpi_response *phr); 204 struct hpi_message *phm, struct hpi_response *phr);
206 205
207static void adapter_get_asserts(struct hpi_adapter_obj *pao, 206static void adapter_get_asserts(struct hpi_adapter_obj *pao,
208 struct hpi_message *phm, struct hpi_response *phr); 207 struct hpi_message *phm, struct hpi_response *phr);
@@ -210,6 +209,8 @@ static void adapter_get_asserts(struct hpi_adapter_obj *pao,
210static short create_adapter_obj(struct hpi_adapter_obj *pao, 209static short create_adapter_obj(struct hpi_adapter_obj *pao,
211 u32 *pos_error_code); 210 u32 *pos_error_code);
212 211
212static void delete_adapter_obj(struct hpi_adapter_obj *pao);
213
213/* local globals */ 214/* local globals */
214 215
215static u16 gw_pci_read_asserts; /* used to count PCI2040 errors */ 216static u16 gw_pci_read_asserts; /* used to count PCI2040 errors */
@@ -217,23 +218,10 @@ static u16 gw_pci_write_asserts; /* used to count PCI2040 errors */
217 218
218static void subsys_message(struct hpi_message *phm, struct hpi_response *phr) 219static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
219{ 220{
220
221 switch (phm->function) { 221 switch (phm->function) {
222 case HPI_SUBSYS_OPEN:
223 case HPI_SUBSYS_CLOSE:
224 case HPI_SUBSYS_GET_INFO:
225 case HPI_SUBSYS_DRIVER_UNLOAD:
226 case HPI_SUBSYS_DRIVER_LOAD:
227 case HPI_SUBSYS_FIND_ADAPTERS:
228 /* messages that should not get here */
229 phr->error = HPI_ERROR_UNIMPLEMENTED;
230 break;
231 case HPI_SUBSYS_CREATE_ADAPTER: 222 case HPI_SUBSYS_CREATE_ADAPTER:
232 subsys_create_adapter(phm, phr); 223 subsys_create_adapter(phm, phr);
233 break; 224 break;
234 case HPI_SUBSYS_DELETE_ADAPTER:
235 subsys_delete_adapter(phm, phr);
236 break;
237 default: 225 default:
238 phr->error = HPI_ERROR_INVALID_FUNC; 226 phr->error = HPI_ERROR_INVALID_FUNC;
239 break; 227 break;
@@ -243,7 +231,6 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
243static void control_message(struct hpi_adapter_obj *pao, 231static void control_message(struct hpi_adapter_obj *pao,
244 struct hpi_message *phm, struct hpi_response *phr) 232 struct hpi_message *phm, struct hpi_response *phr)
245{ 233{
246
247 switch (phm->function) { 234 switch (phm->function) {
248 case HPI_CONTROL_GET_STATE: 235 case HPI_CONTROL_GET_STATE:
249 if (pao->has_control_cache) { 236 if (pao->has_control_cache) {
@@ -251,7 +238,13 @@ static void control_message(struct hpi_adapter_obj *pao,
251 err = hpi6000_update_control_cache(pao, phm); 238 err = hpi6000_update_control_cache(pao, phm);
252 239
253 if (err) { 240 if (err) {
254 phr->error = err; 241 if (err >= HPI_ERROR_BACKEND_BASE) {
242 phr->error =
243 HPI_ERROR_CONTROL_CACHING;
244 phr->specific_error = err;
245 } else {
246 phr->error = err;
247 }
255 break; 248 break;
256 } 249 }
257 250
@@ -262,16 +255,15 @@ static void control_message(struct hpi_adapter_obj *pao,
262 } 255 }
263 hw_message(pao, phm, phr); 256 hw_message(pao, phm, phr);
264 break; 257 break;
265 case HPI_CONTROL_GET_INFO:
266 hw_message(pao, phm, phr);
267 break;
268 case HPI_CONTROL_SET_STATE: 258 case HPI_CONTROL_SET_STATE:
269 hw_message(pao, phm, phr); 259 hw_message(pao, phm, phr);
270 hpi_sync_control_cache(((struct hpi_hw_obj *)pao->priv)-> 260 hpi_cmn_control_cache_sync_to_msg(((struct hpi_hw_obj *)pao->
271 p_cache, phm, phr); 261 priv)->p_cache, phm, phr);
272 break; 262 break;
263
264 case HPI_CONTROL_GET_INFO:
273 default: 265 default:
274 phr->error = HPI_ERROR_INVALID_FUNC; 266 hw_message(pao, phm, phr);
275 break; 267 break;
276 } 268 }
277} 269}
@@ -280,26 +272,16 @@ static void adapter_message(struct hpi_adapter_obj *pao,
280 struct hpi_message *phm, struct hpi_response *phr) 272 struct hpi_message *phm, struct hpi_response *phr)
281{ 273{
282 switch (phm->function) { 274 switch (phm->function) {
283 case HPI_ADAPTER_GET_INFO:
284 hw_message(pao, phm, phr);
285 break;
286 case HPI_ADAPTER_GET_ASSERT: 275 case HPI_ADAPTER_GET_ASSERT:
287 adapter_get_asserts(pao, phm, phr); 276 adapter_get_asserts(pao, phm, phr);
288 break; 277 break;
289 case HPI_ADAPTER_OPEN: 278
290 case HPI_ADAPTER_CLOSE: 279 case HPI_ADAPTER_DELETE:
291 case HPI_ADAPTER_TEST_ASSERT: 280 adapter_delete(pao, phm, phr);
292 case HPI_ADAPTER_SELFTEST:
293 case HPI_ADAPTER_GET_MODE:
294 case HPI_ADAPTER_SET_MODE:
295 case HPI_ADAPTER_FIND_OBJECT:
296 case HPI_ADAPTER_GET_PROPERTY:
297 case HPI_ADAPTER_SET_PROPERTY:
298 case HPI_ADAPTER_ENUM_PROPERTY:
299 hw_message(pao, phm, phr);
300 break; 281 break;
282
301 default: 283 default:
302 phr->error = HPI_ERROR_INVALID_FUNC; 284 hw_message(pao, phm, phr);
303 break; 285 break;
304 } 286 }
305} 287}
@@ -311,7 +293,7 @@ static void outstream_message(struct hpi_adapter_obj *pao,
311 case HPI_OSTREAM_HOSTBUFFER_ALLOC: 293 case HPI_OSTREAM_HOSTBUFFER_ALLOC:
312 case HPI_OSTREAM_HOSTBUFFER_FREE: 294 case HPI_OSTREAM_HOSTBUFFER_FREE:
313 /* Don't let these messages go to the HW function because 295 /* Don't let these messages go to the HW function because
314 * they're called without allocating the spinlock. 296 * they're called without locking the spinlock.
315 * For the HPI6000 adapters the HW would return 297 * For the HPI6000 adapters the HW would return
316 * HPI_ERROR_INVALID_FUNC anyway. 298 * HPI_ERROR_INVALID_FUNC anyway.
317 */ 299 */
@@ -331,7 +313,7 @@ static void instream_message(struct hpi_adapter_obj *pao,
331 case HPI_ISTREAM_HOSTBUFFER_ALLOC: 313 case HPI_ISTREAM_HOSTBUFFER_ALLOC:
332 case HPI_ISTREAM_HOSTBUFFER_FREE: 314 case HPI_ISTREAM_HOSTBUFFER_FREE:
333 /* Don't let these messages go to the HW function because 315 /* Don't let these messages go to the HW function because
334 * they're called without allocating the spinlock. 316 * they're called without locking the spinlock.
335 * For the HPI6000 adapters the HW would return 317 * For the HPI6000 adapters the HW would return
336 * HPI_ERROR_INVALID_FUNC anyway. 318 * HPI_ERROR_INVALID_FUNC anyway.
337 */ 319 */
@@ -352,26 +334,22 @@ void HPI_6000(struct hpi_message *phm, struct hpi_response *phr)
352{ 334{
353 struct hpi_adapter_obj *pao = NULL; 335 struct hpi_adapter_obj *pao = NULL;
354 336
355 /* subsytem messages get executed by every HPI. */
356 /* All other messages are ignored unless the adapter index matches */
357 /* an adapter in the HPI */
358 HPI_DEBUG_LOG(DEBUG, "O %d,F %x\n", phm->object, phm->function);
359
360 /* if Dsp has crashed then do not communicate with it any more */
361 if (phm->object != HPI_OBJ_SUBSYSTEM) { 337 if (phm->object != HPI_OBJ_SUBSYSTEM) {
362 pao = hpi_find_adapter(phm->adapter_index); 338 pao = hpi_find_adapter(phm->adapter_index);
363 if (!pao) { 339 if (!pao) {
364 HPI_DEBUG_LOG(DEBUG, 340 hpi_init_response(phr, phm->object, phm->function,
365 " %d,%d refused, for another HPI?\n", 341 HPI_ERROR_BAD_ADAPTER_NUMBER);
366 phm->object, phm->function); 342 HPI_DEBUG_LOG(DEBUG, "invalid adapter index: %d \n",
343 phm->adapter_index);
367 return; 344 return;
368 } 345 }
369 346
347 /* Don't even try to communicate with crashed DSP */
370 if (pao->dsp_crashed >= 10) { 348 if (pao->dsp_crashed >= 10) {
371 hpi_init_response(phr, phm->object, phm->function, 349 hpi_init_response(phr, phm->object, phm->function,
372 HPI_ERROR_DSP_HARDWARE); 350 HPI_ERROR_DSP_HARDWARE);
373 HPI_DEBUG_LOG(DEBUG, " %d,%d dsp crashed.\n", 351 HPI_DEBUG_LOG(DEBUG, "adapter %d dsp crashed\n",
374 phm->object, phm->function); 352 phm->adapter_index);
375 return; 353 return;
376 } 354 }
377 } 355 }
@@ -433,39 +411,34 @@ static void subsys_create_adapter(struct hpi_message *phm,
433 struct hpi_adapter_obj ao; 411 struct hpi_adapter_obj ao;
434 struct hpi_adapter_obj *pao; 412 struct hpi_adapter_obj *pao;
435 u32 os_error_code; 413 u32 os_error_code;
436 short error = 0; 414 u16 err = 0;
437 u32 dsp_index = 0; 415 u32 dsp_index = 0;
438 416
439 HPI_DEBUG_LOG(VERBOSE, "subsys_create_adapter\n"); 417 HPI_DEBUG_LOG(VERBOSE, "subsys_create_adapter\n");
440 418
441 memset(&ao, 0, sizeof(ao)); 419 memset(&ao, 0, sizeof(ao));
442 420
443 /* this HPI only creates adapters for TI/PCI2040 based devices */
444 if (phm->u.s.resource.bus_type != HPI_BUS_PCI)
445 return;
446 if (phm->u.s.resource.r.pci->vendor_id != HPI_PCI_VENDOR_ID_TI)
447 return;
448 if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_PCI2040)
449 return;
450
451 ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL); 421 ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL);
452 if (!ao.priv) { 422 if (!ao.priv) {
453 HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n"); 423 HPI_DEBUG_LOG(ERROR, "can't get mem for adapter object\n");
454 phr->error = HPI_ERROR_MEMORY_ALLOC; 424 phr->error = HPI_ERROR_MEMORY_ALLOC;
455 return; 425 return;
456 } 426 }
457 427
458 /* create the adapter object based on the resource information */ 428 /* create the adapter object based on the resource information */
459 /*? memcpy(&ao.Pci,&phm->u.s.Resource.r.Pci,sizeof(ao.Pci)); */
460 ao.pci = *phm->u.s.resource.r.pci; 429 ao.pci = *phm->u.s.resource.r.pci;
461 430
462 error = create_adapter_obj(&ao, &os_error_code); 431 err = create_adapter_obj(&ao, &os_error_code);
463 if (!error) 432 if (err) {
464 error = hpi_add_adapter(&ao); 433 delete_adapter_obj(&ao);
465 if (error) { 434 if (err >= HPI_ERROR_BACKEND_BASE) {
435 phr->error = HPI_ERROR_DSP_BOOTLOAD;
436 phr->specific_error = err;
437 } else {
438 phr->error = err;
439 }
440
466 phr->u.s.data = os_error_code; 441 phr->u.s.data = os_error_code;
467 kfree(ao.priv);
468 phr->error = error;
469 return; 442 return;
470 } 443 }
471 /* need to update paParentAdapter */ 444 /* need to update paParentAdapter */
@@ -473,7 +446,7 @@ static void subsys_create_adapter(struct hpi_message *phm,
473 if (!pao) { 446 if (!pao) {
474 /* We just added this adapter, why can't we find it!? */ 447 /* We just added this adapter, why can't we find it!? */
475 HPI_DEBUG_LOG(ERROR, "lost adapter after boot\n"); 448 HPI_DEBUG_LOG(ERROR, "lost adapter after boot\n");
476 phr->error = 950; 449 phr->error = HPI_ERROR_BAD_ADAPTER;
477 return; 450 return;
478 } 451 }
479 452
@@ -482,30 +455,16 @@ static void subsys_create_adapter(struct hpi_message *phm,
482 phw->ado[dsp_index].pa_parent_adapter = pao; 455 phw->ado[dsp_index].pa_parent_adapter = pao;
483 } 456 }
484 457
485 phr->u.s.aw_adapter_list[ao.index] = ao.adapter_type; 458 phr->u.s.adapter_type = ao.adapter_type;
486 phr->u.s.adapter_index = ao.index; 459 phr->u.s.adapter_index = ao.index;
487 phr->u.s.num_adapters++;
488 phr->error = 0; 460 phr->error = 0;
489} 461}
490 462
491static void subsys_delete_adapter(struct hpi_message *phm, 463static void adapter_delete(struct hpi_adapter_obj *pao,
492 struct hpi_response *phr) 464 struct hpi_message *phm, struct hpi_response *phr)
493{ 465{
494 struct hpi_adapter_obj *pao = NULL; 466 delete_adapter_obj(pao);
495 struct hpi_hw_obj *phw;
496
497 pao = hpi_find_adapter(phm->adapter_index);
498 if (!pao)
499 return;
500
501 phw = (struct hpi_hw_obj *)pao->priv;
502
503 if (pao->has_control_cache)
504 hpi_free_control_cache(phw->p_cache);
505
506 hpi_delete_adapter(pao); 467 hpi_delete_adapter(pao);
507 kfree(phw);
508
509 phr->error = 0; 468 phr->error = 0;
510} 469}
511 470
@@ -519,9 +478,6 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
519 u32 control_cache_count = 0; 478 u32 control_cache_count = 0;
520 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 479 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv;
521 480
522 /* init error reporting */
523 pao->dsp_crashed = 0;
524
525 /* The PCI2040 has the following address map */ 481 /* The PCI2040 has the following address map */
526 /* BAR0 - 4K = HPI control and status registers on PCI2040 (HPI CSR) */ 482 /* BAR0 - 4K = HPI control and status registers on PCI2040 (HPI CSR) */
527 /* BAR1 - 32K = HPI registers on DSP */ 483 /* BAR1 - 32K = HPI registers on DSP */
@@ -575,36 +531,36 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
575 /* get info about the adapter by asking the adapter */ 531 /* get info about the adapter by asking the adapter */
576 /* send a HPI_ADAPTER_GET_INFO message */ 532 /* send a HPI_ADAPTER_GET_INFO message */
577 { 533 {
578 struct hpi_message hM; 534 struct hpi_message hm;
579 struct hpi_response hR0; /* response from DSP 0 */ 535 struct hpi_response hr0; /* response from DSP 0 */
580 struct hpi_response hR1; /* response from DSP 1 */ 536 struct hpi_response hr1; /* response from DSP 1 */
581 u16 error = 0; 537 u16 error = 0;
582 538
583 HPI_DEBUG_LOG(VERBOSE, "send ADAPTER_GET_INFO\n"); 539 HPI_DEBUG_LOG(VERBOSE, "send ADAPTER_GET_INFO\n");
584 memset(&hM, 0, sizeof(hM)); 540 memset(&hm, 0, sizeof(hm));
585 hM.type = HPI_TYPE_MESSAGE; 541 hm.type = HPI_TYPE_MESSAGE;
586 hM.size = sizeof(struct hpi_message); 542 hm.size = sizeof(struct hpi_message);
587 hM.object = HPI_OBJ_ADAPTER; 543 hm.object = HPI_OBJ_ADAPTER;
588 hM.function = HPI_ADAPTER_GET_INFO; 544 hm.function = HPI_ADAPTER_GET_INFO;
589 hM.adapter_index = 0; 545 hm.adapter_index = 0;
590 memset(&hR0, 0, sizeof(hR0)); 546 memset(&hr0, 0, sizeof(hr0));
591 memset(&hR1, 0, sizeof(hR1)); 547 memset(&hr1, 0, sizeof(hr1));
592 hR0.size = sizeof(hR0); 548 hr0.size = sizeof(hr0);
593 hR1.size = sizeof(hR1); 549 hr1.size = sizeof(hr1);
594 550
595 error = hpi6000_message_response_sequence(pao, 0, &hM, &hR0); 551 error = hpi6000_message_response_sequence(pao, 0, &hm, &hr0);
596 if (hR0.error) { 552 if (hr0.error) {
597 HPI_DEBUG_LOG(DEBUG, "message error %d\n", hR0.error); 553 HPI_DEBUG_LOG(DEBUG, "message error %d\n", hr0.error);
598 return hR0.error; 554 return hr0.error;
599 } 555 }
600 if (phw->num_dsp == 2) { 556 if (phw->num_dsp == 2) {
601 error = hpi6000_message_response_sequence(pao, 1, &hM, 557 error = hpi6000_message_response_sequence(pao, 1, &hm,
602 &hR1); 558 &hr1);
603 if (error) 559 if (error)
604 return error; 560 return error;
605 } 561 }
606 pao->adapter_type = hR0.u.a.adapter_type; 562 pao->adapter_type = hr0.u.ax.info.adapter_type;
607 pao->index = hR0.u.a.adapter_index; 563 pao->index = hr0.u.ax.info.adapter_index;
608 } 564 }
609 565
610 memset(&phw->control_cache[0], 0, 566 memset(&phw->control_cache[0], 0,
@@ -618,20 +574,37 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
618 control_cache_count = 574 control_cache_count =
619 hpi_read_word(&phw->ado[0], 575 hpi_read_word(&phw->ado[0],
620 HPI_HIF_ADDR(control_cache_count)); 576 HPI_HIF_ADDR(control_cache_count));
621 pao->has_control_cache = 1;
622 577
623 phw->p_cache = 578 phw->p_cache =
624 hpi_alloc_control_cache(control_cache_count, 579 hpi_alloc_control_cache(control_cache_count,
625 control_cache_size, (struct hpi_control_cache_info *) 580 control_cache_size, (unsigned char *)
626 &phw->control_cache[0] 581 &phw->control_cache[0]
627 ); 582 );
628 } else 583 if (phw->p_cache)
629 pao->has_control_cache = 0; 584 pao->has_control_cache = 1;
585 }
630 586
631 HPI_DEBUG_LOG(DEBUG, "get adapter info ASI%04X index %d\n", 587 HPI_DEBUG_LOG(DEBUG, "get adapter info ASI%04X index %d\n",
632 pao->adapter_type, pao->index); 588 pao->adapter_type, pao->index);
633 pao->open = 0; /* upon creation the adapter is closed */ 589 pao->open = 0; /* upon creation the adapter is closed */
634 return 0; 590
591 if (phw->p_cache)
592 phw->p_cache->adap_idx = pao->index;
593
594 return hpi_add_adapter(pao);
595}
596
597static void delete_adapter_obj(struct hpi_adapter_obj *pao)
598{
599 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv;
600
601 if (pao->has_control_cache)
602 hpi_free_control_cache(phw->p_cache);
603
604 /* reset DSPs on adapter */
605 iowrite32(0x0003000F, phw->dw2040_HPICSR + HPI_RESET);
606
607 kfree(phw);
635} 608}
636 609
637/************************************************************************/ 610/************************************************************************/
@@ -643,11 +616,13 @@ static void adapter_get_asserts(struct hpi_adapter_obj *pao,
643#ifndef HIDE_PCI_ASSERTS 616#ifndef HIDE_PCI_ASSERTS
644 /* if we have PCI2040 asserts then collect them */ 617 /* if we have PCI2040 asserts then collect them */
645 if ((gw_pci_read_asserts > 0) || (gw_pci_write_asserts > 0)) { 618 if ((gw_pci_read_asserts > 0) || (gw_pci_write_asserts > 0)) {
646 phr->u.a.serial_number = 619 phr->u.ax.assert.p1 =
647 gw_pci_read_asserts * 100 + gw_pci_write_asserts; 620 gw_pci_read_asserts * 100 + gw_pci_write_asserts;
648 phr->u.a.adapter_index = 1; /* assert count */ 621 phr->u.ax.assert.p2 = 0;
649 phr->u.a.adapter_type = -1; /* "dsp index" */ 622 phr->u.ax.assert.count = 1; /* assert count */
650 strcpy(phr->u.a.sz_adapter_assert, "PCI2040 error"); 623 phr->u.ax.assert.dsp_index = -1; /* "dsp index" */
624 strcpy(phr->u.ax.assert.sz_message, "PCI2040 error");
625 phr->u.ax.assert.dsp_msg_addr = 0;
651 gw_pci_read_asserts = 0; 626 gw_pci_read_asserts = 0;
652 gw_pci_write_asserts = 0; 627 gw_pci_write_asserts = 0;
653 phr->error = 0; 628 phr->error = 0;
@@ -684,10 +659,10 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
684 659
685 /* NOTE don't use wAdapterType in this routine. It is not setup yet */ 660 /* NOTE don't use wAdapterType in this routine. It is not setup yet */
686 661
687 switch (pao->pci.subsys_device_id) { 662 switch (pao->pci.pci_dev->subsystem_device) {
688 case 0x5100: 663 case 0x5100:
689 case 0x5110: /* ASI5100 revB or higher with C6711D */ 664 case 0x5110: /* ASI5100 revB or higher with C6711D */
690 case 0x5200: /* ASI5200 PC_ie version of ASI5100 */ 665 case 0x5200: /* ASI5200 PCIe version of ASI5100 */
691 case 0x6100: 666 case 0x6100:
692 case 0x6200: 667 case 0x6200:
693 boot_load_family = HPI_ADAPTER_FAMILY_ASI(0x6200); 668 boot_load_family = HPI_ADAPTER_FAMILY_ASI(0x6200);
@@ -707,8 +682,9 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
707 * note that bits 4..15 are read-only and so should always return zero, 682 * note that bits 4..15 are read-only and so should always return zero,
708 * even though we wrote 1 to them 683 * even though we wrote 1 to them
709 */ 684 */
710 for (i = 0; i < 1000; i++) 685 hpios_delay_micro_seconds(1000);
711 delay = ioread32(phw->dw2040_HPICSR + HPI_RESET); 686 delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
687
712 if (delay != dw2040_reset) { 688 if (delay != dw2040_reset) {
713 HPI_DEBUG_LOG(ERROR, "INIT_PCI2040 %x %x\n", dw2040_reset, 689 HPI_DEBUG_LOG(ERROR, "INIT_PCI2040 %x %x\n", dw2040_reset,
714 delay); 690 delay);
@@ -741,8 +717,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
741 dw2040_reset = dw2040_reset & (~0x00000008); 717 dw2040_reset = dw2040_reset & (~0x00000008);
742 iowrite32(dw2040_reset, phw->dw2040_HPICSR + HPI_RESET); 718 iowrite32(dw2040_reset, phw->dw2040_HPICSR + HPI_RESET);
743 /*delay to allow DSP to get going */ 719 /*delay to allow DSP to get going */
744 for (i = 0; i < 100; i++) 720 hpios_delay_micro_seconds(100);
745 delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
746 721
747 /* loop through all DSPs, downloading DSP code */ 722 /* loop through all DSPs, downloading DSP code */
748 for (dsp_index = 0; dsp_index < phw->num_dsp; dsp_index++) { 723 for (dsp_index = 0; dsp_index < phw->num_dsp; dsp_index++) {
@@ -781,27 +756,27 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
781 */ 756 */
782 /* bypass PLL */ 757 /* bypass PLL */
783 hpi_write_word(pdo, 0x01B7C100, 0x0000); 758 hpi_write_word(pdo, 0x01B7C100, 0x0000);
784 for (i = 0; i < 100; i++) 759 hpios_delay_micro_seconds(100);
785 delay = ioread32(phw->dw2040_HPICSR +
786 HPI_RESET);
787 760
788 /* ** use default of PLL x7 ** */ 761 /* ** use default of PLL x7 ** */
789 /* EMIF = 225/3=75MHz */ 762 /* EMIF = 225/3=75MHz */
790 hpi_write_word(pdo, 0x01B7C120, 0x8002); 763 hpi_write_word(pdo, 0x01B7C120, 0x8002);
764 hpios_delay_micro_seconds(100);
765
791 /* peri = 225/2 */ 766 /* peri = 225/2 */
792 hpi_write_word(pdo, 0x01B7C11C, 0x8001); 767 hpi_write_word(pdo, 0x01B7C11C, 0x8001);
768 hpios_delay_micro_seconds(100);
769
793 /* cpu = 225/1 */ 770 /* cpu = 225/1 */
794 hpi_write_word(pdo, 0x01B7C118, 0x8000); 771 hpi_write_word(pdo, 0x01B7C118, 0x8000);
795 /* ~200us delay */ 772
796 for (i = 0; i < 2000; i++) 773 /* ~2ms delay */
797 delay = ioread32(phw->dw2040_HPICSR + 774 hpios_delay_micro_seconds(2000);
798 HPI_RESET); 775
799 /* PLL not bypassed */ 776 /* PLL not bypassed */
800 hpi_write_word(pdo, 0x01B7C100, 0x0001); 777 hpi_write_word(pdo, 0x01B7C100, 0x0001);
801 /* ~200us delay */ 778 /* ~2ms delay */
802 for (i = 0; i < 2000; i++) 779 hpios_delay_micro_seconds(2000);
803 delay = ioread32(phw->dw2040_HPICSR +
804 HPI_RESET);
805 } 780 }
806 781
807 /* test r/w to internal DSP memory 782 /* test r/w to internal DSP memory
@@ -925,9 +900,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
925 } 900 }
926 901
927 /* delay a little to allow SDRAM and DSP to "get going" */ 902 /* delay a little to allow SDRAM and DSP to "get going" */
928 903 hpios_delay_micro_seconds(1000);
929 for (i = 0; i < 1000; i++)
930 delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
931 904
932 /* test access to SDRAM */ 905 /* test access to SDRAM */
933 { 906 {
@@ -974,7 +947,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
974 947
975 /* write the DSP code down into the DSPs memory */ 948 /* write the DSP code down into the DSPs memory */
976 /*HpiDspCode_Open(nBootLoadFamily,&DspCode,pdwOsErrorCode); */ 949 /*HpiDspCode_Open(nBootLoadFamily,&DspCode,pdwOsErrorCode); */
977 dsp_code.ps_dev = pao->pci.p_os_data; 950 dsp_code.ps_dev = pao->pci.pci_dev;
978 951
979 error = hpi_dsp_code_open(boot_load_family, &dsp_code, 952 error = hpi_dsp_code_open(boot_load_family, &dsp_code,
980 pos_error_code); 953 pos_error_code);
@@ -1071,8 +1044,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1071 1044
1072 /* step 3. Start code by sending interrupt */ 1045 /* step 3. Start code by sending interrupt */
1073 iowrite32(0x00030003, pdo->prHPI_control); 1046 iowrite32(0x00030003, pdo->prHPI_control);
1074 for (i = 0; i < 10000; i++) 1047 hpios_delay_micro_seconds(10000);
1075 delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
1076 1048
1077 /* wait for a non-zero value in hostcmd - 1049 /* wait for a non-zero value in hostcmd -
1078 * indicating initialization is complete 1050 * indicating initialization is complete
@@ -1099,7 +1071,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1099 * locks up with a bluescreen (NOT GPF or pagefault). 1071 * locks up with a bluescreen (NOT GPF or pagefault).
1100 */ 1072 */
1101 else 1073 else
1102 hpios_delay_micro_seconds(1000); 1074 hpios_delay_micro_seconds(10000);
1103 } 1075 }
1104 if (timeout == 0) 1076 if (timeout == 0)
1105 return HPI6000_ERROR_INIT_NOACK; 1077 return HPI6000_ERROR_INIT_NOACK;
@@ -1130,14 +1102,14 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1130 mask = 0xFFFFFF00L; 1102 mask = 0xFFFFFF00L;
1131 /* ASI5100 uses AX6 code, */ 1103 /* ASI5100 uses AX6 code, */
1132 /* but has no PLD r/w register to test */ 1104 /* but has no PLD r/w register to test */
1133 if (HPI_ADAPTER_FAMILY_ASI(pao->pci. 1105 if (HPI_ADAPTER_FAMILY_ASI(pao->pci.pci_dev->
1134 subsys_device_id) == 1106 subsystem_device) ==
1135 HPI_ADAPTER_FAMILY_ASI(0x5100)) 1107 HPI_ADAPTER_FAMILY_ASI(0x5100))
1136 mask = 0x00000000L; 1108 mask = 0x00000000L;
1137 /* ASI5200 uses AX6 code, */ 1109 /* ASI5200 uses AX6 code, */
1138 /* but has no PLD r/w register to test */ 1110 /* but has no PLD r/w register to test */
1139 if (HPI_ADAPTER_FAMILY_ASI(pao->pci. 1111 if (HPI_ADAPTER_FAMILY_ASI(pao->pci.pci_dev->
1140 subsys_device_id) == 1112 subsystem_device) ==
1141 HPI_ADAPTER_FAMILY_ASI(0x5200)) 1113 HPI_ADAPTER_FAMILY_ASI(0x5200))
1142 mask = 0x00000000L; 1114 mask = 0x00000000L;
1143 break; 1115 break;
@@ -1202,7 +1174,7 @@ static u32 hpi_read_word(struct dsp_obj *pdo, u32 address)
1202 u32 data = 0; 1174 u32 data = 0;
1203 1175
1204 if (hpi_set_address(pdo, address)) 1176 if (hpi_set_address(pdo, address))
1205 return 0; /*? no way to return error */ 1177 return 0; /*? No way to return error */
1206 1178
1207 /* take care of errata in revB DSP (2.0.1) */ 1179 /* take care of errata in revB DSP (2.0.1) */
1208 data = ioread32(pdo->prHPI_data); 1180 data = ioread32(pdo->prHPI_data);
@@ -1338,10 +1310,6 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1338 u32 *p_data; 1310 u32 *p_data;
1339 u16 error = 0; 1311 u16 error = 0;
1340 1312
1341 /* does the DSP we are referencing exist? */
1342 if (dsp_index >= phw->num_dsp)
1343 return HPI6000_ERROR_MSG_INVALID_DSP_INDEX;
1344
1345 ack = hpi6000_wait_dsp_ack(pao, dsp_index, HPI_HIF_IDLE); 1313 ack = hpi6000_wait_dsp_ack(pao, dsp_index, HPI_HIF_IDLE);
1346 if (ack & HPI_HIF_ERROR_MASK) { 1314 if (ack & HPI_HIF_ERROR_MASK) {
1347 pao->dsp_crashed++; 1315 pao->dsp_crashed++;
@@ -1349,9 +1317,7 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1349 } 1317 }
1350 pao->dsp_crashed = 0; 1318 pao->dsp_crashed = 0;
1351 1319
1352 /* send the message */ 1320 /* get the message address and size */
1353
1354 /* get the address and size */
1355 if (phw->message_buffer_address_on_dsp == 0) { 1321 if (phw->message_buffer_address_on_dsp == 0) {
1356 timeout = TIMEOUT; 1322 timeout = TIMEOUT;
1357 do { 1323 do {
@@ -1366,10 +1332,9 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1366 } else 1332 } else
1367 address = phw->message_buffer_address_on_dsp; 1333 address = phw->message_buffer_address_on_dsp;
1368 1334
1369 /* dwLength = sizeof(struct hpi_message); */
1370 length = phm->size; 1335 length = phm->size;
1371 1336
1372 /* send it */ 1337 /* send the message */
1373 p_data = (u32 *)phm; 1338 p_data = (u32 *)phm;
1374 if (hpi6000_dsp_block_write32(pao, dsp_index, address, p_data, 1339 if (hpi6000_dsp_block_write32(pao, dsp_index, address, p_data,
1375 (u16)length / 4)) 1340 (u16)length / 4))
@@ -1383,7 +1348,7 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1383 if (ack & HPI_HIF_ERROR_MASK) 1348 if (ack & HPI_HIF_ERROR_MASK)
1384 return HPI6000_ERROR_MSG_RESP_GET_RESP_ACK; 1349 return HPI6000_ERROR_MSG_RESP_GET_RESP_ACK;
1385 1350
1386 /* get the address and size */ 1351 /* get the response address */
1387 if (phw->response_buffer_address_on_dsp == 0) { 1352 if (phw->response_buffer_address_on_dsp == 0) {
1388 timeout = TIMEOUT; 1353 timeout = TIMEOUT;
1389 do { 1354 do {
@@ -1407,7 +1372,7 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1407 if (!timeout) 1372 if (!timeout)
1408 length = sizeof(struct hpi_response); 1373 length = sizeof(struct hpi_response);
1409 1374
1410 /* get it */ 1375 /* get the response */
1411 p_data = (u32 *)phr; 1376 p_data = (u32 *)phr;
1412 if (hpi6000_dsp_block_read32(pao, dsp_index, address, p_data, 1377 if (hpi6000_dsp_block_read32(pao, dsp_index, address, p_data,
1413 (u16)length / 4)) 1378 (u16)length / 4))
@@ -1803,17 +1768,11 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm,
1803 hpios_dsplock_lock(pao); 1768 hpios_dsplock_lock(pao);
1804 error = hpi6000_message_response_sequence(pao, dsp_index, phm, phr); 1769 error = hpi6000_message_response_sequence(pao, dsp_index, phm, phr);
1805 1770
1806 /* maybe an error response */ 1771 if (error) /* something failed in the HPI/DSP interface */
1807 if (error) {
1808 /* something failed in the HPI/DSP interface */
1809 phr->error = error;
1810 /* just the header of the response is valid */
1811 phr->size = sizeof(struct hpi_response_header);
1812 goto err; 1772 goto err;
1813 }
1814 1773
1815 if (phr->error != 0) /* something failed in the DSP */ 1774 if (phr->error) /* something failed in the DSP */
1816 goto err; 1775 goto out;
1817 1776
1818 switch (phm->function) { 1777 switch (phm->function) {
1819 case HPI_OSTREAM_WRITE: 1778 case HPI_OSTREAM_WRITE:
@@ -1825,21 +1784,30 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm,
1825 error = hpi6000_get_data(pao, dsp_index, phm, phr); 1784 error = hpi6000_get_data(pao, dsp_index, phm, phr);
1826 break; 1785 break;
1827 case HPI_ADAPTER_GET_ASSERT: 1786 case HPI_ADAPTER_GET_ASSERT:
1828 phr->u.a.adapter_index = 0; /* dsp 0 default */ 1787 phr->u.ax.assert.dsp_index = 0; /* dsp 0 default */
1829 if (num_dsp == 2) { 1788 if (num_dsp == 2) {
1830 if (!phr->u.a.adapter_type) { 1789 if (!phr->u.ax.assert.count) {
1831 /* no assert from dsp 0, check dsp 1 */ 1790 /* no assert from dsp 0, check dsp 1 */
1832 error = hpi6000_message_response_sequence(pao, 1791 error = hpi6000_message_response_sequence(pao,
1833 1, phm, phr); 1792 1, phm, phr);
1834 phr->u.a.adapter_index = 1; 1793 phr->u.ax.assert.dsp_index = 1;
1835 } 1794 }
1836 } 1795 }
1837 } 1796 }
1838 1797
1839 if (error)
1840 phr->error = error;
1841
1842err: 1798err:
1799 if (error) {
1800 if (error >= HPI_ERROR_BACKEND_BASE) {
1801 phr->error = HPI_ERROR_DSP_COMMUNICATION;
1802 phr->specific_error = error;
1803 } else {
1804 phr->error = error;
1805 }
1806
1807 /* just the header of the response is valid */
1808 phr->size = sizeof(struct hpi_response_header);
1809 }
1810out:
1843 hpios_dsplock_unlock(pao); 1811 hpios_dsplock_unlock(pao);
1844 return; 1812 return;
1845} 1813}
diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c
index 22c5fc625533..9d5df54a6b46 100644
--- a/sound/pci/asihpi/hpi6205.c
+++ b/sound/pci/asihpi/hpi6205.c
@@ -38,27 +38,26 @@
38 38
39/*****************************************************************************/ 39/*****************************************************************************/
40/* HPI6205 specific error codes */ 40/* HPI6205 specific error codes */
41#define HPI6205_ERROR_BASE 1000 41#define HPI6205_ERROR_BASE 1000 /* not actually used anywhere */
42/*#define HPI6205_ERROR_MEM_ALLOC 1001 */ 42
43/* operational/messaging errors */
44#define HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT 1015
45#define HPI6205_ERROR_MSG_RESP_TIMEOUT 1016
46
47/* initialization/bootload errors */
43#define HPI6205_ERROR_6205_NO_IRQ 1002 48#define HPI6205_ERROR_6205_NO_IRQ 1002
44#define HPI6205_ERROR_6205_INIT_FAILED 1003 49#define HPI6205_ERROR_6205_INIT_FAILED 1003
45/*#define HPI6205_ERROR_MISSING_DSPCODE 1004 */
46#define HPI6205_ERROR_UNKNOWN_PCI_DEVICE 1005
47#define HPI6205_ERROR_6205_REG 1006 50#define HPI6205_ERROR_6205_REG 1006
48#define HPI6205_ERROR_6205_DSPPAGE 1007 51#define HPI6205_ERROR_6205_DSPPAGE 1007
49#define HPI6205_ERROR_BAD_DSPINDEX 1008
50#define HPI6205_ERROR_C6713_HPIC 1009 52#define HPI6205_ERROR_C6713_HPIC 1009
51#define HPI6205_ERROR_C6713_HPIA 1010 53#define HPI6205_ERROR_C6713_HPIA 1010
52#define HPI6205_ERROR_C6713_PLL 1011 54#define HPI6205_ERROR_C6713_PLL 1011
53#define HPI6205_ERROR_DSP_INTMEM 1012 55#define HPI6205_ERROR_DSP_INTMEM 1012
54#define HPI6205_ERROR_DSP_EXTMEM 1013 56#define HPI6205_ERROR_DSP_EXTMEM 1013
55#define HPI6205_ERROR_DSP_PLD 1014 57#define HPI6205_ERROR_DSP_PLD 1014
56#define HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT 1015
57#define HPI6205_ERROR_MSG_RESP_TIMEOUT 1016
58#define HPI6205_ERROR_6205_EEPROM 1017 58#define HPI6205_ERROR_6205_EEPROM 1017
59#define HPI6205_ERROR_DSP_EMIF 1018 59#define HPI6205_ERROR_DSP_EMIF 1018
60 60
61#define hpi6205_error(dsp_index, err) (err)
62/*****************************************************************************/ 61/*****************************************************************************/
63/* for C6205 PCI i/f */ 62/* for C6205 PCI i/f */
64/* Host Status Register (HSR) bitfields */ 63/* Host Status Register (HSR) bitfields */
@@ -128,9 +127,6 @@ struct hpi_hw_obj {
128 u32 outstream_host_buffer_size[HPI_MAX_STREAMS]; 127 u32 outstream_host_buffer_size[HPI_MAX_STREAMS];
129 128
130 struct consistent_dma_area h_control_cache; 129 struct consistent_dma_area h_control_cache;
131 struct consistent_dma_area h_async_event_buffer;
132/* struct hpi_control_cache_single *pControlCache; */
133 struct hpi_async_event *p_async_event_buffer;
134 struct hpi_control_cache *p_cache; 130 struct hpi_control_cache *p_cache;
135}; 131};
136 132
@@ -156,8 +152,8 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm,
156 152
157static void subsys_create_adapter(struct hpi_message *phm, 153static void subsys_create_adapter(struct hpi_message *phm,
158 struct hpi_response *phr); 154 struct hpi_response *phr);
159static void subsys_delete_adapter(struct hpi_message *phm, 155static void adapter_delete(struct hpi_adapter_obj *pao,
160 struct hpi_response *phr); 156 struct hpi_message *phm, struct hpi_response *phr);
161 157
162static u16 create_adapter_obj(struct hpi_adapter_obj *pao, 158static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
163 u32 *pos_error_code); 159 u32 *pos_error_code);
@@ -208,8 +204,8 @@ static void instream_start(struct hpi_adapter_obj *pao,
208static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index, 204static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index,
209 u32 address); 205 u32 address);
210 206
211static u16 boot_loader_write_mem32(struct hpi_adapter_obj *pao, int dsp_index, 207static void boot_loader_write_mem32(struct hpi_adapter_obj *pao,
212 u32 address, u32 data); 208 int dsp_index, u32 address, u32 data);
213 209
214static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, 210static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao,
215 int dsp_index); 211 int dsp_index);
@@ -227,25 +223,13 @@ static u16 boot_loader_test_pld(struct hpi_adapter_obj *pao, int dsp_index);
227 223
228/*****************************************************************************/ 224/*****************************************************************************/
229 225
230static void subsys_message(struct hpi_message *phm, struct hpi_response *phr) 226static void subsys_message(struct hpi_adapter_obj *pao,
227 struct hpi_message *phm, struct hpi_response *phr)
231{ 228{
232
233 switch (phm->function) { 229 switch (phm->function) {
234 case HPI_SUBSYS_OPEN:
235 case HPI_SUBSYS_CLOSE:
236 case HPI_SUBSYS_GET_INFO:
237 case HPI_SUBSYS_DRIVER_UNLOAD:
238 case HPI_SUBSYS_DRIVER_LOAD:
239 case HPI_SUBSYS_FIND_ADAPTERS:
240 /* messages that should not get here */
241 phr->error = HPI_ERROR_UNIMPLEMENTED;
242 break;
243 case HPI_SUBSYS_CREATE_ADAPTER: 230 case HPI_SUBSYS_CREATE_ADAPTER:
244 subsys_create_adapter(phm, phr); 231 subsys_create_adapter(phm, phr);
245 break; 232 break;
246 case HPI_SUBSYS_DELETE_ADAPTER:
247 subsys_delete_adapter(phm, phr);
248 break;
249 default: 233 default:
250 phr->error = HPI_ERROR_INVALID_FUNC; 234 phr->error = HPI_ERROR_INVALID_FUNC;
251 break; 235 break;
@@ -257,15 +241,22 @@ static void control_message(struct hpi_adapter_obj *pao,
257{ 241{
258 242
259 struct hpi_hw_obj *phw = pao->priv; 243 struct hpi_hw_obj *phw = pao->priv;
244 u16 pending_cache_error = 0;
260 245
261 switch (phm->function) { 246 switch (phm->function) {
262 case HPI_CONTROL_GET_STATE: 247 case HPI_CONTROL_GET_STATE:
263 if (pao->has_control_cache) { 248 if (pao->has_control_cache) {
264 rmb(); /* make sure we see updates DM_aed from DSP */ 249 rmb(); /* make sure we see updates DMAed from DSP */
265 if (hpi_check_control_cache(phw->p_cache, phm, phr)) 250 if (hpi_check_control_cache(phw->p_cache, phm, phr)) {
266 break; 251 break;
252 } else if (phm->u.c.attribute == HPI_METER_PEAK) {
253 pending_cache_error =
254 HPI_ERROR_CONTROL_CACHING;
255 }
267 } 256 }
268 hw_message(pao, phm, phr); 257 hw_message(pao, phm, phr);
258 if (pending_cache_error && !phr->error)
259 phr->error = pending_cache_error;
269 break; 260 break;
270 case HPI_CONTROL_GET_INFO: 261 case HPI_CONTROL_GET_INFO:
271 hw_message(pao, phm, phr); 262 hw_message(pao, phm, phr);
@@ -273,7 +264,8 @@ static void control_message(struct hpi_adapter_obj *pao,
273 case HPI_CONTROL_SET_STATE: 264 case HPI_CONTROL_SET_STATE:
274 hw_message(pao, phm, phr); 265 hw_message(pao, phm, phr);
275 if (pao->has_control_cache) 266 if (pao->has_control_cache)
276 hpi_sync_control_cache(phw->p_cache, phm, phr); 267 hpi_cmn_control_cache_sync_to_msg(phw->p_cache, phm,
268 phr);
277 break; 269 break;
278 default: 270 default:
279 phr->error = HPI_ERROR_INVALID_FUNC; 271 phr->error = HPI_ERROR_INVALID_FUNC;
@@ -285,6 +277,10 @@ static void adapter_message(struct hpi_adapter_obj *pao,
285 struct hpi_message *phm, struct hpi_response *phr) 277 struct hpi_message *phm, struct hpi_response *phr)
286{ 278{
287 switch (phm->function) { 279 switch (phm->function) {
280 case HPI_ADAPTER_DELETE:
281 adapter_delete(pao, phm, phr);
282 break;
283
288 default: 284 default:
289 hw_message(pao, phm, phr); 285 hw_message(pao, phm, phr);
290 break; 286 break;
@@ -296,9 +292,9 @@ static void outstream_message(struct hpi_adapter_obj *pao,
296{ 292{
297 293
298 if (phm->obj_index >= HPI_MAX_STREAMS) { 294 if (phm->obj_index >= HPI_MAX_STREAMS) {
299 phr->error = HPI_ERROR_INVALID_STREAM; 295 phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
300 HPI_DEBUG_LOG(WARNING, 296 HPI_DEBUG_LOG(WARNING,
301 "message referencing invalid stream %d " 297 "Message referencing invalid stream %d "
302 "on adapter index %d\n", phm->obj_index, 298 "on adapter index %d\n", phm->obj_index,
303 phm->adapter_index); 299 phm->adapter_index);
304 return; 300 return;
@@ -340,9 +336,9 @@ static void instream_message(struct hpi_adapter_obj *pao,
340{ 336{
341 337
342 if (phm->obj_index >= HPI_MAX_STREAMS) { 338 if (phm->obj_index >= HPI_MAX_STREAMS) {
343 phr->error = HPI_ERROR_INVALID_STREAM; 339 phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
344 HPI_DEBUG_LOG(WARNING, 340 HPI_DEBUG_LOG(WARNING,
345 "message referencing invalid stream %d " 341 "Message referencing invalid stream %d "
346 "on adapter index %d\n", phm->obj_index, 342 "on adapter index %d\n", phm->obj_index,
347 phm->adapter_index); 343 phm->adapter_index);
348 return; 344 return;
@@ -377,55 +373,32 @@ static void instream_message(struct hpi_adapter_obj *pao,
377/** Entry point to this HPI backend 373/** Entry point to this HPI backend
378 * All calls to the HPI start here 374 * All calls to the HPI start here
379 */ 375 */
380void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) 376void _HPI_6205(struct hpi_adapter_obj *pao, struct hpi_message *phm,
377 struct hpi_response *phr)
381{ 378{
382 struct hpi_adapter_obj *pao = NULL; 379 if (pao && (pao->dsp_crashed >= 10)
383 380 && (phm->function != HPI_ADAPTER_DEBUG_READ)) {
384 /* subsytem messages are processed by every HPI. 381 /* allow last resort debug read even after crash */
385 * All other messages are ignored unless the adapter index matches 382 hpi_init_response(phr, phm->object, phm->function,
386 * an adapter in the HPI 383 HPI_ERROR_DSP_HARDWARE);
387 */ 384 HPI_DEBUG_LOG(WARNING, " %d,%d dsp crashed.\n", phm->object,
388 HPI_DEBUG_LOG(DEBUG, "HPI obj=%d, func=%d\n", phm->object, 385 phm->function);
389 phm->function); 386 return;
390
391 /* if Dsp has crashed then do not communicate with it any more */
392 if (phm->object != HPI_OBJ_SUBSYSTEM) {
393 pao = hpi_find_adapter(phm->adapter_index);
394 if (!pao) {
395 HPI_DEBUG_LOG(DEBUG,
396 " %d,%d refused, for another HPI?\n",
397 phm->object, phm->function);
398 return;
399 }
400
401 if ((pao->dsp_crashed >= 10)
402 && (phm->function != HPI_ADAPTER_DEBUG_READ)) {
403 /* allow last resort debug read even after crash */
404 hpi_init_response(phr, phm->object, phm->function,
405 HPI_ERROR_DSP_HARDWARE);
406 HPI_DEBUG_LOG(WARNING, " %d,%d dsp crashed.\n",
407 phm->object, phm->function);
408 return;
409 }
410 } 387 }
411 388
412 /* Init default response */ 389 /* Init default response */
413 if (phm->function != HPI_SUBSYS_CREATE_ADAPTER) 390 if (phm->function != HPI_SUBSYS_CREATE_ADAPTER)
414 hpi_init_response(phr, phm->object, phm->function, 391 phr->error = HPI_ERROR_PROCESSING_MESSAGE;
415 HPI_ERROR_PROCESSING_MESSAGE);
416 392
417 HPI_DEBUG_LOG(VERBOSE, "start of switch\n"); 393 HPI_DEBUG_LOG(VERBOSE, "start of switch\n");
418 switch (phm->type) { 394 switch (phm->type) {
419 case HPI_TYPE_MESSAGE: 395 case HPI_TYPE_MESSAGE:
420 switch (phm->object) { 396 switch (phm->object) {
421 case HPI_OBJ_SUBSYSTEM: 397 case HPI_OBJ_SUBSYSTEM:
422 subsys_message(phm, phr); 398 subsys_message(pao, phm, phr);
423 break; 399 break;
424 400
425 case HPI_OBJ_ADAPTER: 401 case HPI_OBJ_ADAPTER:
426 phr->size =
427 sizeof(struct hpi_response_header) +
428 sizeof(struct hpi_adapter_res);
429 adapter_message(pao, phm, phr); 402 adapter_message(pao, phm, phr);
430 break; 403 break;
431 404
@@ -454,6 +427,26 @@ void HPI_6205(struct hpi_message *phm, struct hpi_response *phr)
454 } 427 }
455} 428}
456 429
430void HPI_6205(struct hpi_message *phm, struct hpi_response *phr)
431{
432 struct hpi_adapter_obj *pao = NULL;
433
434 if (phm->object != HPI_OBJ_SUBSYSTEM) {
435 /* normal messages must have valid adapter index */
436 pao = hpi_find_adapter(phm->adapter_index);
437 } else {
438 /* subsys messages don't address an adapter */
439 _HPI_6205(NULL, phm, phr);
440 return;
441 }
442
443 if (pao)
444 _HPI_6205(pao, phm, phr);
445 else
446 hpi_init_response(phr, phm->object, phm->function,
447 HPI_ERROR_BAD_ADAPTER_NUMBER);
448}
449
457/*****************************************************************************/ 450/*****************************************************************************/
458/* SUBSYSTEM */ 451/* SUBSYSTEM */
459 452
@@ -474,46 +467,38 @@ static void subsys_create_adapter(struct hpi_message *phm,
474 467
475 memset(&ao, 0, sizeof(ao)); 468 memset(&ao, 0, sizeof(ao));
476 469
477 /* this HPI only creates adapters for TI/PCI devices */
478 if (phm->u.s.resource.bus_type != HPI_BUS_PCI)
479 return;
480 if (phm->u.s.resource.r.pci->vendor_id != HPI_PCI_VENDOR_ID_TI)
481 return;
482 if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_DSP6205)
483 return;
484
485 ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL); 470 ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL);
486 if (!ao.priv) { 471 if (!ao.priv) {
487 HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n"); 472 HPI_DEBUG_LOG(ERROR, "can't get mem for adapter object\n");
488 phr->error = HPI_ERROR_MEMORY_ALLOC; 473 phr->error = HPI_ERROR_MEMORY_ALLOC;
489 return; 474 return;
490 } 475 }
491 476
492 ao.pci = *phm->u.s.resource.r.pci; 477 ao.pci = *phm->u.s.resource.r.pci;
493 err = create_adapter_obj(&ao, &os_error_code); 478 err = create_adapter_obj(&ao, &os_error_code);
494 if (!err)
495 err = hpi_add_adapter(&ao);
496 if (err) { 479 if (err) {
497 phr->u.s.data = os_error_code;
498 delete_adapter_obj(&ao); 480 delete_adapter_obj(&ao);
499 phr->error = err; 481 if (err >= HPI_ERROR_BACKEND_BASE) {
482 phr->error = HPI_ERROR_DSP_BOOTLOAD;
483 phr->specific_error = err;
484 } else {
485 phr->error = err;
486 }
487 phr->u.s.data = os_error_code;
500 return; 488 return;
501 } 489 }
502 490
503 phr->u.s.aw_adapter_list[ao.index] = ao.adapter_type; 491 phr->u.s.adapter_type = ao.adapter_type;
504 phr->u.s.adapter_index = ao.index; 492 phr->u.s.adapter_index = ao.index;
505 phr->u.s.num_adapters++;
506 phr->error = 0; 493 phr->error = 0;
507} 494}
508 495
509/** delete an adapter - required by WDM driver */ 496/** delete an adapter - required by WDM driver */
510static void subsys_delete_adapter(struct hpi_message *phm, 497static void adapter_delete(struct hpi_adapter_obj *pao,
511 struct hpi_response *phr) 498 struct hpi_message *phm, struct hpi_response *phr)
512{ 499{
513 struct hpi_adapter_obj *pao;
514 struct hpi_hw_obj *phw; 500 struct hpi_hw_obj *phw;
515 501
516 pao = hpi_find_adapter(phm->adapter_index);
517 if (!pao) { 502 if (!pao) {
518 phr->error = HPI_ERROR_INVALID_OBJ_INDEX; 503 phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
519 return; 504 return;
@@ -526,6 +511,7 @@ static void subsys_delete_adapter(struct hpi_message *phm,
526 iowrite32(C6205_HDCR_WARMRESET, phw->prHDCR); 511 iowrite32(C6205_HDCR_WARMRESET, phw->prHDCR);
527 512
528 delete_adapter_obj(pao); 513 delete_adapter_obj(pao);
514 hpi_delete_adapter(pao);
529 phr->error = 0; 515 phr->error = 0;
530} 516}
531 517
@@ -538,10 +524,6 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
538 struct hpi_hw_obj *phw = pao->priv; 524 struct hpi_hw_obj *phw = pao->priv;
539 struct bus_master_interface *interface; 525 struct bus_master_interface *interface;
540 u32 phys_addr; 526 u32 phys_addr;
541#ifndef HPI6205_NO_HSR_POLL
542 u32 time_out = HPI6205_TIMEOUT;
543 u32 temp1;
544#endif
545 int i; 527 int i;
546 u16 err; 528 u16 err;
547 529
@@ -566,7 +548,7 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
566 548
567 if (hpios_locked_mem_alloc(&phw->h_locked_mem, 549 if (hpios_locked_mem_alloc(&phw->h_locked_mem,
568 sizeof(struct bus_master_interface), 550 sizeof(struct bus_master_interface),
569 pao->pci.p_os_data)) 551 pao->pci.pci_dev))
570 phw->p_interface_buffer = NULL; 552 phw->p_interface_buffer = NULL;
571 else if (hpios_locked_mem_get_virt_addr(&phw->h_locked_mem, 553 else if (hpios_locked_mem_get_virt_addr(&phw->h_locked_mem,
572 (void *)&phw->p_interface_buffer)) 554 (void *)&phw->p_interface_buffer))
@@ -582,58 +564,39 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
582 } 564 }
583 565
584 err = adapter_boot_load_dsp(pao, pos_error_code); 566 err = adapter_boot_load_dsp(pao, pos_error_code);
585 if (err) 567 if (err) {
568 HPI_DEBUG_LOG(ERROR, "DSP code load failed\n");
586 /* no need to clean up as SubSysCreateAdapter */ 569 /* no need to clean up as SubSysCreateAdapter */
587 /* calls DeleteAdapter on error. */ 570 /* calls DeleteAdapter on error. */
588 return err; 571 return err;
589 572 }
590 HPI_DEBUG_LOG(INFO, "load DSP code OK\n"); 573 HPI_DEBUG_LOG(INFO, "load DSP code OK\n");
591 574
592 /* allow boot load even if mem alloc wont work */ 575 /* allow boot load even if mem alloc wont work */
593 if (!phw->p_interface_buffer) 576 if (!phw->p_interface_buffer)
594 return hpi6205_error(0, HPI_ERROR_MEMORY_ALLOC); 577 return HPI_ERROR_MEMORY_ALLOC;
595 578
596 interface = phw->p_interface_buffer; 579 interface = phw->p_interface_buffer;
597 580
598#ifndef HPI6205_NO_HSR_POLL
599 /* wait for first interrupt indicating the DSP init is done */
600 time_out = HPI6205_TIMEOUT * 10;
601 temp1 = 0;
602 while (((temp1 & C6205_HSR_INTSRC) == 0) && --time_out)
603 temp1 = ioread32(phw->prHSR);
604
605 if (temp1 & C6205_HSR_INTSRC)
606 HPI_DEBUG_LOG(INFO,
607 "interrupt confirming DSP code running OK\n");
608 else {
609 HPI_DEBUG_LOG(ERROR,
610 "timed out waiting for interrupt "
611 "confirming DSP code running\n");
612 return hpi6205_error(0, HPI6205_ERROR_6205_NO_IRQ);
613 }
614
615 /* reset the interrupt */
616 iowrite32(C6205_HSR_INTSRC, phw->prHSR);
617#endif
618
619 /* make sure the DSP has started ok */ 581 /* make sure the DSP has started ok */
620 if (!wait_dsp_ack(phw, H620_HIF_RESET, HPI6205_TIMEOUT * 10)) { 582 if (!wait_dsp_ack(phw, H620_HIF_RESET, HPI6205_TIMEOUT * 10)) {
621 HPI_DEBUG_LOG(ERROR, "timed out waiting reset state \n"); 583 HPI_DEBUG_LOG(ERROR, "timed out waiting reset state \n");
622 return hpi6205_error(0, HPI6205_ERROR_6205_INIT_FAILED); 584 return HPI6205_ERROR_6205_INIT_FAILED;
623 } 585 }
624 /* Note that *pao, *phw are zeroed after allocation, 586 /* Note that *pao, *phw are zeroed after allocation,
625 * so pointers and flags are NULL by default. 587 * so pointers and flags are NULL by default.
626 * Allocate bus mastering control cache buffer and tell the DSP about it 588 * Allocate bus mastering control cache buffer and tell the DSP about it
627 */ 589 */
628 if (interface->control_cache.number_of_controls) { 590 if (interface->control_cache.number_of_controls) {
629 void *p_control_cache_virtual; 591 u8 *p_control_cache_virtual;
630 592
631 err = hpios_locked_mem_alloc(&phw->h_control_cache, 593 err = hpios_locked_mem_alloc(&phw->h_control_cache,
632 interface->control_cache.size_in_bytes, 594 interface->control_cache.size_in_bytes,
633 pao->pci.p_os_data); 595 pao->pci.pci_dev);
634 if (!err) 596 if (!err)
635 err = hpios_locked_mem_get_virt_addr(&phw-> 597 err = hpios_locked_mem_get_virt_addr(&phw->
636 h_control_cache, &p_control_cache_virtual); 598 h_control_cache,
599 (void *)&p_control_cache_virtual);
637 if (!err) { 600 if (!err) {
638 memset(p_control_cache_virtual, 0, 601 memset(p_control_cache_virtual, 0,
639 interface->control_cache.size_in_bytes); 602 interface->control_cache.size_in_bytes);
@@ -642,8 +605,10 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
642 hpi_alloc_control_cache(interface-> 605 hpi_alloc_control_cache(interface->
643 control_cache.number_of_controls, 606 control_cache.number_of_controls,
644 interface->control_cache.size_in_bytes, 607 interface->control_cache.size_in_bytes,
645 (struct hpi_control_cache_info *)
646 p_control_cache_virtual); 608 p_control_cache_virtual);
609
610 if (!phw->p_cache)
611 err = HPI_ERROR_MEMORY_ALLOC;
647 } 612 }
648 if (!err) { 613 if (!err) {
649 err = hpios_locked_mem_get_phys_addr(&phw-> 614 err = hpios_locked_mem_get_phys_addr(&phw->
@@ -660,96 +625,67 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
660 pao->has_control_cache = 0; 625 pao->has_control_cache = 0;
661 } 626 }
662 } 627 }
663 /* allocate bus mastering async buffer and tell the DSP about it */
664 if (interface->async_buffer.b.size) {
665 err = hpios_locked_mem_alloc(&phw->h_async_event_buffer,
666 interface->async_buffer.b.size *
667 sizeof(struct hpi_async_event), pao->pci.p_os_data);
668 if (!err)
669 err = hpios_locked_mem_get_virt_addr
670 (&phw->h_async_event_buffer, (void *)
671 &phw->p_async_event_buffer);
672 if (!err)
673 memset((void *)phw->p_async_event_buffer, 0,
674 interface->async_buffer.b.size *
675 sizeof(struct hpi_async_event));
676 if (!err) {
677 err = hpios_locked_mem_get_phys_addr
678 (&phw->h_async_event_buffer, &phys_addr);
679 interface->async_buffer.physical_address32 =
680 phys_addr;
681 }
682 if (err) {
683 if (hpios_locked_mem_valid(&phw->
684 h_async_event_buffer)) {
685 hpios_locked_mem_free
686 (&phw->h_async_event_buffer);
687 phw->p_async_event_buffer = NULL;
688 }
689 }
690 }
691 send_dsp_command(phw, H620_HIF_IDLE); 628 send_dsp_command(phw, H620_HIF_IDLE);
692 629
693 { 630 {
694 struct hpi_message hM; 631 struct hpi_message hm;
695 struct hpi_response hR; 632 struct hpi_response hr;
696 u32 max_streams; 633 u32 max_streams;
697 634
698 HPI_DEBUG_LOG(VERBOSE, "init ADAPTER_GET_INFO\n"); 635 HPI_DEBUG_LOG(VERBOSE, "init ADAPTER_GET_INFO\n");
699 memset(&hM, 0, sizeof(hM)); 636 memset(&hm, 0, sizeof(hm));
700 hM.type = HPI_TYPE_MESSAGE; 637 hm.type = HPI_TYPE_MESSAGE;
701 hM.size = sizeof(hM); 638 hm.size = sizeof(hm);
702 hM.object = HPI_OBJ_ADAPTER; 639 hm.object = HPI_OBJ_ADAPTER;
703 hM.function = HPI_ADAPTER_GET_INFO; 640 hm.function = HPI_ADAPTER_GET_INFO;
704 hM.adapter_index = 0; 641 hm.adapter_index = 0;
705 memset(&hR, 0, sizeof(hR)); 642 memset(&hr, 0, sizeof(hr));
706 hR.size = sizeof(hR); 643 hr.size = sizeof(hr);
707 644
708 err = message_response_sequence(pao, &hM, &hR); 645 err = message_response_sequence(pao, &hm, &hr);
709 if (err) { 646 if (err) {
710 HPI_DEBUG_LOG(ERROR, "message transport error %d\n", 647 HPI_DEBUG_LOG(ERROR, "message transport error %d\n",
711 err); 648 err);
712 return err; 649 return err;
713 } 650 }
714 if (hR.error) 651 if (hr.error)
715 return hR.error; 652 return hr.error;
716 653
717 pao->adapter_type = hR.u.a.adapter_type; 654 pao->adapter_type = hr.u.ax.info.adapter_type;
718 pao->index = hR.u.a.adapter_index; 655 pao->index = hr.u.ax.info.adapter_index;
719 656
720 max_streams = hR.u.a.num_outstreams + hR.u.a.num_instreams; 657 max_streams =
658 hr.u.ax.info.num_outstreams +
659 hr.u.ax.info.num_instreams;
721 660
722 hpios_locked_mem_prepare((max_streams * 6) / 10, max_streams, 661 hpios_locked_mem_prepare((max_streams * 6) / 10, max_streams,
723 65536, pao->pci.p_os_data); 662 65536, pao->pci.pci_dev);
724 663
725 HPI_DEBUG_LOG(VERBOSE, 664 HPI_DEBUG_LOG(VERBOSE,
726 "got adapter info type %x index %d serial %d\n", 665 "got adapter info type %x index %d serial %d\n",
727 hR.u.a.adapter_type, hR.u.a.adapter_index, 666 hr.u.ax.info.adapter_type, hr.u.ax.info.adapter_index,
728 hR.u.a.serial_number); 667 hr.u.ax.info.serial_number);
729 } 668 }
730 669
731 pao->open = 0; /* upon creation the adapter is closed */ 670 pao->open = 0; /* upon creation the adapter is closed */
732 671
672 if (phw->p_cache)
673 phw->p_cache->adap_idx = pao->index;
674
733 HPI_DEBUG_LOG(INFO, "bootload DSP OK\n"); 675 HPI_DEBUG_LOG(INFO, "bootload DSP OK\n");
734 return 0; 676
677 return hpi_add_adapter(pao);
735} 678}
736 679
737/** Free memory areas allocated by adapter 680/** Free memory areas allocated by adapter
738 * this routine is called from SubSysDeleteAdapter, 681 * this routine is called from AdapterDelete,
739 * and SubSysCreateAdapter if duplicate index 682 * and SubSysCreateAdapter if duplicate index
740*/ 683*/
741static void delete_adapter_obj(struct hpi_adapter_obj *pao) 684static void delete_adapter_obj(struct hpi_adapter_obj *pao)
742{ 685{
743 struct hpi_hw_obj *phw; 686 struct hpi_hw_obj *phw = pao->priv;
744 int i; 687 int i;
745 688
746 phw = pao->priv;
747
748 if (hpios_locked_mem_valid(&phw->h_async_event_buffer)) {
749 hpios_locked_mem_free(&phw->h_async_event_buffer);
750 phw->p_async_event_buffer = NULL;
751 }
752
753 if (hpios_locked_mem_valid(&phw->h_control_cache)) { 689 if (hpios_locked_mem_valid(&phw->h_control_cache)) {
754 hpios_locked_mem_free(&phw->h_control_cache); 690 hpios_locked_mem_free(&phw->h_control_cache);
755 hpi_free_control_cache(phw->p_cache); 691 hpi_free_control_cache(phw->p_cache);
@@ -774,13 +710,15 @@ static void delete_adapter_obj(struct hpi_adapter_obj *pao)
774 phw->outstream_host_buffer_size[i] = 0; 710 phw->outstream_host_buffer_size[i] = 0;
775 } 711 }
776 712
777 hpios_locked_mem_unprepare(pao->pci.p_os_data); 713 hpios_locked_mem_unprepare(pao->pci.pci_dev);
778 714
779 hpi_delete_adapter(pao);
780 kfree(phw); 715 kfree(phw);
781} 716}
782 717
783/*****************************************************************************/ 718/*****************************************************************************/
719/* Adapter functions */
720
721/*****************************************************************************/
784/* OutStream Host buffer functions */ 722/* OutStream Host buffer functions */
785 723
786/** Allocate or attach buffer for busmastering 724/** Allocate or attach buffer for busmastering
@@ -822,7 +760,7 @@ static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao,
822 760
823 err = hpios_locked_mem_alloc(&phw->outstream_host_buffers 761 err = hpios_locked_mem_alloc(&phw->outstream_host_buffers
824 [phm->obj_index], phm->u.d.u.buffer.buffer_size, 762 [phm->obj_index], phm->u.d.u.buffer.buffer_size,
825 pao->pci.p_os_data); 763 pao->pci.pci_dev);
826 764
827 if (err) { 765 if (err) {
828 phr->error = HPI_ERROR_INVALID_DATASIZE; 766 phr->error = HPI_ERROR_INVALID_DATASIZE;
@@ -859,7 +797,7 @@ static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao,
859 if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer. 797 if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer.
860 buffer_size - 1)) { 798 buffer_size - 1)) {
861 HPI_DEBUG_LOG(ERROR, 799 HPI_DEBUG_LOG(ERROR,
862 "buffer size must be 2^N not %d\n", 800 "Buffer size must be 2^N not %d\n",
863 phm->u.d.u.buffer.buffer_size); 801 phm->u.d.u.buffer.buffer_size);
864 phr->error = HPI_ERROR_INVALID_DATASIZE; 802 phr->error = HPI_ERROR_INVALID_DATASIZE;
865 return; 803 return;
@@ -873,6 +811,7 @@ static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao,
873 status->dSP_index = 0; 811 status->dSP_index = 0;
874 status->host_index = status->dSP_index; 812 status->host_index = status->dSP_index;
875 status->size_in_bytes = phm->u.d.u.buffer.buffer_size; 813 status->size_in_bytes = phm->u.d.u.buffer.buffer_size;
814 status->auxiliary_data_available = 0;
876 815
877 hw_message(pao, phm, phr); 816 hw_message(pao, phm, phr);
878 817
@@ -964,51 +903,6 @@ static void outstream_write(struct hpi_adapter_obj *pao,
964 hpi_init_response(phr, phm->object, phm->function, 0); 903 hpi_init_response(phr, phm->object, phm->function, 0);
965 status = &interface->outstream_host_buffer_status[phm->obj_index]; 904 status = &interface->outstream_host_buffer_status[phm->obj_index];
966 905
967 if (phw->flag_outstream_just_reset[phm->obj_index]) {
968 /* First OutStremWrite() call following reset will write data to the
969 adapter's buffers, reducing delay before stream can start. The DSP
970 takes care of setting the stream data format using format information
971 embedded in phm.
972 */
973 int partial_write = 0;
974 unsigned int original_size = 0;
975
976 phw->flag_outstream_just_reset[phm->obj_index] = 0;
977
978 /* Send the first buffer to the DSP the old way. */
979 /* Limit size of first transfer - */
980 /* expect that this will not usually be triggered. */
981 if (phm->u.d.u.data.data_size > HPI6205_SIZEOF_DATA) {
982 partial_write = 1;
983 original_size = phm->u.d.u.data.data_size;
984 phm->u.d.u.data.data_size = HPI6205_SIZEOF_DATA;
985 }
986 /* write it */
987 phm->function = HPI_OSTREAM_WRITE;
988 hw_message(pao, phm, phr);
989
990 if (phr->error)
991 return;
992
993 /* update status information that the DSP would typically
994 * update (and will update next time the DSP
995 * buffer update task reads data from the host BBM buffer)
996 */
997 status->auxiliary_data_available = phm->u.d.u.data.data_size;
998 status->host_index += phm->u.d.u.data.data_size;
999 status->dSP_index += phm->u.d.u.data.data_size;
1000
1001 /* if we did a full write, we can return from here. */
1002 if (!partial_write)
1003 return;
1004
1005 /* tweak buffer parameters and let the rest of the */
1006 /* buffer land in internal BBM buffer */
1007 phm->u.d.u.data.data_size =
1008 original_size - HPI6205_SIZEOF_DATA;
1009 phm->u.d.u.data.pb_data += HPI6205_SIZEOF_DATA;
1010 }
1011
1012 space_available = outstream_get_space_available(status); 906 space_available = outstream_get_space_available(status);
1013 if (space_available < phm->u.d.u.data.data_size) { 907 if (space_available < phm->u.d.u.data.data_size) {
1014 phr->error = HPI_ERROR_INVALID_DATASIZE; 908 phr->error = HPI_ERROR_INVALID_DATASIZE;
@@ -1045,6 +939,24 @@ static void outstream_write(struct hpi_adapter_obj *pao,
1045 memcpy(p_bbm_data, p_app_data + l_first_write, 939 memcpy(p_bbm_data, p_app_data + l_first_write,
1046 phm->u.d.u.data.data_size - l_first_write); 940 phm->u.d.u.data.data_size - l_first_write);
1047 } 941 }
942
943 /*
944 * This version relies on the DSP code triggering an OStream buffer
945 * update immediately following a SET_FORMAT call. The host has
946 * already written data into the BBM buffer, but the DSP won't know
947 * about it until dwHostIndex is adjusted.
948 */
949 if (phw->flag_outstream_just_reset[phm->obj_index]) {
950 /* Format can only change after reset. Must tell DSP. */
951 u16 function = phm->function;
952 phw->flag_outstream_just_reset[phm->obj_index] = 0;
953 phm->function = HPI_OSTREAM_SET_FORMAT;
954 hw_message(pao, phm, phr); /* send the format to the DSP */
955 phm->function = function;
956 if (phr->error)
957 return;
958 }
959
1048 status->host_index += phm->u.d.u.data.data_size; 960 status->host_index += phm->u.d.u.data.data_size;
1049} 961}
1050 962
@@ -1130,7 +1042,7 @@ static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao,
1130 1042
1131 err = hpios_locked_mem_alloc(&phw->instream_host_buffers[phm-> 1043 err = hpios_locked_mem_alloc(&phw->instream_host_buffers[phm->
1132 obj_index], phm->u.d.u.buffer.buffer_size, 1044 obj_index], phm->u.d.u.buffer.buffer_size,
1133 pao->pci.p_os_data); 1045 pao->pci.pci_dev);
1134 1046
1135 if (err) { 1047 if (err) {
1136 phr->error = HPI_ERROR_INVALID_DATASIZE; 1048 phr->error = HPI_ERROR_INVALID_DATASIZE;
@@ -1161,7 +1073,7 @@ static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao,
1161 if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer. 1073 if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer.
1162 buffer_size - 1)) { 1074 buffer_size - 1)) {
1163 HPI_DEBUG_LOG(ERROR, 1075 HPI_DEBUG_LOG(ERROR,
1164 "buffer size must be 2^N not %d\n", 1076 "Buffer size must be 2^N not %d\n",
1165 phm->u.d.u.buffer.buffer_size); 1077 phm->u.d.u.buffer.buffer_size);
1166 phr->error = HPI_ERROR_INVALID_DATASIZE; 1078 phr->error = HPI_ERROR_INVALID_DATASIZE;
1167 return; 1079 return;
@@ -1176,8 +1088,10 @@ static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao,
1176 status->dSP_index = 0; 1088 status->dSP_index = 0;
1177 status->host_index = status->dSP_index; 1089 status->host_index = status->dSP_index;
1178 status->size_in_bytes = phm->u.d.u.buffer.buffer_size; 1090 status->size_in_bytes = phm->u.d.u.buffer.buffer_size;
1091 status->auxiliary_data_available = 0;
1179 1092
1180 hw_message(pao, phm, phr); 1093 hw_message(pao, phm, phr);
1094
1181 if (phr->error 1095 if (phr->error
1182 && hpios_locked_mem_valid(&phw-> 1096 && hpios_locked_mem_valid(&phw->
1183 instream_host_buffers[phm->obj_index])) { 1097 instream_host_buffers[phm->obj_index])) {
@@ -1342,33 +1256,37 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1342 struct hpi_hw_obj *phw = pao->priv; 1256 struct hpi_hw_obj *phw = pao->priv;
1343 struct dsp_code dsp_code; 1257 struct dsp_code dsp_code;
1344 u16 boot_code_id[HPI6205_MAX_FILES_TO_LOAD]; 1258 u16 boot_code_id[HPI6205_MAX_FILES_TO_LOAD];
1345 u16 firmware_id = pao->pci.subsys_device_id;
1346 u32 temp; 1259 u32 temp;
1347 int dsp = 0, i = 0; 1260 int dsp = 0, i = 0;
1348 u16 err = 0; 1261 u16 err = 0;
1349 1262
1350 boot_code_id[0] = HPI_ADAPTER_ASI(0x6205); 1263 boot_code_id[0] = HPI_ADAPTER_ASI(0x6205);
1351 1264
1352 /* special cases where firmware_id != subsys ID */ 1265 boot_code_id[1] = pao->pci.pci_dev->subsystem_device;
1353 switch (firmware_id) { 1266 boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(boot_code_id[1]);
1267
1268 /* fix up cases where bootcode id[1] != subsys id */
1269 switch (boot_code_id[1]) {
1354 case HPI_ADAPTER_FAMILY_ASI(0x5000): 1270 case HPI_ADAPTER_FAMILY_ASI(0x5000):
1355 boot_code_id[0] = firmware_id; 1271 boot_code_id[0] = boot_code_id[1];
1356 firmware_id = 0; 1272 boot_code_id[1] = 0;
1357 break; 1273 break;
1358 case HPI_ADAPTER_FAMILY_ASI(0x5300): 1274 case HPI_ADAPTER_FAMILY_ASI(0x5300):
1359 case HPI_ADAPTER_FAMILY_ASI(0x5400): 1275 case HPI_ADAPTER_FAMILY_ASI(0x5400):
1360 case HPI_ADAPTER_FAMILY_ASI(0x6300): 1276 case HPI_ADAPTER_FAMILY_ASI(0x6300):
1361 firmware_id = HPI_ADAPTER_FAMILY_ASI(0x6400); 1277 boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x6400);
1362 break; 1278 break;
1279 case HPI_ADAPTER_FAMILY_ASI(0x5500):
1363 case HPI_ADAPTER_FAMILY_ASI(0x5600): 1280 case HPI_ADAPTER_FAMILY_ASI(0x5600):
1364 case HPI_ADAPTER_FAMILY_ASI(0x6500): 1281 case HPI_ADAPTER_FAMILY_ASI(0x6500):
1365 firmware_id = HPI_ADAPTER_FAMILY_ASI(0x6600); 1282 boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x6600);
1366 break; 1283 break;
1367 case HPI_ADAPTER_FAMILY_ASI(0x8800): 1284 case HPI_ADAPTER_FAMILY_ASI(0x8800):
1368 firmware_id = HPI_ADAPTER_FAMILY_ASI(0x8900); 1285 boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x8900);
1286 break;
1287 default:
1369 break; 1288 break;
1370 } 1289 }
1371 boot_code_id[1] = firmware_id;
1372 1290
1373 /* reset DSP by writing a 1 to the WARMRESET bit */ 1291 /* reset DSP by writing a 1 to the WARMRESET bit */
1374 temp = C6205_HDCR_WARMRESET; 1292 temp = C6205_HDCR_WARMRESET;
@@ -1379,7 +1297,7 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1379 temp = ioread32(phw->prHSR); 1297 temp = ioread32(phw->prHSR);
1380 if ((temp & (C6205_HSR_CFGERR | C6205_HSR_EEREAD)) != 1298 if ((temp & (C6205_HSR_CFGERR | C6205_HSR_EEREAD)) !=
1381 C6205_HSR_EEREAD) 1299 C6205_HSR_EEREAD)
1382 return hpi6205_error(0, HPI6205_ERROR_6205_EEPROM); 1300 return HPI6205_ERROR_6205_EEPROM;
1383 temp |= 0x04; 1301 temp |= 0x04;
1384 /* disable PINTA interrupt */ 1302 /* disable PINTA interrupt */
1385 iowrite32(temp, phw->prHSR); 1303 iowrite32(temp, phw->prHSR);
@@ -1387,27 +1305,27 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1387 /* check control register reports PCI boot mode */ 1305 /* check control register reports PCI boot mode */
1388 temp = ioread32(phw->prHDCR); 1306 temp = ioread32(phw->prHDCR);
1389 if (!(temp & C6205_HDCR_PCIBOOT)) 1307 if (!(temp & C6205_HDCR_PCIBOOT))
1390 return hpi6205_error(0, HPI6205_ERROR_6205_REG); 1308 return HPI6205_ERROR_6205_REG;
1391 1309
1392 /* try writing a couple of numbers to the DSP page register */ 1310 /* try writing a few numbers to the DSP page register */
1393 /* and reading them back. */ 1311 /* and reading them back. */
1394 temp = 1; 1312 temp = 3;
1395 iowrite32(temp, phw->prDSPP); 1313 iowrite32(temp, phw->prDSPP);
1396 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) 1314 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP))
1397 return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE); 1315 return HPI6205_ERROR_6205_DSPPAGE;
1398 temp = 2; 1316 temp = 2;
1399 iowrite32(temp, phw->prDSPP); 1317 iowrite32(temp, phw->prDSPP);
1400 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) 1318 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP))
1401 return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE); 1319 return HPI6205_ERROR_6205_DSPPAGE;
1402 temp = 3; 1320 temp = 1;
1403 iowrite32(temp, phw->prDSPP); 1321 iowrite32(temp, phw->prDSPP);
1404 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) 1322 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP))
1405 return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE); 1323 return HPI6205_ERROR_6205_DSPPAGE;
1406 /* reset DSP page to the correct number */ 1324 /* reset DSP page to the correct number */
1407 temp = 0; 1325 temp = 0;
1408 iowrite32(temp, phw->prDSPP); 1326 iowrite32(temp, phw->prDSPP);
1409 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) 1327 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP))
1410 return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE); 1328 return HPI6205_ERROR_6205_DSPPAGE;
1411 phw->dsp_page = 0; 1329 phw->dsp_page = 0;
1412 1330
1413 /* release 6713 from reset before 6205 is bootloaded. 1331 /* release 6713 from reset before 6205 is bootloaded.
@@ -1453,7 +1371,7 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1453 return err; 1371 return err;
1454 1372
1455 /* write the DSP code down into the DSPs memory */ 1373 /* write the DSP code down into the DSPs memory */
1456 dsp_code.ps_dev = pao->pci.p_os_data; 1374 dsp_code.ps_dev = pao->pci.pci_dev;
1457 err = hpi_dsp_code_open(boot_code_id[dsp], &dsp_code, 1375 err = hpi_dsp_code_open(boot_code_id[dsp], &dsp_code,
1458 pos_error_code); 1376 pos_error_code);
1459 if (err) 1377 if (err)
@@ -1482,10 +1400,8 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1482 if (err) 1400 if (err)
1483 break; 1401 break;
1484 for (i = 0; i < (int)length; i++) { 1402 for (i = 0; i < (int)length; i++) {
1485 err = boot_loader_write_mem32(pao, dsp, 1403 boot_loader_write_mem32(pao, dsp, address,
1486 address, *pcode); 1404 *pcode);
1487 if (err)
1488 break;
1489 /* dummy read every 4 words */ 1405 /* dummy read every 4 words */
1490 /* for 6205 advisory 1.4.4 */ 1406 /* for 6205 advisory 1.4.4 */
1491 if (i % 4 == 0) 1407 if (i % 4 == 0)
@@ -1559,7 +1475,7 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1559 host_mailbox_address_on_dsp = 0x80000000; 1475 host_mailbox_address_on_dsp = 0x80000000;
1560 while ((physicalPC_iaddress != physicalPC_iaddress_verify) 1476 while ((physicalPC_iaddress != physicalPC_iaddress_verify)
1561 && time_out--) { 1477 && time_out--) {
1562 err = boot_loader_write_mem32(pao, 0, 1478 boot_loader_write_mem32(pao, 0,
1563 host_mailbox_address_on_dsp, 1479 host_mailbox_address_on_dsp,
1564 physicalPC_iaddress); 1480 physicalPC_iaddress);
1565 physicalPC_iaddress_verify = 1481 physicalPC_iaddress_verify =
@@ -1629,11 +1545,10 @@ static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index,
1629 return data; 1545 return data;
1630} 1546}
1631 1547
1632static u16 boot_loader_write_mem32(struct hpi_adapter_obj *pao, int dsp_index, 1548static void boot_loader_write_mem32(struct hpi_adapter_obj *pao,
1633 u32 address, u32 data) 1549 int dsp_index, u32 address, u32 data)
1634{ 1550{
1635 struct hpi_hw_obj *phw = pao->priv; 1551 struct hpi_hw_obj *phw = pao->priv;
1636 u16 err = 0;
1637 __iomem u32 *p_data; 1552 __iomem u32 *p_data;
1638 /* u32 dwVerifyData=0; */ 1553 /* u32 dwVerifyData=0; */
1639 1554
@@ -1673,15 +1588,11 @@ static u16 boot_loader_write_mem32(struct hpi_adapter_obj *pao, int dsp_index,
1673 1588
1674 /* dummy read every 4 words for 6205 advisory 1.4.4 */ 1589 /* dummy read every 4 words for 6205 advisory 1.4.4 */
1675 boot_loader_read_mem32(pao, 0, 0); 1590 boot_loader_read_mem32(pao, 0, 0);
1676 } else 1591 }
1677 err = hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX);
1678 return err;
1679} 1592}
1680 1593
1681static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) 1594static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1682{ 1595{
1683 u16 err = 0;
1684
1685 if (dsp_index == 0) { 1596 if (dsp_index == 0) {
1686 u32 setting; 1597 u32 setting;
1687 1598
@@ -1709,8 +1620,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1709 boot_loader_write_mem32(pao, dsp_index, 0x01800008, setting); 1620 boot_loader_write_mem32(pao, dsp_index, 0x01800008, setting);
1710 if (setting != boot_loader_read_mem32(pao, dsp_index, 1621 if (setting != boot_loader_read_mem32(pao, dsp_index,
1711 0x01800008)) 1622 0x01800008))
1712 return hpi6205_error(dsp_index, 1623 return HPI6205_ERROR_DSP_EMIF;
1713 HPI6205_ERROR_DSP_EMIF);
1714 1624
1715 /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */ 1625 /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */
1716 /* which occupies D15..0. 6713 starts at 27MHz, so need */ 1626 /* which occupies D15..0. 6713 starts at 27MHz, so need */
@@ -1723,8 +1633,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1723 boot_loader_write_mem32(pao, dsp_index, 0x01800004, setting); 1633 boot_loader_write_mem32(pao, dsp_index, 0x01800004, setting);
1724 if (setting != boot_loader_read_mem32(pao, dsp_index, 1634 if (setting != boot_loader_read_mem32(pao, dsp_index,
1725 0x01800004)) 1635 0x01800004))
1726 return hpi6205_error(dsp_index, 1636 return HPI6205_ERROR_DSP_EMIF;
1727 HPI6205_ERROR_DSP_EMIF);
1728 1637
1729 /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */ 1638 /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */
1730 /* which occupies D15..0. 6713 starts at 27MHz, so need */ 1639 /* which occupies D15..0. 6713 starts at 27MHz, so need */
@@ -1736,8 +1645,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1736 boot_loader_write_mem32(pao, dsp_index, 0x01800010, setting); 1645 boot_loader_write_mem32(pao, dsp_index, 0x01800010, setting);
1737 if (setting != boot_loader_read_mem32(pao, dsp_index, 1646 if (setting != boot_loader_read_mem32(pao, dsp_index,
1738 0x01800010)) 1647 0x01800010))
1739 return hpi6205_error(dsp_index, 1648 return HPI6205_ERROR_DSP_EMIF;
1740 HPI6205_ERROR_DSP_EMIF);
1741 1649
1742 /* EMIF CE3 setup - 32 bit async. */ 1650 /* EMIF CE3 setup - 32 bit async. */
1743 /* This is the PLD on the ASI5000 cards only */ 1651 /* This is the PLD on the ASI5000 cards only */
@@ -1748,8 +1656,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1748 boot_loader_write_mem32(pao, dsp_index, 0x01800014, setting); 1656 boot_loader_write_mem32(pao, dsp_index, 0x01800014, setting);
1749 if (setting != boot_loader_read_mem32(pao, dsp_index, 1657 if (setting != boot_loader_read_mem32(pao, dsp_index,
1750 0x01800014)) 1658 0x01800014))
1751 return hpi6205_error(dsp_index, 1659 return HPI6205_ERROR_DSP_EMIF;
1752 HPI6205_ERROR_DSP_EMIF);
1753 1660
1754 /* set EMIF SDRAM control for 2Mx32 SDRAM (512x32x4 bank) */ 1661 /* set EMIF SDRAM control for 2Mx32 SDRAM (512x32x4 bank) */
1755 /* need to use this else DSP code crashes? */ 1662 /* need to use this else DSP code crashes? */
@@ -1773,12 +1680,9 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1773 read_data = 1680 read_data =
1774 0xFFF7 & boot_loader_read_mem32(pao, 0, HPICL_ADDR); 1681 0xFFF7 & boot_loader_read_mem32(pao, 0, HPICL_ADDR);
1775 if (write_data != read_data) { 1682 if (write_data != read_data) {
1776 err = hpi6205_error(dsp_index,
1777 HPI6205_ERROR_C6713_HPIC);
1778 HPI_DEBUG_LOG(ERROR, "HPICL %x %x\n", write_data, 1683 HPI_DEBUG_LOG(ERROR, "HPICL %x %x\n", write_data,
1779 read_data); 1684 read_data);
1780 1685 return HPI6205_ERROR_C6713_HPIC;
1781 return err;
1782 } 1686 }
1783 /* HPIA - walking ones test */ 1687 /* HPIA - walking ones test */
1784 write_data = 1; 1688 write_data = 1;
@@ -1796,11 +1700,9 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1796 HPIAH_ADDR)) 1700 HPIAH_ADDR))
1797 << 16); 1701 << 16);
1798 if (read_data != write_data) { 1702 if (read_data != write_data) {
1799 err = hpi6205_error(dsp_index,
1800 HPI6205_ERROR_C6713_HPIA);
1801 HPI_DEBUG_LOG(ERROR, "HPIA %x %x\n", 1703 HPI_DEBUG_LOG(ERROR, "HPIA %x %x\n",
1802 write_data, read_data); 1704 write_data, read_data);
1803 return err; 1705 return HPI6205_ERROR_C6713_HPIA;
1804 } 1706 }
1805 write_data = write_data << 1; 1707 write_data = write_data << 1;
1806 } 1708 }
@@ -1845,30 +1747,81 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1845 /* PLL should not be bypassed! */ 1747 /* PLL should not be bypassed! */
1846 if ((boot_loader_read_mem32(pao, dsp_index, 0x01B7C100) & 0xF) 1748 if ((boot_loader_read_mem32(pao, dsp_index, 0x01B7C100) & 0xF)
1847 != 0x0001) { 1749 != 0x0001) {
1848 err = hpi6205_error(dsp_index, 1750 return HPI6205_ERROR_C6713_PLL;
1849 HPI6205_ERROR_C6713_PLL);
1850 return err;
1851 } 1751 }
1852 /* setup C67x EMIF (note this is the only use of 1752 /* setup C67x EMIF (note this is the only use of
1853 BAR1 via BootLoader_WriteMem32) */ 1753 BAR1 via BootLoader_WriteMem32) */
1854 boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_GCTL, 1754 boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_GCTL,
1855 0x000034A8); 1755 0x000034A8);
1756
1757 /* EMIF CE0 setup - 2Mx32 Sync DRAM
1758 31..28 Wr setup
1759 27..22 Wr strobe
1760 21..20 Wr hold
1761 19..16 Rd setup
1762 15..14 -
1763 13..8 Rd strobe
1764 7..4 MTYPE 0011 Sync DRAM 32bits
1765 3 Wr hold MSB
1766 2..0 Rd hold
1767 */
1856 boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_CE0, 1768 boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_CE0,
1857 0x00000030); 1769 0x00000030);
1770
1771 /* EMIF SDRAM Extension
1772 0x00
1773 31-21 0000b 0000b 000b
1774 20 WR2RD = 2cycles-1 = 1b
1775
1776 19-18 WR2DEAC = 3cycle-1 = 10b
1777 17 WR2WR = 2cycle-1 = 1b
1778 16-15 R2WDQM = 4cycle-1 = 11b
1779 14-12 RD2WR = 6cycles-1 = 101b
1780
1781 11-10 RD2DEAC = 4cycle-1 = 11b
1782 9 RD2RD = 2cycle-1 = 1b
1783 8-7 THZP = 3cycle-1 = 10b
1784 6-5 TWR = 2cycle-1 = 01b (tWR = 17ns)
1785 4 TRRD = 2cycle = 0b (tRRD = 14ns)
1786 3-1 TRAS = 5cycle-1 = 100b (Tras=42ns)
1787 1 CAS latency = 3cyc = 1b
1788 (for Micron 2M32-7 operating at 100MHz)
1789 */
1858 boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMEXT, 1790 boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMEXT,
1859 0x001BDF29); 1791 0x001BDF29);
1792
1793 /* EMIF SDRAM control - set up for a 2Mx32 SDRAM (512x32x4 bank)
1794 31 - 0b -
1795 30 SDBSZ 1b 4 bank
1796 29..28 SDRSZ 00b 11 row address pins
1797
1798 27..26 SDCSZ 01b 8 column address pins
1799 25 RFEN 1b refersh enabled
1800 24 INIT 1b init SDRAM!
1801
1802 23..20 TRCD 0001b (Trcd/Tcyc)-1 = (20/10)-1 = 1
1803
1804 19..16 TRP 0001b (Trp/Tcyc)-1 = (20/10)-1 = 1
1805
1806 15..12 TRC 0110b (Trc/Tcyc)-1 = (70/10)-1 = 6
1807
1808 11..0 - 0000b 0000b 0000b
1809 */
1860 boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMCTL, 1810 boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMCTL,
1861 0x47117000); 1811 0x47116000);
1812
1813 /* SDRAM refresh timing
1814 Need 4,096 refresh cycles every 64ms = 15.625us = 1562cycles of 100MHz = 0x61A
1815 */
1862 boot_loader_write_mem32(pao, dsp_index, 1816 boot_loader_write_mem32(pao, dsp_index,
1863 C6713_EMIF_SDRAMTIMING, 0x00000410); 1817 C6713_EMIF_SDRAMTIMING, 0x00000410);
1864 1818
1865 hpios_delay_micro_seconds(1000); 1819 hpios_delay_micro_seconds(1000);
1866 } else if (dsp_index == 2) { 1820 } else if (dsp_index == 2) {
1867 /* DSP 2 is a C6713 */ 1821 /* DSP 2 is a C6713 */
1822 }
1868 1823
1869 } else 1824 return 0;
1870 err = hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX);
1871 return err;
1872} 1825}
1873 1826
1874static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index, 1827static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index,
@@ -1894,7 +1847,7 @@ static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index,
1894 test_addr); 1847 test_addr);
1895 if (data != test_data) { 1848 if (data != test_data) {
1896 HPI_DEBUG_LOG(VERBOSE, 1849 HPI_DEBUG_LOG(VERBOSE,
1897 "memtest error details " 1850 "Memtest error details "
1898 "%08x %08x %08x %i\n", test_addr, 1851 "%08x %08x %08x %i\n", test_addr,
1899 test_data, data, dsp_index); 1852 test_data, data, dsp_index);
1900 return 1; /* error */ 1853 return 1; /* error */
@@ -1914,7 +1867,7 @@ static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index,
1914 data = boot_loader_read_mem32(pao, dsp_index, test_addr); 1867 data = boot_loader_read_mem32(pao, dsp_index, test_addr);
1915 if (data != test_data) { 1868 if (data != test_data) {
1916 HPI_DEBUG_LOG(VERBOSE, 1869 HPI_DEBUG_LOG(VERBOSE,
1917 "memtest error details " 1870 "Memtest error details "
1918 "%08x %08x %08x %i\n", test_addr, test_data, 1871 "%08x %08x %08x %i\n", test_addr, test_data,
1919 data, dsp_index); 1872 data, dsp_index);
1920 return 1; /* error */ 1873 return 1; /* error */
@@ -1944,8 +1897,8 @@ static u16 boot_loader_test_internal_memory(struct hpi_adapter_obj *pao,
1944 /* 64K data mem */ 1897 /* 64K data mem */
1945 err = boot_loader_test_memory(pao, dsp_index, 1898 err = boot_loader_test_memory(pao, dsp_index,
1946 0x80000000, 0x10000); 1899 0x80000000, 0x10000);
1947 } else if ((dsp_index == 1) || (dsp_index == 2)) { 1900 } else if (dsp_index == 1) {
1948 /* DSP 1&2 are a C6713 */ 1901 /* DSP 1 is a C6713 */
1949 /* 192K internal mem */ 1902 /* 192K internal mem */
1950 err = boot_loader_test_memory(pao, dsp_index, 0x00000000, 1903 err = boot_loader_test_memory(pao, dsp_index, 0x00000000,
1951 0x30000); 1904 0x30000);
@@ -1953,11 +1906,10 @@ static u16 boot_loader_test_internal_memory(struct hpi_adapter_obj *pao,
1953 /* 64K internal mem / L2 cache */ 1906 /* 64K internal mem / L2 cache */
1954 err = boot_loader_test_memory(pao, dsp_index, 1907 err = boot_loader_test_memory(pao, dsp_index,
1955 0x00030000, 0x10000); 1908 0x00030000, 0x10000);
1956 } else 1909 }
1957 return hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX);
1958 1910
1959 if (err) 1911 if (err)
1960 return hpi6205_error(dsp_index, HPI6205_ERROR_DSP_INTMEM); 1912 return HPI6205_ERROR_DSP_INTMEM;
1961 else 1913 else
1962 return 0; 1914 return 0;
1963} 1915}
@@ -1970,24 +1922,23 @@ static u16 boot_loader_test_external_memory(struct hpi_adapter_obj *pao,
1970 1922
1971 if (dsp_index == 0) { 1923 if (dsp_index == 0) {
1972 /* only test for SDRAM if an ASI5000 card */ 1924 /* only test for SDRAM if an ASI5000 card */
1973 if (pao->pci.subsys_device_id == 0x5000) { 1925 if (pao->pci.pci_dev->subsystem_device == 0x5000) {
1974 /* DSP 0 is always C6205 */ 1926 /* DSP 0 is always C6205 */
1975 dRAM_start_address = 0x00400000; 1927 dRAM_start_address = 0x00400000;
1976 dRAM_size = 0x200000; 1928 dRAM_size = 0x200000;
1977 /*dwDRAMinc=1024; */ 1929 /*dwDRAMinc=1024; */
1978 } else 1930 } else
1979 return 0; 1931 return 0;
1980 } else if ((dsp_index == 1) || (dsp_index == 2)) { 1932 } else if (dsp_index == 1) {
1981 /* DSP 1 is a C6713 */ 1933 /* DSP 1 is a C6713 */
1982 dRAM_start_address = 0x80000000; 1934 dRAM_start_address = 0x80000000;
1983 dRAM_size = 0x200000; 1935 dRAM_size = 0x200000;
1984 /*dwDRAMinc=1024; */ 1936 /*dwDRAMinc=1024; */
1985 } else 1937 }
1986 return hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX);
1987 1938
1988 if (boot_loader_test_memory(pao, dsp_index, dRAM_start_address, 1939 if (boot_loader_test_memory(pao, dsp_index, dRAM_start_address,
1989 dRAM_size)) 1940 dRAM_size))
1990 return hpi6205_error(dsp_index, HPI6205_ERROR_DSP_EXTMEM); 1941 return HPI6205_ERROR_DSP_EXTMEM;
1991 return 0; 1942 return 0;
1992} 1943}
1993 1944
@@ -1996,28 +1947,25 @@ static u16 boot_loader_test_pld(struct hpi_adapter_obj *pao, int dsp_index)
1996 u32 data = 0; 1947 u32 data = 0;
1997 if (dsp_index == 0) { 1948 if (dsp_index == 0) {
1998 /* only test for DSP0 PLD on ASI5000 card */ 1949 /* only test for DSP0 PLD on ASI5000 card */
1999 if (pao->pci.subsys_device_id == 0x5000) { 1950 if (pao->pci.pci_dev->subsystem_device == 0x5000) {
2000 /* PLD is located at CE3=0x03000000 */ 1951 /* PLD is located at CE3=0x03000000 */
2001 data = boot_loader_read_mem32(pao, dsp_index, 1952 data = boot_loader_read_mem32(pao, dsp_index,
2002 0x03000008); 1953 0x03000008);
2003 if ((data & 0xF) != 0x5) 1954 if ((data & 0xF) != 0x5)
2004 return hpi6205_error(dsp_index, 1955 return HPI6205_ERROR_DSP_PLD;
2005 HPI6205_ERROR_DSP_PLD);
2006 data = boot_loader_read_mem32(pao, dsp_index, 1956 data = boot_loader_read_mem32(pao, dsp_index,
2007 0x0300000C); 1957 0x0300000C);
2008 if ((data & 0xF) != 0xA) 1958 if ((data & 0xF) != 0xA)
2009 return hpi6205_error(dsp_index, 1959 return HPI6205_ERROR_DSP_PLD;
2010 HPI6205_ERROR_DSP_PLD);
2011 } 1960 }
2012 } else if (dsp_index == 1) { 1961 } else if (dsp_index == 1) {
2013 /* DSP 1 is a C6713 */ 1962 /* DSP 1 is a C6713 */
2014 if (pao->pci.subsys_device_id == 0x8700) { 1963 if (pao->pci.pci_dev->subsystem_device == 0x8700) {
2015 /* PLD is located at CE1=0x90000000 */ 1964 /* PLD is located at CE1=0x90000000 */
2016 data = boot_loader_read_mem32(pao, dsp_index, 1965 data = boot_loader_read_mem32(pao, dsp_index,
2017 0x90000010); 1966 0x90000010);
2018 if ((data & 0xFF) != 0xAA) 1967 if ((data & 0xFF) != 0xAA)
2019 return hpi6205_error(dsp_index, 1968 return HPI6205_ERROR_DSP_PLD;
2020 HPI6205_ERROR_DSP_PLD);
2021 /* 8713 - LED on */ 1969 /* 8713 - LED on */
2022 boot_loader_write_mem32(pao, dsp_index, 0x90000000, 1970 boot_loader_write_mem32(pao, dsp_index, 0x90000000,
2023 0x02); 1971 0x02);
@@ -2035,14 +1983,11 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data,
2035 struct hpi_hw_obj *phw = pao->priv; 1983 struct hpi_hw_obj *phw = pao->priv;
2036 u32 data_transferred = 0; 1984 u32 data_transferred = 0;
2037 u16 err = 0; 1985 u16 err = 0;
2038#ifndef HPI6205_NO_HSR_POLL
2039 u32 time_out;
2040#endif
2041 u32 temp2; 1986 u32 temp2;
2042 struct bus_master_interface *interface = phw->p_interface_buffer; 1987 struct bus_master_interface *interface = phw->p_interface_buffer;
2043 1988
2044 if (!p_data) 1989 if (!p_data)
2045 return HPI_ERROR_INVALID_DATA_TRANSFER; 1990 return HPI_ERROR_INVALID_DATA_POINTER;
2046 1991
2047 data_size &= ~3L; /* round data_size down to nearest 4 bytes */ 1992 data_size &= ~3L; /* round data_size down to nearest 4 bytes */
2048 1993
@@ -2062,14 +2007,10 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data,
2062 2007
2063 interface->transfer_size_in_bytes = this_copy; 2008 interface->transfer_size_in_bytes = this_copy;
2064 2009
2065#ifdef HPI6205_NO_HSR_POLL
2066 /* DSP must change this back to nOperation */ 2010 /* DSP must change this back to nOperation */
2067 interface->dsp_ack = H620_HIF_IDLE; 2011 interface->dsp_ack = H620_HIF_IDLE;
2068#endif
2069
2070 send_dsp_command(phw, operation); 2012 send_dsp_command(phw, operation);
2071 2013
2072#ifdef HPI6205_NO_HSR_POLL
2073 temp2 = wait_dsp_ack(phw, operation, HPI6205_TIMEOUT); 2014 temp2 = wait_dsp_ack(phw, operation, HPI6205_TIMEOUT);
2074 HPI_DEBUG_LOG(DEBUG, "spun %d times for data xfer of %d\n", 2015 HPI_DEBUG_LOG(DEBUG, "spun %d times for data xfer of %d\n",
2075 HPI6205_TIMEOUT - temp2, this_copy); 2016 HPI6205_TIMEOUT - temp2, this_copy);
@@ -2077,45 +2018,11 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data,
2077 if (!temp2) { 2018 if (!temp2) {
2078 /* timed out */ 2019 /* timed out */
2079 HPI_DEBUG_LOG(ERROR, 2020 HPI_DEBUG_LOG(ERROR,
2080 "timed out waiting for " "state %d got %d\n", 2021 "Timed out waiting for " "state %d got %d\n",
2081 operation, interface->dsp_ack); 2022 operation, interface->dsp_ack);
2082 2023
2083 break; 2024 break;
2084 } 2025 }
2085#else
2086 /* spin waiting on the result */
2087 time_out = HPI6205_TIMEOUT;
2088 temp2 = 0;
2089 while ((temp2 == 0) && time_out--) {
2090 /* give 16k bus mastering transfer time to happen */
2091 /*(16k / 132Mbytes/s = 122usec) */
2092 hpios_delay_micro_seconds(20);
2093 temp2 = ioread32(phw->prHSR);
2094 temp2 &= C6205_HSR_INTSRC;
2095 }
2096 HPI_DEBUG_LOG(DEBUG, "spun %d times for data xfer of %d\n",
2097 HPI6205_TIMEOUT - time_out, this_copy);
2098 if (temp2 == C6205_HSR_INTSRC) {
2099 HPI_DEBUG_LOG(VERBOSE,
2100 "interrupt from HIF <data> OK\n");
2101 /*
2102 if(interface->dwDspAck != nOperation) {
2103 HPI_DEBUG_LOG(DEBUG("interface->dwDspAck=%d,
2104 expected %d \n",
2105 interface->dwDspAck,nOperation);
2106 }
2107 */
2108 }
2109/* need to handle this differently... */
2110 else {
2111 HPI_DEBUG_LOG(ERROR,
2112 "interrupt from HIF <data> BAD\n");
2113 err = HPI_ERROR_DSP_HARDWARE;
2114 }
2115
2116 /* reset the interrupt from the DSP */
2117 iowrite32(C6205_HSR_INTSRC, phw->prHSR);
2118#endif
2119 if (operation == H620_HIF_GET_DATA) 2026 if (operation == H620_HIF_GET_DATA)
2120 memcpy(&p_data[data_transferred], 2027 memcpy(&p_data[data_transferred],
2121 (void *)&interface->u.b_data[0], this_copy); 2028 (void *)&interface->u.b_data[0], this_copy);
@@ -2154,7 +2061,6 @@ static int wait_dsp_ack(struct hpi_hw_obj *phw, int state, int timeout_us)
2154static void send_dsp_command(struct hpi_hw_obj *phw, int cmd) 2061static void send_dsp_command(struct hpi_hw_obj *phw, int cmd)
2155{ 2062{
2156 struct bus_master_interface *interface = phw->p_interface_buffer; 2063 struct bus_master_interface *interface = phw->p_interface_buffer;
2157
2158 u32 r; 2064 u32 r;
2159 2065
2160 interface->host_cmd = cmd; 2066 interface->host_cmd = cmd;
@@ -2172,31 +2078,39 @@ static unsigned int message_count;
2172static u16 message_response_sequence(struct hpi_adapter_obj *pao, 2078static u16 message_response_sequence(struct hpi_adapter_obj *pao,
2173 struct hpi_message *phm, struct hpi_response *phr) 2079 struct hpi_message *phm, struct hpi_response *phr)
2174{ 2080{
2175#ifndef HPI6205_NO_HSR_POLL
2176 u32 temp2;
2177#endif
2178 u32 time_out, time_out2; 2081 u32 time_out, time_out2;
2179 struct hpi_hw_obj *phw = pao->priv; 2082 struct hpi_hw_obj *phw = pao->priv;
2180 struct bus_master_interface *interface = phw->p_interface_buffer; 2083 struct bus_master_interface *interface = phw->p_interface_buffer;
2181 u16 err = 0; 2084 u16 err = 0;
2182 2085
2183 message_count++; 2086 message_count++;
2087 if (phm->size > sizeof(interface->u)) {
2088 phr->error = HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL;
2089 phr->specific_error = sizeof(interface->u);
2090 phr->size = sizeof(struct hpi_response_header);
2091 HPI_DEBUG_LOG(ERROR,
2092 "message len %d too big for buffer %zd \n", phm->size,
2093 sizeof(interface->u));
2094 return 0;
2095 }
2096
2184 /* Assume buffer of type struct bus_master_interface 2097 /* Assume buffer of type struct bus_master_interface
2185 is allocated "noncacheable" */ 2098 is allocated "noncacheable" */
2186 2099
2187 if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) { 2100 if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) {
2188 HPI_DEBUG_LOG(DEBUG, "timeout waiting for idle\n"); 2101 HPI_DEBUG_LOG(DEBUG, "timeout waiting for idle\n");
2189 return hpi6205_error(0, HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT); 2102 return HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT;
2190 } 2103 }
2191 interface->u.message_buffer = *phm; 2104
2105 memcpy(&interface->u.message_buffer, phm, phm->size);
2192 /* signal we want a response */ 2106 /* signal we want a response */
2193 send_dsp_command(phw, H620_HIF_GET_RESP); 2107 send_dsp_command(phw, H620_HIF_GET_RESP);
2194 2108
2195 time_out2 = wait_dsp_ack(phw, H620_HIF_GET_RESP, HPI6205_TIMEOUT); 2109 time_out2 = wait_dsp_ack(phw, H620_HIF_GET_RESP, HPI6205_TIMEOUT);
2196 2110
2197 if (time_out2 == 0) { 2111 if (!time_out2) {
2198 HPI_DEBUG_LOG(ERROR, 2112 HPI_DEBUG_LOG(ERROR,
2199 "(%u) timed out waiting for " "GET_RESP state [%x]\n", 2113 "(%u) Timed out waiting for " "GET_RESP state [%x]\n",
2200 message_count, interface->dsp_ack); 2114 message_count, interface->dsp_ack);
2201 } else { 2115 } else {
2202 HPI_DEBUG_LOG(VERBOSE, 2116 HPI_DEBUG_LOG(VERBOSE,
@@ -2206,58 +2120,38 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao,
2206 /* spin waiting on HIF interrupt flag (end of msg process) */ 2120 /* spin waiting on HIF interrupt flag (end of msg process) */
2207 time_out = HPI6205_TIMEOUT; 2121 time_out = HPI6205_TIMEOUT;
2208 2122
2209#ifndef HPI6205_NO_HSR_POLL 2123 /* read the result */
2210 temp2 = 0; 2124 if (time_out) {
2211 while ((temp2 == 0) && --time_out) { 2125 if (interface->u.response_buffer.size <= phr->size)
2212 temp2 = ioread32(phw->prHSR); 2126 memcpy(phr, &interface->u.response_buffer,
2213 temp2 &= C6205_HSR_INTSRC; 2127 interface->u.response_buffer.size);
2214 hpios_delay_micro_seconds(1); 2128 else {
2215 } 2129 HPI_DEBUG_LOG(ERROR,
2216 if (temp2 == C6205_HSR_INTSRC) { 2130 "response len %d too big for buffer %d\n",
2217 rmb(); /* ensure we see latest value for dsp_ack */ 2131 interface->u.response_buffer.size, phr->size);
2218 if ((interface->dsp_ack != H620_HIF_GET_RESP)) { 2132 memcpy(phr, &interface->u.response_buffer,
2219 HPI_DEBUG_LOG(DEBUG, 2133 sizeof(struct hpi_response_header));
2220 "(%u)interface->dsp_ack(0x%x) != " 2134 phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
2221 "H620_HIF_GET_RESP, t=%u\n", message_count, 2135 phr->specific_error =
2222 interface->dsp_ack, 2136 interface->u.response_buffer.size;
2223 HPI6205_TIMEOUT - time_out); 2137 phr->size = sizeof(struct hpi_response_header);
2224 } else {
2225 HPI_DEBUG_LOG(VERBOSE,
2226 "(%u)int with GET_RESP after %u\n",
2227 message_count, HPI6205_TIMEOUT - time_out);
2228 } 2138 }
2229
2230 } else {
2231 /* can we do anything else in response to the error ? */
2232 HPI_DEBUG_LOG(ERROR,
2233 "interrupt from HIF module BAD (function %x)\n",
2234 phm->function);
2235 } 2139 }
2236
2237 /* reset the interrupt from the DSP */
2238 iowrite32(C6205_HSR_INTSRC, phw->prHSR);
2239#endif
2240
2241 /* read the result */
2242 if (time_out != 0)
2243 *phr = interface->u.response_buffer;
2244
2245 /* set interface back to idle */ 2140 /* set interface back to idle */
2246 send_dsp_command(phw, H620_HIF_IDLE); 2141 send_dsp_command(phw, H620_HIF_IDLE);
2247 2142
2248 if ((time_out == 0) || (time_out2 == 0)) { 2143 if (!time_out || !time_out2) {
2249 HPI_DEBUG_LOG(DEBUG, "something timed out!\n"); 2144 HPI_DEBUG_LOG(DEBUG, "something timed out!\n");
2250 return hpi6205_error(0, HPI6205_ERROR_MSG_RESP_TIMEOUT); 2145 return HPI6205_ERROR_MSG_RESP_TIMEOUT;
2251 } 2146 }
2252 /* special case for adapter close - */ 2147 /* special case for adapter close - */
2253 /* wait for the DSP to indicate it is idle */ 2148 /* wait for the DSP to indicate it is idle */
2254 if (phm->function == HPI_ADAPTER_CLOSE) { 2149 if (phm->function == HPI_ADAPTER_CLOSE) {
2255 if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) { 2150 if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) {
2256 HPI_DEBUG_LOG(DEBUG, 2151 HPI_DEBUG_LOG(DEBUG,
2257 "timeout waiting for idle " 2152 "Timeout waiting for idle "
2258 "(on adapter_close)\n"); 2153 "(on adapter_close)\n");
2259 return hpi6205_error(0, 2154 return HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT;
2260 HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT);
2261 } 2155 }
2262 } 2156 }
2263 err = hpi_validate_response(phm, phr); 2157 err = hpi_validate_response(phm, phr);
@@ -2277,7 +2171,13 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm,
2277 /* maybe an error response */ 2171 /* maybe an error response */
2278 if (err) { 2172 if (err) {
2279 /* something failed in the HPI/DSP interface */ 2173 /* something failed in the HPI/DSP interface */
2280 phr->error = err; 2174 if (err >= HPI_ERROR_BACKEND_BASE) {
2175 phr->error = HPI_ERROR_DSP_COMMUNICATION;
2176 phr->specific_error = err;
2177 } else {
2178 phr->error = err;
2179 }
2180
2281 pao->dsp_crashed++; 2181 pao->dsp_crashed++;
2282 2182
2283 /* just the header of the response is valid */ 2183 /* just the header of the response is valid */
diff --git a/sound/pci/asihpi/hpi6205.h b/sound/pci/asihpi/hpi6205.h
index 1adae0857cda..df2f02c0c7b4 100644
--- a/sound/pci/asihpi/hpi6205.h
+++ b/sound/pci/asihpi/hpi6205.h
@@ -25,9 +25,6 @@ Copyright AudioScience, Inc., 2003
25#ifndef _HPI6205_H_ 25#ifndef _HPI6205_H_
26#define _HPI6205_H_ 26#define _HPI6205_H_
27 27
28/* transitional conditional compile shared between host and DSP */
29/* #define HPI6205_NO_HSR_POLL */
30
31#include "hpi_internal.h" 28#include "hpi_internal.h"
32 29
33/*********************************************************** 30/***********************************************************
@@ -78,8 +75,8 @@ struct bus_master_interface {
78 u32 dsp_ack; 75 u32 dsp_ack;
79 u32 transfer_size_in_bytes; 76 u32 transfer_size_in_bytes;
80 union { 77 union {
81 struct hpi_message message_buffer; 78 struct hpi_message_header message_buffer;
82 struct hpi_response response_buffer; 79 struct hpi_response_header response_buffer;
83 u8 b_data[HPI6205_SIZEOF_DATA]; 80 u8 b_data[HPI6205_SIZEOF_DATA];
84 } u; 81 } u;
85 struct controlcache_6205 control_cache; 82 struct controlcache_6205 control_cache;
diff --git a/sound/pci/asihpi/hpi_internal.h b/sound/pci/asihpi/hpi_internal.h
index 16f502d459de..bf5eced76bac 100644
--- a/sound/pci/asihpi/hpi_internal.h
+++ b/sound/pci/asihpi/hpi_internal.h
@@ -28,7 +28,7 @@ HPI internal definitions
28/** maximum number of memory regions mapped to an adapter */ 28/** maximum number of memory regions mapped to an adapter */
29#define HPI_MAX_ADAPTER_MEM_SPACES (2) 29#define HPI_MAX_ADAPTER_MEM_SPACES (2)
30 30
31/* Each OS needs its own hpios.h, or specific define as above */ 31/* Each OS needs its own hpios.h */
32#include "hpios.h" 32#include "hpios.h"
33 33
34/* physical memory allocation */ 34/* physical memory allocation */
@@ -49,7 +49,7 @@ HpiOs_LockedMem_GetPyhsAddr() will always succed on the returned handle.
49*/ 49*/
50u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_locked_mem_handle, 50u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_locked_mem_handle,
51 /**< memory handle */ 51 /**< memory handle */
52 u32 size, /**< size in bytes to allocate */ 52 u32 size, /**< Size in bytes to allocate */
53 struct pci_dev *p_os_reference 53 struct pci_dev *p_os_reference
54 /**< OS specific data required for memory allocation */ 54 /**< OS specific data required for memory allocation */
55 ); 55 );
@@ -96,41 +96,6 @@ typedef void hpi_handler_func(struct hpi_message *, struct hpi_response *);
96#define compile_time_assert(cond, msg) \ 96#define compile_time_assert(cond, msg) \
97 typedef char ASSERT_##msg[(cond) ? 1 : -1] 97 typedef char ASSERT_##msg[(cond) ? 1 : -1]
98 98
99/*/////////////////////////////////////////////////////////////////////////// */
100/* Private HPI Entity related definitions */
101
102#define STR_SIZE_FIELD_MAX 65535U
103#define STR_TYPE_FIELD_MAX 255U
104#define STR_ROLE_FIELD_MAX 255U
105
106struct hpi_entity_str {
107 u16 size;
108 u8 type;
109 u8 role;
110};
111
112#if defined(_MSC_VER)
113#pragma warning(push)
114#pragma warning(disable : 4200)
115#endif
116
117struct hpi_entity {
118 struct hpi_entity_str header;
119#if ! defined(HPI_OS_DSP_C6000) || (defined(HPI_OS_DSP_C6000) && (__TI_COMPILER_VERSION__ > 6000008))
120 /* DSP C6000 compiler v6.0.8 and lower
121 do not support flexible array member */
122 u8 value[];
123#else
124 /* NOTE! Using sizeof(struct hpi_entity) will give erroneous results */
125#define HPI_INTERNAL_WARN_ABOUT_ENTITY_VALUE
126 u8 value[1];
127#endif
128};
129
130#if defined(_MSC_VER)
131#pragma warning(pop)
132#endif
133
134/******************************************* bus types */ 99/******************************************* bus types */
135enum HPI_BUSES { 100enum HPI_BUSES {
136 HPI_BUS_ISAPNP = 1, 101 HPI_BUS_ISAPNP = 1,
@@ -139,206 +104,155 @@ enum HPI_BUSES {
139 HPI_BUS_NET = 4 104 HPI_BUS_NET = 4
140}; 105};
141 106
107enum HPI_SUBSYS_OPTIONS {
108 /* 0, 256 are invalid, 1..255 reserved for global options */
109 HPI_SUBSYS_OPT_NET_ENABLE = 257,
110 HPI_SUBSYS_OPT_NET_BROADCAST = 258,
111 HPI_SUBSYS_OPT_NET_UNICAST = 259,
112 HPI_SUBSYS_OPT_NET_ADDR = 260,
113 HPI_SUBSYS_OPT_NET_MASK = 261,
114 HPI_SUBSYS_OPT_NET_ADAPTER_ADDRESS_ADD = 262
115};
116
117/** Volume flags
118*/
119enum HPI_VOLUME_FLAGS {
120 /** Set if the volume control is muted */
121 HPI_VOLUME_FLAG_MUTED = (1 << 0),
122 /** Set if the volume control has a mute function */
123 HPI_VOLUME_FLAG_HAS_MUTE = (1 << 1),
124 /** Set if volume control can do autofading */
125 HPI_VOLUME_FLAG_HAS_AUTOFADE = (1 << 2)
126 /* Note Flags >= (1<<8) are for DSP internal use only */
127};
128
142/******************************************* CONTROL ATTRIBUTES ****/ 129/******************************************* CONTROL ATTRIBUTES ****/
143/* (in order of control type ID */ 130/* (in order of control type ID */
144 131
145/* This allows for 255 control types, 256 unique attributes each */ 132/* This allows for 255 control types, 256 unique attributes each */
146#define HPI_CTL_ATTR(ctl, ai) (HPI_CONTROL_##ctl * 0x100 + ai) 133#define HPI_CTL_ATTR(ctl, ai) ((HPI_CONTROL_##ctl << 8) + ai)
147 134
148/* Get the sub-index of the attribute for a control type */ 135/* Get the sub-index of the attribute for a control type */
149#define HPI_CTL_ATTR_INDEX(i) (i&0xff) 136#define HPI_CTL_ATTR_INDEX(i) (i & 0xff)
150 137
151/* Extract the control from the control attribute */ 138/* Extract the control from the control attribute */
152#define HPI_CTL_ATTR_CONTROL(i) (i>>8) 139#define HPI_CTL_ATTR_CONTROL(i) (i >> 8)
153
154/* Generic control attributes. */
155
156/** Enable a control.
1570=disable, 1=enable
158\note generic to all mixer plugins?
159*/
160#define HPI_GENERIC_ENABLE HPI_CTL_ATTR(GENERIC, 1)
161 140
162/** Enable event generation for a control. 141/** Enable event generation for a control.
1630=disable, 1=enable 1420=disable, 1=enable
164\note generic to all controls that can generate events 143\note generic to all controls that can generate events
165*/ 144*/
166#define HPI_GENERIC_EVENT_ENABLE HPI_CTL_ATTR(GENERIC, 2) 145
167 146/** Unique identifiers for every control attribute
168/* Volume Control attributes */
169#define HPI_VOLUME_GAIN HPI_CTL_ATTR(VOLUME, 1)
170#define HPI_VOLUME_AUTOFADE HPI_CTL_ATTR(VOLUME, 2)
171
172/** For HPI_ControlQuery() to get the number of channels of a volume control*/
173#define HPI_VOLUME_NUM_CHANNELS HPI_CTL_ATTR(VOLUME, 6)
174#define HPI_VOLUME_RANGE HPI_CTL_ATTR(VOLUME, 10)
175
176/** Level Control attributes */
177#define HPI_LEVEL_GAIN HPI_CTL_ATTR(LEVEL, 1)
178#define HPI_LEVEL_RANGE HPI_CTL_ATTR(LEVEL, 10)
179
180/* Meter Control attributes */
181/** return RMS signal level */
182#define HPI_METER_RMS HPI_CTL_ATTR(METER, 1)
183/** return peak signal level */
184#define HPI_METER_PEAK HPI_CTL_ATTR(METER, 2)
185/** ballistics for ALL rms meters on adapter */
186#define HPI_METER_RMS_BALLISTICS HPI_CTL_ATTR(METER, 3)
187/** ballistics for ALL peak meters on adapter */
188#define HPI_METER_PEAK_BALLISTICS HPI_CTL_ATTR(METER, 4)
189
190/** For HPI_ControlQuery() to get the number of channels of a meter control*/
191#define HPI_METER_NUM_CHANNELS HPI_CTL_ATTR(METER, 5)
192
193/* Multiplexer control attributes */
194#define HPI_MULTIPLEXER_SOURCE HPI_CTL_ATTR(MULTIPLEXER, 1)
195#define HPI_MULTIPLEXER_QUERYSOURCE HPI_CTL_ATTR(MULTIPLEXER, 2)
196
197/** AES/EBU transmitter control attributes */
198/** AESEBU or SPDIF */
199#define HPI_AESEBUTX_FORMAT HPI_CTL_ATTR(AESEBUTX, 1)
200#define HPI_AESEBUTX_SAMPLERATE HPI_CTL_ATTR(AESEBUTX, 3)
201#define HPI_AESEBUTX_CHANNELSTATUS HPI_CTL_ATTR(AESEBUTX, 4)
202#define HPI_AESEBUTX_USERDATA HPI_CTL_ATTR(AESEBUTX, 5)
203
204/** AES/EBU receiver control attributes */
205#define HPI_AESEBURX_FORMAT HPI_CTL_ATTR(AESEBURX, 1)
206#define HPI_AESEBURX_ERRORSTATUS HPI_CTL_ATTR(AESEBURX, 2)
207#define HPI_AESEBURX_SAMPLERATE HPI_CTL_ATTR(AESEBURX, 3)
208#define HPI_AESEBURX_CHANNELSTATUS HPI_CTL_ATTR(AESEBURX, 4)
209#define HPI_AESEBURX_USERDATA HPI_CTL_ATTR(AESEBURX, 5)
210
211/** \defgroup tuner_defs Tuners
212\{
213*/
214/** \defgroup tuner_attrs Tuner control attributes
215\{
216*/
217#define HPI_TUNER_BAND HPI_CTL_ATTR(TUNER, 1)
218#define HPI_TUNER_FREQ HPI_CTL_ATTR(TUNER, 2)
219#define HPI_TUNER_LEVEL HPI_CTL_ATTR(TUNER, 3)
220#define HPI_TUNER_AUDIOMUTE HPI_CTL_ATTR(TUNER, 4)
221/* use TUNER_STATUS instead */
222#define HPI_TUNER_VIDEO_STATUS HPI_CTL_ATTR(TUNER, 5)
223#define HPI_TUNER_GAIN HPI_CTL_ATTR(TUNER, 6)
224#define HPI_TUNER_STATUS HPI_CTL_ATTR(TUNER, 7)
225#define HPI_TUNER_MODE HPI_CTL_ATTR(TUNER, 8)
226/** RDS data. */
227#define HPI_TUNER_RDS HPI_CTL_ATTR(TUNER, 9)
228/** Audio pre-emphasis. */
229#define HPI_TUNER_DEEMPHASIS HPI_CTL_ATTR(TUNER, 10)
230/** HD Radio tuner program control. */
231#define HPI_TUNER_PROGRAM HPI_CTL_ATTR(TUNER, 11)
232/** HD Radio tuner digital signal quality. */
233#define HPI_TUNER_HDRADIO_SIGNAL_QUALITY HPI_CTL_ATTR(TUNER, 12)
234/** HD Radio SDK firmware version. */
235#define HPI_TUNER_HDRADIO_SDK_VERSION HPI_CTL_ATTR(TUNER, 13)
236/** HD Radio DSP firmware version. */
237#define HPI_TUNER_HDRADIO_DSP_VERSION HPI_CTL_ATTR(TUNER, 14)
238/** HD Radio signal blend (force analog, or automatic). */
239#define HPI_TUNER_HDRADIO_BLEND HPI_CTL_ATTR(TUNER, 15)
240
241/** \} */
242
243/** \defgroup pads_attrs Tuner PADs control attributes
244\{
245*/
246/** The text string containing the station/channel combination. */
247#define HPI_PAD_CHANNEL_NAME HPI_CTL_ATTR(PAD, 1)
248/** The text string containing the artist. */
249#define HPI_PAD_ARTIST HPI_CTL_ATTR(PAD, 2)
250/** The text string containing the title. */
251#define HPI_PAD_TITLE HPI_CTL_ATTR(PAD, 3)
252/** The text string containing the comment. */
253#define HPI_PAD_COMMENT HPI_CTL_ATTR(PAD, 4)
254/** The integer containing the PTY code. */
255#define HPI_PAD_PROGRAM_TYPE HPI_CTL_ATTR(PAD, 5)
256/** The integer containing the program identification. */
257#define HPI_PAD_PROGRAM_ID HPI_CTL_ATTR(PAD, 6)
258/** The integer containing whether traffic information is supported.
259Contains either 1 or 0. */
260#define HPI_PAD_TA_SUPPORT HPI_CTL_ATTR(PAD, 7)
261/** The integer containing whether traffic announcement is in progress.
262Contains either 1 or 0. */
263#define HPI_PAD_TA_ACTIVE HPI_CTL_ATTR(PAD, 8)
264/** \} */
265/** \} */
266
267/* VOX control attributes */
268#define HPI_VOX_THRESHOLD HPI_CTL_ATTR(VOX, 1)
269
270/*?? channel mode used hpi_multiplexer_source attribute == 1 */
271#define HPI_CHANNEL_MODE_MODE HPI_CTL_ATTR(CHANNEL_MODE, 1)
272
273/** \defgroup channel_modes Channel Modes
274Used for HPI_ChannelModeSet/Get()
275\{
276*/ 147*/
277/** Left channel out = left channel in, Right channel out = right channel in. */ 148enum HPI_CONTROL_ATTRIBUTES {
278#define HPI_CHANNEL_MODE_NORMAL 1 149 HPI_GENERIC_ENABLE = HPI_CTL_ATTR(GENERIC, 1),
279/** Left channel out = right channel in, Right channel out = left channel in. */ 150 HPI_GENERIC_EVENT_ENABLE = HPI_CTL_ATTR(GENERIC, 2),
280#define HPI_CHANNEL_MODE_SWAP 2 151
281/** Left channel out = left channel in, Right channel out = left channel in. */ 152 HPI_VOLUME_GAIN = HPI_CTL_ATTR(VOLUME, 1),
282#define HPI_CHANNEL_MODE_LEFT_TO_STEREO 3 153 HPI_VOLUME_AUTOFADE = HPI_CTL_ATTR(VOLUME, 2),
283/** Left channel out = right channel in, Right channel out = right channel in.*/ 154 HPI_VOLUME_MUTE = HPI_CTL_ATTR(VOLUME, 3),
284#define HPI_CHANNEL_MODE_RIGHT_TO_STEREO 4 155 HPI_VOLUME_GAIN_AND_FLAGS = HPI_CTL_ATTR(VOLUME, 4),
285/** Left channel out = (left channel in + right channel in)/2, 156 HPI_VOLUME_NUM_CHANNELS = HPI_CTL_ATTR(VOLUME, 6),
286 Right channel out = mute. */ 157 HPI_VOLUME_RANGE = HPI_CTL_ATTR(VOLUME, 10),
287#define HPI_CHANNEL_MODE_STEREO_TO_LEFT 5 158
288/** Left channel out = mute, 159 HPI_METER_RMS = HPI_CTL_ATTR(METER, 1),
289 Right channel out = (right channel in + left channel in)/2. */ 160 HPI_METER_PEAK = HPI_CTL_ATTR(METER, 2),
290#define HPI_CHANNEL_MODE_STEREO_TO_RIGHT 6 161 HPI_METER_RMS_BALLISTICS = HPI_CTL_ATTR(METER, 3),
291#define HPI_CHANNEL_MODE_LAST 6 162 HPI_METER_PEAK_BALLISTICS = HPI_CTL_ATTR(METER, 4),
292/** \} */ 163 HPI_METER_NUM_CHANNELS = HPI_CTL_ATTR(METER, 5),
293 164
294/* Bitstream control set attributes */ 165 HPI_MULTIPLEXER_SOURCE = HPI_CTL_ATTR(MULTIPLEXER, 1),
295#define HPI_BITSTREAM_DATA_POLARITY HPI_CTL_ATTR(BITSTREAM, 1) 166 HPI_MULTIPLEXER_QUERYSOURCE = HPI_CTL_ATTR(MULTIPLEXER, 2),
296#define HPI_BITSTREAM_CLOCK_EDGE HPI_CTL_ATTR(BITSTREAM, 2) 167
297#define HPI_BITSTREAM_CLOCK_SOURCE HPI_CTL_ATTR(BITSTREAM, 3) 168 HPI_AESEBUTX_FORMAT = HPI_CTL_ATTR(AESEBUTX, 1),
169 HPI_AESEBUTX_SAMPLERATE = HPI_CTL_ATTR(AESEBUTX, 3),
170 HPI_AESEBUTX_CHANNELSTATUS = HPI_CTL_ATTR(AESEBUTX, 4),
171 HPI_AESEBUTX_USERDATA = HPI_CTL_ATTR(AESEBUTX, 5),
172
173 HPI_AESEBURX_FORMAT = HPI_CTL_ATTR(AESEBURX, 1),
174 HPI_AESEBURX_ERRORSTATUS = HPI_CTL_ATTR(AESEBURX, 2),
175 HPI_AESEBURX_SAMPLERATE = HPI_CTL_ATTR(AESEBURX, 3),
176 HPI_AESEBURX_CHANNELSTATUS = HPI_CTL_ATTR(AESEBURX, 4),
177 HPI_AESEBURX_USERDATA = HPI_CTL_ATTR(AESEBURX, 5),
178
179 HPI_LEVEL_GAIN = HPI_CTL_ATTR(LEVEL, 1),
180 HPI_LEVEL_RANGE = HPI_CTL_ATTR(LEVEL, 10),
181
182 HPI_TUNER_BAND = HPI_CTL_ATTR(TUNER, 1),
183 HPI_TUNER_FREQ = HPI_CTL_ATTR(TUNER, 2),
184 HPI_TUNER_LEVEL_AVG = HPI_CTL_ATTR(TUNER, 3),
185 HPI_TUNER_LEVEL_RAW = HPI_CTL_ATTR(TUNER, 4),
186 HPI_TUNER_SNR = HPI_CTL_ATTR(TUNER, 5),
187 HPI_TUNER_GAIN = HPI_CTL_ATTR(TUNER, 6),
188 HPI_TUNER_STATUS = HPI_CTL_ATTR(TUNER, 7),
189 HPI_TUNER_MODE = HPI_CTL_ATTR(TUNER, 8),
190 HPI_TUNER_RDS = HPI_CTL_ATTR(TUNER, 9),
191 HPI_TUNER_DEEMPHASIS = HPI_CTL_ATTR(TUNER, 10),
192 HPI_TUNER_PROGRAM = HPI_CTL_ATTR(TUNER, 11),
193 HPI_TUNER_HDRADIO_SIGNAL_QUALITY = HPI_CTL_ATTR(TUNER, 12),
194 HPI_TUNER_HDRADIO_SDK_VERSION = HPI_CTL_ATTR(TUNER, 13),
195 HPI_TUNER_HDRADIO_DSP_VERSION = HPI_CTL_ATTR(TUNER, 14),
196 HPI_TUNER_HDRADIO_BLEND = HPI_CTL_ATTR(TUNER, 15),
197
198 HPI_VOX_THRESHOLD = HPI_CTL_ATTR(VOX, 1),
199
200 HPI_CHANNEL_MODE_MODE = HPI_CTL_ATTR(CHANNEL_MODE, 1),
201
202 HPI_BITSTREAM_DATA_POLARITY = HPI_CTL_ATTR(BITSTREAM, 1),
203 HPI_BITSTREAM_CLOCK_EDGE = HPI_CTL_ATTR(BITSTREAM, 2),
204 HPI_BITSTREAM_CLOCK_SOURCE = HPI_CTL_ATTR(BITSTREAM, 3),
205 HPI_BITSTREAM_ACTIVITY = HPI_CTL_ATTR(BITSTREAM, 4),
206
207 HPI_SAMPLECLOCK_SOURCE = HPI_CTL_ATTR(SAMPLECLOCK, 1),
208 HPI_SAMPLECLOCK_SAMPLERATE = HPI_CTL_ATTR(SAMPLECLOCK, 2),
209 HPI_SAMPLECLOCK_SOURCE_INDEX = HPI_CTL_ATTR(SAMPLECLOCK, 3),
210 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE = HPI_CTL_ATTR(SAMPLECLOCK, 4),
211 HPI_SAMPLECLOCK_AUTO = HPI_CTL_ATTR(SAMPLECLOCK, 5),
212 HPI_SAMPLECLOCK_LOCAL_LOCK = HPI_CTL_ATTR(SAMPLECLOCK, 6),
213
214 HPI_MICROPHONE_PHANTOM_POWER = HPI_CTL_ATTR(MICROPHONE, 1),
215
216 HPI_EQUALIZER_NUM_FILTERS = HPI_CTL_ATTR(EQUALIZER, 1),
217 HPI_EQUALIZER_FILTER = HPI_CTL_ATTR(EQUALIZER, 2),
218 HPI_EQUALIZER_COEFFICIENTS = HPI_CTL_ATTR(EQUALIZER, 3),
219
220 HPI_COMPANDER_PARAMS = HPI_CTL_ATTR(COMPANDER, 1),
221 HPI_COMPANDER_MAKEUPGAIN = HPI_CTL_ATTR(COMPANDER, 2),
222 HPI_COMPANDER_THRESHOLD = HPI_CTL_ATTR(COMPANDER, 3),
223 HPI_COMPANDER_RATIO = HPI_CTL_ATTR(COMPANDER, 4),
224 HPI_COMPANDER_ATTACK = HPI_CTL_ATTR(COMPANDER, 5),
225 HPI_COMPANDER_DECAY = HPI_CTL_ATTR(COMPANDER, 6),
226
227 HPI_COBRANET_SET = HPI_CTL_ATTR(COBRANET, 1),
228 HPI_COBRANET_GET = HPI_CTL_ATTR(COBRANET, 2),
229 HPI_COBRANET_SET_DATA = HPI_CTL_ATTR(COBRANET, 3),
230 HPI_COBRANET_GET_DATA = HPI_CTL_ATTR(COBRANET, 4),
231 HPI_COBRANET_GET_STATUS = HPI_CTL_ATTR(COBRANET, 5),
232 HPI_COBRANET_SEND_PACKET = HPI_CTL_ATTR(COBRANET, 6),
233 HPI_COBRANET_GET_PACKET = HPI_CTL_ATTR(COBRANET, 7),
234
235 HPI_TONEDETECTOR_THRESHOLD = HPI_CTL_ATTR(TONEDETECTOR, 1),
236 HPI_TONEDETECTOR_STATE = HPI_CTL_ATTR(TONEDETECTOR, 2),
237 HPI_TONEDETECTOR_FREQUENCY = HPI_CTL_ATTR(TONEDETECTOR, 3),
238
239 HPI_SILENCEDETECTOR_THRESHOLD = HPI_CTL_ATTR(SILENCEDETECTOR, 1),
240 HPI_SILENCEDETECTOR_STATE = HPI_CTL_ATTR(SILENCEDETECTOR, 2),
241 HPI_SILENCEDETECTOR_DELAY = HPI_CTL_ATTR(SILENCEDETECTOR, 3),
242
243 HPI_PAD_CHANNEL_NAME = HPI_CTL_ATTR(PAD, 1),
244 HPI_PAD_ARTIST = HPI_CTL_ATTR(PAD, 2),
245 HPI_PAD_TITLE = HPI_CTL_ATTR(PAD, 3),
246 HPI_PAD_COMMENT = HPI_CTL_ATTR(PAD, 4),
247 HPI_PAD_PROGRAM_TYPE = HPI_CTL_ATTR(PAD, 5),
248 HPI_PAD_PROGRAM_ID = HPI_CTL_ATTR(PAD, 6),
249 HPI_PAD_TA_SUPPORT = HPI_CTL_ATTR(PAD, 7),
250 HPI_PAD_TA_ACTIVE = HPI_CTL_ATTR(PAD, 8)
251};
298 252
299#define HPI_POLARITY_POSITIVE 0 253#define HPI_POLARITY_POSITIVE 0
300#define HPI_POLARITY_NEGATIVE 1 254#define HPI_POLARITY_NEGATIVE 1
301 255
302/* Bitstream control get attributes */
303#define HPI_BITSTREAM_ACTIVITY 1
304
305/* SampleClock control attributes */
306#define HPI_SAMPLECLOCK_SOURCE HPI_CTL_ATTR(SAMPLECLOCK, 1)
307#define HPI_SAMPLECLOCK_SAMPLERATE HPI_CTL_ATTR(SAMPLECLOCK, 2)
308#define HPI_SAMPLECLOCK_SOURCE_INDEX HPI_CTL_ATTR(SAMPLECLOCK, 3)
309#define HPI_SAMPLECLOCK_LOCAL_SAMPLERATE\
310 HPI_CTL_ATTR(SAMPLECLOCK, 4)
311#define HPI_SAMPLECLOCK_AUTO HPI_CTL_ATTR(SAMPLECLOCK, 5)
312#define HPI_SAMPLECLOCK_LOCAL_LOCK HPI_CTL_ATTR(SAMPLECLOCK, 6)
313
314/* Microphone control attributes */
315#define HPI_MICROPHONE_PHANTOM_POWER HPI_CTL_ATTR(MICROPHONE, 1)
316
317/** Equalizer control attributes */
318/** Used to get number of filters in an EQ. (Can't set) */
319#define HPI_EQUALIZER_NUM_FILTERS HPI_CTL_ATTR(EQUALIZER, 1)
320/** Set/get the filter by type, freq, Q, gain */
321#define HPI_EQUALIZER_FILTER HPI_CTL_ATTR(EQUALIZER, 2)
322/** Get the biquad coefficients */
323#define HPI_EQUALIZER_COEFFICIENTS HPI_CTL_ATTR(EQUALIZER, 3)
324
325/* Note compander also uses HPI_GENERIC_ENABLE */
326#define HPI_COMPANDER_PARAMS HPI_CTL_ATTR(COMPANDER, 1)
327#define HPI_COMPANDER_MAKEUPGAIN HPI_CTL_ATTR(COMPANDER, 2)
328#define HPI_COMPANDER_THRESHOLD HPI_CTL_ATTR(COMPANDER, 3)
329#define HPI_COMPANDER_RATIO HPI_CTL_ATTR(COMPANDER, 4)
330#define HPI_COMPANDER_ATTACK HPI_CTL_ATTR(COMPANDER, 5)
331#define HPI_COMPANDER_DECAY HPI_CTL_ATTR(COMPANDER, 6)
332
333/* Cobranet control attributes. */
334#define HPI_COBRANET_SET HPI_CTL_ATTR(COBRANET, 1)
335#define HPI_COBRANET_GET HPI_CTL_ATTR(COBRANET, 2)
336#define HPI_COBRANET_SET_DATA HPI_CTL_ATTR(COBRANET, 3)
337#define HPI_COBRANET_GET_DATA HPI_CTL_ATTR(COBRANET, 4)
338#define HPI_COBRANET_GET_STATUS HPI_CTL_ATTR(COBRANET, 5)
339#define HPI_COBRANET_SEND_PACKET HPI_CTL_ATTR(COBRANET, 6)
340#define HPI_COBRANET_GET_PACKET HPI_CTL_ATTR(COBRANET, 7)
341
342/*------------------------------------------------------------ 256/*------------------------------------------------------------
343 Cobranet Chip Bridge - copied from HMI.H 257 Cobranet Chip Bridge - copied from HMI.H
344------------------------------------------------------------*/ 258------------------------------------------------------------*/
@@ -380,7 +294,7 @@ Used for HPI_ChannelModeSet/Get()
380 294
381/* These defines are used to fill in protocol information for an Ethernet packet 295/* These defines are used to fill in protocol information for an Ethernet packet
382 sent using HMI on CS18102 */ 296 sent using HMI on CS18102 */
383/** ID supplied by Cirrius for ASI packets. */ 297/** ID supplied by Cirrus for ASI packets. */
384#define HPI_ETHERNET_PACKET_ID 0x85 298#define HPI_ETHERNET_PACKET_ID 0x85
385/** Simple packet - no special routing required */ 299/** Simple packet - no special routing required */
386#define HPI_ETHERNET_PACKET_V1 0x01 300#define HPI_ETHERNET_PACKET_V1 0x01
@@ -393,71 +307,24 @@ Used for HPI_ChannelModeSet/Get()
393/** This packet must make its way to the host across the HPI interface */ 307/** This packet must make its way to the host across the HPI interface */
394#define HPI_ETHERNET_PACKET_HOSTED_VIA_HPI_V1 0x41 308#define HPI_ETHERNET_PACKET_HOSTED_VIA_HPI_V1 0x41
395 309
396#define HPI_ETHERNET_UDP_PORT (44600) /*!< UDP messaging port */ 310#define HPI_ETHERNET_UDP_PORT 44600 /**< HPI UDP service */
397
398/** Base network time out is set to 100 milli-seconds. */
399#define HPI_ETHERNET_TIMEOUT_MS (100)
400
401/** \defgroup tonedet_attr Tonedetector attributes
402\{
403Used by HPI_ToneDetector_Set() and HPI_ToneDetector_Get()
404*/
405
406/** Set the threshold level of a tonedetector,
407Threshold is a -ve number in units of dB/100,
408*/
409#define HPI_TONEDETECTOR_THRESHOLD HPI_CTL_ATTR(TONEDETECTOR, 1)
410
411/** Get the current state of tonedetection
412The result is a bitmap of detected tones. pairs of bits represent the left
413and right channels, with left channel in LSB.
414The lowest frequency detector state is in the LSB
415*/
416#define HPI_TONEDETECTOR_STATE HPI_CTL_ATTR(TONEDETECTOR, 2)
417
418/** Get the frequency of a tonedetector band.
419*/
420#define HPI_TONEDETECTOR_FREQUENCY HPI_CTL_ATTR(TONEDETECTOR, 3)
421 311
422/**\}*/ 312/** Default network timeout in milli-seconds. */
313#define HPI_ETHERNET_TIMEOUT_MS 500
423 314
424/** \defgroup silencedet_attr SilenceDetector attributes 315/** Locked memory buffer alloc/free phases */
425\{ 316enum HPI_BUFFER_CMDS {
426*/ 317 /** use one message to allocate or free physical memory */
427 318 HPI_BUFFER_CMD_EXTERNAL = 0,
428/** Get the current state of tonedetection 319 /** alloc physical memory */
429The result is a bitmap with 1s for silent channels. Left channel is in LSB 320 HPI_BUFFER_CMD_INTERNAL_ALLOC = 1,
430*/ 321 /** send physical memory address to adapter */
431#define HPI_SILENCEDETECTOR_STATE \ 322 HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER = 2,
432 HPI_CTL_ATTR(SILENCEDETECTOR, 2) 323 /** notify adapter to stop using physical buffer */
433 324 HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER = 3,
434/** Set the threshold level of a SilenceDetector, 325 /** free physical buffer */
435Threshold is a -ve number in units of dB/100, 326 HPI_BUFFER_CMD_INTERNAL_FREE = 4
436*/ 327};
437#define HPI_SILENCEDETECTOR_THRESHOLD \
438 HPI_CTL_ATTR(SILENCEDETECTOR, 1)
439
440/** get/set the silence time before the detector triggers
441*/
442#define HPI_SILENCEDETECTOR_DELAY \
443 HPI_CTL_ATTR(SILENCEDETECTOR, 3)
444
445/**\}*/
446
447/* Locked memory buffer alloc/free phases */
448/** use one message to allocate or free physical memory */
449#define HPI_BUFFER_CMD_EXTERNAL 0
450/** alloc physical memory */
451#define HPI_BUFFER_CMD_INTERNAL_ALLOC 1
452/** send physical memory address to adapter */
453#define HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER 2
454/** notify adapter to stop using physical buffer */
455#define HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER 3
456/** free physical buffer */
457#define HPI_BUFFER_CMD_INTERNAL_FREE 4
458
459/******************************************* CONTROLX ATTRIBUTES ****/
460/* NOTE: All controlx attributes must be unique, unlike control attributes */
461 328
462/*****************************************************************************/ 329/*****************************************************************************/
463/*****************************************************************************/ 330/*****************************************************************************/
@@ -482,6 +349,12 @@ Threshold is a -ve number in units of dB/100,
482#define HPI_USB_W2K_TAG 0x57495341 /* "ASIW" */ 349#define HPI_USB_W2K_TAG 0x57495341 /* "ASIW" */
483#define HPI_USB_LINUX_TAG 0x4C495341 /* "ASIL" */ 350#define HPI_USB_LINUX_TAG 0x4C495341 /* "ASIL" */
484 351
352/** Invalid Adapter index
353Used in HPI messages that are not addressed to a specific adapter
354Used in DLL to indicate device not present
355*/
356#define HPI_ADAPTER_INDEX_INVALID 0xFFFF
357
485/** First 2 hex digits define the adapter family */ 358/** First 2 hex digits define the adapter family */
486#define HPI_ADAPTER_FAMILY_MASK 0xff00 359#define HPI_ADAPTER_FAMILY_MASK 0xff00
487#define HPI_MODULE_FAMILY_MASK 0xfff0 360#define HPI_MODULE_FAMILY_MASK 0xfff0
@@ -490,178 +363,186 @@ Threshold is a -ve number in units of dB/100,
490#define HPI_MODULE_FAMILY_ASI(f) (f & HPI_MODULE_FAMILY_MASK) 363#define HPI_MODULE_FAMILY_ASI(f) (f & HPI_MODULE_FAMILY_MASK)
491#define HPI_ADAPTER_ASI(f) (f) 364#define HPI_ADAPTER_ASI(f) (f)
492 365
493/******************************************* message types */ 366enum HPI_MESSAGE_TYPES {
494#define HPI_TYPE_MESSAGE 1 367 HPI_TYPE_MESSAGE = 1,
495#define HPI_TYPE_RESPONSE 2 368 HPI_TYPE_RESPONSE = 2,
496#define HPI_TYPE_DATA 3 369 HPI_TYPE_DATA = 3,
497#define HPI_TYPE_SSX2BYPASS_MESSAGE 4 370 HPI_TYPE_SSX2BYPASS_MESSAGE = 4
498 371};
499/******************************************* object types */ 372
500#define HPI_OBJ_SUBSYSTEM 1 373enum HPI_OBJECT_TYPES {
501#define HPI_OBJ_ADAPTER 2 374 HPI_OBJ_SUBSYSTEM = 1,
502#define HPI_OBJ_OSTREAM 3 375 HPI_OBJ_ADAPTER = 2,
503#define HPI_OBJ_ISTREAM 4 376 HPI_OBJ_OSTREAM = 3,
504#define HPI_OBJ_MIXER 5 377 HPI_OBJ_ISTREAM = 4,
505#define HPI_OBJ_NODE 6 378 HPI_OBJ_MIXER = 5,
506#define HPI_OBJ_CONTROL 7 379 HPI_OBJ_NODE = 6,
507#define HPI_OBJ_NVMEMORY 8 380 HPI_OBJ_CONTROL = 7,
508#define HPI_OBJ_GPIO 9 381 HPI_OBJ_NVMEMORY = 8,
509#define HPI_OBJ_WATCHDOG 10 382 HPI_OBJ_GPIO = 9,
510#define HPI_OBJ_CLOCK 11 383 HPI_OBJ_WATCHDOG = 10,
511#define HPI_OBJ_PROFILE 12 384 HPI_OBJ_CLOCK = 11,
512#define HPI_OBJ_CONTROLEX 13 385 HPI_OBJ_PROFILE = 12,
513#define HPI_OBJ_ASYNCEVENT 14 386 HPI_OBJ_CONTROLEX = 13,
514 387 HPI_OBJ_ASYNCEVENT = 14
515#define HPI_OBJ_MAXINDEX 14 388#define HPI_OBJ_MAXINDEX 14
516 389};
517/******************************************* methods/functions */ 390
518 391#define HPI_OBJ_FUNCTION_SPACING 0x100
519#define HPI_OBJ_FUNCTION_SPACING 0x100 392#define HPI_FUNC_ID(obj, i) (HPI_OBJ_##obj * HPI_OBJ_FUNCTION_SPACING + i)
520#define HPI_MAKE_INDEX(obj, index) (obj * HPI_OBJ_FUNCTION_SPACING + index) 393
521#define HPI_EXTRACT_INDEX(fn) (fn & 0xff) 394#define HPI_EXTRACT_INDEX(fn) (fn & 0xff)
522 395
523/* SUB-SYSTEM */ 396enum HPI_FUNCTION_IDS {
524#define HPI_SUBSYS_OPEN HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 1) 397 HPI_SUBSYS_OPEN = HPI_FUNC_ID(SUBSYSTEM, 1),
525#define HPI_SUBSYS_GET_VERSION HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 2) 398 HPI_SUBSYS_GET_VERSION = HPI_FUNC_ID(SUBSYSTEM, 2),
526#define HPI_SUBSYS_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 3) 399 HPI_SUBSYS_GET_INFO = HPI_FUNC_ID(SUBSYSTEM, 3),
527#define HPI_SUBSYS_FIND_ADAPTERS HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 4) 400 /* HPI_SUBSYS_FIND_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 4), */
528#define HPI_SUBSYS_CREATE_ADAPTER HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 5) 401 HPI_SUBSYS_CREATE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 5),
529#define HPI_SUBSYS_CLOSE HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 6) 402 HPI_SUBSYS_CLOSE = HPI_FUNC_ID(SUBSYSTEM, 6),
530#define HPI_SUBSYS_DELETE_ADAPTER HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 7) 403 /* HPI_SUBSYS_DELETE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 7), */
531#define HPI_SUBSYS_DRIVER_LOAD HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 8) 404 HPI_SUBSYS_DRIVER_LOAD = HPI_FUNC_ID(SUBSYSTEM, 8),
532#define HPI_SUBSYS_DRIVER_UNLOAD HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 9) 405 HPI_SUBSYS_DRIVER_UNLOAD = HPI_FUNC_ID(SUBSYSTEM, 9),
533#define HPI_SUBSYS_READ_PORT_8 HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 10) 406 /* HPI_SUBSYS_READ_PORT_8 = HPI_FUNC_ID(SUBSYSTEM, 10), */
534#define HPI_SUBSYS_WRITE_PORT_8 HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 11) 407 /* HPI_SUBSYS_WRITE_PORT_8 = HPI_FUNC_ID(SUBSYSTEM, 11), */
535#define HPI_SUBSYS_GET_NUM_ADAPTERS HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 12) 408 HPI_SUBSYS_GET_NUM_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 12),
536#define HPI_SUBSYS_GET_ADAPTER HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 13) 409 HPI_SUBSYS_GET_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 13),
537#define HPI_SUBSYS_SET_NETWORK_INTERFACE HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 14) 410 HPI_SUBSYS_SET_NETWORK_INTERFACE = HPI_FUNC_ID(SUBSYSTEM, 14),
538#define HPI_SUBSYS_FUNCTION_COUNT 14 411 HPI_SUBSYS_OPTION_INFO = HPI_FUNC_ID(SUBSYSTEM, 15),
539/* ADAPTER */ 412 HPI_SUBSYS_OPTION_GET = HPI_FUNC_ID(SUBSYSTEM, 16),
540#define HPI_ADAPTER_OPEN HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 1) 413 HPI_SUBSYS_OPTION_SET = HPI_FUNC_ID(SUBSYSTEM, 17),
541#define HPI_ADAPTER_CLOSE HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 2) 414#define HPI_SUBSYS_FUNCTION_COUNT 17
542#define HPI_ADAPTER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 3) 415
543#define HPI_ADAPTER_GET_ASSERT HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 4) 416 HPI_ADAPTER_OPEN = HPI_FUNC_ID(ADAPTER, 1),
544#define HPI_ADAPTER_TEST_ASSERT HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 5) 417 HPI_ADAPTER_CLOSE = HPI_FUNC_ID(ADAPTER, 2),
545#define HPI_ADAPTER_SET_MODE HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 6) 418 HPI_ADAPTER_GET_INFO = HPI_FUNC_ID(ADAPTER, 3),
546#define HPI_ADAPTER_GET_MODE HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 7) 419 HPI_ADAPTER_GET_ASSERT = HPI_FUNC_ID(ADAPTER, 4),
547#define HPI_ADAPTER_ENABLE_CAPABILITY HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 8) 420 HPI_ADAPTER_TEST_ASSERT = HPI_FUNC_ID(ADAPTER, 5),
548#define HPI_ADAPTER_SELFTEST HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 9) 421 HPI_ADAPTER_SET_MODE = HPI_FUNC_ID(ADAPTER, 6),
549#define HPI_ADAPTER_FIND_OBJECT HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 10) 422 HPI_ADAPTER_GET_MODE = HPI_FUNC_ID(ADAPTER, 7),
550#define HPI_ADAPTER_QUERY_FLASH HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 11) 423 HPI_ADAPTER_ENABLE_CAPABILITY = HPI_FUNC_ID(ADAPTER, 8),
551#define HPI_ADAPTER_START_FLASH HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 12) 424 HPI_ADAPTER_SELFTEST = HPI_FUNC_ID(ADAPTER, 9),
552#define HPI_ADAPTER_PROGRAM_FLASH HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 13) 425 HPI_ADAPTER_FIND_OBJECT = HPI_FUNC_ID(ADAPTER, 10),
553#define HPI_ADAPTER_SET_PROPERTY HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 14) 426 HPI_ADAPTER_QUERY_FLASH = HPI_FUNC_ID(ADAPTER, 11),
554#define HPI_ADAPTER_GET_PROPERTY HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 15) 427 HPI_ADAPTER_START_FLASH = HPI_FUNC_ID(ADAPTER, 12),
555#define HPI_ADAPTER_ENUM_PROPERTY HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 16) 428 HPI_ADAPTER_PROGRAM_FLASH = HPI_FUNC_ID(ADAPTER, 13),
556#define HPI_ADAPTER_MODULE_INFO HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 17) 429 HPI_ADAPTER_SET_PROPERTY = HPI_FUNC_ID(ADAPTER, 14),
557#define HPI_ADAPTER_DEBUG_READ HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 18) 430 HPI_ADAPTER_GET_PROPERTY = HPI_FUNC_ID(ADAPTER, 15),
558#define HPI_ADAPTER_FUNCTION_COUNT 18 431 HPI_ADAPTER_ENUM_PROPERTY = HPI_FUNC_ID(ADAPTER, 16),
559/* OUTPUT STREAM */ 432 HPI_ADAPTER_MODULE_INFO = HPI_FUNC_ID(ADAPTER, 17),
560#define HPI_OSTREAM_OPEN HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 1) 433 HPI_ADAPTER_DEBUG_READ = HPI_FUNC_ID(ADAPTER, 18),
561#define HPI_OSTREAM_CLOSE HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 2) 434 HPI_ADAPTER_IRQ_QUERY_AND_CLEAR = HPI_FUNC_ID(ADAPTER, 19),
562#define HPI_OSTREAM_WRITE HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 3) 435 HPI_ADAPTER_IRQ_CALLBACK = HPI_FUNC_ID(ADAPTER, 20),
563#define HPI_OSTREAM_START HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 4) 436 HPI_ADAPTER_DELETE = HPI_FUNC_ID(ADAPTER, 21),
564#define HPI_OSTREAM_STOP HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 5) 437#define HPI_ADAPTER_FUNCTION_COUNT 21
565#define HPI_OSTREAM_RESET HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 6) 438
566#define HPI_OSTREAM_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 7) 439 HPI_OSTREAM_OPEN = HPI_FUNC_ID(OSTREAM, 1),
567#define HPI_OSTREAM_QUERY_FORMAT HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 8) 440 HPI_OSTREAM_CLOSE = HPI_FUNC_ID(OSTREAM, 2),
568#define HPI_OSTREAM_DATA HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 9) 441 HPI_OSTREAM_WRITE = HPI_FUNC_ID(OSTREAM, 3),
569#define HPI_OSTREAM_SET_VELOCITY HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 10) 442 HPI_OSTREAM_START = HPI_FUNC_ID(OSTREAM, 4),
570#define HPI_OSTREAM_SET_PUNCHINOUT HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 11) 443 HPI_OSTREAM_STOP = HPI_FUNC_ID(OSTREAM, 5),
571#define HPI_OSTREAM_SINEGEN HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 12) 444 HPI_OSTREAM_RESET = HPI_FUNC_ID(OSTREAM, 6),
572#define HPI_OSTREAM_ANC_RESET HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 13) 445 HPI_OSTREAM_GET_INFO = HPI_FUNC_ID(OSTREAM, 7),
573#define HPI_OSTREAM_ANC_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 14) 446 HPI_OSTREAM_QUERY_FORMAT = HPI_FUNC_ID(OSTREAM, 8),
574#define HPI_OSTREAM_ANC_READ HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 15) 447 HPI_OSTREAM_DATA = HPI_FUNC_ID(OSTREAM, 9),
575#define HPI_OSTREAM_SET_TIMESCALE HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 16) 448 HPI_OSTREAM_SET_VELOCITY = HPI_FUNC_ID(OSTREAM, 10),
576#define HPI_OSTREAM_SET_FORMAT HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 17) 449 HPI_OSTREAM_SET_PUNCHINOUT = HPI_FUNC_ID(OSTREAM, 11),
577#define HPI_OSTREAM_HOSTBUFFER_ALLOC HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 18) 450 HPI_OSTREAM_SINEGEN = HPI_FUNC_ID(OSTREAM, 12),
578#define HPI_OSTREAM_HOSTBUFFER_FREE HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 19) 451 HPI_OSTREAM_ANC_RESET = HPI_FUNC_ID(OSTREAM, 13),
579#define HPI_OSTREAM_GROUP_ADD HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 20) 452 HPI_OSTREAM_ANC_GET_INFO = HPI_FUNC_ID(OSTREAM, 14),
580#define HPI_OSTREAM_GROUP_GETMAP HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 21) 453 HPI_OSTREAM_ANC_READ = HPI_FUNC_ID(OSTREAM, 15),
581#define HPI_OSTREAM_GROUP_RESET HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 22) 454 HPI_OSTREAM_SET_TIMESCALE = HPI_FUNC_ID(OSTREAM, 16),
582#define HPI_OSTREAM_HOSTBUFFER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 23) 455 HPI_OSTREAM_SET_FORMAT = HPI_FUNC_ID(OSTREAM, 17),
583#define HPI_OSTREAM_WAIT_START HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 24) 456 HPI_OSTREAM_HOSTBUFFER_ALLOC = HPI_FUNC_ID(OSTREAM, 18),
584#define HPI_OSTREAM_FUNCTION_COUNT 24 457 HPI_OSTREAM_HOSTBUFFER_FREE = HPI_FUNC_ID(OSTREAM, 19),
585/* INPUT STREAM */ 458 HPI_OSTREAM_GROUP_ADD = HPI_FUNC_ID(OSTREAM, 20),
586#define HPI_ISTREAM_OPEN HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 1) 459 HPI_OSTREAM_GROUP_GETMAP = HPI_FUNC_ID(OSTREAM, 21),
587#define HPI_ISTREAM_CLOSE HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 2) 460 HPI_OSTREAM_GROUP_RESET = HPI_FUNC_ID(OSTREAM, 22),
588#define HPI_ISTREAM_SET_FORMAT HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 3) 461 HPI_OSTREAM_HOSTBUFFER_GET_INFO = HPI_FUNC_ID(OSTREAM, 23),
589#define HPI_ISTREAM_READ HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 4) 462 HPI_OSTREAM_WAIT_START = HPI_FUNC_ID(OSTREAM, 24),
590#define HPI_ISTREAM_START HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 5) 463 HPI_OSTREAM_WAIT = HPI_FUNC_ID(OSTREAM, 25),
591#define HPI_ISTREAM_STOP HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 6) 464#define HPI_OSTREAM_FUNCTION_COUNT 25
592#define HPI_ISTREAM_RESET HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 7) 465
593#define HPI_ISTREAM_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 8) 466 HPI_ISTREAM_OPEN = HPI_FUNC_ID(ISTREAM, 1),
594#define HPI_ISTREAM_QUERY_FORMAT HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 9) 467 HPI_ISTREAM_CLOSE = HPI_FUNC_ID(ISTREAM, 2),
595#define HPI_ISTREAM_ANC_RESET HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 10) 468 HPI_ISTREAM_SET_FORMAT = HPI_FUNC_ID(ISTREAM, 3),
596#define HPI_ISTREAM_ANC_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 11) 469 HPI_ISTREAM_READ = HPI_FUNC_ID(ISTREAM, 4),
597#define HPI_ISTREAM_ANC_WRITE HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 12) 470 HPI_ISTREAM_START = HPI_FUNC_ID(ISTREAM, 5),
598#define HPI_ISTREAM_HOSTBUFFER_ALLOC HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 13) 471 HPI_ISTREAM_STOP = HPI_FUNC_ID(ISTREAM, 6),
599#define HPI_ISTREAM_HOSTBUFFER_FREE HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 14) 472 HPI_ISTREAM_RESET = HPI_FUNC_ID(ISTREAM, 7),
600#define HPI_ISTREAM_GROUP_ADD HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 15) 473 HPI_ISTREAM_GET_INFO = HPI_FUNC_ID(ISTREAM, 8),
601#define HPI_ISTREAM_GROUP_GETMAP HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 16) 474 HPI_ISTREAM_QUERY_FORMAT = HPI_FUNC_ID(ISTREAM, 9),
602#define HPI_ISTREAM_GROUP_RESET HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 17) 475 HPI_ISTREAM_ANC_RESET = HPI_FUNC_ID(ISTREAM, 10),
603#define HPI_ISTREAM_HOSTBUFFER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 18) 476 HPI_ISTREAM_ANC_GET_INFO = HPI_FUNC_ID(ISTREAM, 11),
604#define HPI_ISTREAM_WAIT_START HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 19) 477 HPI_ISTREAM_ANC_WRITE = HPI_FUNC_ID(ISTREAM, 12),
605#define HPI_ISTREAM_FUNCTION_COUNT 19 478 HPI_ISTREAM_HOSTBUFFER_ALLOC = HPI_FUNC_ID(ISTREAM, 13),
606/* MIXER */ 479 HPI_ISTREAM_HOSTBUFFER_FREE = HPI_FUNC_ID(ISTREAM, 14),
480 HPI_ISTREAM_GROUP_ADD = HPI_FUNC_ID(ISTREAM, 15),
481 HPI_ISTREAM_GROUP_GETMAP = HPI_FUNC_ID(ISTREAM, 16),
482 HPI_ISTREAM_GROUP_RESET = HPI_FUNC_ID(ISTREAM, 17),
483 HPI_ISTREAM_HOSTBUFFER_GET_INFO = HPI_FUNC_ID(ISTREAM, 18),
484 HPI_ISTREAM_WAIT_START = HPI_FUNC_ID(ISTREAM, 19),
485 HPI_ISTREAM_WAIT = HPI_FUNC_ID(ISTREAM, 20),
486#define HPI_ISTREAM_FUNCTION_COUNT 20
487
607/* NOTE: 488/* NOTE:
608 GET_NODE_INFO, SET_CONNECTION, GET_CONNECTIONS are not currently used */ 489 GET_NODE_INFO, SET_CONNECTION, GET_CONNECTIONS are not currently used */
609#define HPI_MIXER_OPEN HPI_MAKE_INDEX(HPI_OBJ_MIXER, 1) 490 HPI_MIXER_OPEN = HPI_FUNC_ID(MIXER, 1),
610#define HPI_MIXER_CLOSE HPI_MAKE_INDEX(HPI_OBJ_MIXER, 2) 491 HPI_MIXER_CLOSE = HPI_FUNC_ID(MIXER, 2),
611#define HPI_MIXER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_MIXER, 3) 492 HPI_MIXER_GET_INFO = HPI_FUNC_ID(MIXER, 3),
612#define HPI_MIXER_GET_NODE_INFO HPI_MAKE_INDEX(HPI_OBJ_MIXER, 4) 493 HPI_MIXER_GET_NODE_INFO = HPI_FUNC_ID(MIXER, 4),
613#define HPI_MIXER_GET_CONTROL HPI_MAKE_INDEX(HPI_OBJ_MIXER, 5) 494 HPI_MIXER_GET_CONTROL = HPI_FUNC_ID(MIXER, 5),
614#define HPI_MIXER_SET_CONNECTION HPI_MAKE_INDEX(HPI_OBJ_MIXER, 6) 495 HPI_MIXER_SET_CONNECTION = HPI_FUNC_ID(MIXER, 6),
615#define HPI_MIXER_GET_CONNECTIONS HPI_MAKE_INDEX(HPI_OBJ_MIXER, 7) 496 HPI_MIXER_GET_CONNECTIONS = HPI_FUNC_ID(MIXER, 7),
616#define HPI_MIXER_GET_CONTROL_BY_INDEX HPI_MAKE_INDEX(HPI_OBJ_MIXER, 8) 497 HPI_MIXER_GET_CONTROL_BY_INDEX = HPI_FUNC_ID(MIXER, 8),
617#define HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX HPI_MAKE_INDEX(HPI_OBJ_MIXER, 9) 498 HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX = HPI_FUNC_ID(MIXER, 9),
618#define HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES HPI_MAKE_INDEX(HPI_OBJ_MIXER, 10) 499 HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES = HPI_FUNC_ID(MIXER, 10),
619#define HPI_MIXER_STORE HPI_MAKE_INDEX(HPI_OBJ_MIXER, 11) 500 HPI_MIXER_STORE = HPI_FUNC_ID(MIXER, 11),
620#define HPI_MIXER_FUNCTION_COUNT 11 501 HPI_MIXER_GET_CACHE_INFO = HPI_FUNC_ID(MIXER, 12),
621/* MIXER CONTROLS */ 502#define HPI_MIXER_FUNCTION_COUNT 12
622#define HPI_CONTROL_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_CONTROL, 1) 503
623#define HPI_CONTROL_GET_STATE HPI_MAKE_INDEX(HPI_OBJ_CONTROL, 2) 504 HPI_CONTROL_GET_INFO = HPI_FUNC_ID(CONTROL, 1),
624#define HPI_CONTROL_SET_STATE HPI_MAKE_INDEX(HPI_OBJ_CONTROL, 3) 505 HPI_CONTROL_GET_STATE = HPI_FUNC_ID(CONTROL, 2),
506 HPI_CONTROL_SET_STATE = HPI_FUNC_ID(CONTROL, 3),
625#define HPI_CONTROL_FUNCTION_COUNT 3 507#define HPI_CONTROL_FUNCTION_COUNT 3
626/* NONVOL MEMORY */ 508
627#define HPI_NVMEMORY_OPEN HPI_MAKE_INDEX(HPI_OBJ_NVMEMORY, 1) 509 HPI_NVMEMORY_OPEN = HPI_FUNC_ID(NVMEMORY, 1),
628#define HPI_NVMEMORY_READ_BYTE HPI_MAKE_INDEX(HPI_OBJ_NVMEMORY, 2) 510 HPI_NVMEMORY_READ_BYTE = HPI_FUNC_ID(NVMEMORY, 2),
629#define HPI_NVMEMORY_WRITE_BYTE HPI_MAKE_INDEX(HPI_OBJ_NVMEMORY, 3) 511 HPI_NVMEMORY_WRITE_BYTE = HPI_FUNC_ID(NVMEMORY, 3),
630#define HPI_NVMEMORY_FUNCTION_COUNT 3 512#define HPI_NVMEMORY_FUNCTION_COUNT 3
631/* GPIO */ 513
632#define HPI_GPIO_OPEN HPI_MAKE_INDEX(HPI_OBJ_GPIO, 1) 514 HPI_GPIO_OPEN = HPI_FUNC_ID(GPIO, 1),
633#define HPI_GPIO_READ_BIT HPI_MAKE_INDEX(HPI_OBJ_GPIO, 2) 515 HPI_GPIO_READ_BIT = HPI_FUNC_ID(GPIO, 2),
634#define HPI_GPIO_WRITE_BIT HPI_MAKE_INDEX(HPI_OBJ_GPIO, 3) 516 HPI_GPIO_WRITE_BIT = HPI_FUNC_ID(GPIO, 3),
635#define HPI_GPIO_READ_ALL HPI_MAKE_INDEX(HPI_OBJ_GPIO, 4) 517 HPI_GPIO_READ_ALL = HPI_FUNC_ID(GPIO, 4),
636#define HPI_GPIO_WRITE_STATUS HPI_MAKE_INDEX(HPI_OBJ_GPIO, 5) 518 HPI_GPIO_WRITE_STATUS = HPI_FUNC_ID(GPIO, 5),
637#define HPI_GPIO_FUNCTION_COUNT 5 519#define HPI_GPIO_FUNCTION_COUNT 5
638/* ASYNC EVENT */ 520
639#define HPI_ASYNCEVENT_OPEN HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 1) 521 HPI_ASYNCEVENT_OPEN = HPI_FUNC_ID(ASYNCEVENT, 1),
640#define HPI_ASYNCEVENT_CLOSE HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 2) 522 HPI_ASYNCEVENT_CLOSE = HPI_FUNC_ID(ASYNCEVENT, 2),
641#define HPI_ASYNCEVENT_WAIT HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 3) 523 HPI_ASYNCEVENT_WAIT = HPI_FUNC_ID(ASYNCEVENT, 3),
642#define HPI_ASYNCEVENT_GETCOUNT HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 4) 524 HPI_ASYNCEVENT_GETCOUNT = HPI_FUNC_ID(ASYNCEVENT, 4),
643#define HPI_ASYNCEVENT_GET HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 5) 525 HPI_ASYNCEVENT_GET = HPI_FUNC_ID(ASYNCEVENT, 5),
644#define HPI_ASYNCEVENT_SENDEVENTS HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 6) 526 HPI_ASYNCEVENT_SENDEVENTS = HPI_FUNC_ID(ASYNCEVENT, 6),
645#define HPI_ASYNCEVENT_FUNCTION_COUNT 6 527#define HPI_ASYNCEVENT_FUNCTION_COUNT 6
646/* WATCH-DOG */ 528
647#define HPI_WATCHDOG_OPEN HPI_MAKE_INDEX(HPI_OBJ_WATCHDOG, 1) 529 HPI_WATCHDOG_OPEN = HPI_FUNC_ID(WATCHDOG, 1),
648#define HPI_WATCHDOG_SET_TIME HPI_MAKE_INDEX(HPI_OBJ_WATCHDOG, 2) 530 HPI_WATCHDOG_SET_TIME = HPI_FUNC_ID(WATCHDOG, 2),
649#define HPI_WATCHDOG_PING HPI_MAKE_INDEX(HPI_OBJ_WATCHDOG, 3) 531 HPI_WATCHDOG_PING = HPI_FUNC_ID(WATCHDOG, 3),
650/* CLOCK */ 532
651#define HPI_CLOCK_OPEN HPI_MAKE_INDEX(HPI_OBJ_CLOCK, 1) 533 HPI_CLOCK_OPEN = HPI_FUNC_ID(CLOCK, 1),
652#define HPI_CLOCK_SET_TIME HPI_MAKE_INDEX(HPI_OBJ_CLOCK, 2) 534 HPI_CLOCK_SET_TIME = HPI_FUNC_ID(CLOCK, 2),
653#define HPI_CLOCK_GET_TIME HPI_MAKE_INDEX(HPI_OBJ_CLOCK, 3) 535 HPI_CLOCK_GET_TIME = HPI_FUNC_ID(CLOCK, 3),
654/* PROFILE */ 536
655#define HPI_PROFILE_OPEN_ALL HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 1) 537 HPI_PROFILE_OPEN_ALL = HPI_FUNC_ID(PROFILE, 1),
656#define HPI_PROFILE_START_ALL HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 2) 538 HPI_PROFILE_START_ALL = HPI_FUNC_ID(PROFILE, 2),
657#define HPI_PROFILE_STOP_ALL HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 3) 539 HPI_PROFILE_STOP_ALL = HPI_FUNC_ID(PROFILE, 3),
658#define HPI_PROFILE_GET HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 4) 540 HPI_PROFILE_GET = HPI_FUNC_ID(PROFILE, 4),
659#define HPI_PROFILE_GET_IDLECOUNT HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 5) 541 HPI_PROFILE_GET_IDLECOUNT = HPI_FUNC_ID(PROFILE, 5),
660#define HPI_PROFILE_GET_NAME HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 6) 542 HPI_PROFILE_GET_NAME = HPI_FUNC_ID(PROFILE, 6),
661#define HPI_PROFILE_GET_UTILIZATION HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 7) 543 HPI_PROFILE_GET_UTILIZATION = HPI_FUNC_ID(PROFILE, 7)
662#define HPI_PROFILE_FUNCTION_COUNT 7 544#define HPI_PROFILE_FUNCTION_COUNT 7
663/* ////////////////////////////////////////////////////////////////////// */ 545};
664/* PRIVATE ATTRIBUTES */
665 546
666/* ////////////////////////////////////////////////////////////////////// */ 547/* ////////////////////////////////////////////////////////////////////// */
667/* STRUCTURES */ 548/* STRUCTURES */
@@ -672,18 +553,7 @@ Threshold is a -ve number in units of dB/100,
672/** PCI bus resource */ 553/** PCI bus resource */
673struct hpi_pci { 554struct hpi_pci {
674 u32 __iomem *ap_mem_base[HPI_MAX_ADAPTER_MEM_SPACES]; 555 u32 __iomem *ap_mem_base[HPI_MAX_ADAPTER_MEM_SPACES];
675 struct pci_dev *p_os_data; 556 struct pci_dev *pci_dev;
676
677#ifndef HPI64BIT /* keep structure size constant */
678 u32 padding[HPI_MAX_ADAPTER_MEM_SPACES + 1];
679#endif
680 u16 vendor_id;
681 u16 device_id;
682 u16 subsys_vendor_id;
683 u16 subsys_device_id;
684 u16 bus_number;
685 u16 device_number;
686 u32 interrupt;
687}; 557};
688 558
689struct hpi_resource { 559struct hpi_resource {
@@ -702,12 +572,10 @@ struct hpi_resource {
702/** Format info used inside struct hpi_message 572/** Format info used inside struct hpi_message
703 Not the same as public API struct hpi_format */ 573 Not the same as public API struct hpi_format */
704struct hpi_msg_format { 574struct hpi_msg_format {
705 u32 sample_rate; 575 u32 sample_rate; /**< 11025, 32000, 44100 etc. */
706 /**< 11025, 32000, 44100 ... */ 576 u32 bit_rate; /**< for MPEG */
707 u32 bit_rate; /**< for MPEG */ 577 u32 attributes; /**< stereo/joint_stereo/mono */
708 u32 attributes; 578 u16 channels; /**< 1,2..., (or ancillary mode or idle bit */
709 /**< Stereo/JointStereo/Mono */
710 u16 channels; /**< 1,2..., (or ancillary mode or idle bit */
711 u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see \ref HPI_FORMATS. */ 579 u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see \ref HPI_FORMATS. */
712}; 580};
713 581
@@ -740,9 +608,9 @@ struct hpi_data_compat32 {
740#endif 608#endif
741 609
742struct hpi_buffer { 610struct hpi_buffer {
743 /** placehoder for backward compatability (see dwBufferSize) */ 611 /** placehoder for backward compatibility (see dwBufferSize) */
744 struct hpi_msg_format reserved; 612 struct hpi_msg_format reserved;
745 u32 command; /**< HPI_BUFFER_CMD_xxx*/ 613 u32 command; /**< HPI_BUFFER_CMD_xxx*/
746 u32 pci_address; /**< PCI physical address of buffer for DSP DMA */ 614 u32 pci_address; /**< PCI physical address of buffer for DSP DMA */
747 u32 buffer_size; /**< must line up with data_size of HPI_DATA*/ 615 u32 buffer_size; /**< must line up with data_size of HPI_DATA*/
748}; 616};
@@ -777,30 +645,25 @@ struct hpi_subsys_msg {
777 645
778struct hpi_subsys_res { 646struct hpi_subsys_res {
779 u32 version; 647 u32 version;
780 u32 data; /* used to return extended version */ 648 u32 data; /* extended version */
781 u16 num_adapters; /* number of adapters */ 649 u16 num_adapters;
782 u16 adapter_index; 650 u16 adapter_index;
783 u16 aw_adapter_list[HPI_MAX_ADAPTERS]; 651 u16 adapter_type;
784}; 652 u16 pad16;
785
786struct hpi_adapter_msg {
787 u32 adapter_mode; /* adapter mode */
788 u16 assert_id; /* assert number for "test assert" call
789 object_index for find object call
790 query_or_set for hpi_adapter_set_mode_ex() */
791 u16 object_type; /* for adapter find object call */
792}; 653};
793 654
794union hpi_adapterx_msg { 655union hpi_adapterx_msg {
795 struct hpi_adapter_msg adapter;
796 struct { 656 struct {
797 u32 offset; 657 u32 dsp_address;
798 } query_flash; 658 u32 count_bytes;
659 } debug_read;
799 struct { 660 struct {
800 u32 offset; 661 u32 adapter_mode;
801 u32 length; 662 u16 query_or_set;
802 u32 key; 663 } mode;
803 } start_flash; 664 struct {
665 u16 index;
666 } module_info;
804 struct { 667 struct {
805 u32 checksum; 668 u32 checksum;
806 u16 sequence; 669 u16 sequence;
@@ -809,28 +672,41 @@ union hpi_adapterx_msg {
809 u16 unused; 672 u16 unused;
810 } program_flash; 673 } program_flash;
811 struct { 674 struct {
675 u16 index;
676 u16 what;
677 u16 property_index;
678 } property_enum;
679 struct {
812 u16 property; 680 u16 property;
813 u16 parameter1; 681 u16 parameter1;
814 u16 parameter2; 682 u16 parameter2;
815 } property_set; 683 } property_set;
816 struct { 684 struct {
817 u16 index; 685 u32 offset;
818 u16 what; 686 } query_flash;
819 u16 property_index;
820 } property_enum;
821 struct { 687 struct {
822 u16 index; 688 u32 pad32;
823 } module_info; 689 u16 key1;
690 u16 key2;
691 } restart;
824 struct { 692 struct {
825 u32 dsp_address; 693 u32 offset;
826 u32 count_bytes; 694 u32 length;
827 } debug_read; 695 u32 key;
696 } start_flash;
697 struct {
698 u32 pad32;
699 u16 value;
700 } test_assert;
701 struct {
702 u32 yes;
703 } irq_query;
828}; 704};
829 705
830struct hpi_adapter_res { 706struct hpi_adapter_res {
831 u32 serial_number; 707 u32 serial_number;
832 u16 adapter_type; 708 u16 adapter_type;
833 u16 adapter_index; /* is this needed? also used for dsp_index */ 709 u16 adapter_index;
834 u16 num_instreams; 710 u16 num_instreams;
835 u16 num_outstreams; 711 u16 num_outstreams;
836 u16 num_mixers; 712 u16 num_mixers;
@@ -839,12 +715,18 @@ struct hpi_adapter_res {
839}; 715};
840 716
841union hpi_adapterx_res { 717union hpi_adapterx_res {
842 struct hpi_adapter_res adapter; 718 struct hpi_adapter_res info;
843 struct { 719 struct {
844 u32 checksum; 720 u32 p1;
845 u32 length; 721 u16 count;
846 u32 version; 722 u16 dsp_index;
847 } query_flash; 723 u32 p2;
724 u32 dsp_msg_addr;
725 char sz_message[HPI_STRING_LEN];
726 } assert;
727 struct {
728 u32 adapter_mode;
729 } mode;
848 struct { 730 struct {
849 u16 sequence; 731 u16 sequence;
850 } program_flash; 732 } program_flash;
@@ -852,6 +734,14 @@ union hpi_adapterx_res {
852 u16 parameter1; 734 u16 parameter1;
853 u16 parameter2; 735 u16 parameter2;
854 } property_get; 736 } property_get;
737 struct {
738 u32 checksum;
739 u32 length;
740 u32 version;
741 } query_flash;
742 struct {
743 u32 yes;
744 } irq_query;
855}; 745};
856 746
857struct hpi_stream_msg { 747struct hpi_stream_msg {
@@ -863,6 +753,7 @@ struct hpi_stream_msg {
863 u32 time_scale; 753 u32 time_scale;
864 struct hpi_buffer buffer; 754 struct hpi_buffer buffer;
865 struct hpi_streamid stream; 755 struct hpi_streamid stream;
756 u32 threshold_bytes;
866 } u; 757 } u;
867}; 758};
868 759
@@ -911,7 +802,7 @@ struct hpi_stream_res {
911struct hpi_mixer_msg { 802struct hpi_mixer_msg {
912 u16 control_index; 803 u16 control_index;
913 u16 control_type; /* = HPI_CONTROL_METER _VOLUME etc */ 804 u16 control_type; /* = HPI_CONTROL_METER _VOLUME etc */
914 u16 padding1; /* maintain alignment of subsequent fields */ 805 u16 padding1; /* Maintain alignment of subsequent fields */
915 u16 node_type1; /* = HPI_SOURCENODE_LINEIN etc */ 806 u16 node_type1; /* = HPI_SOURCENODE_LINEIN etc */
916 u16 node_index1; /* = 0..N */ 807 u16 node_index1; /* = 0..N */
917 u16 node_type2; 808 u16 node_type2;
@@ -949,6 +840,11 @@ union hpi_mixerx_res {
949 u32 p_data; /* pointer to data array */ 840 u32 p_data; /* pointer to data array */
950 u16 more_to_do; /* indicates if there is more to do */ 841 u16 more_to_do; /* indicates if there is more to do */
951 } gcabi; 842 } gcabi;
843 struct {
844 u32 total_controls; /* count of controls in the mixer */
845 u32 cache_controls; /* count of controls in the cac */
846 u32 cache_bytes; /* size of cache */
847 } cache_info;
952}; 848};
953 849
954struct hpi_control_msg { 850struct hpi_control_msg {
@@ -1000,12 +896,16 @@ union hpi_control_union_res {
1000 u32 band; 896 u32 band;
1001 u32 frequency; 897 u32 frequency;
1002 u32 gain; 898 u32 gain;
1003 u32 level;
1004 u32 deemphasis; 899 u32 deemphasis;
1005 struct { 900 struct {
1006 u32 data[2]; 901 u32 data[2];
1007 u32 bLER; 902 u32 bLER;
1008 } rds; 903 } rds;
904 short s_level;
905 struct {
906 u16 value;
907 u16 mask;
908 } status;
1009 } tuner; 909 } tuner;
1010 struct { 910 struct {
1011 char sz_data[8]; 911 char sz_data[8];
@@ -1178,11 +1078,11 @@ struct hpi_profile_res_open {
1178}; 1078};
1179 1079
1180struct hpi_profile_res_time { 1080struct hpi_profile_res_time {
1181 u32 micro_seconds; 1081 u32 total_tick_count;
1182 u32 call_count; 1082 u32 call_count;
1183 u32 max_micro_seconds; 1083 u32 max_tick_count;
1184 u32 min_micro_seconds; 1084 u32 ticks_per_millisecond;
1185 u16 seconds; 1085 u16 profile_interval;
1186}; 1086};
1187 1087
1188struct hpi_profile_res_name { 1088struct hpi_profile_res_name {
@@ -1218,7 +1118,6 @@ struct hpi_message {
1218 u16 obj_index; /* */ 1118 u16 obj_index; /* */
1219 union { 1119 union {
1220 struct hpi_subsys_msg s; 1120 struct hpi_subsys_msg s;
1221 struct hpi_adapter_msg a;
1222 union hpi_adapterx_msg ax; 1121 union hpi_adapterx_msg ax;
1223 struct hpi_stream_msg d; 1122 struct hpi_stream_msg d;
1224 struct hpi_mixer_msg m; 1123 struct hpi_mixer_msg m;
@@ -1239,7 +1138,7 @@ struct hpi_message {
1239}; 1138};
1240 1139
1241#define HPI_MESSAGE_SIZE_BY_OBJECT { \ 1140#define HPI_MESSAGE_SIZE_BY_OBJECT { \
1242 sizeof(struct hpi_message_header) , /* default, no object type 0 */ \ 1141 sizeof(struct hpi_message_header) , /* Default, no object type 0 */ \
1243 sizeof(struct hpi_message_header) + sizeof(struct hpi_subsys_msg),\ 1142 sizeof(struct hpi_message_header) + sizeof(struct hpi_subsys_msg),\
1244 sizeof(struct hpi_message_header) + sizeof(union hpi_adapterx_msg),\ 1143 sizeof(struct hpi_message_header) + sizeof(union hpi_adapterx_msg),\
1245 sizeof(struct hpi_message_header) + sizeof(struct hpi_stream_msg),\ 1144 sizeof(struct hpi_message_header) + sizeof(struct hpi_stream_msg),\
@@ -1256,6 +1155,11 @@ struct hpi_message {
1256 sizeof(struct hpi_message_header) + sizeof(struct hpi_async_msg) \ 1155 sizeof(struct hpi_message_header) + sizeof(struct hpi_async_msg) \
1257} 1156}
1258 1157
1158/*
1159Note that the wSpecificError error field should be inspected and potentially
1160reported whenever HPI_ERROR_DSP_COMMUNICATION or HPI_ERROR_DSP_BOOTLOAD is
1161returned in wError.
1162*/
1259struct hpi_response_header { 1163struct hpi_response_header {
1260 u16 size; 1164 u16 size;
1261 u8 type; /* HPI_TYPE_RESPONSE */ 1165 u8 type; /* HPI_TYPE_RESPONSE */
@@ -1277,7 +1181,6 @@ struct hpi_response {
1277 u16 specific_error; /* adapter specific error */ 1181 u16 specific_error; /* adapter specific error */
1278 union { 1182 union {
1279 struct hpi_subsys_res s; 1183 struct hpi_subsys_res s;
1280 struct hpi_adapter_res a;
1281 union hpi_adapterx_res ax; 1184 union hpi_adapterx_res ax;
1282 struct hpi_stream_res d; 1185 struct hpi_stream_res d;
1283 struct hpi_mixer_res m; 1186 struct hpi_mixer_res m;
@@ -1297,7 +1200,7 @@ struct hpi_response {
1297}; 1200};
1298 1201
1299#define HPI_RESPONSE_SIZE_BY_OBJECT { \ 1202#define HPI_RESPONSE_SIZE_BY_OBJECT { \
1300 sizeof(struct hpi_response_header) ,/* default, no object type 0 */ \ 1203 sizeof(struct hpi_response_header) ,/* Default, no object type 0 */ \
1301 sizeof(struct hpi_response_header) + sizeof(struct hpi_subsys_res),\ 1204 sizeof(struct hpi_response_header) + sizeof(struct hpi_subsys_res),\
1302 sizeof(struct hpi_response_header) + sizeof(union hpi_adapterx_res),\ 1205 sizeof(struct hpi_response_header) + sizeof(union hpi_adapterx_res),\
1303 sizeof(struct hpi_response_header) + sizeof(struct hpi_stream_res),\ 1206 sizeof(struct hpi_response_header) + sizeof(struct hpi_stream_res),\
@@ -1314,7 +1217,7 @@ struct hpi_response {
1314 sizeof(struct hpi_response_header) + sizeof(struct hpi_async_res) \ 1217 sizeof(struct hpi_response_header) + sizeof(struct hpi_async_res) \
1315} 1218}
1316 1219
1317/*********************** version 1 message/response *****************************/ 1220/*********************** version 1 message/response **************************/
1318#define HPINET_ETHERNET_DATA_SIZE (1500) 1221#define HPINET_ETHERNET_DATA_SIZE (1500)
1319#define HPINET_IP_HDR_SIZE (20) 1222#define HPINET_IP_HDR_SIZE (20)
1320#define HPINET_IP_DATA_SIZE (HPINET_ETHERNET_DATA_SIZE - HPINET_IP_HDR_SIZE) 1223#define HPINET_IP_DATA_SIZE (HPINET_ETHERNET_DATA_SIZE - HPINET_IP_HDR_SIZE)
@@ -1394,6 +1297,17 @@ struct hpi_res_adapter_program_flash {
1394 sizeof(struct hpi_response_header) - sizeof(u16)]; 1297 sizeof(struct hpi_response_header) - sizeof(u16)];
1395}; 1298};
1396 1299
1300struct hpi_msg_adapter_debug_read {
1301 struct hpi_message_header h;
1302 u32 dsp_address;
1303 u32 count_bytes;
1304};
1305
1306struct hpi_res_adapter_debug_read {
1307 struct hpi_response_header h;
1308 u8 bytes[256];
1309};
1310
1397#if 1 1311#if 1
1398#define hpi_message_header_v1 hpi_message_header 1312#define hpi_message_header_v1 hpi_message_header
1399#define hpi_response_header_v1 hpi_response_header 1313#define hpi_response_header_v1 hpi_response_header
@@ -1414,23 +1328,10 @@ struct hpi_response_header_v1 {
1414}; 1328};
1415#endif 1329#endif
1416 1330
1417/* STRV HPI Packet */
1418struct hpi_msg_strv {
1419 struct hpi_message_header h;
1420 struct hpi_entity strv;
1421};
1422
1423struct hpi_res_strv {
1424 struct hpi_response_header h;
1425 struct hpi_entity strv;
1426};
1427#define MIN_STRV_PACKET_SIZE sizeof(struct hpi_res_strv)
1428
1429struct hpi_msg_payload_v0 { 1331struct hpi_msg_payload_v0 {
1430 struct hpi_message_header h; 1332 struct hpi_message_header h;
1431 union { 1333 union {
1432 struct hpi_subsys_msg s; 1334 struct hpi_subsys_msg s;
1433 struct hpi_adapter_msg a;
1434 union hpi_adapterx_msg ax; 1335 union hpi_adapterx_msg ax;
1435 struct hpi_stream_msg d; 1336 struct hpi_stream_msg d;
1436 struct hpi_mixer_msg m; 1337 struct hpi_mixer_msg m;
@@ -1451,7 +1352,6 @@ struct hpi_res_payload_v0 {
1451 struct hpi_response_header h; 1352 struct hpi_response_header h;
1452 union { 1353 union {
1453 struct hpi_subsys_res s; 1354 struct hpi_subsys_res s;
1454 struct hpi_adapter_res a;
1455 union hpi_adapterx_res ax; 1355 union hpi_adapterx_res ax;
1456 struct hpi_stream_res d; 1356 struct hpi_stream_res d;
1457 struct hpi_mixer_res m; 1357 struct hpi_mixer_res m;
@@ -1471,13 +1371,13 @@ struct hpi_res_payload_v0 {
1471union hpi_message_buffer_v1 { 1371union hpi_message_buffer_v1 {
1472 struct hpi_message m0; /* version 0 */ 1372 struct hpi_message m0; /* version 0 */
1473 struct hpi_message_header_v1 h; 1373 struct hpi_message_header_v1 h;
1474 unsigned char buf[HPI_MAX_PAYLOAD_SIZE]; 1374 u8 buf[HPI_MAX_PAYLOAD_SIZE];
1475}; 1375};
1476 1376
1477union hpi_response_buffer_v1 { 1377union hpi_response_buffer_v1 {
1478 struct hpi_response r0; /* version 0 */ 1378 struct hpi_response r0; /* version 0 */
1479 struct hpi_response_header_v1 h; 1379 struct hpi_response_header_v1 h;
1480 unsigned char buf[HPI_MAX_PAYLOAD_SIZE]; 1380 u8 buf[HPI_MAX_PAYLOAD_SIZE];
1481}; 1381};
1482 1382
1483compile_time_assert((sizeof(union hpi_message_buffer_v1) <= 1383compile_time_assert((sizeof(union hpi_message_buffer_v1) <=
@@ -1499,6 +1399,11 @@ struct hpi_control_defn {
1499/*////////////////////////////////////////////////////////////////////////// */ 1399/*////////////////////////////////////////////////////////////////////////// */
1500/* declarations for control caching (internal to HPI<->DSP interaction) */ 1400/* declarations for control caching (internal to HPI<->DSP interaction) */
1501 1401
1402/** indicates a cached u16 value is invalid. */
1403#define HPI_CACHE_INVALID_UINT16 0xFFFF
1404/** indicates a cached short value is invalid. */
1405#define HPI_CACHE_INVALID_SHORT -32768
1406
1502/** A compact representation of (part of) a controls state. 1407/** A compact representation of (part of) a controls state.
1503Used for efficient transfer of the control state 1408Used for efficient transfer of the control state
1504between DSP and host or across a network 1409between DSP and host or across a network
@@ -1512,58 +1417,104 @@ struct hpi_control_cache_info {
1512 u16 control_index; 1417 u16 control_index;
1513}; 1418};
1514 1419
1515struct hpi_control_cache_single { 1420struct hpi_control_cache_vol {
1516 struct hpi_control_cache_info i; 1421 struct hpi_control_cache_info i;
1422 short an_log[2];
1423 unsigned short flags;
1424 char padding[2];
1425};
1426
1427struct hpi_control_cache_meter {
1428 struct hpi_control_cache_info i;
1429 short an_log_peak[2];
1430 short an_logRMS[2];
1431};
1432
1433struct hpi_control_cache_channelmode {
1434 struct hpi_control_cache_info i;
1435 u16 mode;
1436 char temp_padding[6];
1437};
1438
1439struct hpi_control_cache_mux {
1440 struct hpi_control_cache_info i;
1441 u16 source_node_type;
1442 u16 source_node_index;
1443 char temp_padding[4];
1444};
1445
1446struct hpi_control_cache_level {
1447 struct hpi_control_cache_info i;
1448 short an_log[2];
1449 char temp_padding[4];
1450};
1451
1452struct hpi_control_cache_tuner {
1453 struct hpi_control_cache_info i;
1454 u32 freq_ink_hz;
1455 u16 band;
1456 short s_level_avg;
1457};
1458
1459struct hpi_control_cache_aes3rx {
1460 struct hpi_control_cache_info i;
1461 u32 error_status;
1462 u32 format;
1463};
1464
1465struct hpi_control_cache_aes3tx {
1466 struct hpi_control_cache_info i;
1467 u32 format;
1468 char temp_padding[4];
1469};
1470
1471struct hpi_control_cache_tonedetector {
1472 struct hpi_control_cache_info i;
1473 u16 state;
1474 char temp_padding[6];
1475};
1476
1477struct hpi_control_cache_silencedetector {
1478 struct hpi_control_cache_info i;
1479 u32 state;
1480 char temp_padding[4];
1481};
1482
1483struct hpi_control_cache_sampleclock {
1484 struct hpi_control_cache_info i;
1485 u16 source;
1486 u16 source_index;
1487 u32 sample_rate;
1488};
1489
1490struct hpi_control_cache_microphone {
1491 struct hpi_control_cache_info i;
1492 u16 phantom_state;
1493 char temp_padding[6];
1494};
1495
1496struct hpi_control_cache_generic {
1497 struct hpi_control_cache_info i;
1498 u32 dw1;
1499 u32 dw2;
1500};
1501
1502struct hpi_control_cache_single {
1517 union { 1503 union {
1518 struct { /* volume */ 1504 struct hpi_control_cache_info i;
1519 short an_log[2]; 1505 struct hpi_control_cache_vol vol;
1520 } v; 1506 struct hpi_control_cache_meter meter;
1521 struct { /* peak meter */ 1507 struct hpi_control_cache_channelmode mode;
1522 short an_log_peak[2]; 1508 struct hpi_control_cache_mux mux;
1523 short an_logRMS[2]; 1509 struct hpi_control_cache_level level;
1524 } p; 1510 struct hpi_control_cache_tuner tuner;
1525 struct { /* channel mode */ 1511 struct hpi_control_cache_aes3rx aes3rx;
1526 u16 mode; 1512 struct hpi_control_cache_aes3tx aes3tx;
1527 } m; 1513 struct hpi_control_cache_tonedetector tone;
1528 struct { /* multiplexer */ 1514 struct hpi_control_cache_silencedetector silence;
1529 u16 source_node_type; 1515 struct hpi_control_cache_sampleclock clk;
1530 u16 source_node_index; 1516 struct hpi_control_cache_microphone microphone;
1531 } x; 1517 struct hpi_control_cache_generic generic;
1532 struct { /* level/trim */
1533 short an_log[2];
1534 } l;
1535 struct { /* tuner - partial caching.
1536 some attributes go to the DSP. */
1537 u32 freq_ink_hz;
1538 u16 band;
1539 u16 level;
1540 } t;
1541 struct { /* AESEBU rx status */
1542 u32 error_status;
1543 u32 source;
1544 } aes3rx;
1545 struct { /* AESEBU tx */
1546 u32 format;
1547 } aes3tx;
1548 struct { /* tone detector */
1549 u16 state;
1550 } tone;
1551 struct { /* silence detector */
1552 u32 state;
1553 u32 count;
1554 } silence;
1555 struct { /* sample clock */
1556 u16 source;
1557 u16 source_index;
1558 u32 sample_rate;
1559 } clk;
1560 struct { /* microphone control */
1561 u16 state;
1562 } phantom_power;
1563 struct { /* generic control */
1564 u32 dw1;
1565 u32 dw2;
1566 } g;
1567 } u; 1518 } u;
1568}; 1519};
1569 1520
@@ -1580,8 +1531,7 @@ struct hpi_control_cache_pad {
1580 u32 traffic_anouncement; 1531 u32 traffic_anouncement;
1581}; 1532};
1582 1533
1583/*/////////////////////////////////////////////////////////////////////////// */ 1534/* 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */
1584/* declarations for 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */
1585struct hpi_fifo_buffer { 1535struct hpi_fifo_buffer {
1586 u32 size; 1536 u32 size;
1587 u32 dSP_index; 1537 u32 dSP_index;
@@ -1606,25 +1556,16 @@ u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index,
1606/*////////////////////////////////////////////////////////////////////////// */ 1556/*////////////////////////////////////////////////////////////////////////// */
1607 1557
1608/* main HPI entry point */ 1558/* main HPI entry point */
1609hpi_handler_func hpi_send_recv; 1559void hpi_send_recv(struct hpi_message *phm, struct hpi_response *phr);
1610
1611/* UDP message */
1612void hpi_send_recvUDP(struct hpi_message *phm, struct hpi_response *phr,
1613 const unsigned int timeout);
1614 1560
1615/* used in PnP OS/driver */ 1561/* used in PnP OS/driver */
1616u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys, 1562u16 hpi_subsys_create_adapter(const struct hpi_resource *p_resource,
1617 const struct hpi_resource *p_resource, u16 *pw_adapter_index); 1563 u16 *pw_adapter_index);
1618
1619u16 hpi_subsys_delete_adapter(const struct hpi_hsubsys *ph_subsys,
1620 u16 adapter_index);
1621 1564
1622u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, 1565u16 hpi_outstream_host_buffer_get_info(u32 h_outstream, u8 **pp_buffer,
1623 u32 h_outstream, u8 **pp_buffer,
1624 struct hpi_hostbuffer_status **pp_status); 1566 struct hpi_hostbuffer_status **pp_status);
1625 1567
1626u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, 1568u16 hpi_instream_host_buffer_get_info(u32 h_instream, u8 **pp_buffer,
1627 u32 h_instream, u8 **pp_buffer,
1628 struct hpi_hostbuffer_status **pp_status); 1569 struct hpi_hostbuffer_status **pp_status);
1629 1570
1630u16 hpi_adapter_restart(u16 adapter_index); 1571u16 hpi_adapter_restart(u16 adapter_index);
@@ -1642,9 +1583,7 @@ void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR);
1642 1583
1643/*////////////////////////////////////////////////////////////////////////// */ 1584/*////////////////////////////////////////////////////////////////////////// */
1644/* declarations for individual HPI entry points */ 1585/* declarations for individual HPI entry points */
1645hpi_handler_func HPI_1000;
1646hpi_handler_func HPI_6000; 1586hpi_handler_func HPI_6000;
1647hpi_handler_func HPI_6205; 1587hpi_handler_func HPI_6205;
1648hpi_handler_func HPI_COMMON;
1649 1588
1650#endif /* _HPI_INTERNAL_H_ */ 1589#endif /* _HPI_INTERNAL_H_ */
diff --git a/sound/pci/asihpi/hpicmn.c b/sound/pci/asihpi/hpicmn.c
index dda4f1c6f658..b15a02e91f82 100644
--- a/sound/pci/asihpi/hpicmn.c
+++ b/sound/pci/asihpi/hpicmn.c
@@ -26,6 +26,8 @@
26 26
27#include "hpi_internal.h" 27#include "hpi_internal.h"
28#include "hpidebug.h" 28#include "hpidebug.h"
29#include "hpimsginit.h"
30
29#include "hpicmn.h" 31#include "hpicmn.h"
30 32
31struct hpi_adapters_list { 33struct hpi_adapters_list {
@@ -43,14 +45,24 @@ static struct hpi_adapters_list adapters;
43**/ 45**/
44u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr) 46u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr)
45{ 47{
46 u16 error = 0; 48 if (phr->type != HPI_TYPE_RESPONSE) {
49 HPI_DEBUG_LOG(ERROR, "header type %d invalid\n", phr->type);
50 return HPI_ERROR_INVALID_RESPONSE;
51 }
52
53 if (phr->object != phm->object) {
54 HPI_DEBUG_LOG(ERROR, "header object %d invalid\n",
55 phr->object);
56 return HPI_ERROR_INVALID_RESPONSE;
57 }
47 58
48 if ((phr->type != HPI_TYPE_RESPONSE) 59 if (phr->function != phm->function) {
49 || (phr->object != phm->object) 60 HPI_DEBUG_LOG(ERROR, "header type %d invalid\n",
50 || (phr->function != phm->function)) 61 phr->function);
51 error = HPI_ERROR_INVALID_RESPONSE; 62 return HPI_ERROR_INVALID_RESPONSE;
63 }
52 64
53 return error; 65 return 0;
54} 66}
55 67
56u16 hpi_add_adapter(struct hpi_adapter_obj *pao) 68u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
@@ -66,8 +78,18 @@ u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
66 } 78 }
67 79
68 if (adapters.adapter[pao->index].adapter_type) { 80 if (adapters.adapter[pao->index].adapter_type) {
69 { 81 int a;
70 retval = HPI_DUPLICATE_ADAPTER_NUMBER; 82 for (a = HPI_MAX_ADAPTERS - 1; a >= 0; a--) {
83 if (!adapters.adapter[a].adapter_type) {
84 HPI_DEBUG_LOG(WARNING,
85 "ASI%X duplicate index %d moved to %d\n",
86 pao->adapter_type, pao->index, a);
87 pao->index = a;
88 break;
89 }
90 }
91 if (a < 0) {
92 retval = HPI_ERROR_DUPLICATE_ADAPTER_NUMBER;
71 goto unlock; 93 goto unlock;
72 } 94 }
73 } 95 }
@@ -76,17 +98,22 @@ u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
76 adapters.gw_num_adapters++; 98 adapters.gw_num_adapters++;
77 99
78unlock: 100unlock:
79 hpios_alistlock_un_lock(&adapters); 101 hpios_alistlock_unlock(&adapters);
80 return retval; 102 return retval;
81} 103}
82 104
83void hpi_delete_adapter(struct hpi_adapter_obj *pao) 105void hpi_delete_adapter(struct hpi_adapter_obj *pao)
84{ 106{
85 memset(pao, 0, sizeof(struct hpi_adapter_obj)); 107 if (!pao->adapter_type) {
108 HPI_DEBUG_LOG(ERROR, "removing null adapter?\n");
109 return;
110 }
86 111
87 hpios_alistlock_lock(&adapters); 112 hpios_alistlock_lock(&adapters);
88 adapters.gw_num_adapters--; /* dec the number of adapters */ 113 if (adapters.adapter[pao->index].adapter_type)
89 hpios_alistlock_un_lock(&adapters); 114 adapters.gw_num_adapters--;
115 memset(&adapters.adapter[pao->index], 0, sizeof(adapters.adapter[0]));
116 hpios_alistlock_unlock(&adapters);
90} 117}
91 118
92/** 119/**
@@ -99,7 +126,7 @@ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index)
99 struct hpi_adapter_obj *pao = NULL; 126 struct hpi_adapter_obj *pao = NULL;
100 127
101 if (adapter_index >= HPI_MAX_ADAPTERS) { 128 if (adapter_index >= HPI_MAX_ADAPTERS) {
102 HPI_DEBUG_LOG(VERBOSE, "find_adapter invalid index %d ", 129 HPI_DEBUG_LOG(VERBOSE, "find_adapter invalid index %d\n",
103 adapter_index); 130 adapter_index);
104 return NULL; 131 return NULL;
105 } 132 }
@@ -125,51 +152,34 @@ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index)
125* wipe an HPI_ADAPTERS_LIST structure. 152* wipe an HPI_ADAPTERS_LIST structure.
126* 153*
127**/ 154**/
128static void wipe_adapter_list(void 155static void wipe_adapter_list(void)
129 )
130{ 156{
131 memset(&adapters, 0, sizeof(adapters)); 157 memset(&adapters, 0, sizeof(adapters));
132} 158}
133 159
134/** 160static void subsys_get_adapter(struct hpi_message *phm,
135* SubSysGetAdapters fills awAdapterList in an struct hpi_response structure 161 struct hpi_response *phr)
136* with all adapters in the given HPI_ADAPTERS_LIST.
137*
138*/
139static void subsys_get_adapters(struct hpi_response *phr)
140{ 162{
141 /* fill in the response adapter array with the position */ 163 int count = phm->obj_index;
142 /* identified by the adapter number/index of the adapters in */ 164 u16 index = 0;
143 /* this HPI */
144 /* i.e. if we have an A120 with it's jumper set to */
145 /* Adapter Number 2 then put an Adapter type A120 in the */
146 /* array in position 1 */
147 /* NOTE: AdapterNumber is 1..N, Index is 0..N-1 */
148
149 /* input: NONE */
150 /* output: wNumAdapters */
151 /* awAdapter[] */
152 /* */
153
154 short i;
155 struct hpi_adapter_obj *pao = NULL;
156
157 HPI_DEBUG_LOG(VERBOSE, "subsys_get_adapters\n");
158 165
159 /* for each adapter, place it's type in the position of the array */ 166 /* find the nCount'th nonzero adapter in array */
160 /* corresponding to it's adapter number */ 167 for (index = 0; index < HPI_MAX_ADAPTERS; index++) {
161 for (i = 0; i < adapters.gw_num_adapters; i++) { 168 if (adapters.adapter[index].adapter_type) {
162 pao = &adapters.adapter[i]; 169 if (!count)
163 if (phr->u.s.aw_adapter_list[pao->index] != 0) { 170 break;
164 phr->error = HPI_DUPLICATE_ADAPTER_NUMBER; 171 count--;
165 phr->specific_error = pao->index;
166 return;
167 } 172 }
168 phr->u.s.aw_adapter_list[pao->index] = pao->adapter_type;
169 } 173 }
170 174
171 phr->u.s.num_adapters = adapters.gw_num_adapters; 175 if (index < HPI_MAX_ADAPTERS) {
172 phr->error = 0; /* the function completed OK; */ 176 phr->u.s.adapter_index = adapters.adapter[index].index;
177 phr->u.s.adapter_type = adapters.adapter[index].adapter_type;
178 } else {
179 phr->u.s.adapter_index = 0;
180 phr->u.s.adapter_type = 0;
181 phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER;
182 }
173} 183}
174 184
175static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC) 185static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC)
@@ -178,67 +188,99 @@ static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC)
178 int cached = 0; 188 int cached = 0;
179 if (!pC) 189 if (!pC)
180 return 0; 190 return 0;
181 if ((!pC->init) && (pC->p_cache != NULL) && (pC->control_count) 191
182 && (pC->cache_size_in_bytes) 192 if (pC->init)
183 ) { 193 return pC->init;
184 u32 *p_master_cache; 194
185 pC->init = 1; 195 if (!pC->p_cache)
186 196 return 0;
187 p_master_cache = (u32 *)pC->p_cache; 197
188 HPI_DEBUG_LOG(VERBOSE, "check %d controls\n", 198 if (pC->control_count && pC->cache_size_in_bytes) {
199 char *p_master_cache;
200 unsigned int byte_count = 0;
201
202 p_master_cache = (char *)pC->p_cache;
203 HPI_DEBUG_LOG(DEBUG, "check %d controls\n",
189 pC->control_count); 204 pC->control_count);
190 for (i = 0; i < pC->control_count; i++) { 205 for (i = 0; i < pC->control_count; i++) {
191 struct hpi_control_cache_info *info = 206 struct hpi_control_cache_info *info =
192 (struct hpi_control_cache_info *) 207 (struct hpi_control_cache_info *)
193 p_master_cache; 208 &p_master_cache[byte_count];
209
210 if (!info->size_in32bit_words) {
211 if (!i) {
212 HPI_DEBUG_LOG(INFO,
213 "adap %d cache not ready?\n",
214 pC->adap_idx);
215 return 0;
216 }
217 /* The cache is invalid.
218 * Minimum valid entry size is
219 * sizeof(struct hpi_control_cache_info)
220 */
221 HPI_DEBUG_LOG(ERROR,
222 "adap %d zero size cache entry %d\n",
223 pC->adap_idx, i);
224 break;
225 }
194 226
195 if (info->control_type) { 227 if (info->control_type) {
196 pC->p_info[i] = info; 228 pC->p_info[info->control_index] = info;
197 cached++; 229 cached++;
198 } else 230 } else { /* dummy cache entry */
199 pC->p_info[i] = NULL; 231 pC->p_info[info->control_index] = NULL;
232 }
200 233
201 if (info->size_in32bit_words) 234 byte_count += info->size_in32bit_words * 4;
202 p_master_cache += info->size_in32bit_words;
203 else
204 p_master_cache +=
205 sizeof(struct
206 hpi_control_cache_single) /
207 sizeof(u32);
208 235
209 HPI_DEBUG_LOG(VERBOSE, 236 HPI_DEBUG_LOG(VERBOSE,
210 "cached %d, pinfo %p index %d type %d\n", 237 "cached %d, pinfo %p index %d type %d size %d\n",
211 cached, pC->p_info[i], info->control_index, 238 cached, pC->p_info[info->control_index],
212 info->control_type); 239 info->control_index, info->control_type,
240 info->size_in32bit_words);
241
242 /* quit loop early if whole cache has been scanned.
243 * dwControlCount is the maximum possible entries
244 * but some may be absent from the cache
245 */
246 if (byte_count >= pC->cache_size_in_bytes)
247 break;
248 /* have seen last control index */
249 if (info->control_index == pC->control_count - 1)
250 break;
213 } 251 }
214 /* 252
215 We didn't find anything to cache, so try again later ! 253 if (byte_count != pC->cache_size_in_bytes)
216 */ 254 HPI_DEBUG_LOG(WARNING,
217 if (!cached) 255 "adap %d bytecount %d != cache size %d\n",
218 pC->init = 0; 256 pC->adap_idx, byte_count,
257 pC->cache_size_in_bytes);
258 else
259 HPI_DEBUG_LOG(DEBUG,
260 "adap %d cache good, bytecount == cache size = %d\n",
261 pC->adap_idx, byte_count);
262
263 pC->init = (u16)cached;
219 } 264 }
220 return pC->init; 265 return pC->init;
221} 266}
222 267
223/** Find a control. 268/** Find a control.
224*/ 269*/
225static short find_control(struct hpi_message *phm, 270static short find_control(u16 control_index,
226 struct hpi_control_cache *p_cache, struct hpi_control_cache_info **pI, 271 struct hpi_control_cache *p_cache, struct hpi_control_cache_info **pI)
227 u16 *pw_control_index)
228{ 272{
229 *pw_control_index = phm->obj_index;
230
231 if (!control_cache_alloc_check(p_cache)) { 273 if (!control_cache_alloc_check(p_cache)) {
232 HPI_DEBUG_LOG(VERBOSE, 274 HPI_DEBUG_LOG(VERBOSE,
233 "control_cache_alloc_check() failed. adap%d ci%d\n", 275 "control_cache_alloc_check() failed %d\n",
234 phm->adapter_index, *pw_control_index); 276 control_index);
235 return 0; 277 return 0;
236 } 278 }
237 279
238 *pI = p_cache->p_info[*pw_control_index]; 280 *pI = p_cache->p_info[control_index];
239 if (!*pI) { 281 if (!*pI) {
240 HPI_DEBUG_LOG(VERBOSE, "uncached adap %d, control %d\n", 282 HPI_DEBUG_LOG(VERBOSE, "Uncached Control %d\n",
241 phm->adapter_index, *pw_control_index); 283 control_index);
242 return 0; 284 return 0;
243 } else { 285 } else {
244 HPI_DEBUG_LOG(VERBOSE, "find_control() type %d\n", 286 HPI_DEBUG_LOG(VERBOSE, "find_control() type %d\n",
@@ -247,25 +289,6 @@ static short find_control(struct hpi_message *phm,
247 return 1; 289 return 1;
248} 290}
249 291
250/** Used by the kernel driver to figure out if a buffer needs mapping.
251 */
252short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache,
253 struct hpi_message *phm, void **p, unsigned int *pN)
254{
255 *pN = 0;
256 *p = NULL;
257 if ((phm->function == HPI_CONTROL_GET_STATE)
258 && (phm->object == HPI_OBJ_CONTROLEX)
259 ) {
260 u16 control_index;
261 struct hpi_control_cache_info *pI;
262
263 if (!find_control(phm, p_cache, &pI, &control_index))
264 return 0;
265 }
266 return 0;
267}
268
269/* allow unified treatment of several string fields within struct */ 292/* allow unified treatment of several string fields within struct */
270#define HPICMN_PAD_OFS_AND_SIZE(m) {\ 293#define HPICMN_PAD_OFS_AND_SIZE(m) {\
271 offsetof(struct hpi_control_cache_pad, m), \ 294 offsetof(struct hpi_control_cache_pad, m), \
@@ -276,7 +299,7 @@ struct pad_ofs_size {
276 unsigned int field_size; 299 unsigned int field_size;
277}; 300};
278 301
279static struct pad_ofs_size pad_desc[] = { 302static const struct pad_ofs_size pad_desc[] = {
280 HPICMN_PAD_OFS_AND_SIZE(c_channel), /* HPI_PAD_CHANNEL_NAME */ 303 HPICMN_PAD_OFS_AND_SIZE(c_channel), /* HPI_PAD_CHANNEL_NAME */
281 HPICMN_PAD_OFS_AND_SIZE(c_artist), /* HPI_PAD_ARTIST */ 304 HPICMN_PAD_OFS_AND_SIZE(c_artist), /* HPI_PAD_ARTIST */
282 HPICMN_PAD_OFS_AND_SIZE(c_title), /* HPI_PAD_TITLE */ 305 HPICMN_PAD_OFS_AND_SIZE(c_title), /* HPI_PAD_TITLE */
@@ -290,13 +313,16 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
290 struct hpi_message *phm, struct hpi_response *phr) 313 struct hpi_message *phm, struct hpi_response *phr)
291{ 314{
292 short found = 1; 315 short found = 1;
293 u16 control_index;
294 struct hpi_control_cache_info *pI; 316 struct hpi_control_cache_info *pI;
295 struct hpi_control_cache_single *pC; 317 struct hpi_control_cache_single *pC;
296 struct hpi_control_cache_pad *p_pad; 318 struct hpi_control_cache_pad *p_pad;
297 319
298 if (!find_control(phm, p_cache, &pI, &control_index)) 320 if (!find_control(phm->obj_index, p_cache, &pI)) {
321 HPI_DEBUG_LOG(VERBOSE,
322 "HPICMN find_control() failed for adap %d\n",
323 phm->adapter_index);
299 return 0; 324 return 0;
325 }
300 326
301 phr->error = 0; 327 phr->error = 0;
302 328
@@ -310,55 +336,79 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
310 336
311 case HPI_CONTROL_METER: 337 case HPI_CONTROL_METER:
312 if (phm->u.c.attribute == HPI_METER_PEAK) { 338 if (phm->u.c.attribute == HPI_METER_PEAK) {
313 phr->u.c.an_log_value[0] = pC->u.p.an_log_peak[0]; 339 phr->u.c.an_log_value[0] = pC->u.meter.an_log_peak[0];
314 phr->u.c.an_log_value[1] = pC->u.p.an_log_peak[1]; 340 phr->u.c.an_log_value[1] = pC->u.meter.an_log_peak[1];
315 } else if (phm->u.c.attribute == HPI_METER_RMS) { 341 } else if (phm->u.c.attribute == HPI_METER_RMS) {
316 phr->u.c.an_log_value[0] = pC->u.p.an_logRMS[0]; 342 if (pC->u.meter.an_logRMS[0] ==
317 phr->u.c.an_log_value[1] = pC->u.p.an_logRMS[1]; 343 HPI_CACHE_INVALID_SHORT) {
344 phr->error =
345 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
346 phr->u.c.an_log_value[0] = HPI_METER_MINIMUM;
347 phr->u.c.an_log_value[1] = HPI_METER_MINIMUM;
348 } else {
349 phr->u.c.an_log_value[0] =
350 pC->u.meter.an_logRMS[0];
351 phr->u.c.an_log_value[1] =
352 pC->u.meter.an_logRMS[1];
353 }
318 } else 354 } else
319 found = 0; 355 found = 0;
320 break; 356 break;
321 case HPI_CONTROL_VOLUME: 357 case HPI_CONTROL_VOLUME:
322 if (phm->u.c.attribute == HPI_VOLUME_GAIN) { 358 if (phm->u.c.attribute == HPI_VOLUME_GAIN) {
323 phr->u.c.an_log_value[0] = pC->u.v.an_log[0]; 359 phr->u.c.an_log_value[0] = pC->u.vol.an_log[0];
324 phr->u.c.an_log_value[1] = pC->u.v.an_log[1]; 360 phr->u.c.an_log_value[1] = pC->u.vol.an_log[1];
325 } else 361 } else if (phm->u.c.attribute == HPI_VOLUME_MUTE) {
362 if (pC->u.vol.flags & HPI_VOLUME_FLAG_HAS_MUTE) {
363 if (pC->u.vol.flags & HPI_VOLUME_FLAG_MUTED)
364 phr->u.c.param1 =
365 HPI_BITMASK_ALL_CHANNELS;
366 else
367 phr->u.c.param1 = 0;
368 } else {
369 phr->error =
370 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
371 phr->u.c.param1 = 0;
372 }
373 } else {
326 found = 0; 374 found = 0;
375 }
327 break; 376 break;
328 case HPI_CONTROL_MULTIPLEXER: 377 case HPI_CONTROL_MULTIPLEXER:
329 if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) { 378 if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) {
330 phr->u.c.param1 = pC->u.x.source_node_type; 379 phr->u.c.param1 = pC->u.mux.source_node_type;
331 phr->u.c.param2 = pC->u.x.source_node_index; 380 phr->u.c.param2 = pC->u.mux.source_node_index;
332 } else { 381 } else {
333 found = 0; 382 found = 0;
334 } 383 }
335 break; 384 break;
336 case HPI_CONTROL_CHANNEL_MODE: 385 case HPI_CONTROL_CHANNEL_MODE:
337 if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE) 386 if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE)
338 phr->u.c.param1 = pC->u.m.mode; 387 phr->u.c.param1 = pC->u.mode.mode;
339 else 388 else
340 found = 0; 389 found = 0;
341 break; 390 break;
342 case HPI_CONTROL_LEVEL: 391 case HPI_CONTROL_LEVEL:
343 if (phm->u.c.attribute == HPI_LEVEL_GAIN) { 392 if (phm->u.c.attribute == HPI_LEVEL_GAIN) {
344 phr->u.c.an_log_value[0] = pC->u.l.an_log[0]; 393 phr->u.c.an_log_value[0] = pC->u.level.an_log[0];
345 phr->u.c.an_log_value[1] = pC->u.l.an_log[1]; 394 phr->u.c.an_log_value[1] = pC->u.level.an_log[1];
346 } else 395 } else
347 found = 0; 396 found = 0;
348 break; 397 break;
349 case HPI_CONTROL_TUNER: 398 case HPI_CONTROL_TUNER:
350 if (phm->u.c.attribute == HPI_TUNER_FREQ) 399 if (phm->u.c.attribute == HPI_TUNER_FREQ)
351 phr->u.c.param1 = pC->u.t.freq_ink_hz; 400 phr->u.c.param1 = pC->u.tuner.freq_ink_hz;
352 else if (phm->u.c.attribute == HPI_TUNER_BAND) 401 else if (phm->u.c.attribute == HPI_TUNER_BAND)
353 phr->u.c.param1 = pC->u.t.band; 402 phr->u.c.param1 = pC->u.tuner.band;
354 else if ((phm->u.c.attribute == HPI_TUNER_LEVEL) 403 else if (phm->u.c.attribute == HPI_TUNER_LEVEL_AVG)
355 && (phm->u.c.param1 == HPI_TUNER_LEVEL_AVERAGE)) 404 if (pC->u.tuner.s_level_avg ==
356 if (pC->u.t.level == HPI_ERROR_ILLEGAL_CACHE_VALUE) { 405 HPI_CACHE_INVALID_SHORT) {
357 phr->u.c.param1 = 0; 406 phr->u.cu.tuner.s_level = 0;
358 phr->error = 407 phr->error =
359 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE; 408 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
360 } else 409 } else
361 phr->u.c.param1 = pC->u.t.level; 410 phr->u.cu.tuner.s_level =
411 pC->u.tuner.s_level_avg;
362 else 412 else
363 found = 0; 413 found = 0;
364 break; 414 break;
@@ -366,7 +416,7 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
366 if (phm->u.c.attribute == HPI_AESEBURX_ERRORSTATUS) 416 if (phm->u.c.attribute == HPI_AESEBURX_ERRORSTATUS)
367 phr->u.c.param1 = pC->u.aes3rx.error_status; 417 phr->u.c.param1 = pC->u.aes3rx.error_status;
368 else if (phm->u.c.attribute == HPI_AESEBURX_FORMAT) 418 else if (phm->u.c.attribute == HPI_AESEBURX_FORMAT)
369 phr->u.c.param1 = pC->u.aes3rx.source; 419 phr->u.c.param1 = pC->u.aes3rx.format;
370 else 420 else
371 found = 0; 421 found = 0;
372 break; 422 break;
@@ -385,13 +435,12 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
385 case HPI_CONTROL_SILENCEDETECTOR: 435 case HPI_CONTROL_SILENCEDETECTOR:
386 if (phm->u.c.attribute == HPI_SILENCEDETECTOR_STATE) { 436 if (phm->u.c.attribute == HPI_SILENCEDETECTOR_STATE) {
387 phr->u.c.param1 = pC->u.silence.state; 437 phr->u.c.param1 = pC->u.silence.state;
388 phr->u.c.param2 = pC->u.silence.count;
389 } else 438 } else
390 found = 0; 439 found = 0;
391 break; 440 break;
392 case HPI_CONTROL_MICROPHONE: 441 case HPI_CONTROL_MICROPHONE:
393 if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER) 442 if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER)
394 phr->u.c.param1 = pC->u.phantom_power.state; 443 phr->u.c.param1 = pC->u.microphone.phantom_state;
395 else 444 else
396 found = 0; 445 found = 0;
397 break; 446 break;
@@ -400,7 +449,7 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
400 phr->u.c.param1 = pC->u.clk.source; 449 phr->u.c.param1 = pC->u.clk.source;
401 else if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE_INDEX) { 450 else if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE_INDEX) {
402 if (pC->u.clk.source_index == 451 if (pC->u.clk.source_index ==
403 HPI_ERROR_ILLEGAL_CACHE_VALUE) { 452 HPI_CACHE_INVALID_UINT16) {
404 phr->u.c.param1 = 0; 453 phr->u.c.param1 = 0;
405 phr->error = 454 phr->error =
406 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE; 455 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
@@ -411,60 +460,63 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
411 else 460 else
412 found = 0; 461 found = 0;
413 break; 462 break;
414 case HPI_CONTROL_PAD: 463 case HPI_CONTROL_PAD:{
415 464 struct hpi_control_cache_pad *p_pad;
416 if (!(p_pad->field_valid_flags & (1 << 465 p_pad = (struct hpi_control_cache_pad *)pI;
417 HPI_CTL_ATTR_INDEX(phm->u.c.
418 attribute)))) {
419 phr->error = HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
420 break;
421 }
422 466
423 if (phm->u.c.attribute == HPI_PAD_PROGRAM_ID) 467 if (!(p_pad->field_valid_flags & (1 <<
424 phr->u.c.param1 = p_pad->pI; 468 HPI_CTL_ATTR_INDEX(phm->u.c.
425 else if (phm->u.c.attribute == HPI_PAD_PROGRAM_TYPE) 469 attribute)))) {
426 phr->u.c.param1 = p_pad->pTY;
427 else {
428 unsigned int index =
429 HPI_CTL_ATTR_INDEX(phm->u.c.attribute) - 1;
430 unsigned int offset = phm->u.c.param1;
431 unsigned int pad_string_len, field_size;
432 char *pad_string;
433 unsigned int tocopy;
434
435 HPI_DEBUG_LOG(VERBOSE, "PADS HPI_PADS_ %d\n",
436 phm->u.c.attribute);
437
438 if (index > ARRAY_SIZE(pad_desc) - 1) {
439 phr->error = 470 phr->error =
440 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE; 471 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
441 break; 472 break;
442 } 473 }
443 474
444 pad_string = ((char *)p_pad) + pad_desc[index].offset; 475 if (phm->u.c.attribute == HPI_PAD_PROGRAM_ID)
445 field_size = pad_desc[index].field_size; 476 phr->u.c.param1 = p_pad->pI;
446 /* Ensure null terminator */ 477 else if (phm->u.c.attribute == HPI_PAD_PROGRAM_TYPE)
447 pad_string[field_size - 1] = 0; 478 phr->u.c.param1 = p_pad->pTY;
448 479 else {
449 pad_string_len = strlen(pad_string) + 1; 480 unsigned int index =
450 481 HPI_CTL_ATTR_INDEX(phm->u.c.
451 if (offset > pad_string_len) { 482 attribute) - 1;
452 phr->error = HPI_ERROR_INVALID_CONTROL_VALUE; 483 unsigned int offset = phm->u.c.param1;
453 break; 484 unsigned int pad_string_len, field_size;
485 char *pad_string;
486 unsigned int tocopy;
487
488 if (index > ARRAY_SIZE(pad_desc) - 1) {
489 phr->error =
490 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
491 break;
492 }
493
494 pad_string =
495 ((char *)p_pad) +
496 pad_desc[index].offset;
497 field_size = pad_desc[index].field_size;
498 /* Ensure null terminator */
499 pad_string[field_size - 1] = 0;
500
501 pad_string_len = strlen(pad_string) + 1;
502
503 if (offset > pad_string_len) {
504 phr->error =
505 HPI_ERROR_INVALID_CONTROL_VALUE;
506 break;
507 }
508
509 tocopy = pad_string_len - offset;
510 if (tocopy > sizeof(phr->u.cu.chars8.sz_data))
511 tocopy = sizeof(phr->u.cu.chars8.
512 sz_data);
513
514 memcpy(phr->u.cu.chars8.sz_data,
515 &pad_string[offset], tocopy);
516
517 phr->u.cu.chars8.remaining_chars =
518 pad_string_len - offset - tocopy;
454 } 519 }
455
456 tocopy = pad_string_len - offset;
457 if (tocopy > sizeof(phr->u.cu.chars8.sz_data))
458 tocopy = sizeof(phr->u.cu.chars8.sz_data);
459
460 HPI_DEBUG_LOG(VERBOSE,
461 "PADS memcpy(%d), offset %d \n", tocopy,
462 offset);
463 memcpy(phr->u.cu.chars8.sz_data, &pad_string[offset],
464 tocopy);
465
466 phr->u.cu.chars8.remaining_chars =
467 pad_string_len - offset - tocopy;
468 } 520 }
469 break; 521 break;
470 default: 522 default:
@@ -472,16 +524,9 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
472 break; 524 break;
473 } 525 }
474 526
475 if (found) 527 HPI_DEBUG_LOG(VERBOSE, "%s Adap %d, Ctl %d, Type %d, Attr %d\n",
476 HPI_DEBUG_LOG(VERBOSE, 528 found ? "Cached" : "Uncached", phm->adapter_index,
477 "cached adap %d, ctl %d, type %d, attr %d\n", 529 pI->control_index, pI->control_type, phm->u.c.attribute);
478 phm->adapter_index, pI->control_index,
479 pI->control_type, phm->u.c.attribute);
480 else
481 HPI_DEBUG_LOG(VERBOSE,
482 "uncached adap %d, ctl %d, ctl type %d\n",
483 phm->adapter_index, pI->control_index,
484 pI->control_type);
485 530
486 if (found) 531 if (found)
487 phr->size = 532 phr->size =
@@ -497,18 +542,21 @@ Only update if no error.
497Volume and Level return the limited values in the response, so use these 542Volume and Level return the limited values in the response, so use these
498Multiplexer does so use sent values 543Multiplexer does so use sent values
499*/ 544*/
500void hpi_sync_control_cache(struct hpi_control_cache *p_cache, 545void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *p_cache,
501 struct hpi_message *phm, struct hpi_response *phr) 546 struct hpi_message *phm, struct hpi_response *phr)
502{ 547{
503 u16 control_index;
504 struct hpi_control_cache_single *pC; 548 struct hpi_control_cache_single *pC;
505 struct hpi_control_cache_info *pI; 549 struct hpi_control_cache_info *pI;
506 550
507 if (phr->error) 551 if (phr->error)
508 return; 552 return;
509 553
510 if (!find_control(phm, p_cache, &pI, &control_index)) 554 if (!find_control(phm->obj_index, p_cache, &pI)) {
555 HPI_DEBUG_LOG(VERBOSE,
556 "HPICMN find_control() failed for adap %d\n",
557 phm->adapter_index);
511 return; 558 return;
559 }
512 560
513 /* pC is the default cached control strucure. 561 /* pC is the default cached control strucure.
514 May be cast to something else in the following switch statement. 562 May be cast to something else in the following switch statement.
@@ -518,31 +566,36 @@ void hpi_sync_control_cache(struct hpi_control_cache *p_cache,
518 switch (pI->control_type) { 566 switch (pI->control_type) {
519 case HPI_CONTROL_VOLUME: 567 case HPI_CONTROL_VOLUME:
520 if (phm->u.c.attribute == HPI_VOLUME_GAIN) { 568 if (phm->u.c.attribute == HPI_VOLUME_GAIN) {
521 pC->u.v.an_log[0] = phr->u.c.an_log_value[0]; 569 pC->u.vol.an_log[0] = phr->u.c.an_log_value[0];
522 pC->u.v.an_log[1] = phr->u.c.an_log_value[1]; 570 pC->u.vol.an_log[1] = phr->u.c.an_log_value[1];
571 } else if (phm->u.c.attribute == HPI_VOLUME_MUTE) {
572 if (phm->u.c.param1)
573 pC->u.vol.flags |= HPI_VOLUME_FLAG_MUTED;
574 else
575 pC->u.vol.flags &= ~HPI_VOLUME_FLAG_MUTED;
523 } 576 }
524 break; 577 break;
525 case HPI_CONTROL_MULTIPLEXER: 578 case HPI_CONTROL_MULTIPLEXER:
526 /* mux does not return its setting on Set command. */ 579 /* mux does not return its setting on Set command. */
527 if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) { 580 if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) {
528 pC->u.x.source_node_type = (u16)phm->u.c.param1; 581 pC->u.mux.source_node_type = (u16)phm->u.c.param1;
529 pC->u.x.source_node_index = (u16)phm->u.c.param2; 582 pC->u.mux.source_node_index = (u16)phm->u.c.param2;
530 } 583 }
531 break; 584 break;
532 case HPI_CONTROL_CHANNEL_MODE: 585 case HPI_CONTROL_CHANNEL_MODE:
533 /* mode does not return its setting on Set command. */ 586 /* mode does not return its setting on Set command. */
534 if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE) 587 if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE)
535 pC->u.m.mode = (u16)phm->u.c.param1; 588 pC->u.mode.mode = (u16)phm->u.c.param1;
536 break; 589 break;
537 case HPI_CONTROL_LEVEL: 590 case HPI_CONTROL_LEVEL:
538 if (phm->u.c.attribute == HPI_LEVEL_GAIN) { 591 if (phm->u.c.attribute == HPI_LEVEL_GAIN) {
539 pC->u.v.an_log[0] = phr->u.c.an_log_value[0]; 592 pC->u.vol.an_log[0] = phr->u.c.an_log_value[0];
540 pC->u.v.an_log[1] = phr->u.c.an_log_value[1]; 593 pC->u.vol.an_log[1] = phr->u.c.an_log_value[1];
541 } 594 }
542 break; 595 break;
543 case HPI_CONTROL_MICROPHONE: 596 case HPI_CONTROL_MICROPHONE:
544 if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER) 597 if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER)
545 pC->u.phantom_power.state = (u16)phm->u.c.param1; 598 pC->u.microphone.phantom_state = (u16)phm->u.c.param1;
546 break; 599 break;
547 case HPI_CONTROL_AESEBU_TRANSMITTER: 600 case HPI_CONTROL_AESEBU_TRANSMITTER:
548 if (phm->u.c.attribute == HPI_AESEBUTX_FORMAT) 601 if (phm->u.c.attribute == HPI_AESEBUTX_FORMAT)
@@ -550,7 +603,7 @@ void hpi_sync_control_cache(struct hpi_control_cache *p_cache,
550 break; 603 break;
551 case HPI_CONTROL_AESEBU_RECEIVER: 604 case HPI_CONTROL_AESEBU_RECEIVER:
552 if (phm->u.c.attribute == HPI_AESEBURX_FORMAT) 605 if (phm->u.c.attribute == HPI_AESEBURX_FORMAT)
553 pC->u.aes3rx.source = phm->u.c.param1; 606 pC->u.aes3rx.format = phm->u.c.param1;
554 break; 607 break;
555 case HPI_CONTROL_SAMPLECLOCK: 608 case HPI_CONTROL_SAMPLECLOCK:
556 if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE) 609 if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE)
@@ -565,53 +618,60 @@ void hpi_sync_control_cache(struct hpi_control_cache *p_cache,
565 } 618 }
566} 619}
567 620
568struct hpi_control_cache *hpi_alloc_control_cache(const u32 621/** Allocate control cache.
569 number_of_controls, const u32 size_in_bytes, 622
570 struct hpi_control_cache_info *pDSP_control_buffer) 623\return Cache pointer, or NULL if allocation fails.
624*/
625struct hpi_control_cache *hpi_alloc_control_cache(const u32 control_count,
626 const u32 size_in_bytes, u8 *p_dsp_control_buffer)
571{ 627{
572 struct hpi_control_cache *p_cache = 628 struct hpi_control_cache *p_cache =
573 kmalloc(sizeof(*p_cache), GFP_KERNEL); 629 kmalloc(sizeof(*p_cache), GFP_KERNEL);
630 if (!p_cache)
631 return NULL;
632
633 p_cache->p_info =
634 kmalloc(sizeof(*p_cache->p_info) * control_count, GFP_KERNEL);
635 if (!p_cache->p_info) {
636 kfree(p_cache);
637 return NULL;
638 }
639 memset(p_cache->p_info, 0, sizeof(*p_cache->p_info) * control_count);
574 p_cache->cache_size_in_bytes = size_in_bytes; 640 p_cache->cache_size_in_bytes = size_in_bytes;
575 p_cache->control_count = number_of_controls; 641 p_cache->control_count = control_count;
576 p_cache->p_cache = 642 p_cache->p_cache = p_dsp_control_buffer;
577 (struct hpi_control_cache_single *)pDSP_control_buffer;
578 p_cache->init = 0; 643 p_cache->init = 0;
579 p_cache->p_info =
580 kmalloc(sizeof(*p_cache->p_info) * p_cache->control_count,
581 GFP_KERNEL);
582 return p_cache; 644 return p_cache;
583} 645}
584 646
585void hpi_free_control_cache(struct hpi_control_cache *p_cache) 647void hpi_free_control_cache(struct hpi_control_cache *p_cache)
586{ 648{
587 if (p_cache->init) { 649 if (p_cache) {
588 kfree(p_cache->p_info); 650 kfree(p_cache->p_info);
589 p_cache->p_info = NULL;
590 p_cache->init = 0;
591 kfree(p_cache); 651 kfree(p_cache);
592 } 652 }
593} 653}
594 654
595static void subsys_message(struct hpi_message *phm, struct hpi_response *phr) 655static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
596{ 656{
657 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, phm->function, 0);
597 658
598 switch (phm->function) { 659 switch (phm->function) {
599 case HPI_SUBSYS_OPEN: 660 case HPI_SUBSYS_OPEN:
600 case HPI_SUBSYS_CLOSE: 661 case HPI_SUBSYS_CLOSE:
601 case HPI_SUBSYS_DRIVER_UNLOAD: 662 case HPI_SUBSYS_DRIVER_UNLOAD:
602 phr->error = 0;
603 break; 663 break;
604 case HPI_SUBSYS_DRIVER_LOAD: 664 case HPI_SUBSYS_DRIVER_LOAD:
605 wipe_adapter_list(); 665 wipe_adapter_list();
606 hpios_alistlock_init(&adapters); 666 hpios_alistlock_init(&adapters);
607 phr->error = 0;
608 break; 667 break;
609 case HPI_SUBSYS_GET_INFO: 668 case HPI_SUBSYS_GET_ADAPTER:
610 subsys_get_adapters(phr); 669 subsys_get_adapter(phm, phr);
670 break;
671 case HPI_SUBSYS_GET_NUM_ADAPTERS:
672 phr->u.s.num_adapters = adapters.gw_num_adapters;
611 break; 673 break;
612 case HPI_SUBSYS_CREATE_ADAPTER: 674 case HPI_SUBSYS_CREATE_ADAPTER:
613 case HPI_SUBSYS_DELETE_ADAPTER:
614 phr->error = 0;
615 break; 675 break;
616 default: 676 default:
617 phr->error = HPI_ERROR_INVALID_FUNC; 677 phr->error = HPI_ERROR_INVALID_FUNC;
diff --git a/sound/pci/asihpi/hpicmn.h b/sound/pci/asihpi/hpicmn.h
index 6229022f56cb..d53cdf6e535f 100644
--- a/sound/pci/asihpi/hpicmn.h
+++ b/sound/pci/asihpi/hpicmn.h
@@ -33,18 +33,19 @@ struct hpi_adapter_obj {
33}; 33};
34 34
35struct hpi_control_cache { 35struct hpi_control_cache {
36 u32 init; /**< indicates whether the 36 /** indicates whether the structures are initialized */
37 structures are initialized */ 37 u16 init;
38 u16 adap_idx;
38 u32 control_count; 39 u32 control_count;
39 u32 cache_size_in_bytes; 40 u32 cache_size_in_bytes;
40 struct hpi_control_cache_info 41 /** pointer to allocated memory of lookup pointers. */
41 **p_info; /**< pointer to allocated memory of 42 struct hpi_control_cache_info **p_info;
42 lookup pointers. */ 43 /** pointer to DSP's control cache. */
43 struct hpi_control_cache_single 44 u8 *p_cache;
44 *p_cache; /**< pointer to DSP's control cache. */
45}; 45};
46 46
47struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index); 47struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index);
48
48u16 hpi_add_adapter(struct hpi_adapter_obj *pao); 49u16 hpi_add_adapter(struct hpi_adapter_obj *pao);
49 50
50void hpi_delete_adapter(struct hpi_adapter_obj *pao); 51void hpi_delete_adapter(struct hpi_adapter_obj *pao);
@@ -52,13 +53,12 @@ void hpi_delete_adapter(struct hpi_adapter_obj *pao);
52short hpi_check_control_cache(struct hpi_control_cache *pC, 53short hpi_check_control_cache(struct hpi_control_cache *pC,
53 struct hpi_message *phm, struct hpi_response *phr); 54 struct hpi_message *phm, struct hpi_response *phr);
54struct hpi_control_cache *hpi_alloc_control_cache(const u32 55struct hpi_control_cache *hpi_alloc_control_cache(const u32
55 number_of_controls, const u32 size_in_bytes, 56 number_of_controls, const u32 size_in_bytes, u8 *pDSP_control_buffer);
56 struct hpi_control_cache_info
57 *pDSP_control_buffer);
58void hpi_free_control_cache(struct hpi_control_cache *p_cache); 57void hpi_free_control_cache(struct hpi_control_cache *p_cache);
59 58
60void hpi_sync_control_cache(struct hpi_control_cache *pC, 59void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *pC,
61 struct hpi_message *phm, struct hpi_response *phr); 60 struct hpi_message *phm, struct hpi_response *phr);
61
62u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr); 62u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr);
63short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache, 63
64 struct hpi_message *phm, void **p, unsigned int *pN); 64hpi_handler_func HPI_COMMON;
diff --git a/sound/pci/asihpi/hpidebug.c b/sound/pci/asihpi/hpidebug.c
index 949836ec913a..b52baf62791e 100644
--- a/sound/pci/asihpi/hpidebug.c
+++ b/sound/pci/asihpi/hpidebug.c
@@ -45,161 +45,14 @@ int hpi_debug_level_get(void)
45 return hpi_debug_level; 45 return hpi_debug_level;
46} 46}
47 47
48#ifdef HPIOS_DEBUG_PRINT
49/* implies OS has no printf-like function */
50#include <stdarg.h>
51
52void hpi_debug_printf(char *fmt, ...)
53{
54 va_list arglist;
55 char buffer[128];
56
57 va_start(arglist, fmt);
58
59 if (buffer[0])
60 HPIOS_DEBUG_PRINT(buffer);
61 va_end(arglist);
62}
63#endif
64
65struct treenode {
66 void *array;
67 unsigned int num_elements;
68};
69
70#define make_treenode_from_array(nodename, array) \
71static void *tmp_strarray_##nodename[] = array; \
72static struct treenode nodename = { \
73 &tmp_strarray_##nodename, \
74 ARRAY_SIZE(tmp_strarray_##nodename) \
75};
76
77#define get_treenode_elem(node_ptr, idx, type) \
78 (&(*((type *)(node_ptr)->array)[idx]))
79
80make_treenode_from_array(hpi_control_type_strings, HPI_CONTROL_TYPE_STRINGS)
81
82 make_treenode_from_array(hpi_subsys_strings, HPI_SUBSYS_STRINGS)
83 make_treenode_from_array(hpi_adapter_strings, HPI_ADAPTER_STRINGS)
84 make_treenode_from_array(hpi_istream_strings, HPI_ISTREAM_STRINGS)
85 make_treenode_from_array(hpi_ostream_strings, HPI_OSTREAM_STRINGS)
86 make_treenode_from_array(hpi_mixer_strings, HPI_MIXER_STRINGS)
87 make_treenode_from_array(hpi_node_strings,
88 {
89 "NODE is invalid object"})
90
91 make_treenode_from_array(hpi_control_strings, HPI_CONTROL_STRINGS)
92 make_treenode_from_array(hpi_nvmemory_strings, HPI_OBJ_STRINGS)
93 make_treenode_from_array(hpi_digitalio_strings, HPI_DIGITALIO_STRINGS)
94 make_treenode_from_array(hpi_watchdog_strings, HPI_WATCHDOG_STRINGS)
95 make_treenode_from_array(hpi_clock_strings, HPI_CLOCK_STRINGS)
96 make_treenode_from_array(hpi_profile_strings, HPI_PROFILE_STRINGS)
97 make_treenode_from_array(hpi_asyncevent_strings, HPI_ASYNCEVENT_STRINGS)
98#define HPI_FUNCTION_STRINGS \
99{ \
100 &hpi_subsys_strings,\
101 &hpi_adapter_strings,\
102 &hpi_ostream_strings,\
103 &hpi_istream_strings,\
104 &hpi_mixer_strings,\
105 &hpi_node_strings,\
106 &hpi_control_strings,\
107 &hpi_nvmemory_strings,\
108 &hpi_digitalio_strings,\
109 &hpi_watchdog_strings,\
110 &hpi_clock_strings,\
111 &hpi_profile_strings,\
112 &hpi_control_strings, \
113 &hpi_asyncevent_strings \
114}
115 make_treenode_from_array(hpi_function_strings, HPI_FUNCTION_STRINGS)
116
117 compile_time_assert(HPI_OBJ_MAXINDEX == 14, obj_list_doesnt_match);
118
119static char *hpi_function_string(unsigned int function)
120{
121 unsigned int object;
122 struct treenode *tmp;
123
124 object = function / HPI_OBJ_FUNCTION_SPACING;
125 function = function - object * HPI_OBJ_FUNCTION_SPACING;
126
127 if (object == 0 || object == HPI_OBJ_NODE
128 || object > hpi_function_strings.num_elements)
129 return "invalid object";
130
131 tmp = get_treenode_elem(&hpi_function_strings, object - 1,
132 struct treenode *);
133
134 if (function == 0 || function > tmp->num_elements)
135 return "invalid function";
136
137 return get_treenode_elem(tmp, function - 1, char *);
138}
139
140void hpi_debug_message(struct hpi_message *phm, char *sz_fileline) 48void hpi_debug_message(struct hpi_message *phm, char *sz_fileline)
141{ 49{
142 if (phm) { 50 if (phm) {
143 if ((phm->object <= HPI_OBJ_MAXINDEX) && phm->object) { 51 printk(KERN_DEBUG "HPI_MSG%d,%d,%d,%d,%d\n", phm->version,
144 u16 index = 0; 52 phm->adapter_index, phm->obj_index, phm->function,
145 u16 attrib = 0; 53 phm->u.c.attribute);
146 int is_control = 0; 54 }
147 55
148 index = phm->obj_index;
149 switch (phm->object) {
150 case HPI_OBJ_ADAPTER:
151 case HPI_OBJ_PROFILE:
152 break;
153 case HPI_OBJ_MIXER:
154 if (phm->function ==
155 HPI_MIXER_GET_CONTROL_BY_INDEX)
156 index = phm->u.m.control_index;
157 break;
158 case HPI_OBJ_OSTREAM:
159 case HPI_OBJ_ISTREAM:
160 break;
161
162 case HPI_OBJ_CONTROLEX:
163 case HPI_OBJ_CONTROL:
164 if (phm->version == 1)
165 attrib = HPI_CTL_ATTR(UNIVERSAL, 1);
166 else
167 attrib = phm->u.c.attribute;
168 is_control = 1;
169 break;
170 default:
171 break;
172 }
173
174 if (is_control && (attrib & 0xFF00)) {
175 int control_type = (attrib & 0xFF00) >> 8;
176 int attr_index = HPI_CTL_ATTR_INDEX(attrib);
177 /* note the KERN facility level
178 is in szFileline already */
179 printk("%s adapter %d %s "
180 "ctrl_index x%04x %s %d\n",
181 sz_fileline, phm->adapter_index,
182 hpi_function_string(phm->function),
183 index,
184 get_treenode_elem
185 (&hpi_control_type_strings,
186 control_type, char *),
187 attr_index);
188
189 } else
190 printk("%s adapter %d %s "
191 "idx x%04x attr x%04x \n",
192 sz_fileline, phm->adapter_index,
193 hpi_function_string(phm->function),
194 index, attrib);
195 } else {
196 printk("adap=%d, invalid obj=%d, func=0x%x\n",
197 phm->adapter_index, phm->object,
198 phm->function);
199 }
200 } else
201 printk(KERN_ERR
202 "NULL message pointer to hpi_debug_message!\n");
203} 56}
204 57
205void hpi_debug_data(u16 *pdata, u32 len) 58void hpi_debug_data(u16 *pdata, u32 len)
diff --git a/sound/pci/asihpi/hpidebug.h b/sound/pci/asihpi/hpidebug.h
index a2f0952a99f0..940f54c3c538 100644
--- a/sound/pci/asihpi/hpidebug.h
+++ b/sound/pci/asihpi/hpidebug.h
@@ -37,7 +37,7 @@ enum { HPI_DEBUG_LEVEL_ERROR = 0, /* always log errors */
37#define HPI_DEBUG_LEVEL_DEFAULT HPI_DEBUG_LEVEL_NOTICE 37#define HPI_DEBUG_LEVEL_DEFAULT HPI_DEBUG_LEVEL_NOTICE
38 38
39/* an OS can define an extra flag string that is appended to 39/* an OS can define an extra flag string that is appended to
40 the start of each message, eg see hpios_linux.h */ 40 the start of each message, eg see linux kernel hpios.h */
41 41
42#ifdef SOURCEFILE_NAME 42#ifdef SOURCEFILE_NAME
43#define FILE_LINE SOURCEFILE_NAME ":" __stringify(__LINE__) " " 43#define FILE_LINE SOURCEFILE_NAME ":" __stringify(__LINE__) " "
@@ -45,18 +45,11 @@ enum { HPI_DEBUG_LEVEL_ERROR = 0, /* always log errors */
45#define FILE_LINE __FILE__ ":" __stringify(__LINE__) " " 45#define FILE_LINE __FILE__ ":" __stringify(__LINE__) " "
46#endif 46#endif
47 47
48#if defined(HPI_DEBUG) && defined(_WINDOWS)
49#define HPI_DEBUGBREAK() debug_break()
50#else
51#define HPI_DEBUGBREAK()
52#endif
53
54#define HPI_DEBUG_ASSERT(expression) \ 48#define HPI_DEBUG_ASSERT(expression) \
55 do { \ 49 do { \
56 if (!(expression)) {\ 50 if (!(expression)) { \
57 printk(KERN_ERR FILE_LINE\ 51 printk(KERN_ERR FILE_LINE \
58 "ASSERT " __stringify(expression));\ 52 "ASSERT " __stringify(expression)); \
59 HPI_DEBUGBREAK();\
60 } \ 53 } \
61 } while (0) 54 } while (0)
62 55
@@ -78,28 +71,27 @@ void hpi_debug_message(struct hpi_message *phm, char *sz_fileline);
78 71
79void hpi_debug_data(u16 *pdata, u32 len); 72void hpi_debug_data(u16 *pdata, u32 len);
80 73
81#define HPI_DEBUG_DATA(pdata, len) \ 74#define HPI_DEBUG_DATA(pdata, len) \
82 do { \ 75 do { \
83 if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE) \ 76 if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE) \
84 hpi_debug_data(pdata, len); \ 77 hpi_debug_data(pdata, len); \
85 } while (0) 78 } while (0)
86 79
87#define HPI_DEBUG_MESSAGE(level, phm) \ 80#define HPI_DEBUG_MESSAGE(level, phm) \
88 do { \ 81 do { \
89 if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \ 82 if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \
90 hpi_debug_message(phm,HPI_DEBUG_FLAG_##level \ 83 hpi_debug_message(phm, HPI_DEBUG_FLAG_##level \
91 FILE_LINE __stringify(level));\ 84 FILE_LINE __stringify(level)); \
92 } \ 85 } \
93 } while (0) 86 } while (0)
94 87
95#define HPI_DEBUG_RESPONSE(phr) \ 88#define HPI_DEBUG_RESPONSE(phr) \
96 do { \ 89 do { \
97 if ((hpi_debug_level >= HPI_DEBUG_LEVEL_DEBUG) && (phr->error))\ 90 if (((hpi_debug_level >= HPI_DEBUG_LEVEL_DEBUG) && \
98 HPI_DEBUG_LOG(ERROR, \ 91 (phr->error)) ||\
99 "HPI response - error# %d\n", \ 92 (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE)) \
100 phr->error); \ 93 printk(KERN_DEBUG "HPI_RES%d,%d,%d\n", \
101 else if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE) \ 94 phr->version, phr->error, phr->specific_error); \
102 HPI_DEBUG_LOG(VERBOSE, "HPI response OK\n");\
103 } while (0) 95 } while (0)
104 96
105#ifndef compile_time_assert 97#ifndef compile_time_assert
@@ -107,279 +99,4 @@ void hpi_debug_data(u16 *pdata, u32 len);
107 typedef char msg[(cond) ? 1 : -1] 99 typedef char msg[(cond) ? 1 : -1]
108#endif 100#endif
109 101
110 /* check that size is exactly some number */ 102#endif /* _HPIDEBUG_H_ */
111#define function_count_check(sym, size) \
112 compile_time_assert((sym##_FUNCTION_COUNT) == (size),\
113 strings_match_defs_##sym)
114
115/* These strings should be generated using a macro which defines
116 the corresponding symbol values. */
117#define HPI_OBJ_STRINGS \
118{ \
119 "HPI_OBJ_SUBSYSTEM", \
120 "HPI_OBJ_ADAPTER", \
121 "HPI_OBJ_OSTREAM", \
122 "HPI_OBJ_ISTREAM", \
123 "HPI_OBJ_MIXER", \
124 "HPI_OBJ_NODE", \
125 "HPI_OBJ_CONTROL", \
126 "HPI_OBJ_NVMEMORY", \
127 "HPI_OBJ_DIGITALIO", \
128 "HPI_OBJ_WATCHDOG", \
129 "HPI_OBJ_CLOCK", \
130 "HPI_OBJ_PROFILE", \
131 "HPI_OBJ_CONTROLEX" \
132}
133
134#define HPI_SUBSYS_STRINGS \
135{ \
136 "HPI_SUBSYS_OPEN", \
137 "HPI_SUBSYS_GET_VERSION", \
138 "HPI_SUBSYS_GET_INFO", \
139 "HPI_SUBSYS_FIND_ADAPTERS", \
140 "HPI_SUBSYS_CREATE_ADAPTER",\
141 "HPI_SUBSYS_CLOSE", \
142 "HPI_SUBSYS_DELETE_ADAPTER", \
143 "HPI_SUBSYS_DRIVER_LOAD", \
144 "HPI_SUBSYS_DRIVER_UNLOAD", \
145 "HPI_SUBSYS_READ_PORT_8", \
146 "HPI_SUBSYS_WRITE_PORT_8", \
147 "HPI_SUBSYS_GET_NUM_ADAPTERS",\
148 "HPI_SUBSYS_GET_ADAPTER", \
149 "HPI_SUBSYS_SET_NETWORK_INTERFACE"\
150}
151function_count_check(HPI_SUBSYS, 14);
152
153#define HPI_ADAPTER_STRINGS \
154{ \
155 "HPI_ADAPTER_OPEN", \
156 "HPI_ADAPTER_CLOSE", \
157 "HPI_ADAPTER_GET_INFO", \
158 "HPI_ADAPTER_GET_ASSERT", \
159 "HPI_ADAPTER_TEST_ASSERT", \
160 "HPI_ADAPTER_SET_MODE", \
161 "HPI_ADAPTER_GET_MODE", \
162 "HPI_ADAPTER_ENABLE_CAPABILITY",\
163 "HPI_ADAPTER_SELFTEST", \
164 "HPI_ADAPTER_FIND_OBJECT", \
165 "HPI_ADAPTER_QUERY_FLASH", \
166 "HPI_ADAPTER_START_FLASH", \
167 "HPI_ADAPTER_PROGRAM_FLASH", \
168 "HPI_ADAPTER_SET_PROPERTY", \
169 "HPI_ADAPTER_GET_PROPERTY", \
170 "HPI_ADAPTER_ENUM_PROPERTY", \
171 "HPI_ADAPTER_MODULE_INFO", \
172 "HPI_ADAPTER_DEBUG_READ" \
173}
174
175function_count_check(HPI_ADAPTER, 18);
176
177#define HPI_OSTREAM_STRINGS \
178{ \
179 "HPI_OSTREAM_OPEN", \
180 "HPI_OSTREAM_CLOSE", \
181 "HPI_OSTREAM_WRITE", \
182 "HPI_OSTREAM_START", \
183 "HPI_OSTREAM_STOP", \
184 "HPI_OSTREAM_RESET", \
185 "HPI_OSTREAM_GET_INFO", \
186 "HPI_OSTREAM_QUERY_FORMAT", \
187 "HPI_OSTREAM_DATA", \
188 "HPI_OSTREAM_SET_VELOCITY", \
189 "HPI_OSTREAM_SET_PUNCHINOUT", \
190 "HPI_OSTREAM_SINEGEN", \
191 "HPI_OSTREAM_ANC_RESET", \
192 "HPI_OSTREAM_ANC_GET_INFO", \
193 "HPI_OSTREAM_ANC_READ", \
194 "HPI_OSTREAM_SET_TIMESCALE",\
195 "HPI_OSTREAM_SET_FORMAT", \
196 "HPI_OSTREAM_HOSTBUFFER_ALLOC", \
197 "HPI_OSTREAM_HOSTBUFFER_FREE", \
198 "HPI_OSTREAM_GROUP_ADD",\
199 "HPI_OSTREAM_GROUP_GETMAP", \
200 "HPI_OSTREAM_GROUP_RESET", \
201 "HPI_OSTREAM_HOSTBUFFER_GET_INFO", \
202 "HPI_OSTREAM_WAIT_START", \
203}
204function_count_check(HPI_OSTREAM, 24);
205
206#define HPI_ISTREAM_STRINGS \
207{ \
208 "HPI_ISTREAM_OPEN", \
209 "HPI_ISTREAM_CLOSE", \
210 "HPI_ISTREAM_SET_FORMAT", \
211 "HPI_ISTREAM_READ", \
212 "HPI_ISTREAM_START", \
213 "HPI_ISTREAM_STOP", \
214 "HPI_ISTREAM_RESET", \
215 "HPI_ISTREAM_GET_INFO", \
216 "HPI_ISTREAM_QUERY_FORMAT", \
217 "HPI_ISTREAM_ANC_RESET", \
218 "HPI_ISTREAM_ANC_GET_INFO", \
219 "HPI_ISTREAM_ANC_WRITE", \
220 "HPI_ISTREAM_HOSTBUFFER_ALLOC",\
221 "HPI_ISTREAM_HOSTBUFFER_FREE", \
222 "HPI_ISTREAM_GROUP_ADD", \
223 "HPI_ISTREAM_GROUP_GETMAP", \
224 "HPI_ISTREAM_GROUP_RESET", \
225 "HPI_ISTREAM_HOSTBUFFER_GET_INFO", \
226 "HPI_ISTREAM_WAIT_START", \
227}
228function_count_check(HPI_ISTREAM, 19);
229
230#define HPI_MIXER_STRINGS \
231{ \
232 "HPI_MIXER_OPEN", \
233 "HPI_MIXER_CLOSE", \
234 "HPI_MIXER_GET_INFO", \
235 "HPI_MIXER_GET_NODE_INFO", \
236 "HPI_MIXER_GET_CONTROL", \
237 "HPI_MIXER_SET_CONNECTION", \
238 "HPI_MIXER_GET_CONNECTIONS", \
239 "HPI_MIXER_GET_CONTROL_BY_INDEX", \
240 "HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX", \
241 "HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES", \
242 "HPI_MIXER_STORE", \
243}
244function_count_check(HPI_MIXER, 11);
245
246#define HPI_CONTROL_STRINGS \
247{ \
248 "HPI_CONTROL_GET_INFO", \
249 "HPI_CONTROL_GET_STATE", \
250 "HPI_CONTROL_SET_STATE" \
251}
252function_count_check(HPI_CONTROL, 3);
253
254#define HPI_NVMEMORY_STRINGS \
255{ \
256 "HPI_NVMEMORY_OPEN", \
257 "HPI_NVMEMORY_READ_BYTE", \
258 "HPI_NVMEMORY_WRITE_BYTE" \
259}
260function_count_check(HPI_NVMEMORY, 3);
261
262#define HPI_DIGITALIO_STRINGS \
263{ \
264 "HPI_GPIO_OPEN", \
265 "HPI_GPIO_READ_BIT", \
266 "HPI_GPIO_WRITE_BIT", \
267 "HPI_GPIO_READ_ALL", \
268 "HPI_GPIO_WRITE_STATUS"\
269}
270function_count_check(HPI_GPIO, 5);
271
272#define HPI_WATCHDOG_STRINGS \
273{ \
274 "HPI_WATCHDOG_OPEN", \
275 "HPI_WATCHDOG_SET_TIME", \
276 "HPI_WATCHDOG_PING" \
277}
278
279#define HPI_CLOCK_STRINGS \
280{ \
281 "HPI_CLOCK_OPEN", \
282 "HPI_CLOCK_SET_TIME", \
283 "HPI_CLOCK_GET_TIME" \
284}
285
286#define HPI_PROFILE_STRINGS \
287{ \
288 "HPI_PROFILE_OPEN_ALL", \
289 "HPI_PROFILE_START_ALL", \
290 "HPI_PROFILE_STOP_ALL", \
291 "HPI_PROFILE_GET", \
292 "HPI_PROFILE_GET_IDLECOUNT", \
293 "HPI_PROFILE_GET_NAME", \
294 "HPI_PROFILE_GET_UTILIZATION" \
295}
296function_count_check(HPI_PROFILE, 7);
297
298#define HPI_ASYNCEVENT_STRINGS \
299{ \
300 "HPI_ASYNCEVENT_OPEN",\
301 "HPI_ASYNCEVENT_CLOSE ",\
302 "HPI_ASYNCEVENT_WAIT",\
303 "HPI_ASYNCEVENT_GETCOUNT",\
304 "HPI_ASYNCEVENT_GET",\
305 "HPI_ASYNCEVENT_SENDEVENTS"\
306}
307function_count_check(HPI_ASYNCEVENT, 6);
308
309#define HPI_CONTROL_TYPE_STRINGS \
310{ \
311 "null control", \
312 "HPI_CONTROL_CONNECTION", \
313 "HPI_CONTROL_VOLUME", \
314 "HPI_CONTROL_METER", \
315 "HPI_CONTROL_MUTE", \
316 "HPI_CONTROL_MULTIPLEXER", \
317 "HPI_CONTROL_AESEBU_TRANSMITTER", \
318 "HPI_CONTROL_AESEBU_RECEIVER", \
319 "HPI_CONTROL_LEVEL", \
320 "HPI_CONTROL_TUNER", \
321 "HPI_CONTROL_ONOFFSWITCH", \
322 "HPI_CONTROL_VOX", \
323 "HPI_CONTROL_AES18_TRANSMITTER", \
324 "HPI_CONTROL_AES18_RECEIVER", \
325 "HPI_CONTROL_AES18_BLOCKGENERATOR", \
326 "HPI_CONTROL_CHANNEL_MODE", \
327 "HPI_CONTROL_BITSTREAM", \
328 "HPI_CONTROL_SAMPLECLOCK", \
329 "HPI_CONTROL_MICROPHONE", \
330 "HPI_CONTROL_PARAMETRIC_EQ", \
331 "HPI_CONTROL_COMPANDER", \
332 "HPI_CONTROL_COBRANET", \
333 "HPI_CONTROL_TONE_DETECT", \
334 "HPI_CONTROL_SILENCE_DETECT", \
335 "HPI_CONTROL_PAD", \
336 "HPI_CONTROL_SRC" ,\
337 "HPI_CONTROL_UNIVERSAL" \
338}
339
340compile_time_assert((HPI_CONTROL_LAST_INDEX + 1 == 27),
341 controltype_strings_match_defs);
342
343#define HPI_SOURCENODE_STRINGS \
344{ \
345 "no source", \
346 "HPI_SOURCENODE_OSTREAM", \
347 "HPI_SOURCENODE_LINEIN", \
348 "HPI_SOURCENODE_AESEBU_IN", \
349 "HPI_SOURCENODE_TUNER", \
350 "HPI_SOURCENODE_RF", \
351 "HPI_SOURCENODE_CLOCK_SOURCE", \
352 "HPI_SOURCENODE_RAW_BITSTREAM", \
353 "HPI_SOURCENODE_MICROPHONE", \
354 "HPI_SOURCENODE_COBRANET", \
355 "HPI_SOURCENODE_ANALOG", \
356 "HPI_SOURCENODE_ADAPTER" \
357}
358
359compile_time_assert((HPI_SOURCENODE_LAST_INDEX - HPI_SOURCENODE_NONE + 1) ==
360 (12), sourcenode_strings_match_defs);
361
362#define HPI_DESTNODE_STRINGS \
363{ \
364 "no destination", \
365 "HPI_DESTNODE_ISTREAM", \
366 "HPI_DESTNODE_LINEOUT", \
367 "HPI_DESTNODE_AESEBU_OUT", \
368 "HPI_DESTNODE_RF", \
369 "HPI_DESTNODE_SPEAKER", \
370 "HPI_DESTNODE_COBRANET", \
371 "HPI_DESTNODE_ANALOG" \
372}
373compile_time_assert((HPI_DESTNODE_LAST_INDEX - HPI_DESTNODE_NONE + 1) == (8),
374 destnode_strings_match_defs);
375
376#define HPI_CONTROL_CHANNEL_MODE_STRINGS \
377{ \
378 "XXX HPI_CHANNEL_MODE_ERROR XXX", \
379 "HPI_CHANNEL_MODE_NORMAL", \
380 "HPI_CHANNEL_MODE_SWAP", \
381 "HPI_CHANNEL_MODE_LEFT_ONLY", \
382 "HPI_CHANNEL_MODE_RIGHT_ONLY" \
383}
384
385#endif /* _HPIDEBUG_H */
diff --git a/sound/pci/asihpi/hpidspcd.c b/sound/pci/asihpi/hpidspcd.c
index 9b10d9a5c255..5c6ea113d219 100644
--- a/sound/pci/asihpi/hpidspcd.c
+++ b/sound/pci/asihpi/hpidspcd.c
@@ -60,7 +60,7 @@ struct code_header {
60 HPI_VER_MINOR(HPI_VER) * 100 + HPI_VER_RELEASE(HPI_VER))) 60 HPI_VER_MINOR(HPI_VER) * 100 + HPI_VER_RELEASE(HPI_VER)))
61 61
62/***********************************************************************/ 62/***********************************************************************/
63#include "linux/pci.h" 63#include <linux/pci.h>
64/*-------------------------------------------------------------------*/ 64/*-------------------------------------------------------------------*/
65short hpi_dsp_code_open(u32 adapter, struct dsp_code *ps_dsp_code, 65short hpi_dsp_code_open(u32 adapter, struct dsp_code *ps_dsp_code,
66 u32 *pos_error_code) 66 u32 *pos_error_code)
@@ -71,47 +71,50 @@ short hpi_dsp_code_open(u32 adapter, struct dsp_code *ps_dsp_code,
71 int err; 71 int err;
72 72
73 sprintf(fw_name, "asihpi/dsp%04x.bin", adapter); 73 sprintf(fw_name, "asihpi/dsp%04x.bin", adapter);
74 HPI_DEBUG_LOG(INFO, "requesting firmware for %s\n", fw_name);
75 74
76 err = request_firmware(&ps_firmware, fw_name, 75 err = request_firmware(&ps_firmware, fw_name,
77 &ps_dsp_code->ps_dev->dev); 76 &ps_dsp_code->ps_dev->dev);
77
78 if (err != 0) { 78 if (err != 0) {
79 HPI_DEBUG_LOG(ERROR, "%d, request_firmware failed for %s\n", 79 dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev,
80 err, fw_name); 80 "%d, request_firmware failed for %s\n", err,
81 fw_name);
81 goto error1; 82 goto error1;
82 } 83 }
83 if (ps_firmware->size < sizeof(header)) { 84 if (ps_firmware->size < sizeof(header)) {
84 HPI_DEBUG_LOG(ERROR, "header size too small %s\n", fw_name); 85 dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev,
86 "Header size too small %s\n", fw_name);
85 goto error2; 87 goto error2;
86 } 88 }
87 memcpy(&header, ps_firmware->data, sizeof(header)); 89 memcpy(&header, ps_firmware->data, sizeof(header));
88 if (header.adapter != adapter) { 90 if (header.adapter != adapter) {
89 HPI_DEBUG_LOG(ERROR, "adapter type incorrect %4x != %4x\n", 91 dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev,
90 header.adapter, adapter); 92 "Adapter type incorrect %4x != %4x\n", header.adapter,
93 adapter);
91 goto error2; 94 goto error2;
92 } 95 }
93 if (header.size != ps_firmware->size) { 96 if (header.size != ps_firmware->size) {
94 HPI_DEBUG_LOG(ERROR, "code size wrong %d != %ld\n", 97 dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev,
95 header.size, (unsigned long)ps_firmware->size); 98 "Code size wrong %d != %ld\n", header.size,
99 (unsigned long)ps_firmware->size);
96 goto error2; 100 goto error2;
97 } 101 }
98 102
99 if (header.version / 10000 != HPI_VER_DECIMAL / 10000) { 103 if (header.version / 100 != HPI_VER_DECIMAL / 100) {
100 HPI_DEBUG_LOG(ERROR, 104 dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev,
101 "firmware major version mismatch " 105 "Incompatible firmware version "
102 "DSP image %d != driver %d\n", header.version, 106 "DSP image %d != Driver %d\n", header.version,
103 HPI_VER_DECIMAL); 107 HPI_VER_DECIMAL);
104 goto error2; 108 goto error2;
105 } 109 }
106 110
107 if (header.version != HPI_VER_DECIMAL) { 111 if (header.version != HPI_VER_DECIMAL) {
108 HPI_DEBUG_LOG(WARNING, 112 dev_printk(KERN_WARNING, &ps_dsp_code->ps_dev->dev,
109 "version mismatch DSP image %d != driver %d\n", 113 "Firmware: release version mismatch DSP image %d != Driver %d\n",
110 header.version, HPI_VER_DECIMAL); 114 header.version, HPI_VER_DECIMAL);
111 /* goto error2; still allow driver to load */
112 } 115 }
113 116
114 HPI_DEBUG_LOG(INFO, "dsp code %s opened\n", fw_name); 117 HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name);
115 ps_dsp_code->ps_firmware = ps_firmware; 118 ps_dsp_code->ps_firmware = ps_firmware;
116 ps_dsp_code->block_length = header.size / sizeof(u32); 119 ps_dsp_code->block_length = header.size / sizeof(u32);
117 ps_dsp_code->word_count = sizeof(header) / sizeof(u32); 120 ps_dsp_code->word_count = sizeof(header) / sizeof(u32);
@@ -148,7 +151,7 @@ void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code)
148short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code, u32 *pword) 151short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code, u32 *pword)
149{ 152{
150 if (ps_dsp_code->word_count + 1 > ps_dsp_code->block_length) 153 if (ps_dsp_code->word_count + 1 > ps_dsp_code->block_length)
151 return (HPI_ERROR_DSP_FILE_FORMAT); 154 return HPI_ERROR_DSP_FILE_FORMAT;
152 155
153 *pword = ((u32 *)(ps_dsp_code->ps_firmware->data))[ps_dsp_code-> 156 *pword = ((u32 *)(ps_dsp_code->ps_firmware->data))[ps_dsp_code->
154 word_count]; 157 word_count];
diff --git a/sound/pci/asihpi/hpidspcd.h b/sound/pci/asihpi/hpidspcd.h
index d7c240398225..65f0ca732704 100644
--- a/sound/pci/asihpi/hpidspcd.h
+++ b/sound/pci/asihpi/hpidspcd.h
@@ -87,7 +87,7 @@ void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code);
87*/ 87*/
88short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code, 88short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code,
89 /**< DSP code descriptor */ 89 /**< DSP code descriptor */
90 u32 *pword /**< where to store the read word */ 90 u32 *pword /**< Where to store the read word */
91 ); 91 );
92 92
93/** Get a block of dsp code into an internal buffer, and provide a pointer to 93/** Get a block of dsp code into an internal buffer, and provide a pointer to
diff --git a/sound/pci/asihpi/hpifunc.c b/sound/pci/asihpi/hpifunc.c
index 1e92eb6dd509..7397b169b89f 100644
--- a/sound/pci/asihpi/hpifunc.c
+++ b/sound/pci/asihpi/hpifunc.c
@@ -30,16 +30,25 @@ u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index,
30 return handle.w; 30 return handle.w;
31} 31}
32 32
33void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index, 33static u16 hpi_handle_indexes(const u32 h, u16 *p1, u16 *p2)
34 u16 *pw_object_index)
35{ 34{
36 union handle_word uhandle; 35 union handle_word uhandle;
37 uhandle.w = handle; 36 if (!h)
37 return HPI_ERROR_INVALID_HANDLE;
38
39 uhandle.w = h;
40
41 *p1 = (u16)uhandle.h.adapter_index;
42 if (p2)
43 *p2 = (u16)uhandle.h.obj_index;
38 44
39 if (pw_adapter_index) 45 return 0;
40 *pw_adapter_index = (u16)uhandle.h.adapter_index; 46}
41 if (pw_object_index) 47
42 *pw_object_index = (u16)uhandle.h.obj_index; 48void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index,
49 u16 *pw_object_index)
50{
51 hpi_handle_indexes(handle, pw_adapter_index, pw_object_index);
43} 52}
44 53
45char hpi_handle_object(const u32 handle) 54char hpi_handle_object(const u32 handle)
@@ -49,22 +58,6 @@ char hpi_handle_object(const u32 handle)
49 return (char)uhandle.h.obj_type; 58 return (char)uhandle.h.obj_type;
50} 59}
51 60
52#define u32TOINDEX(h, i1) \
53do {\
54 if (h == 0) \
55 return HPI_ERROR_INVALID_OBJ; \
56 else \
57 hpi_handle_to_indexes(h, i1, NULL); \
58} while (0)
59
60#define u32TOINDEXES(h, i1, i2) \
61do {\
62 if (h == 0) \
63 return HPI_ERROR_INVALID_OBJ; \
64 else \
65 hpi_handle_to_indexes(h, i1, i2);\
66} while (0)
67
68void hpi_format_to_msg(struct hpi_msg_format *pMF, 61void hpi_format_to_msg(struct hpi_msg_format *pMF,
69 const struct hpi_format *pF) 62 const struct hpi_format *pF)
70{ 63{
@@ -94,52 +87,13 @@ void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR)
94 pSR->u.legacy_stream_info.state = pSR->u.stream_info.state; 87 pSR->u.legacy_stream_info.state = pSR->u.stream_info.state;
95} 88}
96 89
97static struct hpi_hsubsys gh_subsys; 90static inline void hpi_send_recvV1(struct hpi_message_header *m,
98 91 struct hpi_response_header *r)
99struct hpi_hsubsys *hpi_subsys_create(void)
100{
101 struct hpi_message hm;
102 struct hpi_response hr;
103
104 memset(&gh_subsys, 0, sizeof(struct hpi_hsubsys));
105
106 {
107 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
108 HPI_SUBSYS_OPEN);
109 hpi_send_recv(&hm, &hr);
110
111 if (hr.error == 0)
112 return &gh_subsys;
113
114 }
115 return NULL;
116}
117
118void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys)
119{ 92{
120 struct hpi_message hm; 93 hpi_send_recv((struct hpi_message *)m, (struct hpi_response *)r);
121 struct hpi_response hr;
122
123 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
124 HPI_SUBSYS_CLOSE);
125 hpi_send_recv(&hm, &hr);
126
127}
128
129u16 hpi_subsys_get_version(const struct hpi_hsubsys *ph_subsys, u32 *pversion)
130{
131 struct hpi_message hm;
132 struct hpi_response hr;
133
134 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
135 HPI_SUBSYS_GET_VERSION);
136 hpi_send_recv(&hm, &hr);
137 *pversion = hr.u.s.version;
138 return hr.error;
139} 94}
140 95
141u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys, 96u16 hpi_subsys_get_version_ex(u32 *pversion_ex)
142 u32 *pversion_ex)
143{ 97{
144 struct hpi_message hm; 98 struct hpi_message hm;
145 struct hpi_response hr; 99 struct hpi_response hr;
@@ -151,79 +105,7 @@ u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys,
151 return hr.error; 105 return hr.error;
152} 106}
153 107
154u16 hpi_subsys_get_info(const struct hpi_hsubsys *ph_subsys, u32 *pversion, 108u16 hpi_subsys_get_num_adapters(int *pn_num_adapters)
155 u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length)
156{
157 struct hpi_message hm;
158 struct hpi_response hr;
159 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
160 HPI_SUBSYS_GET_INFO);
161
162 hpi_send_recv(&hm, &hr);
163
164 *pversion = hr.u.s.version;
165 if (list_length > HPI_MAX_ADAPTERS)
166 memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list,
167 HPI_MAX_ADAPTERS);
168 else
169 memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list, list_length);
170 *pw_num_adapters = hr.u.s.num_adapters;
171 return hr.error;
172}
173
174u16 hpi_subsys_find_adapters(const struct hpi_hsubsys *ph_subsys,
175 u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length)
176{
177 struct hpi_message hm;
178 struct hpi_response hr;
179 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
180 HPI_SUBSYS_FIND_ADAPTERS);
181
182 hpi_send_recv(&hm, &hr);
183
184 if (list_length > HPI_MAX_ADAPTERS) {
185 memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list,
186 HPI_MAX_ADAPTERS * sizeof(u16));
187 memset(&aw_adapter_list[HPI_MAX_ADAPTERS], 0,
188 (list_length - HPI_MAX_ADAPTERS) * sizeof(u16));
189 } else
190 memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list,
191 list_length * sizeof(u16));
192 *pw_num_adapters = hr.u.s.num_adapters;
193
194 return hr.error;
195}
196
197u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys,
198 const struct hpi_resource *p_resource, u16 *pw_adapter_index)
199{
200 struct hpi_message hm;
201 struct hpi_response hr;
202
203 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
204 HPI_SUBSYS_CREATE_ADAPTER);
205 hm.u.s.resource = *p_resource;
206
207 hpi_send_recv(&hm, &hr);
208
209 *pw_adapter_index = hr.u.s.adapter_index;
210 return hr.error;
211}
212
213u16 hpi_subsys_delete_adapter(const struct hpi_hsubsys *ph_subsys,
214 u16 adapter_index)
215{
216 struct hpi_message hm;
217 struct hpi_response hr;
218 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
219 HPI_SUBSYS_DELETE_ADAPTER);
220 hm.adapter_index = adapter_index;
221 hpi_send_recv(&hm, &hr);
222 return hr.error;
223}
224
225u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys,
226 int *pn_num_adapters)
227{ 109{
228 struct hpi_message hm; 110 struct hpi_message hm;
229 struct hpi_response hr; 111 struct hpi_response hr;
@@ -234,35 +116,22 @@ u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys,
234 return hr.error; 116 return hr.error;
235} 117}
236 118
237u16 hpi_subsys_get_adapter(const struct hpi_hsubsys *ph_subsys, int iterator, 119u16 hpi_subsys_get_adapter(int iterator, u32 *padapter_index,
238 u32 *padapter_index, u16 *pw_adapter_type) 120 u16 *pw_adapter_type)
239{ 121{
240 struct hpi_message hm; 122 struct hpi_message hm;
241 struct hpi_response hr; 123 struct hpi_response hr;
242 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 124 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
243 HPI_SUBSYS_GET_ADAPTER); 125 HPI_SUBSYS_GET_ADAPTER);
244 hm.adapter_index = (u16)iterator; 126 hm.obj_index = (u16)iterator;
245 hpi_send_recv(&hm, &hr); 127 hpi_send_recv(&hm, &hr);
246 *padapter_index = (int)hr.u.s.adapter_index; 128 *padapter_index = (int)hr.u.s.adapter_index;
247 *pw_adapter_type = hr.u.s.aw_adapter_list[0]; 129 *pw_adapter_type = hr.u.s.adapter_type;
248 return hr.error;
249}
250 130
251u16 hpi_subsys_set_host_network_interface(const struct hpi_hsubsys *ph_subsys,
252 const char *sz_interface)
253{
254 struct hpi_message hm;
255 struct hpi_response hr;
256 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
257 HPI_SUBSYS_SET_NETWORK_INTERFACE);
258 if (sz_interface == NULL)
259 return HPI_ERROR_INVALID_RESOURCE;
260 hm.u.s.resource.r.net_if = sz_interface;
261 hpi_send_recv(&hm, &hr);
262 return hr.error; 131 return hr.error;
263} 132}
264 133
265u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) 134u16 hpi_adapter_open(u16 adapter_index)
266{ 135{
267 struct hpi_message hm; 136 struct hpi_message hm;
268 struct hpi_response hr; 137 struct hpi_response hr;
@@ -276,7 +145,7 @@ u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index)
276 145
277} 146}
278 147
279u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) 148u16 hpi_adapter_close(u16 adapter_index)
280{ 149{
281 struct hpi_message hm; 150 struct hpi_message hm;
282 struct hpi_response hr; 151 struct hpi_response hr;
@@ -289,15 +158,14 @@ u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index)
289 return hr.error; 158 return hr.error;
290} 159}
291 160
292u16 hpi_adapter_set_mode(const struct hpi_hsubsys *ph_subsys, 161u16 hpi_adapter_set_mode(u16 adapter_index, u32 adapter_mode)
293 u16 adapter_index, u32 adapter_mode)
294{ 162{
295 return hpi_adapter_set_mode_ex(ph_subsys, adapter_index, adapter_mode, 163 return hpi_adapter_set_mode_ex(adapter_index, adapter_mode,
296 HPI_ADAPTER_MODE_SET); 164 HPI_ADAPTER_MODE_SET);
297} 165}
298 166
299u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys, 167u16 hpi_adapter_set_mode_ex(u16 adapter_index, u32 adapter_mode,
300 u16 adapter_index, u32 adapter_mode, u16 query_or_set) 168 u16 query_or_set)
301{ 169{
302 struct hpi_message hm; 170 struct hpi_message hm;
303 struct hpi_response hr; 171 struct hpi_response hr;
@@ -305,14 +173,13 @@ u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys,
305 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 173 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
306 HPI_ADAPTER_SET_MODE); 174 HPI_ADAPTER_SET_MODE);
307 hm.adapter_index = adapter_index; 175 hm.adapter_index = adapter_index;
308 hm.u.a.adapter_mode = adapter_mode; 176 hm.u.ax.mode.adapter_mode = adapter_mode;
309 hm.u.a.assert_id = query_or_set; 177 hm.u.ax.mode.query_or_set = query_or_set;
310 hpi_send_recv(&hm, &hr); 178 hpi_send_recv(&hm, &hr);
311 return hr.error; 179 return hr.error;
312} 180}
313 181
314u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys, 182u16 hpi_adapter_get_mode(u16 adapter_index, u32 *padapter_mode)
315 u16 adapter_index, u32 *padapter_mode)
316{ 183{
317 struct hpi_message hm; 184 struct hpi_message hm;
318 struct hpi_response hr; 185 struct hpi_response hr;
@@ -321,13 +188,13 @@ u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys,
321 hm.adapter_index = adapter_index; 188 hm.adapter_index = adapter_index;
322 hpi_send_recv(&hm, &hr); 189 hpi_send_recv(&hm, &hr);
323 if (padapter_mode) 190 if (padapter_mode)
324 *padapter_mode = hr.u.a.serial_number; 191 *padapter_mode = hr.u.ax.mode.adapter_mode;
325 return hr.error; 192 return hr.error;
326} 193}
327 194
328u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys, 195u16 hpi_adapter_get_info(u16 adapter_index, u16 *pw_num_outstreams,
329 u16 adapter_index, u16 *pw_num_outstreams, u16 *pw_num_instreams, 196 u16 *pw_num_instreams, u16 *pw_version, u32 *pserial_number,
330 u16 *pw_version, u32 *pserial_number, u16 *pw_adapter_type) 197 u16 *pw_adapter_type)
331{ 198{
332 struct hpi_message hm; 199 struct hpi_message hm;
333 struct hpi_response hr; 200 struct hpi_response hr;
@@ -337,18 +204,17 @@ u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys,
337 204
338 hpi_send_recv(&hm, &hr); 205 hpi_send_recv(&hm, &hr);
339 206
340 *pw_adapter_type = hr.u.a.adapter_type; 207 *pw_adapter_type = hr.u.ax.info.adapter_type;
341 *pw_num_outstreams = hr.u.a.num_outstreams; 208 *pw_num_outstreams = hr.u.ax.info.num_outstreams;
342 *pw_num_instreams = hr.u.a.num_instreams; 209 *pw_num_instreams = hr.u.ax.info.num_instreams;
343 *pw_version = hr.u.a.version; 210 *pw_version = hr.u.ax.info.version;
344 *pserial_number = hr.u.a.serial_number; 211 *pserial_number = hr.u.ax.info.serial_number;
345 return hr.error; 212 return hr.error;
346} 213}
347 214
348u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys, 215u16 hpi_adapter_get_module_by_index(u16 adapter_index, u16 module_index,
349 u16 adapter_index, u16 module_index, u16 *pw_num_outputs, 216 u16 *pw_num_outputs, u16 *pw_num_inputs, u16 *pw_version,
350 u16 *pw_num_inputs, u16 *pw_version, u32 *pserial_number, 217 u32 *pserial_number, u16 *pw_module_type, u32 *ph_module)
351 u16 *pw_module_type, u32 *ph_module)
352{ 218{
353 struct hpi_message hm; 219 struct hpi_message hm;
354 struct hpi_response hr; 220 struct hpi_response hr;
@@ -360,173 +226,18 @@ u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys,
360 226
361 hpi_send_recv(&hm, &hr); 227 hpi_send_recv(&hm, &hr);
362 228
363 *pw_module_type = hr.u.a.adapter_type; 229 *pw_module_type = hr.u.ax.info.adapter_type;
364 *pw_num_outputs = hr.u.a.num_outstreams; 230 *pw_num_outputs = hr.u.ax.info.num_outstreams;
365 *pw_num_inputs = hr.u.a.num_instreams; 231 *pw_num_inputs = hr.u.ax.info.num_instreams;
366 *pw_version = hr.u.a.version; 232 *pw_version = hr.u.ax.info.version;
367 *pserial_number = hr.u.a.serial_number; 233 *pserial_number = hr.u.ax.info.serial_number;
368 *ph_module = 0; 234 *ph_module = 0;
369 235
370 return hr.error; 236 return hr.error;
371} 237}
372 238
373u16 hpi_adapter_get_assert(const struct hpi_hsubsys *ph_subsys, 239u16 hpi_adapter_set_property(u16 adapter_index, u16 property, u16 parameter1,
374 u16 adapter_index, u16 *assert_present, char *psz_assert, 240 u16 parameter2)
375 u16 *pw_line_number)
376{
377 struct hpi_message hm;
378 struct hpi_response hr;
379 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
380 HPI_ADAPTER_GET_ASSERT);
381 hm.adapter_index = adapter_index;
382 hpi_send_recv(&hm, &hr);
383
384 *assert_present = 0;
385
386 if (!hr.error) {
387
388 *pw_line_number = (u16)hr.u.a.serial_number;
389 if (*pw_line_number) {
390
391 int i;
392 char *src = (char *)hr.u.a.sz_adapter_assert;
393 char *dst = psz_assert;
394
395 *assert_present = 1;
396
397 for (i = 0; i < HPI_STRING_LEN; i++) {
398 char c;
399 c = *src++;
400 *dst++ = c;
401 if (c == 0)
402 break;
403 }
404
405 }
406 }
407 return hr.error;
408}
409
410u16 hpi_adapter_get_assert_ex(const struct hpi_hsubsys *ph_subsys,
411 u16 adapter_index, u16 *assert_present, char *psz_assert,
412 u32 *pline_number, u16 *pw_assert_on_dsp)
413{
414 struct hpi_message hm;
415 struct hpi_response hr;
416 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
417 HPI_ADAPTER_GET_ASSERT);
418 hm.adapter_index = adapter_index;
419
420 hpi_send_recv(&hm, &hr);
421
422 *assert_present = 0;
423
424 if (!hr.error) {
425
426 *pline_number = hr.u.a.serial_number;
427
428 *assert_present = hr.u.a.adapter_type;
429
430 *pw_assert_on_dsp = hr.u.a.adapter_index;
431
432 if (!*assert_present && *pline_number)
433
434 *assert_present = 1;
435
436 if (*assert_present) {
437
438 int i;
439 char *src = (char *)hr.u.a.sz_adapter_assert;
440 char *dst = psz_assert;
441
442 for (i = 0; i < HPI_STRING_LEN; i++) {
443 char c;
444 c = *src++;
445 *dst++ = c;
446 if (c == 0)
447 break;
448 }
449
450 } else {
451 *psz_assert = 0;
452 }
453 }
454 return hr.error;
455}
456
457u16 hpi_adapter_test_assert(const struct hpi_hsubsys *ph_subsys,
458 u16 adapter_index, u16 assert_id)
459{
460 struct hpi_message hm;
461 struct hpi_response hr;
462 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
463 HPI_ADAPTER_TEST_ASSERT);
464 hm.adapter_index = adapter_index;
465 hm.u.a.assert_id = assert_id;
466
467 hpi_send_recv(&hm, &hr);
468
469 return hr.error;
470}
471
472u16 hpi_adapter_enable_capability(const struct hpi_hsubsys *ph_subsys,
473 u16 adapter_index, u16 capability, u32 key)
474{
475 struct hpi_message hm;
476 struct hpi_response hr;
477 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
478 HPI_ADAPTER_ENABLE_CAPABILITY);
479 hm.adapter_index = adapter_index;
480 hm.u.a.assert_id = capability;
481 hm.u.a.adapter_mode = key;
482
483 hpi_send_recv(&hm, &hr);
484
485 return hr.error;
486}
487
488u16 hpi_adapter_self_test(const struct hpi_hsubsys *ph_subsys,
489 u16 adapter_index)
490{
491 struct hpi_message hm;
492 struct hpi_response hr;
493 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
494 HPI_ADAPTER_SELFTEST);
495 hm.adapter_index = adapter_index;
496 hpi_send_recv(&hm, &hr);
497 return hr.error;
498}
499
500u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys,
501 u16 adapter_index, u32 dsp_address, char *p_buffer, int *count_bytes)
502{
503 struct hpi_message hm;
504 struct hpi_response hr;
505 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
506 HPI_ADAPTER_DEBUG_READ);
507
508 hr.size = sizeof(hr);
509
510 hm.adapter_index = adapter_index;
511 hm.u.ax.debug_read.dsp_address = dsp_address;
512
513 if (*count_bytes > (int)sizeof(hr.u.bytes))
514 *count_bytes = sizeof(hr.u.bytes);
515
516 hm.u.ax.debug_read.count_bytes = *count_bytes;
517
518 hpi_send_recv(&hm, &hr);
519
520 if (!hr.error) {
521 *count_bytes = hr.size - 12;
522 memcpy(p_buffer, &hr.u.bytes, *count_bytes);
523 } else
524 *count_bytes = 0;
525 return hr.error;
526}
527
528u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys,
529 u16 adapter_index, u16 property, u16 parameter1, u16 parameter2)
530{ 241{
531 struct hpi_message hm; 242 struct hpi_message hm;
532 struct hpi_response hr; 243 struct hpi_response hr;
@@ -542,9 +253,8 @@ u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys,
542 return hr.error; 253 return hr.error;
543} 254}
544 255
545u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys, 256u16 hpi_adapter_get_property(u16 adapter_index, u16 property,
546 u16 adapter_index, u16 property, u16 *pw_parameter1, 257 u16 *pw_parameter1, u16 *pw_parameter2)
547 u16 *pw_parameter2)
548{ 258{
549 struct hpi_message hm; 259 struct hpi_message hm;
550 struct hpi_response hr; 260 struct hpi_response hr;
@@ -564,9 +274,8 @@ u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys,
564 return hr.error; 274 return hr.error;
565} 275}
566 276
567u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys, 277u16 hpi_adapter_enumerate_property(u16 adapter_index, u16 index,
568 u16 adapter_index, u16 index, u16 what_to_enumerate, 278 u16 what_to_enumerate, u16 property_index, u32 *psetting)
569 u16 property_index, u32 *psetting)
570{ 279{
571 return 0; 280 return 0;
572} 281}
@@ -574,7 +283,7 @@ u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys,
574u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, 283u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
575 u32 sample_rate, u32 bit_rate, u32 attributes) 284 u32 sample_rate, u32 bit_rate, u32 attributes)
576{ 285{
577 u16 error = 0; 286 u16 err = 0;
578 struct hpi_msg_format fmt; 287 struct hpi_msg_format fmt;
579 288
580 switch (channels) { 289 switch (channels) {
@@ -586,8 +295,8 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
586 case 16: 295 case 16:
587 break; 296 break;
588 default: 297 default:
589 error = HPI_ERROR_INVALID_CHANNELS; 298 err = HPI_ERROR_INVALID_CHANNELS;
590 return error; 299 return err;
591 } 300 }
592 fmt.channels = channels; 301 fmt.channels = channels;
593 302
@@ -610,17 +319,17 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
610 case HPI_FORMAT_OEM2: 319 case HPI_FORMAT_OEM2:
611 break; 320 break;
612 default: 321 default:
613 error = HPI_ERROR_INVALID_FORMAT; 322 err = HPI_ERROR_INVALID_FORMAT;
614 return error; 323 return err;
615 } 324 }
616 fmt.format = format; 325 fmt.format = format;
617 326
618 if (sample_rate < 8000L) { 327 if (sample_rate < 8000L) {
619 error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; 328 err = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
620 sample_rate = 8000L; 329 sample_rate = 8000L;
621 } 330 }
622 if (sample_rate > 200000L) { 331 if (sample_rate > 200000L) {
623 error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; 332 err = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
624 sample_rate = 200000L; 333 sample_rate = 200000L;
625 } 334 }
626 fmt.sample_rate = sample_rate; 335 fmt.sample_rate = sample_rate;
@@ -651,10 +360,10 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
651 if ((channels == 1) 360 if ((channels == 1)
652 && (attributes != HPI_MPEG_MODE_DEFAULT)) { 361 && (attributes != HPI_MPEG_MODE_DEFAULT)) {
653 attributes = HPI_MPEG_MODE_DEFAULT; 362 attributes = HPI_MPEG_MODE_DEFAULT;
654 error = HPI_ERROR_INVALID_FORMAT; 363 err = HPI_ERROR_INVALID_FORMAT;
655 } else if (attributes > HPI_MPEG_MODE_DUALCHANNEL) { 364 } else if (attributes > HPI_MPEG_MODE_DUALCHANNEL) {
656 attributes = HPI_MPEG_MODE_DEFAULT; 365 attributes = HPI_MPEG_MODE_DEFAULT;
657 error = HPI_ERROR_INVALID_FORMAT; 366 err = HPI_ERROR_INVALID_FORMAT;
658 } 367 }
659 fmt.attributes = attributes; 368 fmt.attributes = attributes;
660 break; 369 break;
@@ -663,7 +372,7 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
663 } 372 }
664 373
665 hpi_msg_to_format(p_format, &fmt); 374 hpi_msg_to_format(p_format, &fmt);
666 return error; 375 return err;
667} 376}
668 377
669u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format, 378u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format,
@@ -712,8 +421,8 @@ u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format,
712 return 0; 421 return 0;
713} 422}
714 423
715u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 424u16 hpi_outstream_open(u16 adapter_index, u16 outstream_index,
716 u16 outstream_index, u32 *ph_outstream) 425 u32 *ph_outstream)
717{ 426{
718 struct hpi_message hm; 427 struct hpi_message hm;
719 struct hpi_response hr; 428 struct hpi_response hr;
@@ -733,38 +442,41 @@ u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
733 return hr.error; 442 return hr.error;
734} 443}
735 444
736u16 hpi_outstream_close(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 445u16 hpi_outstream_close(u32 h_outstream)
737{ 446{
738 struct hpi_message hm; 447 struct hpi_message hm;
739 struct hpi_response hr; 448 struct hpi_response hr;
740 449
741 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 450 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
742 HPI_OSTREAM_HOSTBUFFER_FREE); 451 HPI_OSTREAM_HOSTBUFFER_FREE);
743 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 452 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
453 return HPI_ERROR_INVALID_HANDLE;
454
744 hpi_send_recv(&hm, &hr); 455 hpi_send_recv(&hm, &hr);
745 456
746 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 457 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
747 HPI_OSTREAM_GROUP_RESET); 458 HPI_OSTREAM_GROUP_RESET);
748 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 459 hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index);
749 hpi_send_recv(&hm, &hr); 460 hpi_send_recv(&hm, &hr);
750 461
751 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 462 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
752 HPI_OSTREAM_CLOSE); 463 HPI_OSTREAM_CLOSE);
753 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 464 hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index);
754 hpi_send_recv(&hm, &hr); 465 hpi_send_recv(&hm, &hr);
755 466
756 return hr.error; 467 return hr.error;
757} 468}
758 469
759u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys, 470u16 hpi_outstream_get_info_ex(u32 h_outstream, u16 *pw_state,
760 u32 h_outstream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_to_play, 471 u32 *pbuffer_size, u32 *pdata_to_play, u32 *psamples_played,
761 u32 *psamples_played, u32 *pauxiliary_data_to_play) 472 u32 *pauxiliary_data_to_play)
762{ 473{
763 struct hpi_message hm; 474 struct hpi_message hm;
764 struct hpi_response hr; 475 struct hpi_response hr;
765 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 476 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
766 HPI_OSTREAM_GET_INFO); 477 HPI_OSTREAM_GET_INFO);
767 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 478 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
479 return HPI_ERROR_INVALID_HANDLE;
768 480
769 hpi_send_recv(&hm, &hr); 481 hpi_send_recv(&hm, &hr);
770 482
@@ -782,15 +494,15 @@ u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys,
782 return hr.error; 494 return hr.error;
783} 495}
784 496
785u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys, 497u16 hpi_outstream_write_buf(u32 h_outstream, const u8 *pb_data,
786 u32 h_outstream, const u8 *pb_data, u32 bytes_to_write, 498 u32 bytes_to_write, const struct hpi_format *p_format)
787 const struct hpi_format *p_format)
788{ 499{
789 struct hpi_message hm; 500 struct hpi_message hm;
790 struct hpi_response hr; 501 struct hpi_response hr;
791 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 502 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
792 HPI_OSTREAM_WRITE); 503 HPI_OSTREAM_WRITE);
793 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 504 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
505 return HPI_ERROR_INVALID_HANDLE;
794 hm.u.d.u.data.pb_data = (u8 *)pb_data; 506 hm.u.d.u.data.pb_data = (u8 *)pb_data;
795 hm.u.d.u.data.data_size = bytes_to_write; 507 hm.u.d.u.data.data_size = bytes_to_write;
796 508
@@ -801,82 +513,85 @@ u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys,
801 return hr.error; 513 return hr.error;
802} 514}
803 515
804u16 hpi_outstream_start(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 516u16 hpi_outstream_start(u32 h_outstream)
805{ 517{
806 struct hpi_message hm; 518 struct hpi_message hm;
807 struct hpi_response hr; 519 struct hpi_response hr;
808 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 520 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
809 HPI_OSTREAM_START); 521 HPI_OSTREAM_START);
810 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 522 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
523 return HPI_ERROR_INVALID_HANDLE;
811 524
812 hpi_send_recv(&hm, &hr); 525 hpi_send_recv(&hm, &hr);
813 526
814 return hr.error; 527 return hr.error;
815} 528}
816 529
817u16 hpi_outstream_wait_start(const struct hpi_hsubsys *ph_subsys, 530u16 hpi_outstream_wait_start(u32 h_outstream)
818 u32 h_outstream)
819{ 531{
820 struct hpi_message hm; 532 struct hpi_message hm;
821 struct hpi_response hr; 533 struct hpi_response hr;
822 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 534 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
823 HPI_OSTREAM_WAIT_START); 535 HPI_OSTREAM_WAIT_START);
824 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 536 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
537 return HPI_ERROR_INVALID_HANDLE;
825 538
826 hpi_send_recv(&hm, &hr); 539 hpi_send_recv(&hm, &hr);
827 540
828 return hr.error; 541 return hr.error;
829} 542}
830 543
831u16 hpi_outstream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 544u16 hpi_outstream_stop(u32 h_outstream)
832{ 545{
833 struct hpi_message hm; 546 struct hpi_message hm;
834 struct hpi_response hr; 547 struct hpi_response hr;
835 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 548 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
836 HPI_OSTREAM_STOP); 549 HPI_OSTREAM_STOP);
837 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 550 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
551 return HPI_ERROR_INVALID_HANDLE;
838 552
839 hpi_send_recv(&hm, &hr); 553 hpi_send_recv(&hm, &hr);
840 554
841 return hr.error; 555 return hr.error;
842} 556}
843 557
844u16 hpi_outstream_sinegen(const struct hpi_hsubsys *ph_subsys, 558u16 hpi_outstream_sinegen(u32 h_outstream)
845 u32 h_outstream)
846{ 559{
847 struct hpi_message hm; 560 struct hpi_message hm;
848 struct hpi_response hr; 561 struct hpi_response hr;
849 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 562 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
850 HPI_OSTREAM_SINEGEN); 563 HPI_OSTREAM_SINEGEN);
851 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 564 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
565 return HPI_ERROR_INVALID_HANDLE;
852 566
853 hpi_send_recv(&hm, &hr); 567 hpi_send_recv(&hm, &hr);
854 568
855 return hr.error; 569 return hr.error;
856} 570}
857 571
858u16 hpi_outstream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) 572u16 hpi_outstream_reset(u32 h_outstream)
859{ 573{
860 struct hpi_message hm; 574 struct hpi_message hm;
861 struct hpi_response hr; 575 struct hpi_response hr;
862 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 576 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
863 HPI_OSTREAM_RESET); 577 HPI_OSTREAM_RESET);
864 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 578 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
579 return HPI_ERROR_INVALID_HANDLE;
865 580
866 hpi_send_recv(&hm, &hr); 581 hpi_send_recv(&hm, &hr);
867 582
868 return hr.error; 583 return hr.error;
869} 584}
870 585
871u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys, 586u16 hpi_outstream_query_format(u32 h_outstream, struct hpi_format *p_format)
872 u32 h_outstream, struct hpi_format *p_format)
873{ 587{
874 struct hpi_message hm; 588 struct hpi_message hm;
875 struct hpi_response hr; 589 struct hpi_response hr;
876 590
877 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 591 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
878 HPI_OSTREAM_QUERY_FORMAT); 592 HPI_OSTREAM_QUERY_FORMAT);
879 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 593 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
594 return HPI_ERROR_INVALID_HANDLE;
880 595
881 hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 596 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
882 597
@@ -885,15 +600,15 @@ u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys,
885 return hr.error; 600 return hr.error;
886} 601}
887 602
888u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys, 603u16 hpi_outstream_set_format(u32 h_outstream, struct hpi_format *p_format)
889 u32 h_outstream, struct hpi_format *p_format)
890{ 604{
891 struct hpi_message hm; 605 struct hpi_message hm;
892 struct hpi_response hr; 606 struct hpi_response hr;
893 607
894 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 608 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
895 HPI_OSTREAM_SET_FORMAT); 609 HPI_OSTREAM_SET_FORMAT);
896 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 610 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
611 return HPI_ERROR_INVALID_HANDLE;
897 612
898 hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 613 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
899 614
@@ -902,15 +617,15 @@ u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys,
902 return hr.error; 617 return hr.error;
903} 618}
904 619
905u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys, 620u16 hpi_outstream_set_velocity(u32 h_outstream, short velocity)
906 u32 h_outstream, short velocity)
907{ 621{
908 struct hpi_message hm; 622 struct hpi_message hm;
909 struct hpi_response hr; 623 struct hpi_response hr;
910 624
911 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 625 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
912 HPI_OSTREAM_SET_VELOCITY); 626 HPI_OSTREAM_SET_VELOCITY);
913 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 627 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
628 return HPI_ERROR_INVALID_HANDLE;
914 hm.u.d.u.velocity = velocity; 629 hm.u.d.u.velocity = velocity;
915 630
916 hpi_send_recv(&hm, &hr); 631 hpi_send_recv(&hm, &hr);
@@ -918,15 +633,16 @@ u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys,
918 return hr.error; 633 return hr.error;
919} 634}
920 635
921u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys, 636u16 hpi_outstream_set_punch_in_out(u32 h_outstream, u32 punch_in_sample,
922 u32 h_outstream, u32 punch_in_sample, u32 punch_out_sample) 637 u32 punch_out_sample)
923{ 638{
924 struct hpi_message hm; 639 struct hpi_message hm;
925 struct hpi_response hr; 640 struct hpi_response hr;
926 641
927 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 642 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
928 HPI_OSTREAM_SET_PUNCHINOUT); 643 HPI_OSTREAM_SET_PUNCHINOUT);
929 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 644 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
645 return HPI_ERROR_INVALID_HANDLE;
930 646
931 hm.u.d.u.pio.punch_in_sample = punch_in_sample; 647 hm.u.d.u.pio.punch_in_sample = punch_in_sample;
932 hm.u.d.u.pio.punch_out_sample = punch_out_sample; 648 hm.u.d.u.pio.punch_out_sample = punch_out_sample;
@@ -936,29 +652,29 @@ u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys,
936 return hr.error; 652 return hr.error;
937} 653}
938 654
939u16 hpi_outstream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, 655u16 hpi_outstream_ancillary_reset(u32 h_outstream, u16 mode)
940 u32 h_outstream, u16 mode)
941{ 656{
942 struct hpi_message hm; 657 struct hpi_message hm;
943 struct hpi_response hr; 658 struct hpi_response hr;
944 659
945 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 660 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
946 HPI_OSTREAM_ANC_RESET); 661 HPI_OSTREAM_ANC_RESET);
947 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 662 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
663 return HPI_ERROR_INVALID_HANDLE;
948 hm.u.d.u.data.format.channels = mode; 664 hm.u.d.u.data.format.channels = mode;
949 hpi_send_recv(&hm, &hr); 665 hpi_send_recv(&hm, &hr);
950 return hr.error; 666 return hr.error;
951} 667}
952 668
953u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, 669u16 hpi_outstream_ancillary_get_info(u32 h_outstream, u32 *pframes_available)
954 u32 h_outstream, u32 *pframes_available)
955{ 670{
956 struct hpi_message hm; 671 struct hpi_message hm;
957 struct hpi_response hr; 672 struct hpi_response hr;
958 673
959 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 674 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
960 HPI_OSTREAM_ANC_GET_INFO); 675 HPI_OSTREAM_ANC_GET_INFO);
961 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 676 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
677 return HPI_ERROR_INVALID_HANDLE;
962 hpi_send_recv(&hm, &hr); 678 hpi_send_recv(&hm, &hr);
963 if (hr.error == 0) { 679 if (hr.error == 0) {
964 if (pframes_available) 680 if (pframes_available)
@@ -969,8 +685,8 @@ u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys,
969 return hr.error; 685 return hr.error;
970} 686}
971 687
972u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys, 688u16 hpi_outstream_ancillary_read(u32 h_outstream,
973 u32 h_outstream, struct hpi_anc_frame *p_anc_frame_buffer, 689 struct hpi_anc_frame *p_anc_frame_buffer,
974 u32 anc_frame_buffer_size_in_bytes, 690 u32 anc_frame_buffer_size_in_bytes,
975 u32 number_of_ancillary_frames_to_read) 691 u32 number_of_ancillary_frames_to_read)
976{ 692{
@@ -979,7 +695,8 @@ u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys,
979 695
980 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 696 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
981 HPI_OSTREAM_ANC_READ); 697 HPI_OSTREAM_ANC_READ);
982 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 698 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
699 return HPI_ERROR_INVALID_HANDLE;
983 hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer; 700 hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer;
984 hm.u.d.u.data.data_size = 701 hm.u.d.u.data.data_size =
985 number_of_ancillary_frames_to_read * 702 number_of_ancillary_frames_to_read *
@@ -987,19 +704,19 @@ u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys,
987 if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes) 704 if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes)
988 hpi_send_recv(&hm, &hr); 705 hpi_send_recv(&hm, &hr);
989 else 706 else
990 hr.error = HPI_ERROR_INVALID_DATA_TRANSFER; 707 hr.error = HPI_ERROR_INVALID_DATASIZE;
991 return hr.error; 708 return hr.error;
992} 709}
993 710
994u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys, 711u16 hpi_outstream_set_time_scale(u32 h_outstream, u32 time_scale)
995 u32 h_outstream, u32 time_scale)
996{ 712{
997 struct hpi_message hm; 713 struct hpi_message hm;
998 struct hpi_response hr; 714 struct hpi_response hr;
999 715
1000 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 716 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1001 HPI_OSTREAM_SET_TIMESCALE); 717 HPI_OSTREAM_SET_TIMESCALE);
1002 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 718 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
719 return HPI_ERROR_INVALID_HANDLE;
1003 720
1004 hm.u.d.u.time_scale = time_scale; 721 hm.u.d.u.time_scale = time_scale;
1005 722
@@ -1008,22 +725,21 @@ u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys,
1008 return hr.error; 725 return hr.error;
1009} 726}
1010 727
1011u16 hpi_outstream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, 728u16 hpi_outstream_host_buffer_allocate(u32 h_outstream, u32 size_in_bytes)
1012 u32 h_outstream, u32 size_in_bytes)
1013{ 729{
1014 struct hpi_message hm; 730 struct hpi_message hm;
1015 struct hpi_response hr; 731 struct hpi_response hr;
1016 732
1017 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 733 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1018 HPI_OSTREAM_HOSTBUFFER_ALLOC); 734 HPI_OSTREAM_HOSTBUFFER_ALLOC);
1019 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 735 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
736 return HPI_ERROR_INVALID_HANDLE;
1020 hm.u.d.u.data.data_size = size_in_bytes; 737 hm.u.d.u.data.data_size = size_in_bytes;
1021 hpi_send_recv(&hm, &hr); 738 hpi_send_recv(&hm, &hr);
1022 return hr.error; 739 return hr.error;
1023} 740}
1024 741
1025u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, 742u16 hpi_outstream_host_buffer_get_info(u32 h_outstream, u8 **pp_buffer,
1026 u32 h_outstream, u8 **pp_buffer,
1027 struct hpi_hostbuffer_status **pp_status) 743 struct hpi_hostbuffer_status **pp_status)
1028{ 744{
1029 struct hpi_message hm; 745 struct hpi_message hm;
@@ -1031,7 +747,8 @@ u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1031 747
1032 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 748 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1033 HPI_OSTREAM_HOSTBUFFER_GET_INFO); 749 HPI_OSTREAM_HOSTBUFFER_GET_INFO);
1034 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 750 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
751 return HPI_ERROR_INVALID_HANDLE;
1035 hpi_send_recv(&hm, &hr); 752 hpi_send_recv(&hm, &hr);
1036 753
1037 if (hr.error == 0) { 754 if (hr.error == 0) {
@@ -1043,21 +760,20 @@ u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1043 return hr.error; 760 return hr.error;
1044} 761}
1045 762
1046u16 hpi_outstream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, 763u16 hpi_outstream_host_buffer_free(u32 h_outstream)
1047 u32 h_outstream)
1048{ 764{
1049 struct hpi_message hm; 765 struct hpi_message hm;
1050 struct hpi_response hr; 766 struct hpi_response hr;
1051 767
1052 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 768 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1053 HPI_OSTREAM_HOSTBUFFER_FREE); 769 HPI_OSTREAM_HOSTBUFFER_FREE);
1054 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 770 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
771 return HPI_ERROR_INVALID_HANDLE;
1055 hpi_send_recv(&hm, &hr); 772 hpi_send_recv(&hm, &hr);
1056 return hr.error; 773 return hr.error;
1057} 774}
1058 775
1059u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys, 776u16 hpi_outstream_group_add(u32 h_outstream, u32 h_stream)
1060 u32 h_outstream, u32 h_stream)
1061{ 777{
1062 struct hpi_message hm; 778 struct hpi_message hm;
1063 struct hpi_response hr; 779 struct hpi_response hr;
@@ -1066,22 +782,22 @@ u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys,
1066 782
1067 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 783 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1068 HPI_OSTREAM_GROUP_ADD); 784 HPI_OSTREAM_GROUP_ADD);
1069 hr.error = 0; 785
1070 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 786 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
787 return HPI_ERROR_INVALID_HANDLE;
788
789 if (hpi_handle_indexes(h_stream, &adapter,
790 &hm.u.d.u.stream.stream_index))
791 return HPI_ERROR_INVALID_HANDLE;
792
1071 c_obj_type = hpi_handle_object(h_stream); 793 c_obj_type = hpi_handle_object(h_stream);
1072 switch (c_obj_type) { 794 switch (c_obj_type) {
1073 case HPI_OBJ_OSTREAM: 795 case HPI_OBJ_OSTREAM:
1074 hm.u.d.u.stream.object_type = HPI_OBJ_OSTREAM;
1075 u32TOINDEXES(h_stream, &adapter,
1076 &hm.u.d.u.stream.stream_index);
1077 break;
1078 case HPI_OBJ_ISTREAM: 796 case HPI_OBJ_ISTREAM:
1079 hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM; 797 hm.u.d.u.stream.object_type = c_obj_type;
1080 u32TOINDEXES(h_stream, &adapter,
1081 &hm.u.d.u.stream.stream_index);
1082 break; 798 break;
1083 default: 799 default:
1084 return HPI_ERROR_INVALID_STREAM; 800 return HPI_ERROR_INVALID_OBJ;
1085 } 801 }
1086 if (adapter != hm.adapter_index) 802 if (adapter != hm.adapter_index)
1087 return HPI_ERROR_NO_INTERADAPTER_GROUPS; 803 return HPI_ERROR_NO_INTERADAPTER_GROUPS;
@@ -1090,15 +806,16 @@ u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys,
1090 return hr.error; 806 return hr.error;
1091} 807}
1092 808
1093u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys, 809u16 hpi_outstream_group_get_map(u32 h_outstream, u32 *poutstream_map,
1094 u32 h_outstream, u32 *poutstream_map, u32 *pinstream_map) 810 u32 *pinstream_map)
1095{ 811{
1096 struct hpi_message hm; 812 struct hpi_message hm;
1097 struct hpi_response hr; 813 struct hpi_response hr;
1098 814
1099 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 815 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1100 HPI_OSTREAM_GROUP_GETMAP); 816 HPI_OSTREAM_GROUP_GETMAP);
1101 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 817 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
818 return HPI_ERROR_INVALID_HANDLE;
1102 hpi_send_recv(&hm, &hr); 819 hpi_send_recv(&hm, &hr);
1103 820
1104 if (poutstream_map) 821 if (poutstream_map)
@@ -1109,21 +826,20 @@ u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys,
1109 return hr.error; 826 return hr.error;
1110} 827}
1111 828
1112u16 hpi_outstream_group_reset(const struct hpi_hsubsys *ph_subsys, 829u16 hpi_outstream_group_reset(u32 h_outstream)
1113 u32 h_outstream)
1114{ 830{
1115 struct hpi_message hm; 831 struct hpi_message hm;
1116 struct hpi_response hr; 832 struct hpi_response hr;
1117 833
1118 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 834 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1119 HPI_OSTREAM_GROUP_RESET); 835 HPI_OSTREAM_GROUP_RESET);
1120 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 836 if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
837 return HPI_ERROR_INVALID_HANDLE;
1121 hpi_send_recv(&hm, &hr); 838 hpi_send_recv(&hm, &hr);
1122 return hr.error; 839 return hr.error;
1123} 840}
1124 841
1125u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 842u16 hpi_instream_open(u16 adapter_index, u16 instream_index, u32 *ph_instream)
1126 u16 instream_index, u32 *ph_instream)
1127{ 843{
1128 struct hpi_message hm; 844 struct hpi_message hm;
1129 struct hpi_response hr; 845 struct hpi_response hr;
@@ -1145,38 +861,40 @@ u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1145 return hr.error; 861 return hr.error;
1146} 862}
1147 863
1148u16 hpi_instream_close(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 864u16 hpi_instream_close(u32 h_instream)
1149{ 865{
1150 struct hpi_message hm; 866 struct hpi_message hm;
1151 struct hpi_response hr; 867 struct hpi_response hr;
1152 868
1153 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 869 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1154 HPI_ISTREAM_HOSTBUFFER_FREE); 870 HPI_ISTREAM_HOSTBUFFER_FREE);
1155 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 871 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
872 return HPI_ERROR_INVALID_HANDLE;
1156 hpi_send_recv(&hm, &hr); 873 hpi_send_recv(&hm, &hr);
1157 874
1158 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 875 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1159 HPI_ISTREAM_GROUP_RESET); 876 HPI_ISTREAM_GROUP_RESET);
1160 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 877 hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index);
1161 hpi_send_recv(&hm, &hr); 878 hpi_send_recv(&hm, &hr);
1162 879
1163 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 880 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1164 HPI_ISTREAM_CLOSE); 881 HPI_ISTREAM_CLOSE);
1165 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 882 hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index);
1166 hpi_send_recv(&hm, &hr); 883 hpi_send_recv(&hm, &hr);
1167 884
1168 return hr.error; 885 return hr.error;
1169} 886}
1170 887
1171u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys, 888u16 hpi_instream_query_format(u32 h_instream,
1172 u32 h_instream, const struct hpi_format *p_format) 889 const struct hpi_format *p_format)
1173{ 890{
1174 struct hpi_message hm; 891 struct hpi_message hm;
1175 struct hpi_response hr; 892 struct hpi_response hr;
1176 893
1177 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 894 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1178 HPI_ISTREAM_QUERY_FORMAT); 895 HPI_ISTREAM_QUERY_FORMAT);
1179 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 896 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
897 return HPI_ERROR_INVALID_HANDLE;
1180 hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 898 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
1181 899
1182 hpi_send_recv(&hm, &hr); 900 hpi_send_recv(&hm, &hr);
@@ -1184,15 +902,15 @@ u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys,
1184 return hr.error; 902 return hr.error;
1185} 903}
1186 904
1187u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys, 905u16 hpi_instream_set_format(u32 h_instream, const struct hpi_format *p_format)
1188 u32 h_instream, const struct hpi_format *p_format)
1189{ 906{
1190 struct hpi_message hm; 907 struct hpi_message hm;
1191 struct hpi_response hr; 908 struct hpi_response hr;
1192 909
1193 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 910 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1194 HPI_ISTREAM_SET_FORMAT); 911 HPI_ISTREAM_SET_FORMAT);
1195 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 912 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
913 return HPI_ERROR_INVALID_HANDLE;
1196 hpi_format_to_msg(&hm.u.d.u.data.format, p_format); 914 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
1197 915
1198 hpi_send_recv(&hm, &hr); 916 hpi_send_recv(&hm, &hr);
@@ -1200,15 +918,15 @@ u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys,
1200 return hr.error; 918 return hr.error;
1201} 919}
1202 920
1203u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream, 921u16 hpi_instream_read_buf(u32 h_instream, u8 *pb_data, u32 bytes_to_read)
1204 u8 *pb_data, u32 bytes_to_read)
1205{ 922{
1206 struct hpi_message hm; 923 struct hpi_message hm;
1207 struct hpi_response hr; 924 struct hpi_response hr;
1208 925
1209 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 926 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1210 HPI_ISTREAM_READ); 927 HPI_ISTREAM_READ);
1211 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 928 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
929 return HPI_ERROR_INVALID_HANDLE;
1212 hm.u.d.u.data.data_size = bytes_to_read; 930 hm.u.d.u.data.data_size = bytes_to_read;
1213 hm.u.d.u.data.pb_data = pb_data; 931 hm.u.d.u.data.pb_data = pb_data;
1214 932
@@ -1217,72 +935,76 @@ u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream,
1217 return hr.error; 935 return hr.error;
1218} 936}
1219 937
1220u16 hpi_instream_start(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 938u16 hpi_instream_start(u32 h_instream)
1221{ 939{
1222 struct hpi_message hm; 940 struct hpi_message hm;
1223 struct hpi_response hr; 941 struct hpi_response hr;
1224 942
1225 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 943 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1226 HPI_ISTREAM_START); 944 HPI_ISTREAM_START);
1227 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 945 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
946 return HPI_ERROR_INVALID_HANDLE;
1228 947
1229 hpi_send_recv(&hm, &hr); 948 hpi_send_recv(&hm, &hr);
1230 949
1231 return hr.error; 950 return hr.error;
1232} 951}
1233 952
1234u16 hpi_instream_wait_start(const struct hpi_hsubsys *ph_subsys, 953u16 hpi_instream_wait_start(u32 h_instream)
1235 u32 h_instream)
1236{ 954{
1237 struct hpi_message hm; 955 struct hpi_message hm;
1238 struct hpi_response hr; 956 struct hpi_response hr;
1239 957
1240 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 958 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1241 HPI_ISTREAM_WAIT_START); 959 HPI_ISTREAM_WAIT_START);
1242 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 960 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
961 return HPI_ERROR_INVALID_HANDLE;
1243 962
1244 hpi_send_recv(&hm, &hr); 963 hpi_send_recv(&hm, &hr);
1245 964
1246 return hr.error; 965 return hr.error;
1247} 966}
1248 967
1249u16 hpi_instream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 968u16 hpi_instream_stop(u32 h_instream)
1250{ 969{
1251 struct hpi_message hm; 970 struct hpi_message hm;
1252 struct hpi_response hr; 971 struct hpi_response hr;
1253 972
1254 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 973 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1255 HPI_ISTREAM_STOP); 974 HPI_ISTREAM_STOP);
1256 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 975 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
976 return HPI_ERROR_INVALID_HANDLE;
1257 977
1258 hpi_send_recv(&hm, &hr); 978 hpi_send_recv(&hm, &hr);
1259 979
1260 return hr.error; 980 return hr.error;
1261} 981}
1262 982
1263u16 hpi_instream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_instream) 983u16 hpi_instream_reset(u32 h_instream)
1264{ 984{
1265 struct hpi_message hm; 985 struct hpi_message hm;
1266 struct hpi_response hr; 986 struct hpi_response hr;
1267 987
1268 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 988 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1269 HPI_ISTREAM_RESET); 989 HPI_ISTREAM_RESET);
1270 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 990 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
991 return HPI_ERROR_INVALID_HANDLE;
1271 992
1272 hpi_send_recv(&hm, &hr); 993 hpi_send_recv(&hm, &hr);
1273 994
1274 return hr.error; 995 return hr.error;
1275} 996}
1276 997
1277u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys, 998u16 hpi_instream_get_info_ex(u32 h_instream, u16 *pw_state, u32 *pbuffer_size,
1278 u32 h_instream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_recorded, 999 u32 *pdata_recorded, u32 *psamples_recorded,
1279 u32 *psamples_recorded, u32 *pauxiliary_data_recorded) 1000 u32 *pauxiliary_data_recorded)
1280{ 1001{
1281 struct hpi_message hm; 1002 struct hpi_message hm;
1282 struct hpi_response hr; 1003 struct hpi_response hr;
1283 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1004 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1284 HPI_ISTREAM_GET_INFO); 1005 HPI_ISTREAM_GET_INFO);
1285 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1006 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1007 return HPI_ERROR_INVALID_HANDLE;
1286 1008
1287 hpi_send_recv(&hm, &hr); 1009 hpi_send_recv(&hm, &hr);
1288 1010
@@ -1300,15 +1022,15 @@ u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys,
1300 return hr.error; 1022 return hr.error;
1301} 1023}
1302 1024
1303u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, 1025u16 hpi_instream_ancillary_reset(u32 h_instream, u16 bytes_per_frame,
1304 u32 h_instream, u16 bytes_per_frame, u16 mode, u16 alignment, 1026 u16 mode, u16 alignment, u16 idle_bit)
1305 u16 idle_bit)
1306{ 1027{
1307 struct hpi_message hm; 1028 struct hpi_message hm;
1308 struct hpi_response hr; 1029 struct hpi_response hr;
1309 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1030 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1310 HPI_ISTREAM_ANC_RESET); 1031 HPI_ISTREAM_ANC_RESET);
1311 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1032 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1033 return HPI_ERROR_INVALID_HANDLE;
1312 hm.u.d.u.data.format.attributes = bytes_per_frame; 1034 hm.u.d.u.data.format.attributes = bytes_per_frame;
1313 hm.u.d.u.data.format.format = (mode << 8) | (alignment & 0xff); 1035 hm.u.d.u.data.format.format = (mode << 8) | (alignment & 0xff);
1314 hm.u.d.u.data.format.channels = idle_bit; 1036 hm.u.d.u.data.format.channels = idle_bit;
@@ -1316,14 +1038,14 @@ u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys,
1316 return hr.error; 1038 return hr.error;
1317} 1039}
1318 1040
1319u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, 1041u16 hpi_instream_ancillary_get_info(u32 h_instream, u32 *pframe_space)
1320 u32 h_instream, u32 *pframe_space)
1321{ 1042{
1322 struct hpi_message hm; 1043 struct hpi_message hm;
1323 struct hpi_response hr; 1044 struct hpi_response hr;
1324 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1045 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1325 HPI_ISTREAM_ANC_GET_INFO); 1046 HPI_ISTREAM_ANC_GET_INFO);
1326 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1047 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1048 return HPI_ERROR_INVALID_HANDLE;
1327 hpi_send_recv(&hm, &hr); 1049 hpi_send_recv(&hm, &hr);
1328 if (pframe_space) 1050 if (pframe_space)
1329 *pframe_space = 1051 *pframe_space =
@@ -1333,8 +1055,8 @@ u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys,
1333 return hr.error; 1055 return hr.error;
1334} 1056}
1335 1057
1336u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys, 1058u16 hpi_instream_ancillary_write(u32 h_instream,
1337 u32 h_instream, const struct hpi_anc_frame *p_anc_frame_buffer, 1059 const struct hpi_anc_frame *p_anc_frame_buffer,
1338 u32 anc_frame_buffer_size_in_bytes, 1060 u32 anc_frame_buffer_size_in_bytes,
1339 u32 number_of_ancillary_frames_to_write) 1061 u32 number_of_ancillary_frames_to_write)
1340{ 1062{
@@ -1343,7 +1065,8 @@ u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys,
1343 1065
1344 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1066 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1345 HPI_ISTREAM_ANC_WRITE); 1067 HPI_ISTREAM_ANC_WRITE);
1346 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1068 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1069 return HPI_ERROR_INVALID_HANDLE;
1347 hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer; 1070 hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer;
1348 hm.u.d.u.data.data_size = 1071 hm.u.d.u.data.data_size =
1349 number_of_ancillary_frames_to_write * 1072 number_of_ancillary_frames_to_write *
@@ -1351,12 +1074,11 @@ u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys,
1351 if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes) 1074 if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes)
1352 hpi_send_recv(&hm, &hr); 1075 hpi_send_recv(&hm, &hr);
1353 else 1076 else
1354 hr.error = HPI_ERROR_INVALID_DATA_TRANSFER; 1077 hr.error = HPI_ERROR_INVALID_DATASIZE;
1355 return hr.error; 1078 return hr.error;
1356} 1079}
1357 1080
1358u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, 1081u16 hpi_instream_host_buffer_allocate(u32 h_instream, u32 size_in_bytes)
1359 u32 h_instream, u32 size_in_bytes)
1360{ 1082{
1361 1083
1362 struct hpi_message hm; 1084 struct hpi_message hm;
@@ -1364,14 +1086,14 @@ u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys,
1364 1086
1365 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1087 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1366 HPI_ISTREAM_HOSTBUFFER_ALLOC); 1088 HPI_ISTREAM_HOSTBUFFER_ALLOC);
1367 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1089 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1090 return HPI_ERROR_INVALID_HANDLE;
1368 hm.u.d.u.data.data_size = size_in_bytes; 1091 hm.u.d.u.data.data_size = size_in_bytes;
1369 hpi_send_recv(&hm, &hr); 1092 hpi_send_recv(&hm, &hr);
1370 return hr.error; 1093 return hr.error;
1371} 1094}
1372 1095
1373u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, 1096u16 hpi_instream_host_buffer_get_info(u32 h_instream, u8 **pp_buffer,
1374 u32 h_instream, u8 **pp_buffer,
1375 struct hpi_hostbuffer_status **pp_status) 1097 struct hpi_hostbuffer_status **pp_status)
1376{ 1098{
1377 struct hpi_message hm; 1099 struct hpi_message hm;
@@ -1379,7 +1101,8 @@ u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1379 1101
1380 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1102 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1381 HPI_ISTREAM_HOSTBUFFER_GET_INFO); 1103 HPI_ISTREAM_HOSTBUFFER_GET_INFO);
1382 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1104 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1105 return HPI_ERROR_INVALID_HANDLE;
1383 hpi_send_recv(&hm, &hr); 1106 hpi_send_recv(&hm, &hr);
1384 1107
1385 if (hr.error == 0) { 1108 if (hr.error == 0) {
@@ -1391,8 +1114,7 @@ u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1391 return hr.error; 1114 return hr.error;
1392} 1115}
1393 1116
1394u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, 1117u16 hpi_instream_host_buffer_free(u32 h_instream)
1395 u32 h_instream)
1396{ 1118{
1397 1119
1398 struct hpi_message hm; 1120 struct hpi_message hm;
@@ -1400,13 +1122,13 @@ u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys,
1400 1122
1401 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1123 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1402 HPI_ISTREAM_HOSTBUFFER_FREE); 1124 HPI_ISTREAM_HOSTBUFFER_FREE);
1403 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1125 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1126 return HPI_ERROR_INVALID_HANDLE;
1404 hpi_send_recv(&hm, &hr); 1127 hpi_send_recv(&hm, &hr);
1405 return hr.error; 1128 return hr.error;
1406} 1129}
1407 1130
1408u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys, 1131u16 hpi_instream_group_add(u32 h_instream, u32 h_stream)
1409 u32 h_instream, u32 h_stream)
1410{ 1132{
1411 struct hpi_message hm; 1133 struct hpi_message hm;
1412 struct hpi_response hr; 1134 struct hpi_response hr;
@@ -1416,22 +1138,23 @@ u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys,
1416 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1138 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1417 HPI_ISTREAM_GROUP_ADD); 1139 HPI_ISTREAM_GROUP_ADD);
1418 hr.error = 0; 1140 hr.error = 0;
1419 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1141
1142 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1143 return HPI_ERROR_INVALID_HANDLE;
1144
1145 if (hpi_handle_indexes(h_stream, &adapter,
1146 &hm.u.d.u.stream.stream_index))
1147 return HPI_ERROR_INVALID_HANDLE;
1148
1420 c_obj_type = hpi_handle_object(h_stream); 1149 c_obj_type = hpi_handle_object(h_stream);
1421 1150
1422 switch (c_obj_type) { 1151 switch (c_obj_type) {
1423 case HPI_OBJ_OSTREAM: 1152 case HPI_OBJ_OSTREAM:
1424 hm.u.d.u.stream.object_type = HPI_OBJ_OSTREAM;
1425 u32TOINDEXES(h_stream, &adapter,
1426 &hm.u.d.u.stream.stream_index);
1427 break;
1428 case HPI_OBJ_ISTREAM: 1153 case HPI_OBJ_ISTREAM:
1429 hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM; 1154 hm.u.d.u.stream.object_type = c_obj_type;
1430 u32TOINDEXES(h_stream, &adapter,
1431 &hm.u.d.u.stream.stream_index);
1432 break; 1155 break;
1433 default: 1156 default:
1434 return HPI_ERROR_INVALID_STREAM; 1157 return HPI_ERROR_INVALID_OBJ;
1435 } 1158 }
1436 1159
1437 if (adapter != hm.adapter_index) 1160 if (adapter != hm.adapter_index)
@@ -1441,15 +1164,16 @@ u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys,
1441 return hr.error; 1164 return hr.error;
1442} 1165}
1443 1166
1444u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys, 1167u16 hpi_instream_group_get_map(u32 h_instream, u32 *poutstream_map,
1445 u32 h_instream, u32 *poutstream_map, u32 *pinstream_map) 1168 u32 *pinstream_map)
1446{ 1169{
1447 struct hpi_message hm; 1170 struct hpi_message hm;
1448 struct hpi_response hr; 1171 struct hpi_response hr;
1449 1172
1450 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1173 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1451 HPI_ISTREAM_HOSTBUFFER_FREE); 1174 HPI_ISTREAM_HOSTBUFFER_FREE);
1452 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1175 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1176 return HPI_ERROR_INVALID_HANDLE;
1453 hpi_send_recv(&hm, &hr); 1177 hpi_send_recv(&hm, &hr);
1454 1178
1455 if (poutstream_map) 1179 if (poutstream_map)
@@ -1460,21 +1184,20 @@ u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys,
1460 return hr.error; 1184 return hr.error;
1461} 1185}
1462 1186
1463u16 hpi_instream_group_reset(const struct hpi_hsubsys *ph_subsys, 1187u16 hpi_instream_group_reset(u32 h_instream)
1464 u32 h_instream)
1465{ 1188{
1466 struct hpi_message hm; 1189 struct hpi_message hm;
1467 struct hpi_response hr; 1190 struct hpi_response hr;
1468 1191
1469 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 1192 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1470 HPI_ISTREAM_GROUP_RESET); 1193 HPI_ISTREAM_GROUP_RESET);
1471 u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); 1194 if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1195 return HPI_ERROR_INVALID_HANDLE;
1472 hpi_send_recv(&hm, &hr); 1196 hpi_send_recv(&hm, &hr);
1473 return hr.error; 1197 return hr.error;
1474} 1198}
1475 1199
1476u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, 1200u16 hpi_mixer_open(u16 adapter_index, u32 *ph_mixer)
1477 u32 *ph_mixer)
1478{ 1201{
1479 struct hpi_message hm; 1202 struct hpi_message hm;
1480 struct hpi_response hr; 1203 struct hpi_response hr;
@@ -1492,25 +1215,29 @@ u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1492 return hr.error; 1215 return hr.error;
1493} 1216}
1494 1217
1495u16 hpi_mixer_close(const struct hpi_hsubsys *ph_subsys, u32 h_mixer) 1218u16 hpi_mixer_close(u32 h_mixer)
1496{ 1219{
1497 struct hpi_message hm; 1220 struct hpi_message hm;
1498 struct hpi_response hr; 1221 struct hpi_response hr;
1222
1499 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE); 1223 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE);
1500 u32TOINDEX(h_mixer, &hm.adapter_index); 1224 if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1225 return HPI_ERROR_INVALID_HANDLE;
1226
1501 hpi_send_recv(&hm, &hr); 1227 hpi_send_recv(&hm, &hr);
1502 return hr.error; 1228 return hr.error;
1503} 1229}
1504 1230
1505u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, 1231u16 hpi_mixer_get_control(u32 h_mixer, u16 src_node_type,
1506 u16 src_node_type, u16 src_node_type_index, u16 dst_node_type, 1232 u16 src_node_type_index, u16 dst_node_type, u16 dst_node_type_index,
1507 u16 dst_node_type_index, u16 control_type, u32 *ph_control) 1233 u16 control_type, u32 *ph_control)
1508{ 1234{
1509 struct hpi_message hm; 1235 struct hpi_message hm;
1510 struct hpi_response hr; 1236 struct hpi_response hr;
1511 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, 1237 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER,
1512 HPI_MIXER_GET_CONTROL); 1238 HPI_MIXER_GET_CONTROL);
1513 u32TOINDEX(h_mixer, &hm.adapter_index); 1239 if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1240 return HPI_ERROR_INVALID_HANDLE;
1514 hm.u.m.node_type1 = src_node_type; 1241 hm.u.m.node_type1 = src_node_type;
1515 hm.u.m.node_index1 = src_node_type_index; 1242 hm.u.m.node_index1 = src_node_type_index;
1516 hm.u.m.node_type2 = dst_node_type; 1243 hm.u.m.node_type2 = dst_node_type;
@@ -1528,16 +1255,16 @@ u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer,
1528 return hr.error; 1255 return hr.error;
1529} 1256}
1530 1257
1531u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys, 1258u16 hpi_mixer_get_control_by_index(u32 h_mixer, u16 control_index,
1532 u32 h_mixer, u16 control_index, u16 *pw_src_node_type, 1259 u16 *pw_src_node_type, u16 *pw_src_node_index, u16 *pw_dst_node_type,
1533 u16 *pw_src_node_index, u16 *pw_dst_node_type, u16 *pw_dst_node_index, 1260 u16 *pw_dst_node_index, u16 *pw_control_type, u32 *ph_control)
1534 u16 *pw_control_type, u32 *ph_control)
1535{ 1261{
1536 struct hpi_message hm; 1262 struct hpi_message hm;
1537 struct hpi_response hr; 1263 struct hpi_response hr;
1538 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, 1264 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER,
1539 HPI_MIXER_GET_CONTROL_BY_INDEX); 1265 HPI_MIXER_GET_CONTROL_BY_INDEX);
1540 u32TOINDEX(h_mixer, &hm.adapter_index); 1266 if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1267 return HPI_ERROR_INVALID_HANDLE;
1541 hm.u.m.control_index = control_index; 1268 hm.u.m.control_index = control_index;
1542 hpi_send_recv(&hm, &hr); 1269 hpi_send_recv(&hm, &hr);
1543 1270
@@ -1562,13 +1289,14 @@ u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys,
1562 return hr.error; 1289 return hr.error;
1563} 1290}
1564 1291
1565u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, 1292u16 hpi_mixer_store(u32 h_mixer, enum HPI_MIXER_STORE_COMMAND command,
1566 enum HPI_MIXER_STORE_COMMAND command, u16 index) 1293 u16 index)
1567{ 1294{
1568 struct hpi_message hm; 1295 struct hpi_message hm;
1569 struct hpi_response hr; 1296 struct hpi_response hr;
1570 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_STORE); 1297 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_STORE);
1571 u32TOINDEX(h_mixer, &hm.adapter_index); 1298 if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1299 return HPI_ERROR_INVALID_HANDLE;
1572 hm.u.mx.store.command = command; 1300 hm.u.mx.store.command = command;
1573 hm.u.mx.store.index = index; 1301 hm.u.mx.store.index = index;
1574 hpi_send_recv(&hm, &hr); 1302 hpi_send_recv(&hm, &hr);
@@ -1576,16 +1304,16 @@ u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer,
1576} 1304}
1577 1305
1578static 1306static
1579u16 hpi_control_param_set(const struct hpi_hsubsys *ph_subsys, 1307u16 hpi_control_param_set(const u32 h_control, const u16 attrib,
1580 const u32 h_control, const u16 attrib, const u32 param1, 1308 const u32 param1, const u32 param2)
1581 const u32 param2)
1582{ 1309{
1583 struct hpi_message hm; 1310 struct hpi_message hm;
1584 struct hpi_response hr; 1311 struct hpi_response hr;
1585 1312
1586 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1313 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1587 HPI_CONTROL_SET_STATE); 1314 HPI_CONTROL_SET_STATE);
1588 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1315 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1316 return HPI_ERROR_INVALID_HANDLE;
1589 hm.u.c.attribute = attrib; 1317 hm.u.c.attribute = attrib;
1590 hm.u.c.param1 = param1; 1318 hm.u.c.param1 = param1;
1591 hm.u.c.param2 = param2; 1319 hm.u.c.param2 = param2;
@@ -1601,7 +1329,8 @@ static u16 hpi_control_log_set2(u32 h_control, u16 attrib, short sv0,
1601 1329
1602 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1330 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1603 HPI_CONTROL_SET_STATE); 1331 HPI_CONTROL_SET_STATE);
1604 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1332 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1333 return HPI_ERROR_INVALID_HANDLE;
1605 hm.u.c.attribute = attrib; 1334 hm.u.c.attribute = attrib;
1606 hm.u.c.an_log_value[0] = sv0; 1335 hm.u.c.an_log_value[0] = sv0;
1607 hm.u.c.an_log_value[1] = sv1; 1336 hm.u.c.an_log_value[1] = sv1;
@@ -1610,16 +1339,16 @@ static u16 hpi_control_log_set2(u32 h_control, u16 attrib, short sv0,
1610} 1339}
1611 1340
1612static 1341static
1613u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys, 1342u16 hpi_control_param_get(const u32 h_control, const u16 attrib, u32 param1,
1614 const u32 h_control, const u16 attrib, u32 param1, u32 param2, 1343 u32 param2, u32 *pparam1, u32 *pparam2)
1615 u32 *pparam1, u32 *pparam2)
1616{ 1344{
1617 struct hpi_message hm; 1345 struct hpi_message hm;
1618 struct hpi_response hr; 1346 struct hpi_response hr;
1619 1347
1620 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1348 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1621 HPI_CONTROL_GET_STATE); 1349 HPI_CONTROL_GET_STATE);
1622 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1350 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1351 return HPI_ERROR_INVALID_HANDLE;
1623 hm.u.c.attribute = attrib; 1352 hm.u.c.attribute = attrib;
1624 hm.u.c.param1 = param1; 1353 hm.u.c.param1 = param1;
1625 hm.u.c.param2 = param2; 1354 hm.u.c.param2 = param2;
@@ -1632,19 +1361,20 @@ u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys,
1632 return hr.error; 1361 return hr.error;
1633} 1362}
1634 1363
1635#define hpi_control_param1_get(s, h, a, p1) \ 1364#define hpi_control_param1_get(h, a, p1) \
1636 hpi_control_param_get(s, h, a, 0, 0, p1, NULL) 1365 hpi_control_param_get(h, a, 0, 0, p1, NULL)
1637#define hpi_control_param2_get(s, h, a, p1, p2) \ 1366#define hpi_control_param2_get(h, a, p1, p2) \
1638 hpi_control_param_get(s, h, a, 0, 0, p1, p2) 1367 hpi_control_param_get(h, a, 0, 0, p1, p2)
1639 1368
1640static u16 hpi_control_log_get2(const struct hpi_hsubsys *ph_subsys, 1369static u16 hpi_control_log_get2(u32 h_control, u16 attrib, short *sv0,
1641 u32 h_control, u16 attrib, short *sv0, short *sv1) 1370 short *sv1)
1642{ 1371{
1643 struct hpi_message hm; 1372 struct hpi_message hm;
1644 struct hpi_response hr; 1373 struct hpi_response hr;
1645 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1374 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1646 HPI_CONTROL_GET_STATE); 1375 HPI_CONTROL_GET_STATE);
1647 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1376 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1377 return HPI_ERROR_INVALID_HANDLE;
1648 hm.u.c.attribute = attrib; 1378 hm.u.c.attribute = attrib;
1649 1379
1650 hpi_send_recv(&hm, &hr); 1380 hpi_send_recv(&hm, &hr);
@@ -1655,8 +1385,7 @@ static u16 hpi_control_log_get2(const struct hpi_hsubsys *ph_subsys,
1655} 1385}
1656 1386
1657static 1387static
1658u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys, 1388u16 hpi_control_query(const u32 h_control, const u16 attrib, const u32 index,
1659 const u32 h_control, const u16 attrib, const u32 index,
1660 const u32 param, u32 *psetting) 1389 const u32 param, u32 *psetting)
1661{ 1390{
1662 struct hpi_message hm; 1391 struct hpi_message hm;
@@ -1664,7 +1393,8 @@ u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys,
1664 1393
1665 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1394 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1666 HPI_CONTROL_GET_INFO); 1395 HPI_CONTROL_GET_INFO);
1667 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1396 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1397 return HPI_ERROR_INVALID_HANDLE;
1668 1398
1669 hm.u.c.attribute = attrib; 1399 hm.u.c.attribute = attrib;
1670 hm.u.c.param1 = index; 1400 hm.u.c.param1 = index;
@@ -1682,7 +1412,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1682 unsigned int sub_string_index = 0, j = 0; 1412 unsigned int sub_string_index = 0, j = 0;
1683 char c = 0; 1413 char c = 0;
1684 unsigned int n = 0; 1414 unsigned int n = 0;
1685 u16 hE = 0; 1415 u16 err = 0;
1686 1416
1687 if ((string_length < 1) || (string_length > 256)) 1417 if ((string_length < 1) || (string_length > 256))
1688 return HPI_ERROR_INVALID_CONTROL_VALUE; 1418 return HPI_ERROR_INVALID_CONTROL_VALUE;
@@ -1693,7 +1423,9 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1693 1423
1694 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1424 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1695 HPI_CONTROL_GET_STATE); 1425 HPI_CONTROL_GET_STATE);
1696 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1426 if (hpi_handle_indexes(h_control, &hm.adapter_index,
1427 &hm.obj_index))
1428 return HPI_ERROR_INVALID_HANDLE;
1697 hm.u.c.attribute = attribute; 1429 hm.u.c.attribute = attribute;
1698 hm.u.c.param1 = sub_string_index; 1430 hm.u.c.param1 = sub_string_index;
1699 hm.u.c.param2 = 0; 1431 hm.u.c.param2 = 0;
@@ -1705,7 +1437,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1705 return HPI_ERROR_INVALID_CONTROL_VALUE; 1437 return HPI_ERROR_INVALID_CONTROL_VALUE;
1706 1438
1707 if (hr.error) { 1439 if (hr.error) {
1708 hE = hr.error; 1440 err = hr.error;
1709 break; 1441 break;
1710 } 1442 }
1711 for (j = 0; j < 8; j++) { 1443 for (j = 0; j < 8; j++) {
@@ -1714,7 +1446,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1714 n++; 1446 n++;
1715 if (n >= string_length) { 1447 if (n >= string_length) {
1716 psz_string[string_length - 1] = 0; 1448 psz_string[string_length - 1] = 0;
1717 hE = HPI_ERROR_INVALID_CONTROL_VALUE; 1449 err = HPI_ERROR_INVALID_CONTROL_VALUE;
1718 break; 1450 break;
1719 } 1451 }
1720 if (c == 0) 1452 if (c == 0)
@@ -1730,57 +1462,52 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1730 if (c == 0) 1462 if (c == 0)
1731 break; 1463 break;
1732 } 1464 }
1733 return hE; 1465 return err;
1734} 1466}
1735 1467
1736u16 HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys *ph_subsys, 1468u16 hpi_aesebu_receiver_query_format(const u32 h_aes_rx, const u32 index,
1737 const u32 h_aes_rx, const u32 index, u16 *pw_format) 1469 u16 *pw_format)
1738{ 1470{
1739 u32 qr; 1471 u32 qr;
1740 u16 err; 1472 u16 err;
1741 1473
1742 err = hpi_control_query(ph_subsys, h_aes_rx, HPI_AESEBURX_FORMAT, 1474 err = hpi_control_query(h_aes_rx, HPI_AESEBURX_FORMAT, index, 0, &qr);
1743 index, 0, &qr);
1744 *pw_format = (u16)qr; 1475 *pw_format = (u16)qr;
1745 return err; 1476 return err;
1746} 1477}
1747 1478
1748u16 HPI_AESEBU__receiver_set_format(const struct hpi_hsubsys *ph_subsys, 1479u16 hpi_aesebu_receiver_set_format(u32 h_control, u16 format)
1749 u32 h_control, u16 format)
1750{ 1480{
1751 return hpi_control_param_set(ph_subsys, h_control, 1481 return hpi_control_param_set(h_control, HPI_AESEBURX_FORMAT, format,
1752 HPI_AESEBURX_FORMAT, format, 0); 1482 0);
1753} 1483}
1754 1484
1755u16 HPI_AESEBU__receiver_get_format(const struct hpi_hsubsys *ph_subsys, 1485u16 hpi_aesebu_receiver_get_format(u32 h_control, u16 *pw_format)
1756 u32 h_control, u16 *pw_format)
1757{ 1486{
1758 u16 err; 1487 u16 err;
1759 u32 param; 1488 u32 param;
1760 1489
1761 err = hpi_control_param1_get(ph_subsys, h_control, 1490 err = hpi_control_param1_get(h_control, HPI_AESEBURX_FORMAT, &param);
1762 HPI_AESEBURX_FORMAT, &param);
1763 if (!err && pw_format) 1491 if (!err && pw_format)
1764 *pw_format = (u16)param; 1492 *pw_format = (u16)param;
1765 1493
1766 return err; 1494 return err;
1767} 1495}
1768 1496
1769u16 HPI_AESEBU__receiver_get_sample_rate(const struct hpi_hsubsys *ph_subsys, 1497u16 hpi_aesebu_receiver_get_sample_rate(u32 h_control, u32 *psample_rate)
1770 u32 h_control, u32 *psample_rate)
1771{ 1498{
1772 return hpi_control_param1_get(ph_subsys, h_control, 1499 return hpi_control_param1_get(h_control, HPI_AESEBURX_SAMPLERATE,
1773 HPI_AESEBURX_SAMPLERATE, psample_rate); 1500 psample_rate);
1774} 1501}
1775 1502
1776u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys, 1503u16 hpi_aesebu_receiver_get_user_data(u32 h_control, u16 index, u16 *pw_data)
1777 u32 h_control, u16 index, u16 *pw_data)
1778{ 1504{
1779 struct hpi_message hm; 1505 struct hpi_message hm;
1780 struct hpi_response hr; 1506 struct hpi_response hr;
1781 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1507 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1782 HPI_CONTROL_GET_STATE); 1508 HPI_CONTROL_GET_STATE);
1783 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1509 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1510 return HPI_ERROR_INVALID_HANDLE;
1784 hm.u.c.attribute = HPI_AESEBURX_USERDATA; 1511 hm.u.c.attribute = HPI_AESEBURX_USERDATA;
1785 hm.u.c.param1 = index; 1512 hm.u.c.param1 = index;
1786 1513
@@ -1791,14 +1518,15 @@ u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys,
1791 return hr.error; 1518 return hr.error;
1792} 1519}
1793 1520
1794u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys 1521u16 hpi_aesebu_receiver_get_channel_status(u32 h_control, u16 index,
1795 *ph_subsys, u32 h_control, u16 index, u16 *pw_data) 1522 u16 *pw_data)
1796{ 1523{
1797 struct hpi_message hm; 1524 struct hpi_message hm;
1798 struct hpi_response hr; 1525 struct hpi_response hr;
1799 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1526 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1800 HPI_CONTROL_GET_STATE); 1527 HPI_CONTROL_GET_STATE);
1801 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1528 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1529 return HPI_ERROR_INVALID_HANDLE;
1802 hm.u.c.attribute = HPI_AESEBURX_CHANNELSTATUS; 1530 hm.u.c.attribute = HPI_AESEBURX_CHANNELSTATUS;
1803 hm.u.c.param1 = index; 1531 hm.u.c.param1 = index;
1804 1532
@@ -1809,101 +1537,93 @@ u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys
1809 return hr.error; 1537 return hr.error;
1810} 1538}
1811 1539
1812u16 HPI_AESEBU__receiver_get_error_status(const struct hpi_hsubsys *ph_subsys, 1540u16 hpi_aesebu_receiver_get_error_status(u32 h_control, u16 *pw_error_data)
1813 u32 h_control, u16 *pw_error_data)
1814{ 1541{
1815 u32 error_data = 0; 1542 u32 error_data = 0;
1816 u16 error = 0; 1543 u16 err = 0;
1817 1544
1818 error = hpi_control_param1_get(ph_subsys, h_control, 1545 err = hpi_control_param1_get(h_control, HPI_AESEBURX_ERRORSTATUS,
1819 HPI_AESEBURX_ERRORSTATUS, &error_data); 1546 &error_data);
1820 if (pw_error_data) 1547 if (pw_error_data)
1821 *pw_error_data = (u16)error_data; 1548 *pw_error_data = (u16)error_data;
1822 return error; 1549 return err;
1823} 1550}
1824 1551
1825u16 HPI_AESEBU__transmitter_set_sample_rate(const struct hpi_hsubsys 1552u16 hpi_aesebu_transmitter_set_sample_rate(u32 h_control, u32 sample_rate)
1826 *ph_subsys, u32 h_control, u32 sample_rate)
1827{ 1553{
1828 return hpi_control_param_set(ph_subsys, h_control, 1554 return hpi_control_param_set(h_control, HPI_AESEBUTX_SAMPLERATE,
1829 HPI_AESEBUTX_SAMPLERATE, sample_rate, 0); 1555 sample_rate, 0);
1830} 1556}
1831 1557
1832u16 HPI_AESEBU__transmitter_set_user_data(const struct hpi_hsubsys *ph_subsys, 1558u16 hpi_aesebu_transmitter_set_user_data(u32 h_control, u16 index, u16 data)
1833 u32 h_control, u16 index, u16 data)
1834{ 1559{
1835 return hpi_control_param_set(ph_subsys, h_control, 1560 return hpi_control_param_set(h_control, HPI_AESEBUTX_USERDATA, index,
1836 HPI_AESEBUTX_USERDATA, index, data); 1561 data);
1837} 1562}
1838 1563
1839u16 HPI_AESEBU__transmitter_set_channel_status(const struct hpi_hsubsys 1564u16 hpi_aesebu_transmitter_set_channel_status(u32 h_control, u16 index,
1840 *ph_subsys, u32 h_control, u16 index, u16 data) 1565 u16 data)
1841{ 1566{
1842 return hpi_control_param_set(ph_subsys, h_control, 1567 return hpi_control_param_set(h_control, HPI_AESEBUTX_CHANNELSTATUS,
1843 HPI_AESEBUTX_CHANNELSTATUS, index, data); 1568 index, data);
1844} 1569}
1845 1570
1846u16 HPI_AESEBU__transmitter_get_channel_status(const struct hpi_hsubsys 1571u16 hpi_aesebu_transmitter_get_channel_status(u32 h_control, u16 index,
1847 *ph_subsys, u32 h_control, u16 index, u16 *pw_data) 1572 u16 *pw_data)
1848{ 1573{
1849 return HPI_ERROR_INVALID_OPERATION; 1574 return HPI_ERROR_INVALID_OPERATION;
1850} 1575}
1851 1576
1852u16 HPI_AESEBU__transmitter_query_format(const struct hpi_hsubsys *ph_subsys, 1577u16 hpi_aesebu_transmitter_query_format(const u32 h_aes_tx, const u32 index,
1853 const u32 h_aes_tx, const u32 index, u16 *pw_format) 1578 u16 *pw_format)
1854{ 1579{
1855 u32 qr; 1580 u32 qr;
1856 u16 err; 1581 u16 err;
1857 1582
1858 err = hpi_control_query(ph_subsys, h_aes_tx, HPI_AESEBUTX_FORMAT, 1583 err = hpi_control_query(h_aes_tx, HPI_AESEBUTX_FORMAT, index, 0, &qr);
1859 index, 0, &qr);
1860 *pw_format = (u16)qr; 1584 *pw_format = (u16)qr;
1861 return err; 1585 return err;
1862} 1586}
1863 1587
1864u16 HPI_AESEBU__transmitter_set_format(const struct hpi_hsubsys *ph_subsys, 1588u16 hpi_aesebu_transmitter_set_format(u32 h_control, u16 output_format)
1865 u32 h_control, u16 output_format)
1866{ 1589{
1867 return hpi_control_param_set(ph_subsys, h_control, 1590 return hpi_control_param_set(h_control, HPI_AESEBUTX_FORMAT,
1868 HPI_AESEBUTX_FORMAT, output_format, 0); 1591 output_format, 0);
1869} 1592}
1870 1593
1871u16 HPI_AESEBU__transmitter_get_format(const struct hpi_hsubsys *ph_subsys, 1594u16 hpi_aesebu_transmitter_get_format(u32 h_control, u16 *pw_output_format)
1872 u32 h_control, u16 *pw_output_format)
1873{ 1595{
1874 u16 err; 1596 u16 err;
1875 u32 param; 1597 u32 param;
1876 1598
1877 err = hpi_control_param1_get(ph_subsys, h_control, 1599 err = hpi_control_param1_get(h_control, HPI_AESEBUTX_FORMAT, &param);
1878 HPI_AESEBUTX_FORMAT, &param);
1879 if (!err && pw_output_format) 1600 if (!err && pw_output_format)
1880 *pw_output_format = (u16)param; 1601 *pw_output_format = (u16)param;
1881 1602
1882 return err; 1603 return err;
1883} 1604}
1884 1605
1885u16 hpi_bitstream_set_clock_edge(const struct hpi_hsubsys *ph_subsys, 1606u16 hpi_bitstream_set_clock_edge(u32 h_control, u16 edge_type)
1886 u32 h_control, u16 edge_type)
1887{ 1607{
1888 return hpi_control_param_set(ph_subsys, h_control, 1608 return hpi_control_param_set(h_control, HPI_BITSTREAM_CLOCK_EDGE,
1889 HPI_BITSTREAM_CLOCK_EDGE, edge_type, 0); 1609 edge_type, 0);
1890} 1610}
1891 1611
1892u16 hpi_bitstream_set_data_polarity(const struct hpi_hsubsys *ph_subsys, 1612u16 hpi_bitstream_set_data_polarity(u32 h_control, u16 polarity)
1893 u32 h_control, u16 polarity)
1894{ 1613{
1895 return hpi_control_param_set(ph_subsys, h_control, 1614 return hpi_control_param_set(h_control, HPI_BITSTREAM_DATA_POLARITY,
1896 HPI_BITSTREAM_DATA_POLARITY, polarity, 0); 1615 polarity, 0);
1897} 1616}
1898 1617
1899u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys, 1618u16 hpi_bitstream_get_activity(u32 h_control, u16 *pw_clk_activity,
1900 u32 h_control, u16 *pw_clk_activity, u16 *pw_data_activity) 1619 u16 *pw_data_activity)
1901{ 1620{
1902 struct hpi_message hm; 1621 struct hpi_message hm;
1903 struct hpi_response hr; 1622 struct hpi_response hr;
1904 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1623 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1905 HPI_CONTROL_GET_STATE); 1624 HPI_CONTROL_GET_STATE);
1906 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1625 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1626 return HPI_ERROR_INVALID_HANDLE;
1907 hm.u.c.attribute = HPI_BITSTREAM_ACTIVITY; 1627 hm.u.c.attribute = HPI_BITSTREAM_ACTIVITY;
1908 hpi_send_recv(&hm, &hr); 1628 hpi_send_recv(&hm, &hr);
1909 if (pw_clk_activity) 1629 if (pw_clk_activity)
@@ -1913,45 +1633,43 @@ u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys,
1913 return hr.error; 1633 return hr.error;
1914} 1634}
1915 1635
1916u16 hpi_channel_mode_query_mode(const struct hpi_hsubsys *ph_subsys, 1636u16 hpi_channel_mode_query_mode(const u32 h_mode, const u32 index,
1917 const u32 h_mode, const u32 index, u16 *pw_mode) 1637 u16 *pw_mode)
1918{ 1638{
1919 u32 qr; 1639 u32 qr;
1920 u16 err; 1640 u16 err;
1921 1641
1922 err = hpi_control_query(ph_subsys, h_mode, HPI_CHANNEL_MODE_MODE, 1642 err = hpi_control_query(h_mode, HPI_CHANNEL_MODE_MODE, index, 0, &qr);
1923 index, 0, &qr);
1924 *pw_mode = (u16)qr; 1643 *pw_mode = (u16)qr;
1925 return err; 1644 return err;
1926} 1645}
1927 1646
1928u16 hpi_channel_mode_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1647u16 hpi_channel_mode_set(u32 h_control, u16 mode)
1929 u16 mode)
1930{ 1648{
1931 return hpi_control_param_set(ph_subsys, h_control, 1649 return hpi_control_param_set(h_control, HPI_CHANNEL_MODE_MODE, mode,
1932 HPI_CHANNEL_MODE_MODE, mode, 0); 1650 0);
1933} 1651}
1934 1652
1935u16 hpi_channel_mode_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1653u16 hpi_channel_mode_get(u32 h_control, u16 *mode)
1936 u16 *mode)
1937{ 1654{
1938 u32 mode32 = 0; 1655 u32 mode32 = 0;
1939 u16 error = hpi_control_param1_get(ph_subsys, h_control, 1656 u16 err = hpi_control_param1_get(h_control,
1940 HPI_CHANNEL_MODE_MODE, &mode32); 1657 HPI_CHANNEL_MODE_MODE, &mode32);
1941 if (mode) 1658 if (mode)
1942 *mode = (u16)mode32; 1659 *mode = (u16)mode32;
1943 return error; 1660 return err;
1944} 1661}
1945 1662
1946u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1663u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count,
1947 u32 hmi_address, u32 byte_count, u8 *pb_data) 1664 u8 *pb_data)
1948{ 1665{
1949 struct hpi_message hm; 1666 struct hpi_message hm;
1950 struct hpi_response hr; 1667 struct hpi_response hr;
1951 1668
1952 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1669 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
1953 HPI_CONTROL_SET_STATE); 1670 HPI_CONTROL_SET_STATE);
1954 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1671 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1672 return HPI_ERROR_INVALID_HANDLE;
1955 1673
1956 hm.u.cx.u.cobranet_data.byte_count = byte_count; 1674 hm.u.cx.u.cobranet_data.byte_count = byte_count;
1957 hm.u.cx.u.cobranet_data.hmi_address = hmi_address; 1675 hm.u.cx.u.cobranet_data.hmi_address = hmi_address;
@@ -1969,15 +1687,16 @@ u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1969 return hr.error; 1687 return hr.error;
1970} 1688}
1971 1689
1972u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1690u16 hpi_cobranet_hmi_read(u32 h_control, u32 hmi_address, u32 max_byte_count,
1973 u32 hmi_address, u32 max_byte_count, u32 *pbyte_count, u8 *pb_data) 1691 u32 *pbyte_count, u8 *pb_data)
1974{ 1692{
1975 struct hpi_message hm; 1693 struct hpi_message hm;
1976 struct hpi_response hr; 1694 struct hpi_response hr;
1977 1695
1978 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1696 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
1979 HPI_CONTROL_GET_STATE); 1697 HPI_CONTROL_GET_STATE);
1980 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1698 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1699 return HPI_ERROR_INVALID_HANDLE;
1981 1700
1982 hm.u.cx.u.cobranet_data.byte_count = max_byte_count; 1701 hm.u.cx.u.cobranet_data.byte_count = max_byte_count;
1983 hm.u.cx.u.cobranet_data.hmi_address = hmi_address; 1702 hm.u.cx.u.cobranet_data.hmi_address = hmi_address;
@@ -2008,16 +1727,16 @@ u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2008 return hr.error; 1727 return hr.error;
2009} 1728}
2010 1729
2011u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys, 1730u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus,
2012 u32 h_control, u32 *pstatus, u32 *preadable_size, 1731 u32 *preadable_size, u32 *pwriteable_size)
2013 u32 *pwriteable_size)
2014{ 1732{
2015 struct hpi_message hm; 1733 struct hpi_message hm;
2016 struct hpi_response hr; 1734 struct hpi_response hr;
2017 1735
2018 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1736 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
2019 HPI_CONTROL_GET_STATE); 1737 HPI_CONTROL_GET_STATE);
2020 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1738 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1739 return HPI_ERROR_INVALID_HANDLE;
2021 1740
2022 hm.u.cx.attribute = HPI_COBRANET_GET_STATUS; 1741 hm.u.cx.attribute = HPI_COBRANET_GET_STATUS;
2023 1742
@@ -2035,177 +1754,176 @@ u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys,
2035 return hr.error; 1754 return hr.error;
2036} 1755}
2037 1756
2038u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys, 1757u16 hpi_cobranet_get_ip_address(u32 h_control, u32 *pdw_ip_address)
2039 u32 h_control, u32 *pi_paddress)
2040{ 1758{
2041 u32 byte_count; 1759 u32 byte_count;
2042 u32 iP; 1760 u32 iP;
2043 u16 error; 1761 u16 err;
2044 1762
2045 error = hpi_cobranet_hmi_read(ph_subsys, h_control, 1763 err = hpi_cobranet_hmi_read(h_control,
2046 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count, 1764 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count,
2047 (u8 *)&iP); 1765 (u8 *)&iP);
2048 1766
2049 *pi_paddress = 1767 *pdw_ip_address =
2050 ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP & 1768 ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
2051 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8); 1769 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
2052 1770
2053 if (error) 1771 if (err)
2054 *pi_paddress = 0; 1772 *pdw_ip_address = 0;
2055 1773
2056 return error; 1774 return err;
2057 1775
2058} 1776}
2059 1777
2060u16 hpi_cobranet_setI_paddress(const struct hpi_hsubsys *ph_subsys, 1778u16 hpi_cobranet_set_ip_address(u32 h_control, u32 dw_ip_address)
2061 u32 h_control, u32 i_paddress)
2062{ 1779{
2063 u32 iP; 1780 u32 iP;
2064 u16 error; 1781 u16 err;
2065 1782
2066 iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) << 1783 iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
2067 8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress & 1784 0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
2068 0x000000ff) << 8); 1785 8) | ((dw_ip_address & 0x000000ff) << 8);
2069 1786
2070 error = hpi_cobranet_hmi_write(ph_subsys, h_control, 1787 err = hpi_cobranet_hmi_write(h_control,
2071 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, (u8 *)&iP); 1788 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, (u8 *)&iP);
2072 1789
2073 return error; 1790 return err;
2074 1791
2075} 1792}
2076 1793
2077u16 hpi_cobranet_get_staticI_paddress(const struct hpi_hsubsys *ph_subsys, 1794u16 hpi_cobranet_get_static_ip_address(u32 h_control, u32 *pdw_ip_address)
2078 u32 h_control, u32 *pi_paddress)
2079{ 1795{
2080 u32 byte_count; 1796 u32 byte_count;
2081 u32 iP; 1797 u32 iP;
2082 u16 error; 1798 u16 err;
2083 error = hpi_cobranet_hmi_read(ph_subsys, h_control, 1799 err = hpi_cobranet_hmi_read(h_control,
2084 HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count, 1800 HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count,
2085 (u8 *)&iP); 1801 (u8 *)&iP);
2086 1802
2087 *pi_paddress = 1803 *pdw_ip_address =
2088 ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP & 1804 ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
2089 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8); 1805 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
2090 1806
2091 if (error) 1807 if (err)
2092 *pi_paddress = 0; 1808 *pdw_ip_address = 0;
2093 1809
2094 return error; 1810 return err;
2095 1811
2096} 1812}
2097 1813
2098u16 hpi_cobranet_set_staticI_paddress(const struct hpi_hsubsys *ph_subsys, 1814u16 hpi_cobranet_set_static_ip_address(u32 h_control, u32 dw_ip_address)
2099 u32 h_control, u32 i_paddress)
2100{ 1815{
2101 u32 iP; 1816 u32 iP;
2102 u16 error; 1817 u16 err;
2103 1818
2104 iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) << 1819 iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
2105 8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress & 1820 0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
2106 0x000000ff) << 8); 1821 8) | ((dw_ip_address & 0x000000ff) << 8);
2107 1822
2108 error = hpi_cobranet_hmi_write(ph_subsys, h_control, 1823 err = hpi_cobranet_hmi_write(h_control,
2109 HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, (u8 *)&iP); 1824 HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, (u8 *)&iP);
2110 1825
2111 return error; 1826 return err;
2112 1827
2113} 1828}
2114 1829
2115u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys, 1830u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *p_mac_msbs,
2116 u32 h_control, u32 *pmAC_MS_bs, u32 *pmAC_LS_bs) 1831 u32 *p_mac_lsbs)
2117{ 1832{
2118 u32 byte_count; 1833 u32 byte_count;
2119 u16 error; 1834 u16 err;
2120 u32 mAC; 1835 u32 mac;
2121 1836
2122 error = hpi_cobranet_hmi_read(ph_subsys, h_control, 1837 err = hpi_cobranet_hmi_read(h_control,
2123 HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count, 1838 HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count,
2124 (u8 *)&mAC); 1839 (u8 *)&mac);
2125 *pmAC_MS_bs = 1840
2126 ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC 1841 if (!err) {
2127 & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8); 1842 *p_mac_msbs =
2128 error += hpi_cobranet_hmi_read(ph_subsys, h_control, 1843 ((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8)
2129 HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4, &byte_count, 1844 | ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) <<
2130 (u8 *)&mAC); 1845 8);
2131 *pmAC_LS_bs = 1846
2132 ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC 1847 err = hpi_cobranet_hmi_read(h_control,
2133 & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8); 1848 HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4,
2134 1849 &byte_count, (u8 *)&mac);
2135 if (error) {
2136 *pmAC_MS_bs = 0;
2137 *pmAC_LS_bs = 0;
2138 } 1850 }
2139 1851
2140 return error; 1852 if (!err) {
1853 *p_mac_lsbs =
1854 ((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8)
1855 | ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) <<
1856 8);
1857 } else {
1858 *p_mac_msbs = 0;
1859 *p_mac_lsbs = 0;
1860 }
1861
1862 return err;
2141} 1863}
2142 1864
2143u16 hpi_compander_set_enable(const struct hpi_hsubsys *ph_subsys, 1865u16 hpi_compander_set_enable(u32 h_control, u32 enable)
2144 u32 h_control, u32 enable)
2145{ 1866{
2146 return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 1867 return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
2147 enable, 0); 1868 0);
2148} 1869}
2149 1870
2150u16 hpi_compander_get_enable(const struct hpi_hsubsys *ph_subsys, 1871u16 hpi_compander_get_enable(u32 h_control, u32 *enable)
2151 u32 h_control, u32 *enable)
2152{ 1872{
2153 return hpi_control_param1_get(ph_subsys, h_control, 1873 return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
2154 HPI_GENERIC_ENABLE, enable);
2155} 1874}
2156 1875
2157u16 hpi_compander_set_makeup_gain(const struct hpi_hsubsys *ph_subsys, 1876u16 hpi_compander_set_makeup_gain(u32 h_control, short makeup_gain0_01dB)
2158 u32 h_control, short makeup_gain0_01dB)
2159{ 1877{
2160 return hpi_control_log_set2(h_control, HPI_COMPANDER_MAKEUPGAIN, 1878 return hpi_control_log_set2(h_control, HPI_COMPANDER_MAKEUPGAIN,
2161 makeup_gain0_01dB, 0); 1879 makeup_gain0_01dB, 0);
2162} 1880}
2163 1881
2164u16 hpi_compander_get_makeup_gain(const struct hpi_hsubsys *ph_subsys, 1882u16 hpi_compander_get_makeup_gain(u32 h_control, short *makeup_gain0_01dB)
2165 u32 h_control, short *makeup_gain0_01dB)
2166{ 1883{
2167 return hpi_control_log_get2(ph_subsys, h_control, 1884 return hpi_control_log_get2(h_control, HPI_COMPANDER_MAKEUPGAIN,
2168 HPI_COMPANDER_MAKEUPGAIN, makeup_gain0_01dB, NULL); 1885 makeup_gain0_01dB, NULL);
2169} 1886}
2170 1887
2171u16 hpi_compander_set_attack_time_constant(const struct hpi_hsubsys 1888u16 hpi_compander_set_attack_time_constant(u32 h_control, unsigned int index,
2172 *ph_subsys, u32 h_control, unsigned int index, u32 attack) 1889 u32 attack)
2173{ 1890{
2174 return hpi_control_param_set(ph_subsys, h_control, 1891 return hpi_control_param_set(h_control, HPI_COMPANDER_ATTACK, attack,
2175 HPI_COMPANDER_ATTACK, attack, index); 1892 index);
2176} 1893}
2177 1894
2178u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys 1895u16 hpi_compander_get_attack_time_constant(u32 h_control, unsigned int index,
2179 *ph_subsys, u32 h_control, unsigned int index, u32 *attack) 1896 u32 *attack)
2180{ 1897{
2181 return hpi_control_param_get(ph_subsys, h_control, 1898 return hpi_control_param_get(h_control, HPI_COMPANDER_ATTACK, 0,
2182 HPI_COMPANDER_ATTACK, 0, index, attack, NULL); 1899 index, attack, NULL);
2183} 1900}
2184 1901
2185u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys, 1902u16 hpi_compander_set_decay_time_constant(u32 h_control, unsigned int index,
2186 u32 h_control, unsigned int index, u32 decay) 1903 u32 decay)
2187{ 1904{
2188 return hpi_control_param_set(ph_subsys, h_control, 1905 return hpi_control_param_set(h_control, HPI_COMPANDER_DECAY, decay,
2189 HPI_COMPANDER_DECAY, decay, index); 1906 index);
2190} 1907}
2191 1908
2192u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys, 1909u16 hpi_compander_get_decay_time_constant(u32 h_control, unsigned int index,
2193 u32 h_control, unsigned int index, u32 *decay) 1910 u32 *decay)
2194{ 1911{
2195 return hpi_control_param_get(ph_subsys, h_control, 1912 return hpi_control_param_get(h_control, HPI_COMPANDER_DECAY, 0, index,
2196 HPI_COMPANDER_DECAY, 0, index, decay, NULL); 1913 decay, NULL);
2197 1914
2198} 1915}
2199 1916
2200u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys, 1917u16 hpi_compander_set_threshold(u32 h_control, unsigned int index,
2201 u32 h_control, unsigned int index, short threshold0_01dB) 1918 short threshold0_01dB)
2202{ 1919{
2203 struct hpi_message hm; 1920 struct hpi_message hm;
2204 struct hpi_response hr; 1921 struct hpi_response hr;
2205 1922
2206 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1923 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2207 HPI_CONTROL_SET_STATE); 1924 HPI_CONTROL_SET_STATE);
2208 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1925 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1926 return HPI_ERROR_INVALID_HANDLE;
2209 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD; 1927 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
2210 hm.u.c.param2 = index; 1928 hm.u.c.param2 = index;
2211 hm.u.c.an_log_value[0] = threshold0_01dB; 1929 hm.u.c.an_log_value[0] = threshold0_01dB;
@@ -2215,15 +1933,16 @@ u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys,
2215 return hr.error; 1933 return hr.error;
2216} 1934}
2217 1935
2218u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys, 1936u16 hpi_compander_get_threshold(u32 h_control, unsigned int index,
2219 u32 h_control, unsigned int index, short *threshold0_01dB) 1937 short *threshold0_01dB)
2220{ 1938{
2221 struct hpi_message hm; 1939 struct hpi_message hm;
2222 struct hpi_response hr; 1940 struct hpi_response hr;
2223 1941
2224 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1942 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2225 HPI_CONTROL_GET_STATE); 1943 HPI_CONTROL_GET_STATE);
2226 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1944 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1945 return HPI_ERROR_INVALID_HANDLE;
2227 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD; 1946 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
2228 hm.u.c.param2 = index; 1947 hm.u.c.param2 = index;
2229 1948
@@ -2233,29 +1952,28 @@ u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys,
2233 return hr.error; 1952 return hr.error;
2234} 1953}
2235 1954
2236u16 hpi_compander_set_ratio(const struct hpi_hsubsys *ph_subsys, 1955u16 hpi_compander_set_ratio(u32 h_control, u32 index, u32 ratio100)
2237 u32 h_control, u32 index, u32 ratio100)
2238{ 1956{
2239 return hpi_control_param_set(ph_subsys, h_control, 1957 return hpi_control_param_set(h_control, HPI_COMPANDER_RATIO, ratio100,
2240 HPI_COMPANDER_RATIO, ratio100, index); 1958 index);
2241} 1959}
2242 1960
2243u16 hpi_compander_get_ratio(const struct hpi_hsubsys *ph_subsys, 1961u16 hpi_compander_get_ratio(u32 h_control, u32 index, u32 *ratio100)
2244 u32 h_control, u32 index, u32 *ratio100)
2245{ 1962{
2246 return hpi_control_param_get(ph_subsys, h_control, 1963 return hpi_control_param_get(h_control, HPI_COMPANDER_RATIO, 0, index,
2247 HPI_COMPANDER_RATIO, 0, index, ratio100, NULL); 1964 ratio100, NULL);
2248} 1965}
2249 1966
2250u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1967u16 hpi_level_query_range(u32 h_control, short *min_gain_01dB,
2251 short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB) 1968 short *max_gain_01dB, short *step_gain_01dB)
2252{ 1969{
2253 struct hpi_message hm; 1970 struct hpi_message hm;
2254 struct hpi_response hr; 1971 struct hpi_response hr;
2255 1972
2256 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1973 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2257 HPI_CONTROL_GET_STATE); 1974 HPI_CONTROL_GET_STATE);
2258 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1975 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1976 return HPI_ERROR_INVALID_HANDLE;
2259 hm.u.c.attribute = HPI_LEVEL_RANGE; 1977 hm.u.c.attribute = HPI_LEVEL_RANGE;
2260 1978
2261 hpi_send_recv(&hm, &hr); 1979 hpi_send_recv(&hm, &hr);
@@ -2273,31 +1991,27 @@ u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2273 return hr.error; 1991 return hr.error;
2274} 1992}
2275 1993
2276u16 hpi_level_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1994u16 hpi_level_set_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
2277 short an_gain0_01dB[HPI_MAX_CHANNELS]
2278 ) 1995 )
2279{ 1996{
2280 return hpi_control_log_set2(h_control, HPI_LEVEL_GAIN, 1997 return hpi_control_log_set2(h_control, HPI_LEVEL_GAIN,
2281 an_gain0_01dB[0], an_gain0_01dB[1]); 1998 an_gain0_01dB[0], an_gain0_01dB[1]);
2282} 1999}
2283 2000
2284u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2001u16 hpi_level_get_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
2285 short an_gain0_01dB[HPI_MAX_CHANNELS]
2286 ) 2002 )
2287{ 2003{
2288 return hpi_control_log_get2(ph_subsys, h_control, HPI_LEVEL_GAIN, 2004 return hpi_control_log_get2(h_control, HPI_LEVEL_GAIN,
2289 &an_gain0_01dB[0], &an_gain0_01dB[1]); 2005 &an_gain0_01dB[0], &an_gain0_01dB[1]);
2290} 2006}
2291 2007
2292u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys, 2008u16 hpi_meter_query_channels(const u32 h_meter, u32 *p_channels)
2293 const u32 h_meter, u32 *p_channels)
2294{ 2009{
2295 return hpi_control_query(ph_subsys, h_meter, HPI_METER_NUM_CHANNELS, 2010 return hpi_control_query(h_meter, HPI_METER_NUM_CHANNELS, 0, 0,
2296 0, 0, p_channels); 2011 p_channels);
2297} 2012}
2298 2013
2299u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2014u16 hpi_meter_get_peak(u32 h_control, short an_peakdB[HPI_MAX_CHANNELS]
2300 short an_peakdB[HPI_MAX_CHANNELS]
2301 ) 2015 )
2302{ 2016{
2303 short i = 0; 2017 short i = 0;
@@ -2307,7 +2021,8 @@ u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2307 2021
2308 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2022 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2309 HPI_CONTROL_GET_STATE); 2023 HPI_CONTROL_GET_STATE);
2310 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2024 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2025 return HPI_ERROR_INVALID_HANDLE;
2311 hm.obj_index = hm.obj_index; 2026 hm.obj_index = hm.obj_index;
2312 hm.u.c.attribute = HPI_METER_PEAK; 2027 hm.u.c.attribute = HPI_METER_PEAK;
2313 2028
@@ -2322,8 +2037,7 @@ u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2322 return hr.error; 2037 return hr.error;
2323} 2038}
2324 2039
2325u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2040u16 hpi_meter_get_rms(u32 h_control, short an_rmsdB[HPI_MAX_CHANNELS]
2326 short an_rmsdB[HPI_MAX_CHANNELS]
2327 ) 2041 )
2328{ 2042{
2329 short i = 0; 2043 short i = 0;
@@ -2333,7 +2047,8 @@ u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2333 2047
2334 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2048 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2335 HPI_CONTROL_GET_STATE); 2049 HPI_CONTROL_GET_STATE);
2336 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2050 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2051 return HPI_ERROR_INVALID_HANDLE;
2337 hm.u.c.attribute = HPI_METER_RMS; 2052 hm.u.c.attribute = HPI_METER_RMS;
2338 2053
2339 hpi_send_recv(&hm, &hr); 2054 hpi_send_recv(&hm, &hr);
@@ -2348,22 +2063,20 @@ u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2348 return hr.error; 2063 return hr.error;
2349} 2064}
2350 2065
2351u16 hpi_meter_set_rms_ballistics(const struct hpi_hsubsys *ph_subsys, 2066u16 hpi_meter_set_rms_ballistics(u32 h_control, u16 attack, u16 decay)
2352 u32 h_control, u16 attack, u16 decay)
2353{ 2067{
2354 return hpi_control_param_set(ph_subsys, h_control, 2068 return hpi_control_param_set(h_control, HPI_METER_RMS_BALLISTICS,
2355 HPI_METER_RMS_BALLISTICS, attack, decay); 2069 attack, decay);
2356} 2070}
2357 2071
2358u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys, 2072u16 hpi_meter_get_rms_ballistics(u32 h_control, u16 *pn_attack, u16 *pn_decay)
2359 u32 h_control, u16 *pn_attack, u16 *pn_decay)
2360{ 2073{
2361 u32 attack; 2074 u32 attack;
2362 u32 decay; 2075 u32 decay;
2363 u16 error; 2076 u16 error;
2364 2077
2365 error = hpi_control_param2_get(ph_subsys, h_control, 2078 error = hpi_control_param2_get(h_control, HPI_METER_RMS_BALLISTICS,
2366 HPI_METER_RMS_BALLISTICS, &attack, &decay); 2079 &attack, &decay);
2367 2080
2368 if (pn_attack) 2081 if (pn_attack)
2369 *pn_attack = (unsigned short)attack; 2082 *pn_attack = (unsigned short)attack;
@@ -2373,22 +2086,21 @@ u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys,
2373 return error; 2086 return error;
2374} 2087}
2375 2088
2376u16 hpi_meter_set_peak_ballistics(const struct hpi_hsubsys *ph_subsys, 2089u16 hpi_meter_set_peak_ballistics(u32 h_control, u16 attack, u16 decay)
2377 u32 h_control, u16 attack, u16 decay)
2378{ 2090{
2379 return hpi_control_param_set(ph_subsys, h_control, 2091 return hpi_control_param_set(h_control, HPI_METER_PEAK_BALLISTICS,
2380 HPI_METER_PEAK_BALLISTICS, attack, decay); 2092 attack, decay);
2381} 2093}
2382 2094
2383u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys, 2095u16 hpi_meter_get_peak_ballistics(u32 h_control, u16 *pn_attack,
2384 u32 h_control, u16 *pn_attack, u16 *pn_decay) 2096 u16 *pn_decay)
2385{ 2097{
2386 u32 attack; 2098 u32 attack;
2387 u32 decay; 2099 u32 decay;
2388 u16 error; 2100 u16 error;
2389 2101
2390 error = hpi_control_param2_get(ph_subsys, h_control, 2102 error = hpi_control_param2_get(h_control, HPI_METER_PEAK_BALLISTICS,
2391 HPI_METER_PEAK_BALLISTICS, &attack, &decay); 2103 &attack, &decay);
2392 2104
2393 if (pn_attack) 2105 if (pn_attack)
2394 *pn_attack = (short)attack; 2106 *pn_attack = (short)attack;
@@ -2398,55 +2110,53 @@ u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys,
2398 return error; 2110 return error;
2399} 2111}
2400 2112
2401u16 hpi_microphone_set_phantom_power(const struct hpi_hsubsys *ph_subsys, 2113u16 hpi_microphone_set_phantom_power(u32 h_control, u16 on_off)
2402 u32 h_control, u16 on_off)
2403{ 2114{
2404 return hpi_control_param_set(ph_subsys, h_control, 2115 return hpi_control_param_set(h_control, HPI_MICROPHONE_PHANTOM_POWER,
2405 HPI_MICROPHONE_PHANTOM_POWER, (u32)on_off, 0); 2116 (u32)on_off, 0);
2406} 2117}
2407 2118
2408u16 hpi_microphone_get_phantom_power(const struct hpi_hsubsys *ph_subsys, 2119u16 hpi_microphone_get_phantom_power(u32 h_control, u16 *pw_on_off)
2409 u32 h_control, u16 *pw_on_off)
2410{ 2120{
2411 u16 error = 0; 2121 u16 error = 0;
2412 u32 on_off = 0; 2122 u32 on_off = 0;
2413 error = hpi_control_param1_get(ph_subsys, h_control, 2123 error = hpi_control_param1_get(h_control,
2414 HPI_MICROPHONE_PHANTOM_POWER, &on_off); 2124 HPI_MICROPHONE_PHANTOM_POWER, &on_off);
2415 if (pw_on_off) 2125 if (pw_on_off)
2416 *pw_on_off = (u16)on_off; 2126 *pw_on_off = (u16)on_off;
2417 return error; 2127 return error;
2418} 2128}
2419 2129
2420u16 hpi_multiplexer_set_source(const struct hpi_hsubsys *ph_subsys, 2130u16 hpi_multiplexer_set_source(u32 h_control, u16 source_node_type,
2421 u32 h_control, u16 source_node_type, u16 source_node_index) 2131 u16 source_node_index)
2422{ 2132{
2423 return hpi_control_param_set(ph_subsys, h_control, 2133 return hpi_control_param_set(h_control, HPI_MULTIPLEXER_SOURCE,
2424 HPI_MULTIPLEXER_SOURCE, source_node_type, source_node_index); 2134 source_node_type, source_node_index);
2425} 2135}
2426 2136
2427u16 hpi_multiplexer_get_source(const struct hpi_hsubsys *ph_subsys, 2137u16 hpi_multiplexer_get_source(u32 h_control, u16 *source_node_type,
2428 u32 h_control, u16 *source_node_type, u16 *source_node_index) 2138 u16 *source_node_index)
2429{ 2139{
2430 u32 node, index; 2140 u32 node, index;
2431 u16 error = hpi_control_param2_get(ph_subsys, h_control, 2141 u16 err = hpi_control_param2_get(h_control,
2432 HPI_MULTIPLEXER_SOURCE, &node, 2142 HPI_MULTIPLEXER_SOURCE, &node,
2433 &index); 2143 &index);
2434 if (source_node_type) 2144 if (source_node_type)
2435 *source_node_type = (u16)node; 2145 *source_node_type = (u16)node;
2436 if (source_node_index) 2146 if (source_node_index)
2437 *source_node_index = (u16)index; 2147 *source_node_index = (u16)index;
2438 return error; 2148 return err;
2439} 2149}
2440 2150
2441u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys, 2151u16 hpi_multiplexer_query_source(u32 h_control, u16 index,
2442 u32 h_control, u16 index, u16 *source_node_type, 2152 u16 *source_node_type, u16 *source_node_index)
2443 u16 *source_node_index)
2444{ 2153{
2445 struct hpi_message hm; 2154 struct hpi_message hm;
2446 struct hpi_response hr; 2155 struct hpi_response hr;
2447 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2156 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2448 HPI_CONTROL_GET_STATE); 2157 HPI_CONTROL_GET_STATE);
2449 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2158 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2159 return HPI_ERROR_INVALID_HANDLE;
2450 hm.u.c.attribute = HPI_MULTIPLEXER_QUERYSOURCE; 2160 hm.u.c.attribute = HPI_MULTIPLEXER_QUERYSOURCE;
2451 hm.u.c.param1 = index; 2161 hm.u.c.param1 = index;
2452 2162
@@ -2459,15 +2169,15 @@ u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys,
2459 return hr.error; 2169 return hr.error;
2460} 2170}
2461 2171
2462u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys, 2172u16 hpi_parametric_eq_get_info(u32 h_control, u16 *pw_number_of_bands,
2463 u32 h_control, u16 *pw_number_of_bands, u16 *pw_on_off) 2173 u16 *pw_on_off)
2464{ 2174{
2465 u32 oB = 0; 2175 u32 oB = 0;
2466 u32 oO = 0; 2176 u32 oO = 0;
2467 u16 error = 0; 2177 u16 error = 0;
2468 2178
2469 error = hpi_control_param2_get(ph_subsys, h_control, 2179 error = hpi_control_param2_get(h_control, HPI_EQUALIZER_NUM_FILTERS,
2470 HPI_EQUALIZER_NUM_FILTERS, &oO, &oB); 2180 &oO, &oB);
2471 if (pw_number_of_bands) 2181 if (pw_number_of_bands)
2472 *pw_number_of_bands = (u16)oB; 2182 *pw_number_of_bands = (u16)oB;
2473 if (pw_on_off) 2183 if (pw_on_off)
@@ -2475,23 +2185,22 @@ u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys,
2475 return error; 2185 return error;
2476} 2186}
2477 2187
2478u16 hpi_parametricEQ__set_state(const struct hpi_hsubsys *ph_subsys, 2188u16 hpi_parametric_eq_set_state(u32 h_control, u16 on_off)
2479 u32 h_control, u16 on_off)
2480{ 2189{
2481 return hpi_control_param_set(ph_subsys, h_control, 2190 return hpi_control_param_set(h_control, HPI_EQUALIZER_NUM_FILTERS,
2482 HPI_EQUALIZER_NUM_FILTERS, on_off, 0); 2191 on_off, 0);
2483} 2192}
2484 2193
2485u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys, 2194u16 hpi_parametric_eq_get_band(u32 h_control, u16 index, u16 *pn_type,
2486 u32 h_control, u16 index, u16 *pn_type, u32 *pfrequency_hz, 2195 u32 *pfrequency_hz, short *pnQ100, short *pn_gain0_01dB)
2487 short *pnQ100, short *pn_gain0_01dB)
2488{ 2196{
2489 struct hpi_message hm; 2197 struct hpi_message hm;
2490 struct hpi_response hr; 2198 struct hpi_response hr;
2491 2199
2492 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2200 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2493 HPI_CONTROL_GET_STATE); 2201 HPI_CONTROL_GET_STATE);
2494 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2202 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2203 return HPI_ERROR_INVALID_HANDLE;
2495 hm.u.c.attribute = HPI_EQUALIZER_FILTER; 2204 hm.u.c.attribute = HPI_EQUALIZER_FILTER;
2496 hm.u.c.param2 = index; 2205 hm.u.c.param2 = index;
2497 2206
@@ -2509,16 +2218,16 @@ u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys,
2509 return hr.error; 2218 return hr.error;
2510} 2219}
2511 2220
2512u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys, 2221u16 hpi_parametric_eq_set_band(u32 h_control, u16 index, u16 type,
2513 u32 h_control, u16 index, u16 type, u32 frequency_hz, short q100, 2222 u32 frequency_hz, short q100, short gain0_01dB)
2514 short gain0_01dB)
2515{ 2223{
2516 struct hpi_message hm; 2224 struct hpi_message hm;
2517 struct hpi_response hr; 2225 struct hpi_response hr;
2518 2226
2519 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2227 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2520 HPI_CONTROL_SET_STATE); 2228 HPI_CONTROL_SET_STATE);
2521 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2229 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2230 return HPI_ERROR_INVALID_HANDLE;
2522 2231
2523 hm.u.c.param1 = frequency_hz; 2232 hm.u.c.param1 = frequency_hz;
2524 hm.u.c.param2 = (index & 0xFFFFL) + ((u32)type << 16); 2233 hm.u.c.param2 = (index & 0xFFFFL) + ((u32)type << 16);
@@ -2531,8 +2240,7 @@ u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys,
2531 return hr.error; 2240 return hr.error;
2532} 2241}
2533 2242
2534u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys, 2243u16 hpi_parametric_eq_get_coeffs(u32 h_control, u16 index, short coeffs[5]
2535 u32 h_control, u16 index, short coeffs[5]
2536 ) 2244 )
2537{ 2245{
2538 struct hpi_message hm; 2246 struct hpi_message hm;
@@ -2540,7 +2248,8 @@ u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys,
2540 2248
2541 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2249 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2542 HPI_CONTROL_GET_STATE); 2250 HPI_CONTROL_GET_STATE);
2543 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2251 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2252 return HPI_ERROR_INVALID_HANDLE;
2544 hm.u.c.attribute = HPI_EQUALIZER_COEFFICIENTS; 2253 hm.u.c.attribute = HPI_EQUALIZER_COEFFICIENTS;
2545 hm.u.c.param2 = index; 2254 hm.u.c.param2 = index;
2546 2255
@@ -2555,444 +2264,388 @@ u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys,
2555 return hr.error; 2264 return hr.error;
2556} 2265}
2557 2266
2558u16 hpi_sample_clock_query_source(const struct hpi_hsubsys *ph_subsys, 2267u16 hpi_sample_clock_query_source(const u32 h_clock, const u32 index,
2559 const u32 h_clock, const u32 index, u16 *pw_source) 2268 u16 *pw_source)
2560{ 2269{
2561 u32 qr; 2270 u32 qr;
2562 u16 err; 2271 u16 err;
2563 2272
2564 err = hpi_control_query(ph_subsys, h_clock, HPI_SAMPLECLOCK_SOURCE, 2273 err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE, index, 0,
2565 index, 0, &qr); 2274 &qr);
2566 *pw_source = (u16)qr; 2275 *pw_source = (u16)qr;
2567 return err; 2276 return err;
2568} 2277}
2569 2278
2570u16 hpi_sample_clock_set_source(const struct hpi_hsubsys *ph_subsys, 2279u16 hpi_sample_clock_set_source(u32 h_control, u16 source)
2571 u32 h_control, u16 source)
2572{ 2280{
2573 return hpi_control_param_set(ph_subsys, h_control, 2281 return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE,
2574 HPI_SAMPLECLOCK_SOURCE, source, 0); 2282 source, 0);
2575} 2283}
2576 2284
2577u16 hpi_sample_clock_get_source(const struct hpi_hsubsys *ph_subsys, 2285u16 hpi_sample_clock_get_source(u32 h_control, u16 *pw_source)
2578 u32 h_control, u16 *pw_source)
2579{ 2286{
2580 u16 error = 0; 2287 u16 err = 0;
2581 u32 source = 0; 2288 u32 source = 0;
2582 error = hpi_control_param1_get(ph_subsys, h_control, 2289 err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE,
2583 HPI_SAMPLECLOCK_SOURCE, &source); 2290 &source);
2584 if (!error) 2291 if (!err)
2585 if (pw_source) 2292 if (pw_source)
2586 *pw_source = (u16)source; 2293 *pw_source = (u16)source;
2587 return error; 2294 return err;
2588} 2295}
2589 2296
2590u16 hpi_sample_clock_query_source_index(const struct hpi_hsubsys *ph_subsys, 2297u16 hpi_sample_clock_query_source_index(const u32 h_clock, const u32 index,
2591 const u32 h_clock, const u32 index, const u32 source, 2298 const u32 source, u16 *pw_source_index)
2592 u16 *pw_source_index)
2593{ 2299{
2594 u32 qr; 2300 u32 qr;
2595 u16 err; 2301 u16 err;
2596 2302
2597 err = hpi_control_query(ph_subsys, h_clock, 2303 err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE_INDEX, index,
2598 HPI_SAMPLECLOCK_SOURCE_INDEX, index, source, &qr); 2304 source, &qr);
2599 *pw_source_index = (u16)qr; 2305 *pw_source_index = (u16)qr;
2600 return err; 2306 return err;
2601} 2307}
2602 2308
2603u16 hpi_sample_clock_set_source_index(const struct hpi_hsubsys *ph_subsys, 2309u16 hpi_sample_clock_set_source_index(u32 h_control, u16 source_index)
2604 u32 h_control, u16 source_index)
2605{ 2310{
2606 return hpi_control_param_set(ph_subsys, h_control, 2311 return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
2607 HPI_SAMPLECLOCK_SOURCE_INDEX, source_index, 0); 2312 source_index, 0);
2608} 2313}
2609 2314
2610u16 hpi_sample_clock_get_source_index(const struct hpi_hsubsys *ph_subsys, 2315u16 hpi_sample_clock_get_source_index(u32 h_control, u16 *pw_source_index)
2611 u32 h_control, u16 *pw_source_index)
2612{ 2316{
2613 u16 error = 0; 2317 u16 err = 0;
2614 u32 source_index = 0; 2318 u32 source_index = 0;
2615 error = hpi_control_param1_get(ph_subsys, h_control, 2319 err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
2616 HPI_SAMPLECLOCK_SOURCE_INDEX, &source_index); 2320 &source_index);
2617 if (!error) 2321 if (!err)
2618 if (pw_source_index) 2322 if (pw_source_index)
2619 *pw_source_index = (u16)source_index; 2323 *pw_source_index = (u16)source_index;
2620 return error; 2324 return err;
2621} 2325}
2622 2326
2623u16 hpi_sample_clock_query_local_rate(const struct hpi_hsubsys *ph_subsys, 2327u16 hpi_sample_clock_query_local_rate(const u32 h_clock, const u32 index,
2624 const u32 h_clock, const u32 index, u32 *prate) 2328 u32 *prate)
2625{ 2329{
2626 u16 err; 2330 u16 err;
2627 err = hpi_control_query(ph_subsys, h_clock, 2331 err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_LOCAL_SAMPLERATE,
2628 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, index, 0, prate); 2332 index, 0, prate);
2629 2333
2630 return err; 2334 return err;
2631} 2335}
2632 2336
2633u16 hpi_sample_clock_set_local_rate(const struct hpi_hsubsys *ph_subsys, 2337u16 hpi_sample_clock_set_local_rate(u32 h_control, u32 sample_rate)
2634 u32 h_control, u32 sample_rate)
2635{ 2338{
2636 return hpi_control_param_set(ph_subsys, h_control, 2339 return hpi_control_param_set(h_control,
2637 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, sample_rate, 0); 2340 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, sample_rate, 0);
2638} 2341}
2639 2342
2640u16 hpi_sample_clock_get_local_rate(const struct hpi_hsubsys *ph_subsys, 2343u16 hpi_sample_clock_get_local_rate(u32 h_control, u32 *psample_rate)
2641 u32 h_control, u32 *psample_rate)
2642{ 2344{
2643 u16 error = 0; 2345 u16 err = 0;
2644 u32 sample_rate = 0; 2346 u32 sample_rate = 0;
2645 error = hpi_control_param1_get(ph_subsys, h_control, 2347 err = hpi_control_param1_get(h_control,
2646 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate); 2348 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate);
2647 if (!error) 2349 if (!err)
2648 if (psample_rate) 2350 if (psample_rate)
2649 *psample_rate = sample_rate; 2351 *psample_rate = sample_rate;
2650 return error; 2352 return err;
2651} 2353}
2652 2354
2653u16 hpi_sample_clock_get_sample_rate(const struct hpi_hsubsys *ph_subsys, 2355u16 hpi_sample_clock_get_sample_rate(u32 h_control, u32 *psample_rate)
2654 u32 h_control, u32 *psample_rate)
2655{ 2356{
2656 u16 error = 0; 2357 u16 err = 0;
2657 u32 sample_rate = 0; 2358 u32 sample_rate = 0;
2658 error = hpi_control_param1_get(ph_subsys, h_control, 2359 err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SAMPLERATE,
2659 HPI_SAMPLECLOCK_SAMPLERATE, &sample_rate); 2360 &sample_rate);
2660 if (!error) 2361 if (!err)
2661 if (psample_rate) 2362 if (psample_rate)
2662 *psample_rate = sample_rate; 2363 *psample_rate = sample_rate;
2663 return error; 2364 return err;
2664} 2365}
2665 2366
2666u16 hpi_sample_clock_set_auto(const struct hpi_hsubsys *ph_subsys, 2367u16 hpi_sample_clock_set_auto(u32 h_control, u32 enable)
2667 u32 h_control, u32 enable)
2668{ 2368{
2669 return hpi_control_param_set(ph_subsys, h_control, 2369 return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_AUTO, enable,
2670 HPI_SAMPLECLOCK_AUTO, enable, 0); 2370 0);
2671} 2371}
2672 2372
2673u16 hpi_sample_clock_get_auto(const struct hpi_hsubsys *ph_subsys, 2373u16 hpi_sample_clock_get_auto(u32 h_control, u32 *penable)
2674 u32 h_control, u32 *penable)
2675{ 2374{
2676 return hpi_control_param1_get(ph_subsys, h_control, 2375 return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_AUTO,
2677 HPI_SAMPLECLOCK_AUTO, penable); 2376 penable);
2678} 2377}
2679 2378
2680u16 hpi_sample_clock_set_local_rate_lock(const struct hpi_hsubsys *ph_subsys, 2379u16 hpi_sample_clock_set_local_rate_lock(u32 h_control, u32 lock)
2681 u32 h_control, u32 lock)
2682{ 2380{
2683 return hpi_control_param_set(ph_subsys, h_control, 2381 return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
2684 HPI_SAMPLECLOCK_LOCAL_LOCK, lock, 0); 2382 lock, 0);
2685} 2383}
2686 2384
2687u16 hpi_sample_clock_get_local_rate_lock(const struct hpi_hsubsys *ph_subsys, 2385u16 hpi_sample_clock_get_local_rate_lock(u32 h_control, u32 *plock)
2688 u32 h_control, u32 *plock)
2689{ 2386{
2690 return hpi_control_param1_get(ph_subsys, h_control, 2387 return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
2691 HPI_SAMPLECLOCK_LOCAL_LOCK, plock); 2388 plock);
2692} 2389}
2693 2390
2694u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys, 2391u16 hpi_tone_detector_get_frequency(u32 h_control, u32 index, u32 *frequency)
2695 u32 h_control, u32 index, u32 *frequency)
2696{ 2392{
2697 return hpi_control_param_get(ph_subsys, h_control, 2393 return hpi_control_param_get(h_control, HPI_TONEDETECTOR_FREQUENCY,
2698 HPI_TONEDETECTOR_FREQUENCY, index, 0, frequency, NULL); 2394 index, 0, frequency, NULL);
2699} 2395}
2700 2396
2701u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys, 2397u16 hpi_tone_detector_get_state(u32 h_control, u32 *state)
2702 u32 h_control, u32 *state)
2703{ 2398{
2704 return hpi_control_param1_get(ph_subsys, h_control, 2399 return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_STATE,
2705 HPI_TONEDETECTOR_STATE, state); 2400 state);
2706} 2401}
2707 2402
2708u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys, 2403u16 hpi_tone_detector_set_enable(u32 h_control, u32 enable)
2709 u32 h_control, u32 enable)
2710{ 2404{
2711 return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2405 return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
2712 (u32)enable, 0); 2406 0);
2713} 2407}
2714 2408
2715u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 2409u16 hpi_tone_detector_get_enable(u32 h_control, u32 *enable)
2716 u32 h_control, u32 *enable)
2717{ 2410{
2718 return hpi_control_param1_get(ph_subsys, h_control, 2411 return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
2719 HPI_GENERIC_ENABLE, enable);
2720} 2412}
2721 2413
2722u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, 2414u16 hpi_tone_detector_set_event_enable(u32 h_control, u32 event_enable)
2723 u32 h_control, u32 event_enable)
2724{ 2415{
2725 return hpi_control_param_set(ph_subsys, h_control, 2416 return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
2726 HPI_GENERIC_EVENT_ENABLE, (u32)event_enable, 0); 2417 (u32)event_enable, 0);
2727} 2418}
2728 2419
2729u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, 2420u16 hpi_tone_detector_get_event_enable(u32 h_control, u32 *event_enable)
2730 u32 h_control, u32 *event_enable)
2731{ 2421{
2732 return hpi_control_param1_get(ph_subsys, h_control, 2422 return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
2733 HPI_GENERIC_EVENT_ENABLE, event_enable); 2423 event_enable);
2734} 2424}
2735 2425
2736u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, 2426u16 hpi_tone_detector_set_threshold(u32 h_control, int threshold)
2737 u32 h_control, int threshold)
2738{ 2427{
2739 return hpi_control_param_set(ph_subsys, h_control, 2428 return hpi_control_param_set(h_control, HPI_TONEDETECTOR_THRESHOLD,
2740 HPI_TONEDETECTOR_THRESHOLD, (u32)threshold, 0); 2429 (u32)threshold, 0);
2741} 2430}
2742 2431
2743u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, 2432u16 hpi_tone_detector_get_threshold(u32 h_control, int *threshold)
2744 u32 h_control, int *threshold)
2745{ 2433{
2746 return hpi_control_param1_get(ph_subsys, h_control, 2434 return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_THRESHOLD,
2747 HPI_TONEDETECTOR_THRESHOLD, (u32 *)threshold); 2435 (u32 *)threshold);
2748} 2436}
2749 2437
2750u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys, 2438u16 hpi_silence_detector_get_state(u32 h_control, u32 *state)
2751 u32 h_control, u32 *state)
2752{ 2439{
2753 return hpi_control_param1_get(ph_subsys, h_control, 2440 return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_STATE,
2754 HPI_SILENCEDETECTOR_STATE, state); 2441 state);
2755} 2442}
2756 2443
2757u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys, 2444u16 hpi_silence_detector_set_enable(u32 h_control, u32 enable)
2758 u32 h_control, u32 enable)
2759{ 2445{
2760 return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2446 return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
2761 (u32)enable, 0); 2447 0);
2762} 2448}
2763 2449
2764u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 2450u16 hpi_silence_detector_get_enable(u32 h_control, u32 *enable)
2765 u32 h_control, u32 *enable)
2766{ 2451{
2767 return hpi_control_param1_get(ph_subsys, h_control, 2452 return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
2768 HPI_GENERIC_ENABLE, enable);
2769} 2453}
2770 2454
2771u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, 2455u16 hpi_silence_detector_set_event_enable(u32 h_control, u32 event_enable)
2772 u32 h_control, u32 event_enable)
2773{ 2456{
2774 return hpi_control_param_set(ph_subsys, h_control, 2457 return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
2775 HPI_GENERIC_EVENT_ENABLE, event_enable, 0); 2458 event_enable, 0);
2776} 2459}
2777 2460
2778u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, 2461u16 hpi_silence_detector_get_event_enable(u32 h_control, u32 *event_enable)
2779 u32 h_control, u32 *event_enable)
2780{ 2462{
2781 return hpi_control_param1_get(ph_subsys, h_control, 2463 return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
2782 HPI_GENERIC_EVENT_ENABLE, event_enable); 2464 event_enable);
2783} 2465}
2784 2466
2785u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys, 2467u16 hpi_silence_detector_set_delay(u32 h_control, u32 delay)
2786 u32 h_control, u32 delay)
2787{ 2468{
2788 return hpi_control_param_set(ph_subsys, h_control, 2469 return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_DELAY,
2789 HPI_SILENCEDETECTOR_DELAY, delay, 0); 2470 delay, 0);
2790} 2471}
2791 2472
2792u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys, 2473u16 hpi_silence_detector_get_delay(u32 h_control, u32 *delay)
2793 u32 h_control, u32 *delay)
2794{ 2474{
2795 return hpi_control_param1_get(ph_subsys, h_control, 2475 return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_DELAY,
2796 HPI_SILENCEDETECTOR_DELAY, delay); 2476 delay);
2797} 2477}
2798 2478
2799u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, 2479u16 hpi_silence_detector_set_threshold(u32 h_control, int threshold)
2800 u32 h_control, int threshold)
2801{ 2480{
2802 return hpi_control_param_set(ph_subsys, h_control, 2481 return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_THRESHOLD,
2803 HPI_SILENCEDETECTOR_THRESHOLD, threshold, 0); 2482 threshold, 0);
2804} 2483}
2805 2484
2806u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, 2485u16 hpi_silence_detector_get_threshold(u32 h_control, int *threshold)
2807 u32 h_control, int *threshold)
2808{ 2486{
2809 return hpi_control_param1_get(ph_subsys, h_control, 2487 return hpi_control_param1_get(h_control,
2810 HPI_SILENCEDETECTOR_THRESHOLD, (u32 *)threshold); 2488 HPI_SILENCEDETECTOR_THRESHOLD, (u32 *)threshold);
2811} 2489}
2812 2490
2813u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys, 2491u16 hpi_tuner_query_band(const u32 h_tuner, const u32 index, u16 *pw_band)
2814 const u32 h_tuner, const u32 index, u16 *pw_band)
2815{ 2492{
2816 u32 qr; 2493 u32 qr;
2817 u16 err; 2494 u16 err;
2818 2495
2819 err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0, 2496 err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
2820 &qr);
2821 *pw_band = (u16)qr; 2497 *pw_band = (u16)qr;
2822 return err; 2498 return err;
2823} 2499}
2824 2500
2825u16 hpi_tuner_set_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2501u16 hpi_tuner_set_band(u32 h_control, u16 band)
2826 u16 band)
2827{ 2502{
2828 return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_BAND, 2503 return hpi_control_param_set(h_control, HPI_TUNER_BAND, band, 0);
2829 band, 0);
2830} 2504}
2831 2505
2832u16 hpi_tuner_get_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2506u16 hpi_tuner_get_band(u32 h_control, u16 *pw_band)
2833 u16 *pw_band)
2834{ 2507{
2835 u32 band = 0; 2508 u32 band = 0;
2836 u16 error = 0; 2509 u16 error = 0;
2837 2510
2838 error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_BAND, 2511 error = hpi_control_param1_get(h_control, HPI_TUNER_BAND, &band);
2839 &band);
2840 if (pw_band) 2512 if (pw_band)
2841 *pw_band = (u16)band; 2513 *pw_band = (u16)band;
2842 return error; 2514 return error;
2843} 2515}
2844 2516
2845u16 hpi_tuner_query_frequency(const struct hpi_hsubsys *ph_subsys, 2517u16 hpi_tuner_query_frequency(const u32 h_tuner, const u32 index,
2846 const u32 h_tuner, const u32 index, const u16 band, u32 *pfreq) 2518 const u16 band, u32 *pfreq)
2847{ 2519{
2848 return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_FREQ, index, 2520 return hpi_control_query(h_tuner, HPI_TUNER_FREQ, index, band, pfreq);
2849 band, pfreq);
2850} 2521}
2851 2522
2852u16 hpi_tuner_set_frequency(const struct hpi_hsubsys *ph_subsys, 2523u16 hpi_tuner_set_frequency(u32 h_control, u32 freq_ink_hz)
2853 u32 h_control, u32 freq_ink_hz)
2854{ 2524{
2855 return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_FREQ, 2525 return hpi_control_param_set(h_control, HPI_TUNER_FREQ, freq_ink_hz,
2856 freq_ink_hz, 0); 2526 0);
2857} 2527}
2858 2528
2859u16 hpi_tuner_get_frequency(const struct hpi_hsubsys *ph_subsys, 2529u16 hpi_tuner_get_frequency(u32 h_control, u32 *pw_freq_ink_hz)
2860 u32 h_control, u32 *pw_freq_ink_hz)
2861{ 2530{
2862 return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_FREQ, 2531 return hpi_control_param1_get(h_control, HPI_TUNER_FREQ,
2863 pw_freq_ink_hz); 2532 pw_freq_ink_hz);
2864} 2533}
2865 2534
2866u16 hpi_tuner_query_gain(const struct hpi_hsubsys *ph_subsys, 2535u16 hpi_tuner_query_gain(const u32 h_tuner, const u32 index, u16 *pw_gain)
2867 const u32 h_tuner, const u32 index, u16 *pw_gain)
2868{ 2536{
2869 u32 qr; 2537 u32 qr;
2870 u16 err; 2538 u16 err;
2871 2539
2872 err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0, 2540 err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
2873 &qr);
2874 *pw_gain = (u16)qr; 2541 *pw_gain = (u16)qr;
2875 return err; 2542 return err;
2876} 2543}
2877 2544
2878u16 hpi_tuner_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2545u16 hpi_tuner_set_gain(u32 h_control, short gain)
2879 short gain)
2880{ 2546{
2881 return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_GAIN, 2547 return hpi_control_param_set(h_control, HPI_TUNER_GAIN, gain, 0);
2882 gain, 0);
2883} 2548}
2884 2549
2885u16 hpi_tuner_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2550u16 hpi_tuner_get_gain(u32 h_control, short *pn_gain)
2886 short *pn_gain)
2887{ 2551{
2888 u32 gain = 0; 2552 u32 gain = 0;
2889 u16 error = 0; 2553 u16 error = 0;
2890 2554
2891 error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_GAIN, 2555 error = hpi_control_param1_get(h_control, HPI_TUNER_GAIN, &gain);
2892 &gain);
2893 if (pn_gain) 2556 if (pn_gain)
2894 *pn_gain = (u16)gain; 2557 *pn_gain = (u16)gain;
2895 return error; 2558 return error;
2896} 2559}
2897 2560
2898u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2561u16 hpi_tuner_get_rf_level(u32 h_control, short *pw_level)
2899 short *pw_level)
2900{ 2562{
2901 struct hpi_message hm; 2563 struct hpi_message hm;
2902 struct hpi_response hr; 2564 struct hpi_response hr;
2903 2565
2904 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2566 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2905 HPI_CONTROL_GET_STATE); 2567 HPI_CONTROL_GET_STATE);
2906 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2568 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2907 hm.u.c.attribute = HPI_TUNER_LEVEL; 2569 return HPI_ERROR_INVALID_HANDLE;
2908 hm.u.c.param1 = HPI_TUNER_LEVEL_AVERAGE; 2570 hm.u.cu.attribute = HPI_TUNER_LEVEL_AVG;
2909 hpi_send_recv(&hm, &hr); 2571 hpi_send_recv(&hm, &hr);
2910 if (pw_level) 2572 if (pw_level)
2911 *pw_level = (short)hr.u.c.param1; 2573 *pw_level = hr.u.cu.tuner.s_level;
2912 return hr.error; 2574 return hr.error;
2913} 2575}
2914 2576
2915u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys, 2577u16 hpi_tuner_get_raw_rf_level(u32 h_control, short *pw_level)
2916 u32 h_control, short *pw_level)
2917{ 2578{
2918 struct hpi_message hm; 2579 struct hpi_message hm;
2919 struct hpi_response hr; 2580 struct hpi_response hr;
2920 2581
2921 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2582 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2922 HPI_CONTROL_GET_STATE); 2583 HPI_CONTROL_GET_STATE);
2923 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2584 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2924 hm.u.c.attribute = HPI_TUNER_LEVEL; 2585 return HPI_ERROR_INVALID_HANDLE;
2925 hm.u.c.param1 = HPI_TUNER_LEVEL_RAW; 2586 hm.u.cu.attribute = HPI_TUNER_LEVEL_RAW;
2926 hpi_send_recv(&hm, &hr); 2587 hpi_send_recv(&hm, &hr);
2927 if (pw_level) 2588 if (pw_level)
2928 *pw_level = (short)hr.u.c.param1; 2589 *pw_level = hr.u.cu.tuner.s_level;
2929 return hr.error; 2590 return hr.error;
2930} 2591}
2931 2592
2932u16 hpi_tuner_query_deemphasis(const struct hpi_hsubsys *ph_subsys, 2593u16 hpi_tuner_query_deemphasis(const u32 h_tuner, const u32 index,
2933 const u32 h_tuner, const u32 index, const u16 band, u32 *pdeemphasis) 2594 const u16 band, u32 *pdeemphasis)
2934{ 2595{
2935 return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_DEEMPHASIS, 2596 return hpi_control_query(h_tuner, HPI_TUNER_DEEMPHASIS, index, band,
2936 index, band, pdeemphasis); 2597 pdeemphasis);
2937} 2598}
2938 2599
2939u16 hpi_tuner_set_deemphasis(const struct hpi_hsubsys *ph_subsys, 2600u16 hpi_tuner_set_deemphasis(u32 h_control, u32 deemphasis)
2940 u32 h_control, u32 deemphasis)
2941{ 2601{
2942 return hpi_control_param_set(ph_subsys, h_control, 2602 return hpi_control_param_set(h_control, HPI_TUNER_DEEMPHASIS,
2943 HPI_TUNER_DEEMPHASIS, deemphasis, 0); 2603 deemphasis, 0);
2944} 2604}
2945 2605
2946u16 hpi_tuner_get_deemphasis(const struct hpi_hsubsys *ph_subsys, 2606u16 hpi_tuner_get_deemphasis(u32 h_control, u32 *pdeemphasis)
2947 u32 h_control, u32 *pdeemphasis)
2948{ 2607{
2949 return hpi_control_param1_get(ph_subsys, h_control, 2608 return hpi_control_param1_get(h_control, HPI_TUNER_DEEMPHASIS,
2950 HPI_TUNER_DEEMPHASIS, pdeemphasis); 2609 pdeemphasis);
2951} 2610}
2952 2611
2953u16 hpi_tuner_query_program(const struct hpi_hsubsys *ph_subsys, 2612u16 hpi_tuner_query_program(const u32 h_tuner, u32 *pbitmap_program)
2954 const u32 h_tuner, u32 *pbitmap_program)
2955{ 2613{
2956 return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_PROGRAM, 0, 0, 2614 return hpi_control_query(h_tuner, HPI_TUNER_PROGRAM, 0, 0,
2957 pbitmap_program); 2615 pbitmap_program);
2958} 2616}
2959 2617
2960u16 hpi_tuner_set_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2618u16 hpi_tuner_set_program(u32 h_control, u32 program)
2961 u32 program)
2962{ 2619{
2963 return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_PROGRAM, 2620 return hpi_control_param_set(h_control, HPI_TUNER_PROGRAM, program,
2964 program, 0); 2621 0);
2965} 2622}
2966 2623
2967u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2624u16 hpi_tuner_get_program(u32 h_control, u32 *pprogram)
2968 u32 *pprogram)
2969{ 2625{
2970 return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_PROGRAM, 2626 return hpi_control_param1_get(h_control, HPI_TUNER_PROGRAM, pprogram);
2971 pprogram);
2972} 2627}
2973 2628
2974u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys, 2629u16 hpi_tuner_get_hd_radio_dsp_version(u32 h_control, char *psz_dsp_version,
2975 u32 h_control, char *psz_dsp_version, const u32 string_size) 2630 const u32 string_size)
2976{ 2631{
2977 return hpi_control_get_string(h_control, 2632 return hpi_control_get_string(h_control,
2978 HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size); 2633 HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size);
2979} 2634}
2980 2635
2981u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys, 2636u16 hpi_tuner_get_hd_radio_sdk_version(u32 h_control, char *psz_sdk_version,
2982 u32 h_control, char *psz_sdk_version, const u32 string_size) 2637 const u32 string_size)
2983{ 2638{
2984 return hpi_control_get_string(h_control, 2639 return hpi_control_get_string(h_control,
2985 HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size); 2640 HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size);
2986} 2641}
2987 2642
2988u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2643u16 hpi_tuner_get_status(u32 h_control, u16 *pw_status_mask, u16 *pw_status)
2989 u16 *pw_status_mask, u16 *pw_status)
2990{ 2644{
2991 u32 status = 0; 2645 u32 status = 0;
2992 u16 error = 0; 2646 u16 error = 0;
2993 2647
2994 error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_STATUS, 2648 error = hpi_control_param1_get(h_control, HPI_TUNER_STATUS, &status);
2995 &status);
2996 if (pw_status) { 2649 if (pw_status) {
2997 if (!error) { 2650 if (!error) {
2998 *pw_status_mask = (u16)(status >> 16); 2651 *pw_status_mask = (u16)(status >> 16);
@@ -3005,50 +2658,44 @@ u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3005 return error; 2658 return error;
3006} 2659}
3007 2660
3008u16 hpi_tuner_set_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2661u16 hpi_tuner_set_mode(u32 h_control, u32 mode, u32 value)
3009 u32 mode, u32 value)
3010{ 2662{
3011 return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_MODE, 2663 return hpi_control_param_set(h_control, HPI_TUNER_MODE, mode, value);
3012 mode, value);
3013} 2664}
3014 2665
3015u16 hpi_tuner_get_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2666u16 hpi_tuner_get_mode(u32 h_control, u32 mode, u32 *pn_value)
3016 u32 mode, u32 *pn_value)
3017{ 2667{
3018 return hpi_control_param_get(ph_subsys, h_control, HPI_TUNER_MODE, 2668 return hpi_control_param_get(h_control, HPI_TUNER_MODE, mode, 0,
3019 mode, 0, pn_value, NULL); 2669 pn_value, NULL);
3020} 2670}
3021 2671
3022u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys, 2672u16 hpi_tuner_get_hd_radio_signal_quality(u32 h_control, u32 *pquality)
3023 u32 h_control, u32 *pquality)
3024{ 2673{
3025 return hpi_control_param1_get(ph_subsys, h_control, 2674 return hpi_control_param1_get(h_control,
3026 HPI_TUNER_HDRADIO_SIGNAL_QUALITY, pquality); 2675 HPI_TUNER_HDRADIO_SIGNAL_QUALITY, pquality);
3027} 2676}
3028 2677
3029u16 hpi_tuner_get_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys, 2678u16 hpi_tuner_get_hd_radio_signal_blend(u32 h_control, u32 *pblend)
3030 u32 h_control, u32 *pblend)
3031{ 2679{
3032 return hpi_control_param1_get(ph_subsys, h_control, 2680 return hpi_control_param1_get(h_control, HPI_TUNER_HDRADIO_BLEND,
3033 HPI_TUNER_HDRADIO_BLEND, pblend); 2681 pblend);
3034} 2682}
3035 2683
3036u16 hpi_tuner_set_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys, 2684u16 hpi_tuner_set_hd_radio_signal_blend(u32 h_control, const u32 blend)
3037 u32 h_control, const u32 blend)
3038{ 2685{
3039 return hpi_control_param_set(ph_subsys, h_control, 2686 return hpi_control_param_set(h_control, HPI_TUNER_HDRADIO_BLEND,
3040 HPI_TUNER_HDRADIO_BLEND, blend, 0); 2687 blend, 0);
3041} 2688}
3042 2689
3043u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2690u16 hpi_tuner_get_rds(u32 h_control, char *p_data)
3044 char *p_data)
3045{ 2691{
3046 struct hpi_message hm; 2692 struct hpi_message hm;
3047 struct hpi_response hr; 2693 struct hpi_response hr;
3048 2694
3049 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2695 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3050 HPI_CONTROL_GET_STATE); 2696 HPI_CONTROL_GET_STATE);
3051 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2697 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2698 return HPI_ERROR_INVALID_HANDLE;
3052 hm.u.c.attribute = HPI_TUNER_RDS; 2699 hm.u.c.attribute = HPI_TUNER_RDS;
3053 hpi_send_recv(&hm, &hr); 2700 hpi_send_recv(&hm, &hr);
3054 if (p_data) { 2701 if (p_data) {
@@ -3059,80 +2706,82 @@ u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3059 return hr.error; 2706 return hr.error;
3060} 2707}
3061 2708
3062u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys, 2709u16 hpi_pad_get_channel_name(u32 h_control, char *psz_string,
3063 u32 h_control, char *psz_string, const u32 data_length) 2710 const u32 data_length)
3064{ 2711{
3065 return hpi_control_get_string(h_control, HPI_PAD_CHANNEL_NAME, 2712 return hpi_control_get_string(h_control, HPI_PAD_CHANNEL_NAME,
3066 psz_string, data_length); 2713 psz_string, data_length);
3067} 2714}
3068 2715
3069u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2716u16 hpi_pad_get_artist(u32 h_control, char *psz_string, const u32 data_length)
3070 char *psz_string, const u32 data_length)
3071{ 2717{
3072 return hpi_control_get_string(h_control, HPI_PAD_ARTIST, psz_string, 2718 return hpi_control_get_string(h_control, HPI_PAD_ARTIST, psz_string,
3073 data_length); 2719 data_length);
3074} 2720}
3075 2721
3076u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2722u16 hpi_pad_get_title(u32 h_control, char *psz_string, const u32 data_length)
3077 char *psz_string, const u32 data_length)
3078{ 2723{
3079 return hpi_control_get_string(h_control, HPI_PAD_TITLE, psz_string, 2724 return hpi_control_get_string(h_control, HPI_PAD_TITLE, psz_string,
3080 data_length); 2725 data_length);
3081} 2726}
3082 2727
3083u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2728u16 hpi_pad_get_comment(u32 h_control, char *psz_string,
3084 char *psz_string, const u32 data_length) 2729 const u32 data_length)
3085{ 2730{
3086 return hpi_control_get_string(h_control, HPI_PAD_COMMENT, psz_string, 2731 return hpi_control_get_string(h_control, HPI_PAD_COMMENT, psz_string,
3087 data_length); 2732 data_length);
3088} 2733}
3089 2734
3090u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys, 2735u16 hpi_pad_get_program_type(u32 h_control, u32 *ppTY)
3091 u32 h_control, u32 *ppTY)
3092{ 2736{
3093 return hpi_control_param1_get(ph_subsys, h_control, 2737 return hpi_control_param1_get(h_control, HPI_PAD_PROGRAM_TYPE, ppTY);
3094 HPI_PAD_PROGRAM_TYPE, ppTY);
3095} 2738}
3096 2739
3097u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2740u16 hpi_pad_get_rdsPI(u32 h_control, u32 *ppI)
3098 u32 *ppI)
3099{ 2741{
3100 return hpi_control_param1_get(ph_subsys, h_control, 2742 return hpi_control_param1_get(h_control, HPI_PAD_PROGRAM_ID, ppI);
3101 HPI_PAD_PROGRAM_ID, ppI);
3102} 2743}
3103 2744
3104u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys, 2745u16 hpi_volume_query_channels(const u32 h_volume, u32 *p_channels)
3105 const u32 h_volume, u32 *p_channels)
3106{ 2746{
3107 return hpi_control_query(ph_subsys, h_volume, HPI_VOLUME_NUM_CHANNELS, 2747 return hpi_control_query(h_volume, HPI_VOLUME_NUM_CHANNELS, 0, 0,
3108 0, 0, p_channels); 2748 p_channels);
3109} 2749}
3110 2750
3111u16 hpi_volume_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2751u16 hpi_volume_set_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS]
3112 short an_log_gain[HPI_MAX_CHANNELS]
3113 ) 2752 )
3114{ 2753{
3115 return hpi_control_log_set2(h_control, HPI_VOLUME_GAIN, 2754 return hpi_control_log_set2(h_control, HPI_VOLUME_GAIN,
3116 an_log_gain[0], an_log_gain[1]); 2755 an_log_gain[0], an_log_gain[1]);
3117} 2756}
3118 2757
3119u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2758u16 hpi_volume_get_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS]
3120 short an_log_gain[HPI_MAX_CHANNELS]
3121 ) 2759 )
3122{ 2760{
3123 return hpi_control_log_get2(ph_subsys, h_control, HPI_VOLUME_GAIN, 2761 return hpi_control_log_get2(h_control, HPI_VOLUME_GAIN,
3124 &an_log_gain[0], &an_log_gain[1]); 2762 &an_log_gain[0], &an_log_gain[1]);
3125} 2763}
3126 2764
3127u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2765u16 hpi_volume_set_mute(u32 h_control, u32 mute)
3128 short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB) 2766{
2767 return hpi_control_param_set(h_control, HPI_VOLUME_MUTE, mute, 0);
2768}
2769
2770u16 hpi_volume_get_mute(u32 h_control, u32 *mute)
2771{
2772 return hpi_control_param1_get(h_control, HPI_VOLUME_MUTE, mute);
2773}
2774
2775u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB,
2776 short *max_gain_01dB, short *step_gain_01dB)
3129{ 2777{
3130 struct hpi_message hm; 2778 struct hpi_message hm;
3131 struct hpi_response hr; 2779 struct hpi_response hr;
3132 2780
3133 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2781 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3134 HPI_CONTROL_GET_STATE); 2782 HPI_CONTROL_GET_STATE);
3135 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2783 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2784 return HPI_ERROR_INVALID_HANDLE;
3136 hm.u.c.attribute = HPI_VOLUME_RANGE; 2785 hm.u.c.attribute = HPI_VOLUME_RANGE;
3137 2786
3138 hpi_send_recv(&hm, &hr); 2787 hpi_send_recv(&hm, &hr);
@@ -3150,16 +2799,17 @@ u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3150 return hr.error; 2799 return hr.error;
3151} 2800}
3152 2801
3153u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys, 2802u16 hpi_volume_auto_fade_profile(u32 h_control,
3154 u32 h_control, short an_stop_gain0_01dB[HPI_MAX_CHANNELS], 2803 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms,
3155 u32 duration_ms, u16 profile) 2804 u16 profile)
3156{ 2805{
3157 struct hpi_message hm; 2806 struct hpi_message hm;
3158 struct hpi_response hr; 2807 struct hpi_response hr;
3159 2808
3160 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2809 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3161 HPI_CONTROL_SET_STATE); 2810 HPI_CONTROL_SET_STATE);
3162 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2811 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2812 return HPI_ERROR_INVALID_HANDLE;
3163 2813
3164 memcpy(hm.u.c.an_log_value, an_stop_gain0_01dB, 2814 memcpy(hm.u.c.an_log_value, an_stop_gain0_01dB,
3165 sizeof(short) * HPI_MAX_CHANNELS); 2815 sizeof(short) * HPI_MAX_CHANNELS);
@@ -3173,21 +2823,21 @@ u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys,
3173 return hr.error; 2823 return hr.error;
3174} 2824}
3175 2825
3176u16 hpi_volume_auto_fade(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2826u16 hpi_volume_auto_fade(u32 h_control,
3177 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms) 2827 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms)
3178{ 2828{
3179 return hpi_volume_auto_fade_profile(ph_subsys, h_control, 2829 return hpi_volume_auto_fade_profile(h_control, an_stop_gain0_01dB,
3180 an_stop_gain0_01dB, duration_ms, HPI_VOLUME_AUTOFADE_LOG); 2830 duration_ms, HPI_VOLUME_AUTOFADE_LOG);
3181} 2831}
3182 2832
3183u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2833u16 hpi_vox_set_threshold(u32 h_control, short an_gain0_01dB)
3184 short an_gain0_01dB)
3185{ 2834{
3186 struct hpi_message hm; 2835 struct hpi_message hm;
3187 struct hpi_response hr; 2836 struct hpi_response hr;
3188 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2837 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3189 HPI_CONTROL_SET_STATE); 2838 HPI_CONTROL_SET_STATE);
3190 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2839 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2840 return HPI_ERROR_INVALID_HANDLE;
3191 hm.u.c.attribute = HPI_VOX_THRESHOLD; 2841 hm.u.c.attribute = HPI_VOX_THRESHOLD;
3192 2842
3193 hm.u.c.an_log_value[0] = an_gain0_01dB; 2843 hm.u.c.an_log_value[0] = an_gain0_01dB;
@@ -3197,14 +2847,14 @@ u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3197 return hr.error; 2847 return hr.error;
3198} 2848}
3199 2849
3200u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2850u16 hpi_vox_get_threshold(u32 h_control, short *an_gain0_01dB)
3201 short *an_gain0_01dB)
3202{ 2851{
3203 struct hpi_message hm; 2852 struct hpi_message hm;
3204 struct hpi_response hr; 2853 struct hpi_response hr;
3205 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2854 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3206 HPI_CONTROL_GET_STATE); 2855 HPI_CONTROL_GET_STATE);
3207 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2856 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2857 return HPI_ERROR_INVALID_HANDLE;
3208 hm.u.c.attribute = HPI_VOX_THRESHOLD; 2858 hm.u.c.attribute = HPI_VOX_THRESHOLD;
3209 2859
3210 hpi_send_recv(&hm, &hr); 2860 hpi_send_recv(&hm, &hr);
@@ -3213,728 +2863,3 @@ u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3213 2863
3214 return hr.error; 2864 return hr.error;
3215} 2865}
3216
3217static size_t strv_packet_size = MIN_STRV_PACKET_SIZE;
3218
3219static size_t entity_type_to_size[LAST_ENTITY_TYPE] = {
3220 0,
3221 sizeof(struct hpi_entity),
3222 sizeof(void *),
3223
3224 sizeof(int),
3225 sizeof(float),
3226 sizeof(double),
3227
3228 sizeof(char),
3229 sizeof(char),
3230
3231 4 * sizeof(char),
3232 16 * sizeof(char),
3233 6 * sizeof(char),
3234};
3235
3236static inline size_t hpi_entity_size(struct hpi_entity *entity_ptr)
3237{
3238 return entity_ptr->header.size;
3239}
3240
3241static inline size_t hpi_entity_header_size(struct hpi_entity *entity_ptr)
3242{
3243 return sizeof(entity_ptr->header);
3244}
3245
3246static inline size_t hpi_entity_value_size(struct hpi_entity *entity_ptr)
3247{
3248 return hpi_entity_size(entity_ptr) -
3249 hpi_entity_header_size(entity_ptr);
3250}
3251
3252static inline size_t hpi_entity_item_count(struct hpi_entity *entity_ptr)
3253{
3254 return hpi_entity_value_size(entity_ptr) /
3255 entity_type_to_size[entity_ptr->header.type];
3256}
3257
3258static inline struct hpi_entity *hpi_entity_ptr_to_next(struct hpi_entity
3259 *entity_ptr)
3260{
3261 return (void *)(((u8 *)entity_ptr) + hpi_entity_size(entity_ptr));
3262}
3263
3264static inline u16 hpi_entity_check_type(const enum e_entity_type t)
3265{
3266 if (t >= 0 && t < STR_TYPE_FIELD_MAX)
3267 return 0;
3268 return HPI_ERROR_ENTITY_TYPE_INVALID;
3269}
3270
3271static inline u16 hpi_entity_check_role(const enum e_entity_role r)
3272{
3273 if (r >= 0 && r < STR_ROLE_FIELD_MAX)
3274 return 0;
3275 return HPI_ERROR_ENTITY_ROLE_INVALID;
3276}
3277
3278static u16 hpi_entity_get_next(struct hpi_entity *entity, int recursive_flag,
3279 void *guard_p, struct hpi_entity **next)
3280{
3281 HPI_DEBUG_ASSERT(entity != NULL);
3282 HPI_DEBUG_ASSERT(next != NULL);
3283 HPI_DEBUG_ASSERT(hpi_entity_size(entity) != 0);
3284
3285 if (guard_p <= (void *)entity) {
3286 *next = NULL;
3287 return 0;
3288 }
3289
3290 if (recursive_flag && entity->header.type == entity_type_sequence)
3291 *next = (struct hpi_entity *)entity->value;
3292 else
3293 *next = (struct hpi_entity *)hpi_entity_ptr_to_next(entity);
3294
3295 if (guard_p <= (void *)*next) {
3296 *next = NULL;
3297 return 0;
3298 }
3299
3300 HPI_DEBUG_ASSERT(guard_p >= (void *)hpi_entity_ptr_to_next(*next));
3301 return 0;
3302}
3303
3304u16 hpi_entity_find_next(struct hpi_entity *container_entity,
3305 enum e_entity_type type, enum e_entity_role role, int recursive_flag,
3306 struct hpi_entity **current_match)
3307{
3308 struct hpi_entity *tmp = NULL;
3309 void *guard_p = NULL;
3310
3311 HPI_DEBUG_ASSERT(container_entity != NULL);
3312 guard_p = hpi_entity_ptr_to_next(container_entity);
3313
3314 if (*current_match != NULL)
3315 hpi_entity_get_next(*current_match, recursive_flag, guard_p,
3316 &tmp);
3317 else
3318 hpi_entity_get_next(container_entity, 1, guard_p, &tmp);
3319
3320 while (tmp) {
3321 u16 err;
3322
3323 HPI_DEBUG_ASSERT((void *)tmp >= (void *)container_entity);
3324
3325 if ((!type || tmp->header.type == type) && (!role
3326 || tmp->header.role == role)) {
3327 *current_match = tmp;
3328 return 0;
3329 }
3330
3331 err = hpi_entity_get_next(tmp, recursive_flag, guard_p,
3332 current_match);
3333 if (err)
3334 return err;
3335
3336 tmp = *current_match;
3337 }
3338
3339 *current_match = NULL;
3340 return 0;
3341}
3342
3343void hpi_entity_free(struct hpi_entity *entity)
3344{
3345 kfree(entity);
3346}
3347
3348static u16 hpi_entity_alloc_and_copy(struct hpi_entity *src,
3349 struct hpi_entity **dst)
3350{
3351 size_t buf_size;
3352 HPI_DEBUG_ASSERT(dst != NULL);
3353 HPI_DEBUG_ASSERT(src != NULL);
3354
3355 buf_size = hpi_entity_size(src);
3356 *dst = kmalloc(buf_size, GFP_KERNEL);
3357 if (*dst == NULL)
3358 return HPI_ERROR_MEMORY_ALLOC;
3359 memcpy(*dst, src, buf_size);
3360 return 0;
3361}
3362
3363u16 hpi_universal_info(const struct hpi_hsubsys *ph_subsys, u32 hC,
3364 struct hpi_entity **info)
3365{
3366 struct hpi_msg_strv hm;
3367 struct hpi_res_strv *phr;
3368 u16 hpi_err;
3369 int remaining_attempts = 2;
3370 size_t resp_packet_size = 1024;
3371
3372 *info = NULL;
3373
3374 while (remaining_attempts--) {
3375 phr = kmalloc(resp_packet_size, GFP_KERNEL);
3376 HPI_DEBUG_ASSERT(phr != NULL);
3377
3378 hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h,
3379 (u16)resp_packet_size, HPI_OBJ_CONTROL,
3380 HPI_CONTROL_GET_INFO);
3381 u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index);
3382
3383 hm.strv.header.size = sizeof(hm.strv);
3384 phr->strv.header.size = resp_packet_size - sizeof(phr->h);
3385
3386 hpi_send_recv((struct hpi_message *)&hm.h,
3387 (struct hpi_response *)&phr->h);
3388 if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) {
3389
3390 HPI_DEBUG_ASSERT(phr->h.specific_error >
3391 MIN_STRV_PACKET_SIZE
3392 && phr->h.specific_error < 1500);
3393 resp_packet_size = phr->h.specific_error;
3394 } else {
3395 remaining_attempts = 0;
3396 if (!phr->h.error)
3397 hpi_entity_alloc_and_copy(&phr->strv, info);
3398 }
3399
3400 hpi_err = phr->h.error;
3401 kfree(phr);
3402 }
3403
3404 return hpi_err;
3405}
3406
3407u16 hpi_universal_get(const struct hpi_hsubsys *ph_subsys, u32 hC,
3408 struct hpi_entity **value)
3409{
3410 struct hpi_msg_strv hm;
3411 struct hpi_res_strv *phr;
3412 u16 hpi_err;
3413 int remaining_attempts = 2;
3414
3415 *value = NULL;
3416
3417 while (remaining_attempts--) {
3418 phr = kmalloc(strv_packet_size, GFP_KERNEL);
3419 if (!phr)
3420 return HPI_ERROR_MEMORY_ALLOC;
3421
3422 hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h,
3423 (u16)strv_packet_size, HPI_OBJ_CONTROL,
3424 HPI_CONTROL_GET_STATE);
3425 u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index);
3426
3427 hm.strv.header.size = sizeof(hm.strv);
3428 phr->strv.header.size = strv_packet_size - sizeof(phr->h);
3429
3430 hpi_send_recv((struct hpi_message *)&hm.h,
3431 (struct hpi_response *)&phr->h);
3432 if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) {
3433
3434 HPI_DEBUG_ASSERT(phr->h.specific_error >
3435 MIN_STRV_PACKET_SIZE
3436 && phr->h.specific_error < 1000);
3437 strv_packet_size = phr->h.specific_error;
3438 } else {
3439 remaining_attempts = 0;
3440 if (!phr->h.error)
3441 hpi_entity_alloc_and_copy(&phr->strv, value);
3442 }
3443
3444 hpi_err = phr->h.error;
3445 kfree(phr);
3446 }
3447
3448 return hpi_err;
3449}
3450
3451u16 hpi_universal_set(const struct hpi_hsubsys *ph_subsys, u32 hC,
3452 struct hpi_entity *value)
3453{
3454 struct hpi_msg_strv *phm;
3455 struct hpi_res_strv hr;
3456
3457 phm = kmalloc(sizeof(phm->h) + value->header.size, GFP_KERNEL);
3458 HPI_DEBUG_ASSERT(phm != NULL);
3459
3460 hpi_init_message_responseV1(&phm->h,
3461 sizeof(phm->h) + value->header.size, &hr.h, sizeof(hr),
3462 HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE);
3463 u32TOINDEXES(hC, &phm->h.adapter_index, &phm->h.obj_index);
3464 hr.strv.header.size = sizeof(hr.strv);
3465
3466 memcpy(&phm->strv, value, value->header.size);
3467 hpi_send_recv((struct hpi_message *)&phm->h,
3468 (struct hpi_response *)&hr.h);
3469
3470 return hr.h.error;
3471}
3472
3473u16 hpi_entity_alloc_and_pack(const enum e_entity_type type,
3474 const size_t item_count, const enum e_entity_role role, void *value,
3475 struct hpi_entity **entity)
3476{
3477 size_t bytes_to_copy, total_size;
3478 u16 hE = 0;
3479 *entity = NULL;
3480
3481 hE = hpi_entity_check_type(type);
3482 if (hE)
3483 return hE;
3484
3485 HPI_DEBUG_ASSERT(role > entity_role_null && type < LAST_ENTITY_TYPE);
3486
3487 bytes_to_copy = entity_type_to_size[type] * item_count;
3488 total_size = hpi_entity_header_size(*entity) + bytes_to_copy;
3489
3490 HPI_DEBUG_ASSERT(total_size >= hpi_entity_header_size(*entity)
3491 && total_size < STR_SIZE_FIELD_MAX);
3492
3493 *entity = kmalloc(total_size, GFP_KERNEL);
3494 if (*entity == NULL)
3495 return HPI_ERROR_MEMORY_ALLOC;
3496 memcpy((*entity)->value, value, bytes_to_copy);
3497 (*entity)->header.size =
3498 hpi_entity_header_size(*entity) + bytes_to_copy;
3499 (*entity)->header.type = type;
3500 (*entity)->header.role = role;
3501 return 0;
3502}
3503
3504u16 hpi_entity_copy_value_from(struct hpi_entity *entity,
3505 enum e_entity_type type, size_t item_count, void *value_dst_p)
3506{
3507 size_t bytes_to_copy;
3508
3509 if (entity->header.type != type)
3510 return HPI_ERROR_ENTITY_TYPE_MISMATCH;
3511
3512 if (hpi_entity_item_count(entity) != item_count)
3513 return HPI_ERROR_ENTITY_ITEM_COUNT;
3514
3515 bytes_to_copy = entity_type_to_size[type] * item_count;
3516 memcpy(value_dst_p, entity->value, bytes_to_copy);
3517 return 0;
3518}
3519
3520u16 hpi_entity_unpack(struct hpi_entity *entity, enum e_entity_type *type,
3521 size_t *item_count, enum e_entity_role *role, void **value)
3522{
3523 u16 err = 0;
3524 HPI_DEBUG_ASSERT(entity != NULL);
3525
3526 if (type)
3527 *type = entity->header.type;
3528
3529 if (role)
3530 *role = entity->header.role;
3531
3532 if (value)
3533 *value = entity->value;
3534
3535 if (item_count != NULL) {
3536 if (entity->header.type == entity_type_sequence) {
3537 void *guard_p = hpi_entity_ptr_to_next(entity);
3538 struct hpi_entity *next = NULL;
3539 void *contents = entity->value;
3540
3541 *item_count = 0;
3542 while (contents < guard_p) {
3543 (*item_count)++;
3544 err = hpi_entity_get_next(contents, 0,
3545 guard_p, &next);
3546 if (next == NULL || err)
3547 break;
3548 contents = next;
3549 }
3550 } else {
3551 *item_count = hpi_entity_item_count(entity);
3552 }
3553 }
3554 return err;
3555}
3556
3557u16 hpi_gpio_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3558 u32 *ph_gpio, u16 *pw_number_input_bits, u16 *pw_number_output_bits)
3559{
3560 struct hpi_message hm;
3561 struct hpi_response hr;
3562 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_OPEN);
3563 hm.adapter_index = adapter_index;
3564
3565 hpi_send_recv(&hm, &hr);
3566
3567 if (hr.error == 0) {
3568 *ph_gpio =
3569 hpi_indexes_to_handle(HPI_OBJ_GPIO, adapter_index, 0);
3570 if (pw_number_input_bits)
3571 *pw_number_input_bits = hr.u.l.number_input_bits;
3572 if (pw_number_output_bits)
3573 *pw_number_output_bits = hr.u.l.number_output_bits;
3574 } else
3575 *ph_gpio = 0;
3576 return hr.error;
3577}
3578
3579u16 hpi_gpio_read_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3580 u16 bit_index, u16 *pw_bit_data)
3581{
3582 struct hpi_message hm;
3583 struct hpi_response hr;
3584 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_BIT);
3585 u32TOINDEX(h_gpio, &hm.adapter_index);
3586 hm.u.l.bit_index = bit_index;
3587
3588 hpi_send_recv(&hm, &hr);
3589
3590 *pw_bit_data = hr.u.l.bit_data[0];
3591 return hr.error;
3592}
3593
3594u16 hpi_gpio_read_all_bits(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3595 u16 aw_all_bit_data[4]
3596 )
3597{
3598 struct hpi_message hm;
3599 struct hpi_response hr;
3600 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_ALL);
3601 u32TOINDEX(h_gpio, &hm.adapter_index);
3602
3603 hpi_send_recv(&hm, &hr);
3604
3605 if (aw_all_bit_data) {
3606 aw_all_bit_data[0] = hr.u.l.bit_data[0];
3607 aw_all_bit_data[1] = hr.u.l.bit_data[1];
3608 aw_all_bit_data[2] = hr.u.l.bit_data[2];
3609 aw_all_bit_data[3] = hr.u.l.bit_data[3];
3610 }
3611 return hr.error;
3612}
3613
3614u16 hpi_gpio_write_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3615 u16 bit_index, u16 bit_data)
3616{
3617 struct hpi_message hm;
3618 struct hpi_response hr;
3619 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_WRITE_BIT);
3620 u32TOINDEX(h_gpio, &hm.adapter_index);
3621 hm.u.l.bit_index = bit_index;
3622 hm.u.l.bit_data = bit_data;
3623
3624 hpi_send_recv(&hm, &hr);
3625
3626 return hr.error;
3627}
3628
3629u16 hpi_gpio_write_status(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3630 u16 aw_all_bit_data[4]
3631 )
3632{
3633 struct hpi_message hm;
3634 struct hpi_response hr;
3635 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO,
3636 HPI_GPIO_WRITE_STATUS);
3637 u32TOINDEX(h_gpio, &hm.adapter_index);
3638
3639 hpi_send_recv(&hm, &hr);
3640
3641 if (aw_all_bit_data) {
3642 aw_all_bit_data[0] = hr.u.l.bit_data[0];
3643 aw_all_bit_data[1] = hr.u.l.bit_data[1];
3644 aw_all_bit_data[2] = hr.u.l.bit_data[2];
3645 aw_all_bit_data[3] = hr.u.l.bit_data[3];
3646 }
3647 return hr.error;
3648}
3649
3650u16 hpi_async_event_open(const struct hpi_hsubsys *ph_subsys,
3651 u16 adapter_index, u32 *ph_async)
3652{
3653 struct hpi_message hm;
3654 struct hpi_response hr;
3655 hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3656 HPI_ASYNCEVENT_OPEN);
3657 hm.adapter_index = adapter_index;
3658
3659 hpi_send_recv(&hm, &hr);
3660
3661 if (hr.error == 0)
3662
3663 *ph_async =
3664 hpi_indexes_to_handle(HPI_OBJ_ASYNCEVENT,
3665 adapter_index, 0);
3666 else
3667 *ph_async = 0;
3668 return hr.error;
3669
3670}
3671
3672u16 hpi_async_event_close(const struct hpi_hsubsys *ph_subsys, u32 h_async)
3673{
3674 struct hpi_message hm;
3675 struct hpi_response hr;
3676 hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3677 HPI_ASYNCEVENT_OPEN);
3678 u32TOINDEX(h_async, &hm.adapter_index);
3679
3680 hpi_send_recv(&hm, &hr);
3681
3682 return hr.error;
3683}
3684
3685u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async,
3686 u16 maximum_events, struct hpi_async_event *p_events,
3687 u16 *pw_number_returned)
3688{
3689
3690 return 0;
3691}
3692
3693u16 hpi_async_event_get_count(const struct hpi_hsubsys *ph_subsys,
3694 u32 h_async, u16 *pw_count)
3695{
3696 struct hpi_message hm;
3697 struct hpi_response hr;
3698 hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3699 HPI_ASYNCEVENT_GETCOUNT);
3700 u32TOINDEX(h_async, &hm.adapter_index);
3701
3702 hpi_send_recv(&hm, &hr);
3703
3704 if (hr.error == 0)
3705 if (pw_count)
3706 *pw_count = hr.u.as.u.count.count;
3707
3708 return hr.error;
3709}
3710
3711u16 hpi_async_event_get(const struct hpi_hsubsys *ph_subsys, u32 h_async,
3712 u16 maximum_events, struct hpi_async_event *p_events,
3713 u16 *pw_number_returned)
3714{
3715 struct hpi_message hm;
3716 struct hpi_response hr;
3717 hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3718 HPI_ASYNCEVENT_GET);
3719 u32TOINDEX(h_async, &hm.adapter_index);
3720
3721 hpi_send_recv(&hm, &hr);
3722 if (!hr.error) {
3723 memcpy(p_events, &hr.u.as.u.event,
3724 sizeof(struct hpi_async_event));
3725 *pw_number_returned = 1;
3726 }
3727
3728 return hr.error;
3729}
3730
3731u16 hpi_nv_memory_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3732 u32 *ph_nv_memory, u16 *pw_size_in_bytes)
3733{
3734 struct hpi_message hm;
3735 struct hpi_response hr;
3736 hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3737 HPI_NVMEMORY_OPEN);
3738 hm.adapter_index = adapter_index;
3739
3740 hpi_send_recv(&hm, &hr);
3741
3742 if (hr.error == 0) {
3743 *ph_nv_memory =
3744 hpi_indexes_to_handle(HPI_OBJ_NVMEMORY, adapter_index,
3745 0);
3746 if (pw_size_in_bytes)
3747 *pw_size_in_bytes = hr.u.n.size_in_bytes;
3748 } else
3749 *ph_nv_memory = 0;
3750 return hr.error;
3751}
3752
3753u16 hpi_nv_memory_read_byte(const struct hpi_hsubsys *ph_subsys,
3754 u32 h_nv_memory, u16 index, u16 *pw_data)
3755{
3756 struct hpi_message hm;
3757 struct hpi_response hr;
3758 hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3759 HPI_NVMEMORY_READ_BYTE);
3760 u32TOINDEX(h_nv_memory, &hm.adapter_index);
3761 hm.u.n.address = index;
3762
3763 hpi_send_recv(&hm, &hr);
3764
3765 *pw_data = hr.u.n.data;
3766 return hr.error;
3767}
3768
3769u16 hpi_nv_memory_write_byte(const struct hpi_hsubsys *ph_subsys,
3770 u32 h_nv_memory, u16 index, u16 data)
3771{
3772 struct hpi_message hm;
3773 struct hpi_response hr;
3774 hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3775 HPI_NVMEMORY_WRITE_BYTE);
3776 u32TOINDEX(h_nv_memory, &hm.adapter_index);
3777 hm.u.n.address = index;
3778 hm.u.n.data = data;
3779
3780 hpi_send_recv(&hm, &hr);
3781
3782 return hr.error;
3783}
3784
3785u16 hpi_profile_open_all(const struct hpi_hsubsys *ph_subsys,
3786 u16 adapter_index, u16 profile_index, u32 *ph_profile,
3787 u16 *pw_max_profiles)
3788{
3789 struct hpi_message hm;
3790 struct hpi_response hr;
3791 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3792 HPI_PROFILE_OPEN_ALL);
3793 hm.adapter_index = adapter_index;
3794 hm.obj_index = profile_index;
3795 hpi_send_recv(&hm, &hr);
3796
3797 *pw_max_profiles = hr.u.p.u.o.max_profiles;
3798 if (hr.error == 0)
3799 *ph_profile =
3800 hpi_indexes_to_handle(HPI_OBJ_PROFILE, adapter_index,
3801 profile_index);
3802 else
3803 *ph_profile = 0;
3804 return hr.error;
3805}
3806
3807u16 hpi_profile_get(const struct hpi_hsubsys *ph_subsys, u32 h_profile,
3808 u16 bin_index, u16 *pw_seconds, u32 *pmicro_seconds, u32 *pcall_count,
3809 u32 *pmax_micro_seconds, u32 *pmin_micro_seconds)
3810{
3811 struct hpi_message hm;
3812 struct hpi_response hr;
3813 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_GET);
3814 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3815 hm.u.p.bin_index = bin_index;
3816 hpi_send_recv(&hm, &hr);
3817 if (pw_seconds)
3818 *pw_seconds = hr.u.p.u.t.seconds;
3819 if (pmicro_seconds)
3820 *pmicro_seconds = hr.u.p.u.t.micro_seconds;
3821 if (pcall_count)
3822 *pcall_count = hr.u.p.u.t.call_count;
3823 if (pmax_micro_seconds)
3824 *pmax_micro_seconds = hr.u.p.u.t.max_micro_seconds;
3825 if (pmin_micro_seconds)
3826 *pmin_micro_seconds = hr.u.p.u.t.min_micro_seconds;
3827 return hr.error;
3828}
3829
3830u16 hpi_profile_get_utilization(const struct hpi_hsubsys *ph_subsys,
3831 u32 h_profile, u32 *putilization)
3832{
3833 struct hpi_message hm;
3834 struct hpi_response hr;
3835 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3836 HPI_PROFILE_GET_UTILIZATION);
3837 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3838 hpi_send_recv(&hm, &hr);
3839 if (hr.error) {
3840 if (putilization)
3841 *putilization = 0;
3842 } else {
3843 if (putilization)
3844 *putilization = hr.u.p.u.t.call_count;
3845 }
3846 return hr.error;
3847}
3848
3849u16 hpi_profile_get_name(const struct hpi_hsubsys *ph_subsys, u32 h_profile,
3850 u16 bin_index, char *sz_name, u16 name_length)
3851{
3852 struct hpi_message hm;
3853 struct hpi_response hr;
3854 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3855 HPI_PROFILE_GET_NAME);
3856 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3857 hm.u.p.bin_index = bin_index;
3858 hpi_send_recv(&hm, &hr);
3859 if (hr.error) {
3860 if (sz_name)
3861 strcpy(sz_name, "??");
3862 } else {
3863 if (sz_name)
3864 memcpy(sz_name, (char *)hr.u.p.u.n.sz_name,
3865 name_length);
3866 }
3867 return hr.error;
3868}
3869
3870u16 hpi_profile_start_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile)
3871{
3872 struct hpi_message hm;
3873 struct hpi_response hr;
3874 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3875 HPI_PROFILE_START_ALL);
3876 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3877 hpi_send_recv(&hm, &hr);
3878
3879 return hr.error;
3880}
3881
3882u16 hpi_profile_stop_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile)
3883{
3884 struct hpi_message hm;
3885 struct hpi_response hr;
3886 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3887 HPI_PROFILE_STOP_ALL);
3888 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3889 hpi_send_recv(&hm, &hr);
3890
3891 return hr.error;
3892}
3893
3894u16 hpi_watchdog_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3895 u32 *ph_watchdog)
3896{
3897 struct hpi_message hm;
3898 struct hpi_response hr;
3899 hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3900 HPI_WATCHDOG_OPEN);
3901 hm.adapter_index = adapter_index;
3902
3903 hpi_send_recv(&hm, &hr);
3904
3905 if (hr.error == 0)
3906 *ph_watchdog =
3907 hpi_indexes_to_handle(HPI_OBJ_WATCHDOG, adapter_index,
3908 0);
3909 else
3910 *ph_watchdog = 0;
3911 return hr.error;
3912}
3913
3914u16 hpi_watchdog_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog,
3915 u32 time_millisec)
3916{
3917 struct hpi_message hm;
3918 struct hpi_response hr;
3919 hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3920 HPI_WATCHDOG_SET_TIME);
3921 u32TOINDEX(h_watchdog, &hm.adapter_index);
3922 hm.u.w.time_ms = time_millisec;
3923
3924 hpi_send_recv(&hm, &hr);
3925
3926 return hr.error;
3927}
3928
3929u16 hpi_watchdog_ping(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog)
3930{
3931 struct hpi_message hm;
3932 struct hpi_response hr;
3933 hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3934 HPI_WATCHDOG_PING);
3935 u32TOINDEX(h_watchdog, &hm.adapter_index);
3936
3937 hpi_send_recv(&hm, &hr);
3938
3939 return hr.error;
3940}
diff --git a/sound/pci/asihpi/hpimsginit.c b/sound/pci/asihpi/hpimsginit.c
index 8e1d099ed7e4..628376ce4a49 100644
--- a/sound/pci/asihpi/hpimsginit.c
+++ b/sound/pci/asihpi/hpimsginit.c
@@ -32,21 +32,6 @@ static u16 res_size[HPI_OBJ_MAXINDEX + 1] = HPI_RESPONSE_SIZE_BY_OBJECT;
32static u16 gwSSX2_bypass; 32static u16 gwSSX2_bypass;
33 33
34/** \internal 34/** \internal
35 * Used by ASIO driver to disable SSX2 for a single process
36 * \param phSubSys Pointer to HPI subsystem handle.
37 * \param wBypass New bypass setting 0 = off, nonzero = on
38 * \return Previous bypass setting.
39 */
40u16 hpi_subsys_ssx2_bypass(const struct hpi_hsubsys *ph_subsys, u16 bypass)
41{
42 u16 old_value = gwSSX2_bypass;
43
44 gwSSX2_bypass = bypass;
45
46 return old_value;
47}
48
49/** \internal
50 * initialize the HPI message structure 35 * initialize the HPI message structure
51 */ 36 */
52static void hpi_init_message(struct hpi_message *phm, u16 object, 37static void hpi_init_message(struct hpi_message *phm, u16 object,
@@ -65,7 +50,8 @@ static void hpi_init_message(struct hpi_message *phm, u16 object,
65 phm->object = object; 50 phm->object = object;
66 phm->function = function; 51 phm->function = function;
67 phm->version = 0; 52 phm->version = 0;
68 /* Expect adapter index to be set by caller */ 53 phm->adapter_index = HPI_ADAPTER_INDEX_INVALID;
54 /* Expect actual adapter index to be set by caller */
69} 55}
70 56
71/** \internal 57/** \internal
diff --git a/sound/pci/asihpi/hpimsginit.h b/sound/pci/asihpi/hpimsginit.h
index 864ad020c9b3..bfd330d78b58 100644
--- a/sound/pci/asihpi/hpimsginit.h
+++ b/sound/pci/asihpi/hpimsginit.h
@@ -21,11 +21,15 @@
21 (C) Copyright AudioScience Inc. 2007 21 (C) Copyright AudioScience Inc. 2007
22*******************************************************************************/ 22*******************************************************************************/
23/* Initialise response headers, or msg/response pairs. 23/* Initialise response headers, or msg/response pairs.
24Note that it is valid to just init a response e.g. when a lower level is preparing 24Note that it is valid to just init a response e.g. when a lower level is
25a response to a message. 25preparing a response to a message.
26However, when sending a message, a matching response buffer always must be prepared 26However, when sending a message, a matching response buffer must always be
27prepared.
27*/ 28*/
28 29
30#ifndef _HPIMSGINIT_H_
31#define _HPIMSGINIT_H_
32
29void hpi_init_response(struct hpi_response *phr, u16 object, u16 function, 33void hpi_init_response(struct hpi_response *phr, u16 object, u16 function,
30 u16 error); 34 u16 error);
31 35
@@ -38,3 +42,5 @@ void hpi_init_responseV1(struct hpi_response_header *phr, u16 size,
38void hpi_init_message_responseV1(struct hpi_message_header *phm, u16 msg_size, 42void hpi_init_message_responseV1(struct hpi_message_header *phm, u16 msg_size,
39 struct hpi_response_header *phr, u16 res_size, u16 object, 43 struct hpi_response_header *phr, u16 res_size, u16 object,
40 u16 function); 44 u16 function);
45
46#endif /* _HPIMSGINIT_H_ */
diff --git a/sound/pci/asihpi/hpimsgx.c b/sound/pci/asihpi/hpimsgx.c
index f01ab964f602..7352a5f7b4f7 100644
--- a/sound/pci/asihpi/hpimsgx.c
+++ b/sound/pci/asihpi/hpimsgx.c
@@ -23,6 +23,7 @@ Extended Message Function With Response Cacheing
23#define SOURCEFILE_NAME "hpimsgx.c" 23#define SOURCEFILE_NAME "hpimsgx.c"
24#include "hpi_internal.h" 24#include "hpi_internal.h"
25#include "hpimsginit.h" 25#include "hpimsginit.h"
26#include "hpicmn.h"
26#include "hpimsgx.h" 27#include "hpimsgx.h"
27#include "hpidebug.h" 28#include "hpidebug.h"
28 29
@@ -42,22 +43,24 @@ static hpi_handler_func *hpi_lookup_entry_point_function(const struct hpi_pci
42 43
43 for (i = 0; asihpi_pci_tbl[i].vendor != 0; i++) { 44 for (i = 0; asihpi_pci_tbl[i].vendor != 0; i++) {
44 if (asihpi_pci_tbl[i].vendor != PCI_ANY_ID 45 if (asihpi_pci_tbl[i].vendor != PCI_ANY_ID
45 && asihpi_pci_tbl[i].vendor != pci_info->vendor_id) 46 && asihpi_pci_tbl[i].vendor !=
47 pci_info->pci_dev->vendor)
46 continue; 48 continue;
47 if (asihpi_pci_tbl[i].device != PCI_ANY_ID 49 if (asihpi_pci_tbl[i].device != PCI_ANY_ID
48 && asihpi_pci_tbl[i].device != pci_info->device_id) 50 && asihpi_pci_tbl[i].device !=
51 pci_info->pci_dev->device)
49 continue; 52 continue;
50 if (asihpi_pci_tbl[i].subvendor != PCI_ANY_ID 53 if (asihpi_pci_tbl[i].subvendor != PCI_ANY_ID
51 && asihpi_pci_tbl[i].subvendor != 54 && asihpi_pci_tbl[i].subvendor !=
52 pci_info->subsys_vendor_id) 55 pci_info->pci_dev->subsystem_vendor)
53 continue; 56 continue;
54 if (asihpi_pci_tbl[i].subdevice != PCI_ANY_ID 57 if (asihpi_pci_tbl[i].subdevice != PCI_ANY_ID
55 && asihpi_pci_tbl[i].subdevice != 58 && asihpi_pci_tbl[i].subdevice !=
56 pci_info->subsys_device_id) 59 pci_info->pci_dev->subsystem_device)
57 continue; 60 continue;
58 61
59 HPI_DEBUG_LOG(DEBUG, " %x,%lu\n", i, 62 /* HPI_DEBUG_LOG(DEBUG, " %x,%lx\n", i,
60 asihpi_pci_tbl[i].driver_data); 63 asihpi_pci_tbl[i].driver_data); */
61 return (hpi_handler_func *) asihpi_pci_tbl[i].driver_data; 64 return (hpi_handler_func *) asihpi_pci_tbl[i].driver_data;
62 } 65 }
63 66
@@ -67,21 +70,12 @@ static hpi_handler_func *hpi_lookup_entry_point_function(const struct hpi_pci
67static inline void hw_entry_point(struct hpi_message *phm, 70static inline void hw_entry_point(struct hpi_message *phm,
68 struct hpi_response *phr) 71 struct hpi_response *phr)
69{ 72{
70 73 if ((phm->adapter_index < HPI_MAX_ADAPTERS)
71 hpi_handler_func *ep; 74 && hpi_entry_points[phm->adapter_index])
72 75 hpi_entry_points[phm->adapter_index] (phm, phr);
73 if (phm->adapter_index < HPI_MAX_ADAPTERS) { 76 else
74 ep = (hpi_handler_func *) hpi_entry_points[phm-> 77 hpi_init_response(phr, phm->object, phm->function,
75 adapter_index]; 78 HPI_ERROR_PROCESSING_MESSAGE);
76 if (ep) {
77 HPI_DEBUG_MESSAGE(DEBUG, phm);
78 ep(phm, phr);
79 HPI_DEBUG_RESPONSE(phr);
80 return;
81 }
82 }
83 hpi_init_response(phr, phm->object, phm->function,
84 HPI_ERROR_PROCESSING_MESSAGE);
85} 79}
86 80
87static void adapter_open(struct hpi_message *phm, struct hpi_response *phr); 81static void adapter_open(struct hpi_message *phm, struct hpi_response *phr);
@@ -100,6 +94,7 @@ static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
100 void *h_owner); 94 void *h_owner);
101 95
102static void HPIMSGX__reset(u16 adapter_index); 96static void HPIMSGX__reset(u16 adapter_index);
97
103static u16 HPIMSGX__init(struct hpi_message *phm, struct hpi_response *phr); 98static u16 HPIMSGX__init(struct hpi_message *phm, struct hpi_response *phr);
104static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner); 99static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner);
105 100
@@ -153,8 +148,6 @@ static struct hpi_stream_response
153 148
154static struct hpi_mixer_response rESP_HPI_MIXER_OPEN[HPI_MAX_ADAPTERS]; 149static struct hpi_mixer_response rESP_HPI_MIXER_OPEN[HPI_MAX_ADAPTERS];
155 150
156static struct hpi_subsys_response gRESP_HPI_SUBSYS_FIND_ADAPTERS;
157
158static struct adapter_info aDAPTER_INFO[HPI_MAX_ADAPTERS]; 151static struct adapter_info aDAPTER_INFO[HPI_MAX_ADAPTERS];
159 152
160/* use these to keep track of opens from user mode apps/DLLs */ 153/* use these to keep track of opens from user mode apps/DLLs */
@@ -167,6 +160,11 @@ static struct asi_open_state
167static void subsys_message(struct hpi_message *phm, struct hpi_response *phr, 160static void subsys_message(struct hpi_message *phm, struct hpi_response *phr,
168 void *h_owner) 161 void *h_owner)
169{ 162{
163 if (phm->adapter_index != HPI_ADAPTER_INDEX_INVALID)
164 HPI_DEBUG_LOG(WARNING,
165 "suspicious adapter index %d in subsys message 0x%x.\n",
166 phm->adapter_index, phm->function);
167
170 switch (phm->function) { 168 switch (phm->function) {
171 case HPI_SUBSYS_GET_VERSION: 169 case HPI_SUBSYS_GET_VERSION:
172 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, 170 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
@@ -204,85 +202,19 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr,
204 HPI_SUBSYS_DRIVER_UNLOAD, 0); 202 HPI_SUBSYS_DRIVER_UNLOAD, 0);
205 return; 203 return;
206 204
207 case HPI_SUBSYS_GET_INFO:
208 HPI_COMMON(phm, phr);
209 break;
210
211 case HPI_SUBSYS_FIND_ADAPTERS:
212 memcpy(phr, &gRESP_HPI_SUBSYS_FIND_ADAPTERS,
213 sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS));
214 break;
215 case HPI_SUBSYS_GET_NUM_ADAPTERS: 205 case HPI_SUBSYS_GET_NUM_ADAPTERS:
216 memcpy(phr, &gRESP_HPI_SUBSYS_FIND_ADAPTERS,
217 sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS));
218 phr->function = HPI_SUBSYS_GET_NUM_ADAPTERS;
219 break;
220 case HPI_SUBSYS_GET_ADAPTER: 206 case HPI_SUBSYS_GET_ADAPTER:
221 { 207 HPI_COMMON(phm, phr);
222 int count = phm->adapter_index; 208 break;
223 int index = 0;
224 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
225 HPI_SUBSYS_GET_ADAPTER, 0);
226
227 /* This is complicated by the fact that we want to
228 * "skip" 0's in the adapter list.
229 * First, make sure we are pointing to a
230 * non-zero adapter type.
231 */
232 while (gRESP_HPI_SUBSYS_FIND_ADAPTERS.
233 s.aw_adapter_list[index] == 0) {
234 index++;
235 if (index >= HPI_MAX_ADAPTERS)
236 break;
237 }
238 while (count) {
239 /* move on to the next adapter */
240 index++;
241 if (index >= HPI_MAX_ADAPTERS)
242 break;
243 while (gRESP_HPI_SUBSYS_FIND_ADAPTERS.
244 s.aw_adapter_list[index] == 0) {
245 index++;
246 if (index >= HPI_MAX_ADAPTERS)
247 break;
248 }
249 count--;
250 }
251 209
252 if (index < HPI_MAX_ADAPTERS) {
253 phr->u.s.adapter_index = (u16)index;
254 phr->u.s.aw_adapter_list[0] =
255 gRESP_HPI_SUBSYS_FIND_ADAPTERS.
256 s.aw_adapter_list[index];
257 } else {
258 phr->u.s.adapter_index = 0;
259 phr->u.s.aw_adapter_list[0] = 0;
260 phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER;
261 }
262 break;
263 }
264 case HPI_SUBSYS_CREATE_ADAPTER: 210 case HPI_SUBSYS_CREATE_ADAPTER:
265 HPIMSGX__init(phm, phr); 211 HPIMSGX__init(phm, phr);
266 break; 212 break;
267 case HPI_SUBSYS_DELETE_ADAPTER: 213
268 HPIMSGX__cleanup(phm->adapter_index, h_owner);
269 {
270 struct hpi_message hm;
271 struct hpi_response hr;
272 /* call to HPI_ADAPTER_CLOSE */
273 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
274 HPI_ADAPTER_CLOSE);
275 hm.adapter_index = phm->adapter_index;
276 hw_entry_point(&hm, &hr);
277 }
278 hw_entry_point(phm, phr);
279 gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.
280 aw_adapter_list[phm->adapter_index]
281 = 0;
282 hpi_entry_points[phm->adapter_index] = NULL;
283 break;
284 default: 214 default:
285 hw_entry_point(phm, phr); 215 /* Must explicitly handle every subsys message in this switch */
216 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, phm->function,
217 HPI_ERROR_INVALID_FUNC);
286 break; 218 break;
287 } 219 }
288} 220}
@@ -297,6 +229,19 @@ static void adapter_message(struct hpi_message *phm, struct hpi_response *phr,
297 case HPI_ADAPTER_CLOSE: 229 case HPI_ADAPTER_CLOSE:
298 adapter_close(phm, phr); 230 adapter_close(phm, phr);
299 break; 231 break;
232 case HPI_ADAPTER_DELETE:
233 HPIMSGX__cleanup(phm->adapter_index, h_owner);
234 {
235 struct hpi_message hm;
236 struct hpi_response hr;
237 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
238 HPI_ADAPTER_CLOSE);
239 hm.adapter_index = phm->adapter_index;
240 hw_entry_point(&hm, &hr);
241 }
242 hw_entry_point(phm, phr);
243 break;
244
300 default: 245 default:
301 hw_entry_point(phm, phr); 246 hw_entry_point(phm, phr);
302 break; 247 break;
@@ -409,33 +354,7 @@ void hpi_send_recv_ex(struct hpi_message *phm, struct hpi_response *phr,
409 break; 354 break;
410 } 355 }
411 HPI_DEBUG_RESPONSE(phr); 356 HPI_DEBUG_RESPONSE(phr);
412#if 1 357
413 if (phr->error >= HPI_ERROR_BACKEND_BASE) {
414 void *ep = NULL;
415 char *ep_name;
416
417 HPI_DEBUG_MESSAGE(ERROR, phm);
418
419 if (phm->adapter_index < HPI_MAX_ADAPTERS)
420 ep = hpi_entry_points[phm->adapter_index];
421
422 /* Don't need this? Have adapter index in debug info
423 Know at driver load time index->backend mapping */
424 if (ep == HPI_6000)
425 ep_name = "HPI_6000";
426 else if (ep == HPI_6205)
427 ep_name = "HPI_6205";
428 else
429 ep_name = "unknown";
430
431 HPI_DEBUG_LOG(ERROR, "HPI %s response - error# %d\n", ep_name,
432 phr->error);
433
434 if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE)
435 hpi_debug_data((u16 *)phm,
436 sizeof(*phm) / sizeof(u16));
437 }
438#endif
439} 358}
440 359
441static void adapter_open(struct hpi_message *phm, struct hpi_response *phr) 360static void adapter_open(struct hpi_message *phm, struct hpi_response *phr)
@@ -484,7 +403,7 @@ static void instream_open(struct hpi_message *phm, struct hpi_response *phr,
484 else { 403 else {
485 instream_user_open[phm->adapter_index][phm-> 404 instream_user_open[phm->adapter_index][phm->
486 obj_index].open_flag = 1; 405 obj_index].open_flag = 1;
487 hpios_msgxlock_un_lock(&msgx_lock); 406 hpios_msgxlock_unlock(&msgx_lock);
488 407
489 /* issue a reset */ 408 /* issue a reset */
490 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 409 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
@@ -509,7 +428,7 @@ static void instream_open(struct hpi_message *phm, struct hpi_response *phr,
509 sizeof(rESP_HPI_ISTREAM_OPEN[0][0])); 428 sizeof(rESP_HPI_ISTREAM_OPEN[0][0]));
510 } 429 }
511 } 430 }
512 hpios_msgxlock_un_lock(&msgx_lock); 431 hpios_msgxlock_unlock(&msgx_lock);
513} 432}
514 433
515static void instream_close(struct hpi_message *phm, struct hpi_response *phr, 434static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
@@ -530,7 +449,7 @@ static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
530 phm->wAdapterIndex, phm->wObjIndex, hOwner); */ 449 phm->wAdapterIndex, phm->wObjIndex, hOwner); */
531 instream_user_open[phm->adapter_index][phm-> 450 instream_user_open[phm->adapter_index][phm->
532 obj_index].h_owner = NULL; 451 obj_index].h_owner = NULL;
533 hpios_msgxlock_un_lock(&msgx_lock); 452 hpios_msgxlock_unlock(&msgx_lock);
534 /* issue a reset */ 453 /* issue a reset */
535 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 454 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
536 HPI_ISTREAM_RESET); 455 HPI_ISTREAM_RESET);
@@ -556,7 +475,7 @@ static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
556 obj_index].h_owner); 475 obj_index].h_owner);
557 phr->error = HPI_ERROR_OBJ_NOT_OPEN; 476 phr->error = HPI_ERROR_OBJ_NOT_OPEN;
558 } 477 }
559 hpios_msgxlock_un_lock(&msgx_lock); 478 hpios_msgxlock_unlock(&msgx_lock);
560} 479}
561 480
562static void outstream_open(struct hpi_message *phm, struct hpi_response *phr, 481static void outstream_open(struct hpi_message *phm, struct hpi_response *phr,
@@ -581,7 +500,7 @@ static void outstream_open(struct hpi_message *phm, struct hpi_response *phr,
581 else { 500 else {
582 outstream_user_open[phm->adapter_index][phm-> 501 outstream_user_open[phm->adapter_index][phm->
583 obj_index].open_flag = 1; 502 obj_index].open_flag = 1;
584 hpios_msgxlock_un_lock(&msgx_lock); 503 hpios_msgxlock_unlock(&msgx_lock);
585 504
586 /* issue a reset */ 505 /* issue a reset */
587 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 506 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
@@ -606,7 +525,7 @@ static void outstream_open(struct hpi_message *phm, struct hpi_response *phr,
606 sizeof(rESP_HPI_OSTREAM_OPEN[0][0])); 525 sizeof(rESP_HPI_OSTREAM_OPEN[0][0]));
607 } 526 }
608 } 527 }
609 hpios_msgxlock_un_lock(&msgx_lock); 528 hpios_msgxlock_unlock(&msgx_lock);
610} 529}
611 530
612static void outstream_close(struct hpi_message *phm, struct hpi_response *phr, 531static void outstream_close(struct hpi_message *phm, struct hpi_response *phr,
@@ -628,7 +547,7 @@ static void outstream_close(struct hpi_message *phm, struct hpi_response *phr,
628 phm->wAdapterIndex, phm->wObjIndex, hOwner); */ 547 phm->wAdapterIndex, phm->wObjIndex, hOwner); */
629 outstream_user_open[phm->adapter_index][phm-> 548 outstream_user_open[phm->adapter_index][phm->
630 obj_index].h_owner = NULL; 549 obj_index].h_owner = NULL;
631 hpios_msgxlock_un_lock(&msgx_lock); 550 hpios_msgxlock_unlock(&msgx_lock);
632 /* issue a reset */ 551 /* issue a reset */
633 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 552 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
634 HPI_OSTREAM_RESET); 553 HPI_OSTREAM_RESET);
@@ -654,7 +573,7 @@ static void outstream_close(struct hpi_message *phm, struct hpi_response *phr,
654 obj_index].h_owner); 573 obj_index].h_owner);
655 phr->error = HPI_ERROR_OBJ_NOT_OPEN; 574 phr->error = HPI_ERROR_OBJ_NOT_OPEN;
656 } 575 }
657 hpios_msgxlock_un_lock(&msgx_lock); 576 hpios_msgxlock_unlock(&msgx_lock);
658} 577}
659 578
660static u16 adapter_prepare(u16 adapter) 579static u16 adapter_prepare(u16 adapter)
@@ -683,16 +602,9 @@ static u16 adapter_prepare(u16 adapter)
683 if (hr.error) 602 if (hr.error)
684 return hr.error; 603 return hr.error;
685 604
686 aDAPTER_INFO[adapter].num_outstreams = hr.u.a.num_outstreams; 605 aDAPTER_INFO[adapter].num_outstreams = hr.u.ax.info.num_outstreams;
687 aDAPTER_INFO[adapter].num_instreams = hr.u.a.num_instreams; 606 aDAPTER_INFO[adapter].num_instreams = hr.u.ax.info.num_instreams;
688 aDAPTER_INFO[adapter].type = hr.u.a.adapter_type; 607 aDAPTER_INFO[adapter].type = hr.u.ax.info.adapter_type;
689
690 gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list[adapter] =
691 hr.u.a.adapter_type;
692 gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters++;
693 if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters > HPI_MAX_ADAPTERS)
694 gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters =
695 HPI_MAX_ADAPTERS;
696 608
697 /* call to HPI_OSTREAM_OPEN */ 609 /* call to HPI_OSTREAM_OPEN */
698 for (i = 0; i < aDAPTER_INFO[adapter].num_outstreams; i++) { 610 for (i = 0; i < aDAPTER_INFO[adapter].num_outstreams; i++) {
@@ -727,7 +639,7 @@ static u16 adapter_prepare(u16 adapter)
727 memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr, 639 memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr,
728 sizeof(rESP_HPI_MIXER_OPEN[0])); 640 sizeof(rESP_HPI_MIXER_OPEN[0]));
729 641
730 return gRESP_HPI_SUBSYS_FIND_ADAPTERS.h.error; 642 return 0;
731} 643}
732 644
733static void HPIMSGX__reset(u16 adapter_index) 645static void HPIMSGX__reset(u16 adapter_index)
@@ -737,12 +649,6 @@ static void HPIMSGX__reset(u16 adapter_index)
737 struct hpi_response hr; 649 struct hpi_response hr;
738 650
739 if (adapter_index == HPIMSGX_ALLADAPTERS) { 651 if (adapter_index == HPIMSGX_ALLADAPTERS) {
740 /* reset all responses to contain errors */
741 hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM,
742 HPI_SUBSYS_FIND_ADAPTERS, 0);
743 memcpy(&gRESP_HPI_SUBSYS_FIND_ADAPTERS, &hr,
744 sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS));
745
746 for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) { 652 for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) {
747 653
748 hpi_init_response(&hr, HPI_OBJ_ADAPTER, 654 hpi_init_response(&hr, HPI_OBJ_ADAPTER,
@@ -783,12 +689,6 @@ static void HPIMSGX__reset(u16 adapter_index)
783 rESP_HPI_ISTREAM_OPEN[adapter_index][i].h.error = 689 rESP_HPI_ISTREAM_OPEN[adapter_index][i].h.error =
784 HPI_ERROR_INVALID_OBJ; 690 HPI_ERROR_INVALID_OBJ;
785 } 691 }
786 if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.
787 s.aw_adapter_list[adapter_index]) {
788 gRESP_HPI_SUBSYS_FIND_ADAPTERS.
789 s.aw_adapter_list[adapter_index] = 0;
790 gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters--;
791 }
792 } 692 }
793} 693}
794 694
@@ -802,15 +702,9 @@ static u16 HPIMSGX__init(struct hpi_message *phm,
802 hpi_handler_func *entry_point_func; 702 hpi_handler_func *entry_point_func;
803 struct hpi_response hr; 703 struct hpi_response hr;
804 704
805 if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters >= HPI_MAX_ADAPTERS)
806 return HPI_ERROR_BAD_ADAPTER_NUMBER;
807
808 /* Init response here so we can pass in previous adapter list */ 705 /* Init response here so we can pass in previous adapter list */
809 hpi_init_response(&hr, phm->object, phm->function, 706 hpi_init_response(&hr, phm->object, phm->function,
810 HPI_ERROR_INVALID_OBJ); 707 HPI_ERROR_INVALID_OBJ);
811 memcpy(hr.u.s.aw_adapter_list,
812 gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list,
813 sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list));
814 708
815 entry_point_func = 709 entry_point_func =
816 hpi_lookup_entry_point_function(phm->u.s.resource.r.pci); 710 hpi_lookup_entry_point_function(phm->u.s.resource.r.pci);
@@ -823,7 +717,7 @@ static u16 HPIMSGX__init(struct hpi_message *phm,
823 return phr->error; 717 return phr->error;
824 } 718 }
825 if (hr.error == 0) { 719 if (hr.error == 0) {
826 /* the adapter was created succesfully 720 /* the adapter was created successfully
827 save the mapping for future use */ 721 save the mapping for future use */
828 hpi_entry_points[hr.u.s.adapter_index] = entry_point_func; 722 hpi_entry_points[hr.u.s.adapter_index] = entry_point_func;
829 /* prepare adapter (pre-open streams etc.) */ 723 /* prepare adapter (pre-open streams etc.) */
@@ -860,7 +754,7 @@ static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner)
860 struct hpi_response hr; 754 struct hpi_response hr;
861 755
862 HPI_DEBUG_LOG(DEBUG, 756 HPI_DEBUG_LOG(DEBUG,
863 "close adapter %d ostream %d\n", 757 "Close adapter %d ostream %d\n",
864 adapter, i); 758 adapter, i);
865 759
866 hpi_init_message_response(&hm, &hr, 760 hpi_init_message_response(&hm, &hr,
@@ -884,7 +778,7 @@ static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner)
884 struct hpi_response hr; 778 struct hpi_response hr;
885 779
886 HPI_DEBUG_LOG(DEBUG, 780 HPI_DEBUG_LOG(DEBUG,
887 "close adapter %d istream %d\n", 781 "Close adapter %d istream %d\n",
888 adapter, i); 782 adapter, i);
889 783
890 hpi_init_message_response(&hm, &hr, 784 hpi_init_message_response(&hm, &hr,
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index 62895a719fcb..d8e7047512f8 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -25,11 +25,13 @@ Common Linux HPI ioctl and module probe/remove functions
25#include "hpidebug.h" 25#include "hpidebug.h"
26#include "hpimsgx.h" 26#include "hpimsgx.h"
27#include "hpioctl.h" 27#include "hpioctl.h"
28#include "hpicmn.h"
28 29
29#include <linux/fs.h> 30#include <linux/fs.h>
30#include <linux/slab.h> 31#include <linux/slab.h>
31#include <linux/moduleparam.h> 32#include <linux/moduleparam.h>
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
34#include <linux/pci.h>
33#include <linux/stringify.h> 35#include <linux/stringify.h>
34 36
35#ifdef MODULE_FIRMWARE 37#ifdef MODULE_FIRMWARE
@@ -45,7 +47,7 @@ MODULE_FIRMWARE("asihpi/dsp8900.bin");
45static int prealloc_stream_buf; 47static int prealloc_stream_buf;
46module_param(prealloc_stream_buf, int, S_IRUGO); 48module_param(prealloc_stream_buf, int, S_IRUGO);
47MODULE_PARM_DESC(prealloc_stream_buf, 49MODULE_PARM_DESC(prealloc_stream_buf,
48 "preallocate size for per-adapter stream buffer"); 50 "Preallocate size for per-adapter stream buffer");
49 51
50/* Allow the debug level to be changed after module load. 52/* Allow the debug level to be changed after module load.
51 E.g. echo 2 > /sys/module/asihpi/parameters/hpiDebugLevel 53 E.g. echo 2 > /sys/module/asihpi/parameters/hpiDebugLevel
@@ -121,8 +123,8 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
121 phpi_ioctl_data = (struct hpi_ioctl_linux __user *)arg; 123 phpi_ioctl_data = (struct hpi_ioctl_linux __user *)arg;
122 124
123 /* Read the message and response pointers from user space. */ 125 /* Read the message and response pointers from user space. */
124 if (get_user(puhm, &phpi_ioctl_data->phm) || 126 if (get_user(puhm, &phpi_ioctl_data->phm)
125 get_user(puhr, &phpi_ioctl_data->phr)) { 127 || get_user(puhr, &phpi_ioctl_data->phr)) {
126 err = -EFAULT; 128 err = -EFAULT;
127 goto out; 129 goto out;
128 } 130 }
@@ -135,7 +137,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
135 if (hm->h.size > sizeof(*hm)) 137 if (hm->h.size > sizeof(*hm))
136 hm->h.size = sizeof(*hm); 138 hm->h.size = sizeof(*hm);
137 139
138 /*printk(KERN_INFO "message size %d\n", hm->h.wSize); */ 140 /* printk(KERN_INFO "message size %d\n", hm->h.wSize); */
139 141
140 uncopied_bytes = copy_from_user(hm, puhm, hm->h.size); 142 uncopied_bytes = copy_from_user(hm, puhm, hm->h.size);
141 if (uncopied_bytes) { 143 if (uncopied_bytes) {
@@ -155,26 +157,29 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
155 goto out; 157 goto out;
156 } 158 }
157 159
158 pa = &adapters[hm->h.adapter_index]; 160 if (hm->h.adapter_index >= HPI_MAX_ADAPTERS) {
159 hr->h.size = 0; 161 err = -EINVAL;
160 if (hm->h.object == HPI_OBJ_SUBSYSTEM) { 162 goto out;
161 switch (hm->h.function) { 163 }
162 case HPI_SUBSYS_CREATE_ADAPTER:
163 case HPI_SUBSYS_DELETE_ADAPTER:
164 /* Application must not use these functions! */
165 hr->h.size = sizeof(hr->h);
166 hr->h.error = HPI_ERROR_INVALID_OPERATION;
167 hr->h.function = hm->h.function;
168 uncopied_bytes = copy_to_user(puhr, hr, hr->h.size);
169 if (uncopied_bytes)
170 err = -EFAULT;
171 else
172 err = 0;
173 goto out;
174 164
175 default: 165 switch (hm->h.function) {
176 hpi_send_recv_f(&hm->m0, &hr->r0, file); 166 case HPI_SUBSYS_CREATE_ADAPTER:
177 } 167 case HPI_ADAPTER_DELETE:
168 /* Application must not use these functions! */
169 hr->h.size = sizeof(hr->h);
170 hr->h.error = HPI_ERROR_INVALID_OPERATION;
171 hr->h.function = hm->h.function;
172 uncopied_bytes = copy_to_user(puhr, hr, hr->h.size);
173 if (uncopied_bytes)
174 err = -EFAULT;
175 else
176 err = 0;
177 goto out;
178 }
179
180 hr->h.size = res_max_size;
181 if (hm->h.object == HPI_OBJ_SUBSYSTEM) {
182 hpi_send_recv_f(&hm->m0, &hr->r0, file);
178 } else { 183 } else {
179 u16 __user *ptr = NULL; 184 u16 __user *ptr = NULL;
180 u32 size = 0; 185 u32 size = 0;
@@ -182,8 +187,9 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
182 /* -1=no data 0=read from user mem, 1=write to user mem */ 187 /* -1=no data 0=read from user mem, 1=write to user mem */
183 int wrflag = -1; 188 int wrflag = -1;
184 u32 adapter = hm->h.adapter_index; 189 u32 adapter = hm->h.adapter_index;
190 pa = &adapters[adapter];
185 191
186 if ((hm->h.adapter_index > HPI_MAX_ADAPTERS) || (!pa->type)) { 192 if ((adapter > HPI_MAX_ADAPTERS) || (!pa->type)) {
187 hpi_init_response(&hr->r0, HPI_OBJ_ADAPTER, 193 hpi_init_response(&hr->r0, HPI_OBJ_ADAPTER,
188 HPI_ADAPTER_OPEN, 194 HPI_ADAPTER_OPEN,
189 HPI_ERROR_BAD_ADAPTER_NUMBER); 195 HPI_ERROR_BAD_ADAPTER_NUMBER);
@@ -216,7 +222,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
216 */ 222 */
217 if (pa->buffer_size < size) { 223 if (pa->buffer_size < size) {
218 HPI_DEBUG_LOG(DEBUG, 224 HPI_DEBUG_LOG(DEBUG,
219 "realloc adapter %d stream " 225 "Realloc adapter %d stream "
220 "buffer from %zd to %d\n", 226 "buffer from %zd to %d\n",
221 hm->h.adapter_index, 227 hm->h.adapter_index,
222 pa->buffer_size, size); 228 pa->buffer_size, size);
@@ -259,7 +265,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
259 copy_from_user(pa->p_buffer, ptr, size); 265 copy_from_user(pa->p_buffer, ptr, size);
260 if (uncopied_bytes) 266 if (uncopied_bytes)
261 HPI_DEBUG_LOG(WARNING, 267 HPI_DEBUG_LOG(WARNING,
262 "missed %d of %d " 268 "Missed %d of %d "
263 "bytes from user\n", uncopied_bytes, 269 "bytes from user\n", uncopied_bytes,
264 size); 270 size);
265 } 271 }
@@ -271,7 +277,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
271 copy_to_user(ptr, pa->p_buffer, size); 277 copy_to_user(ptr, pa->p_buffer, size);
272 if (uncopied_bytes) 278 if (uncopied_bytes)
273 HPI_DEBUG_LOG(WARNING, 279 HPI_DEBUG_LOG(WARNING,
274 "missed %d of %d " "bytes to user\n", 280 "Missed %d of %d " "bytes to user\n",
275 uncopied_bytes, size); 281 uncopied_bytes, size);
276 } 282 }
277 283
@@ -290,9 +296,9 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
290 if (hr->h.size > res_max_size) { 296 if (hr->h.size > res_max_size) {
291 HPI_DEBUG_LOG(ERROR, "response too big %d %d\n", hr->h.size, 297 HPI_DEBUG_LOG(ERROR, "response too big %d %d\n", hr->h.size,
292 res_max_size); 298 res_max_size);
293 /*HPI_DEBUG_MESSAGE(ERROR, hm); */ 299 hr->h.error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
294 err = -EFAULT; 300 hr->h.specific_error = hr->h.size;
295 goto out; 301 hr->h.size = sizeof(hr->h);
296 } 302 }
297 303
298 uncopied_bytes = copy_to_user(puhr, hr, hr->h.size); 304 uncopied_bytes = copy_to_user(puhr, hr, hr->h.size);
@@ -311,7 +317,7 @@ out:
311int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, 317int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
312 const struct pci_device_id *pci_id) 318 const struct pci_device_id *pci_id)
313{ 319{
314 int err, idx, nm; 320 int idx, nm;
315 unsigned int memlen; 321 unsigned int memlen;
316 struct hpi_message hm; 322 struct hpi_message hm;
317 struct hpi_response hr; 323 struct hpi_response hr;
@@ -320,28 +326,33 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
320 326
321 memset(&adapter, 0, sizeof(adapter)); 327 memset(&adapter, 0, sizeof(adapter));
322 328
323 printk(KERN_DEBUG "probe PCI device (%04x:%04x,%04x:%04x,%04x)\n", 329 dev_printk(KERN_DEBUG, &pci_dev->dev,
324 pci_dev->vendor, pci_dev->device, pci_dev->subsystem_vendor, 330 "probe %04x:%04x,%04x:%04x,%04x\n", pci_dev->vendor,
331 pci_dev->device, pci_dev->subsystem_vendor,
325 pci_dev->subsystem_device, pci_dev->devfn); 332 pci_dev->subsystem_device, pci_dev->devfn);
326 333
334 if (pci_enable_device(pci_dev) < 0) {
335 dev_printk(KERN_ERR, &pci_dev->dev,
336 "pci_enable_device failed, disabling device\n");
337 return -EIO;
338 }
339
340 pci_set_master(pci_dev); /* also sets latency timer if < 16 */
341
327 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 342 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
328 HPI_SUBSYS_CREATE_ADAPTER); 343 HPI_SUBSYS_CREATE_ADAPTER);
329 hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CREATE_ADAPTER, 344 hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CREATE_ADAPTER,
330 HPI_ERROR_PROCESSING_MESSAGE); 345 HPI_ERROR_PROCESSING_MESSAGE);
331 346
332 hm.adapter_index = -1; /* an invalid index */ 347 hm.adapter_index = HPI_ADAPTER_INDEX_INVALID;
333 348
334 /* fill in HPI_PCI information from kernel provided information */
335 adapter.pci = pci_dev; 349 adapter.pci = pci_dev;
336 350
337 nm = HPI_MAX_ADAPTER_MEM_SPACES; 351 nm = HPI_MAX_ADAPTER_MEM_SPACES;
338 352
339 for (idx = 0; idx < nm; idx++) { 353 for (idx = 0; idx < nm; idx++) {
340 HPI_DEBUG_LOG(INFO, "resource %d %s %08llx-%08llx %04llx\n", 354 HPI_DEBUG_LOG(INFO, "resource %d %pR\n", idx,
341 idx, pci_dev->resource[idx].name, 355 &pci_dev->resource[idx]);
342 (unsigned long long)pci_resource_start(pci_dev, idx),
343 (unsigned long long)pci_resource_end(pci_dev, idx),
344 (unsigned long long)pci_resource_flags(pci_dev, idx));
345 356
346 if (pci_resource_flags(pci_dev, idx) & IORESOURCE_MEM) { 357 if (pci_resource_flags(pci_dev, idx) & IORESOURCE_MEM) {
347 memlen = pci_resource_len(pci_dev, idx); 358 memlen = pci_resource_len(pci_dev, idx);
@@ -359,19 +370,7 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
359 pci.ap_mem_base[idx] = adapter.ap_remapped_mem_base[idx]; 370 pci.ap_mem_base[idx] = adapter.ap_remapped_mem_base[idx];
360 } 371 }
361 372
362 /* could replace Pci with direct pointer to pci_dev for linux 373 pci.pci_dev = pci_dev;
363 Instead wrap accessor functions for IDs etc.
364 Would it work for windows?
365 */
366 pci.bus_number = pci_dev->bus->number;
367 pci.vendor_id = (u16)pci_dev->vendor;
368 pci.device_id = (u16)pci_dev->device;
369 pci.subsys_vendor_id = (u16)(pci_dev->subsystem_vendor & 0xffff);
370 pci.subsys_device_id = (u16)(pci_dev->subsystem_device & 0xffff);
371 pci.device_number = pci_dev->devfn;
372 pci.interrupt = pci_dev->irq;
373 pci.p_os_data = pci_dev;
374
375 hm.u.s.resource.bus_type = HPI_BUS_PCI; 374 hm.u.s.resource.bus_type = HPI_BUS_PCI;
376 hm.u.s.resource.r.pci = &pci; 375 hm.u.s.resource.r.pci = &pci;
377 376
@@ -392,23 +391,27 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
392 } 391 }
393 392
394 adapter.index = hr.u.s.adapter_index; 393 adapter.index = hr.u.s.adapter_index;
395 adapter.type = hr.u.s.aw_adapter_list[adapter.index]; 394 adapter.type = hr.u.s.adapter_type;
395
396 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
397 HPI_ADAPTER_OPEN);
396 hm.adapter_index = adapter.index; 398 hm.adapter_index = adapter.index;
399 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL);
397 400
398 err = hpi_adapter_open(NULL, adapter.index); 401 if (hr.error)
399 if (err)
400 goto err; 402 goto err;
401 403
402 adapter.snd_card_asihpi = NULL; 404 adapter.snd_card_asihpi = NULL;
403 /* WARNING can't init mutex in 'adapter' 405 /* WARNING can't init mutex in 'adapter'
404 * and then copy it to adapters[] ?!?! 406 * and then copy it to adapters[] ?!?!
405 */ 407 */
406 adapters[hr.u.s.adapter_index] = adapter; 408 adapters[adapter.index] = adapter;
407 mutex_init(&adapters[adapter.index].mutex); 409 mutex_init(&adapters[adapter.index].mutex);
408 pci_set_drvdata(pci_dev, &adapters[adapter.index]); 410 pci_set_drvdata(pci_dev, &adapters[adapter.index]);
409 411
410 printk(KERN_INFO "probe found adapter ASI%04X HPI index #%d.\n", 412 dev_printk(KERN_INFO, &pci_dev->dev,
411 adapter.type, adapter.index); 413 "probe succeeded for ASI%04X HPI index %d\n", adapter.type,
414 adapter.index);
412 415
413 return 0; 416 return 0;
414 417
@@ -435,10 +438,10 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev)
435 struct hpi_message hm; 438 struct hpi_message hm;
436 struct hpi_response hr; 439 struct hpi_response hr;
437 struct hpi_adapter *pa; 440 struct hpi_adapter *pa;
438 pa = (struct hpi_adapter *)pci_get_drvdata(pci_dev); 441 pa = pci_get_drvdata(pci_dev);
439 442
440 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 443 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
441 HPI_SUBSYS_DELETE_ADAPTER); 444 HPI_ADAPTER_DELETE);
442 hm.adapter_index = pa->index; 445 hm.adapter_index = pa->index;
443 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); 446 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL);
444 447
@@ -450,20 +453,18 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev)
450 } 453 }
451 } 454 }
452 455
453 if (pa->p_buffer) { 456 if (pa->p_buffer)
454 pa->buffer_size = 0;
455 vfree(pa->p_buffer); 457 vfree(pa->p_buffer);
456 }
457 458
458 pci_set_drvdata(pci_dev, NULL); 459 pci_set_drvdata(pci_dev, NULL);
459 /* 460 if (1)
460 printk(KERN_INFO "PCI device (%04x:%04x,%04x:%04x,%04x)," 461 dev_printk(KERN_INFO, &pci_dev->dev,
461 " HPI index # %d, removed.\n", 462 "remove %04x:%04x,%04x:%04x,%04x," " HPI index %d.\n",
462 pci_dev->vendor, pci_dev->device, 463 pci_dev->vendor, pci_dev->device,
463 pci_dev->subsystem_vendor, 464 pci_dev->subsystem_vendor, pci_dev->subsystem_device,
464 pci_dev->subsystem_device, pci_dev->devfn, 465 pci_dev->devfn, pa->index);
465 pa->index); 466
466 */ 467 memset(pa, 0, sizeof(*pa));
467} 468}
468 469
469void __init asihpi_init(void) 470void __init asihpi_init(void)
diff --git a/sound/pci/asihpi/hpios.h b/sound/pci/asihpi/hpios.h
index 370f39b43f85..03273e729f99 100644
--- a/sound/pci/asihpi/hpios.h
+++ b/sound/pci/asihpi/hpios.h
@@ -27,9 +27,7 @@ HPI Operating System Specific macros for Linux Kernel driver
27#define HPI_OS_LINUX_KERNEL 27#define HPI_OS_LINUX_KERNEL
28 28
29#define HPI_OS_DEFINED 29#define HPI_OS_DEFINED
30#define HPI_KERNEL_MODE 30#define HPI_BUILD_KERNEL_MODE
31
32#define HPI_REASSIGN_DUPLICATE_ADAPTER_IDX
33 31
34#include <linux/io.h> 32#include <linux/io.h>
35#include <asm/system.h> 33#include <asm/system.h>
@@ -135,20 +133,20 @@ static inline void cond_unlock(struct hpios_spinlock *l)
135 133
136#define hpios_msgxlock_init(obj) spin_lock_init(&(obj)->lock) 134#define hpios_msgxlock_init(obj) spin_lock_init(&(obj)->lock)
137#define hpios_msgxlock_lock(obj) cond_lock(obj) 135#define hpios_msgxlock_lock(obj) cond_lock(obj)
138#define hpios_msgxlock_un_lock(obj) cond_unlock(obj) 136#define hpios_msgxlock_unlock(obj) cond_unlock(obj)
139 137
140#define hpios_dsplock_init(obj) spin_lock_init(&(obj)->dsp_lock.lock) 138#define hpios_dsplock_init(obj) spin_lock_init(&(obj)->dsp_lock.lock)
141#define hpios_dsplock_lock(obj) cond_lock(&(obj)->dsp_lock) 139#define hpios_dsplock_lock(obj) cond_lock(&(obj)->dsp_lock)
142#define hpios_dsplock_unlock(obj) cond_unlock(&(obj)->dsp_lock) 140#define hpios_dsplock_unlock(obj) cond_unlock(&(obj)->dsp_lock)
143 141
144#ifdef CONFIG_SND_DEBUG 142#ifdef CONFIG_SND_DEBUG
145#define HPI_DEBUG 143#define HPI_BUILD_DEBUG
146#endif 144#endif
147 145
148#define HPI_ALIST_LOCKING 146#define HPI_ALIST_LOCKING
149#define hpios_alistlock_init(obj) spin_lock_init(&((obj)->list_lock.lock)) 147#define hpios_alistlock_init(obj) spin_lock_init(&((obj)->list_lock.lock))
150#define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock)) 148#define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock))
151#define hpios_alistlock_un_lock(obj) spin_unlock(&((obj)->list_lock.lock)) 149#define hpios_alistlock_unlock(obj) spin_unlock(&((obj)->list_lock.lock))
152 150
153struct hpi_adapter { 151struct hpi_adapter {
154 /* mutex prevents contention for one card 152 /* mutex prevents contention for one card