diff options
author | Jaroslav Kysela <perex@perex.cz> | 2010-04-16 09:27:40 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2010-04-16 09:27:40 +0200 |
commit | 4c003ad941d619afdb96f13192f32c924cfb0a6b (patch) | |
tree | c2dc1c629f5117b6b0e30ab540b479f805b29185 | |
parent | 2ed2288b6fca780faf7b28efb38119528bb44a81 (diff) | |
parent | 2afa3a921bf022e43c72b1a9e78eefc6c4fe1b4d (diff) | |
download | alsa-driver-build-unstable-4c003ad941d619afdb96f13192f32c924cfb0a6b.tar.gz |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/alsa-driver-build
Conflicts:
include/adriver.h
31 files changed, 6759 insertions, 9041 deletions
diff --git a/acore/control.patch b/acore/control.patch index 4b67090b6..28e2d51bb 100644 --- a/acore/control.patch +++ b/acore/control.patch @@ -1,5 +1,5 @@ ---- ../alsa-kernel/core/control.c 2009-11-18 14:27:35.000000000 +0100 -+++ control.c 2009-12-15 22:17:50.000000000 +0100 +--- ../alsa-kernel/core/control.c 2010-04-13 12:01:49.080966488 +0200 ++++ control.c 2010-04-13 13:03:53.852789224 +0200 @@ -1,3 +1,5 @@ +#define __NO_VERSION__ +#include "adriver.h" @@ -14,7 +14,7 @@ #include <linux/slab.h> #include <linux/vmalloc.h> #include <linux/time.h> -@@ -727,6 +730,10 @@ +@@ -732,6 +735,10 @@ return result; } @@ -25,7 +25,7 @@ static int snd_ctl_elem_read_user(struct snd_card *card, struct snd_ctl_elem_value __user *_control) { -@@ -783,6 +790,10 @@ +@@ -788,6 +795,10 @@ return result; } @@ -36,7 +36,7 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file, struct snd_ctl_elem_value __user *_control) { -@@ -1371,25 +1382,44 @@ +@@ -1376,26 +1387,45 @@ /* * ioctl32 compat */ @@ -72,8 +72,9 @@ .read = snd_ctl_read, .open = snd_ctl_open, .release = snd_ctl_release, - .poll = snd_ctl_poll, + .llseek = no_llseek, +#ifdef CONFIG_SND_HAVE_NEW_IOCTL + .poll = snd_ctl_poll, .unlocked_ioctl = snd_ctl_ioctl, .compat_ioctl = snd_ctl_ioctl_compat, +#else diff --git a/acore/info.patch b/acore/info.patch index b0a58d4ce..eba6f6083 100644 --- a/acore/info.patch +++ b/acore/info.patch @@ -1,5 +1,5 @@ ---- ../alsa-kernel/core/info.c 2009-07-06 14:32:55.000000000 +0200 -+++ info.c 2009-07-06 14:39:42.000000000 +0200 +--- ../alsa-kernel/core/info.c 2010-04-09 17:37:52.473468020 +0200 ++++ info.c 2010-04-09 19:27:27.688965183 +0200 @@ -1,3 +1,4 @@ +#include "info.inc" /* @@ -39,27 +39,7 @@ static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig) { struct snd_info_private_data *data; -@@ -167,7 +169,9 @@ - - data = file->private_data; - entry = data->entry; -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 3) - lock_kernel(); -+#endif - switch (entry->content) { - case SNDRV_INFO_CONTENT_TEXT: - switch (orig) { -@@ -196,7 +200,9 @@ - } - ret = -ENXIO; - out: -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 3) - unlock_kernel(); -+#endif - return ret; - } - -@@ -481,9 +487,26 @@ +@@ -481,9 +483,26 @@ return -ENOTTY; } @@ -86,7 +66,7 @@ struct snd_info_private_data *data; struct snd_info_entry *entry; -@@ -504,22 +527,35 @@ +@@ -504,22 +523,35 @@ static const struct file_operations snd_info_entry_operations = { @@ -123,7 +103,7 @@ if (p == NULL) return -ENOMEM; snd_proc_root = p; -@@ -907,6 +943,7 @@ +@@ -907,6 +939,7 @@ EXPORT_SYMBOL(snd_card_proc_new); @@ -131,7 +111,7 @@ /** * snd_info_free_entry - release the info entry * @entry: the info entry -@@ -946,13 +983,21 @@ +@@ -946,13 +979,21 @@ return -ENXIO; root = entry->parent == NULL ? snd_proc_root : entry->parent->p; mutex_lock(&info_mutex); @@ -155,7 +135,7 @@ p->size = entry->size; p->data = entry; entry->p = p; -@@ -972,9 +1017,19 @@ +@@ -972,9 +1013,19 @@ static void snd_info_version_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { diff --git a/acore/oss/mixer_oss.patch b/acore/oss/mixer_oss.patch index 46825b5fb..6e66b4fc7 100644 --- a/acore/oss/mixer_oss.patch +++ b/acore/oss/mixer_oss.patch @@ -1,5 +1,5 @@ ---- ../../alsa-kernel/core/oss/mixer_oss.c 2007-12-20 10:19:01.000000000 +0100 -+++ mixer_oss.c 2007-12-20 10:45:48.000000000 +0100 +--- ../../alsa-kernel/core/oss/mixer_oss.c 2010-04-13 12:01:49.080966488 +0200 ++++ mixer_oss.c 2010-04-13 13:07:14.784700677 +0200 @@ -1,3 +1,4 @@ +#include "adriver.h" /* @@ -13,7 +13,7 @@ #include <linux/slab.h> #include <linux/time.h> #include <linux/string.h> -@@ -377,24 +379,43 @@ +@@ -385,25 +387,44 @@ return snd_mixer_oss_ioctl1(&fmixer, cmd, arg); } @@ -49,6 +49,7 @@ +#endif .open = snd_mixer_oss_open, .release = snd_mixer_oss_release, + .llseek = no_llseek, +#ifdef CONFIG_SND_HAVE_NEW_IOCTL .unlocked_ioctl = snd_mixer_oss_ioctl, .compat_ioctl = snd_mixer_oss_ioctl_compat, diff --git a/acore/oss/pcm_oss.patch b/acore/oss/pcm_oss.patch index ea2b5d211..4c8666c95 100644 --- a/acore/oss/pcm_oss.patch +++ b/acore/oss/pcm_oss.patch @@ -1,5 +1,5 @@ ---- ../../../alsa-kmirror/core/oss/pcm_oss.c 2009-04-08 12:30:58.000000000 +0200 -+++ pcm_oss.c 2009-04-08 16:08:18.000000000 +0200 +--- ../../alsa-kernel/core/oss/pcm_oss.c 2010-04-13 12:01:49.084966034 +0200 ++++ pcm_oss.c 2010-04-13 13:10:22.969200644 +0200 @@ -1,3 +1,4 @@ +#include "adriver.h" /* @@ -13,7 +13,7 @@ #include <linux/slab.h> #include <linux/time.h> #include <linux/vmalloc.h> -@@ -1903,9 +1905,13 @@ static int snd_pcm_oss_set_fragment(stru +@@ -1913,9 +1915,13 @@ static int snd_pcm_oss_nonblock(struct file * file) { @@ -27,7 +27,7 @@ return 0; } -@@ -2617,13 +2623,26 @@ static long snd_pcm_oss_ioctl(struct fil +@@ -2634,13 +2640,26 @@ return -EINVAL; } @@ -55,7 +55,7 @@ static ssize_t snd_pcm_oss_read(struct file *file, char __user *buf, size_t count, loff_t *offset) { struct snd_pcm_oss_file *pcm_oss_file; -@@ -2656,8 +2675,14 @@ static ssize_t snd_pcm_oss_write(struct +@@ -2673,8 +2692,14 @@ substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; if (substream == NULL) return -ENXIO; @@ -70,7 +70,7 @@ #ifdef OSS_DEBUG printk(KERN_DEBUG "pcm_oss: write %li bytes (wrote %li bytes)\n", (long)count, (long)result); -@@ -2774,7 +2799,11 @@ static int snd_pcm_oss_mmap(struct file +@@ -2795,7 +2820,11 @@ return -EIO; #endif @@ -82,7 +82,7 @@ return -EINVAL; err = snd_pcm_mmap_data(substream, file, area); -@@ -2954,14 +2983,20 @@ static void snd_pcm_oss_proc_done(struct +@@ -2976,15 +3005,21 @@ static const struct file_operations snd_pcm_oss_f_reg = { @@ -93,6 +93,7 @@ .write = snd_pcm_oss_write, .open = snd_pcm_oss_open, .release = snd_pcm_oss_release, + .llseek = no_llseek, .poll = snd_pcm_oss_poll, +#ifdef CONFIG_SND_HAVE_NEW_IOCTL .unlocked_ioctl = snd_pcm_oss_ioctl, @@ -103,7 +104,7 @@ .mmap = snd_pcm_oss_mmap, }; -@@ -3075,3 +3110,5 @@ static void __exit alsa_pcm_oss_exit(voi +@@ -3098,3 +3133,5 @@ module_init(alsa_pcm_oss_init) module_exit(alsa_pcm_oss_exit) diff --git a/acore/pcm_native.patch b/acore/pcm_native.patch index acef0c95e..939daea9b 100644 --- a/acore/pcm_native.patch +++ b/acore/pcm_native.patch @@ -1,5 +1,5 @@ ---- ../alsa-kernel/core/pcm_native.c 2010-03-10 09:06:46.035772832 +0100 -+++ pcm_native.c 2010-03-10 09:13:01.287272310 +0100 +--- ../alsa-kernel/core/pcm_native.c 2010-04-13 12:01:49.316965755 +0200 ++++ pcm_native.c 2010-04-13 13:02:27.280928480 +0200 @@ -1,3 +1,5 @@ +#define __NO_VERSION__ +#include "adriver.h" @@ -41,7 +41,7 @@ if (!S_ISCHR(inode->i_mode) || imajor(inode) != snd_major) { fput(file); -@@ -2830,25 +2839,50 @@ +@@ -2834,25 +2843,50 @@ struct snd_pcm_runtime *runtime; snd_pcm_sframes_t result; @@ -99,7 +99,7 @@ { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; -@@ -2858,7 +2892,11 @@ +@@ -2862,7 +2896,11 @@ void __user **bufs; snd_pcm_uframes_t frames; @@ -111,7 +111,7 @@ substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; -@@ -2882,8 +2920,13 @@ +@@ -2886,8 +2924,13 @@ return result; } @@ -125,7 +125,7 @@ { struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream; -@@ -2893,7 +2936,11 @@ +@@ -2897,7 +2940,11 @@ void __user **bufs; snd_pcm_uframes_t frames; @@ -137,7 +137,7 @@ substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; -@@ -2915,6 +2962,7 @@ +@@ -2919,6 +2966,7 @@ kfree(bufs); return result; } @@ -145,7 +145,7 @@ static unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait) { -@@ -3002,6 +3050,22 @@ +@@ -3006,6 +3054,22 @@ * mmap support */ @@ -168,7 +168,7 @@ /* * Only on coherent architectures, we can mmap the status and the control records * for effcient data transfer. On others, we have to use HWSYNC ioctl... -@@ -3010,6 +3074,7 @@ +@@ -3014,6 +3078,7 @@ /* * mmap status record */ @@ -176,7 +176,7 @@ static int snd_pcm_mmap_status_fault(struct vm_area_struct *area, struct vm_fault *vmf) { -@@ -3023,10 +3088,49 @@ +@@ -3027,10 +3092,49 @@ get_page(vmf->page); return 0; } @@ -226,7 +226,7 @@ }; static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, -@@ -3041,7 +3145,11 @@ +@@ -3045,7 +3149,11 @@ if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status))) return -EINVAL; area->vm_ops = &snd_pcm_vm_ops_status; @@ -238,7 +238,7 @@ area->vm_flags |= VM_RESERVED; return 0; } -@@ -3049,6 +3157,7 @@ +@@ -3053,6 +3161,7 @@ /* * mmap control record */ @@ -246,7 +246,7 @@ static int snd_pcm_mmap_control_fault(struct vm_area_struct *area, struct vm_fault *vmf) { -@@ -3062,10 +3171,50 @@ +@@ -3066,10 +3175,50 @@ get_page(vmf->page); return 0; } @@ -297,7 +297,7 @@ }; static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, -@@ -3080,7 +3229,11 @@ +@@ -3084,7 +3233,11 @@ if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))) return -EINVAL; area->vm_ops = &snd_pcm_vm_ops_control; @@ -309,7 +309,7 @@ area->vm_flags |= VM_RESERVED; return 0; } -@@ -3121,9 +3274,16 @@ +@@ -3125,9 +3278,16 @@ return virt_to_page(vaddr); } @@ -326,7 +326,7 @@ static int snd_pcm_mmap_data_fault(struct vm_area_struct *area, struct vm_fault *vmf) { -@@ -3150,6 +3310,59 @@ +@@ -3154,6 +3314,59 @@ vmf->page = page; return 0; } @@ -386,7 +386,7 @@ static const struct vm_operations_struct snd_pcm_vm_ops_data = { .open = snd_pcm_mmap_data_open, -@@ -3159,7 +3372,14 @@ +@@ -3163,7 +3376,14 @@ static const struct vm_operations_struct snd_pcm_vm_ops_data_fault = { .open = snd_pcm_mmap_data_open, .close = snd_pcm_mmap_data_close, @@ -401,7 +401,7 @@ }; #ifndef ARCH_HAS_DMA_MMAP_COHERENT -@@ -3203,11 +3423,26 @@ +@@ -3207,11 +3427,26 @@ area->vm_page_prot = pgprot_noncached(area->vm_page_prot); area->vm_flags |= VM_IO; size = area->vm_end - area->vm_start; @@ -429,7 +429,7 @@ return 0; } -@@ -3251,7 +3486,7 @@ +@@ -3255,7 +3490,7 @@ runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) return -EINVAL; size = area->vm_end - area->vm_start; @@ -438,7 +438,7 @@ dma_bytes = PAGE_ALIGN(runtime->dma_bytes); if ((size_t)size > dma_bytes) return -EINVAL; -@@ -3259,7 +3494,11 @@ +@@ -3263,7 +3498,11 @@ return -EINVAL; area->vm_ops = &snd_pcm_vm_ops_data; @@ -450,7 +450,7 @@ if (substream->ops->mmap) err = substream->ops->mmap(substream, area); else -@@ -3282,7 +3521,7 @@ +@@ -3286,7 +3525,7 @@ if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; @@ -459,7 +459,7 @@ switch (offset) { case SNDRV_PCM_MMAP_OFFSET_STATUS: if (pcm_file->no_compat_mmap) -@@ -3320,12 +3559,34 @@ +@@ -3319,12 +3558,34 @@ /* * ioctl32 compat */ @@ -495,7 +495,7 @@ /* * To be removed helpers to keep binary compatibility */ -@@ -3464,29 +3725,53 @@ +@@ -3463,31 +3724,55 @@ const struct file_operations snd_pcm_f_ops[2] = { { @@ -510,6 +510,7 @@ +#endif .open = snd_pcm_playback_open, .release = snd_pcm_release, + .llseek = no_llseek, .poll = snd_pcm_playback_poll, +#ifdef CONFIG_SND_HAVE_NEW_IOCTL .unlocked_ioctl = snd_pcm_playback_ioctl, @@ -535,6 +536,7 @@ +#endif .open = snd_pcm_capture_open, .release = snd_pcm_release, + .llseek = no_llseek, .poll = snd_pcm_capture_poll, +#ifdef CONFIG_SND_HAVE_NEW_IOCTL .unlocked_ioctl = snd_pcm_capture_ioctl, diff --git a/acore/rawmidi.patch b/acore/rawmidi.patch index ffe716c80..dad0ac58f 100644 --- a/acore/rawmidi.patch +++ b/acore/rawmidi.patch @@ -1,5 +1,5 @@ ---- ../alsa-kernel/core/rawmidi.c 2009-12-15 22:08:58.000000000 +0100 -+++ rawmidi.c 2009-12-15 22:25:55.000000000 +0100 +--- ../alsa-kernel/core/rawmidi.c 2010-04-13 12:01:49.084966034 +0200 ++++ rawmidi.c 2010-04-13 13:04:40.000999370 +0200 @@ -1,3 +1,4 @@ +#include "adriver.h" /* @@ -13,7 +13,7 @@ #include <linux/sched.h> #include <linux/slab.h> #include <linux/time.h> -@@ -1257,6 +1259,9 @@ +@@ -1261,6 +1263,9 @@ break; count -= count1; } @@ -23,7 +23,7 @@ if (file->f_flags & O_DSYNC) { spin_lock_irq(&runtime->lock); while (runtime->avail != runtime->buffer_size) { -@@ -1309,12 +1314,25 @@ +@@ -1313,12 +1318,25 @@ /* */ @@ -50,7 +50,7 @@ /* */ -@@ -1386,14 +1404,20 @@ +@@ -1390,15 +1408,21 @@ static const struct file_operations snd_rawmidi_f_ops = { @@ -61,6 +61,7 @@ .write = snd_rawmidi_write, .open = snd_rawmidi_open, .release = snd_rawmidi_release, + .llseek = no_llseek, .poll = snd_rawmidi_poll, +#ifdef CONFIG_SND_HAVE_NEW_IOCTL .unlocked_ioctl = snd_rawmidi_ioctl, diff --git a/acore/seq/seq_clientmgr.patch b/acore/seq/seq_clientmgr.patch index f03506de8..f97de90b4 100644 --- a/acore/seq/seq_clientmgr.patch +++ b/acore/seq/seq_clientmgr.patch @@ -1,5 +1,5 @@ ---- ../../alsa-kernel/core/seq/seq_clientmgr.c 2007-12-20 10:19:43.000000000 +0100 -+++ seq_clientmgr.c 2007-12-20 10:51:34.000000000 +0100 +--- ../../alsa-kernel/core/seq/seq_clientmgr.c 2010-04-13 12:01:49.084966034 +0200 ++++ seq_clientmgr.c 2010-04-13 13:11:27.005575952 +0200 @@ -1,3 +1,5 @@ +#define __NO_VERSION__ +#include "adriver.h" @@ -14,7 +14,7 @@ #include <linux/slab.h> #include <sound/core.h> #include <sound/minors.h> -@@ -2200,12 +2203,25 @@ +@@ -2211,12 +2214,25 @@ return snd_seq_do_ioctl(client, cmd, (void __user *) arg); } @@ -41,7 +41,7 @@ /* -------------------------------------------------------- */ -@@ -2535,14 +2551,20 @@ +@@ -2550,15 +2566,21 @@ static const struct file_operations snd_seq_f_ops = { @@ -52,6 +52,7 @@ .write = snd_seq_write, .open = snd_seq_open, .release = snd_seq_release, + .llseek = no_llseek, .poll = snd_seq_poll, +#ifdef CONFIG_SND_HAVE_NEW_IOCTL .unlocked_ioctl = snd_seq_ioctl, diff --git a/acore/timer.patch b/acore/timer.patch index 049bfc924..5a8c65f16 100644 --- a/acore/timer.patch +++ b/acore/timer.patch @@ -1,5 +1,5 @@ ---- ../alsa-kernel/core/timer.c 2009-09-21 15:57:35.000000000 +0200 -+++ timer.c 2009-12-15 22:17:50.000000000 +0100 +--- ../alsa-kernel/core/timer.c 2010-04-13 12:01:49.084966034 +0200 ++++ timer.c 2010-04-13 13:05:39.544700178 +0200 @@ -1,3 +1,4 @@ +#include "adriver.h" /* @@ -22,7 +22,7 @@ .ticks = 10000000L, .start = snd_timer_s_start, .stop = snd_timer_s_stop -@@ -1909,21 +1911,40 @@ +@@ -1914,22 +1916,41 @@ return mask; } @@ -54,6 +54,7 @@ .read = snd_timer_user_read, .open = snd_timer_user_open, .release = snd_timer_user_release, + .llseek = no_llseek, .poll = snd_timer_user_poll, +#ifdef CONFIG_SND_HAVE_NEW_IOCTL .unlocked_ioctl = snd_timer_user_ioctl, @@ -64,7 +65,7 @@ .fasync = snd_timer_user_fasync, }; -@@ -1935,6 +1956,7 @@ +@@ -1941,6 +1962,7 @@ { int err; diff --git a/include/adriver.h b/include/adriver.h index a204e17cf..3b8f54605 100644 --- a/include/adriver.h +++ b/include/adriver.h @@ -1425,6 +1425,7 @@ static inline int snd_pci_enable_msi(struct pci_dev *dev) { return -1; } /* kmemdup() wrapper */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) || defined(CONFIG_SND_DEBUG_MEMORY) #include <linux/string.h> +#include <linux/slab.h> static inline void *snd_kmemdup(const void *src, size_t len, gfp_t gfp) { void *dst = kmalloc(len, gfp); @@ -2000,4 +2001,14 @@ blocking_notifier_chain_unregister(struct blocking_notifier_head *nh, #endif #endif +/* no_llseek() */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0) +#define no_llseek NULL +#endif + +/* nonseekable_open() */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) +#define nonseekable_open(i,f) 0 +#endif + #endif /* __SOUND_LOCAL_DRIVER_H */ diff --git a/pci/asihpi/asihpi.c b/pci/asihpi/asihpi.c index 585d0c517..8aa1231c8 100644 --- a/pci/asihpi/asihpi.c +++ b/pci/asihpi/asihpi.c @@ -70,36 +70,36 @@ MODULE_LICENSE("GPL"); -MODULE_AUTHOR("AudioScience Inc. <support@audioscience.com>"); +MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>"); MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx"); -static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ +static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; static int enable_hpi_hwdep = 1; module_param_array(index, int, NULL, S_IRUGO); -MODULE_PARM_DESC(index, "ALSA Index value for AudioScience soundcard."); +MODULE_PARM_DESC(index, "ALSA index value for AudioScience soundcard."); module_param_array(id, charp, NULL, S_IRUGO); MODULE_PARM_DESC(id, "ALSA ID string for AudioScience soundcard."); module_param_array(enable, bool, NULL, S_IRUGO); -MODULE_PARM_DESC(enable, "ALSA Enable AudioScience soundcard."); +MODULE_PARM_DESC(enable, "ALSA enable AudioScience soundcard."); module_param(enable_hpi_hwdep, bool, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(enable_hpi_hwdep, - "ALSA Enable HPI hwdep for AudioScience soundcard "); + "ALSA enable HPI hwdep for AudioScience soundcard "); /* identify driver */ #ifdef KERNEL_ALSA_BUILD -static char *build_info = "Built using headers from kernel source"; +static char *build_info = "built using headers from kernel source"; module_param(build_info, charp, S_IRUGO); -MODULE_PARM_DESC(build_info, "Built using headers from kernel source"); +MODULE_PARM_DESC(build_info, "built using headers from kernel source"); #else -static char *build_info = "Built within ALSA source"; +static char *build_info = "built within ALSA source"; module_param(build_info, charp, S_IRUGO); -MODULE_PARM_DESC(build_info, "Built within ALSA source"); +MODULE_PARM_DESC(build_info, "built within ALSA source"); #endif /* set to 1 to dump every control from adapter to log */ @@ -108,7 +108,7 @@ static const int mixer_dump; #define DEFAULT_SAMPLERATE 44100 static int adapter_fs = DEFAULT_SAMPLERATE; -static struct hpi_hsubsys *phSubSys; /* handle to HPI audio subsystem */ +static struct hpi_hsubsys *ph_subsys; /* handle to HPI audio subsystem */ /* defaults */ #define PERIODS_MIN 2 @@ -137,14 +137,14 @@ struct clk_cache { struct snd_card_asihpi { struct snd_card *card; struct pci_dev *pci; - u16 wAdapterIndex; - u32 dwSerialNumber; - u16 wType; - u16 wVersion; - u16 wNumOutStreams; - u16 wNumInStreams; - - u32 hMixer; + u16 adapter_index; + u32 serial_number; + u16 type; + u16 version; + u16 num_outstreams; + u16 num_instreams; + + u32 h_mixer; struct clk_cache cc; u16 support_mmap; @@ -166,131 +166,131 @@ struct snd_card_asihpi_pcm { unsigned int pcm_irq_pos; /* IRQ position */ unsigned int pcm_buf_pos; /* position in buffer */ struct snd_pcm_substream *substream; - u32 hStream; - struct hpi_format Format; + u32 h_stream; + struct hpi_format format; }; /* universal stream verbs work with out or in stream handles */ /* Functions to allow driver to give a buffer to HPI for busmastering */ -static u16 HPI_StreamHostBufferAttach( +static u16 hpi_stream_host_buffer_attach( struct hpi_hsubsys *hS, - u32 hStream, /* Handle to OutStream. */ - u32 dwSizeInBytes, /* Size in bytes of bus mastering buffer */ - u32 dwPciAddress + u32 h_stream, /* handle to outstream. */ + u32 size_in_bytes, /* size in bytes of bus mastering buffer */ + u32 pci_address ) { struct hpi_message hm; struct hpi_response hr; - unsigned int obj = HPI_HandleObject(hStream); + unsigned int obj = hpi_handle_object(h_stream); - if (!hStream) + if (!h_stream) return HPI_ERROR_INVALID_OBJ; - HPI_InitMessageResponse(&hm, &hr, obj, + hpi_init_message_response(&hm, &hr, obj, obj == HPI_OBJ_OSTREAM ? HPI_OSTREAM_HOSTBUFFER_ALLOC : HPI_ISTREAM_HOSTBUFFER_ALLOC); - HPI_HandleToIndexes(hStream, &hm.wAdapterIndex, - &hm.wObjIndex); + hpi_handle_to_indexes(h_stream, &hm.adapter_index, + &hm.obj_index); - hm.u.d.u.Buffer.dwBufferSize = dwSizeInBytes; - hm.u.d.u.Buffer.dwPciAddress = dwPciAddress; - hm.u.d.u.Buffer.dwCommand = HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER; - HPI_Message(&hm, &hr); - return(hr.wError); + hm.u.d.u.buffer.buffer_size = size_in_bytes; + hm.u.d.u.buffer.pci_address = pci_address; + hm.u.d.u.buffer.command = HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER; + hpi_send_recv(&hm, &hr); + return(hr.error); } -static u16 HPI_StreamHostBufferDetach( +static u16 hpi_stream_host_buffer_detach( struct hpi_hsubsys *hS, - u32 hStream + u32 h_stream ) { struct hpi_message hm; struct hpi_response hr; - unsigned int obj = HPI_HandleObject(hStream); + unsigned int obj = hpi_handle_object(h_stream); - if (!hStream) + if (!h_stream) return HPI_ERROR_INVALID_OBJ; - HPI_InitMessageResponse(&hm, &hr, obj, + hpi_init_message_response(&hm, &hr, obj, obj == HPI_OBJ_OSTREAM ? HPI_OSTREAM_HOSTBUFFER_FREE : HPI_ISTREAM_HOSTBUFFER_FREE); - HPI_HandleToIndexes(hStream, &hm.wAdapterIndex, - &hm.wObjIndex); - hm.u.d.u.Buffer.dwCommand = HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER; - HPI_Message(&hm, &hr); - return(hr.wError); + hpi_handle_to_indexes(h_stream, &hm.adapter_index, + &hm.obj_index); + hm.u.d.u.buffer.command = HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER; + hpi_send_recv(&hm, &hr); + return(hr.error); } -static inline u16 HPI_StreamStart(struct hpi_hsubsys *hS, u32 hStream) +static inline u16 hpi_stream_start(struct hpi_hsubsys *hS, u32 h_stream) { - if (HPI_HandleObject(hStream) == HPI_OBJ_OSTREAM) - return HPI_OutStreamStart(hS, hStream); + if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) + return hpi_outstream_start(hS, h_stream); else - return HPI_InStreamStart(hS, hStream); + return hpi_instream_start(hS, h_stream); } -static inline u16 HPI_StreamStop(struct hpi_hsubsys *hS, u32 hStream) +static inline u16 hpi_stream_stop(struct hpi_hsubsys *hS, u32 h_stream) { - if (HPI_HandleObject(hStream) == HPI_OBJ_OSTREAM) - return HPI_OutStreamStop(hS, hStream); + if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) + return hpi_outstream_stop(hS, h_stream); else - return HPI_InStreamStop(hS, hStream); + return hpi_instream_stop(hS, h_stream); } -static inline u16 HPI_StreamGetInfoEx( +static inline u16 hpi_stream_get_info_ex( struct hpi_hsubsys *hS, - u32 hStream, - u16 *pwState, - u32 *pdwBufferSize, - u32 *pdwDataInBuffer, - u32 *pdwSampleCount, - u32 *pdwAuxiliaryData + u32 h_stream, + u16 *pw_state, + u32 *pbuffer_size, + u32 *pdata_in_buffer, + u32 *psample_count, + u32 *pauxiliary_data ) { - if (HPI_HandleObject(hStream) == HPI_OBJ_OSTREAM) - return HPI_OutStreamGetInfoEx(hS, hStream, pwState, - pdwBufferSize, pdwDataInBuffer, - pdwSampleCount, pdwAuxiliaryData); + if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) + return hpi_outstream_get_info_ex(hS, h_stream, pw_state, + pbuffer_size, pdata_in_buffer, + psample_count, pauxiliary_data); else - return HPI_InStreamGetInfoEx(hS, hStream, pwState, - pdwBufferSize, pdwDataInBuffer, - pdwSampleCount, pdwAuxiliaryData); + return hpi_instream_get_info_ex(hS, h_stream, pw_state, + pbuffer_size, pdata_in_buffer, + psample_count, pauxiliary_data); } -static inline u16 HPI_StreamGroupAdd(struct hpi_hsubsys *hS, - u32 hMaster, - u32 hStream) +static inline u16 hpi_stream_group_add(struct hpi_hsubsys *hS, + u32 h_master, + u32 h_stream) { - if (HPI_HandleObject(hMaster) == HPI_OBJ_OSTREAM) - return HPI_OutStreamGroupAdd(hS, hMaster, hStream); + if (hpi_handle_object(h_master) == HPI_OBJ_OSTREAM) + return hpi_outstream_group_add(hS, h_master, h_stream); else - return HPI_InStreamGroupAdd(hS, hMaster, hStream); + return hpi_instream_group_add(hS, h_master, h_stream); } -static inline u16 HPI_StreamGroupReset(struct hpi_hsubsys *hS, - u32 hStream) +static inline u16 hpi_stream_group_reset(struct hpi_hsubsys *hS, + u32 h_stream) { - if (HPI_HandleObject(hStream) == HPI_OBJ_OSTREAM) - return HPI_OutStreamGroupReset(hS, hStream); + if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) + return hpi_outstream_group_reset(hS, h_stream); else - return HPI_InStreamGroupReset(hS, hStream); + return hpi_instream_group_reset(hS, h_stream); } -static inline u16 HPI_StreamGroupGetMap(struct hpi_hsubsys *hS, - u32 hStream, u32 *mo, u32 *mi) +static inline u16 hpi_stream_group_get_map(struct hpi_hsubsys *hS, + u32 h_stream, u32 *mo, u32 *mi) { - if (HPI_HandleObject(hStream) == HPI_OBJ_OSTREAM) - return HPI_OutStreamGroupGetMap(hS, hStream, mo, mi); + if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) + return hpi_outstream_group_get_map(hS, h_stream, mo, mi); else - return HPI_InStreamGroupGetMap(hS, hStream, mo, mi); + return hpi_instream_group_get_map(hS, h_stream, mo, mi); } -static u16 _HandleError(u16 err, int line, char *filename) +static u16 handle_error(u16 err, int line, char *filename) { if (err) printk(KERN_WARNING @@ -299,7 +299,7 @@ static u16 _HandleError(u16 err, int line, char *filename) return err; } -#define HPI_HandleError(x) _HandleError(x, __LINE__, __FILE__) +#define hpi_handle_error(x) handle_error(x, __LINE__, __FILE__) /***************************** GENERAL PCM ****************/ #if REALLY_VERBOSE_LOGGING @@ -307,11 +307,11 @@ static void print_hwparams(struct snd_pcm_hw_params *p) { snd_printd("HWPARAMS \n"); snd_printd("samplerate %d \n", params_rate(p)); - snd_printd("Channels %d \n", params_channels(p)); - snd_printd("Format %d \n", params_format(p)); + snd_printd("channels %d \n", params_channels(p)); + snd_printd("format %d \n", params_format(p)); snd_printd("subformat %d \n", params_subformat(p)); - snd_printd("Buffer bytes %d \n", params_buffer_bytes(p)); - snd_printd("Period bytes %d \n", params_period_bytes(p)); + snd_printd("buffer bytes %d \n", params_buffer_bytes(p)); + snd_printd("period bytes %d \n", params_period_bytes(p)); snd_printd("access %d \n", params_access(p)); snd_printd("period_size %d \n", params_period_size(p)); snd_printd("periods %d \n", params_periods(p)); @@ -348,22 +348,22 @@ static snd_pcm_format_t hpi_to_alsa_formats[] = { }; -static int snd_card_asihpi_format_alsa2hpi(snd_pcm_format_t alsaFormat, - u16 *hpiFormat) +static int snd_card_asihpi_format_alsa2hpi(snd_pcm_format_t alsa_format, + u16 *hpi_format) { - u16 wFormat; + u16 format; - for (wFormat = HPI_FORMAT_PCM8_UNSIGNED; - wFormat <= HPI_FORMAT_PCM24_SIGNED; wFormat++) { - if (hpi_to_alsa_formats[wFormat] == alsaFormat) { - *hpiFormat = wFormat; + for (format = HPI_FORMAT_PCM8_UNSIGNED; + format <= HPI_FORMAT_PCM24_SIGNED; format++) { + if (hpi_to_alsa_formats[format] == alsa_format) { + *hpi_format = format; return 0; } } - snd_printd(KERN_WARNING "Failed match for alsa format %d\n", - alsaFormat); - *hpiFormat = 0; + snd_printd(KERN_WARNING "failed match for alsa format %d\n", + alsa_format); + *hpi_format = 0; return -EINVAL; } @@ -371,8 +371,8 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi, struct snd_pcm_hardware *pcmhw) { u16 err; - u32 hControl; - u32 sampleRate; + u32 h_control; + u32 sample_rate; int idx; unsigned int rate_min = 200000; unsigned int rate_max = 0; @@ -386,26 +386,26 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi, } else { /* on cards without SRC, valid rates are determined by sampleclock */ - err = HPI_MixerGetControl(phSubSys, asihpi->hMixer, + err = hpi_mixer_get_control(ph_subsys, asihpi->h_mixer, HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, - HPI_CONTROL_SAMPLECLOCK, &hControl); + HPI_CONTROL_SAMPLECLOCK, &h_control); if (err) { - snd_printk(KERN_ERR "No local sampleclock, err %d\n", err); + snd_printk(KERN_ERR "no local sampleclock, err %d\n", err); } for (idx = 0; idx < 100; idx++) { - if (HPI_SampleClock_QueryLocalRate(phSubSys, hControl, - idx, &sampleRate)) { + if (hpi_sample_clock_query_local_rate(ph_subsys, h_control, + idx, &sample_rate)) { if (!idx) - snd_printk(KERN_ERR "Local rate query failed\n"); + snd_printk(KERN_ERR "local rate query failed\n"); break; } - rate_min = min(rate_min, sampleRate); - rate_max = max(rate_max, sampleRate); + rate_min = min(rate_min, sample_rate); + rate_max = max(rate_max, sample_rate); - switch (sampleRate) { + switch (sample_rate) { case 5512: rates |= SNDRV_PCM_RATE_5512; break; @@ -466,55 +466,55 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_card_asihpi_pcm *dpcm = runtime->private_data; struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); int err; - u16 wFormat; + u16 format; unsigned int bytes_per_sec; print_hwparams(params); err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); if (err < 0) return err; - err = snd_card_asihpi_format_alsa2hpi(params_format(params), &wFormat); + err = snd_card_asihpi_format_alsa2hpi(params_format(params), &format); if (err) return err; - VPRINTK1(KERN_INFO "Format %d, %d chans, %dHz\n", - wFormat,params_channels(params), + VPRINTK1(KERN_INFO "format %d, %d chans, %d_hz\n", + format,params_channels(params), params_rate(params)); - HPI_HandleError(HPI_FormatCreate(&dpcm->Format, params_channels(params), - wFormat, params_rate(params), 0, 0)); + hpi_handle_error(hpi_format_create(&dpcm->format, params_channels(params), + format, params_rate(params), 0, 0)); if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - if (HPI_InStreamReset(phSubSys, dpcm->hStream) != 0) + if (hpi_instream_reset(ph_subsys, dpcm->h_stream) != 0) return -EINVAL; - if (HPI_InStreamSetFormat(phSubSys, - dpcm->hStream, &dpcm->Format) != 0) + if (hpi_instream_set_format(ph_subsys, + dpcm->h_stream, &dpcm->format) != 0) return -EINVAL; } dpcm->hpi_buffer_attached = 0; if (card->support_mmap) { - err = HPI_StreamHostBufferAttach(phSubSys, dpcm->hStream, + err = hpi_stream_host_buffer_attach(ph_subsys, dpcm->h_stream, params_buffer_bytes(params), runtime->dma_addr); if (err == 0) { snd_printd(KERN_INFO - "StreamHostBufferAttach succeeded %u %lu\n", + "stream_host_buffer_attach succeeded %u %lu\n", params_buffer_bytes(params), (unsigned long)runtime->dma_addr); } else { snd_printd(KERN_INFO - "StreamHostBufferAttach error %d\n", + "stream_host_buffer_attach error %d\n", err); return -ENOMEM; } - err = HPI_StreamGetInfoEx(phSubSys, dpcm->hStream, NULL, + err = hpi_stream_get_info_ex(ph_subsys, dpcm->h_stream, NULL, &dpcm->hpi_buffer_attached, NULL, NULL, NULL); - snd_printd(KERN_INFO "StreamHostBufferAttach status 0x%x\n", + snd_printd(KERN_INFO "stream_host_buffer_attach status 0x%x\n", dpcm->hpi_buffer_attached); } bytes_per_sec = params_rate(params) * params_channels(params); @@ -526,7 +526,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, dpcm->bytes_per_sec = bytes_per_sec; dpcm->pcm_size = params_buffer_bytes(params); dpcm->pcm_count = params_period_bytes(params); - snd_printd(KERN_INFO "pcm_size=%d, pcm_count=%d, Bps=%d\n", + snd_printd(KERN_INFO "pcm_size=%d, pcm_count=%d, bps=%d\n", dpcm->pcm_size, dpcm->pcm_count, bytes_per_sec); dpcm->pcm_irq_pos = 0; @@ -566,7 +566,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, struct snd_pcm_substream *s; u16 e; - snd_printd("Trigger %dstream %d\n", + snd_printd("trigger %dstream %d\n", substream->stream, substream->number); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -585,31 +585,31 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, * data?? */ unsigned int preload = ds->pcm_count * 2; - VPRINTK2("Preload %d\n", preload); - HPI_HandleError(HPI_OutStreamWriteBuf(phSubSys, ds->hStream, + VPRINTK2("preload %d\n", preload); + hpi_handle_error(hpi_outstream_write_buf(ph_subsys, ds->h_stream, &s->runtime->dma_area[0], preload, - &ds->Format)); + &ds->format)); } if (card->support_grouping) { - VPRINTK1("\tGroup %dstream %d\n", s->stream, + VPRINTK1("\t_group %dstream %d\n", s->stream, s->number); - e = HPI_StreamGroupAdd(phSubSys, dpcm->hStream, - ds->hStream); + e = hpi_stream_group_add(ph_subsys, dpcm->h_stream, + ds->h_stream); if (!e) { snd_pcm_trigger_done(s, substream); } else { - HPI_HandleError(e); + hpi_handle_error(e); break; } } else break; } - snd_printd("Start\n"); + snd_printd("start\n"); /* start the master stream */ snd_card_asihpi_pcm_timer_start(substream); - HPI_HandleError(HPI_StreamStart(phSubSys, dpcm->hStream)); + hpi_handle_error(hpi_stream_start(ph_subsys, dpcm->h_stream)); break; case SNDRV_PCM_TRIGGER_STOP: @@ -623,33 +623,33 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, s->runtime->status->state = SNDRV_PCM_STATE_SETUP; if (card->support_grouping) { - VPRINTK1("\tGroup %dstream %d\n", s->stream, + VPRINTK1("\t_group %dstream %d\n", s->stream, s->number); snd_pcm_trigger_done(s, substream); } else break; } - snd_printd("Stop\n"); + snd_printd("stop\n"); /* _prepare and _hwparams reset the stream */ - HPI_HandleError(HPI_StreamStop(phSubSys, dpcm->hStream)); + hpi_handle_error(hpi_stream_stop(ph_subsys, dpcm->h_stream)); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - HPI_HandleError(HPI_OutStreamReset(phSubSys, dpcm->hStream)); + hpi_handle_error(hpi_outstream_reset(ph_subsys, dpcm->h_stream)); if (card->support_grouping) - HPI_HandleError(HPI_StreamGroupReset(phSubSys, - dpcm->hStream)); + hpi_handle_error(hpi_stream_group_reset(ph_subsys, + dpcm->h_stream)); break; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - snd_printd("Pause release\n"); - HPI_HandleError(HPI_StreamStart(phSubSys, dpcm->hStream)); + snd_printd("pause release\n"); + hpi_handle_error(hpi_stream_start(ph_subsys, dpcm->h_stream)); snd_card_asihpi_pcm_timer_start(substream); break; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - snd_printd("Pause\n"); + snd_printd("pause\n"); snd_card_asihpi_pcm_timer_stop(substream); - HPI_HandleError(HPI_StreamStop(phSubSys, dpcm->hStream)); + hpi_handle_error(hpi_stream_stop(ph_subsys, dpcm->h_stream)); break; default: snd_printd("\tINVALID\n"); @@ -665,7 +665,7 @@ snd_card_asihpi_hw_free(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_card_asihpi_pcm *dpcm = runtime->private_data; if (dpcm->hpi_buffer_attached) - HPI_StreamHostBufferDetach(phSubSys, dpcm->hStream); + hpi_stream_host_buffer_detach(ph_subsys, dpcm->h_stream); snd_pcm_lib_free_pages(substream); return 0; @@ -732,8 +732,8 @@ static void snd_card_asihpi_timer_function(unsigned long data) unsigned int buf_pos, min_buf_pos = 0; unsigned int remdata, xfercount, next_jiffies; int first = 1; - u16 wState; - u32 dwBufferSize, dwDataAvail, dwSamplesPlayed, dwAux; + u16 state; + u32 buffer_size, data_avail, samples_played, aux; /* find minimum newdata and buffer pos in group */ snd_pcm_group_for_each_entry(s, dpcm->substream) { @@ -743,25 +743,25 @@ static void snd_card_asihpi_timer_function(unsigned long data) if (snd_pcm_substream_chip(s) != card) continue; - HPI_HandleError(HPI_StreamGetInfoEx(phSubSys, - ds->hStream, &wState, - &dwBufferSize, &dwDataAvail, - &dwSamplesPlayed, &dwAux)); + hpi_handle_error(hpi_stream_get_info_ex(ph_subsys, + ds->h_stream, &state, + &buffer_size, &data_avail, + &samples_played, &aux)); /* number of bytes in on-card buffer */ - runtime->delay = dwAux; + runtime->delay = aux; - if (wState == HPI_STATE_DRAINED) { - snd_printd(KERN_WARNING "OStream %d drained\n", + if (state == HPI_STATE_DRAINED) { + snd_printd(KERN_WARNING "outstream %d drained\n", s->number); snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN); return; } if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { - buf_pos = frames_to_bytes(runtime, dwSamplesPlayed); + buf_pos = frames_to_bytes(runtime, samples_played); } else { - buf_pos = dwDataAvail + ds->pcm_irq_pos; + buf_pos = data_avail + ds->pcm_irq_pos; } if (first) { @@ -784,8 +784,8 @@ static void snd_card_asihpi_timer_function(unsigned long data) runtime->control->appl_ptr)); VPRINTK1("%d S=%d, irq=%04X, pos=x%04X, left=x%04X," " aux=x%04X space=x%04X\n", s->number, - wState, ds->pcm_irq_pos, buf_pos, (int)dwDataAvail, - (int)dwAux, dwBufferSize-dwDataAvail); + state, ds->pcm_irq_pos, buf_pos, (int)data_avail, + (int)aux, buffer_size-data_avail); } remdata = newdata % dpcm->pcm_count; @@ -804,23 +804,23 @@ static void snd_card_asihpi_timer_function(unsigned long data) if (card->support_mmap) { ds->pcm_irq_pos = ds->pcm_irq_pos + xfercount; if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { - VPRINTK2("Write OS%d x%04x\n", + VPRINTK2("write OS%d x%04x\n", s->number, ds->pcm_count); - HPI_HandleError( - HPI_OutStreamWriteBuf( - phSubSys, ds->hStream, + hpi_handle_error( + hpi_outstream_write_buf( + ph_subsys, ds->h_stream, &s->runtime-> dma_area[0], xfercount, - &ds->Format)); + &ds->format)); } else { - VPRINTK2("Read IS%d x%04x\n", + VPRINTK2("read IS%d x%04x\n", s->number, dpcm->pcm_count); - HPI_HandleError( - HPI_InStreamReadBuf( - phSubSys, ds->hStream, + hpi_handle_error( + hpi_instream_read_buf( + ph_subsys, ds->h_stream, NULL, xfercount)); } } /* else R/W will be handled by read/write callbacks */ @@ -846,9 +846,9 @@ static int snd_card_asihpi_playback_prepare(struct snd_pcm_substream * struct snd_pcm_runtime *runtime = substream->runtime; struct snd_card_asihpi_pcm *dpcm = runtime->private_data; - snd_printd(KERN_INFO "Playback prepare %d\n", substream->number); + snd_printd(KERN_INFO "playback prepare %d\n", substream->number); - HPI_HandleError(HPI_OutStreamReset(phSubSys, dpcm->hStream)); + hpi_handle_error(hpi_outstream_reset(ph_subsys, dpcm->h_stream)); dpcm->pcm_irq_pos = 0; dpcm->pcm_buf_pos = 0; @@ -862,7 +862,7 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream) struct snd_card_asihpi_pcm *dpcm = runtime->private_data; snd_pcm_uframes_t ptr; - u32 dwSamplesPlayed; + u32 samples_played; u16 err; if (!snd_pcm_stream_linked(substream)) { @@ -870,12 +870,12 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream) * in timer fn because it LAGS the actual read pointer, and is a * better representation of actual playout position */ - err = HPI_OutStreamGetInfoEx(phSubSys, dpcm->hStream, NULL, + err = hpi_outstream_get_info_ex(ph_subsys, dpcm->h_stream, NULL, NULL, NULL, - &dwSamplesPlayed, NULL); - HPI_HandleError(err); + &samples_played, NULL); + hpi_handle_error(err); - dpcm->pcm_buf_pos = frames_to_bytes(runtime, dwSamplesPlayed); + dpcm->pcm_buf_pos = frames_to_bytes(runtime, samples_played); } /* else must return most conservative value found in timer func * by looping over all streams @@ -887,36 +887,36 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream) } static void snd_card_asihpi_playback_format(struct snd_card_asihpi *asihpi, - u32 hStream, + u32 h_stream, struct snd_pcm_hardware *pcmhw) { struct hpi_format hpi_format; - u16 wFormat; + u16 format; u16 err; - u32 hControl; - u32 dwSampleRate = 48000; + u32 h_control; + u32 sample_rate = 48000; /* on cards without SRC, must query at valid rate, * maybe set by external sync */ - err = HPI_MixerGetControl(phSubSys, asihpi->hMixer, + err = hpi_mixer_get_control(ph_subsys, asihpi->h_mixer, HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, - HPI_CONTROL_SAMPLECLOCK, &hControl); + HPI_CONTROL_SAMPLECLOCK, &h_control); if (!err) - err = HPI_SampleClock_GetSampleRate(phSubSys, hControl, - &dwSampleRate); + err = hpi_sample_clock_get_sample_rate(ph_subsys, h_control, + &sample_rate); - for (wFormat = HPI_FORMAT_PCM8_UNSIGNED; - wFormat <= HPI_FORMAT_PCM24_SIGNED; wFormat++) { - err = HPI_FormatCreate(&hpi_format, - 2, wFormat, dwSampleRate, 128000, 0); + for (format = HPI_FORMAT_PCM8_UNSIGNED; + format <= HPI_FORMAT_PCM24_SIGNED; format++) { + err = hpi_format_create(&hpi_format, + 2, format, sample_rate, 128000, 0); if (!err) - err = HPI_OutStreamQueryFormat(phSubSys, hStream, + err = hpi_outstream_query_format(ph_subsys, h_stream, &hpi_format); - if (!err && (hpi_to_alsa_formats[wFormat] != -1)) + if (!err && (hpi_to_alsa_formats[format] != -1)) pcmhw->formats |= - (1ULL << hpi_to_alsa_formats[wFormat]); + (1ULL << hpi_to_alsa_formats[format]); } } @@ -943,9 +943,9 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) return -ENOMEM; err = - HPI_OutStreamOpen(phSubSys, card->wAdapterIndex, - substream->number, &dpcm->hStream); - HPI_HandleError(err); + hpi_outstream_open(ph_subsys, card->adapter_index, + substream->number, &dpcm->h_stream); + hpi_handle_error(err); if (err) kfree(dpcm); if (err == HPI_ERROR_OBJ_ALREADY_OPEN) @@ -969,7 +969,7 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) /*?snd_card_asihpi_playback.period_bytes_min = card->out_max_chans * 4096; */ - snd_card_asihpi_playback_format(card, dpcm->hStream, + snd_card_asihpi_playback_format(card, dpcm->h_stream, &snd_card_asihpi_playback); snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_playback); @@ -1001,7 +1001,7 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) snd_pcm_set_sync(substream); - snd_printd(KERN_INFO "Playback open\n"); + snd_printd(KERN_INFO "playback open\n"); return 0; } @@ -1011,8 +1011,8 @@ static int snd_card_asihpi_playback_close(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_card_asihpi_pcm *dpcm = runtime->private_data; - HPI_HandleError(HPI_OutStreamClose(phSubSys, dpcm->hStream)); - snd_printd(KERN_INFO "Playback close\n"); + hpi_handle_error(hpi_outstream_close(ph_subsys, dpcm->h_stream)); + snd_printd(KERN_INFO "playback close\n"); return 0; } @@ -1032,11 +1032,11 @@ static int snd_card_asihpi_playback_copy(struct snd_pcm_substream *substream, if (copy_from_user(runtime->dma_area, src, len)) return -EFAULT; - VPRINTK2(KERN_DEBUG "Playback copy%d %u bytes\n", + VPRINTK2(KERN_DEBUG "playback copy%d %u bytes\n", substream->number, len); - HPI_HandleError(HPI_OutStreamWriteBuf(phSubSys, dpcm->hStream, - runtime->dma_area, len, &dpcm->Format)); + hpi_handle_error(hpi_outstream_write_buf(ph_subsys, dpcm->h_stream, + runtime->dma_area, len, &dpcm->format)); return 0; } @@ -1051,11 +1051,11 @@ static int snd_card_asihpi_playback_silence(struct snd_pcm_substream * struct snd_card_asihpi_pcm *dpcm = runtime->private_data; len = frames_to_bytes(runtime, count); - snd_printd(KERN_INFO "Playback silence %u bytes\n", len); + snd_printd(KERN_INFO "playback silence %u bytes\n", len); memset(runtime->dma_area, 0, len); - HPI_HandleError(HPI_OutStreamWriteBuf(phSubSys, dpcm->hStream, - runtime->dma_area, len, &dpcm->Format)); + hpi_handle_error(hpi_outstream_write_buf(ph_subsys, dpcm->h_stream, + runtime->dma_area, len, &dpcm->format)); return 0; } @@ -1090,7 +1090,7 @@ snd_card_asihpi_capture_pointer(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_card_asihpi_pcm *dpcm = runtime->private_data; - VPRINTK2("Capture pointer %d=%d\n", + VPRINTK2("capture pointer %d=%d\n", substream->number, dpcm->pcm_buf_pos); /* NOTE Unlike playback can't use actual dwSamplesPlayed for the capture position, because those samples aren't yet in @@ -1110,47 +1110,47 @@ static int snd_card_asihpi_capture_prepare(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_card_asihpi_pcm *dpcm = runtime->private_data; - HPI_HandleError(HPI_InStreamReset(phSubSys, dpcm->hStream)); + hpi_handle_error(hpi_instream_reset(ph_subsys, dpcm->h_stream)); dpcm->pcm_irq_pos = 0; dpcm->pcm_buf_pos = 0; - snd_printd("Capture Prepare %d\n", substream->number); + snd_printd("capture prepare %d\n", substream->number); return 0; } static void snd_card_asihpi_capture_format(struct snd_card_asihpi *asihpi, - u32 hStream, + u32 h_stream, struct snd_pcm_hardware *pcmhw) { struct hpi_format hpi_format; - u16 wFormat; + u16 format; u16 err; - u32 hControl; - u32 dwSampleRate = 48000; + u32 h_control; + u32 sample_rate = 48000; /* on cards without SRC, must query at valid rate, maybe set by external sync */ - err = HPI_MixerGetControl(phSubSys, asihpi->hMixer, + err = hpi_mixer_get_control(ph_subsys, asihpi->h_mixer, HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, - HPI_CONTROL_SAMPLECLOCK, &hControl); + HPI_CONTROL_SAMPLECLOCK, &h_control); if (!err) - err = HPI_SampleClock_GetSampleRate(phSubSys, hControl, - &dwSampleRate); + err = hpi_sample_clock_get_sample_rate(ph_subsys, h_control, + &sample_rate); - for (wFormat = HPI_FORMAT_PCM8_UNSIGNED; - wFormat <= HPI_FORMAT_PCM24_SIGNED; wFormat++) { + for (format = HPI_FORMAT_PCM8_UNSIGNED; + format <= HPI_FORMAT_PCM24_SIGNED; format++) { - err = HPI_FormatCreate(&hpi_format, 2, wFormat, - dwSampleRate, 128000, 0); + err = hpi_format_create(&hpi_format, 2, format, + sample_rate, 128000, 0); if (!err) - err = HPI_InStreamQueryFormat(phSubSys, hStream, + err = hpi_instream_query_format(ph_subsys, h_stream, &hpi_format); if (!err) pcmhw->formats |= - (1ULL << hpi_to_alsa_formats[wFormat]); + (1ULL << hpi_to_alsa_formats[format]); } } @@ -1177,12 +1177,12 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) if (dpcm == NULL) return -ENOMEM; - snd_printd("HPI_InStreamOpen Adapter %d Stream %d\n", - card->wAdapterIndex, substream->number); + snd_printd("hpi_instream_open adapter %d stream %d\n", + card->adapter_index, substream->number); - err = HPI_HandleError( - HPI_InStreamOpen(phSubSys, card->wAdapterIndex, - substream->number, &dpcm->hStream)); + err = hpi_handle_error( + hpi_instream_open(ph_subsys, card->adapter_index, + substream->number, &dpcm->h_stream)); if (err) kfree(dpcm); if (err == HPI_ERROR_OBJ_ALREADY_OPEN) @@ -1199,7 +1199,7 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) runtime->private_free = snd_card_asihpi_runtime_free; snd_card_asihpi_capture.channels_max = card->in_max_chans; - snd_card_asihpi_capture_format(card, dpcm->hStream, + snd_card_asihpi_capture_format(card, dpcm->h_stream, &snd_card_asihpi_capture); snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_capture); snd_card_asihpi_capture.info = SNDRV_PCM_INFO_INTERLEAVED; @@ -1228,7 +1228,7 @@ static int snd_card_asihpi_capture_close(struct snd_pcm_substream *substream) { struct snd_card_asihpi_pcm *dpcm = substream->runtime->private_data; - HPI_HandleError(HPI_InStreamClose(phSubSys, dpcm->hStream)); + hpi_handle_error(hpi_instream_close(ph_subsys, dpcm->h_stream)); return 0; } @@ -1238,18 +1238,18 @@ static int snd_card_asihpi_capture_copy(struct snd_pcm_substream *substream, { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_card_asihpi_pcm *dpcm = runtime->private_data; - u32 dwDataSize; + u32 data_size; - dwDataSize = frames_to_bytes(runtime, count); + data_size = frames_to_bytes(runtime, count); - VPRINTK2("Capture copy%d %d bytes\n", substream->number, dwDataSize); - HPI_HandleError(HPI_InStreamReadBuf(phSubSys, dpcm->hStream, - runtime->dma_area, dwDataSize)); + VPRINTK2("capture copy%d %d bytes\n", substream->number, data_size); + hpi_handle_error(hpi_instream_read_buf(ph_subsys, dpcm->h_stream, + runtime->dma_area, data_size)); /* Used by capture_pointer */ - dpcm->pcm_irq_pos = dpcm->pcm_irq_pos + dwDataSize; + dpcm->pcm_irq_pos = dpcm->pcm_irq_pos + data_size; - if (copy_to_user(dst, runtime->dma_area, dwDataSize)) + if (copy_to_user(dst, runtime->dma_area, data_size)) return -EFAULT; return 0; @@ -1284,8 +1284,8 @@ static int __devinit snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, struct snd_pcm *pcm; int err; - err = snd_pcm_new(asihpi->card, "Asihpi PCM", device, - asihpi->wNumOutStreams, asihpi->wNumInStreams, + err = snd_pcm_new(asihpi->card, "asihpi PCM", device, + asihpi->num_outstreams, asihpi->num_instreams, &pcm); if (err < 0) return err; @@ -1304,7 +1304,7 @@ static int __devinit snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, pcm->private_data = asihpi; pcm->info_flags = 0; - strcpy(pcm->name, "Asihpi PCM"); + strcpy(pcm->name, "asihpi PCM"); /* ? do we want to emulate MMAP for non-BBM cards? Jack doesn't work with ALSAs MMAP emulation - WHY NOT? */ @@ -1317,13 +1317,13 @@ static int __devinit snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, /***************************** MIXER CONTROLS ****************/ struct hpi_control { - u32 hControl; - u16 wControlType; - u16 wSrcNodeType; - u16 wSrcNodeIndex; - u16 wDstNodeType; - u16 wDstNodeIndex; - u16 wBand; + u32 h_control; + u16 control_type; + u16 src_node_type; + u16 src_node_index; + u16 dst_node_type; + u16 dst_node_index; + u16 band; char name[44]; /* copied to snd_ctl_elem_id.name[44]; */ }; @@ -1350,33 +1350,33 @@ compile_time_assert( static char *asihpi_src_names[] = { "no source", - "OutStream", - "LineIn", - "AesIn", - "Tuner", + "outstream", + "line_in", + "aes_in", + "tuner", "RF", - "Clock", - "Bitstr", - "Mic", - "Cobranet", - "AnalogIn", - "Adapter", + "clock", + "bitstr", + "mic", + "cobranet", + "analog_in", + "adapter", }; #else static char *asihpi_src_names[] = { "no source", - "PCM Playback", - "Line in", - "Digital in", - "Tuner", + "PCM playback", + "line in", + "digital in", + "tuner", "RF", - "Clock", - "Bitstream", - "Mic", - "Cobranet in", - "Analog in", - "Adapter", + "clock", + "bitstream", + "mic", + "cobranet in", + "analog in", + "adapter", }; #endif @@ -1389,25 +1389,25 @@ compile_time_assert( static char *asihpi_dst_names[] = { "no destination", - "InStream", - "LineOut", - "AesOut", + "instream", + "line_out", + "aes_out", "RF", - "Speaker" , - "Cobranet", - "AnalogOut", + "speaker" , + "cobranet", + "analog_out", }; #else static char *asihpi_dst_names[] = { "no destination", - "PCM Capture", - "Line out", - "Digital out", + "PCM capture", + "line out", + "digital out", "RF", - "Speaker", - "Cobranet out", - "Analog out" + "speaker", + "cobranet out", + "analog out" }; #endif @@ -1425,7 +1425,7 @@ static inline int ctl_add(struct snd_card *card, struct snd_kcontrol_new *ctl, if (err < 0) return err; else if (mixer_dump) - snd_printk(KERN_INFO "Added %s(%d)\n", ctl->name, ctl->index); + snd_printk(KERN_INFO "added %s(%d)\n", ctl->name, ctl->index); return 0; } @@ -1437,26 +1437,26 @@ static void asihpi_ctl_init(struct snd_kcontrol_new *snd_control, { memset(snd_control, 0, sizeof(*snd_control)); snd_control->name = asihpi_control->name; - snd_control->private_value = asihpi_control->hControl; + snd_control->private_value = asihpi_control->h_control; snd_control->iface = SNDRV_CTL_ELEM_IFACE_MIXER; snd_control->index = 0; - if (asihpi_control->wSrcNodeType && asihpi_control->wDstNodeType) + if (asihpi_control->src_node_type && asihpi_control->dst_node_type) sprintf(asihpi_control->name, "%s%d to %s%d %s", - asihpi_src_names[asihpi_control->wSrcNodeType], - asihpi_control->wSrcNodeIndex, - asihpi_dst_names[asihpi_control->wDstNodeType], - asihpi_control->wDstNodeIndex, + asihpi_src_names[asihpi_control->src_node_type], + asihpi_control->src_node_index, + asihpi_dst_names[asihpi_control->dst_node_type], + asihpi_control->dst_node_index, name); - else if (asihpi_control->wDstNodeType) { + else if (asihpi_control->dst_node_type) { sprintf(asihpi_control->name, "%s%d %s", - asihpi_dst_names[asihpi_control->wDstNodeType], - asihpi_control->wDstNodeIndex, + asihpi_dst_names[asihpi_control->dst_node_type], + asihpi_control->dst_node_index, name); } else { sprintf(asihpi_control->name, "%s%d %s", - asihpi_src_names[asihpi_control->wSrcNodeType], - asihpi_control->wSrcNodeIndex, + asihpi_src_names[asihpi_control->src_node_type], + asihpi_control->src_node_index, name); } } @@ -1468,38 +1468,38 @@ static void asihpi_ctl_init(struct snd_kcontrol_new *snd_control, static int snd_asihpi_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; u16 err; /* native gains are in millibels */ - short nMinGain_mB; - short nMaxGain_mB; - short nStepGain_mB; + short min_gain_mB; + short max_gain_mB; + short step_gain_mB; - err = HPI_VolumeQueryRange(phSubSys, hControl, - &nMinGain_mB, &nMaxGain_mB, &nStepGain_mB); + err = hpi_volume_query_range(ph_subsys, h_control, + &min_gain_mB, &max_gain_mB, &step_gain_mB); if (err) { - nMaxGain_mB = 0; - nMinGain_mB = -10000; - nStepGain_mB = VOL_STEP_mB; + max_gain_mB = 0; + min_gain_mB = -10000; + step_gain_mB = VOL_STEP_mB; } uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; - uinfo->value.integer.min = nMinGain_mB / VOL_STEP_mB; - uinfo->value.integer.max = nMaxGain_mB / VOL_STEP_mB; - uinfo->value.integer.step = nStepGain_mB / VOL_STEP_mB; + uinfo->value.integer.min = min_gain_mB / VOL_STEP_mB; + uinfo->value.integer.max = max_gain_mB / VOL_STEP_mB; + uinfo->value.integer.step = step_gain_mB / VOL_STEP_mB; return 0; } static int snd_asihpi_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - u32 hControl = kcontrol->private_value; - short anGain_mB[HPI_MAX_CHANNELS]; + u32 h_control = kcontrol->private_value; + short an_gain_mB[HPI_MAX_CHANNELS]; - HPI_HandleError(HPI_VolumeGetGain(phSubSys, hControl, anGain_mB)); - ucontrol->value.integer.value[0] = anGain_mB[0] / VOL_STEP_mB; - ucontrol->value.integer.value[1] = anGain_mB[1] / VOL_STEP_mB; + hpi_handle_error(hpi_volume_get_gain(ph_subsys, h_control, an_gain_mB)); + ucontrol->value.integer.value[0] = an_gain_mB[0] / VOL_STEP_mB; + ucontrol->value.integer.value[1] = an_gain_mB[1] / VOL_STEP_mB; return 0; } @@ -1508,18 +1508,18 @@ static int snd_asihpi_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int change; - u32 hControl = kcontrol->private_value; - short anGain_mB[HPI_MAX_CHANNELS]; + u32 h_control = kcontrol->private_value; + short an_gain_mB[HPI_MAX_CHANNELS]; - anGain_mB[0] = + an_gain_mB[0] = (ucontrol->value.integer.value[0]) * VOL_STEP_mB; - anGain_mB[1] = + an_gain_mB[1] = (ucontrol->value.integer.value[1]) * VOL_STEP_mB; /* change = asihpi->mixer_volume[addr][0] != left || asihpi->mixer_volume[addr][1] != right; */ change = 1; - HPI_HandleError(HPI_VolumeSetGain(phSubSys, hControl, anGain_mB)); + hpi_handle_error(hpi_volume_set_gain(ph_subsys, h_control, an_gain_mB)); return change; } @@ -1531,7 +1531,7 @@ static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, struct snd_card *card = asihpi->card; struct snd_kcontrol_new snd_control; - asihpi_ctl_init(&snd_control, asihpi_control, "Volume"); + asihpi_ctl_init(&snd_control, asihpi_control, "volume"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ; snd_control.info = snd_asihpi_volume_info; @@ -1548,40 +1548,40 @@ static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, static int snd_asihpi_level_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; u16 err; - short nMinGain_mB; - short nMaxGain_mB; - short nStepGain_mB; + short min_gain_mB; + short max_gain_mB; + short step_gain_mB; err = - HPI_LevelQueryRange(phSubSys, hControl, &nMinGain_mB, - &nMaxGain_mB, &nStepGain_mB); + hpi_level_query_range(ph_subsys, h_control, &min_gain_mB, + &max_gain_mB, &step_gain_mB); if (err) { - nMaxGain_mB = 2400; - nMinGain_mB = -1000; - nStepGain_mB = 100; + max_gain_mB = 2400; + min_gain_mB = -1000; + step_gain_mB = 100; } uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; - uinfo->value.integer.min = nMinGain_mB / HPI_UNITS_PER_dB; - uinfo->value.integer.max = nMaxGain_mB / HPI_UNITS_PER_dB; - uinfo->value.integer.step = nStepGain_mB / HPI_UNITS_PER_dB; + uinfo->value.integer.min = min_gain_mB / HPI_UNITS_PER_dB; + uinfo->value.integer.max = max_gain_mB / HPI_UNITS_PER_dB; + uinfo->value.integer.step = step_gain_mB / HPI_UNITS_PER_dB; return 0; } static int snd_asihpi_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - u32 hControl = kcontrol->private_value; - short anGain_mB[HPI_MAX_CHANNELS]; + u32 h_control = kcontrol->private_value; + short an_gain_mB[HPI_MAX_CHANNELS]; - HPI_HandleError(HPI_LevelGetGain(phSubSys, hControl, anGain_mB)); + hpi_handle_error(hpi_level_get_gain(ph_subsys, h_control, an_gain_mB)); ucontrol->value.integer.value[0] = - anGain_mB[0] / HPI_UNITS_PER_dB; + an_gain_mB[0] / HPI_UNITS_PER_dB; ucontrol->value.integer.value[1] = - anGain_mB[1] / HPI_UNITS_PER_dB; + an_gain_mB[1] / HPI_UNITS_PER_dB; return 0; } @@ -1590,18 +1590,18 @@ static int snd_asihpi_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int change; - u32 hControl = kcontrol->private_value; - short anGain_mB[HPI_MAX_CHANNELS]; + u32 h_control = kcontrol->private_value; + short an_gain_mB[HPI_MAX_CHANNELS]; - anGain_mB[0] = + an_gain_mB[0] = (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB; - anGain_mB[1] = + an_gain_mB[1] = (ucontrol->value.integer.value[1]) * HPI_UNITS_PER_dB; /* change = asihpi->mixer_level[addr][0] != left || asihpi->mixer_level[addr][1] != right; */ change = 1; - HPI_HandleError(HPI_LevelSetGain(phSubSys, hControl, anGain_mB)); + hpi_handle_error(hpi_level_set_gain(ph_subsys, h_control, an_gain_mB)); return change; } @@ -1614,7 +1614,7 @@ static int __devinit snd_asihpi_level_add(struct snd_card_asihpi *asihpi, struct snd_kcontrol_new snd_control; /* can't use 'volume' cos some nodes have volume as well */ - asihpi_ctl_init(&snd_control, asihpi_control, "Level"); + asihpi_ctl_init(&snd_control, asihpi_control, "level"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ; snd_control.info = snd_asihpi_level_info; @@ -1658,10 +1658,10 @@ static int snd_asihpi_aesebu_format_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol, u16 (*func)(const struct hpi_hsubsys *, u32, u16 *)) { - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; u16 source, err; - err = func(phSubSys, hControl, &source); + err = func(ph_subsys, h_control, &source); /* default to N/A */ ucontrol->value.enumerated.item[0] = 0; @@ -1680,7 +1680,7 @@ static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol, u16 (*func)(const struct hpi_hsubsys *, u32, u16)) { - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; /* default to S/PDIF */ u16 source = HPI_AESEBU_FORMAT_SPDIF; @@ -1690,7 +1690,7 @@ static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol, if (ucontrol->value.enumerated.item[0] == 2) source = HPI_AESEBU_FORMAT_AESEBU; - if (func(phSubSys, hControl, source) != 0) + if (func(ph_subsys, h_control, source) != 0) return -EINVAL; return 1; @@ -1699,13 +1699,13 @@ static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol, static int snd_asihpi_aesebu_rx_format_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return snd_asihpi_aesebu_format_get(kcontrol, ucontrol, - HPI_AESEBU_Receiver_GetFormat); + HPI_AESEBU__receiver_get_format); } static int snd_asihpi_aesebu_rx_format_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return snd_asihpi_aesebu_format_put(kcontrol, ucontrol, - HPI_AESEBU_Receiver_SetFormat); + HPI_AESEBU__receiver_set_format); } static int snd_asihpi_aesebu_rxstatus_info(struct snd_kcontrol *kcontrol, @@ -1724,10 +1724,10 @@ static int snd_asihpi_aesebu_rxstatus_info(struct snd_kcontrol *kcontrol, static int snd_asihpi_aesebu_rxstatus_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; u16 status; - HPI_HandleError(HPI_AESEBU_Receiver_GetErrorStatus(phSubSys, hControl, &status)); + hpi_handle_error(HPI_AESEBU__receiver_get_error_status(ph_subsys, h_control, &status)); ucontrol->value.integer.value[0] = status; return 0; } @@ -1738,7 +1738,7 @@ static int __devinit snd_asihpi_aesebu_rx_add(struct snd_card_asihpi *asihpi, struct snd_card *card = asihpi->card; struct snd_kcontrol_new snd_control; - asihpi_ctl_init(&snd_control, asihpi_control, "Format"); + asihpi_ctl_init(&snd_control, asihpi_control, "format"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; snd_control.info = snd_asihpi_aesebu_format_info; snd_control.get = snd_asihpi_aesebu_rx_format_get; @@ -1748,7 +1748,7 @@ static int __devinit snd_asihpi_aesebu_rx_add(struct snd_card_asihpi *asihpi, if (ctl_add(card, &snd_control, asihpi) < 0) return -EINVAL; - asihpi_ctl_init(&snd_control, asihpi_control, "Status"); + asihpi_ctl_init(&snd_control, asihpi_control, "status"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ; snd_control.info = snd_asihpi_aesebu_rxstatus_info; @@ -1760,13 +1760,13 @@ static int __devinit snd_asihpi_aesebu_rx_add(struct snd_card_asihpi *asihpi, static int snd_asihpi_aesebu_tx_format_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return snd_asihpi_aesebu_format_get(kcontrol, ucontrol, - HPI_AESEBU_Transmitter_GetFormat); + HPI_AESEBU__transmitter_get_format); } static int snd_asihpi_aesebu_tx_format_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return snd_asihpi_aesebu_format_put(kcontrol, ucontrol, - HPI_AESEBU_Transmitter_SetFormat); + HPI_AESEBU__transmitter_set_format); } @@ -1776,7 +1776,7 @@ static int __devinit snd_asihpi_aesebu_tx_add(struct snd_card_asihpi *asihpi, struct snd_card *card = asihpi->card; struct snd_kcontrol_new snd_control; - asihpi_ctl_init(&snd_control, asihpi_control, "Format"); + asihpi_ctl_init(&snd_control, asihpi_control, "format"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; snd_control.info = snd_asihpi_aesebu_format_info; snd_control.get = snd_asihpi_aesebu_tx_format_get; @@ -1794,22 +1794,22 @@ static int __devinit snd_asihpi_aesebu_tx_add(struct snd_card_asihpi *asihpi, static int snd_asihpi_tuner_gain_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; u16 err; short idx; - u16 gainRange[3]; + u16 gain_range[3]; for (idx = 0; idx < 3; idx++) { - err = HPI_Tuner_QueryGain(phSubSys, hControl, idx, &gainRange[idx]); + err = hpi_tuner_query_gain(ph_subsys, h_control, idx, &gain_range[idx]); if (err != 0) return err; } uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; - uinfo->value.integer.min = ((int)gainRange[0]) / HPI_UNITS_PER_dB; - uinfo->value.integer.max = ((int)gainRange[1]) / HPI_UNITS_PER_dB; - uinfo->value.integer.step = ((int) gainRange[2]) / HPI_UNITS_PER_dB; + uinfo->value.integer.min = ((int)gain_range[0]) / HPI_UNITS_PER_dB; + uinfo->value.integer.max = ((int)gain_range[1]) / HPI_UNITS_PER_dB; + uinfo->value.integer.step = ((int) gain_range[2]) / HPI_UNITS_PER_dB; return 0; } @@ -1819,10 +1819,10 @@ static int snd_asihpi_tuner_gain_get(struct snd_kcontrol *kcontrol, /* struct snd_card_asihpi *asihpi = snd_kcontrol_chip(kcontrol); */ - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; short gain; - HPI_HandleError(HPI_Tuner_GetGain(phSubSys, hControl, &gain)); + hpi_handle_error(hpi_tuner_get_gain(ph_subsys, h_control, &gain)); ucontrol->value.integer.value[0] = gain / HPI_UNITS_PER_dB; return 0; @@ -1834,11 +1834,11 @@ static int snd_asihpi_tuner_gain_put(struct snd_kcontrol *kcontrol, /* struct snd_card_asihpi *asihpi = snd_kcontrol_chip(kcontrol); */ - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; short gain; gain = (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB; - HPI_HandleError(HPI_Tuner_SetGain(phSubSys, hControl, gain)); + hpi_handle_error(hpi_tuner_set_gain(ph_subsys, h_control, gain)); return 1; } @@ -1846,13 +1846,13 @@ static int snd_asihpi_tuner_gain_put(struct snd_kcontrol *kcontrol, /* Band */ static int asihpi_tuner_band_query(struct snd_kcontrol *kcontrol, - u16 *bandList, u32 len) { - u32 hControl = kcontrol->private_value; + u16 *band_list, u32 len) { + u32 h_control = kcontrol->private_value; u16 err = 0; u32 i; for (i = 0; i < len; i++) { - err = HPI_Tuner_QueryBand(phSubSys, hControl, i, &bandList[i]); + err = hpi_tuner_query_band(ph_subsys, h_control, i, &band_list[i]); if (err != 0) break; } @@ -1866,20 +1866,20 @@ static int asihpi_tuner_band_query(struct snd_kcontrol *kcontrol, static int snd_asihpi_tuner_band_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - u16 tunerBands[HPI_TUNER_BAND_LAST]; - int numBands = 0; + u16 tuner_bands[HPI_TUNER_BAND_LAST]; + int num_bands = 0; - numBands = asihpi_tuner_band_query(kcontrol, tunerBands, + num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands, HPI_TUNER_BAND_LAST); - if (numBands < 0) - return numBands; + if (num_bands < 0) + return num_bands; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; - uinfo->value.enumerated.items = numBands; + uinfo->value.enumerated.items = num_bands; - if (numBands > 0) { + if (num_bands > 0) { if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) uinfo->value.enumerated.item = @@ -1887,7 +1887,7 @@ static int snd_asihpi_tuner_band_info(struct snd_kcontrol *kcontrol, strcpy(uinfo->value.enumerated.name, asihpi_tuner_band_names[ - tunerBands[uinfo->value.enumerated.item]]); + tuner_bands[uinfo->value.enumerated.item]]); } return 0; @@ -1896,22 +1896,22 @@ static int snd_asihpi_tuner_band_info(struct snd_kcontrol *kcontrol, static int snd_asihpi_tuner_band_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; /* struct snd_card_asihpi *asihpi = snd_kcontrol_chip(kcontrol); */ u16 band, idx; - u16 tunerBands[HPI_TUNER_BAND_LAST]; - u32 numBands = 0; + u16 tuner_bands[HPI_TUNER_BAND_LAST]; + u32 num_bands = 0; - numBands = asihpi_tuner_band_query(kcontrol, tunerBands, + num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands, HPI_TUNER_BAND_LAST); - HPI_HandleError(HPI_Tuner_GetBand(phSubSys, hControl, &band)); + hpi_handle_error(hpi_tuner_get_band(ph_subsys, h_control, &band)); ucontrol->value.enumerated.item[0] = -1; for (idx = 0; idx < HPI_TUNER_BAND_LAST; idx++) - if (tunerBands[idx] == band) { + if (tuner_bands[idx] == band) { ucontrol->value.enumerated.item[0] = idx; break; } @@ -1925,16 +1925,16 @@ static int snd_asihpi_tuner_band_put(struct snd_kcontrol *kcontrol, /* struct snd_card_asihpi *asihpi = snd_kcontrol_chip(kcontrol); */ - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; u16 band; - u16 tunerBands[HPI_TUNER_BAND_LAST]; - u32 numBands = 0; + u16 tuner_bands[HPI_TUNER_BAND_LAST]; + u32 num_bands = 0; - numBands = asihpi_tuner_band_query(kcontrol, tunerBands, + num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands, HPI_TUNER_BAND_LAST); - band = tunerBands[ucontrol->value.enumerated.item[0]]; - HPI_HandleError(HPI_Tuner_SetBand(phSubSys, hControl, band)); + band = tuner_bands[ucontrol->value.enumerated.item[0]]; + hpi_handle_error(hpi_tuner_set_band(ph_subsys, h_control, band)); return 1; } @@ -1944,55 +1944,55 @@ static int snd_asihpi_tuner_band_put(struct snd_kcontrol *kcontrol, static int snd_asihpi_tuner_freq_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; u16 err; - u16 tunerBands[HPI_TUNER_BAND_LAST]; - u16 numBands = 0, band_iter, idx; - u32 freqRange[3], tempFreqRange[3]; + u16 tuner_bands[HPI_TUNER_BAND_LAST]; + u16 num_bands = 0, band_iter, idx; + u32 freq_range[3], temp_freq_range[3]; - numBands = asihpi_tuner_band_query(kcontrol, tunerBands, + num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands, HPI_TUNER_BAND_LAST); - freqRange[0] = INT_MAX; - freqRange[1] = 0; - freqRange[2] = INT_MAX; + freq_range[0] = INT_MAX; + freq_range[1] = 0; + freq_range[2] = INT_MAX; - for (band_iter = 0; band_iter < numBands; band_iter++) { + for (band_iter = 0; band_iter < num_bands; band_iter++) { for (idx = 0; idx < 3; idx++) { - err = HPI_Tuner_QueryFrequency(phSubSys, hControl, - idx, tunerBands[band_iter], - &tempFreqRange[idx]); + err = hpi_tuner_query_frequency(ph_subsys, h_control, + idx, tuner_bands[band_iter], + &temp_freq_range[idx]); if (err != 0) return err; } /* skip band with bogus stepping */ - if (tempFreqRange[2] <= 0) + if (temp_freq_range[2] <= 0) continue; - if (tempFreqRange[0] < freqRange[0]) - freqRange[0] = tempFreqRange[0]; - if (tempFreqRange[1] > freqRange[1]) - freqRange[1] = tempFreqRange[1]; - if (tempFreqRange[2] < freqRange[2]) - freqRange[2] = tempFreqRange[2]; + if (temp_freq_range[0] < freq_range[0]) + freq_range[0] = temp_freq_range[0]; + if (temp_freq_range[1] > freq_range[1]) + freq_range[1] = temp_freq_range[1]; + if (temp_freq_range[2] < freq_range[2]) + freq_range[2] = temp_freq_range[2]; } uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; - uinfo->value.integer.min = ((int)freqRange[0]); - uinfo->value.integer.max = ((int)freqRange[1]); - uinfo->value.integer.step = ((int)freqRange[2]); + uinfo->value.integer.min = ((int)freq_range[0]); + uinfo->value.integer.max = ((int)freq_range[1]); + uinfo->value.integer.step = ((int)freq_range[2]); return 0; } static int snd_asihpi_tuner_freq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; u32 freq; - HPI_HandleError(HPI_Tuner_GetFrequency(phSubSys, hControl, &freq)); + hpi_handle_error(hpi_tuner_get_frequency(ph_subsys, h_control, &freq)); ucontrol->value.integer.value[0] = freq; return 0; @@ -2001,11 +2001,11 @@ static int snd_asihpi_tuner_freq_get(struct snd_kcontrol *kcontrol, static int snd_asihpi_tuner_freq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; u32 freq; freq = ucontrol->value.integer.value[0]; - HPI_HandleError(HPI_Tuner_SetFrequency(phSubSys, hControl, freq)); + hpi_handle_error(hpi_tuner_set_frequency(ph_subsys, h_control, freq)); return 1; } @@ -2017,11 +2017,11 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi, struct snd_card *card = asihpi->card; struct snd_kcontrol_new snd_control; - snd_control.private_value = asihpi_control->hControl; + snd_control.private_value = asihpi_control->h_control; snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; - if (HPI_Tuner_GetGain(phSubSys, asihpi_control->hControl, NULL) == 0) { - asihpi_ctl_init(&snd_control, asihpi_control, "Gain"); + if (hpi_tuner_get_gain(ph_subsys, asihpi_control->h_control, NULL) == 0) { + asihpi_ctl_init(&snd_control, asihpi_control, "gain"); snd_control.info = snd_asihpi_tuner_gain_info; snd_control.get = snd_asihpi_tuner_gain_get; snd_control.put = snd_asihpi_tuner_gain_put; @@ -2030,7 +2030,7 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi, return -EINVAL; } - asihpi_ctl_init(&snd_control, asihpi_control, "Band"); + asihpi_ctl_init(&snd_control, asihpi_control, "band"); snd_control.info = snd_asihpi_tuner_band_info; snd_control.get = snd_asihpi_tuner_band_get; snd_control.put = snd_asihpi_tuner_band_put; @@ -2038,7 +2038,7 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi, if (ctl_add(card, &snd_control, asihpi) < 0) return -EINVAL; - asihpi_ctl_init(&snd_control, asihpi_control, "Freq"); + asihpi_ctl_init(&snd_control, asihpi_control, "freq"); snd_control.info = snd_asihpi_tuner_freq_info; snd_control.get = snd_asihpi_tuner_freq_get; snd_control.put = snd_asihpi_tuner_freq_put; @@ -2085,24 +2085,24 @@ static int log2lin[] = { static int snd_asihpi_meter_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - u32 hControl = kcontrol->private_value; - short anGain_mB[HPI_MAX_CHANNELS], i; + u32 h_control = kcontrol->private_value; + short an_gain_mB[HPI_MAX_CHANNELS], i; u16 err; - err = HPI_MeterGetPeak(phSubSys, hControl, anGain_mB); + err = hpi_meter_get_peak(ph_subsys, h_control, an_gain_mB); for (i = 0; i < HPI_MAX_CHANNELS; i++) { if (err) { ucontrol->value.integer.value[i] = 0; - } else if (anGain_mB[i] >= 0) { + } else if (an_gain_mB[i] >= 0) { ucontrol->value.integer.value[i] = - anGain_mB[i] << 16; + an_gain_mB[i] << 16; } else { /* -ve is log value in millibels < -60dB, * convert to (roughly!) linear, */ ucontrol->value.integer.value[i] = - log2lin[anGain_mB[i] / -1000]; + log2lin[an_gain_mB[i] / -1000]; } } return 0; @@ -2114,7 +2114,7 @@ static int __devinit snd_asihpi_meter_add(struct snd_card_asihpi *asihpi, struct snd_card *card = asihpi->card; struct snd_kcontrol_new snd_control; - asihpi_ctl_init(&snd_control, asihpi_control, "Meter"); + asihpi_ctl_init(&snd_control, asihpi_control, "meter"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ; snd_control.info = snd_asihpi_meter_info; @@ -2130,15 +2130,15 @@ static int __devinit snd_asihpi_meter_add(struct snd_card_asihpi *asihpi, ------------------------------------------------------------*/ static int snd_card_asihpi_mux_count_sources(struct snd_kcontrol *snd_control) { - u32 hControl = snd_control->private_value; + u32 h_control = snd_control->private_value; struct hpi_control asihpi_control; int s, err; for (s = 0; s < 32; s++) { - err = HPI_Multiplexer_QuerySource(phSubSys, hControl, s, + err = hpi_multiplexer_query_source(ph_subsys, h_control, s, &asihpi_control. - wSrcNodeType, + src_node_type, &asihpi_control. - wSrcNodeIndex); + src_node_index); if (err) break; } @@ -2149,8 +2149,8 @@ static int snd_asihpi_mux_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int err; - u16 wSrcNodeType, wSrcNodeIndex; - u32 hControl = kcontrol->private_value; + u16 src_node_type, src_node_index; + u32 h_control = kcontrol->private_value; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -2162,40 +2162,40 @@ static int snd_asihpi_mux_info(struct snd_kcontrol *kcontrol, uinfo->value.enumerated.items - 1; err = - HPI_Multiplexer_QuerySource(phSubSys, hControl, + hpi_multiplexer_query_source(ph_subsys, h_control, uinfo->value.enumerated.item, - &wSrcNodeType, &wSrcNodeIndex); + &src_node_type, &src_node_index); sprintf(uinfo->value.enumerated.name, "%s %d", - asihpi_src_names[wSrcNodeType - HPI_SOURCENODE_BASE], - wSrcNodeIndex); + asihpi_src_names[src_node_type - HPI_SOURCENODE_BASE], + src_node_index); return 0; } static int snd_asihpi_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - u32 hControl = kcontrol->private_value; - u16 wSourceType, wSourceIndex; - u16 wSrcNodeType, wSrcNodeIndex; + u32 h_control = kcontrol->private_value; + u16 source_type, source_index; + u16 src_node_type, src_node_index; int s; - HPI_HandleError(HPI_Multiplexer_GetSource(phSubSys, hControl, - &wSourceType, &wSourceIndex)); + hpi_handle_error(hpi_multiplexer_get_source(ph_subsys, h_control, + &source_type, &source_index)); /* Should cache this search result! */ for (s = 0; s < 256; s++) { - if (HPI_Multiplexer_QuerySource(phSubSys, hControl, s, - &wSrcNodeType, &wSrcNodeIndex)) + if (hpi_multiplexer_query_source(ph_subsys, h_control, s, + &src_node_type, &src_node_index)) break; - if ((wSourceType == wSrcNodeType) - && (wSourceIndex == wSrcNodeIndex)) { + if ((source_type == src_node_type) + && (source_index == src_node_index)) { ucontrol->value.enumerated.item[0] = s; return 0; } } - snd_printd(KERN_WARNING "Control %x failed to match mux source %hu %hu\n", - hControl, wSourceType, wSourceIndex); + snd_printd(KERN_WARNING "control %x failed to match mux source %hu %hu\n", + h_control, source_type, source_index); ucontrol->value.enumerated.item[0] = 0; return 0; } @@ -2204,18 +2204,18 @@ static int snd_asihpi_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int change; - u32 hControl = kcontrol->private_value; - u16 wSourceType, wSourceIndex; + u32 h_control = kcontrol->private_value; + u16 source_type, source_index; u16 e; change = 1; - e = HPI_Multiplexer_QuerySource(phSubSys, hControl, + e = hpi_multiplexer_query_source(ph_subsys, h_control, ucontrol->value.enumerated.item[0], - &wSourceType, &wSourceIndex); + &source_type, &source_index); if (!e) - HPI_HandleError(HPI_Multiplexer_SetSource(phSubSys, hControl, - wSourceType, wSourceIndex)); + hpi_handle_error(hpi_multiplexer_set_source(ph_subsys, h_control, + source_type, source_index)); return change; } @@ -2227,9 +2227,9 @@ static int __devinit snd_asihpi_mux_add(struct snd_card_asihpi *asihpi, struct snd_kcontrol_new snd_control; #if ASI_STYLE_NAMES - asihpi_ctl_init(&snd_control, asihpi_control, "Multiplexer"); + asihpi_ctl_init(&snd_control, asihpi_control, "multiplexer"); #else - asihpi_ctl_init(&snd_control, asihpi_control, "Route"); + asihpi_ctl_init(&snd_control, asihpi_control, "route"); #endif snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; snd_control.info = snd_asihpi_mux_info; @@ -2247,18 +2247,18 @@ static int snd_asihpi_cmode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *mode_names[HPI_CHANNEL_MODE_LAST] = { - "Normal", "Swap", "FromLeft", "FromRight", "ToLeft", "ToRight" + "normal", "swap", "from_left", "from_right", "to_left", "to_right" }; - u32 hControl = kcontrol->private_value; - u16 wMode; + u32 h_control = kcontrol->private_value; + u16 mode; int i; /* HPI channel mode values can be from 1 to 6 Some adapters only support a contiguous subset */ for (i = 0; i < HPI_CHANNEL_MODE_LAST; i++) - if (HPI_ChannelMode_QueryMode(phSubSys, hControl, i, &wMode)) + if (hpi_channel_mode_query_mode(ph_subsys, h_control, i, &mode)) break; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -2277,13 +2277,13 @@ static int snd_asihpi_cmode_info(struct snd_kcontrol *kcontrol, static int snd_asihpi_cmode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - u32 hControl = kcontrol->private_value; - u16 wMode; + u32 h_control = kcontrol->private_value; + u16 mode; - if (HPI_ChannelModeGet(phSubSys, hControl, &wMode)) - wMode = 1; + if (hpi_channel_mode_get(ph_subsys, h_control, &mode)) + mode = 1; - ucontrol->value.enumerated.item[0] = wMode - 1; + ucontrol->value.enumerated.item[0] = mode - 1; return 0; } @@ -2292,11 +2292,11 @@ static int snd_asihpi_cmode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int change; - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; change = 1; - HPI_HandleError(HPI_ChannelModeSet(phSubSys, hControl, + hpi_handle_error(hpi_channel_mode_set(ph_subsys, h_control, ucontrol->value.enumerated.item[0] + 1)); return change; } @@ -2308,7 +2308,7 @@ static int __devinit snd_asihpi_cmode_add(struct snd_card_asihpi *asihpi, struct snd_card *card = asihpi->card; struct snd_kcontrol_new snd_control; - asihpi_ctl_init(&snd_control, asihpi_control, "Channel Mode"); + asihpi_ctl_init(&snd_control, asihpi_control, "channel mode"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; snd_control.info = snd_asihpi_cmode_info; snd_control.get = snd_asihpi_cmode_get; @@ -2322,11 +2322,11 @@ static int __devinit snd_asihpi_cmode_add(struct snd_card_asihpi *asihpi, ------------------------------------------------------------*/ static char *sampleclock_sources[MAX_CLOCKSOURCES] = - { "N/A", "Local PLL", "AES/EBU Sync", "Word External", "Word Header", - "SMPTE", "AES/EBU In1", "Auto", "Network", "Invalid", - "Prev Module", - "AES/EBU In2", "AES/EBU In3", "AES/EBU In4", "AES/EBU In5", - "AES/EBU In6", "AES/EBU In7", "AES/EBU In8"}; + { "N/A", "local PLL", "AES/EBU sync", "word external", "word header", + "SMPTE", "AES/EBU in1", "auto", "network", "invalid", + "prev module", + "AES/EBU in2", "AES/EBU in3", "AES/EBU in4", "AES/EBU in5", + "AES/EBU in6", "AES/EBU in7", "AES/EBU in8"}; @@ -2355,21 +2355,21 @@ static int snd_asihpi_clksrc_get(struct snd_kcontrol *kcontrol, struct snd_card_asihpi *asihpi = (struct snd_card_asihpi *)(kcontrol->private_data); struct clk_cache *clkcache = &asihpi->cc; - u32 hControl = kcontrol->private_value; - u16 wSource, wIndex = 0; + u32 h_control = kcontrol->private_value; + u16 source, index = 0; int i; ucontrol->value.enumerated.item[0] = 0; - if (HPI_SampleClock_GetSource(phSubSys, hControl, &wSource)) - wSource = 0; + if (hpi_sample_clock_get_source(ph_subsys, h_control, &source)) + source = 0; - if (wSource == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) - if (HPI_SampleClock_GetSourceIndex(phSubSys, hControl, &wIndex)) - wIndex = 0; + if (source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) + if (hpi_sample_clock_get_source_index(ph_subsys, h_control, &index)) + index = 0; for (i = 0; i < clkcache->count; i++) - if ((clkcache->s[i].source == wSource) && - (clkcache->s[i].index == wIndex)) + if ((clkcache->s[i].source == source) && + (clkcache->s[i].index == index)) break; ucontrol->value.enumerated.item[0] = i; @@ -2384,19 +2384,19 @@ static int snd_asihpi_clksrc_put(struct snd_kcontrol *kcontrol, (struct snd_card_asihpi *)(kcontrol->private_data); struct clk_cache *clkcache = &asihpi->cc; int change, item; - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; change = 1; item = ucontrol->value.enumerated.item[0]; if (item >= clkcache->count) item = clkcache->count-1; - HPI_HandleError(HPI_SampleClock_SetSource(phSubSys, - hControl, clkcache->s[item].source)); + hpi_handle_error(hpi_sample_clock_set_source(ph_subsys, + h_control, clkcache->s[item].source)); if (clkcache->s[item].source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) - HPI_HandleError(HPI_SampleClock_SetSourceIndex(phSubSys, - hControl, clkcache->s[item].index)); + hpi_handle_error(hpi_sample_clock_set_source_index(ph_subsys, + h_control, clkcache->s[item].index)); return change; } @@ -2419,13 +2419,13 @@ static int snd_asihpi_clklocal_info(struct snd_kcontrol *kcontrol, static int snd_asihpi_clklocal_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - u32 hControl = kcontrol->private_value; - u32 dwRate; + u32 h_control = kcontrol->private_value; + u32 rate; u16 e; - e = HPI_SampleClock_GetLocalRate(phSubSys, hControl, &dwRate); + e = hpi_sample_clock_get_local_rate(ph_subsys, h_control, &rate); if (!e) - ucontrol->value.integer.value[0] = dwRate; + ucontrol->value.integer.value[0] = rate; else ucontrol->value.integer.value[0] = 0; return 0; @@ -2435,13 +2435,13 @@ static int snd_asihpi_clklocal_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int change; - u32 hControl = kcontrol->private_value; + u32 h_control = kcontrol->private_value; /* change = asihpi->mixer_clkrate[addr][0] != left || asihpi->mixer_clkrate[addr][1] != right; */ change = 1; - HPI_HandleError(HPI_SampleClock_SetLocalRate(phSubSys, hControl, + hpi_handle_error(hpi_sample_clock_set_local_rate(ph_subsys, h_control, ucontrol->value.integer.value[0])); return change; } @@ -2461,13 +2461,13 @@ static int snd_asihpi_clkrate_info(struct snd_kcontrol *kcontrol, static int snd_asihpi_clkrate_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - u32 hControl = kcontrol->private_value; - u32 dwRate; + u32 h_control = kcontrol->private_value; + u32 rate; u16 e; - e = HPI_SampleClock_GetSampleRate(phSubSys, hControl, &dwRate); + e = hpi_sample_clock_get_sample_rate(ph_subsys, h_control, &rate); if (!e) - ucontrol->value.integer.value[0] = dwRate; + ucontrol->value.integer.value[0] = rate; else ucontrol->value.integer.value[0] = 0; return 0; @@ -2480,33 +2480,33 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, struct snd_kcontrol_new snd_control; struct clk_cache *clkcache = &asihpi->cc; - u32 hSC = asihpi_control->hControl; - int hasAesIn = 0; + u32 hSC = asihpi_control->h_control; + int has_aes_in = 0; int i, j; - u16 wSource; + u16 source; - snd_control.private_value = asihpi_control->hControl; + snd_control.private_value = asihpi_control->h_control; clkcache->has_local = 0; for (i = 0; i <= HPI_SAMPLECLOCK_SOURCE_LAST; i++) { - if (HPI_SampleClock_QuerySource(phSubSys, hSC, - i, &wSource)) + if (hpi_sample_clock_query_source(ph_subsys, hSC, + i, &source)) break; - clkcache->s[i].source = wSource; + clkcache->s[i].source = source; clkcache->s[i].index = 0; - clkcache->s[i].name = sampleclock_sources[wSource]; - if (wSource == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) - hasAesIn = 1; - if (wSource == HPI_SAMPLECLOCK_SOURCE_LOCAL) + clkcache->s[i].name = sampleclock_sources[source]; + if (source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) + has_aes_in = 1; + if (source == HPI_SAMPLECLOCK_SOURCE_LOCAL) clkcache->has_local = 1; } - if (hasAesIn) + if (has_aes_in) /* already will have picked up index 0 above */ for (j = 1; j < 8; j++) { - if (HPI_SampleClock_QuerySourceIndex(phSubSys, hSC, + if (hpi_sample_clock_query_source_index(ph_subsys, hSC, j, HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT, - &wSource)) + &source)) break; clkcache->s[i].source = HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT; @@ -2517,7 +2517,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, } clkcache->count = i; - asihpi_ctl_init(&snd_control, asihpi_control, "Source"); + asihpi_ctl_init(&snd_control, asihpi_control, "source"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE ; snd_control.info = snd_asihpi_clksrc_info; snd_control.get = snd_asihpi_clksrc_get; @@ -2527,7 +2527,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, if (clkcache->has_local) { - asihpi_ctl_init(&snd_control, asihpi_control, "LocalRate"); + asihpi_ctl_init(&snd_control, asihpi_control, "local_rate"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE ; snd_control.info = snd_asihpi_clklocal_info; snd_control.get = snd_asihpi_clklocal_get; @@ -2538,7 +2538,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, return -EINVAL; } - asihpi_ctl_init(&snd_control, asihpi_control, "Rate"); + asihpi_ctl_init(&snd_control, asihpi_control, "rate"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ; snd_control.info = snd_asihpi_clkrate_info; @@ -2560,29 +2560,29 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) if (snd_BUG_ON(!asihpi)) return -EINVAL; - strcpy(card->mixername, "Asihpi Mixer"); + strcpy(card->mixername, "asihpi mixer"); err = - HPI_MixerOpen(phSubSys, asihpi->wAdapterIndex, - &asihpi->hMixer); - HPI_HandleError(err); + hpi_mixer_open(ph_subsys, asihpi->adapter_index, + &asihpi->h_mixer); + hpi_handle_error(err); if (err) return -err; for (idx = 0; idx < 2000; idx++) { - err = HPI_MixerGetControlByIndex(phSubSys, asihpi->hMixer, + err = hpi_mixer_get_control_by_index(ph_subsys, asihpi->h_mixer, idx, - &asihpi_control.wSrcNodeType, - &asihpi_control.wSrcNodeIndex, - &asihpi_control.wDstNodeType, - &asihpi_control.wDstNodeIndex, - &asihpi_control.wControlType, - &asihpi_control.hControl); + &asihpi_control.src_node_type, + &asihpi_control.src_node_index, + &asihpi_control.dst_node_type, + &asihpi_control.dst_node_index, + &asihpi_control.control_type, + &asihpi_control.h_control); if (err) { if (err == HPI_ERROR_CONTROL_DISABLED) { if (mixer_dump) snd_printk(KERN_INFO - "Disabled HPI Control(%d)\n", + "disabled HPI control(%d)\n", idx); continue; } else @@ -2590,25 +2590,25 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) } - asihpi_control.wSrcNodeType -= HPI_SOURCENODE_BASE; - asihpi_control.wDstNodeType -= HPI_DESTNODE_BASE; + asihpi_control.src_node_type -= HPI_SOURCENODE_BASE; + asihpi_control.dst_node_type -= HPI_DESTNODE_BASE; /* ASI50xx in SSX mode has multiple meters on the same node. Use subindex to create distinct ALSA controls for any duplicated controls. */ - if ((asihpi_control.wControlType == prev_control.wControlType) && - (asihpi_control.wSrcNodeType == prev_control.wSrcNodeType) && - (asihpi_control.wSrcNodeIndex == prev_control.wSrcNodeIndex) && - (asihpi_control.wDstNodeType == prev_control.wDstNodeType) && - (asihpi_control.wDstNodeIndex == prev_control.wDstNodeIndex)) + if ((asihpi_control.control_type == prev_control.control_type) && + (asihpi_control.src_node_type == prev_control.src_node_type) && + (asihpi_control.src_node_index == prev_control.src_node_index) && + (asihpi_control.dst_node_type == prev_control.dst_node_type) && + (asihpi_control.dst_node_index == prev_control.dst_node_index)) subindex++; else subindex = 0; prev_control = asihpi_control; - switch (asihpi_control.wControlType) { + switch (asihpi_control.control_type) { case HPI_CONTROL_VOLUME: err = snd_asihpi_volume_add(asihpi, &asihpi_control); break; @@ -2647,21 +2647,21 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) default: if (mixer_dump) snd_printk(KERN_INFO - "Untranslated HPI Control" + "untranslated HPI control" "(%d) %d %d %d %d %d\n", idx, - asihpi_control.wControlType, - asihpi_control.wSrcNodeType, - asihpi_control.wSrcNodeIndex, - asihpi_control.wDstNodeType, - asihpi_control.wDstNodeIndex); + asihpi_control.control_type, + asihpi_control.src_node_type, + asihpi_control.src_node_index, + asihpi_control.dst_node_type, + asihpi_control.dst_node_index); continue; }; if (err < 0) return err; } if (HPI_ERROR_INVALID_OBJ_INDEX != err) - HPI_HandleError(err); + hpi_handle_error(err); snd_printk(KERN_INFO "%d mixer controls found\n", idx); @@ -2677,38 +2677,38 @@ snd_asihpi_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { struct snd_card_asihpi *asihpi = entry->private_data; - u16 wVersion; - u32 hControl; - u32 dwRate = 0; - u16 wSource = 0; + u16 version; + u32 h_control; + u32 rate = 0; + u16 source = 0; int err; snd_iprintf(buffer, "ASIHPI driver proc file\n"); snd_iprintf(buffer, - "Adapter ID=%4X\nIndex=%d\n" - "NumOutStreams=%d\nNumInStreams=%d\n", - asihpi->wType, asihpi->wAdapterIndex, - asihpi->wNumOutStreams, asihpi->wNumInStreams); + "adapter ID=%4X\n_index=%d\n" + "num_outstreams=%d\n_num_instreams=%d\n", + asihpi->type, asihpi->adapter_index, + asihpi->num_outstreams, asihpi->num_instreams); - wVersion = asihpi->wVersion; + version = asihpi->version; snd_iprintf(buffer, - "Serial#=%d\nHw Version %c%d\nDSP code version %03d\n", - asihpi->dwSerialNumber, ((wVersion >> 3) & 0xf) + 'A', - wVersion & 0x7, - ((wVersion >> 13) * 100) + ((wVersion >> 7) & 0x3f)); + "serial#=%d\n_hw version %c%d\nDSP code version %03d\n", + asihpi->serial_number, ((version >> 3) & 0xf) + 'A', + version & 0x7, + ((version >> 13) * 100) + ((version >> 7) & 0x3f)); - err = HPI_MixerGetControl(phSubSys, asihpi->hMixer, + err = hpi_mixer_get_control(ph_subsys, asihpi->h_mixer, HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, - HPI_CONTROL_SAMPLECLOCK, &hControl); + HPI_CONTROL_SAMPLECLOCK, &h_control); if (!err) { - err = HPI_SampleClock_GetSampleRate(phSubSys, - hControl, &dwRate); - err += HPI_SampleClock_GetSource(phSubSys, hControl, &wSource); + err = hpi_sample_clock_get_sample_rate(ph_subsys, + h_control, &rate); + err += hpi_sample_clock_get_source(ph_subsys, h_control, &source); if (!err) - snd_iprintf(buffer, "SampleClock=%dHz, source %s\n", - dwRate, sampleclock_sources[wSource]); + snd_iprintf(buffer, "sample_clock=%d_hz, source %s\n", + rate, sampleclock_sources[source]); } } @@ -2786,15 +2786,15 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, { int err; - u16 wVersion; + u16 version; int pcm_substreams; struct hpi_adapter *hpi_card; struct snd_card *card; struct snd_card_asihpi *asihpi; - u32 hControl; - u32 hStream; + u32 h_control; + u32 h_stream; static int dev; if (dev >= SNDRV_CARDS) @@ -2826,63 +2826,63 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, if (err < 0) return err; snd_printk(KERN_WARNING - "**** WARNING **** Adapter index %d->ALSA index %d\n", + "**** WARNING **** adapter index %d->ALSA index %d\n", hpi_card->index, card->number); } asihpi = (struct snd_card_asihpi *) card->private_data; asihpi->card = card; asihpi->pci = hpi_card->pci; - asihpi->wAdapterIndex = hpi_card->index; - HPI_HandleError(HPI_AdapterGetInfo(phSubSys, - asihpi->wAdapterIndex, - &asihpi->wNumOutStreams, - &asihpi->wNumInStreams, - &asihpi->wVersion, - &asihpi->dwSerialNumber, &asihpi->wType)); - - wVersion = asihpi->wVersion; - snd_printk(KERN_INFO "Adapter ID=%4X Index=%d NumOutStreams=%d " - "NumInStreams=%d S/N=%d\n" - "Hw Version %c%d DSP code version %03d\n", - asihpi->wType, asihpi->wAdapterIndex, - asihpi->wNumOutStreams, - asihpi->wNumInStreams, asihpi->dwSerialNumber, - ((wVersion >> 3) & 0xf) + 'A', - wVersion & 0x7, - ((wVersion >> 13) * 100) + ((wVersion >> 7) & 0x3f)); - - pcm_substreams = asihpi->wNumOutStreams; - if (pcm_substreams < asihpi->wNumInStreams) - pcm_substreams = asihpi->wNumInStreams; - - err = HPI_AdapterGetProperty(phSubSys, asihpi->wAdapterIndex, + asihpi->adapter_index = hpi_card->index; + hpi_handle_error(hpi_adapter_get_info(ph_subsys, + asihpi->adapter_index, + &asihpi->num_outstreams, + &asihpi->num_instreams, + &asihpi->version, + &asihpi->serial_number, &asihpi->type)); + + version = asihpi->version; + snd_printk(KERN_INFO "adapter ID=%4X index=%d num_outstreams=%d " + "num_instreams=%d S/N=%d\n" + "hw version %c%d DSP code version %03d\n", + asihpi->type, asihpi->adapter_index, + asihpi->num_outstreams, + asihpi->num_instreams, asihpi->serial_number, + ((version >> 3) & 0xf) + 'A', + version & 0x7, + ((version >> 13) * 100) + ((version >> 7) & 0x3f)); + + pcm_substreams = asihpi->num_outstreams; + if (pcm_substreams < asihpi->num_instreams) + pcm_substreams = asihpi->num_instreams; + + err = hpi_adapter_get_property(ph_subsys, asihpi->adapter_index, HPI_ADAPTER_PROPERTY_CAPS1, NULL, &asihpi->support_grouping); if (err) asihpi->support_grouping = 0; - err = HPI_AdapterGetProperty(phSubSys, asihpi->wAdapterIndex, + err = hpi_adapter_get_property(ph_subsys, asihpi->adapter_index, HPI_ADAPTER_PROPERTY_CAPS2, &asihpi->support_mrx, NULL); if (err) asihpi->support_mrx = 0; - err = HPI_AdapterGetProperty(phSubSys, asihpi->wAdapterIndex, + err = hpi_adapter_get_property(ph_subsys, asihpi->adapter_index, HPI_ADAPTER_PROPERTY_INTERVAL, NULL, &asihpi->update_interval_frames); if (err) asihpi->update_interval_frames = 512; - HPI_HandleError(HPI_InStreamOpen(phSubSys, asihpi->wAdapterIndex, - 0, &hStream)); + hpi_handle_error(hpi_instream_open(ph_subsys, asihpi->adapter_index, + 0, &h_stream)); - err = HPI_InStreamHostBufferFree(phSubSys, hStream); + err = hpi_instream_host_buffer_free(ph_subsys, h_stream); asihpi->support_mmap = (!err); - HPI_HandleError(HPI_InStreamClose(phSubSys, hStream)); + hpi_handle_error(hpi_instream_close(ph_subsys, h_stream)); - err = HPI_AdapterGetProperty(phSubSys, asihpi->wAdapterIndex, + err = hpi_adapter_get_property(ph_subsys, asihpi->adapter_index, HPI_ADAPTER_PROPERTY_CURCHANNELS, &asihpi->in_max_chans, &asihpi->out_max_chans); if (err) { @@ -2890,7 +2890,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, asihpi->out_max_chans = 2; } - snd_printk(KERN_INFO "Supports mmap:%d grouping:%d mrx:%d\n", + snd_printk(KERN_INFO "supports mmap:%d grouping:%d mrx:%d\n", asihpi->support_mmap, asihpi->support_grouping, asihpi->support_mrx @@ -2908,13 +2908,13 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, goto __nodev; } - err = HPI_MixerGetControl(phSubSys, asihpi->hMixer, + err = hpi_mixer_get_control(ph_subsys, asihpi->h_mixer, HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0, - HPI_CONTROL_SAMPLECLOCK, &hControl); + HPI_CONTROL_SAMPLECLOCK, &h_control); if (!err) - err = HPI_SampleClock_SetLocalRate(phSubSys, - hControl, adapter_fs); + err = hpi_sample_clock_set_local_rate(ph_subsys, + h_control, adapter_fs); snd_asihpi_proc_init(asihpi); @@ -2927,9 +2927,9 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, else strcpy(card->driver, "ASIHPI"); - sprintf(card->shortname, "AudioScience ASI%4X", asihpi->wType); + sprintf(card->shortname, "AudioScience ASI%4X", asihpi->type); sprintf(card->longname, "%s %i", - card->shortname, asihpi->wAdapterIndex); + card->shortname, asihpi->adapter_index); err = snd_card_register(card); if (!err) { hpi_card->snd_card_asihpi = card; diff --git a/pci/asihpi/hpi.h b/pci/asihpi/hpi.h index b89a55764..d84af71b2 100644 --- a/pci/asihpi/hpi.h +++ b/pci/asihpi/hpi.h @@ -26,11 +26,12 @@ AudioScience digital audio adapters */ /* - You must define one operating systems that the HPI is to be compiled under - HPI_OS_WIN32_USER 32bit Windows - HPI_OS_DSP_C6000 DSP TI C6000 environment - HPI_OS_WDM Windows WDM kernel driver - HPI_OS_LINUX Linux kernel driver + You must define one operating system that the HPI is to be compiled under + HPI_OS_WIN32_USER 32bit Windows + HPI_OS_DSP_C6000 DSP TI C6000 (automatically set) + HPI_OS_WDM Windows WDM kernel driver + HPI_OS_LINUX Linux userspace + HPI_OS_LINUX_KERNEL Linux kernel (automatically set) (C) Copyright AudioScience Inc. 1998-2010 ******************************************************************************/ @@ -49,7 +50,7 @@ i.e 3.05.02 is a development version #define HPI_VER_RELEASE(v) ((int)(v & 0xFF)) /* Use single digits for versions less that 10 to avoid octal. */ -#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 3, 13) +#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 3, 18) /* Library version as documented in hpi-api-versions.txt */ #define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0) @@ -215,16 +216,16 @@ enum HPI_SOURCENODES { /** Line in node - could be analog, AES/EBU or network. */ HPI_SOURCENODE_LINEIN = 102, HPI_SOURCENODE_AESEBU_IN = 103, /**< AES/EBU input node. */ - HPI_SOURCENODE_TUNER = 104, /**< Tuner node. */ + HPI_SOURCENODE_TUNER = 104, /**< tuner node. */ HPI_SOURCENODE_RF = 105, /**< RF input node. */ - HPI_SOURCENODE_CLOCK_SOURCE = 106, /**< Clock source node. */ - HPI_SOURCENODE_RAW_BITSTREAM = 107, /**< Raw bitstream node. */ - HPI_SOURCENODE_MICROPHONE = 108, /**< Microphone node. */ + HPI_SOURCENODE_CLOCK_SOURCE = 106, /**< clock source node. */ + HPI_SOURCENODE_RAW_BITSTREAM = 107, /**< raw bitstream node. */ + HPI_SOURCENODE_MICROPHONE = 108, /**< microphone node. */ /** Cobranet input node - Audio samples come from the Cobranet network and into the device. */ HPI_SOURCENODE_COBRANET = 109, - HPI_SOURCENODE_ANALOG = 110, /**< Analog input node. */ - HPI_SOURCENODE_ADAPTER = 111, /**< Adapter node. */ + HPI_SOURCENODE_ANALOG = 110, /**< analog input node. */ + HPI_SOURCENODE_ADAPTER = 111, /**< adapter node. */ /* !!!Update this AND hpidebug.h if you add a new sourcenode type!!! */ HPI_SOURCENODE_LAST_INDEX = 111 /**< largest ID */ /* AX6 max sourcenode types = 15 */ @@ -244,14 +245,14 @@ enum HPI_DESTNODES { HPI_DESTNODE_BASE = 200, /** In Stream (Record) node. */ HPI_DESTNODE_ISTREAM = 201, - HPI_DESTNODE_LINEOUT = 202, /**< Line Out node. */ + HPI_DESTNODE_LINEOUT = 202, /**< line out node. */ HPI_DESTNODE_AESEBU_OUT = 203, /**< AES/EBU output node. */ HPI_DESTNODE_RF = 204, /**< RF output node. */ - HPI_DESTNODE_SPEAKER = 205, /**< Speaker output node. */ + HPI_DESTNODE_SPEAKER = 205, /**< speaker output node. */ /** Cobranet output node - Audio samples from the device are sent out on the Cobranet network.*/ HPI_DESTNODE_COBRANET = 206, - HPI_DESTNODE_ANALOG = 207, /**< Analog output node. */ + HPI_DESTNODE_ANALOG = 207, /**< analog output node. */ /* !!!Update this AND hpidebug.h if you add a new destnode type!!! */ HPI_DESTNODE_LAST_INDEX = 207 /**< largest ID */ @@ -263,12 +264,12 @@ enum HPI_DESTNODES { \ingroup mixer */ enum HPI_CONTROLS { - HPI_CONTROL_GENERIC = 0, /**< Generic control. */ + HPI_CONTROL_GENERIC = 0, /**< generic control. */ HPI_CONTROL_CONNECTION = 1, /**< A connection between nodes. */ - HPI_CONTROL_VOLUME = 2, /**< Volume control - works in dBFs. */ - HPI_CONTROL_METER = 3, /**< Peak meter control. */ - HPI_CONTROL_MUTE = 4, /*Mute control - not used at present. */ - HPI_CONTROL_MULTIPLEXER = 5, /**< Multiplexer control. */ + HPI_CONTROL_VOLUME = 2, /**< volume control - works in dB_fs. */ + HPI_CONTROL_METER = 3, /**< peak meter control. */ + HPI_CONTROL_MUTE = 4, /*mute control - not used at present. */ + HPI_CONTROL_MULTIPLEXER = 5, /**< multiplexer control. */ HPI_CONTROL_AESEBU_TRANSMITTER = 6, /**< AES/EBU transmitter control. */ HPI_CONTROL_AESEBUTX = HPI_CONTROL_AESEBU_TRANSMITTER, @@ -276,31 +277,31 @@ enum HPI_CONTROLS { HPI_CONTROL_AESEBU_RECEIVER = 7, /**< AES/EBU receiver control. */ HPI_CONTROL_AESEBURX = HPI_CONTROL_AESEBU_RECEIVER, - HPI_CONTROL_LEVEL = 8, /**< Level/trim control - works in dBu. */ - HPI_CONTROL_TUNER = 9, /**< Tuner control. */ + HPI_CONTROL_LEVEL = 8, /**< level/trim control - works in d_bu. */ + HPI_CONTROL_TUNER = 9, /**< tuner control. */ /* HPI_CONTROL_ONOFFSWITCH = 10 */ - HPI_CONTROL_VOX = 11, /**< Vox control. */ + HPI_CONTROL_VOX = 11, /**< vox control. */ /* HPI_CONTROL_AES18_TRANSMITTER = 12 */ /* HPI_CONTROL_AES18_RECEIVER = 13 */ /* HPI_CONTROL_AES18_BLOCKGENERATOR = 14 */ - HPI_CONTROL_CHANNEL_MODE = 15, /**< Channel mode control. */ + HPI_CONTROL_CHANNEL_MODE = 15, /**< channel mode control. */ - HPI_CONTROL_BITSTREAM = 16, /**< Bitstream control. */ - HPI_CONTROL_SAMPLECLOCK = 17, /**< Sample clock control. */ - HPI_CONTROL_MICROPHONE = 18, /**< Microphone control. */ - HPI_CONTROL_PARAMETRIC_EQ = 19, /**< Parametric EQ control. */ + HPI_CONTROL_BITSTREAM = 16, /**< bitstream control. */ + HPI_CONTROL_SAMPLECLOCK = 17, /**< sample clock control. */ + HPI_CONTROL_MICROPHONE = 18, /**< microphone control. */ + HPI_CONTROL_PARAMETRIC_EQ = 19, /**< parametric EQ control. */ HPI_CONTROL_EQUALIZER = HPI_CONTROL_PARAMETRIC_EQ, - HPI_CONTROL_COMPANDER = 20, /**< Compander control. */ - HPI_CONTROL_COBRANET = 21, /**< Cobranet control. */ - HPI_CONTROL_TONEDETECTOR = 22, /**< Tone detector control. */ - HPI_CONTROL_SILENCEDETECTOR = 23, /**< Silence detector control. */ - HPI_CONTROL_PAD = 24, /**< Tuner PAD control. */ - HPI_CONTROL_SRC = 25, /**< Samplerate converter control. */ - HPI_CONTROL_UNIVERSAL = 26, /**< Universal control. */ + HPI_CONTROL_COMPANDER = 20, /**< compander control. */ + HPI_CONTROL_COBRANET = 21, /**< cobranet control. */ + HPI_CONTROL_TONEDETECTOR = 22, /**< tone detector control. */ + HPI_CONTROL_SILENCEDETECTOR = 23, /**< silence detector control. */ + HPI_CONTROL_PAD = 24, /**< tuner PAD control. */ + HPI_CONTROL_SRC = 25, /**< samplerate converter control. */ + HPI_CONTROL_UNIVERSAL = 26, /**< universal control. */ /* !!! Update this AND hpidebug.h if you add a new control type!!!*/ - HPI_CONTROL_LAST_INDEX = 26 /**<Highest control type ID */ + HPI_CONTROL_LAST_INDEX = 26 /**<highest control type ID */ /* WARNING types 256 or greater impact bit packing in all AX6 DSP code */ }; @@ -534,7 +535,12 @@ enum HPI_ADAPTER_MODES { - ASI6416: 16 outstreams/instreams - ASI5402: 2 outstreams/instreams */ - HPI_ADAPTER_MODE_MONO = 12 + HPI_ADAPTER_MODE_MONO = 12, + +/** Low latency mode. +- ASI6416/ASI6316: 1 16 channel outstream and instream +*/ + HPI_ADAPTER_MODE_LOW_LATENCY = 13 }; /* Note, adapters can have more than one capability - @@ -628,8 +634,8 @@ E.g. HPI_ParametricEQ_SetState() \ingroup mixer */ enum HPI_SWITCH_STATES { - HPI_SWITCH_OFF = 0, /**< Turn the mixer plugin on. */ - HPI_SWITCH_ON = 1 /**< Turn the mixer plugin off. */ + HPI_SWITCH_OFF = 0, /**< turn the mixer plugin on. */ + HPI_SWITCH_ON = 1 /**< turn the mixer plugin off. */ }; /* Volume control special gain values */ @@ -724,12 +730,12 @@ enum HPI_TUNER_BAND { HPI_TUNER_BAND_TV_NTSC_M = 3, /**< NTSC-M TV band*/ HPI_TUNER_BAND_TV = 3, /* use TV_NTSC_M */ HPI_TUNER_BAND_FM_STEREO = 4, /**< FM band (stereo) */ - HPI_TUNER_BAND_AUX = 5, /**< Auxiliary input */ + HPI_TUNER_BAND_AUX = 5, /**< auxiliary input */ HPI_TUNER_BAND_TV_PAL_BG = 6, /**< PAL-B/G TV band*/ HPI_TUNER_BAND_TV_PAL_I = 7, /**< PAL-I TV band*/ HPI_TUNER_BAND_TV_PAL_DK = 8, /**< PAL-D/K TV band*/ HPI_TUNER_BAND_TV_SECAM_L = 9, /**< SECAM-L TV band*/ - HPI_TUNER_BAND_LAST = 9 /**< The index of the last tuner band. */ + HPI_TUNER_BAND_LAST = 9 /**< the index of the last tuner band. */ }; /** Tuner mode attributes @@ -739,8 +745,8 @@ Used by HPI_Tuner_SetMode(), HPI_Tuner_GetMode() */ enum HPI_TUNER_MODES { - HPI_TUNER_MODE_RSS = 1, /**< Tuner mode attribute RSS */ - HPI_TUNER_MODE_RDS = 2 /**< Tuner mode attribute RBDS/RDS */ + HPI_TUNER_MODE_RSS = 1, /**< tuner mode attribute RSS */ + HPI_TUNER_MODE_RDS = 2 /**< tuner mode attribute RBDS/RDS */ }; /** Tuner mode attribute values @@ -750,13 +756,13 @@ Used by HPI_Tuner_SetMode(), HPI_Tuner_GetMode() */ enum HPI_TUNER_MODE_VALUES { /* RSS attribute values */ - HPI_TUNER_MODE_RSS_DISABLE = 0, /**< Tuner mode attribute RSS disable */ - HPI_TUNER_MODE_RSS_ENABLE = 1, /**< Tuner mode attribute RSS enable */ + HPI_TUNER_MODE_RSS_DISABLE = 0, /**< tuner mode attribute RSS disable */ + HPI_TUNER_MODE_RSS_ENABLE = 1, /**< tuner mode attribute RSS enable */ /* RDS mode attributes */ - HPI_TUNER_MODE_RDS_DISABLE = 0, /**< Tuner mode attribute RDS - disabled */ - HPI_TUNER_MODE_RDS_RDS = 1, /**< Tuner mode attribute RDS - RDS mode */ - HPI_TUNER_MODE_RDS_RBDS = 2 /**< Tuner mode attribute RDS - RBDS mode */ + HPI_TUNER_MODE_RDS_DISABLE = 0, /**< tuner mode attribute RDS - disabled */ + HPI_TUNER_MODE_RDS_RDS = 1, /**< tuner mode attribute RDS - RDS mode */ + HPI_TUNER_MODE_RDS_RBDS = 2 /**< tuner mode attribute RDS - RBDS mode */ }; /** Tuner Level settings @@ -774,14 +780,14 @@ Multiple fields are returned from a single call. \ingroup tuner */ enum HPI_TUNER_STATUS_BITS { - HPI_TUNER_VIDEO_COLOR_PRESENT = 0x0001, /**< Video color is present. */ - HPI_TUNER_VIDEO_IS_60HZ = 0x0020, /**< 60 Hz video detected. */ - HPI_TUNER_VIDEO_HORZ_SYNC_MISSING = 0x0040, /**< Video HSYNC is missing. */ - HPI_TUNER_VIDEO_STATUS_VALID = 0x0100, /**< Video status is valid. */ - HPI_TUNER_PLL_LOCKED = 0x1000, /**< The tuner's PLL is locked. */ - HPI_TUNER_FM_STEREO = 0x2000, /**< Tuner reports back FM stereo. */ - HPI_TUNER_DIGITAL = 0x0200, /**< Tuner reports digital programming. */ - HPI_TUNER_MULTIPROGRAM = 0x0400 /**< Tuner reports multiple programs. */ + HPI_TUNER_VIDEO_COLOR_PRESENT = 0x0001, /**< video color is present. */ + HPI_TUNER_VIDEO_IS_60HZ = 0x0020, /**< 60 hz video detected. */ + HPI_TUNER_VIDEO_HORZ_SYNC_MISSING = 0x0040, /**< video HSYNC is missing. */ + HPI_TUNER_VIDEO_STATUS_VALID = 0x0100, /**< video status is valid. */ + HPI_TUNER_PLL_LOCKED = 0x1000, /**< the tuner's PLL is locked. */ + HPI_TUNER_FM_STEREO = 0x2000, /**< tuner reports back FM stereo. */ + HPI_TUNER_DIGITAL = 0x0200, /**< tuner reports digital programming. */ + HPI_TUNER_MULTIPROGRAM = 0x0400 /**< tuner reports multiple programs. */ }; /** Channel Modes @@ -841,16 +847,16 @@ Superseded by separate Auto enable flag \ingroup parmeq */ enum HPI_FILTER_TYPE { - HPI_FILTER_TYPE_BYPASS = 0, /**< Filter is turned off */ + HPI_FILTER_TYPE_BYPASS = 0, /**< filter is turned off */ HPI_FILTER_TYPE_LOWSHELF = 1, /**< EQ low shelf */ HPI_FILTER_TYPE_HIGHSHELF = 2, /**< EQ high shelf */ HPI_FILTER_TYPE_EQ_BAND = 3, /**< EQ gain */ - HPI_FILTER_TYPE_LOWPASS = 4, /**< Standard low pass */ - HPI_FILTER_TYPE_HIGHPASS = 5, /**< Standard high pass */ - HPI_FILTER_TYPE_BANDPASS = 6, /**< Standard band pass */ - HPI_FILTER_TYPE_BANDSTOP = 7 /**< Standard band stop/notch */ + HPI_FILTER_TYPE_LOWPASS = 4, /**< standard low pass */ + HPI_FILTER_TYPE_HIGHPASS = 5, /**< standard high pass */ + HPI_FILTER_TYPE_BANDPASS = 6, /**< standard band pass */ + HPI_FILTER_TYPE_BANDSTOP = 7 /**< standard band stop/notch */ }; /** Async Event sources @@ -858,7 +864,7 @@ enum HPI_FILTER_TYPE { */ enum ASYNC_EVENT_SOURCES { HPI_ASYNC_EVENT_GPIO = 1, /**< GPIO event. */ - HPI_ASYNC_EVENT_SILENCE = 2, /**< Silence event detected. */ + HPI_ASYNC_EVENT_SILENCE = 2, /**< silence event detected. */ HPI_ASYNC_EVENT_TONE = 3 /**< tone event detected. */ }; /*******************************************/ @@ -905,6 +911,8 @@ enum HPI_ERROR_CODES { HPI_ERROR_NETWORK_TOO_MANY_CLIENTS = 113, /** Response buffer passed to HPI_Message was smaller than returned response */ HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL = 114, + /** The returned response did not match the sent message */ + HPI_ERROR_RESPONSE_MISMATCH = 115, /** Too many adapters.*/ HPI_ERROR_TOO_MANY_ADAPTERS = 200, @@ -1083,37 +1091,37 @@ enum HPI_ERROR_CODES { See also HPI_FormatCreate(). */ struct hpi_format { - u32 dwSampleRate; + u32 sample_rate; /**< 11025, 32000, 44100 ... */ - u32 dwBitRate; /**< for MPEG */ - u32 dwAttributes; + u32 bit_rate; /**< for MPEG */ + u32 attributes; /**< Stereo/JointStereo/Mono */ - u16 wModeLegacy; + u16 mode_legacy; /**< Legacy ancillary mode or idle bit */ - u16 wUnused; /**< Unused */ - u16 wChannels; /**< 1,2..., (or ancillary mode or idle bit */ - u16 wFormat; /**< HPI_FORMAT_PCM16, _MPEG etc. See #HPI_FORMATS. */ + u16 unused; /**< unused */ + u16 channels; /**< 1,2..., (or ancillary mode or idle bit */ + u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see #HPI_FORMATS. */ }; struct hpi_anc_frame { - u32 dwValidBitsInThisFrame; - u8 bData[HPI_MAX_ANC_BYTES_PER_FRAME]; + u32 valid_bits_in_this_frame; + u8 b_data[HPI_MAX_ANC_BYTES_PER_FRAME]; }; /** An object for containing a single async event. */ struct hpi_async_event { - u16 wEventType; /**< Type of event. \sa async_event */ - u16 wSequence; /**< Sequence number, allows lost event detection */ - u32 dwState; /**< New state */ - u32 hObject; /**< Handle to the object returning the event. */ + u16 event_type; /**< type of event. \sa async_event */ + u16 sequence; /**< sequence number, allows lost event detection */ + u32 state; /**< new state */ + u32 h_object; /**< handle to the object returning the event. */ union { struct { - u16 wIndex; /**< GPIO bit index. */ + u16 index; /**< GPIO bit index. */ } gpio; struct { - u16 wNodeIndex; /**< What node is the control on ? */ - u16 wNodeType; /**< What type of node is the control on ? */ + u16 node_index; /**< what node is the control on ? */ + u16 node_type; /**< what type of node is the control on ? */ } control; } u; }; @@ -1184,1598 +1192,810 @@ struct hpi_hsubsys { /*/////////////////////////// */ /* DATA and FORMAT and STREAM */ -u16 HPI_StreamEstimateBufferSize( - struct hpi_format *pF, - u32 dwHostPollingRateInMilliSeconds, - u32 *dwRecommendedBufferSize -); +u16 hpi_stream_estimate_buffer_size(struct hpi_format *pF, + u32 host_polling_rate_in_milli_seconds, u32 *recommended_buffer_size); /*/////////// */ /* SUB SYSTEM */ -struct hpi_hsubsys *HPI_SubSysCreate( - void -); - -void HPI_SubSysFree( - const struct hpi_hsubsys *phSubSys -); - -u16 HPI_SubSysGetVersion( - const struct hpi_hsubsys *phSubSys, - u32 *pdwVersion -); - -u16 HPI_SubSysGetVersionEx( - const struct hpi_hsubsys *phSubSys, - u32 *pdwVersionEx -); - -u16 HPI_SubSysGetInfo( - const struct hpi_hsubsys *phSubSys, - u32 *pdwVersion, - u16 *pwNumAdapters, - u16 awAdapterList[], - u16 wListLength -); - -u16 HPI_SubSysFindAdapters( - const struct hpi_hsubsys *phSubSys, - u16 *pwNumAdapters, - u16 awAdapterList[], - u16 wListLength -); - -u16 HPI_SubSysGetNumAdapters( - const struct hpi_hsubsys *phSubSys, - int *pnNumAdapters -); - -u16 HPI_SubSysGetAdapter( - const struct hpi_hsubsys *phSubSys, - int nIterator, - u32 *pdwAdapterIndex, - u16 *pwAdapterType -); - -u16 HPI_SubSysSsx2Bypass( - const struct hpi_hsubsys *phSubSys, - u16 wBypass -); - -u16 HPI_SubSysSetHostNetworkInterface( - const struct hpi_hsubsys *phSubSys, - const char *szInterface -); +struct hpi_hsubsys *hpi_subsys_create(void + ); + +void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys); + +u16 hpi_subsys_get_version(const struct hpi_hsubsys *ph_subsys, + u32 *pversion); + +u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys, + u32 *pversion_ex); + +u16 hpi_subsys_get_info(const struct hpi_hsubsys *ph_subsys, u32 *pversion, + u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length); + +u16 hpi_subsys_find_adapters(const struct hpi_hsubsys *ph_subsys, + u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length); + +u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys, + int *pn_num_adapters); + +u16 hpi_subsys_get_adapter(const struct hpi_hsubsys *ph_subsys, int iterator, + u32 *padapter_index, u16 *pw_adapter_type); + +u16 hpi_subsys_ssx2_bypass(const struct hpi_hsubsys *ph_subsys, u16 bypass); + +u16 hpi_subsys_set_host_network_interface(const struct hpi_hsubsys *ph_subsys, + const char *sz_interface); /*///////// */ /* ADAPTER */ -u16 HPI_AdapterOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex -); - -u16 HPI_AdapterClose( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex -); - -u16 HPI_AdapterGetInfo( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 *pwNumOutStreams, - u16 *pwNumInStreams, - u16 *pwVersion, - u32 *pdwSerialNumber, - u16 *pwAdapterType -); - -u16 HPI_AdapterGetModuleByIndex( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wModuleIndex, - u16 *pwNumOutputs, - u16 *pwNumInputs, - u16 *pwVersion, - u32 *pdwSerialNumber, - u16 *pwModuleType, - u32 *phModule -); - -u16 HPI_AdapterSetMode( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 dwAdapterMode -); -u16 HPI_AdapterSetModeEx( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 dwAdapterMode, - u16 wQueryOrSet -); - -u16 HPI_AdapterGetMode( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *pdwAdapterMode -); - -u16 HPI_AdapterGetAssert( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 *wAssertPresent, - char *pszAssert, - u16 *pwLineNumber -); - -u16 HPI_AdapterGetAssertEx( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 *wAssertPresent, - char *pszAssert, - u32 *pdwLineNumber, - u16 *pwAssertOnDsp -); - -u16 HPI_AdapterTestAssert( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wAssertId -); - -u16 HPI_AdapterEnableCapability( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wCapability, - u32 dwKey -); - -u16 HPI_AdapterSelfTest( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex -); - -u16 HPI_AdapterDebugRead( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 dwDspAddress, - char *pBytes, - int *dwCountBytes -); - -u16 HPI_AdapterSetProperty( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wProperty, - u16 wParamter1, - u16 wParamter2 -); - -u16 HPI_AdapterGetProperty( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wProperty, - u16 *pwParamter1, - u16 *pwParamter2 -); - -u16 HPI_AdapterEnumerateProperty( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wIndex, - u16 wWhatToEnumerate, - u16 wPropertyIndex, - u32 *pdwSetting -); +u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index); + +u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index); + +u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 *pw_num_outstreams, u16 *pw_num_instreams, + u16 *pw_version, u32 *pserial_number, u16 *pw_adapter_type); + +u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 module_index, u16 *pw_num_outputs, + u16 *pw_num_inputs, u16 *pw_version, u32 *pserial_number, + u16 *pw_module_type, u32 *ph_module); + +u16 hpi_adapter_set_mode(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u32 adapter_mode); + +u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u32 adapter_mode, u16 query_or_set); + +u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u32 *padapter_mode); + +u16 hpi_adapter_get_assert(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 *assert_present, char *psz_assert, + u16 *pw_line_number); + +u16 hpi_adapter_get_assert_ex(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 *assert_present, char *psz_assert, + u32 *pline_number, u16 *pw_assert_on_dsp); + +u16 hpi_adapter_test_assert(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 assert_id); + +u16 hpi_adapter_enable_capability(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 capability, u32 key); + +u16 hpi_adapter_self_test(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index); + +u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u32 dsp_address, char *p_bytes, int *count_bytes); + +u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 property, u16 paramter1, u16 paramter2); + +u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 property, u16 *pw_paramter1, + u16 *pw_paramter2); + +u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 index, u16 what_to_enumerate, + u16 property_index, u32 *psetting); /*////////////// */ /* NonVol Memory */ -u16 HPI_NvMemoryOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *phNvMemory, - u16 *pwSizeInBytes -); - -u16 HPI_NvMemoryReadByte( - const struct hpi_hsubsys *phSubSys, - u32 hNvMemory, - u16 wIndex, - u16 *pwData -); - -u16 HPI_NvMemoryWriteByte( - const struct hpi_hsubsys *phSubSys, - u32 hNvMemory, - u16 wIndex, - u16 wData -); +u16 hpi_nv_memory_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u32 *ph_nv_memory, u16 *pw_size_in_bytes); + +u16 hpi_nv_memory_read_byte(const struct hpi_hsubsys *ph_subsys, + u32 h_nv_memory, u16 index, u16 *pw_data); + +u16 hpi_nv_memory_write_byte(const struct hpi_hsubsys *ph_subsys, + u32 h_nv_memory, u16 index, u16 data); /*////////////// */ /* Digital I/O */ -u16 HPI_GpioOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *phGpio, - u16 *pwNumberInputBits, - u16 *pwNumberOutputBits -); - -u16 HPI_GpioReadBit( - const struct hpi_hsubsys *phSubSys, - u32 hGpio, - u16 wBitIndex, - u16 *pwBitData -); - -u16 HPI_GpioReadAllBits( - const struct hpi_hsubsys *phSubSys, - u32 hGpio, - u16 awAllBitData[4] -); - -u16 HPI_GpioWriteBit( - const struct hpi_hsubsys *phSubSys, - u32 hGpio, - u16 wBitIndex, - u16 wBitData -); - -u16 HPI_GpioWriteStatus( - const struct hpi_hsubsys *phSubSys, - u32 hGpio, - u16 awAllBitData[4] -); +u16 hpi_gpio_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u32 *ph_gpio, u16 *pw_number_input_bits, u16 *pw_number_output_bits); + +u16 hpi_gpio_read_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, + u16 bit_index, u16 *pw_bit_data); + +u16 hpi_gpio_read_all_bits(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, + u16 aw_all_bit_data[4] + ); + +u16 hpi_gpio_write_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, + u16 bit_index, u16 bit_data); + +u16 hpi_gpio_write_status(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, + u16 aw_all_bit_data[4] + ); /**********************/ /* Async Event Object */ /**********************/ -u16 HPI_AsyncEventOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *phAsync -); - -u16 HPI_AsyncEventClose( - const struct hpi_hsubsys *phSubSys, - u32 hAsync -); - -u16 HPI_AsyncEventWait( - const struct hpi_hsubsys *phSubSys, - u32 hAsync, - u16 wMaximumEvents, - struct hpi_async_event *pEvents, - u16 *pwNumberReturned -); - -u16 HPI_AsyncEventGetCount( - const struct hpi_hsubsys *phSubSys, - u32 hAsync, - u16 *pwCount -); - -u16 HPI_AsyncEventGet( - const struct hpi_hsubsys *phSubSys, - u32 hAsync, - u16 wMaximumEvents, - struct hpi_async_event *pEvents, - u16 *pwNumberReturned -); +u16 hpi_async_event_open(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u32 *ph_async); + +u16 hpi_async_event_close(const struct hpi_hsubsys *ph_subsys, u32 h_async); + +u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async, + u16 maximum_events, struct hpi_async_event *p_events, + u16 *pw_number_returned); + +u16 hpi_async_event_get_count(const struct hpi_hsubsys *ph_subsys, + u32 h_async, u16 *pw_count); + +u16 hpi_async_event_get(const struct hpi_hsubsys *ph_subsys, u32 h_async, + u16 maximum_events, struct hpi_async_event *p_events, + u16 *pw_number_returned); /*/////////// */ /* WATCH-DOG */ -u16 HPI_WatchdogOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *phWatchdog -); - -u16 HPI_WatchdogSetTime( - const struct hpi_hsubsys *phSubSys, - u32 hWatchdog, - u32 dwTimeMillisec -); - -u16 HPI_WatchdogPing( - const struct hpi_hsubsys *phSubSys, - u32 hWatchdog -); +u16 hpi_watchdog_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u32 *ph_watchdog); + +u16 hpi_watchdog_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog, + u32 time_millisec); + +u16 hpi_watchdog_ping(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog); /**************/ /* OUT STREAM */ /**************/ -u16 HPI_OutStreamOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wOutStreamIndex, - u32 *phOutStream -); - -u16 HPI_OutStreamClose( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -); - -u16 HPI_OutStreamGetInfoEx( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u16 *pwState, - u32 *pdwBufferSize, - u32 *pdwDataToPlay, - u32 *pdwSamplesPlayed, - u32 *pdwAuxiliaryDataToPlay -); - -u16 HPI_OutStreamWriteBuf( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - const u8 *pbWriteBuf, - u32 dwBytesToWrite, - const struct hpi_format *pFormat -); - -u16 HPI_OutStreamStart( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -); - -u16 HPI_OutStreamWaitStart( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -); - -u16 HPI_OutStreamStop( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -); - -u16 HPI_OutStreamSinegen( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -); - -u16 HPI_OutStreamReset( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -); - -u16 HPI_OutStreamQueryFormat( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - struct hpi_format *pFormat -); - -u16 HPI_OutStreamSetFormat( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - struct hpi_format *pFormat -); - -u16 HPI_OutStreamSetPunchInOut( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u32 dwPunchInSample, - u32 dwPunchOutSample -); - -u16 HPI_OutStreamSetVelocity( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - short nVelocity -); - -u16 HPI_OutStreamAncillaryReset( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u16 wMode -); - -u16 HPI_OutStreamAncillaryGetInfo( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u32 *pdwFramesAvailable -); - -u16 HPI_OutStreamAncillaryRead( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - struct hpi_anc_frame *pAncFrameBuffer, - u32 dwAncFrameBufferSizeInBytes, - u32 dwNumberOfAncillaryFramesToRead -); - -u16 HPI_OutStreamSetTimeScale( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u32 dwTimeScaleX10000 -); - -u16 HPI_OutStreamHostBufferAllocate( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u32 dwSizeInBytes -); - -u16 HPI_OutStreamHostBufferFree( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -); - -u16 HPI_OutStreamGroupAdd( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u32 hStream -); - -u16 HPI_OutStreamGroupGetMap( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u32 *pdwOutStreamMap, - u32 *pdwInStreamMap -); - -u16 HPI_OutStreamGroupReset( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -); +u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u16 outstream_index, u32 *ph_outstream); + +u16 hpi_outstream_close(const struct hpi_hsubsys *ph_subsys, u32 h_outstream); + +u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_to_play, + u32 *psamples_played, u32 *pauxiliary_data_to_play); + +u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, const u8 *pb_write_buf, u32 bytes_to_write, + const struct hpi_format *p_format); + +u16 hpi_outstream_start(const struct hpi_hsubsys *ph_subsys, u32 h_outstream); + +u16 hpi_outstream_wait_start(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream); + +u16 hpi_outstream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_outstream); + +u16 hpi_outstream_sinegen(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream); + +u16 hpi_outstream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_outstream); + +u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, struct hpi_format *p_format); + +u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, struct hpi_format *p_format); + +u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u32 punch_in_sample, u32 punch_out_sample); + +u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, short velocity); + +u16 hpi_outstream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u16 mode); + +u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u32 *pframes_available); + +u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, struct hpi_anc_frame *p_anc_frame_buffer, + u32 anc_frame_buffer_size_in_bytes, + u32 number_of_ancillary_frames_to_read); + +u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u32 time_scaleX10000); + +u16 hpi_outstream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u32 size_in_bytes); + +u16 hpi_outstream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream); + +u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u32 h_stream); + +u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u32 *poutstream_map, u32 *pinstream_map); + +u16 hpi_outstream_group_reset(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream); /*////////// */ /* IN_STREAM */ -u16 HPI_InStreamOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wInStreamIndex, - u32 *phInStream -); - -u16 HPI_InStreamClose( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -); - -u16 HPI_InStreamQueryFormat( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - const struct hpi_format *pFormat -); - -u16 HPI_InStreamSetFormat( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - const struct hpi_format *pFormat -); - -u16 HPI_InStreamReadBuf( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u8 *pbReadBuf, - u32 dwBytesToRead -); - -u16 HPI_InStreamStart( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -); - -u16 HPI_InStreamWaitStart( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -); - -u16 HPI_InStreamStop( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -); - -u16 HPI_InStreamReset( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -); - -u16 HPI_InStreamGetInfoEx( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u16 *pwState, - u32 *pdwBufferSize, - u32 *pdwDataRecorded, - u32 *pdwSamplesRecorded, - u32 *pdwAuxiliaryDataRecorded -); - -u16 HPI_InStreamAncillaryReset( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u16 wBytesPerFrame, - u16 wMode, - u16 wAlignment, - u16 wIdleBit -); - -u16 HPI_InStreamAncillaryGetInfo( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u32 *pdwFrameSpace -); - -u16 HPI_InStreamAncillaryWrite( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - const struct hpi_anc_frame *pAncFrameBuffer, - u32 dwAncFrameBufferSizeInBytes, - u32 dwNumberOfAncillaryFramesToWrite -); - -u16 HPI_InStreamHostBufferAllocate( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u32 dwSizeInBytes -); - -u16 HPI_InStreamHostBufferFree( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -); - -u16 HPI_InStreamGroupAdd( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u32 hStream -); - -u16 HPI_InStreamGroupGetMap( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u32 *pdwOutStreamMap, - u32 *pdwInStreamMap -); - -u16 HPI_InStreamGroupReset( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -); +u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u16 instream_index, u32 *ph_instream); + +u16 hpi_instream_close(const struct hpi_hsubsys *ph_subsys, u32 h_instream); + +u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, const struct hpi_format *p_format); + +u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, const struct hpi_format *p_format); + +u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream, + u8 *pb_read_buf, u32 bytes_to_read); + +u16 hpi_instream_start(const struct hpi_hsubsys *ph_subsys, u32 h_instream); + +u16 hpi_instream_wait_start(const struct hpi_hsubsys *ph_subsys, + u32 h_instream); + +u16 hpi_instream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_instream); + +u16 hpi_instream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_instream); + +u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_recorded, + u32 *psamples_recorded, u32 *pauxiliary_data_recorded); + +u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u16 bytes_per_frame, u16 mode, u16 alignment, + u16 idle_bit); + +u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u32 *pframe_space); + +u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, const struct hpi_anc_frame *p_anc_frame_buffer, + u32 anc_frame_buffer_size_in_bytes, + u32 number_of_ancillary_frames_to_write); + +u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u32 size_in_bytes); + +u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, + u32 h_instream); + +u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u32 h_stream); + +u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u32 *poutstream_map, u32 *pinstream_map); + +u16 hpi_instream_group_reset(const struct hpi_hsubsys *ph_subsys, + u32 h_instream); /*********/ /* MIXER */ /*********/ -u16 HPI_MixerOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *phMixer -); - -u16 HPI_MixerClose( - const struct hpi_hsubsys *phSubSys, - u32 hMixer -); - -u16 HPI_MixerGetControl( - const struct hpi_hsubsys *phSubSys, - u32 hMixer, - u16 wSrcNodeType, - u16 wSrcNodeTypeIndex, - u16 wDstNodeType, - u16 wDstNodeTypeIndex, - u16 wControlType, - u32 *phControl -); - -u16 HPI_MixerGetControlByIndex( - const struct hpi_hsubsys *phSubSys, - u32 hMixer, - u16 wControlIndex, - u16 *pwSrcNodeType, - u16 *pwSrcNodeIndex, - u16 *pwDstNodeType, - u16 *pwDstNodeIndex, - u16 *pwControlType, - u32 *phControl -); - -u16 HPI_MixerStore( - const struct hpi_hsubsys *phSubSys, - u32 hMixer, - enum HPI_MIXER_STORE_COMMAND Command, - u16 wIndex -); +u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u32 *ph_mixer); + +u16 hpi_mixer_close(const struct hpi_hsubsys *ph_subsys, u32 h_mixer); + +u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, + u16 src_node_type, u16 src_node_type_index, u16 dst_node_type, + u16 dst_node_type_index, u16 control_type, u32 *ph_control); + +u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys, + u32 h_mixer, u16 control_index, u16 *pw_src_node_type, + u16 *pw_src_node_index, u16 *pw_dst_node_type, u16 *pw_dst_node_index, + u16 *pw_control_type, u32 *ph_control); + +u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, + enum HPI_MIXER_STORE_COMMAND command, u16 index); /*************************/ /* mixer CONTROLS */ /*************************/ /*************************/ /* volume control */ /*************************/ -u16 HPI_VolumeSetGain( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anGain0_01dB[HPI_MAX_CHANNELS] -); - -u16 HPI_VolumeGetGain( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anGain0_01dB_out[HPI_MAX_CHANNELS] -); - -#define HPI_VolumeGetRange HPI_VolumeQueryRange -u16 HPI_VolumeQueryRange( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short *nMinGain_01dB, - short *nMaxGain_01dB, - short *nStepGain_01dB -); - -u16 HPI_Volume_QueryChannels( - const struct hpi_hsubsys *phSubSys, - const u32 hVolume, - u32 *pChannels -); - -u16 HPI_VolumeAutoFade( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anStopGain0_01dB[HPI_MAX_CHANNELS], - u32 wDurationMs -); - -u16 HPI_VolumeAutoFadeProfile( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anStopGain0_01dB[HPI_MAX_CHANNELS], - u32 dwDurationMs, - u16 dwProfile -); +u16 hpi_volume_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_gain0_01dB[HPI_MAX_CHANNELS] + ); + +u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_gain0_01dB_out[HPI_MAX_CHANNELS] + ); + +#define hpi_volume_get_range hpi_volume_query_range +u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB); + +u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys, + const u32 h_volume, u32 *p_channels); + +u16 hpi_volume_auto_fade(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms); + +u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys, + u32 h_control, short an_stop_gain0_01dB[HPI_MAX_CHANNELS], + u32 duration_ms, u16 profile); /*************************/ /* level control */ /*************************/ -u16 HPI_LevelQueryRange( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short *nMinGain_01dB, - short *nMaxGain_01dB, - short *nStepGain_01dB -); - -u16 HPI_LevelSetGain( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anGain0_01dB[HPI_MAX_CHANNELS] -); - -u16 HPI_LevelGetGain( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anGain0_01dB_out[HPI_MAX_CHANNELS] -); +u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB); + +u16 hpi_level_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_gain0_01dB[HPI_MAX_CHANNELS] + ); + +u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_gain0_01dB_out[HPI_MAX_CHANNELS] + ); /*************************/ /* meter control */ /*************************/ -u16 HPI_Meter_QueryChannels( - const struct hpi_hsubsys *phSubSys, - const u32 hMeter, - u32 *pChannels -); - -u16 HPI_MeterGetPeak( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anPeak0_01dB_out[HPI_MAX_CHANNELS] -); - -u16 HPI_MeterGetRms( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anPeak0_01dB_out[HPI_MAX_CHANNELS] -); - -u16 HPI_MeterSetPeakBallistics( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 nAttack, - u16 nDecay -); - -u16 HPI_MeterSetRmsBallistics( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 nAttack, - u16 nDecay -); - -u16 HPI_MeterGetPeakBallistics( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *nAttack, - u16 *nDecay -); - -u16 HPI_MeterGetRmsBallistics( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *nAttack, - u16 *nDecay -); +u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys, + const u32 h_meter, u32 *p_channels); + +u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_peak0_01dB_out[HPI_MAX_CHANNELS] + ); + +u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_peak0_01dB_out[HPI_MAX_CHANNELS] + ); + +u16 hpi_meter_set_peak_ballistics(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 attack, u16 decay); + +u16 hpi_meter_set_rms_ballistics(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 attack, u16 decay); + +u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *attack, u16 *decay); + +u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *attack, u16 *decay); /*************************/ /* channel mode control */ /*************************/ -u16 HPI_ChannelMode_QueryMode( - const struct hpi_hsubsys *phSubSys, - const u32 hMode, - const u32 dwIndex, - u16 *pwMode -); - -u16 HPI_ChannelModeSet( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wMode -); - -u16 HPI_ChannelModeGet( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *wMode -); +u16 hpi_channel_mode_query_mode(const struct hpi_hsubsys *ph_subsys, + const u32 h_mode, const u32 index, u16 *pw_mode); + +u16 hpi_channel_mode_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 mode); + +u16 hpi_channel_mode_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 *mode); /*************************/ /* Tuner control */ /*************************/ -u16 HPI_Tuner_QueryBand( - const struct hpi_hsubsys *phSubSys, - const u32 hTuner, - const u32 dwIndex, - u16 *pwBand -); - -u16 HPI_Tuner_SetBand( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wBand -); - -u16 HPI_Tuner_GetBand( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwBand -); - -u16 HPI_Tuner_QueryFrequency( - const struct hpi_hsubsys *phSubSys, - const u32 hTuner, - const u32 dwIndex, - const u16 band, - u32 *pdwFreq -); - -u16 HPI_Tuner_SetFrequency( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 wFreqInkHz -); - -u16 HPI_Tuner_GetFrequency( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pwFreqInkHz -); - -u16 HPI_Tuner_GetRFLevel( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short *pwLevel -); - -u16 HPI_Tuner_GetRawRFLevel( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short *pwLevel -); - -u16 HPI_Tuner_QueryGain( - const struct hpi_hsubsys *phSubSys, - const u32 hTuner, - const u32 dwIndex, - u16 *pwGain -); - -u16 HPI_Tuner_SetGain( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short nGain -); - -u16 HPI_Tuner_GetGain( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short *pnGain -); - -u16 HPI_Tuner_GetStatus( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwStatusMask, - u16 *pwStatus -); - -u16 HPI_Tuner_SetMode( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 nMode, - u32 nValue -); - -u16 HPI_Tuner_GetMode( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 nMode, - u32 *pnValue -); - -u16 HPI_Tuner_GetRDS( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pRdsData -); - -u16 HPI_Tuner_QueryDeemphasis( - const struct hpi_hsubsys *phSubSys, - const u32 hTuner, - const u32 dwIndex, - const u16 band, - u32 *pdwDeemphasis -); - -u16 HPI_Tuner_SetDeemphasis( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwDeemphasis -); -u16 HPI_Tuner_GetDeemphasis( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwDeemphasis -); - -u16 HPI_Tuner_QueryProgram( - const struct hpi_hsubsys *phSubSys, - const u32 hTuner, - u32 *pbitmapProgram -); - -u16 HPI_Tuner_SetProgram( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwProgram -); - -u16 HPI_Tuner_GetProgram( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwProgram -); - -u16 HPI_Tuner_GetHdRadioDspVersion( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pszDspVersion, - const u32 dwStringSize -); - -u16 HPI_Tuner_GetHdRadioSdkVersion( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pszSdkVersion, - const u32 dwStringSize -); - -u16 HPI_Tuner_GetHdRadioSignalQuality( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwQuality -); +u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys, + const u32 h_tuner, const u32 index, u16 *pw_band); + +u16 hpi_tuner_set_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 band); + +u16 hpi_tuner_get_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 *pw_band); + +u16 hpi_tuner_query_frequency(const struct hpi_hsubsys *ph_subsys, + const u32 h_tuner, const u32 index, const u16 band, u32 *pfreq); + +u16 hpi_tuner_set_frequency(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 freq_ink_hz); + +u16 hpi_tuner_get_frequency(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pw_freq_ink_hz); + +u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short *pw_level); + +u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys, + u32 h_control, short *pw_level); + +u16 hpi_tuner_query_gain(const struct hpi_hsubsys *ph_subsys, + const u32 h_tuner, const u32 index, u16 *pw_gain); + +u16 hpi_tuner_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short gain); + +u16 hpi_tuner_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short *pn_gain); + +u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 *pw_status_mask, u16 *pw_status); + +u16 hpi_tuner_set_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 mode, u32 value); + +u16 hpi_tuner_get_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 mode, u32 *pn_value); + +u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control, + char *p_rds_data); + +u16 hpi_tuner_query_deemphasis(const struct hpi_hsubsys *ph_subsys, + const u32 h_tuner, const u32 index, const u16 band, u32 *pdeemphasis); + +u16 hpi_tuner_set_deemphasis(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 deemphasis); +u16 hpi_tuner_get_deemphasis(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pdeemphasis); + +u16 hpi_tuner_query_program(const struct hpi_hsubsys *ph_subsys, + const u32 h_tuner, u32 *pbitmap_program); + +u16 hpi_tuner_set_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 program); + +u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 *pprogram); + +u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys, + u32 h_control, char *psz_dsp_version, const u32 string_size); + +u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys, + u32 h_control, char *psz_sdk_version, const u32 string_size); + +u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pquality); /****************************/ /* PADs control */ /****************************/ -u16 HPI_PAD_GetChannelName( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pszString, - const u32 dwStringLength -); - -u16 HPI_PAD_GetArtist( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pszString, - const u32 dwStringLength -); - -u16 HPI_PAD_GetTitle( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pszString, - const u32 dwStringLength -); - -u16 HPI_PAD_GetComment( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pszString, - const u32 dwStringLength -); - -u16 HPI_PAD_GetProgramType( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwPTY -); - -u16 HPI_PAD_GetRdsPI( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwPI -); - -u16 HPI_PAD_GetProgramTypeString( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - const u32 dwDataType, - const u32 nPTY, - char *pszString, - const u32 dwStringLength -); +u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys, + u32 h_control, char *psz_string, const u32 string_length); + +u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control, + char *psz_string, const u32 string_length); + +u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control, + char *psz_string, const u32 string_length); + +u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control, + char *psz_string, const u32 string_length); + +u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *ppTY); + +u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 *ppI); + +u16 HPI_PAD__get_program_type_string(const struct hpi_hsubsys *ph_subsys, + u32 h_control, const u32 data_type, const u32 pTY, char *psz_string, + const u32 string_length); /****************************/ /* AES/EBU Receiver control */ /****************************/ -u16 HPI_AESEBU_Receiver_QueryFormat( - const struct hpi_hsubsys *phSubSys, - const u32 hAesRx, - const u32 dwIndex, - u16 *pwFormat -); - -u16 HPI_AESEBU_Receiver_SetFormat( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wSource -); - -u16 HPI_AESEBU_Receiver_GetFormat( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwSource -); - -u16 HPI_AESEBU_Receiver_GetSampleRate( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwSampleRate -); - -u16 HPI_AESEBU_Receiver_GetUserData( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 *pwData -); - -u16 HPI_AESEBU_Receiver_GetChannelStatus( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 *pwData -); - -u16 HPI_AESEBU_Receiver_GetErrorStatus( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwErrorData -); +u16 HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys *ph_subsys, + const u32 h_aes_rx, const u32 index, u16 *pw_format); + +u16 HPI_AESEBU__receiver_set_format(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 source); + +u16 HPI_AESEBU__receiver_get_format(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_source); + +u16 HPI_AESEBU__receiver_get_sample_rate(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *psample_rate); + +u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 index, u16 *pw_data); + +u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys + *ph_subsys, u32 h_control, u16 index, u16 *pw_data); + +u16 HPI_AESEBU__receiver_get_error_status(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_error_data); /*******************************/ /* AES/EBU Transmitter control */ /*******************************/ -u16 HPI_AESEBU_Transmitter_SetSampleRate( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwSampleRate -); - -u16 HPI_AESEBU_Transmitter_SetUserData( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 wData -); - -u16 HPI_AESEBU_Transmitter_SetChannelStatus( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 wData -); - -u16 HPI_AESEBU_Transmitter_GetChannelStatus( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 *pwData -); - -u16 HPI_AESEBU_Transmitter_QueryFormat( - const struct hpi_hsubsys *phSubSys, - const u32 hAesTx, - const u32 dwIndex, - u16 *pwFormat -); - -u16 HPI_AESEBU_Transmitter_SetFormat( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wOutputFormat -); - -u16 HPI_AESEBU_Transmitter_GetFormat( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwOutputFormat -); +u16 HPI_AESEBU__transmitter_set_sample_rate(const struct hpi_hsubsys + *ph_subsys, u32 h_control, u32 sample_rate); + +u16 HPI_AESEBU__transmitter_set_user_data(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 index, u16 data); + +u16 HPI_AESEBU__transmitter_set_channel_status(const struct hpi_hsubsys + *ph_subsys, u32 h_control, u16 index, u16 data); + +u16 HPI_AESEBU__transmitter_get_channel_status(const struct hpi_hsubsys + *ph_subsys, u32 h_control, u16 index, u16 *pw_data); + +u16 HPI_AESEBU__transmitter_query_format(const struct hpi_hsubsys *ph_subsys, + const u32 h_aes_tx, const u32 index, u16 *pw_format); + +u16 HPI_AESEBU__transmitter_set_format(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 output_format); + +u16 HPI_AESEBU__transmitter_get_format(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_output_format); /***********************/ /* multiplexer control */ /***********************/ -u16 HPI_Multiplexer_SetSource( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wSourceNodeType, - u16 wSourceNodeIndex -); - -u16 HPI_Multiplexer_GetSource( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *wSourceNodeType, - u16 *wSourceNodeIndex -); - -u16 HPI_Multiplexer_QuerySource( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 nIndex, - u16 *wSourceNodeType, - u16 *wSourceNodeIndex -); +u16 hpi_multiplexer_set_source(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 source_node_type, u16 source_node_index); + +u16 hpi_multiplexer_get_source(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *source_node_type, u16 *source_node_index); + +u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 index, u16 *source_node_type, + u16 *source_node_index); /***************/ /* VOX control */ /***************/ -u16 HPI_VoxSetThreshold( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anGain0_01dB -); - -u16 HPI_VoxGetThreshold( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short *anGain0_01dB -); +u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_gain0_01dB); + +u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short *an_gain0_01dB); /*********************/ /* Bitstream control */ /*********************/ -u16 HPI_Bitstream_SetClockEdge( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wEdgeType -); - -u16 HPI_Bitstream_SetDataPolarity( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wPolarity -); - -u16 HPI_Bitstream_GetActivity( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwClkActivity, - u16 *pwDataActivity -); +u16 hpi_bitstream_set_clock_edge(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 edge_type); + +u16 hpi_bitstream_set_data_polarity(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 polarity); + +u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_clk_activity, u16 *pw_data_activity); /***********************/ /* SampleClock control */ /***********************/ -u16 HPI_SampleClock_QuerySource( - const struct hpi_hsubsys *phSubSys, - const u32 hClock, - const u32 dwIndex, - u16 *pwSource -); - -u16 HPI_SampleClock_SetSource( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wSource -); - -u16 HPI_SampleClock_GetSource( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwSource -); - -u16 HPI_SampleClock_QuerySourceIndex( - const struct hpi_hsubsys *phSubSys, - const u32 hClock, - const u32 dwIndex, - const u32 dwSource, - u16 *pwSourceIndex -); - -u16 HPI_SampleClock_SetSourceIndex( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wSourceIndex -); - -u16 HPI_SampleClock_GetSourceIndex( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwSourceIndex -); - -u16 HPI_SampleClock_GetSampleRate( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwSampleRate -); - -u16 HPI_SampleClock_QueryLocalRate( - const struct hpi_hsubsys *phSubSys, - const u32 hClock, - const u32 dwIndex, - u32 *pdwSource -); - -u16 HPI_SampleClock_SetLocalRate( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwSampleRate -); - -u16 HPI_SampleClock_GetLocalRate( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwSampleRate -); - -u16 HPI_SampleClock_SetAuto( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwAuto -); - -u16 HPI_SampleClock_GetAuto( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwAuto -); - -u16 HPI_SampleClock_SetLocalRateLock( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwLock -); - -u16 HPI_SampleClock_GetLocalRateLock( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwLock -); +u16 hpi_sample_clock_query_source(const struct hpi_hsubsys *ph_subsys, + const u32 h_clock, const u32 index, u16 *pw_source); + +u16 hpi_sample_clock_set_source(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 source); + +u16 hpi_sample_clock_get_source(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_source); + +u16 hpi_sample_clock_query_source_index(const struct hpi_hsubsys *ph_subsys, + const u32 h_clock, const u32 index, const u32 source, + u16 *pw_source_index); + +u16 hpi_sample_clock_set_source_index(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 source_index); + +u16 hpi_sample_clock_get_source_index(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_source_index); + +u16 hpi_sample_clock_get_sample_rate(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *psample_rate); + +u16 hpi_sample_clock_query_local_rate(const struct hpi_hsubsys *ph_subsys, + const u32 h_clock, const u32 index, u32 *psource); + +u16 hpi_sample_clock_set_local_rate(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 sample_rate); + +u16 hpi_sample_clock_get_local_rate(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *psample_rate); + +u16 hpi_sample_clock_set_auto(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 enable); + +u16 hpi_sample_clock_get_auto(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *penable); + +u16 hpi_sample_clock_set_local_rate_lock(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 lock); + +u16 hpi_sample_clock_get_local_rate_lock(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *plock); /***********************/ /* Microphone control */ /***********************/ -u16 HPI_Microphone_SetPhantomPower( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wOnOff -); - -u16 HPI_Microphone_GetPhantomPower( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwOnOff -); +u16 hpi_microphone_set_phantom_power(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 on_off); + +u16 hpi_microphone_get_phantom_power(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_on_off); /******************************* Parametric Equalizer control *******************************/ -u16 HPI_ParametricEQ_GetInfo( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwNumberOfBands, - u16 *pwEnabled -); - -u16 HPI_ParametricEQ_SetState( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wOnOff -); - -u16 HPI_ParametricEQ_SetBand( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 nType, - u32 dwFrequencyHz, - short nQ100, - short nGain0_01dB -); - -u16 HPI_ParametricEQ_GetBand( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 *pnType, - u32 *pdwFrequencyHz, - short *pnQ100, - short *pnGain0_01dB -); - -u16 HPI_ParametricEQ_GetCoeffs( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - short coeffs[5] -); +u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_number_of_bands, u16 *pw_enabled); + +u16 hpi_parametricEQ__set_state(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 on_off); + +u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 index, u16 type, u32 frequency_hz, short q100, + short gain0_01dB); + +u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 index, u16 *pn_type, u32 *pfrequency_hz, + short *pnQ100, short *pn_gain0_01dB); + +u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 index, short coeffs[5] + ); /******************************* Compressor Expander control *******************************/ -u16 HPI_Compander_Set( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wAttack, - u16 wDecay, - short wRatio100, - short nThreshold0_01dB, - short nMakeupGain0_01dB -); - -u16 HPI_Compander_Get( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwAttack, - u16 *pwDecay, - short *pwRatio100, - short *pnThreshold0_01dB, - short *pnMakeupGain0_01dB -); +u16 hpi_compander_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 attack, u16 decay, short ratio100, short threshold0_01dB, + short makeup_gain0_01dB); + +u16 hpi_compander_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 *pw_attack, u16 *pw_decay, short *pw_ratio100, + short *pn_threshold0_01dB, short *pn_makeup_gain0_01dB); /******************************* Cobranet HMI control *******************************/ -u16 HPI_Cobranet_HmiWrite( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwHmiAddress, - u32 dwByteCount, - u8 *pbData -); - -u16 HPI_Cobranet_HmiRead( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwHmiAddress, - u32 dwMaxByteCount, - u32 *pdwByteCount, - u8 *pbData -); - -u16 HPI_Cobranet_HmiGetStatus( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwStatus, - u32 *pdwReadableSize, - u32 *pdwWriteableSize -); +u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 hmi_address, u32 byte_count, u8 *pb_data); + +u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 hmi_address, u32 max_byte_count, u32 *pbyte_count, u8 *pb_data); + +u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pstatus, u32 *preadable_size, + u32 *pwriteable_size); /*Read the current IP address */ -u16 HPI_Cobranet_GetIPaddress( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwIPaddress -); +u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pi_paddress); + /* Write the current IP address */ -u16 HPI_Cobranet_SetIPaddress( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwIPaddress -); +u16 hpi_cobranet_setI_paddress(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 i_paddress); + /* Read the static IP address */ -u16 HPI_Cobranet_GetStaticIPaddress( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwIPaddress -); +u16 hpi_cobranet_get_staticI_paddress(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pi_paddress); + /* Write the static IP address */ -u16 HPI_Cobranet_SetStaticIPaddress( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwIPaddress -); +u16 hpi_cobranet_set_staticI_paddress(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 i_paddress); + /* Read the MAC address */ -u16 HPI_Cobranet_GetMACaddress( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwMAC_MSBs, - u32 *pdwMAC_LSBs -); +u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pmAC_MS_bs, u32 *pmAC_LS_bs); + /******************************* Tone Detector control *******************************/ -u16 HPI_ToneDetector_GetState( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 *State -); - -u16 HPI_ToneDetector_SetEnable( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 Enable -); - -u16 HPI_ToneDetector_GetEnable( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 *Enable -); - -u16 HPI_ToneDetector_SetEventEnable( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 EventEnable -); - -u16 HPI_ToneDetector_GetEventEnable( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 *EventEnable -); - -u16 HPI_ToneDetector_SetThreshold( - const struct hpi_hsubsys *phSubSys, - u32 hC, - int Threshold -); - -u16 HPI_ToneDetector_GetThreshold( - const struct hpi_hsubsys *phSubSys, - u32 hC, - int *Threshold -); - -u16 HPI_ToneDetector_GetFrequency( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 nIndex, - u32 *dwFrequency -); +u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys, u32 hC, + u32 *state); + +u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys, u32 hC, + u32 enable); + +u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys, u32 hC, + u32 *enable); + +u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, + u32 hC, u32 event_enable); + +u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, + u32 hC, u32 *event_enable); + +u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, + u32 hC, int threshold); + +u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, + u32 hC, int *threshold); + +u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys, + u32 hC, u32 index, u32 *frequency); /******************************* Silence Detector control *******************************/ -u16 HPI_SilenceDetector_GetState( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 *State -); - -u16 HPI_SilenceDetector_SetEnable( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 Enable -); - -u16 HPI_SilenceDetector_GetEnable( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 *Enable -); - -u16 HPI_SilenceDetector_SetEventEnable( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 EventEnable -); - -u16 HPI_SilenceDetector_GetEventEnable( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 *EventEnable -); - -u16 HPI_SilenceDetector_SetDelay( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 Delay -); - -u16 HPI_SilenceDetector_GetDelay( - const struct hpi_hsubsys *phSubSys, - u32 hC, - u32 *Delay -); - -u16 HPI_SilenceDetector_SetThreshold( - const struct hpi_hsubsys *phSubSys, - u32 hC, - int Threshold -); - -u16 HPI_SilenceDetector_GetThreshold( - const struct hpi_hsubsys *phSubSys, - u32 hC, - int *Threshold -); +u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys, + u32 hC, u32 *state); + +u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys, + u32 hC, u32 enable); + +u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys, + u32 hC, u32 *enable); + +u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, + u32 hC, u32 event_enable); + +u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, + u32 hC, u32 *event_enable); + +u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys, + u32 hC, u32 delay); + +u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys, + u32 hC, u32 *delay); + +u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, + u32 hC, int threshold); + +u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, + u32 hC, int *threshold); /******************************* Universal control *******************************/ -u16 HPI_Entity_FindNext( - struct hpi_entity *container_entity, - enum e_entity_type type, - enum e_entity_role role, - int recursive_flag, - struct hpi_entity **current_match -); - -u16 HPI_Entity_CopyValueFrom( - struct hpi_entity *entity, - enum e_entity_type type, - size_t item_count, - void *value_dst_p -); - -u16 HPI_Entity_Unpack( - struct hpi_entity *entity, - enum e_entity_type *type, - size_t *items, - enum e_entity_role *role, - void **value -); - -u16 HPI_Entity_AllocAndPack( - const enum e_entity_type type, - const size_t item_count, - const enum e_entity_role role, - void *value, - struct hpi_entity **entity -); - -void HPI_Entity_Free( - struct hpi_entity *entity -); - -u16 HPI_Universal_Info( - const struct hpi_hsubsys *phSubSys, - u32 hC, - struct hpi_entity **info -); - -u16 HPI_Universal_Get( - const struct hpi_hsubsys *phSubSys, - u32 hC, - struct hpi_entity **value -); - -u16 HPI_Universal_Set( - const struct hpi_hsubsys *phSubSys, - u32 hC, - struct hpi_entity *value -); +u16 hpi_entity_find_next(struct hpi_entity *container_entity, + enum e_entity_type type, enum e_entity_role role, int recursive_flag, + struct hpi_entity **current_match); + +u16 hpi_entity_copy_value_from(struct hpi_entity *entity, + enum e_entity_type type, size_t item_count, void *value_dst_p); + +u16 hpi_entity_unpack(struct hpi_entity *entity, enum e_entity_type *type, + size_t *items, enum e_entity_role *role, void **value); + +u16 hpi_entity_alloc_and_pack(const enum e_entity_type type, + const size_t item_count, const enum e_entity_role role, void *value, + struct hpi_entity **entity); + +void hpi_entity_free(struct hpi_entity *entity); + +u16 hpi_universal_info(const struct hpi_hsubsys *ph_subsys, u32 hC, + struct hpi_entity **info); + +u16 hpi_universal_get(const struct hpi_hsubsys *ph_subsys, u32 hC, + struct hpi_entity **value); + +u16 hpi_universal_set(const struct hpi_hsubsys *ph_subsys, u32 hC, + struct hpi_entity *value); /*/////////// */ /* DSP CLOCK */ /*/////////// */ -u16 HPI_ClockOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *phDspClock -); - -u16 HPI_ClockSetTime( - const struct hpi_hsubsys *phSubSys, - u32 hClock, - u16 wHour, - u16 wMinute, - u16 wSecond, - u16 wMilliSecond -); - -u16 HPI_ClockGetTime( - const struct hpi_hsubsys *phSubSys, - u32 hClock, - u16 *pwHour, - u16 *pwMinute, - u16 *pwSecond, - u16 *pwMilliSecond -); +u16 hpi_clock_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u32 *ph_dsp_clock); + +u16 hpi_clock_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_clock, + u16 hour, u16 minute, u16 second, u16 milli_second); + +u16 hpi_clock_get_time(const struct hpi_hsubsys *ph_subsys, u32 h_clock, + u16 *pw_hour, u16 *pw_minute, u16 *pw_second, u16 *pw_milli_second); /*/////////// */ /* PROFILE */ /*/////////// */ -u16 HPI_ProfileOpenAll( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wProfileIndex, - u32 *phProfile, - u16 *pwMaxProfiles -); - -u16 HPI_ProfileGet( - const struct hpi_hsubsys *phSubSys, - u32 hProfile, - u16 wIndex, - u16 *pwSeconds, - u32 *pdwMicroSeconds, - u32 *pdwCallCount, - u32 *pdwMaxMicroSeconds, - u32 *pdwMinMicroSeconds -); - -u16 HPI_ProfileStartAll( - const struct hpi_hsubsys *phSubSys, - u32 hProfile -); - -u16 HPI_ProfileStopAll( - const struct hpi_hsubsys *phSubSys, - u32 hProfile -); - -u16 HPI_ProfileGetName( - const struct hpi_hsubsys *phSubSys, - u32 hProfile, - u16 wIndex, - char *szProfileName, - u16 nProfileNameLength -); - -u16 HPI_ProfileGetUtilization( - const struct hpi_hsubsys *phSubSys, - u32 hProfile, - u32 *pdwUtilization -); +u16 hpi_profile_open_all(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 profile_index, u32 *ph_profile, + u16 *pw_max_profiles); + +u16 hpi_profile_get(const struct hpi_hsubsys *ph_subsys, u32 h_profile, + u16 index, u16 *pw_seconds, u32 *pmicro_seconds, u32 *pcall_count, + u32 *pmax_micro_seconds, u32 *pmin_micro_seconds); + +u16 hpi_profile_start_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile); + +u16 hpi_profile_stop_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile); + +u16 hpi_profile_get_name(const struct hpi_hsubsys *ph_subsys, u32 h_profile, + u16 index, char *sz_profile_name, u16 profile_name_length); + +u16 hpi_profile_get_utilization(const struct hpi_hsubsys *ph_subsys, + u32 h_profile, u32 *putilization); /*//////////////////// */ /* UTILITY functions */ -u16 HPI_FormatCreate( - struct hpi_format *pFormat, - u16 wChannels, - u16 wFormat, - u32 dwSampleRate, - u32 dwBitRate, - u32 dwAttributes -); +u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, + u32 sample_rate, u32 bit_rate, u32 attributes); /* Until it's verified, this function is for Windows OSs only */ diff --git a/pci/asihpi/hpi6000.c b/pci/asihpi/hpi6000.c index 09440ea76..3a0c651c7 100644 --- a/pci/asihpi/hpi6000.c +++ b/pci/asihpi/hpi6000.c @@ -129,153 +129,96 @@ #define TIMEOUT 500000 struct dsp_obj { - __iomem u32 *prHPIControl; - __iomem u32 *prHPIAddress; - __iomem u32 *prHPIData; - __iomem u32 *prHPIDataAutoInc; - char cDspRev; /*A, B */ - u32 dwControlCacheAddressOnDSP; - u32 dwControlCacheLengthOnDSP; - struct hpi_adapter_obj *paParentAdapter; + __iomem u32 *prHPI_control; + __iomem u32 *prHPI_address; + __iomem u32 *prHPI_data; + __iomem u32 *prHPI_data_auto_inc; + char c_dsp_rev; /*A, B */ + u32 control_cache_address_on_dsp; + u32 control_cache_length_on_dsp; + struct hpi_adapter_obj *pa_parent_adapter; }; struct hpi_hw_obj { __iomem u32 *dw2040_HPICSR; __iomem u32 *dw2040_HPIDSP; - u16 wNumDsp; + u16 num_dsp; struct dsp_obj ado[MAX_DSPS]; - u32 dwMessageBufferAddressOnDSP; - u32 dwResponseBufferAddressOnDSP; - u32 dwPCI2040HPIErrorCount; + u32 message_buffer_address_on_dsp; + u32 response_buffer_address_on_dsp; + u32 pCI2040HPI_error_count; - struct hpi_control_cache_single aControlCache[HPI_NMIXER_CONTROLS]; - struct hpi_control_cache *pCache; + struct hpi_control_cache_single control_cache[HPI_NMIXER_CONTROLS]; + struct hpi_control_cache *p_cache; }; -static u16 Hpi6000_DspBlockWrite32( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - u32 dwHpiAddress, - u32 *dwSource, - u32 dwCount -); -static u16 Hpi6000_DspBlockRead32( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - u32 dwHpiAddress, - u32 *dwDest, - u32 dwCount -); - -static short Hpi6000_AdapterBootLoadDsp( - struct hpi_adapter_obj *pao, - u32 *pdwOsErrorCode -); -static short Hpi6000_Check_PCI2040_ErrorFlag( - struct hpi_adapter_obj *pao, - u16 nReadOrWrite -); +static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao, + u16 dsp_index, u32 hpi_address, u32 *source, u32 count); +static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao, + u16 dsp_index, u32 hpi_address, u32 *dest, u32 count); + +static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, + u32 *pos_error_code); +static short hpi6000_check_PCI2040_error_flag(struct hpi_adapter_obj *pao, + u16 read_or_write); #define H6READ 1 #define H6WRITE 0 -static short Hpi6000_UpdateControlCache( - struct hpi_adapter_obj *pao, - struct hpi_message *phm -); -static short Hpi6000_MessageResponseSequence( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - struct hpi_message *phm, - struct hpi_response *phr -); - -static void HW_Message( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static short Hpi6000_WaitDspAck( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - u32 dwAckValue -); -static short Hpi6000_SendHostCommand( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - u32 dwHostCmd -); -static void Hpi6000_SendDspInterrupt( - struct dsp_obj *pdo -); -static short Hpi6000_SendData( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - struct hpi_message *phm, - struct hpi_response *phr -); -static short Hpi6000_GetData( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - struct hpi_message *phm, - struct hpi_response *phr -); - -static void HpiWriteWord( - struct dsp_obj *pdo, - u32 dwAddress, - u32 dwData -); -static u32 HpiReadWord( - struct dsp_obj *pdo, - u32 dwAddress -); -static void HpiWriteBlock( - struct dsp_obj *pdo, - u32 dwAddress, - u32 *pdwData, - u32 dwLength -); -static void HpiReadBlock( - struct dsp_obj *pdo, - u32 dwAddress, - u32 *pdwData, - u32 dwLength -); - -static void SubSysCreateAdapter( - struct hpi_message *phm, - struct hpi_response *phr -); -static void SubSysDeleteAdapter( - struct hpi_message *phm, - struct hpi_response *phr -); - -static void AdapterGetAsserts( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); - -static short CreateAdapterObj( - struct hpi_adapter_obj *pao, - u32 *pdwOsErrorCode -); +static short hpi6000_update_control_cache(struct hpi_adapter_obj *pao, + struct hpi_message *phm); +static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao, + u16 dsp_index, struct hpi_message *phm, struct hpi_response *phr); + +static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, + struct hpi_response *phr); + +static short hpi6000_wait_dsp_ack(struct hpi_adapter_obj *pao, u16 dsp_index, + u32 ack_value); + +static short hpi6000_send_host_command(struct hpi_adapter_obj *pao, + u16 dsp_index, u32 host_cmd); + +static void hpi6000_send_dsp_interrupt(struct dsp_obj *pdo); + +static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index, + struct hpi_message *phm, struct hpi_response *phr); + +static short hpi6000_get_data(struct hpi_adapter_obj *pao, u16 dsp_index, + struct hpi_message *phm, struct hpi_response *phr); + +static void hpi_write_word(struct dsp_obj *pdo, u32 address, u32 data); + +static u32 hpi_read_word(struct dsp_obj *pdo, u32 address); + +static void hpi_write_block(struct dsp_obj *pdo, u32 address, u32 *pdata, + u32 length); + +static void hpi_read_block(struct dsp_obj *pdo, u32 address, u32 *pdata, + u32 length); + +static void subsys_create_adapter(struct hpi_message *phm, + struct hpi_response *phr); + +static void subsys_delete_adapter(struct hpi_message *phm, + struct hpi_response *phr); + +static void adapter_get_asserts(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static short create_adapter_obj(struct hpi_adapter_obj *pao, + u32 *pos_error_code); /* local globals */ -static u16 gwPciReadAsserts; /* used to count PCI2040 errors */ -static u16 gwPciWriteAsserts; /* used to count PCI2040 errors */ +static u16 gw_pci_read_asserts; /* used to count PCI2040 errors */ +static u16 gw_pci_write_asserts; /* used to count PCI2040 errors */ -static void SubSysMessage( - struct hpi_message *phm, - struct hpi_response *phr -) +static void subsys_message(struct hpi_message *phm, struct hpi_response *phr) { - switch (phm->wFunction) { + switch (phm->function) { case HPI_SUBSYS_OPEN: case HPI_SUBSYS_CLOSE: case HPI_SUBSYS_GET_INFO: @@ -283,71 +226,65 @@ static void SubSysMessage( case HPI_SUBSYS_DRIVER_LOAD: case HPI_SUBSYS_FIND_ADAPTERS: /* messages that should not get here */ - phr->wError = HPI_ERROR_UNIMPLEMENTED; + phr->error = HPI_ERROR_UNIMPLEMENTED; break; case HPI_SUBSYS_CREATE_ADAPTER: - SubSysCreateAdapter(phm, phr); + subsys_create_adapter(phm, phr); break; case HPI_SUBSYS_DELETE_ADAPTER: - SubSysDeleteAdapter(phm, phr); + subsys_delete_adapter(phm, phr); break; default: - phr->wError = HPI_ERROR_INVALID_FUNC; + phr->error = HPI_ERROR_INVALID_FUNC; break; } } -static void ControlMessage( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void control_message(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { - switch (phm->wFunction) { + switch (phm->function) { case HPI_CONTROL_GET_STATE: - if (pao->wHasControlCache) { + if (pao->has_control_cache) { u16 err; - err = Hpi6000_UpdateControlCache(pao, phm); + err = hpi6000_update_control_cache(pao, phm); if (err) { - phr->wError = err; + phr->error = err; break; } - if (HpiCheckControlCache - (((struct hpi_hw_obj *)pao->priv)->pCache, - phm, phr)) + if (hpi_check_control_cache(((struct hpi_hw_obj *) + pao->priv)->p_cache, phm, + phr)) break; } - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); break; case HPI_CONTROL_GET_INFO: - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); break; case HPI_CONTROL_SET_STATE: - HW_Message(pao, phm, phr); - HpiSyncControlCache( - ((struct hpi_hw_obj *)pao->priv)->pCache, phm, phr); + hw_message(pao, phm, phr); + hpi_sync_control_cache(((struct hpi_hw_obj *)pao->priv)-> + p_cache, phm, phr); break; default: - phr->wError = HPI_ERROR_INVALID_FUNC; + phr->error = HPI_ERROR_INVALID_FUNC; break; } } -static void AdapterMessage( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void adapter_message(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { - switch (phm->wFunction) { + switch (phm->function) { case HPI_ADAPTER_GET_INFO: - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); break; case HPI_ADAPTER_GET_ASSERT: - AdapterGetAsserts(pao, phm, phr); + adapter_get_asserts(pao, phm, phr); break; case HPI_ADAPTER_OPEN: case HPI_ADAPTER_CLOSE: @@ -359,21 +296,18 @@ static void AdapterMessage( case HPI_ADAPTER_GET_PROPERTY: case HPI_ADAPTER_SET_PROPERTY: case HPI_ADAPTER_ENUM_PROPERTY: - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); break; default: - phr->wError = HPI_ERROR_INVALID_FUNC; + phr->error = HPI_ERROR_INVALID_FUNC; break; } } -static void OStreamMessage( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void outstream_message(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { - switch (phm->wFunction) { + switch (phm->function) { case HPI_OSTREAM_HOSTBUFFER_ALLOC: case HPI_OSTREAM_HOSTBUFFER_FREE: /* Don't let these messages go to the HW function because @@ -381,22 +315,19 @@ static void OStreamMessage( * For the HPI6000 adapters the HW would return * HPI_ERROR_INVALID_FUNC anyway. */ - phr->wError = HPI_ERROR_INVALID_FUNC; + phr->error = HPI_ERROR_INVALID_FUNC; break; default: - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); return; } } -static void IStreamMessage( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void instream_message(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { - switch (phm->wFunction) { + switch (phm->function) { case HPI_ISTREAM_HOSTBUFFER_ALLOC: case HPI_ISTREAM_HOSTBUFFER_FREE: /* Don't let these messages go to the HW function because @@ -404,10 +335,10 @@ static void IStreamMessage( * For the HPI6000 adapters the HW would return * HPI_ERROR_INVALID_FUNC anyway. */ - phr->wError = HPI_ERROR_INVALID_FUNC; + phr->error = HPI_ERROR_INVALID_FUNC; break; default: - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); return; } } @@ -417,75 +348,72 @@ static void IStreamMessage( * Entry point from HPIMAN * All calls to the HPI start here */ -void HPI_6000( - struct hpi_message *phm, - struct hpi_response *phr -) +void HPI_6000(struct hpi_message *phm, struct hpi_response *phr) { struct hpi_adapter_obj *pao = NULL; /* subsytem messages get executed by every HPI. */ /* All other messages are ignored unless the adapter index matches */ /* an adapter in the HPI */ - HPI_DEBUG_LOG(DEBUG, "O %d,F %x\n", phm->wObject, phm->wFunction); + HPI_DEBUG_LOG(DEBUG, "O %d,F %x\n", phm->object, phm->function); /* if Dsp has crashed then do not communicate with it any more */ - if (phm->wObject != HPI_OBJ_SUBSYSTEM) { - pao = HpiFindAdapter(phm->wAdapterIndex); + if (phm->object != HPI_OBJ_SUBSYSTEM) { + pao = hpi_find_adapter(phm->adapter_index); if (!pao) { HPI_DEBUG_LOG(DEBUG, " %d,%d refused, for another HPI?\n", - phm->wObject, phm->wFunction); + phm->object, phm->function); return; } - if (pao->wDspCrashed >= 10) { - HPI_InitResponse(phr, phm->wObject, phm->wFunction, + if (pao->dsp_crashed >= 10) { + hpi_init_response(phr, phm->object, phm->function, HPI_ERROR_DSP_HARDWARE); HPI_DEBUG_LOG(DEBUG, " %d,%d dsp crashed.\n", - phm->wObject, phm->wFunction); + phm->object, phm->function); return; } } /* Init default response including the size field */ - if (phm->wFunction != HPI_SUBSYS_CREATE_ADAPTER) - HPI_InitResponse(phr, phm->wObject, phm->wFunction, + if (phm->function != HPI_SUBSYS_CREATE_ADAPTER) + hpi_init_response(phr, phm->object, phm->function, HPI_ERROR_PROCESSING_MESSAGE); - switch (phm->wType) { + switch (phm->type) { case HPI_TYPE_MESSAGE: - switch (phm->wObject) { + switch (phm->object) { case HPI_OBJ_SUBSYSTEM: - SubSysMessage(phm, phr); + subsys_message(phm, phr); break; case HPI_OBJ_ADAPTER: - phr->wSize = + phr->size = sizeof(struct hpi_response_header) + sizeof(struct hpi_adapter_res); - AdapterMessage(pao, phm, phr); + adapter_message(pao, phm, phr); break; case HPI_OBJ_CONTROL: - ControlMessage(pao, phm, phr); + control_message(pao, phm, phr); break; case HPI_OBJ_OSTREAM: - OStreamMessage(pao, phm, phr); + outstream_message(pao, phm, phr); break; case HPI_OBJ_ISTREAM: - IStreamMessage(pao, phm, phr); + instream_message(pao, phm, phr); break; default: - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); break; } break; default: - phr->wError = HPI_ERROR_INVALID_TYPE; + phr->error = HPI_ERROR_INVALID_TYPE; break; } } @@ -498,159 +426,152 @@ void HPI_6000( * NOTE - you cannot use this function AND the FindAdapters function at the * same time, the application must use only one of them to get the adapters */ -static void SubSysCreateAdapter( - struct hpi_message *phm, - struct hpi_response *phr -) +static void subsys_create_adapter(struct hpi_message *phm, + struct hpi_response *phr) { /* create temp adapter obj, because we don't know what index yet */ struct hpi_adapter_obj ao; struct hpi_adapter_obj *pao; - u32 dwOsErrorCode; - short nError = 0; - u32 dwDspIndex = 0; + u32 os_error_code; + short error = 0; + u32 dsp_index = 0; - HPI_DEBUG_LOG(VERBOSE, "SubSysCreateAdapter\n"); + HPI_DEBUG_LOG(VERBOSE, "subsys_create_adapter\n"); memset(&ao, 0, sizeof(ao)); /* this HPI only creates adapters for TI/PCI2040 based devices */ - if (phm->u.s.Resource.wBusType != HPI_BUS_PCI) + if (phm->u.s.resource.bus_type != HPI_BUS_PCI) return; - if (phm->u.s.Resource.r.Pci->wVendorId != HPI_PCI_VENDOR_ID_TI) + if (phm->u.s.resource.r.pci->vendor_id != HPI_PCI_VENDOR_ID_TI) return; - if (phm->u.s.Resource.r.Pci->wDeviceId != HPI_PCI_DEV_ID_PCI2040) + if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_PCI2040) return; ao.priv = kmalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL); if (!ao.priv) { HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n"); - phr->wError = HPI_ERROR_MEMORY_ALLOC; + phr->error = HPI_ERROR_MEMORY_ALLOC; return; } memset(ao.priv, 0, sizeof(struct hpi_hw_obj)); /* create the adapter object based on the resource information */ /*? memcpy(&ao.Pci,&phm->u.s.Resource.r.Pci,sizeof(ao.Pci)); */ - ao.Pci = *phm->u.s.Resource.r.Pci; + ao.pci = *phm->u.s.resource.r.pci; - nError = CreateAdapterObj(&ao, &dwOsErrorCode); - if (!nError) - nError = HpiAddAdapter(&ao); - if (nError) { - phr->u.s.dwData = dwOsErrorCode; + error = create_adapter_obj(&ao, &os_error_code); + if (!error) + error = hpi_add_adapter(&ao); + if (error) { + phr->u.s.data = os_error_code; kfree(ao.priv); - phr->wError = nError; + phr->error = error; return; } /* need to update paParentAdapter */ - pao = HpiFindAdapter(ao.wIndex); + pao = hpi_find_adapter(ao.index); if (!pao) { /* We just added this adapter, why can't we find it!? */ HPI_DEBUG_LOG(ERROR, "lost adapter after boot\n"); - phr->wError = 950; + phr->error = 950; return; } - for (dwDspIndex = 0; dwDspIndex < MAX_DSPS; dwDspIndex++) { + for (dsp_index = 0; dsp_index < MAX_DSPS; dsp_index++) { struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; - phw->ado[dwDspIndex].paParentAdapter = pao; + phw->ado[dsp_index].pa_parent_adapter = pao; } - phr->u.s.awAdapterList[ao.wIndex] = ao.wAdapterType; - phr->u.s.wAdapterIndex = ao.wIndex; - phr->u.s.wNumAdapters++; - phr->wError = 0; + phr->u.s.aw_adapter_list[ao.index] = ao.adapter_type; + phr->u.s.adapter_index = ao.index; + phr->u.s.num_adapters++; + phr->error = 0; } -static void SubSysDeleteAdapter( - struct hpi_message *phm, - struct hpi_response *phr -) +static void subsys_delete_adapter(struct hpi_message *phm, + struct hpi_response *phr) { struct hpi_adapter_obj *pao = NULL; struct hpi_hw_obj *phw; - pao = HpiFindAdapter(phm->wAdapterIndex); + pao = hpi_find_adapter(phm->adapter_index); if (!pao) return; phw = (struct hpi_hw_obj *)pao->priv; - if (pao->wHasControlCache) - HpiFreeControlCache(phw->pCache); + if (pao->has_control_cache) + hpi_free_control_cache(phw->p_cache); - HpiDeleteAdapter(pao); + hpi_delete_adapter(pao); kfree(phw); - phr->wError = 0; + phr->error = 0; } /* this routine is called from SubSysFindAdapter and SubSysCreateAdapter */ -static short CreateAdapterObj( - struct hpi_adapter_obj *pao, - u32 *pdwOsErrorCode -) +static short create_adapter_obj(struct hpi_adapter_obj *pao, + u32 *pos_error_code) { - short nBootError = 0; - u32 dwDspIndex = 0; - u32 dwControlCacheSize = 0; - u32 dwControlCacheCount = 0; + short boot_error = 0; + u32 dsp_index = 0; + u32 control_cache_size = 0; + u32 control_cache_count = 0; struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; /* init error reporting */ - pao->wDspCrashed = 0; + pao->dsp_crashed = 0; /* The PCI2040 has the following address map */ /* BAR0 - 4K = HPI control and status registers on PCI2040 (HPI CSR) */ /* BAR1 - 32K = HPI registers on DSP */ - phw->dw2040_HPICSR = pao->Pci.apMemBase[0]; - phw->dw2040_HPIDSP = pao->Pci.apMemBase[1]; - HPI_DEBUG_LOG(VERBOSE, "csr %p, dsp %p\n", - phw->dw2040_HPICSR, phw->dw2040_HPIDSP); + phw->dw2040_HPICSR = pao->pci.ap_mem_base[0]; + phw->dw2040_HPIDSP = pao->pci.ap_mem_base[1]; + HPI_DEBUG_LOG(VERBOSE, "csr %p, dsp %p\n", phw->dw2040_HPICSR, + phw->dw2040_HPIDSP); /* set addresses for the possible DSP HPI interfaces */ - for (dwDspIndex = 0; dwDspIndex < MAX_DSPS; dwDspIndex++) { - phw->ado[dwDspIndex].prHPIControl = + for (dsp_index = 0; dsp_index < MAX_DSPS; dsp_index++) { + phw->ado[dsp_index].prHPI_control = phw->dw2040_HPIDSP + (CONTROL + - DSP_SPACING * dwDspIndex); + DSP_SPACING * dsp_index); - phw->ado[dwDspIndex].prHPIAddress = + phw->ado[dsp_index].prHPI_address = phw->dw2040_HPIDSP + (ADDRESS + - DSP_SPACING * dwDspIndex); - phw->ado[dwDspIndex].prHPIData = - phw->dw2040_HPIDSP + (DATA + - DSP_SPACING * dwDspIndex); + DSP_SPACING * dsp_index); + phw->ado[dsp_index].prHPI_data = + phw->dw2040_HPIDSP + (DATA + DSP_SPACING * dsp_index); - phw->ado[dwDspIndex].prHPIDataAutoInc = - phw->dw2040_HPIDSP + - (DATA_AUTOINC + DSP_SPACING * dwDspIndex); + phw->ado[dsp_index].prHPI_data_auto_inc = + phw->dw2040_HPIDSP + (DATA_AUTOINC + + DSP_SPACING * dsp_index); HPI_DEBUG_LOG(VERBOSE, "ctl %p, adr %p, dat %p, dat++ %p\n", - phw->ado[dwDspIndex].prHPIControl, - phw->ado[dwDspIndex].prHPIAddress, - phw->ado[dwDspIndex].prHPIData, - phw->ado[dwDspIndex].prHPIDataAutoInc); + phw->ado[dsp_index].prHPI_control, + phw->ado[dsp_index].prHPI_address, + phw->ado[dsp_index].prHPI_data, + phw->ado[dsp_index].prHPI_data_auto_inc); - phw->ado[dwDspIndex].paParentAdapter = pao; + phw->ado[dsp_index].pa_parent_adapter = pao; } - phw->dwPCI2040HPIErrorCount = 0; - pao->wHasControlCache = 0; + phw->pCI2040HPI_error_count = 0; + pao->has_control_cache = 0; /* Set the default number of DSPs on this card */ /* This is (conditionally) adjusted after bootloading */ /* of the first DSP in the bootload section. */ - phw->wNumDsp = 1; + phw->num_dsp = 1; - nBootError = Hpi6000_AdapterBootLoadDsp(pao, pdwOsErrorCode); - if (nBootError) - return (nBootError); + boot_error = hpi6000_adapter_boot_load_dsp(pao, pos_error_code); + if (boot_error) + return (boot_error); - HPI_DEBUG_LOG(INFO, "Bootload DSP OK\n"); + HPI_DEBUG_LOG(INFO, "bootload DSP OK\n"); - phw->dwMessageBufferAddressOnDSP = 0L; - phw->dwResponseBufferAddressOnDSP = 0L; + phw->message_buffer_address_on_dsp = 0L; + phw->response_buffer_address_on_dsp = 0L; /* get info about the adapter by asking the adapter */ /* send a HPI_ADAPTER_GET_INFO message */ @@ -658,83 +579,82 @@ static short CreateAdapterObj( struct hpi_message hM; struct hpi_response hR0; /* response from DSP 0 */ struct hpi_response hR1; /* response from DSP 1 */ - u16 wError = 0; + u16 error = 0; HPI_DEBUG_LOG(VERBOSE, "send ADAPTER_GET_INFO\n"); memset(&hM, 0, sizeof(hM)); - hM.wType = HPI_TYPE_MESSAGE; - hM.wSize = sizeof(struct hpi_message); - hM.wObject = HPI_OBJ_ADAPTER; - hM.wFunction = HPI_ADAPTER_GET_INFO; - hM.wAdapterIndex = 0; + hM.type = HPI_TYPE_MESSAGE; + hM.size = sizeof(struct hpi_message); + hM.object = HPI_OBJ_ADAPTER; + hM.function = HPI_ADAPTER_GET_INFO; + hM.adapter_index = 0; memset(&hR0, 0, sizeof(hR0)); memset(&hR1, 0, sizeof(hR1)); - hR0.wSize = sizeof(hR0); - hR1.wSize = sizeof(hR1); - - wError = Hpi6000_MessageResponseSequence(pao, 0, &hM, &hR0); - if (hR0.wError) { - HPI_DEBUG_LOG(DEBUG, "message error %d\n", - hR0.wError); - return (hR0.wError); /*error */ + hR0.size = sizeof(hR0); + hR1.size = sizeof(hR1); + + error = hpi6000_message_response_sequence(pao, 0, &hM, &hR0); + if (hR0.error) { + HPI_DEBUG_LOG(DEBUG, "message error %d\n", hR0.error); + return (hR0.error); /*error */ } - if (phw->wNumDsp == 2) { - wError = Hpi6000_MessageResponseSequence(pao, 1, &hM, + if (phw->num_dsp == 2) { + error = hpi6000_message_response_sequence(pao, 1, &hM, &hR1); - if (wError) - return wError; + if (error) + return error; } - pao->wAdapterType = hR0.u.a.wAdapterType; - pao->wIndex = hR0.u.a.wAdapterIndex; + pao->adapter_type = hR0.u.a.adapter_type; + pao->index = hR0.u.a.adapter_index; } - memset(&phw->aControlCache[0], 0, + memset(&phw->control_cache[0], 0, sizeof(struct hpi_control_cache_single) * HPI_NMIXER_CONTROLS); /* Read the control cache length to figure out if it is turned on */ - dwControlCacheSize = HpiReadWord(&phw->ado[0], - HPI_HIF_ADDR(dwControlCacheSizeInBytes)); - if (dwControlCacheSize) { - dwControlCacheCount = HpiReadWord(&phw->ado[0], - HPI_HIF_ADDR(dwControlCacheCount)); - pao->wHasControlCache = 1; - - phw->pCache = HpiAllocControlCache(dwControlCacheCount, - dwControlCacheSize, (struct hpi_control_cache_info *) - &phw->aControlCache[0] + control_cache_size = + hpi_read_word(&phw->ado[0], + HPI_HIF_ADDR(control_cache_size_in_bytes)); + if (control_cache_size) { + control_cache_count = + hpi_read_word(&phw->ado[0], + HPI_HIF_ADDR(control_cache_count)); + pao->has_control_cache = 1; + + phw->p_cache = + hpi_alloc_control_cache(control_cache_count, + control_cache_size, (struct hpi_control_cache_info *) + &phw->control_cache[0] ); } else - pao->wHasControlCache = 0; + pao->has_control_cache = 0; - HPI_DEBUG_LOG(DEBUG, "Get adapter info ASI%04X index %d\n", - pao->wAdapterType, pao->wIndex); - pao->wOpen = 0; /* upon creation the adapter is closed */ + HPI_DEBUG_LOG(DEBUG, "get adapter info ASI%04X index %d\n", + pao->adapter_type, pao->index); + pao->open = 0; /* upon creation the adapter is closed */ return 0; } /************************************************************************/ /* ADAPTER */ -static void AdapterGetAsserts( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void adapter_get_asserts(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { #ifndef HIDE_PCI_ASSERTS /* if we have PCI2040 asserts then collect them */ - if ((gwPciReadAsserts > 0) || (gwPciWriteAsserts > 0)) { - phr->u.a.dwSerialNumber = - gwPciReadAsserts * 100 + gwPciWriteAsserts; - phr->u.a.wAdapterIndex = 1; /* assert count */ - phr->u.a.wAdapterType = -1; /* "dsp index" */ - strcpy(phr->u.a.szAdapterAssert, "PCI2040 error"); - gwPciReadAsserts = 0; - gwPciWriteAsserts = 0; - phr->wError = 0; + if ((gw_pci_read_asserts > 0) || (gw_pci_write_asserts > 0)) { + phr->u.a.serial_number = + gw_pci_read_asserts * 100 + gw_pci_write_asserts; + phr->u.a.adapter_index = 1; /* assert count */ + phr->u.a.adapter_type = -1; /* "dsp index" */ + strcpy(phr->u.a.sz_adapter_assert, "PCI2040 error"); + gw_pci_read_asserts = 0; + gw_pci_write_asserts = 0; + phr->error = 0; } else #endif - HW_Message(pao, phm, phr); /*get DSP asserts */ + hw_message(pao, phm, phr); /*get DSP asserts */ return; } @@ -742,40 +662,38 @@ static void AdapterGetAsserts( /************************************************************************/ /* LOW-LEVEL */ -static short Hpi6000_AdapterBootLoadDsp( - struct hpi_adapter_obj *pao, - u32 *pdwOsErrorCode -) +static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, + u32 *pos_error_code) { struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; - short nError; - u32 dwTimeout; - u32 dwRead = 0; + short error; + u32 timeout; + u32 read = 0; u32 i = 0; - u32 dwData = 0; + u32 data = 0; u32 j = 0; - u32 dwTestAddr = 0x80000000; - u32 dwTestData = 0x00000001; - u32 dw2040Reset = 0; - u32 dwDspIndex = 0; - u32 dwEndian = 0; - u32 dwAdapterInfo = 0; - u32 dwDelay = 0; + u32 test_addr = 0x80000000; + u32 test_data = 0x00000001; + u32 dw2040_reset = 0; + u32 dsp_index = 0; + u32 endian = 0; + u32 adapter_info = 0; + u32 delay = 0; - struct dsp_code DspCode; - u16 nBootLoadFamily = 0; + struct dsp_code dsp_code; + u16 boot_load_family = 0; /* NOTE don't use wAdapterType in this routine. It is not setup yet */ - switch (pao->Pci.wSubSysDeviceId) { + switch (pao->pci.subsys_device_id) { case 0x5100: case 0x5110: /* ASI5100 revB or higher with C6711D */ case 0x6100: case 0x6200: - nBootLoadFamily = HPI_ADAPTER_FAMILY_ASI(0x6200); + boot_load_family = HPI_ADAPTER_FAMILY_ASI(0x6200); break; case 0x8800: - nBootLoadFamily = HPI_ADAPTER_FAMILY_ASI(0x8800); + boot_load_family = HPI_ADAPTER_FAMILY_ASI(0x8800); break; default: return (HPI6000_ERROR_UNHANDLED_SUBSYS_ID); @@ -784,19 +702,19 @@ static short Hpi6000_AdapterBootLoadDsp( /* reset all DSPs, indicate two DSPs are present * set RST3-=1 to disconnect HAD8 to set DSP in little endian mode */ - dwEndian = 0; - dw2040Reset = 0x0003000F; - iowrite32(dw2040Reset, phw->dw2040_HPICSR + HPI_RESET); + endian = 0; + dw2040_reset = 0x0003000F; + iowrite32(dw2040_reset, phw->dw2040_HPICSR + HPI_RESET); /* read back register to make sure PCI2040 chip is functioning * note that bits 4..15 are read-only and so should always return zero, * even though we wrote 1 to them */ for (i = 0; i < 1000; i++) - dwDelay = ioread32(phw->dw2040_HPICSR + HPI_RESET); - if (dwDelay != dw2040Reset) { - HPI_DEBUG_LOG(ERROR, "INIT_PCI2040 %x %x\n", - dw2040Reset, dwDelay); + delay = ioread32(phw->dw2040_HPICSR + HPI_RESET); + if (delay != dw2040_reset) { + HPI_DEBUG_LOG(ERROR, "INIT_PCI2040 %x %x\n", dw2040_reset, + delay); return (HPI6000_ERROR_INIT_PCI2040); } @@ -810,45 +728,44 @@ static short Hpi6000_AdapterBootLoadDsp( /* isolate DSP HAD8 line from PCI2040 so that * Little endian can be set by pullup */ - dw2040Reset = dw2040Reset & (~(dwEndian << 3)); - iowrite32(dw2040Reset, phw->dw2040_HPICSR + HPI_RESET); + dw2040_reset = dw2040_reset & (~(endian << 3)); + iowrite32(dw2040_reset, phw->dw2040_HPICSR + HPI_RESET); - phw->ado[0].cDspRev = 'B'; /* revB */ - phw->ado[1].cDspRev = 'B'; /* revB */ + phw->ado[0].c_dsp_rev = 'B'; /* revB */ + phw->ado[1].c_dsp_rev = 'B'; /* revB */ /*Take both DSPs out of reset, setting HAD8 to the correct Endian */ - dw2040Reset = dw2040Reset & (~0x00000001); /* start DSP 0 */ - iowrite32(dw2040Reset, phw->dw2040_HPICSR + HPI_RESET); - dw2040Reset = dw2040Reset & (~0x00000002); /* start DSP 1 */ - iowrite32(dw2040Reset, phw->dw2040_HPICSR + HPI_RESET); + dw2040_reset = dw2040_reset & (~0x00000001); /* start DSP 0 */ + iowrite32(dw2040_reset, phw->dw2040_HPICSR + HPI_RESET); + dw2040_reset = dw2040_reset & (~0x00000002); /* start DSP 1 */ + iowrite32(dw2040_reset, phw->dw2040_HPICSR + HPI_RESET); /* set HAD8 back to PCI2040, now that DSP set to little endian mode */ - dw2040Reset = dw2040Reset & (~0x00000008); - iowrite32(dw2040Reset, phw->dw2040_HPICSR + HPI_RESET); + dw2040_reset = dw2040_reset & (~0x00000008); + iowrite32(dw2040_reset, phw->dw2040_HPICSR + HPI_RESET); /*delay to allow DSP to get going */ for (i = 0; i < 100; i++) - dwDelay = ioread32(phw->dw2040_HPICSR + HPI_RESET); + delay = ioread32(phw->dw2040_HPICSR + HPI_RESET); /* loop through all DSPs, downloading DSP code */ - for (dwDspIndex = 0; dwDspIndex < phw->wNumDsp; dwDspIndex++) { - struct dsp_obj *pdo = &phw->ado[dwDspIndex]; + for (dsp_index = 0; dsp_index < phw->num_dsp; dsp_index++) { + struct dsp_obj *pdo = &phw->ado[dsp_index]; /* configure DSP so that we download code into the SRAM */ /* set control reg for little endian, HWOB=1 */ - iowrite32(0x00010001, pdo->prHPIControl); + iowrite32(0x00010001, pdo->prHPI_control); /* test access to the HPI address register (HPIA) */ - dwTestData = 0x00000001; + test_data = 0x00000001; for (j = 0; j < 32; j++) { - iowrite32(dwTestData, pdo->prHPIAddress); - dwData = ioread32(pdo->prHPIAddress); - if (dwData != dwTestData) { - HPI_DEBUG_LOG(ERROR, - "INIT_DSPHPI %x %x %x\n", - dwTestData, dwData, dwDspIndex); + iowrite32(test_data, pdo->prHPI_address); + data = ioread32(pdo->prHPI_address); + if (data != test_data) { + HPI_DEBUG_LOG(ERROR, "INIT_DSPHPI %x %x %x\n", + test_data, data, dsp_index); return (HPI6000_ERROR_INIT_DSPHPI); } - dwTestData = dwTestData << 1; + test_data = test_data << 1; } /* if C6713 the setup PLL to generate 225MHz from 25MHz. @@ -865,30 +782,27 @@ static short Hpi6000_AdapterBootLoadDsp( * HPI, the PLL does not seem to lock, * so we enable the PLL and use the default of x 7 */ - HpiWriteWord(pdo, 0x01B7C100, 0x0000); /* bypass PLL */ + hpi_write_word(pdo, 0x01B7C100, 0x0000); /* bypass PLL */ for (i = 0; i < 100; i++) - dwDelay = - ioread32(phw->dw2040_HPICSR + + delay = ioread32(phw->dw2040_HPICSR + HPI_RESET); /* ** use default of PLL x7 ** */ /* EMIF = 225/3=75MHz */ - HpiWriteWord(pdo, 0x01B7C120, 0x8002); + hpi_write_word(pdo, 0x01B7C120, 0x8002); /* peri = 225/2 */ - HpiWriteWord(pdo, 0x01B7C11C, 0x8001); + hpi_write_word(pdo, 0x01B7C11C, 0x8001); /* cpu = 225/1 */ - HpiWriteWord(pdo, 0x01B7C118, 0x8000); + hpi_write_word(pdo, 0x01B7C118, 0x8000); /* ~200us delay */ for (i = 0; i < 2000; i++) - dwDelay = - ioread32(phw->dw2040_HPICSR + + delay = ioread32(phw->dw2040_HPICSR + HPI_RESET); /* PLL not bypassed */ - HpiWriteWord(pdo, 0x01B7C100, 0x0001); + hpi_write_word(pdo, 0x01B7C100, 0x0001); /* ~200us delay */ for (i = 0; i < 2000; i++) - dwDelay = - ioread32(phw->dw2040_HPICSR + + delay = ioread32(phw->dw2040_HPICSR + HPI_RESET); } @@ -900,21 +814,20 @@ static short Hpi6000_AdapterBootLoadDsp( */ /* test each bit in the 32bit word */ for (i = 0; i < 100; i++) { - dwTestAddr = 0x00000000; - dwTestData = 0x00000001; + test_addr = 0x00000000; + test_data = 0x00000001; for (j = 0; j < 32; j++) { - HpiWriteWord(pdo, dwTestAddr + i, dwTestData); - dwData = HpiReadWord(pdo, dwTestAddr + i); - if (dwData != dwTestData) { + hpi_write_word(pdo, test_addr + i, test_data); + data = hpi_read_word(pdo, test_addr + i); + if (data != test_data) { HPI_DEBUG_LOG(ERROR, "DSP mem %x %x %x %x\n", - dwTestAddr + i, - dwTestData, dwData, - dwDspIndex); + test_addr + i, test_data, + data, dsp_index); return (HPI6000_ERROR_INIT_DSPINTMEM); } - dwTestData = dwTestData << 1; + test_data = test_data << 1; } } @@ -941,7 +854,7 @@ static short Hpi6000_AdapterBootLoadDsp( 11 BUSREQ = 0 BUSREQ output is low 12,13 Reserved = 1 */ - HpiWriteWord(pdo, 0x01800000, 0x34A8); + hpi_write_word(pdo, 0x01800000, 0x34A8); /* EMIF CE0 setup - 2Mx32 Sync DRAM 31..28 Wr setup @@ -954,7 +867,7 @@ static short Hpi6000_AdapterBootLoadDsp( 3 Wr hold MSB 2..0 Rd hold */ - HpiWriteWord(pdo, 0x01800008, 0x00000030); + hpi_write_word(pdo, 0x01800008, 0x00000030); /* EMIF SDRAM Extension 31-21 0 @@ -974,7 +887,7 @@ static short Hpi6000_AdapterBootLoadDsp( */ /* need to use this else DSP code crashes */ - HpiWriteWord(pdo, 0x01800020, 0x001BDF29); + hpi_write_word(pdo, 0x01800020, 0x001BDF29); /* EMIF SDRAM control - set up for a 2Mx32 SDRAM (512x32x4 bank) 31 - - @@ -989,10 +902,10 @@ static short Hpi6000_AdapterBootLoadDsp( 11..0 - - */ /* need to use this else DSP code crashes */ - HpiWriteWord(pdo, 0x01800018, 0x47117000); + hpi_write_word(pdo, 0x01800018, 0x47117000); /* EMIF SDRAM Refresh Timing */ - HpiWriteWord(pdo, 0x0180001C, 0x00000410); + hpi_write_word(pdo, 0x0180001C, 0x00000410); /*MIF CE1 setup - Async peripherals @100MHz bus speed, each cycle is 10ns, @@ -1007,164 +920,161 @@ static short Hpi6000_AdapterBootLoadDsp( 2..0 Rd hold = 1 */ { - u32 dwCE1 = (1L << 28) | (3L << 22) | (1L << 20) | - (1L << 16) | (2L << 14) | (3L << 8) | - (2L << 4) | 1L; - HpiWriteWord(pdo, 0x01800004, dwCE1); + u32 cE1 = + (1L << 28) | (3L << 22) | (1L << 20) | (1L << + 16) | (2L << 14) | (3L << 8) | (2L << 4) | 1L; + hpi_write_word(pdo, 0x01800004, cE1); } /* delay a little to allow SDRAM and DSP to "get going" */ for (i = 0; i < 1000; i++) - dwDelay = ioread32(phw->dw2040_HPICSR + HPI_RESET); + delay = ioread32(phw->dw2040_HPICSR + HPI_RESET); /* test access to SDRAM */ { - dwTestAddr = 0x80000000; - dwTestData = 0x00000001; + test_addr = 0x80000000; + test_data = 0x00000001; /* test each bit in the 32bit word */ for (j = 0; j < 32; j++) { - HpiWriteWord(pdo, dwTestAddr, dwTestData); - dwData = HpiReadWord(pdo, dwTestAddr); - if (dwData != dwTestData) { + hpi_write_word(pdo, test_addr, test_data); + data = hpi_read_word(pdo, test_addr); + if (data != test_data) { HPI_DEBUG_LOG(ERROR, "DSP dram %x %x %x %x\n", - dwTestAddr, - dwTestData, dwData, - dwDspIndex); + test_addr, test_data, data, + dsp_index); return (HPI6000_ERROR_INIT_SDRAM1); } - dwTestData = dwTestData << 1; + test_data = test_data << 1; } /* test every Nth address in the DRAM */ -#define DRAM_SIZE_WORDS 0x200000 /*2Mx32 */ +#define DRAM_SIZE_WORDS 0x200000 /*2_mx32 */ #define DRAM_INC 1024 - dwTestAddr = 0x80000000; - dwTestData = 0x0; + test_addr = 0x80000000; + test_data = 0x0; for (i = 0; i < DRAM_SIZE_WORDS; i = i + DRAM_INC) { - HpiWriteWord(pdo, dwTestAddr + i, dwTestData); - dwTestData++; + hpi_write_word(pdo, test_addr + i, test_data); + test_data++; } - dwTestAddr = 0x80000000; - dwTestData = 0x0; + test_addr = 0x80000000; + test_data = 0x0; for (i = 0; i < DRAM_SIZE_WORDS; i = i + DRAM_INC) { - dwData = HpiReadWord(pdo, dwTestAddr + i); - if (dwData != dwTestData) { + data = hpi_read_word(pdo, test_addr + i); + if (data != test_data) { HPI_DEBUG_LOG(ERROR, "DSP dram %x %x %x %x\n", - dwTestAddr + i, - dwTestData, dwData, - dwDspIndex); + test_addr + i, test_data, + data, dsp_index); return (HPI6000_ERROR_INIT_SDRAM2); } - dwTestData++; + test_data++; } } /* write the DSP code down into the DSPs memory */ /*HpiDspCode_Open(nBootLoadFamily,&DspCode,pdwOsErrorCode); */ - DspCode.psDev = pao->Pci.pOsData; + dsp_code.ps_dev = pao->pci.p_os_data; - nError = HpiDspCode_Open(nBootLoadFamily, &DspCode, - pdwOsErrorCode); + error = hpi_dsp_code_open(boot_load_family, &dsp_code, + pos_error_code); - if (nError) - return (nError); + if (error) + return (error); while (1) { - u32 dwLength; - u32 dwAddress; - u32 dwType; - u32 *pdwCode; + u32 length; + u32 address; + u32 type; + u32 *pcode; - nError = HpiDspCode_ReadWord(&DspCode, &dwLength); - if (nError) + error = hpi_dsp_code_read_word(&dsp_code, &length); + if (error) break; - if (dwLength == 0xFFFFFFFF) + if (length == 0xFFFFFFFF) break; /* end of code */ - nError = HpiDspCode_ReadWord(&DspCode, &dwAddress); - if (nError) + error = hpi_dsp_code_read_word(&dsp_code, &address); + if (error) break; - nError = HpiDspCode_ReadWord(&DspCode, &dwType); - if (nError) + error = hpi_dsp_code_read_word(&dsp_code, &type); + if (error) break; - nError = HpiDspCode_ReadBlock(dwLength, &DspCode, - &pdwCode); - if (nError) + error = hpi_dsp_code_read_block(length, &dsp_code, + &pcode); + if (error) break; - nError = Hpi6000_DspBlockWrite32(pao, - (u16)dwDspIndex, dwAddress, pdwCode, - dwLength); - if (nError) + error = hpi6000_dsp_block_write32(pao, (u16)dsp_index, + address, pcode, length); + if (error) break; } - if (nError) { - HpiDspCode_Close(&DspCode); - return (nError); + if (error) { + hpi_dsp_code_close(&dsp_code); + return (error); } /* verify that code was written correctly */ /* this time through, assume no errors in DSP code file/array */ - HpiDspCode_Rewind(&DspCode); + hpi_dsp_code_rewind(&dsp_code); while (1) { - u32 dwLength; - u32 dwAddress; - u32 dwType; - u32 *pdwCode; + u32 length; + u32 address; + u32 type; + u32 *pcode; - HpiDspCode_ReadWord(&DspCode, &dwLength); - if (dwLength == 0xFFFFFFFF) + hpi_dsp_code_read_word(&dsp_code, &length); + if (length == 0xFFFFFFFF) break; /* end of code */ - HpiDspCode_ReadWord(&DspCode, &dwAddress); - HpiDspCode_ReadWord(&DspCode, &dwType); - HpiDspCode_ReadBlock(dwLength, &DspCode, &pdwCode); + hpi_dsp_code_read_word(&dsp_code, &address); + hpi_dsp_code_read_word(&dsp_code, &type); + hpi_dsp_code_read_block(length, &dsp_code, &pcode); - for (i = 0; i < dwLength; i++) { - dwData = HpiReadWord(pdo, dwAddress); - if (dwData != *pdwCode) { - nError = HPI6000_ERROR_INIT_VERIFY; + for (i = 0; i < length; i++) { + data = hpi_read_word(pdo, address); + if (data != *pcode) { + error = HPI6000_ERROR_INIT_VERIFY; HPI_DEBUG_LOG(ERROR, "DSP verify %x %x %x %x\n", - dwAddress, *pdwCode, - dwData, dwDspIndex); + address, *pcode, data, + dsp_index); break; } - pdwCode++; - dwAddress += 4; + pcode++; + address += 4; } - if (nError) + if (error) break; } - HpiDspCode_Close(&DspCode); - if (nError) - return (nError); + hpi_dsp_code_close(&dsp_code); + if (error) + return (error); /* zero out the hostmailbox */ { - u32 dwAddress = HPI_HIF_ADDR(dwHostCmd); + u32 address = HPI_HIF_ADDR(host_cmd); for (i = 0; i < 4; i++) { - HpiWriteWord(pdo, dwAddress, 0); - dwAddress += 4; + hpi_write_word(pdo, address, 0); + address += 4; } } /* write the DSP number into the hostmailbox */ /* structure before starting the DSP */ - HpiWriteWord(pdo, HPI_HIF_ADDR(dwDspNumber), dwDspIndex); + hpi_write_word(pdo, HPI_HIF_ADDR(dsp_number), dsp_index); /* write the DSP adapter Info into the */ /* hostmailbox before starting the DSP */ - if (dwDspIndex > 0) - HpiWriteWord(pdo, HPI_HIF_ADDR(dwAdapterInfo), - dwAdapterInfo); + if (dsp_index > 0) + hpi_write_word(pdo, HPI_HIF_ADDR(adapter_info), + adapter_info); /* step 3. Start code by sending interrupt */ - iowrite32(0x00030003, pdo->prHPIControl); + iowrite32(0x00030003, pdo->prHPI_control); for (i = 0; i < 10000; i++) - dwDelay = ioread32(phw->dw2040_HPICSR + HPI_RESET); + delay = ioread32(phw->dw2040_HPICSR + HPI_RESET); /* wait for a non-zero value in hostcmd - * indicating initialization is complete @@ -1173,16 +1083,16 @@ static short Hpi6000_AdapterBootLoadDsp( * Was 200000. Increased to 2000000 for ASI8801 so we * don't get 938 errors. */ - dwTimeout = 2000000; - while (dwTimeout) { + timeout = 2000000; + while (timeout) { do { - dwRead = HpiReadWord(pdo, - HPI_HIF_ADDR(dwHostCmd)); - } while (--dwTimeout - && Hpi6000_Check_PCI2040_ErrorFlag(pao, + read = hpi_read_word(pdo, + HPI_HIF_ADDR(host_cmd)); + } while (--timeout + && hpi6000_check_PCI2040_error_flag(pao, H6READ)); - if (dwRead) + if (read) break; /* The following is a workaround for bug #94: * Bluescreen on install and subsequent boots on a @@ -1191,353 +1101,325 @@ static short Hpi6000_AdapterBootLoadDsp( * locks up with a bluescreen (NOT GPF or pagefault). */ else - HpiOs_DelayMicroSeconds(1000); + hpios_delay_micro_seconds(1000); } - if (dwTimeout == 0) + if (timeout == 0) return (HPI6000_ERROR_INIT_NOACK); /* read the DSP adapter Info from the */ /* hostmailbox structure after starting the DSP */ - if (dwDspIndex == 0) { + if (dsp_index == 0) { /*u32 dwTestData=0; */ - u32 dwMask = 0; + u32 mask = 0; - dwAdapterInfo = - HpiReadWord(pdo, HPI_HIF_ADDR(dwAdapterInfo)); + adapter_info = + hpi_read_word(pdo, + HPI_HIF_ADDR(adapter_info)); if (HPI_ADAPTER_FAMILY_ASI (HPI_HIF_ADAPTER_INFO_EXTRACT_ADAPTER - (dwAdapterInfo)) == + (adapter_info)) == HPI_ADAPTER_FAMILY_ASI(0x6200)) /* all 6200 cards have this many DSPs */ - phw->wNumDsp = 2; + phw->num_dsp = 2; /* test that the PLD is programmed */ /* and we can read/write 24bits */ #define PLD_BASE_ADDRESS 0x90000000L /*for ASI6100/6200/8800 */ - switch (nBootLoadFamily) { + switch (boot_load_family) { case HPI_ADAPTER_FAMILY_ASI(0x6200): /* ASI6100/6200 has 24bit path to FPGA */ - dwMask = 0xFFFFFF00L; + mask = 0xFFFFFF00L; /* ASI5100 uses AX6 code, */ /* but has no PLD r/w register to test */ - if (HPI_ADAPTER_FAMILY_ASI(pao->Pci. - wSubSysDeviceId) == + if (HPI_ADAPTER_FAMILY_ASI(pao->pci. + subsys_device_id) == HPI_ADAPTER_FAMILY_ASI(0x5100)) - dwMask = 0x00000000L; + mask = 0x00000000L; break; case HPI_ADAPTER_FAMILY_ASI(0x8800): /* ASI8800 has 16bit path to FPGA */ - dwMask = 0xFFFF0000L; + mask = 0xFFFF0000L; break; } - dwTestData = 0xAAAAAA00L & dwMask; + test_data = 0xAAAAAA00L & mask; /* write to 24 bit Debug register (D31-D8) */ - HpiWriteWord(pdo, PLD_BASE_ADDRESS + 4L, dwTestData); - dwRead = HpiReadWord(pdo, - PLD_BASE_ADDRESS + 4L) & dwMask; - if (dwRead != dwTestData) { - HPI_DEBUG_LOG(ERROR, - "PLD %x %x\n", dwTestData, dwRead); + hpi_write_word(pdo, PLD_BASE_ADDRESS + 4L, test_data); + read = hpi_read_word(pdo, + PLD_BASE_ADDRESS + 4L) & mask; + if (read != test_data) { + HPI_DEBUG_LOG(ERROR, "PLD %x %x\n", test_data, + read); return (HPI6000_ERROR_INIT_PLDTEST1); } - dwTestData = 0x55555500L & dwMask; - HpiWriteWord(pdo, PLD_BASE_ADDRESS + 4L, dwTestData); - dwRead = HpiReadWord(pdo, - PLD_BASE_ADDRESS + 4L) & dwMask; - if (dwRead != dwTestData) { - HPI_DEBUG_LOG(ERROR, - "PLD %x %x\n", dwTestData, dwRead); + test_data = 0x55555500L & mask; + hpi_write_word(pdo, PLD_BASE_ADDRESS + 4L, test_data); + read = hpi_read_word(pdo, + PLD_BASE_ADDRESS + 4L) & mask; + if (read != test_data) { + HPI_DEBUG_LOG(ERROR, "PLD %x %x\n", test_data, + read); return (HPI6000_ERROR_INIT_PLDTEST2); } } - } /* for wNumDSP */ + } /* for numDSP */ return 0; } #define PCI_TIMEOUT 100 -static int HpiSetAddress( - struct dsp_obj *pdo, - u32 dwAddress -) +static int hpi_set_address(struct dsp_obj *pdo, u32 address) { - u32 dwTimeout = PCI_TIMEOUT; + u32 timeout = PCI_TIMEOUT; do { - iowrite32(dwAddress, pdo->prHPIAddress); + iowrite32(address, pdo->prHPI_address); } - while (Hpi6000_Check_PCI2040_ErrorFlag(pdo->paParentAdapter, H6WRITE) - && --dwTimeout); + while (hpi6000_check_PCI2040_error_flag(pdo->pa_parent_adapter, + H6WRITE) + && --timeout); - if (dwTimeout) + if (timeout) return 0; return 1; } /* write one word to the HPI port */ -static void HpiWriteWord( - struct dsp_obj *pdo, - u32 dwAddress, - u32 dwData -) +static void hpi_write_word(struct dsp_obj *pdo, u32 address, u32 data) { - if (HpiSetAddress(pdo, dwAddress)) + if (hpi_set_address(pdo, address)) return; - iowrite32(dwData, pdo->prHPIData); + iowrite32(data, pdo->prHPI_data); } /* read one word from the HPI port */ -static u32 HpiReadWord( - struct dsp_obj *pdo, - u32 dwAddress -) +static u32 hpi_read_word(struct dsp_obj *pdo, u32 address) { - u32 dwData = 0; + u32 data = 0; - if (HpiSetAddress(pdo, dwAddress)) - return 0; /*? No way to return error */ + if (hpi_set_address(pdo, address)) + return 0; /*? no way to return error */ /* take care of errata in revB DSP (2.0.1) */ - dwData = ioread32(pdo->prHPIData); - return (dwData); + data = ioread32(pdo->prHPI_data); + return (data); } /* write a block of 32bit words to the DSP HPI port using auto-inc mode */ -static void HpiWriteBlock( - struct dsp_obj *pdo, - u32 dwAddress, - u32 *pdwData, - u32 dwLength -) +static void hpi_write_block(struct dsp_obj *pdo, u32 address, u32 *pdata, + u32 length) { - u16 wLength = dwLength - 1; + u16 length16 = length - 1; - if (dwLength == 0) + if (length == 0) return; - if (HpiSetAddress(pdo, dwAddress)) + if (hpi_set_address(pdo, address)) return; - iowrite32_rep(pdo->prHPIDataAutoInc, pdwData, wLength); + iowrite32_rep(pdo->prHPI_data_auto_inc, pdata, length16); /* take care of errata in revB DSP (2.0.1) */ /* must end with non auto-inc */ - iowrite32(*(pdwData + dwLength - 1), pdo->prHPIData); + iowrite32(*(pdata + length - 1), pdo->prHPI_data); } /** read a block of 32bit words from the DSP HPI port using auto-inc mode */ -static void HpiReadBlock( - struct dsp_obj *pdo, - u32 dwAddress, - u32 *pdwData, - u32 dwLength -) +static void hpi_read_block(struct dsp_obj *pdo, u32 address, u32 *pdata, + u32 length) { - u16 wLength = dwLength - 1; + u16 length16 = length - 1; - if (dwLength == 0) + if (length == 0) return; - if (HpiSetAddress(pdo, dwAddress)) + if (hpi_set_address(pdo, address)) return; - ioread32_rep(pdo->prHPIDataAutoInc, pdwData, wLength); + ioread32_rep(pdo->prHPI_data_auto_inc, pdata, length16); /* take care of errata in revB DSP (2.0.1) */ /* must end with non auto-inc */ - *(pdwData + dwLength - 1) = ioread32(pdo->prHPIData); + *(pdata + length - 1) = ioread32(pdo->prHPI_data); } -static u16 Hpi6000_DspBlockWrite32( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - u32 dwHpiAddress, - u32 *dwSource, - u32 dwCount -) +static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao, + u16 dsp_index, u32 hpi_address, u32 *source, u32 count) { struct dsp_obj *pdo = - &(*(struct hpi_hw_obj *)pao->priv).ado[wDspIndex]; - u32 dwTimeOut = PCI_TIMEOUT; - int nC6711BurstSize = 128; - u32 dwLocalHpiAddress = dwHpiAddress; - int wLocalCount = dwCount; - int wXferSize; - u32 *pdwData = dwSource; - - while (wLocalCount) { - if (wLocalCount > nC6711BurstSize) - wXferSize = nC6711BurstSize; + &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; + u32 time_out = PCI_TIMEOUT; + int c6711_burst_size = 128; + u32 local_hpi_address = hpi_address; + int local_count = count; + int xfer_size; + u32 *pdata = source; + + while (local_count) { + if (local_count > c6711_burst_size) + xfer_size = c6711_burst_size; else - wXferSize = wLocalCount; + xfer_size = local_count; - dwTimeOut = PCI_TIMEOUT; + time_out = PCI_TIMEOUT; do { - HpiWriteBlock(pdo, dwLocalHpiAddress, pdwData, - wXferSize); - } while (Hpi6000_Check_PCI2040_ErrorFlag(pao, H6WRITE) - && --dwTimeOut); + hpi_write_block(pdo, local_hpi_address, pdata, + xfer_size); + } while (hpi6000_check_PCI2040_error_flag(pao, H6WRITE) + && --time_out); - if (!dwTimeOut) + if (!time_out) break; - pdwData += wXferSize; - dwLocalHpiAddress += sizeof(u32) * wXferSize; - wLocalCount -= wXferSize; + pdata += xfer_size; + local_hpi_address += sizeof(u32) * xfer_size; + local_count -= xfer_size; } - if (dwTimeOut) + if (time_out) return 0; else return 1; } -static u16 Hpi6000_DspBlockRead32( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - u32 dwHpiAddress, - u32 *dwDest, - u32 dwCount -) +static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao, + u16 dsp_index, u32 hpi_address, u32 *dest, u32 count) { struct dsp_obj *pdo = - &(*(struct hpi_hw_obj *)pao->priv).ado[wDspIndex]; - u32 dwTimeOut = PCI_TIMEOUT; - int nC6711BurstSize = 16; - u32 dwLocalHpiAddress = dwHpiAddress; - int wLocalCount = dwCount; - int wXferSize; - u32 *pdwData = dwDest; - u32 dwLoopCount = 0; - - while (wLocalCount) { - if (wLocalCount > nC6711BurstSize) - wXferSize = nC6711BurstSize; + &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; + u32 time_out = PCI_TIMEOUT; + int c6711_burst_size = 16; + u32 local_hpi_address = hpi_address; + int local_count = count; + int xfer_size; + u32 *pdata = dest; + u32 loop_count = 0; + + while (local_count) { + if (local_count > c6711_burst_size) + xfer_size = c6711_burst_size; else - wXferSize = wLocalCount; + xfer_size = local_count; - dwTimeOut = PCI_TIMEOUT; + time_out = PCI_TIMEOUT; do { - HpiReadBlock(pdo, dwLocalHpiAddress, pdwData, - wXferSize); + hpi_read_block(pdo, local_hpi_address, pdata, + xfer_size); } - while (Hpi6000_Check_PCI2040_ErrorFlag(pao, H6READ) - && --dwTimeOut); - if (!dwTimeOut) + while (hpi6000_check_PCI2040_error_flag(pao, H6READ) + && --time_out); + if (!time_out) break; - pdwData += wXferSize; - dwLocalHpiAddress += sizeof(u32) * wXferSize; - wLocalCount -= wXferSize; - dwLoopCount++; + pdata += xfer_size; + local_hpi_address += sizeof(u32) * xfer_size; + local_count -= xfer_size; + loop_count++; } - if (dwTimeOut) + if (time_out) return 0; else return 1; } -static short Hpi6000_MessageResponseSequence( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - struct hpi_message *phm, - struct hpi_response *phr -) +static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao, + u16 dsp_index, struct hpi_message *phm, struct hpi_response *phr) { struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; - struct dsp_obj *pdo = &phw->ado[wDspIndex]; - u32 dwTimeout; - u16 wAck; - u32 dwAddress; - u32 dwLength; - u32 *pData; - u16 wError = 0; + struct dsp_obj *pdo = &phw->ado[dsp_index]; + u32 timeout; + u16 ack; + u32 address; + u32 length; + u32 *p_data; + u16 error = 0; /* does the DSP we are referencing exist? */ - if (wDspIndex >= phw->wNumDsp) + if (dsp_index >= phw->num_dsp) return HPI6000_ERROR_MSG_INVALID_DSP_INDEX; - wAck = Hpi6000_WaitDspAck(pao, wDspIndex, HPI_HIF_IDLE); - if (wAck & HPI_HIF_ERROR_MASK) { - pao->wDspCrashed++; + ack = hpi6000_wait_dsp_ack(pao, dsp_index, HPI_HIF_IDLE); + if (ack & HPI_HIF_ERROR_MASK) { + pao->dsp_crashed++; return HPI6000_ERROR_MSG_RESP_IDLE_TIMEOUT; } - pao->wDspCrashed = 0; + pao->dsp_crashed = 0; /* send the message */ /* get the address and size */ - if (phw->dwMessageBufferAddressOnDSP == 0) { - dwTimeout = TIMEOUT; + if (phw->message_buffer_address_on_dsp == 0) { + timeout = TIMEOUT; do { - dwAddress = HpiReadWord(pdo, - HPI_HIF_ADDR(dwMessageBufferAddress)); - phw->dwMessageBufferAddressOnDSP = dwAddress; + address = + hpi_read_word(pdo, + HPI_HIF_ADDR(message_buffer_address)); + phw->message_buffer_address_on_dsp = address; } - while (Hpi6000_Check_PCI2040_ErrorFlag(pao, H6READ) - && --dwTimeout); - if (!dwTimeout) + while (hpi6000_check_PCI2040_error_flag(pao, H6READ) + && --timeout); + if (!timeout) return HPI6000_ERROR_MSG_GET_ADR; } else - dwAddress = phw->dwMessageBufferAddressOnDSP; + address = phw->message_buffer_address_on_dsp; /* dwLength = sizeof(struct hpi_message); */ - dwLength = phm->wSize; + length = phm->size; /* send it */ - pData = (u32 *)phm; - if (Hpi6000_DspBlockWrite32(pao, wDspIndex, dwAddress, - pData, (u16)dwLength / 4)) + p_data = (u32 *)phm; + if (hpi6000_dsp_block_write32(pao, dsp_index, address, p_data, + (u16)length / 4)) return HPI6000_ERROR_MSG_RESP_BLOCKWRITE32; - if (Hpi6000_SendHostCommand(pao, wDspIndex, HPI_HIF_GET_RESP)) + if (hpi6000_send_host_command(pao, dsp_index, HPI_HIF_GET_RESP)) return HPI6000_ERROR_MSG_RESP_GETRESPCMD; - Hpi6000_SendDspInterrupt(pdo); + hpi6000_send_dsp_interrupt(pdo); - wAck = Hpi6000_WaitDspAck(pao, wDspIndex, HPI_HIF_GET_RESP); - if (wAck & HPI_HIF_ERROR_MASK) + ack = hpi6000_wait_dsp_ack(pao, dsp_index, HPI_HIF_GET_RESP); + if (ack & HPI_HIF_ERROR_MASK) return HPI6000_ERROR_MSG_RESP_GET_RESP_ACK; /* get the address and size */ - if (phw->dwResponseBufferAddressOnDSP == 0) { - dwTimeout = TIMEOUT; + if (phw->response_buffer_address_on_dsp == 0) { + timeout = TIMEOUT; do { - dwAddress = HpiReadWord(pdo, - HPI_HIF_ADDR(dwResponseBufferAddress)); - } while (Hpi6000_Check_PCI2040_ErrorFlag(pao, H6READ) - && --dwTimeout); - phw->dwResponseBufferAddressOnDSP = dwAddress; - - if (!dwTimeout) + address = + hpi_read_word(pdo, + HPI_HIF_ADDR(response_buffer_address)); + } while (hpi6000_check_PCI2040_error_flag(pao, H6READ) + && --timeout); + phw->response_buffer_address_on_dsp = address; + + if (!timeout) return HPI6000_ERROR_RESP_GET_ADR; } else - dwAddress = phw->dwResponseBufferAddressOnDSP; + address = phw->response_buffer_address_on_dsp; /* read the length of the response back from the DSP */ - dwTimeout = TIMEOUT; + timeout = TIMEOUT; do { - dwLength = HpiReadWord(pdo, HPI_HIF_ADDR(dwLength)); + length = hpi_read_word(pdo, HPI_HIF_ADDR(length)); } - while (Hpi6000_Check_PCI2040_ErrorFlag(pao, H6READ) && --dwTimeout); - if (!dwTimeout) - dwLength = sizeof(struct hpi_response); + while (hpi6000_check_PCI2040_error_flag(pao, H6READ) && --timeout); + if (!timeout) + length = sizeof(struct hpi_response); /* get it */ - pData = (u32 *)phr; - if (Hpi6000_DspBlockRead32 - (pao, wDspIndex, dwAddress, pData, (u16)dwLength / 4)) + p_data = (u32 *)phr; + if (hpi6000_dsp_block_read32(pao, dsp_index, address, p_data, + (u16)length / 4)) return HPI6000_ERROR_MSG_RESP_BLOCKREAD32; /* set i/f back to idle */ - if (Hpi6000_SendHostCommand(pao, wDspIndex, HPI_HIF_IDLE)) + if (hpi6000_send_host_command(pao, dsp_index, HPI_HIF_IDLE)) return HPI6000_ERROR_MSG_RESP_IDLECMD; - Hpi6000_SendDspInterrupt(pdo); + hpi6000_send_dsp_interrupt(pdo); - wError = HpiValidateResponse(phm, phr); - return wError; + error = hpi_validate_response(phm, phr); + return error; } /* have to set up the below defines to match stuff in the MAP file */ @@ -1549,71 +1431,64 @@ static short Hpi6000_MessageResponseSequence( #define QUEUE_START (HPI_HIF_BASE+0x88) #define QUEUE_SIZE 0x8000 -static short Hpi6000_SendData_CheckAdr( - u32 dwAddress, - u32 dwLengthInDwords -) +static short hpi6000_send_data_check_adr(u32 address, u32 length_in_dwords) { /*#define CHECKING // comment this line in to enable checking */ #ifdef CHECKING - if (dwAddress < (u32)MSG_ADDRESS) + if (address < (u32)MSG_ADDRESS) return 0; - if (dwAddress > (u32)(QUEUE_START + QUEUE_SIZE)) + if (address > (u32)(QUEUE_START + QUEUE_SIZE)) return 0; - if ((dwAddress + (dwLengthInDwords << 2)) > + if ((address + (length_in_dwords << 2)) > (u32)(QUEUE_START + QUEUE_SIZE)) return 0; #else - (void)dwAddress; - (void)dwLengthInDwords; + (void)address; + (void)length_in_dwords; return 1; #endif } -static short Hpi6000_SendData( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - struct hpi_message *phm, - struct hpi_response *phr -) +static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index, + struct hpi_message *phm, struct hpi_response *phr) { struct dsp_obj *pdo = - &(*(struct hpi_hw_obj *)pao->priv).ado[wDspIndex]; - u32 dwDataSent = 0; - u16 wAck; - u32 dwLength, dwAddress; - u32 *pData = (u32 *)phm->u.d.u.Data.pbData; - u16 wTimeOut = 8; + &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; + u32 data_sent = 0; + u16 ack; + u32 length, address; + u32 *p_data = (u32 *)phm->u.d.u.data.pb_data; + u16 time_out = 8; (void)phr; /* round dwDataSize down to nearest 4 bytes */ - while ((dwDataSent < (phm->u.d.u.Data.dwDataSize & ~3L)) - && --wTimeOut) { - wAck = Hpi6000_WaitDspAck(pao, wDspIndex, HPI_HIF_IDLE); - if (wAck & HPI_HIF_ERROR_MASK) + while ((data_sent < (phm->u.d.u.data.data_size & ~3L)) + && --time_out) { + ack = hpi6000_wait_dsp_ack(pao, dsp_index, HPI_HIF_IDLE); + if (ack & HPI_HIF_ERROR_MASK) return HPI6000_ERROR_SEND_DATA_IDLE_TIMEOUT; - if (Hpi6000_SendHostCommand - (pao, wDspIndex, HPI_HIF_SEND_DATA)) + if (hpi6000_send_host_command(pao, dsp_index, + HPI_HIF_SEND_DATA)) return HPI6000_ERROR_SEND_DATA_CMD; - Hpi6000_SendDspInterrupt(pdo); + hpi6000_send_dsp_interrupt(pdo); - wAck = Hpi6000_WaitDspAck(pao, wDspIndex, HPI_HIF_SEND_DATA); + ack = hpi6000_wait_dsp_ack(pao, dsp_index, HPI_HIF_SEND_DATA); - if (wAck & HPI_HIF_ERROR_MASK) + if (ack & HPI_HIF_ERROR_MASK) return HPI6000_ERROR_SEND_DATA_ACK; do { /* get the address and size */ - dwAddress = HpiReadWord(pdo, HPI_HIF_ADDR(dwAddress)); + address = hpi_read_word(pdo, HPI_HIF_ADDR(address)); /* DSP returns number of DWORDS */ - dwLength = HpiReadWord(pdo, HPI_HIF_ADDR(dwLength)); + length = hpi_read_word(pdo, HPI_HIF_ADDR(length)); } - while (Hpi6000_Check_PCI2040_ErrorFlag(pao, H6READ)); + while (hpi6000_check_PCI2040_error_flag(pao, H6READ)); - if (!Hpi6000_SendData_CheckAdr(dwAddress, dwLength)) + if (!hpi6000_send_data_check_adr(address, length)) return HPI6000_ERROR_SEND_DATA_ADR; /* send the data. break data into 512 DWORD blocks (2K bytes) @@ -1622,269 +1497,254 @@ static short Hpi6000_SendData( */ { - u32 dwLen = dwLength; - u32 dwBlkLen = 512; - while (dwLen) { - if (dwLen < dwBlkLen) - dwBlkLen = dwLen; - if (Hpi6000_DspBlockWrite32(pao, wDspIndex, - dwAddress, pData, dwBlkLen)) + u32 len = length; + u32 blk_len = 512; + while (len) { + if (len < blk_len) + blk_len = len; + if (hpi6000_dsp_block_write32(pao, dsp_index, + address, p_data, blk_len)) return HPI6000_ERROR_SEND_DATA_WRITE; - dwAddress += dwBlkLen * 4; - pData += dwBlkLen; - dwLen -= dwBlkLen; + address += blk_len * 4; + p_data += blk_len; + len -= blk_len; } } - if (Hpi6000_SendHostCommand(pao, wDspIndex, HPI_HIF_IDLE)) + if (hpi6000_send_host_command(pao, dsp_index, HPI_HIF_IDLE)) return HPI6000_ERROR_SEND_DATA_IDLECMD; - Hpi6000_SendDspInterrupt(pdo); + hpi6000_send_dsp_interrupt(pdo); - dwDataSent += dwLength * 4; + data_sent += length * 4; } - if (!wTimeOut) + if (!time_out) return HPI6000_ERROR_SEND_DATA_TIMEOUT; return 0; } -static short Hpi6000_GetData( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - struct hpi_message *phm, - struct hpi_response *phr -) +static short hpi6000_get_data(struct hpi_adapter_obj *pao, u16 dsp_index, + struct hpi_message *phm, struct hpi_response *phr) { struct dsp_obj *pdo = - &(*(struct hpi_hw_obj *)pao->priv).ado[wDspIndex]; - u32 dwDataGot = 0; - u16 wAck; - u32 dwLength, dwAddress; - u32 *pData = (u32 *)phm->u.d.u.Data.pbData; + &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; + u32 data_got = 0; + u16 ack; + u32 length, address; + u32 *p_data = (u32 *)phm->u.d.u.data.pb_data; (void)phr; /* this parameter not used! */ /* round dwDataSize down to nearest 4 bytes */ - while (dwDataGot < (phm->u.d.u.Data.dwDataSize & ~3L)) { - wAck = Hpi6000_WaitDspAck(pao, wDspIndex, HPI_HIF_IDLE); - if (wAck & HPI_HIF_ERROR_MASK) + while (data_got < (phm->u.d.u.data.data_size & ~3L)) { + ack = hpi6000_wait_dsp_ack(pao, dsp_index, HPI_HIF_IDLE); + if (ack & HPI_HIF_ERROR_MASK) return HPI6000_ERROR_GET_DATA_IDLE_TIMEOUT; - if (Hpi6000_SendHostCommand(pao, wDspIndex, HPI_HIF_GET_DATA)) + if (hpi6000_send_host_command(pao, dsp_index, + HPI_HIF_GET_DATA)) return HPI6000_ERROR_GET_DATA_CMD; - Hpi6000_SendDspInterrupt(pdo); + hpi6000_send_dsp_interrupt(pdo); - wAck = Hpi6000_WaitDspAck(pao, wDspIndex, HPI_HIF_GET_DATA); + ack = hpi6000_wait_dsp_ack(pao, dsp_index, HPI_HIF_GET_DATA); - if (wAck & HPI_HIF_ERROR_MASK) + if (ack & HPI_HIF_ERROR_MASK) return HPI6000_ERROR_GET_DATA_ACK; /* get the address and size */ do { - dwAddress = HpiReadWord(pdo, HPI_HIF_ADDR(dwAddress)); - dwLength = HpiReadWord(pdo, HPI_HIF_ADDR(dwLength)); + address = hpi_read_word(pdo, HPI_HIF_ADDR(address)); + length = hpi_read_word(pdo, HPI_HIF_ADDR(length)); } - while (Hpi6000_Check_PCI2040_ErrorFlag(pao, H6READ)); + while (hpi6000_check_PCI2040_error_flag(pao, H6READ)); /* read the data */ { - u32 dwLen = dwLength; - u32 dwBlkLen = 512; - while (dwLen) { - if (dwLen < dwBlkLen) - dwBlkLen = dwLen; - if (Hpi6000_DspBlockRead32(pao, wDspIndex, - dwAddress, pData, dwBlkLen)) + u32 len = length; + u32 blk_len = 512; + while (len) { + if (len < blk_len) + blk_len = len; + if (hpi6000_dsp_block_read32(pao, dsp_index, + address, p_data, blk_len)) return HPI6000_ERROR_GET_DATA_READ; - dwAddress += dwBlkLen * 4; - pData += dwBlkLen; - dwLen -= dwBlkLen; + address += blk_len * 4; + p_data += blk_len; + len -= blk_len; } } - if (Hpi6000_SendHostCommand(pao, wDspIndex, HPI_HIF_IDLE)) + if (hpi6000_send_host_command(pao, dsp_index, HPI_HIF_IDLE)) return HPI6000_ERROR_GET_DATA_IDLECMD; - Hpi6000_SendDspInterrupt(pdo); + hpi6000_send_dsp_interrupt(pdo); - dwDataGot += dwLength * 4; + data_got += length * 4; } return 0; } -static void Hpi6000_SendDspInterrupt( - struct dsp_obj *pdo -) +static void hpi6000_send_dsp_interrupt(struct dsp_obj *pdo) { - iowrite32(0x00030003, pdo->prHPIControl); /* DSPINT */ + iowrite32(0x00030003, pdo->prHPI_control); /* DSPINT */ } -static short Hpi6000_SendHostCommand( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - u32 dwHostCmd -) +static short hpi6000_send_host_command(struct hpi_adapter_obj *pao, + u16 dsp_index, u32 host_cmd) { struct dsp_obj *pdo = - &(*(struct hpi_hw_obj *)pao->priv).ado[wDspIndex]; - u32 dwTimeout = TIMEOUT; + &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; + u32 timeout = TIMEOUT; /* set command */ do { - HpiWriteWord(pdo, HPI_HIF_ADDR(dwHostCmd), dwHostCmd); + hpi_write_word(pdo, HPI_HIF_ADDR(host_cmd), host_cmd); /* flush the FIFO */ - HpiSetAddress(pdo, HPI_HIF_ADDR(dwHostCmd)); + hpi_set_address(pdo, HPI_HIF_ADDR(host_cmd)); } - while (Hpi6000_Check_PCI2040_ErrorFlag(pao, H6WRITE) && --dwTimeout); + while (hpi6000_check_PCI2040_error_flag(pao, H6WRITE) && --timeout); /* reset the interrupt bit */ - iowrite32(0x00040004, pdo->prHPIControl); + iowrite32(0x00040004, pdo->prHPI_control); - if (dwTimeout) + if (timeout) return 0; else return 1; } /* if the PCI2040 has recorded an HPI timeout, reset the error and return 1 */ -static short Hpi6000_Check_PCI2040_ErrorFlag( - struct hpi_adapter_obj *pao, - u16 nReadOrWrite -) +static short hpi6000_check_PCI2040_error_flag(struct hpi_adapter_obj *pao, + u16 read_or_write) { - u32 dwHPIError; + u32 hPI_error; struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; /* read the error bits from the PCI2040 */ - dwHPIError = ioread32(phw->dw2040_HPICSR + HPI_ERROR_REPORT); - if (dwHPIError) { + hPI_error = ioread32(phw->dw2040_HPICSR + HPI_ERROR_REPORT); + if (hPI_error) { /* reset the error flag */ iowrite32(0L, phw->dw2040_HPICSR + HPI_ERROR_REPORT); - phw->dwPCI2040HPIErrorCount++; - if (nReadOrWrite == 1) - gwPciReadAsserts++; /************* inc global */ + phw->pCI2040HPI_error_count++; + if (read_or_write == 1) + gw_pci_read_asserts++; /************* inc global */ else - gwPciWriteAsserts++; + gw_pci_write_asserts++; return 1; } else return 0; } -static short Hpi6000_WaitDspAck( - struct hpi_adapter_obj *pao, - u16 wDspIndex, - u32 dwAckValue -) +static short hpi6000_wait_dsp_ack(struct hpi_adapter_obj *pao, u16 dsp_index, + u32 ack_value) { struct dsp_obj *pdo = - &(*(struct hpi_hw_obj *)pao->priv).ado[wDspIndex]; - u32 dwAck = 0L; - u32 dwTimeout; - u32 dwHPIC = 0L; + &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; + u32 ack = 0L; + u32 timeout; + u32 hPIC = 0L; /* wait for host interrupt to signal ack is ready */ - dwTimeout = TIMEOUT; - while (--dwTimeout) { - dwHPIC = ioread32(pdo->prHPIControl); - if (dwHPIC & 0x04) /* 0x04 = HINT from DSP */ + timeout = TIMEOUT; + while (--timeout) { + hPIC = ioread32(pdo->prHPI_control); + if (hPIC & 0x04) /* 0x04 = HINT from DSP */ break; } - if (dwTimeout == 0) + if (timeout == 0) return HPI_HIF_ERROR_MASK; /* wait for dwAckValue */ - dwTimeout = TIMEOUT; - while (--dwTimeout) { + timeout = TIMEOUT; + while (--timeout) { /* read the ack mailbox */ - dwAck = HpiReadWord(pdo, HPI_HIF_ADDR(dwDspAck)); - if (dwAck == dwAckValue) + ack = hpi_read_word(pdo, HPI_HIF_ADDR(dsp_ack)); + if (ack == ack_value) break; - if ((dwAck & HPI_HIF_ERROR_MASK) & - !Hpi6000_Check_PCI2040_ErrorFlag(pao, H6READ)) + if ((ack & HPI_HIF_ERROR_MASK) & + !hpi6000_check_PCI2040_error_flag(pao, H6READ)) break; /*for (i=0;i<1000;i++) */ /* dwPause=i+1; */ } - if (dwAck & HPI_HIF_ERROR_MASK) + if (ack & HPI_HIF_ERROR_MASK) /* indicates bad read from DSP - typically 0xffffff is read for some reason */ - dwAck = HPI_HIF_ERROR_MASK; + ack = HPI_HIF_ERROR_MASK; - if (dwTimeout == 0) - dwAck = HPI_HIF_ERROR_MASK; - return (short)dwAck; + if (timeout == 0) + ack = HPI_HIF_ERROR_MASK; + return (short)ack; } -static short Hpi6000_UpdateControlCache( - struct hpi_adapter_obj *pao, - struct hpi_message *phm -) +static short hpi6000_update_control_cache(struct hpi_adapter_obj *pao, + struct hpi_message *phm) { - const u16 wDspIndex = 0; + const u16 dsp_index = 0; struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; - struct dsp_obj *pdo = &phw->ado[wDspIndex]; - u32 dwTimeout; - u32 dwCacheDirtyFlag; + struct dsp_obj *pdo = &phw->ado[dsp_index]; + u32 timeout; + u32 cache_dirty_flag; u16 err; - HpiOs_Dsplock_Lock(pao); + hpios_dsplock_lock(pao); - dwTimeout = TIMEOUT; + timeout = TIMEOUT; do { - dwCacheDirtyFlag = HpiReadWord((struct dsp_obj *)pdo, - HPI_HIF_ADDR(dwControlCacheIsDirty)); + cache_dirty_flag = + hpi_read_word((struct dsp_obj *)pdo, + HPI_HIF_ADDR(control_cache_is_dirty)); } - while (Hpi6000_Check_PCI2040_ErrorFlag(pao, H6READ) && --dwTimeout); - if (!dwTimeout) { + while (hpi6000_check_PCI2040_error_flag(pao, H6READ) && --timeout); + if (!timeout) { err = HPI6000_ERROR_CONTROL_CACHE_PARAMS; goto unlock; } - if (dwCacheDirtyFlag) { + if (cache_dirty_flag) { /* read the cached controls */ - u32 dwAddress; - u32 dwLength; + u32 address; + u32 length; - dwTimeout = TIMEOUT; - if (pdo->dwControlCacheAddressOnDSP == 0) { + timeout = TIMEOUT; + if (pdo->control_cache_address_on_dsp == 0) { do { - dwAddress = - HpiReadWord((struct dsp_obj *)pdo, - HPI_HIF_ADDR(dwControlCacheAddress)); + address = + hpi_read_word((struct dsp_obj *)pdo, + HPI_HIF_ADDR(control_cache_address)); - dwLength = - HpiReadWord((struct dsp_obj *)pdo, + length = hpi_read_word((struct dsp_obj *)pdo, HPI_HIF_ADDR - (dwControlCacheSizeInBytes)); + (control_cache_size_in_bytes)); } - while (Hpi6000_Check_PCI2040_ErrorFlag(pao, H6READ) - && --dwTimeout); - if (!dwTimeout) { + while (hpi6000_check_PCI2040_error_flag(pao, H6READ) + && --timeout); + if (!timeout) { err = HPI6000_ERROR_CONTROL_CACHE_ADDRLEN; goto unlock; } - pdo->dwControlCacheAddressOnDSP = dwAddress; - pdo->dwControlCacheLengthOnDSP = dwLength; + pdo->control_cache_address_on_dsp = address; + pdo->control_cache_length_on_dsp = length; } else { - dwAddress = pdo->dwControlCacheAddressOnDSP; - dwLength = pdo->dwControlCacheLengthOnDSP; + address = pdo->control_cache_address_on_dsp; + length = pdo->control_cache_length_on_dsp; } - if (Hpi6000_DspBlockRead32(pao, wDspIndex, dwAddress, - (u32 *)&phw->aControlCache[0], - dwLength / sizeof(u32))) { + if (hpi6000_dsp_block_read32(pao, dsp_index, address, + (u32 *)&phw->control_cache[0], + length / sizeof(u32))) { err = HPI6000_ERROR_CONTROL_CACHE_READ; goto unlock; } do { - HpiWriteWord((struct dsp_obj *)pdo, - HPI_HIF_ADDR(dwControlCacheIsDirty), 0); + hpi_write_word((struct dsp_obj *)pdo, + HPI_HIF_ADDR(control_cache_is_dirty), 0); /* flush the FIFO */ - HpiSetAddress(pdo, HPI_HIF_ADDR(dwHostCmd)); + hpi_set_address(pdo, HPI_HIF_ADDR(host_cmd)); } - while (Hpi6000_Check_PCI2040_ErrorFlag(pao, H6WRITE) - && --dwTimeout); - if (!dwTimeout) { + while (hpi6000_check_PCI2040_error_flag(pao, H6WRITE) + && --timeout); + if (!timeout) { err = HPI6000_ERROR_CONTROL_CACHE_FLUSH; goto unlock; } @@ -1893,24 +1753,21 @@ static short Hpi6000_UpdateControlCache( err = 0; unlock: - HpiOs_Dsplock_UnLock(pao); + hpios_dsplock_unlock(pao); return err; } /** Get dsp index for multi DSP adapters only */ -static u16 GetDspIndex( - struct hpi_adapter_obj *pao, - struct hpi_message *phm -) +static u16 get_dsp_index(struct hpi_adapter_obj *pao, struct hpi_message *phm) { u16 ret = 0; - switch (phm->wObject) { + switch (phm->object) { case HPI_OBJ_ISTREAM: - if (phm->wObjIndex < 2) + if (phm->obj_index < 2) ret = 1; break; case HPI_OBJ_PROFILE: - ret = phm->wObjIndex; + ret = phm->obj_index; break; default: break; @@ -1922,75 +1779,72 @@ static u16 GetDspIndex( Send message, get response, send or get stream data if any. */ -static void HW_Message( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, + struct hpi_response *phr) { - u16 nError = 0; - u16 wDspIndex = 0; - u16 numDsp = ((struct hpi_hw_obj *)pao->priv)->wNumDsp; - HpiOs_Dsplock_Lock(pao); + u16 error = 0; + u16 dsp_index = 0; + u16 num_dsp = ((struct hpi_hw_obj *)pao->priv)->num_dsp; + hpios_dsplock_lock(pao); - if (numDsp < 2) - wDspIndex = 0; + if (num_dsp < 2) + dsp_index = 0; else { - wDspIndex = GetDspIndex(pao, phm); + dsp_index = get_dsp_index(pao, phm); /* is this checked on the DSP anyway? */ - if ((phm->wFunction == HPI_ISTREAM_GROUP_ADD) || - (phm->wFunction == HPI_OSTREAM_GROUP_ADD)) { + if ((phm->function == HPI_ISTREAM_GROUP_ADD) + || (phm->function == HPI_OSTREAM_GROUP_ADD)) { struct hpi_message hm; - u16 wAddIndex; - hm.wObjIndex = phm->u.d.u.Stream.wStreamIndex; - hm.wObject = phm->u.d.u.Stream.wObjectType; - wAddIndex = GetDspIndex(pao, &hm); - if (wAddIndex != wDspIndex) { - phr->wError = HPI_ERROR_NO_INTERDSP_GROUPS; + u16 add_index; + hm.obj_index = phm->u.d.u.stream.stream_index; + hm.object = phm->u.d.u.stream.object_type; + add_index = get_dsp_index(pao, &hm); + if (add_index != dsp_index) { + phr->error = HPI_ERROR_NO_INTERDSP_GROUPS; return; } } } - nError = Hpi6000_MessageResponseSequence(pao, wDspIndex, phm, phr); + error = hpi6000_message_response_sequence(pao, dsp_index, phm, phr); /* maybe an error response */ - if (nError) { + if (error) { /* something failed in the HPI/DSP interface */ - phr->wError = nError; + phr->error = error; /* just the header of the response is valid */ - phr->wSize = sizeof(struct hpi_response_header); + phr->size = sizeof(struct hpi_response_header); goto err; } - if (phr->wError != 0) /* something failed in the DSP */ + if (phr->error != 0) /* something failed in the DSP */ goto err; - switch (phm->wFunction) { + switch (phm->function) { case HPI_OSTREAM_WRITE: case HPI_ISTREAM_ANC_WRITE: - nError = Hpi6000_SendData(pao, wDspIndex, phm, phr); + error = hpi6000_send_data(pao, dsp_index, phm, phr); break; case HPI_ISTREAM_READ: case HPI_OSTREAM_ANC_READ: - nError = Hpi6000_GetData(pao, wDspIndex, phm, phr); + error = hpi6000_get_data(pao, dsp_index, phm, phr); break; case HPI_ADAPTER_GET_ASSERT: - phr->u.a.wAdapterIndex = 0; /* dsp 0 default */ - if (numDsp == 2) { - if (!phr->u.a.wAdapterType) { + phr->u.a.adapter_index = 0; /* dsp 0 default */ + if (num_dsp == 2) { + if (!phr->u.a.adapter_type) { /* no assert from dsp 0, check dsp 1 */ - nError = Hpi6000_MessageResponseSequence(pao, + error = hpi6000_message_response_sequence(pao, 1, phm, phr); - phr->u.a.wAdapterIndex = 1; + phr->u.a.adapter_index = 1; } } } - if (nError) - phr->wError = nError; + if (error) + phr->error = error; err: - HpiOs_Dsplock_UnLock(pao); + hpios_dsplock_unlock(pao); return; } diff --git a/pci/asihpi/hpi6000.h b/pci/asihpi/hpi6000.h index 348ad8db1..448ffd43a 100644 --- a/pci/asihpi/hpi6000.h +++ b/pci/asihpi/hpi6000.h @@ -34,22 +34,22 @@ Shared between hpi6000.c and DSP code * during boot to make it in-active. */ struct hpi_hif_6000 { - u32 dwHostCmd; - u32 dwDspAck; - u32 dwAddress; - u32 dwLength; - u32 dwMessageBufferAddress; - u32 dwResponseBufferAddress; - u32 dwDspNumber; - u32 dwAdapterInfo; - u32 dwControlCacheIsDirty; - u32 dwControlCacheAddress; - u32 dwControlCacheSizeInBytes; - u32 dwControlCacheCount; + u32 host_cmd; + u32 dsp_ack; + u32 address; + u32 length; + u32 message_buffer_address; + u32 response_buffer_address; + u32 dsp_number; + u32 adapter_info; + u32 control_cache_is_dirty; + u32 control_cache_address; + u32 control_cache_size_in_bytes; + u32 control_cache_count; }; -#define HPI_HIF_PACK_ADAPTER_INFO(adapter, versionMajor, versionMinor) \ - ((adapter << 16) | (versionMajor << 8) | versionMinor) +#define HPI_HIF_PACK_ADAPTER_INFO(adapter, version_major, version_minor) \ + ((adapter << 16) | (version_major << 8) | version_minor) #define HPI_HIF_ADAPTER_INFO_EXTRACT_ADAPTER(adapterinfo) \ ((adapterinfo >> 16) & 0xffff) #define HPI_HIF_ADAPTER_INFO_EXTRACT_HWVERSION_MAJOR(adapterinfo) \ diff --git a/pci/asihpi/hpi6205.c b/pci/asihpi/hpi6205.c index 6db1c58d1..83ce029c4 100644 --- a/pci/asihpi/hpi6205.c +++ b/pci/asihpi/hpi6205.c @@ -16,14 +16,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Hardware Programming Interface (HPI) for AudioScience ASI5000 - series adapters. - These PCI bus adapters are based on a TI C6205 PCI bus mastering DSP + Hardware Programming Interface (HPI) for AudioScience + ASI50xx, AS51xx, ASI6xxx, ASI87xx ASI89xx series adapters. + These PCI and PCIe bus adapters are based on a TMS320C6205 PCI bus mastering DSP, + and (except ASI50xx) TI TMS320C6xxx floating point DSP - Exported functions: + Exported function: void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) -(C) Copyright AudioScience Inc. 1998-2003 +(C) Copyright AudioScience Inc. 1998-2010 *******************************************************************************/ #define SOURCEFILE_NAME "hpi6205.c" @@ -56,7 +57,7 @@ #define HPI6205_ERROR_6205_EEPROM 1017 #define HPI6205_ERROR_DSP_EMIF 1018 -#define Hpi6205_Error(nDspIndex, err) (err) +#define hpi6205_error(dsp_index, err) (err) /*****************************************************************************/ /* for C6205 PCI i/f */ /* Host Status Register (HSR) bitfields */ @@ -112,191 +113,123 @@ struct hpi_hw_obj { __iomem u32 *prHDCR; __iomem u32 *prDSPP; - u32 dwDspPage; + u32 dsp_page; - struct consistent_dma_area hLockedMem; - struct bus_master_interface *pInterfaceBuffer; + struct consistent_dma_area h_locked_mem; + struct bus_master_interface *p_interface_buffer; - u16 flagOStreamJustReset[HPI_MAX_STREAMS]; + u16 flag_outstream_just_reset[HPI_MAX_STREAMS]; /* a non-NULL handle means there is an HPI allocated buffer */ - struct consistent_dma_area InStreamHostBuffers[HPI_MAX_STREAMS]; - struct consistent_dma_area OutStreamHostBuffers[HPI_MAX_STREAMS]; + struct consistent_dma_area instream_host_buffers[HPI_MAX_STREAMS]; + struct consistent_dma_area outstream_host_buffers[HPI_MAX_STREAMS]; /* non-zero size means a buffer exists, may be external */ - u32 InStreamHostBufferSize[HPI_MAX_STREAMS]; - u32 OutStreamHostBufferSize[HPI_MAX_STREAMS]; + u32 instream_host_buffer_size[HPI_MAX_STREAMS]; + u32 outstream_host_buffer_size[HPI_MAX_STREAMS]; - struct consistent_dma_area hControlCache; - struct consistent_dma_area hAsyncEventBuffer; + struct consistent_dma_area h_control_cache; + struct consistent_dma_area h_async_event_buffer; /* struct hpi_control_cache_single *pControlCache; */ - struct hpi_async_event *pAsyncEventBuffer; - struct hpi_control_cache *pCache; + struct hpi_async_event *p_async_event_buffer; + struct hpi_control_cache *p_cache; }; /*****************************************************************************/ /* local prototypes */ -#define CheckBeforeBBMCopy(status, pBBMData, lFirstWrite, lSecondWrite) - -static int WaitDspAck( - struct hpi_hw_obj *phw, - int state, - int timeout_us -); - -static void SendDspCommand( - struct hpi_hw_obj *phw, - int cmd -); - -static u16 AdapterBootLoadDsp( - struct hpi_adapter_obj *pao, - u32 *pdwOsErrorCode -); -static u16 MessageResponseSequence( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void HW_Message( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); +#define check_before_bbm_copy(status, p_bbm_data, l_first_write, l_second_write) + +static int wait_dsp_ack(struct hpi_hw_obj *phw, int state, int timeout_us); + +static void send_dsp_command(struct hpi_hw_obj *phw, int cmd); + +static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, + u32 *pos_error_code); + +static u16 message_response_sequence(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, + struct hpi_response *phr); #define HPI6205_TIMEOUT 1000000 -static void SubSysCreateAdapter( - struct hpi_message *phm, - struct hpi_response *phr -); -static void SubSysDeleteAdapter( - struct hpi_message *phm, - struct hpi_response *phr -); - -static u16 CreateAdapterObj( - struct hpi_adapter_obj *pao, - u32 *pdwOsErrorCode -); -static void DeleteAdapterObj( - struct hpi_adapter_obj *pao -); - -static void OutStreamHostBufferAllocate( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void OutStreamHostBufferGetInfo( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void OutStreamHostBufferFree( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void OutStreamWrite( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void OutStreamGetInfo( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void OutStreamStart( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void OutStreamOpen( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void OutStreamReset( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); - -static void InStreamHostBufferAllocate( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void InStreamHostBufferGetInfo( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void InStreamHostBufferFree( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void InStreamRead( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void InStreamGetInfo( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); -static void InStreamStart( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -); - -static u32 BootLoader_ReadMem32( - struct hpi_adapter_obj *pao, - int nDSPIndex, - u32 dwAddress -); -static u16 BootLoader_WriteMem32( - struct hpi_adapter_obj *pao, - int nDSPIndex, - u32 dwAddress, - u32 dwData -); -static u16 BootLoader_ConfigEMIF( - struct hpi_adapter_obj *pao, - int nDSPIndex -); -static u16 BootLoader_TestMemory( - struct hpi_adapter_obj *pao, - int nDSPIndex, - u32 dwAddress, - u32 dwLength -); -static u16 BootLoader_TestInternalMemory( - struct hpi_adapter_obj *pao, - int nDSPIndex -); -static u16 BootLoader_TestExternalMemory( - struct hpi_adapter_obj *pao, - int nDSPIndex -); -static u16 BootLoader_TestPld( - struct hpi_adapter_obj *pao, - int nDSPIndex -); +static void subsys_create_adapter(struct hpi_message *phm, + struct hpi_response *phr); +static void subsys_delete_adapter(struct hpi_message *phm, + struct hpi_response *phr); + +static u16 create_adapter_obj(struct hpi_adapter_obj *pao, + u32 *pos_error_code); + +static void delete_adapter_obj(struct hpi_adapter_obj *pao); + +static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void outstream_host_buffer_get_info(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void outstream_host_buffer_free(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); +static void outstream_write(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void outstream_get_info(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void outstream_start(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void outstream_open(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void outstream_reset(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void instream_host_buffer_get_info(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void instream_host_buffer_free(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void instream_read(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void instream_get_info(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static void instream_start(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr); + +static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index, + u32 address); + +static u16 boot_loader_write_mem32(struct hpi_adapter_obj *pao, int dsp_index, + u32 address, u32 data); + +static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, + int dsp_index); + +static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index, + u32 address, u32 length); + +static u16 boot_loader_test_internal_memory(struct hpi_adapter_obj *pao, + int dsp_index); + +static u16 boot_loader_test_external_memory(struct hpi_adapter_obj *pao, + int dsp_index); + +static u16 boot_loader_test_pld(struct hpi_adapter_obj *pao, int dsp_index); /*****************************************************************************/ -static void SubSysMessage( - struct hpi_message *phm, - struct hpi_response *phr -) +static void subsys_message(struct hpi_message *phm, struct hpi_response *phr) { - switch (phm->wFunction) { + switch (phm->function) { case HPI_SUBSYS_OPEN: case HPI_SUBSYS_CLOSE: case HPI_SUBSYS_GET_INFO: @@ -304,149 +237,137 @@ static void SubSysMessage( case HPI_SUBSYS_DRIVER_LOAD: case HPI_SUBSYS_FIND_ADAPTERS: /* messages that should not get here */ - phr->wError = HPI_ERROR_UNIMPLEMENTED; + phr->error = HPI_ERROR_UNIMPLEMENTED; break; case HPI_SUBSYS_CREATE_ADAPTER: - SubSysCreateAdapter(phm, phr); + subsys_create_adapter(phm, phr); break; case HPI_SUBSYS_DELETE_ADAPTER: - SubSysDeleteAdapter(phm, phr); + subsys_delete_adapter(phm, phr); break; default: - phr->wError = HPI_ERROR_INVALID_FUNC; + phr->error = HPI_ERROR_INVALID_FUNC; break; } } -static void ControlMessage( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void control_message(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { struct hpi_hw_obj *phw = pao->priv; - switch (phm->wFunction) { + switch (phm->function) { case HPI_CONTROL_GET_STATE: - if (pao->wHasControlCache) { - rmb(); /* make sure we see updates DMAed from DSP */ - if (HpiCheckControlCache(phw->pCache, phm, phr)) + if (pao->has_control_cache) { + rmb(); /* make sure we see updates DM_aed from DSP */ + if (hpi_check_control_cache(phw->p_cache, phm, phr)) break; } - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); break; case HPI_CONTROL_GET_INFO: - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); break; case HPI_CONTROL_SET_STATE: - HW_Message(pao, phm, phr); - if (pao->wHasControlCache) - HpiSyncControlCache(phw->pCache, phm, phr); + hw_message(pao, phm, phr); + if (pao->has_control_cache) + hpi_sync_control_cache(phw->p_cache, phm, phr); break; default: - phr->wError = HPI_ERROR_INVALID_FUNC; + phr->error = HPI_ERROR_INVALID_FUNC; break; } } -static void AdapterMessage( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void adapter_message(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { - switch (phm->wFunction) { + switch (phm->function) { default: - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); break; } } -static void OStreamMessage( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void outstream_message(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { - if (phm->wObjIndex >= HPI_MAX_STREAMS) { - phr->wError = HPI_ERROR_INVALID_STREAM; + if (phm->obj_index >= HPI_MAX_STREAMS) { + phr->error = HPI_ERROR_INVALID_STREAM; HPI_DEBUG_LOG(WARNING, - "Message referencing invalid stream %d " - "on adapter index %d\n", - phm->wObjIndex, phm->wAdapterIndex); + "message referencing invalid stream %d " + "on adapter index %d\n", phm->obj_index, + phm->adapter_index); return; } - switch (phm->wFunction) { + switch (phm->function) { case HPI_OSTREAM_WRITE: - OutStreamWrite(pao, phm, phr); + outstream_write(pao, phm, phr); break; case HPI_OSTREAM_GET_INFO: - OutStreamGetInfo(pao, phm, phr); + outstream_get_info(pao, phm, phr); break; case HPI_OSTREAM_HOSTBUFFER_ALLOC: - OutStreamHostBufferAllocate(pao, phm, phr); + outstream_host_buffer_allocate(pao, phm, phr); break; case HPI_OSTREAM_HOSTBUFFER_GET_INFO: - OutStreamHostBufferGetInfo(pao, phm, phr); + outstream_host_buffer_get_info(pao, phm, phr); break; case HPI_OSTREAM_HOSTBUFFER_FREE: - OutStreamHostBufferFree(pao, phm, phr); + outstream_host_buffer_free(pao, phm, phr); break; case HPI_OSTREAM_START: - OutStreamStart(pao, phm, phr); + outstream_start(pao, phm, phr); break; case HPI_OSTREAM_OPEN: - OutStreamOpen(pao, phm, phr); + outstream_open(pao, phm, phr); break; case HPI_OSTREAM_RESET: - OutStreamReset(pao, phm, phr); + outstream_reset(pao, phm, phr); break; default: - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); break; } } -static void IStreamMessage( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void instream_message(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { - if (phm->wObjIndex >= HPI_MAX_STREAMS) { - phr->wError = HPI_ERROR_INVALID_STREAM; + if (phm->obj_index >= HPI_MAX_STREAMS) { + phr->error = HPI_ERROR_INVALID_STREAM; HPI_DEBUG_LOG(WARNING, - "Message referencing invalid stream %d " - "on adapter index %d\n", - phm->wObjIndex, phm->wAdapterIndex); + "message referencing invalid stream %d " + "on adapter index %d\n", phm->obj_index, + phm->adapter_index); return; } - switch (phm->wFunction) { + switch (phm->function) { case HPI_ISTREAM_READ: - InStreamRead(pao, phm, phr); + instream_read(pao, phm, phr); break; case HPI_ISTREAM_GET_INFO: - InStreamGetInfo(pao, phm, phr); + instream_get_info(pao, phm, phr); break; case HPI_ISTREAM_HOSTBUFFER_ALLOC: - InStreamHostBufferAllocate(pao, phm, phr); + instream_host_buffer_allocate(pao, phm, phr); break; case HPI_ISTREAM_HOSTBUFFER_GET_INFO: - InStreamHostBufferGetInfo(pao, phm, phr); + instream_host_buffer_get_info(pao, phm, phr); break; case HPI_ISTREAM_HOSTBUFFER_FREE: - InStreamHostBufferFree(pao, phm, phr); + instream_host_buffer_free(pao, phm, phr); break; case HPI_ISTREAM_START: - InStreamStart(pao, phm, phr); + instream_start(pao, phm, phr); break; default: - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); break; } } @@ -455,10 +376,7 @@ static void IStreamMessage( /** Entry point to this HPI backend * All calls to the HPI start here */ -void HPI_6205( - struct hpi_message *phm, - struct hpi_response *phr -) +void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) { struct hpi_adapter_obj *pao = NULL; @@ -466,70 +384,71 @@ void HPI_6205( * All other messages are ignored unless the adapter index matches * an adapter in the HPI */ - HPI_DEBUG_LOG(DEBUG, "HPI Obj=%d, Func=%d\n", phm->wObject, - phm->wFunction); + HPI_DEBUG_LOG(DEBUG, "HPI obj=%d, func=%d\n", phm->object, + phm->function); /* if Dsp has crashed then do not communicate with it any more */ - if (phm->wObject != HPI_OBJ_SUBSYSTEM) { - pao = HpiFindAdapter(phm->wAdapterIndex); + if (phm->object != HPI_OBJ_SUBSYSTEM) { + pao = hpi_find_adapter(phm->adapter_index); if (!pao) { HPI_DEBUG_LOG(DEBUG, " %d,%d refused, for another HPI?\n", - phm->wObject, phm->wFunction); + phm->object, phm->function); return; } - if ((pao->wDspCrashed >= 10) && - (phm->wFunction != HPI_ADAPTER_DEBUG_READ)) { + if ((pao->dsp_crashed >= 10) + && (phm->function != HPI_ADAPTER_DEBUG_READ)) { /* allow last resort debug read even after crash */ - HPI_InitResponse(phr, phm->wObject, phm->wFunction, + hpi_init_response(phr, phm->object, phm->function, HPI_ERROR_DSP_HARDWARE); HPI_DEBUG_LOG(WARNING, " %d,%d dsp crashed.\n", - phm->wObject, phm->wFunction); + phm->object, phm->function); return; } } /* Init default response */ - if (phm->wFunction != HPI_SUBSYS_CREATE_ADAPTER) - HPI_InitResponse(phr, phm->wObject, phm->wFunction, + if (phm->function != HPI_SUBSYS_CREATE_ADAPTER) + hpi_init_response(phr, phm->object, phm->function, HPI_ERROR_PROCESSING_MESSAGE); HPI_DEBUG_LOG(VERBOSE, "start of switch\n"); - switch (phm->wType) { + switch (phm->type) { case HPI_TYPE_MESSAGE: - switch (phm->wObject) { + switch (phm->object) { case HPI_OBJ_SUBSYSTEM: - SubSysMessage(phm, phr); + subsys_message(phm, phr); break; case HPI_OBJ_ADAPTER: - phr->wSize = sizeof(struct hpi_response_header) + + phr->size = + sizeof(struct hpi_response_header) + sizeof(struct hpi_adapter_res); - AdapterMessage(pao, phm, phr); + adapter_message(pao, phm, phr); break; case HPI_OBJ_CONTROLEX: case HPI_OBJ_CONTROL: - ControlMessage(pao, phm, phr); + control_message(pao, phm, phr); break; case HPI_OBJ_OSTREAM: - OStreamMessage(pao, phm, phr); + outstream_message(pao, phm, phr); break; case HPI_OBJ_ISTREAM: - IStreamMessage(pao, phm, phr); + instream_message(pao, phm, phr); break; default: - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); break; } break; default: - phr->wError = HPI_ERROR_INVALID_TYPE; + phr->error = HPI_ERROR_INVALID_TYPE; break; } } @@ -542,160 +461,155 @@ void HPI_6205( * *** NOTE - you cannot use this function AND the FindAdapters function at the * same time, the application must use only one of them to get the adapters *** */ -static void SubSysCreateAdapter( - struct hpi_message *phm, - struct hpi_response *phr -) +static void subsys_create_adapter(struct hpi_message *phm, + struct hpi_response *phr) { /* create temp adapter obj, because we don't know what index yet */ struct hpi_adapter_obj ao; - u32 dwOsErrorCode; + u32 os_error_code; u16 err; - HPI_DEBUG_LOG(DEBUG, " SubSysCreateAdapter\n"); + HPI_DEBUG_LOG(DEBUG, " subsys_create_adapter\n"); memset(&ao, 0, sizeof(ao)); /* this HPI only creates adapters for TI/PCI devices */ - if (phm->u.s.Resource.wBusType != HPI_BUS_PCI) + if (phm->u.s.resource.bus_type != HPI_BUS_PCI) return; - if (phm->u.s.Resource.r.Pci->wVendorId != HPI_PCI_VENDOR_ID_TI) + if (phm->u.s.resource.r.pci->vendor_id != HPI_PCI_VENDOR_ID_TI) return; - if (phm->u.s.Resource.r.Pci->wDeviceId != HPI_PCI_DEV_ID_DSP6205) + if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_DSP6205) return; ao.priv = kmalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL); if (!ao.priv) { HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n"); - phr->wError = HPI_ERROR_MEMORY_ALLOC; + phr->error = HPI_ERROR_MEMORY_ALLOC; return; } memset(ao.priv, 0, sizeof(struct hpi_hw_obj)); - ao.Pci = *phm->u.s.Resource.r.Pci; - err = CreateAdapterObj(&ao, &dwOsErrorCode); + ao.pci = *phm->u.s.resource.r.pci; + err = create_adapter_obj(&ao, &os_error_code); if (!err) - err = HpiAddAdapter(&ao); + err = hpi_add_adapter(&ao); if (err) { - phr->u.s.dwData = dwOsErrorCode; - DeleteAdapterObj(&ao); - phr->wError = err; + phr->u.s.data = os_error_code; + delete_adapter_obj(&ao); + phr->error = err; return; } - phr->u.s.awAdapterList[ao.wIndex] = ao.wAdapterType; - phr->u.s.wAdapterIndex = ao.wIndex; - phr->u.s.wNumAdapters++; - phr->wError = 0; + phr->u.s.aw_adapter_list[ao.index] = ao.adapter_type; + phr->u.s.adapter_index = ao.index; + phr->u.s.num_adapters++; + phr->error = 0; } /** delete an adapter - required by WDM driver */ -static void SubSysDeleteAdapter( - struct hpi_message *phm, - struct hpi_response *phr -) +static void subsys_delete_adapter(struct hpi_message *phm, + struct hpi_response *phr) { struct hpi_adapter_obj *pao; struct hpi_hw_obj *phw; - pao = HpiFindAdapter(phm->wAdapterIndex); + pao = hpi_find_adapter(phm->adapter_index); if (!pao) { - phr->wError = HPI_ERROR_INVALID_OBJ_INDEX; + phr->error = HPI_ERROR_INVALID_OBJ_INDEX; return; } phw = (struct hpi_hw_obj *)pao->priv; /* reset adapter h/w */ /* Reset C6713 #1 */ - BootLoader_WriteMem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0); + boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0); /* reset C6205 */ iowrite32(C6205_HDCR_WARMRESET, phw->prHDCR); - DeleteAdapterObj(pao); - phr->wError = 0; + delete_adapter_obj(pao); + phr->error = 0; } /** Create adapter object allocate buffers, bootload DSPs, initialise control cache */ -static u16 CreateAdapterObj( - struct hpi_adapter_obj *pao, - u32 *pdwOsErrorCode -) +static u16 create_adapter_obj(struct hpi_adapter_obj *pao, + u32 *pos_error_code) { struct hpi_hw_obj *phw = pao->priv; struct bus_master_interface *interface; - u32 dwPhysAddr; + u32 phys_addr; #ifndef HPI6205_NO_HSR_POLL - u32 dwTimeOut = HPI6205_TIMEOUT; - u32 dwTemp1; + u32 time_out = HPI6205_TIMEOUT; + u32 temp1; #endif int i; u16 err; /* init error reporting */ - pao->wDspCrashed = 0; + pao->dsp_crashed = 0; for (i = 0; i < HPI_MAX_STREAMS; i++) - phw->flagOStreamJustReset[i] = 1; + phw->flag_outstream_just_reset[i] = 1; /* The C6205 memory area 1 is 8Mbyte window into DSP registers */ - phw->prHSR = pao->Pci.apMemBase[1] + - C6205_BAR1_HSR / sizeof(*pao->Pci.apMemBase[1]); + phw->prHSR = + pao->pci.ap_mem_base[1] + + C6205_BAR1_HSR / sizeof(*pao->pci.ap_mem_base[1]); phw->prHDCR = - pao->Pci.apMemBase[1] + - C6205_BAR1_HDCR / sizeof(*pao->Pci.apMemBase[1]); + pao->pci.ap_mem_base[1] + + C6205_BAR1_HDCR / sizeof(*pao->pci.ap_mem_base[1]); phw->prDSPP = - pao->Pci.apMemBase[1] + - C6205_BAR1_DSPP / sizeof(*pao->Pci.apMemBase[1]); + pao->pci.ap_mem_base[1] + + C6205_BAR1_DSPP / sizeof(*pao->pci.ap_mem_base[1]); - pao->wHasControlCache = 0; + pao->has_control_cache = 0; - if (HpiOs_LockedMem_Alloc(&phw->hLockedMem, + if (hpios_locked_mem_alloc(&phw->h_locked_mem, sizeof(struct bus_master_interface), - pao->Pci.pOsData)) - phw->pInterfaceBuffer = NULL; - else if (HpiOs_LockedMem_GetVirtAddr - (&phw->hLockedMem, (void *)&phw->pInterfaceBuffer)) - phw->pInterfaceBuffer = NULL; + pao->pci.p_os_data)) + phw->p_interface_buffer = NULL; + else if (hpios_locked_mem_get_virt_addr(&phw->h_locked_mem, + (void *)&phw->p_interface_buffer)) + phw->p_interface_buffer = NULL; - HPI_DEBUG_LOG(DEBUG, "Interface buffer address %p\n", - phw->pInterfaceBuffer); + HPI_DEBUG_LOG(DEBUG, "interface buffer address %p\n", + phw->p_interface_buffer); - if (phw->pInterfaceBuffer) { - memset((void *)phw->pInterfaceBuffer, 0, + if (phw->p_interface_buffer) { + memset((void *)phw->p_interface_buffer, 0, sizeof(struct bus_master_interface)); - phw->pInterfaceBuffer->dwDspAck = H620_HIF_UNKNOWN; + phw->p_interface_buffer->dsp_ack = H620_HIF_UNKNOWN; } - err = AdapterBootLoadDsp(pao, pdwOsErrorCode); + err = adapter_boot_load_dsp(pao, pos_error_code); if (err) /* no need to clean up as SubSysCreateAdapter */ /* calls DeleteAdapter on error. */ return (err); - HPI_DEBUG_LOG(INFO, "Load DSP code OK\n"); + HPI_DEBUG_LOG(INFO, "load DSP code OK\n"); /* allow boot load even if mem alloc wont work */ - if (!phw->pInterfaceBuffer) - return (Hpi6205_Error(0, HPI_ERROR_MEMORY_ALLOC)); + if (!phw->p_interface_buffer) + return (hpi6205_error(0, HPI_ERROR_MEMORY_ALLOC)); - interface = phw->pInterfaceBuffer; + interface = phw->p_interface_buffer; #ifndef HPI6205_NO_HSR_POLL /* wait for first interrupt indicating the DSP init is done */ - dwTimeOut = HPI6205_TIMEOUT * 10; - dwTemp1 = 0; - while (((dwTemp1 & C6205_HSR_INTSRC) == 0) && --dwTimeOut) - dwTemp1 = ioread32(phw->prHSR); + time_out = HPI6205_TIMEOUT * 10; + temp1 = 0; + while (((temp1 & C6205_HSR_INTSRC) == 0) && --time_out) + temp1 = ioread32(phw->prHSR); - if (dwTemp1 & C6205_HSR_INTSRC) + if (temp1 & C6205_HSR_INTSRC) HPI_DEBUG_LOG(INFO, - "Interrupt confirming DSP code running OK\n"); + "interrupt confirming DSP code running OK\n"); else { HPI_DEBUG_LOG(ERROR, - "Timed out waiting for interrupt " + "timed out waiting for interrupt " "confirming DSP code running\n"); - return (Hpi6205_Error(0, HPI6205_ERROR_6205_NO_IRQ)); + return (hpi6205_error(0, HPI6205_ERROR_6205_NO_IRQ)); } /* reset the interrupt */ @@ -703,118 +617,120 @@ static u16 CreateAdapterObj( #endif /* make sure the DSP has started ok */ - if (!WaitDspAck(phw, H620_HIF_RESET, HPI6205_TIMEOUT * 10)) { - HPI_DEBUG_LOG(ERROR, "Timed out waiting reset state \n"); - return (Hpi6205_Error(0, HPI6205_ERROR_6205_INIT_FAILED)); + if (!wait_dsp_ack(phw, H620_HIF_RESET, HPI6205_TIMEOUT * 10)) { + HPI_DEBUG_LOG(ERROR, "timed out waiting reset state \n"); + return (hpi6205_error(0, HPI6205_ERROR_6205_INIT_FAILED)); } /* Note that *pao, *phw are zeroed after allocation, * so pointers and flags are NULL by default. * Allocate bus mastering control cache buffer and tell the DSP about it */ - if (interface->aControlCache.dwNumberOfControls) { - void *pControlCacheVirtual; + if (interface->control_cache.number_of_controls) { + void *p_control_cache_virtual; - err = HpiOs_LockedMem_Alloc(&phw->hControlCache, - interface->aControlCache.dwSizeInBytes, - pao->Pci.pOsData); + err = hpios_locked_mem_alloc(&phw->h_control_cache, + interface->control_cache.size_in_bytes, + pao->pci.p_os_data); if (!err) - err = HpiOs_LockedMem_GetVirtAddr(&phw->hControlCache, - &pControlCacheVirtual); + err = hpios_locked_mem_get_virt_addr(&phw-> + h_control_cache, &p_control_cache_virtual); if (!err) { - memset(pControlCacheVirtual, 0, - interface->aControlCache.dwSizeInBytes); + memset(p_control_cache_virtual, 0, + interface->control_cache.size_in_bytes); - phw->pCache = - HpiAllocControlCache(interface->aControlCache. - dwNumberOfControls, - interface->aControlCache.dwSizeInBytes, + phw->p_cache = + hpi_alloc_control_cache(interface-> + control_cache.number_of_controls, + interface->control_cache.size_in_bytes, (struct hpi_control_cache_info *) - pControlCacheVirtual); + p_control_cache_virtual); } if (!err) { - err = HpiOs_LockedMem_GetPhysAddr(&phw->hControlCache, - &dwPhysAddr); - interface->aControlCache.dwPhysicalPCI32address = - dwPhysAddr; + err = hpios_locked_mem_get_phys_addr(&phw-> + h_control_cache, &phys_addr); + interface->control_cache.physical_address32 = + phys_addr; } if (!err) - pao->wHasControlCache = 1; + pao->has_control_cache = 1; else { - if (HpiOs_LockedMem_Valid(&phw->hControlCache)) - HpiOs_LockedMem_Free(&phw->hControlCache); - pao->wHasControlCache = 0; + if (hpios_locked_mem_valid(&phw->h_control_cache)) + hpios_locked_mem_free(&phw->h_control_cache); + pao->has_control_cache = 0; } } /* allocate bus mastering async buffer and tell the DSP about it */ - if (interface->aAsyncBuffer.b.dwSize) { - err = HpiOs_LockedMem_Alloc(&phw->hAsyncEventBuffer, - interface->aAsyncBuffer.b.dwSize * - sizeof(struct hpi_async_event), pao->Pci.pOsData); + if (interface->async_buffer.b.size) { + err = hpios_locked_mem_alloc(&phw->h_async_event_buffer, + interface->async_buffer.b.size * + sizeof(struct hpi_async_event), pao->pci.p_os_data); if (!err) - err = HpiOs_LockedMem_GetVirtAddr - (&phw->hAsyncEventBuffer, (void *) - &phw->pAsyncEventBuffer); + err = hpios_locked_mem_get_virt_addr + (&phw->h_async_event_buffer, (void *) + &phw->p_async_event_buffer); if (!err) - memset((void *)phw->pAsyncEventBuffer, 0, - interface->aAsyncBuffer.b.dwSize * + memset((void *)phw->p_async_event_buffer, 0, + interface->async_buffer.b.size * sizeof(struct hpi_async_event)); if (!err) { - err = HpiOs_LockedMem_GetPhysAddr - (&phw->hAsyncEventBuffer, &dwPhysAddr); - interface->aAsyncBuffer.dwPhysicalPCI32address = - dwPhysAddr; + err = hpios_locked_mem_get_phys_addr + (&phw->h_async_event_buffer, &phys_addr); + interface->async_buffer.physical_address32 = + phys_addr; } if (err) { - if (HpiOs_LockedMem_Valid(&phw->hAsyncEventBuffer)) { - HpiOs_LockedMem_Free(&phw->hAsyncEventBuffer); - phw->pAsyncEventBuffer = NULL; + if (hpios_locked_mem_valid(&phw-> + h_async_event_buffer)) { + hpios_locked_mem_free + (&phw->h_async_event_buffer); + phw->p_async_event_buffer = NULL; } } } - SendDspCommand(phw, H620_HIF_IDLE); + send_dsp_command(phw, H620_HIF_IDLE); { struct hpi_message hM; struct hpi_response hR; - u32 nMaxStreams; + u32 max_streams; - HPI_DEBUG_LOG(VERBOSE, "Init ADAPTER_GET_INFO\n"); + HPI_DEBUG_LOG(VERBOSE, "init ADAPTER_GET_INFO\n"); memset(&hM, 0, sizeof(hM)); - hM.wType = HPI_TYPE_MESSAGE; - hM.wSize = sizeof(hM); - hM.wObject = HPI_OBJ_ADAPTER; - hM.wFunction = HPI_ADAPTER_GET_INFO; - hM.wAdapterIndex = 0; + hM.type = HPI_TYPE_MESSAGE; + hM.size = sizeof(hM); + hM.object = HPI_OBJ_ADAPTER; + hM.function = HPI_ADAPTER_GET_INFO; + hM.adapter_index = 0; memset(&hR, 0, sizeof(hR)); - hR.wSize = sizeof(hR); + hR.size = sizeof(hR); - err = MessageResponseSequence(pao, &hM, &hR); + err = message_response_sequence(pao, &hM, &hR); if (err) { HPI_DEBUG_LOG(ERROR, "message transport error %d\n", err); return (err); } - if (hR.wError) - return (hR.wError); + if (hR.error) + return (hR.error); - pao->wAdapterType = hR.u.a.wAdapterType; - pao->wIndex = hR.u.a.wAdapterIndex; + pao->adapter_type = hR.u.a.adapter_type; + pao->index = hR.u.a.adapter_index; - nMaxStreams = hR.u.a.wNumOStreams + hR.u.a.wNumIStreams; + max_streams = hR.u.a.num_outstreams + hR.u.a.num_instreams; - HpiOs_LockedMem_Prepare((nMaxStreams * 6) / 10, nMaxStreams, - 65536, pao->Pci.pOsData); + hpios_locked_mem_prepare((max_streams * 6) / 10, max_streams, + 65536, pao->pci.p_os_data); HPI_DEBUG_LOG(VERBOSE, - "Got adapter info Type %x Index %d Serial %d\n", - hR.u.a.wAdapterType, hR.u.a.wAdapterIndex, - hR.u.a.dwSerialNumber); + "got adapter info type %x index %d serial %d\n", + hR.u.a.adapter_type, hR.u.a.adapter_index, + hR.u.a.serial_number); } - pao->wOpen = 0; /* upon creation the adapter is closed */ + pao->open = 0; /* upon creation the adapter is closed */ - HPI_DEBUG_LOG(INFO, "Bootload DSP OK\n"); + HPI_DEBUG_LOG(INFO, "bootload DSP OK\n"); return (0); } @@ -822,46 +738,45 @@ static u16 CreateAdapterObj( * this routine is called from SubSysDeleteAdapter, * and SubSysCreateAdapter if duplicate index */ -static void DeleteAdapterObj( - struct hpi_adapter_obj *pao -) +static void delete_adapter_obj(struct hpi_adapter_obj *pao) { struct hpi_hw_obj *phw; int i; phw = pao->priv; - if (HpiOs_LockedMem_Valid(&phw->hAsyncEventBuffer)) { - HpiOs_LockedMem_Free(&phw->hAsyncEventBuffer); - phw->pAsyncEventBuffer = NULL; + if (hpios_locked_mem_valid(&phw->h_async_event_buffer)) { + hpios_locked_mem_free(&phw->h_async_event_buffer); + phw->p_async_event_buffer = NULL; } - if (HpiOs_LockedMem_Valid(&phw->hControlCache)) { - HpiOs_LockedMem_Free(&phw->hControlCache); - HpiFreeControlCache(phw->pCache); + if (hpios_locked_mem_valid(&phw->h_control_cache)) { + hpios_locked_mem_free(&phw->h_control_cache); + hpi_free_control_cache(phw->p_cache); } - if (HpiOs_LockedMem_Valid(&phw->hLockedMem)) { - HpiOs_LockedMem_Free(&phw->hLockedMem); - phw->pInterfaceBuffer = NULL; + if (hpios_locked_mem_valid(&phw->h_locked_mem)) { + hpios_locked_mem_free(&phw->h_locked_mem); + phw->p_interface_buffer = NULL; } for (i = 0; i < HPI_MAX_STREAMS; i++) - if (HpiOs_LockedMem_Valid(&phw->InStreamHostBuffers[i])) { - HpiOs_LockedMem_Free(&phw->InStreamHostBuffers[i]); + if (hpios_locked_mem_valid(&phw->instream_host_buffers[i])) { + hpios_locked_mem_free(&phw->instream_host_buffers[i]); /*?phw->InStreamHostBuffers[i] = NULL; */ - phw->InStreamHostBufferSize[i] = 0; + phw->instream_host_buffer_size[i] = 0; } for (i = 0; i < HPI_MAX_STREAMS; i++) - if (HpiOs_LockedMem_Valid(&phw->OutStreamHostBuffers[i])) { - HpiOs_LockedMem_Free(&phw->OutStreamHostBuffers[i]); - phw->OutStreamHostBufferSize[i] = 0; + if (hpios_locked_mem_valid(&phw->outstream_host_buffers[i])) { + hpios_locked_mem_free(&phw->outstream_host_buffers + [i]); + phw->outstream_host_buffer_size[i] = 0; } - HpiOs_LockedMem_Unprepare(pao->Pci.pOsData); + hpios_locked_mem_unprepare(pao->pci.p_os_data); - HpiDeleteAdapter(pao); + hpi_delete_adapter(pao); kfree(phw); } @@ -870,618 +785,579 @@ static void DeleteAdapterObj( /** Allocate or attach buffer for busmastering */ -static void OutStreamHostBufferAllocate( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { u16 err = 0; - u32 dwCommand = phm->u.d.u.Buffer.dwCommand; + u32 command = phm->u.d.u.buffer.command; struct hpi_hw_obj *phw = pao->priv; - struct bus_master_interface *interface = phw->pInterfaceBuffer; + struct bus_master_interface *interface = phw->p_interface_buffer; - HPI_InitResponse(phr, phm->wObject, phm->wFunction, 0); + hpi_init_response(phr, phm->object, phm->function, 0); - if (dwCommand == HPI_BUFFER_CMD_EXTERNAL - || dwCommand == HPI_BUFFER_CMD_INTERNAL_ALLOC) { + if (command == HPI_BUFFER_CMD_EXTERNAL + || command == HPI_BUFFER_CMD_INTERNAL_ALLOC) { /* ALLOC phase, allocate a buffer with power of 2 size, get its bus address for PCI bus mastering */ - phm->u.d.u.Buffer.dwBufferSize = - roundup_pow_of_two(phm->u.d.u.Buffer.dwBufferSize); + phm->u.d.u.buffer.buffer_size = + roundup_pow_of_two(phm->u.d.u.buffer.buffer_size); /* return old size and allocated size, so caller can detect change */ - phr->u.d.u.stream_info.dwDataAvailable = - phw->OutStreamHostBufferSize[phm->wObjIndex]; - phr->u.d.u.stream_info.dwBufferSize = - phm->u.d.u.Buffer.dwBufferSize; + phr->u.d.u.stream_info.data_available = + phw->outstream_host_buffer_size[phm->obj_index]; + phr->u.d.u.stream_info.buffer_size = + phm->u.d.u.buffer.buffer_size; - if (phw->OutStreamHostBufferSize[phm->wObjIndex] == - phm->u.d.u.Buffer.dwBufferSize) { + if (phw->outstream_host_buffer_size[phm->obj_index] == + phm->u.d.u.buffer.buffer_size) { /* Same size, no action required */ return; } - if (HpiOs_LockedMem_Valid(&phw->OutStreamHostBuffers[phm-> - wObjIndex])) - HpiOs_LockedMem_Free(&phw->OutStreamHostBuffers[phm-> - wObjIndex]); + if (hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> + obj_index])) + hpios_locked_mem_free(&phw->outstream_host_buffers + [phm->obj_index]); - err = HpiOs_LockedMem_Alloc(&phw->OutStreamHostBuffers[phm-> - wObjIndex], phm->u.d.u.Buffer.dwBufferSize, - pao->Pci.pOsData); + err = hpios_locked_mem_alloc(&phw->outstream_host_buffers + [phm->obj_index], phm->u.d.u.buffer.buffer_size, + pao->pci.p_os_data); if (err) { - phr->wError = HPI_ERROR_INVALID_DATASIZE; - phw->OutStreamHostBufferSize[phm->wObjIndex] = 0; + phr->error = HPI_ERROR_INVALID_DATASIZE; + phw->outstream_host_buffer_size[phm->obj_index] = 0; return; } - err = HpiOs_LockedMem_GetPhysAddr(&phw->OutStreamHostBuffers - [phm->wObjIndex], &phm->u.d.u.Buffer.dwPciAddress); + err = hpios_locked_mem_get_phys_addr + (&phw->outstream_host_buffers[phm->obj_index], + &phm->u.d.u.buffer.pci_address); /* get the phys addr into msg for single call alloc caller * needs to do this for split alloc (or use the same message) * return the phy address for split alloc in the respose too */ - phr->u.d.u.stream_info.dwAuxiliaryDataAvailable = - phm->u.d.u.Buffer.dwPciAddress; + phr->u.d.u.stream_info.auxiliary_data_available = + phm->u.d.u.buffer.pci_address; if (err) { - HpiOs_LockedMem_Free(&phw->OutStreamHostBuffers[phm-> - wObjIndex]); - phw->OutStreamHostBufferSize[phm->wObjIndex] = 0; - phr->wError = HPI_ERROR_MEMORY_ALLOC; + hpios_locked_mem_free(&phw->outstream_host_buffers + [phm->obj_index]); + phw->outstream_host_buffer_size[phm->obj_index] = 0; + phr->error = HPI_ERROR_MEMORY_ALLOC; return; } } - if (dwCommand == HPI_BUFFER_CMD_EXTERNAL - || dwCommand == HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER) { + if (command == HPI_BUFFER_CMD_EXTERNAL + || command == HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER) { /* GRANT phase. Set up the BBM status, tell the DSP about the buffer so it can start using BBM. */ struct hpi_hostbuffer_status *status; - if (phm->u.d.u.Buffer.dwBufferSize & (phm->u.d.u.Buffer. - dwBufferSize - 1)) { + if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer. + buffer_size - 1)) { HPI_DEBUG_LOG(ERROR, - "Buffer size must be 2^N not %d\n", - phm->u.d.u.Buffer.dwBufferSize); - phr->wError = HPI_ERROR_INVALID_DATASIZE; + "buffer size must be 2^N not %d\n", + phm->u.d.u.buffer.buffer_size); + phr->error = HPI_ERROR_INVALID_DATASIZE; return; } - phw->OutStreamHostBufferSize[phm->wObjIndex] = - phm->u.d.u.Buffer.dwBufferSize; - status = &interface->aOutStreamHostBufferStatus[phm-> - wObjIndex]; - status->dwSamplesProcessed = 0; - status->dwStreamState = HPI_STATE_STOPPED; - status->dwDSPIndex = 0; - status->dwHostIndex = status->dwDSPIndex; - status->dwSizeInBytes = phm->u.d.u.Buffer.dwBufferSize; - - HW_Message(pao, phm, phr); - - if (phr->wError && - HpiOs_LockedMem_Valid(&phw->OutStreamHostBuffers[phm-> - wObjIndex])) { - HpiOs_LockedMem_Free(&phw->OutStreamHostBuffers[phm-> - wObjIndex]); - phw->OutStreamHostBufferSize[phm->wObjIndex] = 0; + phw->outstream_host_buffer_size[phm->obj_index] = + phm->u.d.u.buffer.buffer_size; + status = &interface->outstream_host_buffer_status[phm-> + obj_index]; + status->samples_processed = 0; + status->stream_state = HPI_STATE_STOPPED; + status->dSP_index = 0; + status->host_index = status->dSP_index; + status->size_in_bytes = phm->u.d.u.buffer.buffer_size; + + hw_message(pao, phm, phr); + + if (phr->error + && hpios_locked_mem_valid(&phw-> + outstream_host_buffers[phm->obj_index])) { + hpios_locked_mem_free(&phw->outstream_host_buffers + [phm->obj_index]); + phw->outstream_host_buffer_size[phm->obj_index] = 0; } } } -static void OutStreamHostBufferGetInfo( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void outstream_host_buffer_get_info(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { struct hpi_hw_obj *phw = pao->priv; - struct bus_master_interface *interface = phw->pInterfaceBuffer; + struct bus_master_interface *interface = phw->p_interface_buffer; struct hpi_hostbuffer_status *status; - u8 *pBBMData; - - if (HpiOs_LockedMem_Valid(&phw->OutStreamHostBuffers[phm->wObjIndex])) { - if (HpiOs_LockedMem_GetVirtAddr - (&phw->OutStreamHostBuffers[phm->wObjIndex], - (void *)&pBBMData)) { - phr->wError = HPI_ERROR_INVALID_OPERATION; + u8 *p_bbm_data; + + if (hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> + obj_index])) { + if (hpios_locked_mem_get_virt_addr(&phw-> + outstream_host_buffers[phm->obj_index], + (void *)&p_bbm_data)) { + phr->error = HPI_ERROR_INVALID_OPERATION; return; } - status = &interface->aOutStreamHostBufferStatus[phm-> - wObjIndex]; - HPI_InitResponse(phr, HPI_OBJ_OSTREAM, + status = &interface->outstream_host_buffer_status[phm-> + obj_index]; + hpi_init_response(phr, HPI_OBJ_OSTREAM, HPI_OSTREAM_HOSTBUFFER_GET_INFO, 0); - phr->u.d.u.hostbuffer_info.pBuffer = pBBMData; - phr->u.d.u.hostbuffer_info.pStatus = status; + phr->u.d.u.hostbuffer_info.p_buffer = p_bbm_data; + phr->u.d.u.hostbuffer_info.p_status = status; } else { - HPI_InitResponse(phr, HPI_OBJ_OSTREAM, + hpi_init_response(phr, HPI_OBJ_OSTREAM, HPI_OSTREAM_HOSTBUFFER_GET_INFO, HPI_ERROR_INVALID_OPERATION); } } -static void OutStreamHostBufferFree( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void outstream_host_buffer_free(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { struct hpi_hw_obj *phw = pao->priv; - u32 dwCommand = phm->u.d.u.Buffer.dwCommand; + u32 command = phm->u.d.u.buffer.command; - if (phw->OutStreamHostBufferSize[phm->wObjIndex]) { - if (dwCommand == HPI_BUFFER_CMD_EXTERNAL || - dwCommand == HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER) { - phw->OutStreamHostBufferSize[phm->wObjIndex] = 0; - HW_Message(pao, phm, phr); + if (phw->outstream_host_buffer_size[phm->obj_index]) { + if (command == HPI_BUFFER_CMD_EXTERNAL + || command == HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER) { + phw->outstream_host_buffer_size[phm->obj_index] = 0; + hw_message(pao, phm, phr); /* Tell adapter to stop using the host buffer. */ } - if (dwCommand == HPI_BUFFER_CMD_EXTERNAL || - dwCommand == HPI_BUFFER_CMD_INTERNAL_FREE) - HpiOs_LockedMem_Free(&phw->OutStreamHostBuffers[phm-> - wObjIndex]); + if (command == HPI_BUFFER_CMD_EXTERNAL + || command == HPI_BUFFER_CMD_INTERNAL_FREE) + hpios_locked_mem_free(&phw->outstream_host_buffers + [phm->obj_index]); } /* Should HPI_ERROR_INVALID_OPERATION be returned if no host buffer is allocated? */ else - HPI_InitResponse(phr, HPI_OBJ_OSTREAM, + hpi_init_response(phr, HPI_OBJ_OSTREAM, HPI_OSTREAM_HOSTBUFFER_FREE, 0); } -static long OutStreamGetSpaceAvailable( - struct hpi_hostbuffer_status *status -) +static long outstream_get_space_available(struct hpi_hostbuffer_status + *status) { - return status->dwSizeInBytes - ((long)(status->dwHostIndex) - - (long)(status->dwDSPIndex)); + return status->size_in_bytes - ((long)(status->host_index) - + (long)(status->dSP_index)); } -static void OutStreamWrite( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void outstream_write(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { struct hpi_hw_obj *phw = pao->priv; - struct bus_master_interface *interface = phw->pInterfaceBuffer; + struct bus_master_interface *interface = phw->p_interface_buffer; struct hpi_hostbuffer_status *status; - long dwSpaceAvailable; + long space_available; - if (!phw->OutStreamHostBufferSize[phm->wObjIndex]) { + if (!phw->outstream_host_buffer_size[phm->obj_index]) { /* there is no BBM buffer, write via message */ - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); return; } - HPI_InitResponse(phr, phm->wObject, phm->wFunction, 0); - status = &interface->aOutStreamHostBufferStatus[phm->wObjIndex]; + hpi_init_response(phr, phm->object, phm->function, 0); + status = &interface->outstream_host_buffer_status[phm->obj_index]; - if (phw->flagOStreamJustReset[phm->wObjIndex]) { + if (phw->flag_outstream_just_reset[phm->obj_index]) { /* Format can only change after reset. Must tell DSP. */ - u16 wFunction = phm->wFunction; - phw->flagOStreamJustReset[phm->wObjIndex] = 0; - phm->wFunction = HPI_OSTREAM_SET_FORMAT; - HW_Message(pao, phm, phr); /* send the format to the DSP */ - phm->wFunction = wFunction; - if (phr->wError) + u16 function = phm->function; + phw->flag_outstream_just_reset[phm->obj_index] = 0; + phm->function = HPI_OSTREAM_SET_FORMAT; + hw_message(pao, phm, phr); /* send the format to the DSP */ + phm->function = function; + if (phr->error) return; } #if 1 - if (phw->flagOStreamJustReset[phm->wObjIndex]) { + if (phw->flag_outstream_just_reset[phm->obj_index]) { /* First OutStremWrite() call following reset will write data to the adapter's buffers, reducing delay before stream can start */ - int nPartialWrite = 0; - unsigned int nOriginalSize = 0; + int partial_write = 0; + unsigned int original_size = 0; /* Send the first buffer to the DSP the old way. */ /* Limit size of first transfer - */ /* expect that this will not usually be triggered. */ - if (phm->u.d.u.Data.dwDataSize > HPI6205_SIZEOF_DATA) { - nPartialWrite = 1; - nOriginalSize = phm->u.d.u.Data.dwDataSize; - phm->u.d.u.Data.dwDataSize = HPI6205_SIZEOF_DATA; + if (phm->u.d.u.data.data_size > HPI6205_SIZEOF_DATA) { + partial_write = 1; + original_size = phm->u.d.u.data.data_size; + phm->u.d.u.data.data_size = HPI6205_SIZEOF_DATA; } /* write it */ - phm->wFunction = HPI_OSTREAM_WRITE; - HW_Message(pao, phm, phr); + phm->function = HPI_OSTREAM_WRITE; + hw_message(pao, phm, phr); /* update status information that the DSP would typically * update (and will update next time the DSP * buffer update task reads data from the host BBM buffer) */ - status->dwAuxiliaryDataAvailable = phm->u.d.u.Data.dwDataSize; - status->dwHostIndex += phm->u.d.u.Data.dwDataSize; - status->dwDSPIndex += phm->u.d.u.Data.dwDataSize; + status->auxiliary_data_available = phm->u.d.u.data.data_size; + status->host_index += phm->u.d.u.data.data_size; + status->dSP_index += phm->u.d.u.data.data_size; /* if we did a full write, we can return from here. */ - if (!nPartialWrite) + if (!partial_write) return; /* tweak buffer parameters and let the rest of the */ /* buffer land in internal BBM buffer */ - phm->u.d.u.Data.dwDataSize = - nOriginalSize - HPI6205_SIZEOF_DATA; - phm->u.d.u.Data.pbData += HPI6205_SIZEOF_DATA; + phm->u.d.u.data.data_size = + original_size - HPI6205_SIZEOF_DATA; + phm->u.d.u.data.pb_data += HPI6205_SIZEOF_DATA; } #endif - dwSpaceAvailable = OutStreamGetSpaceAvailable(status); - if (dwSpaceAvailable < (long)phm->u.d.u.Data.dwDataSize) { - phr->wError = HPI_ERROR_INVALID_DATASIZE; + space_available = outstream_get_space_available(status); + if (space_available < (long)phm->u.d.u.data.data_size) { + phr->error = HPI_ERROR_INVALID_DATASIZE; return; } /* HostBuffers is used to indicate host buffer is internally allocated. otherwise, assumed external, data written externally */ - if (phm->u.d.u.Data.pbData && - HpiOs_LockedMem_Valid(&phw->OutStreamHostBuffers[phm-> - wObjIndex])) { - u8 *pBBMData; - long lFirstWrite; - u8 *pAppData = (u8 *)phm->u.d.u.Data.pbData; - - if (HpiOs_LockedMem_GetVirtAddr - (&phw->OutStreamHostBuffers[phm->wObjIndex], - (void *)&pBBMData)) { - phr->wError = HPI_ERROR_INVALID_OPERATION; + if (phm->u.d.u.data.pb_data + && hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> + obj_index])) { + u8 *p_bbm_data; + long l_first_write; + u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; + + if (hpios_locked_mem_get_virt_addr(&phw-> + outstream_host_buffers[phm->obj_index], + (void *)&p_bbm_data)) { + phr->error = HPI_ERROR_INVALID_OPERATION; return; } /* either all data, or enough to fit from current to end of BBM buffer */ - lFirstWrite = min(phm->u.d.u.Data.dwDataSize, - status->dwSizeInBytes - - (status->dwHostIndex & (status->dwSizeInBytes - 1))); - - memcpy(pBBMData + - (status->dwHostIndex & (status->dwSizeInBytes - - 1)), pAppData, lFirstWrite); + l_first_write = + min(phm->u.d.u.data.data_size, + status->size_in_bytes - + (status->host_index & (status->size_in_bytes - 1))); + + memcpy(p_bbm_data + + (status->host_index & (status->size_in_bytes - 1)), + p_app_data, l_first_write); /* remaining data if any */ - memcpy(pBBMData, pAppData + lFirstWrite, - phm->u.d.u.Data.dwDataSize - lFirstWrite); + memcpy(p_bbm_data, p_app_data + l_first_write, + phm->u.d.u.data.data_size - l_first_write); } - status->dwHostIndex += phm->u.d.u.Data.dwDataSize; + status->host_index += phm->u.d.u.data.data_size; } -static void OutStreamGetInfo( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void outstream_get_info(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { struct hpi_hw_obj *phw = pao->priv; - struct bus_master_interface *interface = phw->pInterfaceBuffer; + struct bus_master_interface *interface = phw->p_interface_buffer; struct hpi_hostbuffer_status *status; - if (!phw->OutStreamHostBufferSize[phm->wObjIndex]) { - HW_Message(pao, phm, phr); + if (!phw->outstream_host_buffer_size[phm->obj_index]) { + hw_message(pao, phm, phr); return; } - HPI_InitResponse(phr, phm->wObject, phm->wFunction, 0); + hpi_init_response(phr, phm->object, phm->function, 0); - status = &interface->aOutStreamHostBufferStatus[phm->wObjIndex]; + status = &interface->outstream_host_buffer_status[phm->obj_index]; - phr->u.d.u.stream_info.wState = (u16)status->dwStreamState; - phr->u.d.u.stream_info.dwSamplesTransferred = - status->dwSamplesProcessed; - phr->u.d.u.stream_info.dwBufferSize = status->dwSizeInBytes; - phr->u.d.u.stream_info.dwDataAvailable = - status->dwSizeInBytes - OutStreamGetSpaceAvailable(status); - phr->u.d.u.stream_info.dwAuxiliaryDataAvailable = - status->dwAuxiliaryDataAvailable; + phr->u.d.u.stream_info.state = (u16)status->stream_state; + phr->u.d.u.stream_info.samples_transferred = + status->samples_processed; + phr->u.d.u.stream_info.buffer_size = status->size_in_bytes; + phr->u.d.u.stream_info.data_available = + status->size_in_bytes - outstream_get_space_available(status); + phr->u.d.u.stream_info.auxiliary_data_available = + status->auxiliary_data_available; } -static void OutStreamStart( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void outstream_start(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); } -static void OutStreamReset( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void outstream_reset(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { struct hpi_hw_obj *phw = pao->priv; - phw->flagOStreamJustReset[phm->wObjIndex] = 1; - HW_Message(pao, phm, phr); + phw->flag_outstream_just_reset[phm->obj_index] = 1; + hw_message(pao, phm, phr); } -static void OutStreamOpen( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void outstream_open(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { - OutStreamReset(pao, phm, phr); + outstream_reset(pao, phm, phr); } /*****************************************************************************/ /* InStream Host buffer functions */ -static void InStreamHostBufferAllocate( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { u16 err = 0; - u32 dwCommand = phm->u.d.u.Buffer.dwCommand; + u32 command = phm->u.d.u.buffer.command; struct hpi_hw_obj *phw = pao->priv; - struct bus_master_interface *interface = phw->pInterfaceBuffer; + struct bus_master_interface *interface = phw->p_interface_buffer; - HPI_InitResponse(phr, phm->wObject, phm->wFunction, 0); + hpi_init_response(phr, phm->object, phm->function, 0); - if (dwCommand == HPI_BUFFER_CMD_EXTERNAL || - dwCommand == HPI_BUFFER_CMD_INTERNAL_ALLOC) { + if (command == HPI_BUFFER_CMD_EXTERNAL + || command == HPI_BUFFER_CMD_INTERNAL_ALLOC) { - phm->u.d.u.Buffer.dwBufferSize = - roundup_pow_of_two(phm->u.d.u.Buffer.dwBufferSize); - phr->u.d.u.stream_info.dwDataAvailable = - phw->InStreamHostBufferSize[phm->wObjIndex]; - phr->u.d.u.stream_info.dwBufferSize = - phm->u.d.u.Buffer.dwBufferSize; + phm->u.d.u.buffer.buffer_size = + roundup_pow_of_two(phm->u.d.u.buffer.buffer_size); + phr->u.d.u.stream_info.data_available = + phw->instream_host_buffer_size[phm->obj_index]; + phr->u.d.u.stream_info.buffer_size = + phm->u.d.u.buffer.buffer_size; - if (phw->InStreamHostBufferSize[phm->wObjIndex] == - phm->u.d.u.Buffer.dwBufferSize) { + if (phw->instream_host_buffer_size[phm->obj_index] == + phm->u.d.u.buffer.buffer_size) { /* Same size, no action required */ return; } - if (HpiOs_LockedMem_Valid(&phw->InStreamHostBuffers[phm-> - wObjIndex])) - HpiOs_LockedMem_Free(&phw->InStreamHostBuffers[phm-> - wObjIndex]); + if (hpios_locked_mem_valid(&phw->instream_host_buffers[phm-> + obj_index])) + hpios_locked_mem_free(&phw->instream_host_buffers + [phm->obj_index]); - err = HpiOs_LockedMem_Alloc(&phw->InStreamHostBuffers[phm-> - wObjIndex], phm->u.d.u.Buffer.dwBufferSize, - pao->Pci.pOsData); + err = hpios_locked_mem_alloc(&phw->instream_host_buffers[phm-> + obj_index], phm->u.d.u.buffer.buffer_size, + pao->pci.p_os_data); if (err) { - phr->wError = HPI_ERROR_INVALID_DATASIZE; - phw->InStreamHostBufferSize[phm->wObjIndex] = 0; + phr->error = HPI_ERROR_INVALID_DATASIZE; + phw->instream_host_buffer_size[phm->obj_index] = 0; return; } - err = HpiOs_LockedMem_GetPhysAddr(&phw->InStreamHostBuffers - [phm->wObjIndex], &phm->u.d.u.Buffer.dwPciAddress); + err = hpios_locked_mem_get_phys_addr + (&phw->instream_host_buffers[phm->obj_index], + &phm->u.d.u.buffer.pci_address); /* get the phys addr into msg for single call alloc. Caller needs to do this for split alloc so return the phy address */ - phr->u.d.u.stream_info.dwAuxiliaryDataAvailable = - phm->u.d.u.Buffer.dwPciAddress; + phr->u.d.u.stream_info.auxiliary_data_available = + phm->u.d.u.buffer.pci_address; if (err) { - HpiOs_LockedMem_Free(&phw->InStreamHostBuffers[phm-> - wObjIndex]); - phw->InStreamHostBufferSize[phm->wObjIndex] = 0; - phr->wError = HPI_ERROR_MEMORY_ALLOC; + hpios_locked_mem_free(&phw->instream_host_buffers + [phm->obj_index]); + phw->instream_host_buffer_size[phm->obj_index] = 0; + phr->error = HPI_ERROR_MEMORY_ALLOC; return; } } - if (dwCommand == HPI_BUFFER_CMD_EXTERNAL || - dwCommand == HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER) { + if (command == HPI_BUFFER_CMD_EXTERNAL + || command == HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER) { struct hpi_hostbuffer_status *status; - if (phm->u.d.u.Buffer.dwBufferSize & (phm->u.d.u.Buffer. - dwBufferSize - 1)) { + if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer. + buffer_size - 1)) { HPI_DEBUG_LOG(ERROR, - "Buffer size must be 2^N not %d\n", - phm->u.d.u.Buffer.dwBufferSize); - phr->wError = HPI_ERROR_INVALID_DATASIZE; + "buffer size must be 2^N not %d\n", + phm->u.d.u.buffer.buffer_size); + phr->error = HPI_ERROR_INVALID_DATASIZE; return; } - phw->InStreamHostBufferSize[phm->wObjIndex] = - phm->u.d.u.Buffer.dwBufferSize; - status = &interface->aInStreamHostBufferStatus[phm-> - wObjIndex]; - status->dwSamplesProcessed = 0; - status->dwStreamState = HPI_STATE_STOPPED; - status->dwDSPIndex = 0; - status->dwHostIndex = status->dwDSPIndex; - status->dwSizeInBytes = phm->u.d.u.Buffer.dwBufferSize; - - HW_Message(pao, phm, phr); - if (phr->wError - && HpiOs_LockedMem_Valid(&phw-> - InStreamHostBuffers[phm->wObjIndex])) { - HpiOs_LockedMem_Free(&phw->InStreamHostBuffers[phm-> - wObjIndex]); - phw->InStreamHostBufferSize[phm->wObjIndex] = 0; + phw->instream_host_buffer_size[phm->obj_index] = + phm->u.d.u.buffer.buffer_size; + status = &interface->instream_host_buffer_status[phm-> + obj_index]; + status->samples_processed = 0; + status->stream_state = HPI_STATE_STOPPED; + status->dSP_index = 0; + status->host_index = status->dSP_index; + status->size_in_bytes = phm->u.d.u.buffer.buffer_size; + + hw_message(pao, phm, phr); + if (phr->error + && hpios_locked_mem_valid(&phw-> + instream_host_buffers[phm->obj_index])) { + hpios_locked_mem_free(&phw->instream_host_buffers + [phm->obj_index]); + phw->instream_host_buffer_size[phm->obj_index] = 0; } } } -static void InStreamHostBufferGetInfo( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void instream_host_buffer_get_info(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { struct hpi_hw_obj *phw = pao->priv; - struct bus_master_interface *interface = phw->pInterfaceBuffer; + struct bus_master_interface *interface = phw->p_interface_buffer; struct hpi_hostbuffer_status *status; - u8 *pBBMData; - - if (HpiOs_LockedMem_Valid(&phw->InStreamHostBuffers[phm->wObjIndex])) { - if (HpiOs_LockedMem_GetVirtAddr - (&phw->InStreamHostBuffers[phm->wObjIndex], - (void *)&pBBMData)) { - phr->wError = HPI_ERROR_INVALID_OPERATION; + u8 *p_bbm_data; + + if (hpios_locked_mem_valid(&phw->instream_host_buffers[phm-> + obj_index])) { + if (hpios_locked_mem_get_virt_addr(&phw-> + instream_host_buffers[phm->obj_index], + (void *)&p_bbm_data)) { + phr->error = HPI_ERROR_INVALID_OPERATION; return; } - status = &interface->aInStreamHostBufferStatus[phm-> - wObjIndex]; - HPI_InitResponse(phr, HPI_OBJ_ISTREAM, + status = &interface->instream_host_buffer_status[phm-> + obj_index]; + hpi_init_response(phr, HPI_OBJ_ISTREAM, HPI_ISTREAM_HOSTBUFFER_GET_INFO, 0); - phr->u.d.u.hostbuffer_info.pBuffer = pBBMData; - phr->u.d.u.hostbuffer_info.pStatus = status; + phr->u.d.u.hostbuffer_info.p_buffer = p_bbm_data; + phr->u.d.u.hostbuffer_info.p_status = status; } else { - HPI_InitResponse(phr, HPI_OBJ_ISTREAM, + hpi_init_response(phr, HPI_OBJ_ISTREAM, HPI_ISTREAM_HOSTBUFFER_GET_INFO, HPI_ERROR_INVALID_OPERATION); } } -static void InStreamHostBufferFree( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void instream_host_buffer_free(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { struct hpi_hw_obj *phw = pao->priv; - u32 dwCommand = phm->u.d.u.Buffer.dwCommand; + u32 command = phm->u.d.u.buffer.command; - if (phw->InStreamHostBufferSize[phm->wObjIndex]) { - if (dwCommand == HPI_BUFFER_CMD_EXTERNAL || - dwCommand == HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER) { - phw->InStreamHostBufferSize[phm->wObjIndex] = 0; - HW_Message(pao, phm, phr); + if (phw->instream_host_buffer_size[phm->obj_index]) { + if (command == HPI_BUFFER_CMD_EXTERNAL + || command == HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER) { + phw->instream_host_buffer_size[phm->obj_index] = 0; + hw_message(pao, phm, phr); } - if (dwCommand == HPI_BUFFER_CMD_EXTERNAL || - dwCommand == HPI_BUFFER_CMD_INTERNAL_FREE) - HpiOs_LockedMem_Free(&phw->InStreamHostBuffers[phm-> - wObjIndex]); + if (command == HPI_BUFFER_CMD_EXTERNAL + || command == HPI_BUFFER_CMD_INTERNAL_FREE) + hpios_locked_mem_free(&phw->instream_host_buffers + [phm->obj_index]); } else { /* Should HPI_ERROR_INVALID_OPERATION be returned if no host buffer is allocated? */ - HPI_InitResponse(phr, HPI_OBJ_ISTREAM, + hpi_init_response(phr, HPI_OBJ_ISTREAM, HPI_ISTREAM_HOSTBUFFER_FREE, 0); } } -static void InStreamStart( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void instream_start(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { - HW_Message(pao, phm, phr); + hw_message(pao, phm, phr); } -static long InStreamGetBytesAvailable( - struct hpi_hostbuffer_status *status -) +static long instream_get_bytes_available(struct hpi_hostbuffer_status *status) { - return (long)(status->dwDSPIndex) - (long)(status->dwHostIndex); + return (long)(status->dSP_index) - (long)(status->host_index); } -static void InStreamRead( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void instream_read(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { struct hpi_hw_obj *phw = pao->priv; - struct bus_master_interface *interface = phw->pInterfaceBuffer; + struct bus_master_interface *interface = phw->p_interface_buffer; struct hpi_hostbuffer_status *status; - long dwDataAvailable; - u8 *pBBMData; - long lFirstRead; - u8 *pAppData = (u8 *)phm->u.d.u.Data.pbData; + long data_available; + u8 *p_bbm_data; + long l_first_read; + u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; - if (!phw->InStreamHostBufferSize[phm->wObjIndex]) { - HW_Message(pao, phm, phr); + if (!phw->instream_host_buffer_size[phm->obj_index]) { + hw_message(pao, phm, phr); return; } - HPI_InitResponse(phr, phm->wObject, phm->wFunction, 0); + hpi_init_response(phr, phm->object, phm->function, 0); - status = &interface->aInStreamHostBufferStatus[phm->wObjIndex]; - dwDataAvailable = InStreamGetBytesAvailable(status); - if (dwDataAvailable < (long)phm->u.d.u.Data.dwDataSize) { - phr->wError = HPI_ERROR_INVALID_DATASIZE; + status = &interface->instream_host_buffer_status[phm->obj_index]; + data_available = instream_get_bytes_available(status); + if (data_available < (long)phm->u.d.u.data.data_size) { + phr->error = HPI_ERROR_INVALID_DATASIZE; return; } - if (HpiOs_LockedMem_Valid(&phw->InStreamHostBuffers[phm->wObjIndex])) { - if (HpiOs_LockedMem_GetVirtAddr - (&phw->InStreamHostBuffers[phm->wObjIndex], - (void *)&pBBMData)) { - phr->wError = HPI_ERROR_INVALID_OPERATION; + if (hpios_locked_mem_valid(&phw->instream_host_buffers[phm-> + obj_index])) { + if (hpios_locked_mem_get_virt_addr(&phw-> + instream_host_buffers[phm->obj_index], + (void *)&p_bbm_data)) { + phr->error = HPI_ERROR_INVALID_OPERATION; return; } /* either all data, or enough to fit from current to end of BBM buffer */ - lFirstRead = min(phm->u.d.u.Data.dwDataSize, - status->dwSizeInBytes - - (status->dwHostIndex & (status->dwSizeInBytes - 1))); - - memcpy(pAppData, pBBMData + - (status->dwHostIndex & (status->dwSizeInBytes - - 1)), lFirstRead); + l_first_read = + min(phm->u.d.u.data.data_size, + status->size_in_bytes - + (status->host_index & (status->size_in_bytes - 1))); + + memcpy(p_app_data, + p_bbm_data + + (status->host_index & (status->size_in_bytes - 1)), + l_first_read); /* remaining data if any */ - memcpy(pAppData + lFirstRead, - pBBMData, phm->u.d.u.Data.dwDataSize - lFirstRead); + memcpy(p_app_data + l_first_read, p_bbm_data, + phm->u.d.u.data.data_size - l_first_read); } - status->dwHostIndex += phm->u.d.u.Data.dwDataSize; + status->host_index += phm->u.d.u.data.data_size; } -static void InStreamGetInfo( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void instream_get_info(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { struct hpi_hw_obj *phw = pao->priv; - struct bus_master_interface *interface = phw->pInterfaceBuffer; + struct bus_master_interface *interface = phw->p_interface_buffer; struct hpi_hostbuffer_status *status; - if (!phw->InStreamHostBufferSize[phm->wObjIndex]) { - HW_Message(pao, phm, phr); + if (!phw->instream_host_buffer_size[phm->obj_index]) { + hw_message(pao, phm, phr); return; } - status = &interface->aInStreamHostBufferStatus[phm->wObjIndex]; + status = &interface->instream_host_buffer_status[phm->obj_index]; - HPI_InitResponse(phr, phm->wObject, phm->wFunction, 0); + hpi_init_response(phr, phm->object, phm->function, 0); - phr->u.d.u.stream_info.wState = (u16)status->dwStreamState; - phr->u.d.u.stream_info.dwSamplesTransferred = - status->dwSamplesProcessed; - phr->u.d.u.stream_info.dwBufferSize = status->dwSizeInBytes; - phr->u.d.u.stream_info.dwDataAvailable = - InStreamGetBytesAvailable(status); - phr->u.d.u.stream_info.dwAuxiliaryDataAvailable = - status->dwAuxiliaryDataAvailable; + phr->u.d.u.stream_info.state = (u16)status->stream_state; + phr->u.d.u.stream_info.samples_transferred = + status->samples_processed; + phr->u.d.u.stream_info.buffer_size = status->size_in_bytes; + phr->u.d.u.stream_info.data_available = + instream_get_bytes_available(status); + phr->u.d.u.stream_info.auxiliary_data_available = + status->auxiliary_data_available; } /*****************************************************************************/ /* LOW-LEVEL */ #define HPI6205_MAX_FILES_TO_LOAD 2 -static u16 AdapterBootLoadDsp( - struct hpi_adapter_obj *pao, - u32 *pdwOsErrorCode -) +static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, + u32 *pos_error_code) { struct hpi_hw_obj *phw = pao->priv; - struct dsp_code DspCode; - u16 aBootCodeId[HPI6205_MAX_FILES_TO_LOAD]; - u16 firmware_id = pao->Pci.wSubSysDeviceId; - u32 dwTemp; - int nDsp = 0, i = 0; + struct dsp_code dsp_code; + u16 boot_code_id[HPI6205_MAX_FILES_TO_LOAD]; + u16 firmware_id = pao->pci.subsys_device_id; + u32 temp; + int dsp = 0, i = 0; u16 err = 0; - aBootCodeId[0] = HPI_ADAPTER_ASI(0x6205); + boot_code_id[0] = HPI_ADAPTER_ASI(0x6205); /* special cases where firmware_id != subsys ID */ switch (firmware_id) { case HPI_ADAPTER_FAMILY_ASI(0x5000): - aBootCodeId[0] = firmware_id; + boot_code_id[0] = firmware_id; firmware_id = 0; break; case HPI_ADAPTER_FAMILY_ASI(0x5300): @@ -1494,170 +1370,170 @@ static u16 AdapterBootLoadDsp( firmware_id = HPI_ADAPTER_FAMILY_ASI(0x6600); break; } - aBootCodeId[1] = firmware_id; + boot_code_id[1] = firmware_id; /* reset DSP by writing a 1 to the WARMRESET bit */ - dwTemp = C6205_HDCR_WARMRESET; - iowrite32(dwTemp, phw->prHDCR); - HpiOs_DelayMicroSeconds(1000); + temp = C6205_HDCR_WARMRESET; + iowrite32(temp, phw->prHDCR); + hpios_delay_micro_seconds(1000); /* check that PCI i/f was configured by EEPROM */ - dwTemp = ioread32(phw->prHSR); - if ((dwTemp & (C6205_HSR_CFGERR | C6205_HSR_EEREAD)) != + temp = ioread32(phw->prHSR); + if ((temp & (C6205_HSR_CFGERR | C6205_HSR_EEREAD)) != C6205_HSR_EEREAD) - return Hpi6205_Error(0, HPI6205_ERROR_6205_EEPROM); - dwTemp |= 0x04; + return hpi6205_error(0, HPI6205_ERROR_6205_EEPROM); + temp |= 0x04; /* disable PINTA interrupt */ - iowrite32(dwTemp, phw->prHSR); + iowrite32(temp, phw->prHSR); /* check control register reports PCI boot mode */ - dwTemp = ioread32(phw->prHDCR); - if (!(dwTemp & C6205_HDCR_PCIBOOT)) - return Hpi6205_Error(0, HPI6205_ERROR_6205_REG); + temp = ioread32(phw->prHDCR); + if (!(temp & C6205_HDCR_PCIBOOT)) + return hpi6205_error(0, HPI6205_ERROR_6205_REG); /* try writing a couple of numbers to the DSP page register */ /* and reading them back. */ - dwTemp = 1; - iowrite32(dwTemp, phw->prDSPP); - if ((dwTemp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) - return Hpi6205_Error(0, HPI6205_ERROR_6205_DSPPAGE); - dwTemp = 2; - iowrite32(dwTemp, phw->prDSPP); - if ((dwTemp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) - return Hpi6205_Error(0, HPI6205_ERROR_6205_DSPPAGE); - dwTemp = 3; - iowrite32(dwTemp, phw->prDSPP); - if ((dwTemp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) - return Hpi6205_Error(0, HPI6205_ERROR_6205_DSPPAGE); + temp = 1; + iowrite32(temp, phw->prDSPP); + if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) + return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE); + temp = 2; + iowrite32(temp, phw->prDSPP); + if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) + return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE); + temp = 3; + iowrite32(temp, phw->prDSPP); + if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) + return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE); /* reset DSP page to the correct number */ - dwTemp = 0; - iowrite32(dwTemp, phw->prDSPP); - if ((dwTemp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) - return Hpi6205_Error(0, HPI6205_ERROR_6205_DSPPAGE); - phw->dwDspPage = 0; + temp = 0; + iowrite32(temp, phw->prDSPP); + if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) + return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE); + phw->dsp_page = 0; /* release 6713 from reset before 6205 is bootloaded. This ensures that the EMIF is inactive, and the 6713 HPI gets the correct bootmode etc */ - if (aBootCodeId[1] != 0) { + if (boot_code_id[1] != 0) { /* DSP 1 is a C6713 */ /* CLKX0 <- '1' release the C6205 bootmode pulldowns */ - BootLoader_WriteMem32(pao, 0, (0x018C0024L), 0x00002202); - HpiOs_DelayMicroSeconds(100); + boot_loader_write_mem32(pao, 0, (0x018C0024L), 0x00002202); + hpios_delay_micro_seconds(100); /* Reset the 6713 #1 - revB */ - BootLoader_WriteMem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0); + boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0); /* dummy read every 4 words for 6205 advisory 1.4.4 */ - BootLoader_ReadMem32(pao, 0, 0); + boot_loader_read_mem32(pao, 0, 0); - HpiOs_DelayMicroSeconds(100); + hpios_delay_micro_seconds(100); /* Release C6713 from reset - revB */ - BootLoader_WriteMem32(pao, 0, C6205_BAR0_TIMER1_CTL, 4); - HpiOs_DelayMicroSeconds(100); + boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 4); + hpios_delay_micro_seconds(100); } - for (nDsp = 0; nDsp < HPI6205_MAX_FILES_TO_LOAD; nDsp++) { + for (dsp = 0; dsp < HPI6205_MAX_FILES_TO_LOAD; dsp++) { /* is there a DSP to load? */ - if (aBootCodeId[nDsp] == 0) + if (boot_code_id[dsp] == 0) continue; - err = BootLoader_ConfigEMIF(pao, nDsp); + err = boot_loader_config_emif(pao, dsp); if (err) return (err); - err = BootLoader_TestInternalMemory(pao, nDsp); + err = boot_loader_test_internal_memory(pao, dsp); if (err) return (err); - err = BootLoader_TestExternalMemory(pao, nDsp); + err = boot_loader_test_external_memory(pao, dsp); if (err) return (err); - err = BootLoader_TestPld(pao, nDsp); + err = boot_loader_test_pld(pao, dsp); if (err) return (err); /* write the DSP code down into the DSPs memory */ - DspCode.psDev = pao->Pci.pOsData; - err = HpiDspCode_Open(aBootCodeId[nDsp], - &DspCode, pdwOsErrorCode); + dsp_code.ps_dev = pao->pci.p_os_data; + err = hpi_dsp_code_open(boot_code_id[dsp], &dsp_code, + pos_error_code); if (err) return (err); while (1) { - u32 dwLength; - u32 dwAddress; - u32 dwType; - u32 *pdwCode; + u32 length; + u32 address; + u32 type; + u32 *pcode; - err = HpiDspCode_ReadWord(&DspCode, &dwLength); + err = hpi_dsp_code_read_word(&dsp_code, &length); if (err) break; - if (dwLength == 0xFFFFFFFF) + if (length == 0xFFFFFFFF) break; /* end of code */ - err = HpiDspCode_ReadWord(&DspCode, &dwAddress); + err = hpi_dsp_code_read_word(&dsp_code, &address); if (err) break; - err = HpiDspCode_ReadWord(&DspCode, &dwType); + err = hpi_dsp_code_read_word(&dsp_code, &type); if (err) break; - err = HpiDspCode_ReadBlock(dwLength, &DspCode, - &pdwCode); + err = hpi_dsp_code_read_block(length, &dsp_code, + &pcode); if (err) break; - for (i = 0; i < (int)dwLength; i++) { - err = BootLoader_WriteMem32(pao, nDsp, - dwAddress, *pdwCode); + for (i = 0; i < (int)length; i++) { + err = boot_loader_write_mem32(pao, dsp, + address, *pcode); if (err) break; /* dummy read every 4 words */ /* for 6205 advisory 1.4.4 */ if (i % 4 == 0) - BootLoader_ReadMem32(pao, nDsp, - dwAddress); - pdwCode++; - dwAddress += 4; + boot_loader_read_mem32(pao, dsp, + address); + pcode++; + address += 4; } } if (err) { - HpiDspCode_Close(&DspCode); + hpi_dsp_code_close(&dsp_code); return (err); } /* verify code */ - HpiDspCode_Rewind(&DspCode); + hpi_dsp_code_rewind(&dsp_code); while (1) { - u32 dwLength = 0; - u32 dwAddress = 0; - u32 dwType = 0; - u32 *pdwCode = NULL; - u32 dwData = 0; - - HpiDspCode_ReadWord(&DspCode, &dwLength); - if (dwLength == 0xFFFFFFFF) + u32 length = 0; + u32 address = 0; + u32 type = 0; + u32 *pcode = NULL; + u32 data = 0; + + hpi_dsp_code_read_word(&dsp_code, &length); + if (length == 0xFFFFFFFF) break; /* end of code */ - HpiDspCode_ReadWord(&DspCode, &dwAddress); - HpiDspCode_ReadWord(&DspCode, &dwType); - HpiDspCode_ReadBlock(dwLength, &DspCode, &pdwCode); + hpi_dsp_code_read_word(&dsp_code, &address); + hpi_dsp_code_read_word(&dsp_code, &type); + hpi_dsp_code_read_block(length, &dsp_code, &pcode); - for (i = 0; i < (int)dwLength; i++) { - dwData = BootLoader_ReadMem32(pao, nDsp, - dwAddress); - if (dwData != *pdwCode) { + for (i = 0; i < (int)length; i++) { + data = boot_loader_read_mem32(pao, dsp, + address); + if (data != *pcode) { err = 0; break; } - pdwCode++; - dwAddress += 4; + pcode++; + address += 4; } if (err) break; } - HpiDspCode_Close(&DspCode); + hpi_dsp_code_close(&dsp_code); if (err) return (err); } @@ -1665,47 +1541,47 @@ static u16 AdapterBootLoadDsp( /* After bootloading all DSPs, start DSP0 running * The DSP0 code will handle starting and synchronizing with its slaves */ - if (phw->pInterfaceBuffer) { + if (phw->p_interface_buffer) { /* we need to tell the card the physical PCI address */ - u32 dwPhysicalPCIaddress; + u32 physicalPC_iaddress; struct bus_master_interface *interface = - phw->pInterfaceBuffer; - u32 dwHostMailboxAddressOnDsp; - u32 dwPhysicalPCIaddressVerify = 0; - int nTimeOut = 10; + phw->p_interface_buffer; + u32 host_mailbox_address_on_dsp; + u32 physicalPC_iaddress_verify = 0; + int time_out = 10; /* set ack so we know when DSP is ready to go */ /* (dwDspAck will be changed to HIF_RESET) */ - interface->dwDspAck = H620_HIF_UNKNOWN; + interface->dsp_ack = H620_HIF_UNKNOWN; wmb(); /* ensure ack is written before dsp writes back */ - err = HpiOs_LockedMem_GetPhysAddr(&phw->hLockedMem, - &dwPhysicalPCIaddress); + err = hpios_locked_mem_get_phys_addr(&phw->h_locked_mem, + &physicalPC_iaddress); /* locate the host mailbox on the DSP. */ - dwHostMailboxAddressOnDsp = 0x80000000; - while ((dwPhysicalPCIaddress != dwPhysicalPCIaddressVerify) - && nTimeOut--) { - err = BootLoader_WriteMem32(pao, 0, - dwHostMailboxAddressOnDsp, - dwPhysicalPCIaddress); - dwPhysicalPCIaddressVerify = - BootLoader_ReadMem32(pao, 0, - dwHostMailboxAddressOnDsp); + host_mailbox_address_on_dsp = 0x80000000; + while ((physicalPC_iaddress != physicalPC_iaddress_verify) + && time_out--) { + err = boot_loader_write_mem32(pao, 0, + host_mailbox_address_on_dsp, + physicalPC_iaddress); + physicalPC_iaddress_verify = + boot_loader_read_mem32(pao, 0, + host_mailbox_address_on_dsp); } } - HPI_DEBUG_LOG(DEBUG, "Starting DSPs running\n"); + HPI_DEBUG_LOG(DEBUG, "starting DS_ps running\n"); /* enable interrupts */ - dwTemp = ioread32(phw->prHSR); - dwTemp &= ~(u32)C6205_HSR_INTAM; - iowrite32(dwTemp, phw->prHSR); + temp = ioread32(phw->prHSR); + temp &= ~(u32)C6205_HSR_INTAM; + iowrite32(temp, phw->prHSR); /* start code running... */ - dwTemp = ioread32(phw->prHDCR); - dwTemp |= (u32)C6205_HDCR_DSPINT; - iowrite32(dwTemp, phw->prHDCR); + temp = ioread32(phw->prHDCR); + temp |= (u32)C6205_HDCR_DSPINT; + iowrite32(temp, phw->prHDCR); /* give the DSP 10ms to start up */ - HpiOs_DelayMicroSeconds(10000); + hpios_delay_micro_seconds(10000); return err; } @@ -1713,113 +1589,103 @@ static u16 AdapterBootLoadDsp( /*****************************************************************************/ /* Bootloader utility functions */ -static u32 BootLoader_ReadMem32( - struct hpi_adapter_obj *pao, - int nDSPIndex, - u32 dwAddress -) +static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index, + u32 address) { struct hpi_hw_obj *phw = pao->priv; - u32 dwData = 0; - __iomem u32 *pData; + u32 data = 0; + __iomem u32 *p_data; - if (nDSPIndex == 0) { + if (dsp_index == 0) { /* DSP 0 is always C6205 */ - if ((dwAddress >= 0x01800000) & (dwAddress < 0x02000000)) { + if ((address >= 0x01800000) & (address < 0x02000000)) { /* BAR1 register access */ - pData = pao->Pci.apMemBase[1] + - (dwAddress & 0x007fffff) / - sizeof(*pao->Pci.apMemBase[1]); + p_data = pao->pci.ap_mem_base[1] + + (address & 0x007fffff) / + sizeof(*pao->pci.ap_mem_base[1]); /* HPI_DEBUG_LOG(WARNING, "BAR1 access %08x\n", dwAddress); */ } else { - u32 dw4MPage = dwAddress >> 22L; - if (dw4MPage != phw->dwDspPage) { - phw->dwDspPage = dw4MPage; + u32 dw4M_page = address >> 22L; + if (dw4M_page != phw->dsp_page) { + phw->dsp_page = dw4M_page; /* *INDENT OFF* */ - iowrite32(phw->dwDspPage, phw->prDSPP); + iowrite32(phw->dsp_page, phw->prDSPP); /* *INDENT-ON* */ } - dwAddress &= 0x3fffff; /* address within 4M page */ + address &= 0x3fffff; /* address within 4M page */ /* BAR0 memory access */ - pData = pao->Pci.apMemBase[0] + - dwAddress / sizeof(u32); + p_data = pao->pci.ap_mem_base[0] + + address / sizeof(u32); } - dwData = ioread32(pData); - } else if (nDSPIndex == 1) { + data = ioread32(p_data); + } else if (dsp_index == 1) { /* DSP 1 is a C6713 */ - u32 dwLsb; - BootLoader_WriteMem32(pao, 0, HPIAL_ADDR, dwAddress); - BootLoader_WriteMem32(pao, 0, HPIAH_ADDR, dwAddress >> 16); - dwLsb = BootLoader_ReadMem32(pao, 0, HPIDL_ADDR); - dwData = BootLoader_ReadMem32(pao, 0, HPIDH_ADDR); - dwData = (dwData << 16) | (dwLsb & 0xFFFF); + u32 lsb; + boot_loader_write_mem32(pao, 0, HPIAL_ADDR, address); + boot_loader_write_mem32(pao, 0, HPIAH_ADDR, address >> 16); + lsb = boot_loader_read_mem32(pao, 0, HPIDL_ADDR); + data = boot_loader_read_mem32(pao, 0, HPIDH_ADDR); + data = (data << 16) | (lsb & 0xFFFF); } - return dwData; + return data; } -static u16 BootLoader_WriteMem32( - struct hpi_adapter_obj *pao, - int nDSPIndex, - u32 dwAddress, - u32 dwData -) +static u16 boot_loader_write_mem32(struct hpi_adapter_obj *pao, int dsp_index, + u32 address, u32 data) { struct hpi_hw_obj *phw = pao->priv; u16 err = 0; - __iomem u32 *pData; + __iomem u32 *p_data; /* u32 dwVerifyData=0; */ - if (nDSPIndex == 0) { + if (dsp_index == 0) { /* DSP 0 is always C6205 */ - if ((dwAddress >= 0x01800000) & (dwAddress < 0x02000000)) { + if ((address >= 0x01800000) & (address < 0x02000000)) { /* BAR1 - DSP register access using */ /* Non-prefetchable PCI access */ - pData = pao->Pci.apMemBase[1] + - (dwAddress & 0x007fffff) / - sizeof(*pao->Pci.apMemBase[1]); + p_data = pao->pci.ap_mem_base[1] + + (address & 0x007fffff) / + sizeof(*pao->pci.ap_mem_base[1]); } else { /* BAR0 access - all of DSP memory using */ /* pre-fetchable PCI access */ - u32 dw4MPage = dwAddress >> 22L; - if (dw4MPage != phw->dwDspPage) { - phw->dwDspPage = dw4MPage; + u32 dw4M_page = address >> 22L; + if (dw4M_page != phw->dsp_page) { + phw->dsp_page = dw4M_page; /* *INDENT-OFF* */ - iowrite32(phw->dwDspPage, phw->prDSPP); + iowrite32(phw->dsp_page, phw->prDSPP); /* *INDENT-ON* */ } - dwAddress &= 0x3fffff; /* address within 4M page */ - pData = pao->Pci.apMemBase[0] + - dwAddress / sizeof(u32); + address &= 0x3fffff; /* address within 4M page */ + p_data = pao->pci.ap_mem_base[0] + + address / sizeof(u32); } - iowrite32(dwData, pData); - } else if (nDSPIndex == 1) { + iowrite32(data, p_data); + } else if (dsp_index == 1) { /* DSP 1 is a C6713 */ - BootLoader_WriteMem32(pao, 0, HPIAL_ADDR, dwAddress); - BootLoader_WriteMem32(pao, 0, HPIAH_ADDR, dwAddress >> 16); + boot_loader_write_mem32(pao, 0, HPIAL_ADDR, address); + boot_loader_write_mem32(pao, 0, HPIAH_ADDR, address >> 16); /* dummy read every 4 words for 6205 advisory 1.4.4 */ - BootLoader_ReadMem32(pao, 0, 0); + boot_loader_read_mem32(pao, 0, 0); - BootLoader_WriteMem32(pao, 0, HPIDL_ADDR, dwData); - BootLoader_WriteMem32(pao, 0, HPIDH_ADDR, dwData >> 16); + boot_loader_write_mem32(pao, 0, HPIDL_ADDR, data); + boot_loader_write_mem32(pao, 0, HPIDH_ADDR, data >> 16); /* dummy read every 4 words for 6205 advisory 1.4.4 */ - BootLoader_ReadMem32(pao, 0, 0); + boot_loader_read_mem32(pao, 0, 0); } else - err = Hpi6205_Error(nDSPIndex, HPI6205_ERROR_BAD_DSPINDEX); + err = hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX); return err; } -static u16 BootLoader_ConfigEMIF( - struct hpi_adapter_obj *pao, - int nDSPIndex -) +static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) { u16 err = 0; - if (nDSPIndex == 0) { - u32 dwSetting; + if (dsp_index == 0) { + u32 setting; /* DSP 0 is always C6205 */ @@ -1831,7 +1697,7 @@ static u16 BootLoader_ConfigEMIF( /* EMIF config */ /*------------ */ /* Global EMIF control */ - BootLoader_WriteMem32(pao, nDSPIndex, 0x01800000, 0x3779); + boot_loader_write_mem32(pao, dsp_index, 0x01800000, 0x3779); #define WS_OFS 28 #define WST_OFS 22 #define WH_OFS 20 @@ -1841,102 +1707,104 @@ static u16 BootLoader_ConfigEMIF( #define RH_OFS 0 /* EMIF CE0 setup - 2Mx32 Sync DRAM on ASI5000 cards only */ - dwSetting = 0x00000030; - BootLoader_WriteMem32(pao, nDSPIndex, 0x01800008, dwSetting); - if (dwSetting != BootLoader_ReadMem32(pao, nDSPIndex, + setting = 0x00000030; + boot_loader_write_mem32(pao, dsp_index, 0x01800008, setting); + if (setting != boot_loader_read_mem32(pao, dsp_index, 0x01800008)) - return Hpi6205_Error(nDSPIndex, + return hpi6205_error(dsp_index, HPI6205_ERROR_DSP_EMIF); /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */ /* which occupies D15..0. 6713 starts at 27MHz, so need */ /* plenty of wait states. See dsn8701.rtf, and 6713 errata. */ /* WST should be 71, but 63 is max possible */ - dwSetting = (1L << WS_OFS) | (63L << WST_OFS) | - (1L << WH_OFS) | (1L << RS_OFS) | - (63L << RST_OFS) | (1L << RH_OFS) | (2L << MTYPE_OFS); - BootLoader_WriteMem32(pao, nDSPIndex, 0x01800004, dwSetting); - if (dwSetting != BootLoader_ReadMem32(pao, nDSPIndex, + setting = + (1L << WS_OFS) | (63L << WST_OFS) | (1L << WH_OFS) | + (1L << RS_OFS) | (63L << RST_OFS) | (1L << RH_OFS) | + (2L << MTYPE_OFS); + boot_loader_write_mem32(pao, dsp_index, 0x01800004, setting); + if (setting != boot_loader_read_mem32(pao, dsp_index, 0x01800004)) - return Hpi6205_Error(nDSPIndex, + return hpi6205_error(dsp_index, HPI6205_ERROR_DSP_EMIF); /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */ /* which occupies D15..0. 6713 starts at 27MHz, so need */ /* plenty of wait states */ - dwSetting = (1L << WS_OFS) | - (28L << WST_OFS) | - (1L << WH_OFS) | - (1L << RS_OFS) | - (63L << RST_OFS) | (1L << RH_OFS) | (2L << MTYPE_OFS); - BootLoader_WriteMem32(pao, nDSPIndex, 0x01800010, dwSetting); - if (dwSetting != BootLoader_ReadMem32(pao, nDSPIndex, + setting = + (1L << WS_OFS) | (28L << WST_OFS) | (1L << WH_OFS) | + (1L << RS_OFS) | (63L << RST_OFS) | (1L << RH_OFS) | + (2L << MTYPE_OFS); + boot_loader_write_mem32(pao, dsp_index, 0x01800010, setting); + if (setting != boot_loader_read_mem32(pao, dsp_index, 0x01800010)) - return Hpi6205_Error(nDSPIndex, + return hpi6205_error(dsp_index, HPI6205_ERROR_DSP_EMIF); /* EMIF CE3 setup - 32 bit async. */ /* This is the PLD on the ASI5000 cards only */ - dwSetting = (1L << WS_OFS) | - (10L << WST_OFS) | - (1L << WH_OFS) | - (1L << RS_OFS) | - (10L << RST_OFS) | (1L << RH_OFS) | (2L << MTYPE_OFS); - BootLoader_WriteMem32(pao, nDSPIndex, 0x01800014, dwSetting); - if (dwSetting != BootLoader_ReadMem32(pao, nDSPIndex, + setting = + (1L << WS_OFS) | (10L << WST_OFS) | (1L << WH_OFS) | + (1L << RS_OFS) | (10L << RST_OFS) | (1L << RH_OFS) | + (2L << MTYPE_OFS); + boot_loader_write_mem32(pao, dsp_index, 0x01800014, setting); + if (setting != boot_loader_read_mem32(pao, dsp_index, 0x01800014)) - return Hpi6205_Error(nDSPIndex, + return hpi6205_error(dsp_index, HPI6205_ERROR_DSP_EMIF); /* set EMIF SDRAM control for 2Mx32 SDRAM (512x32x4 bank) */ /* need to use this else DSP code crashes? */ - BootLoader_WriteMem32(pao, nDSPIndex, 0x01800018, 0x07117000); + boot_loader_write_mem32(pao, dsp_index, 0x01800018, + 0x07117000); /* EMIF SDRAM Refresh Timing */ /* EMIF SDRAM timing (orig = 0x410, emulator = 0x61a) */ - BootLoader_WriteMem32(pao, nDSPIndex, 0x0180001C, 0x00000410); + boot_loader_write_mem32(pao, dsp_index, 0x0180001C, + 0x00000410); - } else if (nDSPIndex == 1) { + } else if (dsp_index == 1) { /* test access to the C6713s HPI registers */ - u32 dwWriteData = 0, dwReadData = 0, i = 0; + u32 write_data = 0, read_data = 0, i = 0; /* Set up HPIC for little endian, by setiing HPIC:HWOB=1 */ - dwWriteData = 1; - BootLoader_WriteMem32(pao, 0, HPICL_ADDR, dwWriteData); - BootLoader_WriteMem32(pao, 0, HPICH_ADDR, dwWriteData); + write_data = 1; + boot_loader_write_mem32(pao, 0, HPICL_ADDR, write_data); + boot_loader_write_mem32(pao, 0, HPICH_ADDR, write_data); /* C67 HPI is on lower 16bits of 32bit EMIF */ - dwReadData = 0xFFF7 & BootLoader_ReadMem32(pao, 0, - HPICL_ADDR); - if (dwWriteData != dwReadData) { - err = Hpi6205_Error(nDSPIndex, + read_data = + 0xFFF7 & boot_loader_read_mem32(pao, 0, HPICL_ADDR); + if (write_data != read_data) { + err = hpi6205_error(dsp_index, HPI6205_ERROR_C6713_HPIC); - HPI_DEBUG_LOG(ERROR, - "HPICL %x %x\n", dwWriteData, dwReadData); + HPI_DEBUG_LOG(ERROR, "HPICL %x %x\n", write_data, + read_data); return err; } /* HPIA - walking ones test */ - dwWriteData = 1; + write_data = 1; for (i = 0; i < 32; i++) { - BootLoader_WriteMem32(pao, 0, HPIAL_ADDR, - dwWriteData); - BootLoader_WriteMem32(pao, 0, HPIAH_ADDR, - (dwWriteData >> 16)); - dwReadData = 0xFFFF & BootLoader_ReadMem32(pao, 0, + boot_loader_write_mem32(pao, 0, HPIAL_ADDR, + write_data); + boot_loader_write_mem32(pao, 0, HPIAH_ADDR, + (write_data >> 16)); + read_data = + 0xFFFF & boot_loader_read_mem32(pao, 0, HPIAL_ADDR); - dwReadData = dwReadData | - ((0xFFFF & BootLoader_ReadMem32(pao, - 0, HPIAH_ADDR)) + read_data = + read_data | ((0xFFFF & + boot_loader_read_mem32(pao, 0, + HPIAH_ADDR)) << 16); - if (dwReadData != dwWriteData) { - err = Hpi6205_Error(nDSPIndex, + if (read_data != write_data) { + err = hpi6205_error(dsp_index, HPI6205_ERROR_C6713_HPIA); - HPI_DEBUG_LOG(ERROR, - "HPIA %x %x\n", - dwWriteData, dwReadData); + HPI_DEBUG_LOG(ERROR, "HPIA %x %x\n", + write_data, read_data); return err; } - dwWriteData = dwWriteData << 1; + write_data = write_data << 1; } /* setup C67x PLL @@ -1947,101 +1815,93 @@ static u16 BootLoader_ConfigEMIF( * gives a DSP speed of 189MHz */ /* bypass PLL */ - BootLoader_WriteMem32(pao, nDSPIndex, 0x01B7C100, 0x0000); - HpiOs_DelayMicroSeconds(1000); + boot_loader_write_mem32(pao, dsp_index, 0x01B7C100, 0x0000); + hpios_delay_micro_seconds(1000); /* EMIF = 189/3=63MHz */ - BootLoader_WriteMem32(pao, nDSPIndex, 0x01B7C120, 0x8002); + boot_loader_write_mem32(pao, dsp_index, 0x01B7C120, 0x8002); /* peri = 189/2 */ - BootLoader_WriteMem32(pao, nDSPIndex, 0x01B7C11C, 0x8001); + boot_loader_write_mem32(pao, dsp_index, 0x01B7C11C, 0x8001); /* cpu = 189/1 */ - BootLoader_WriteMem32(pao, nDSPIndex, 0x01B7C118, 0x8000); - HpiOs_DelayMicroSeconds(1000); + boot_loader_write_mem32(pao, dsp_index, 0x01B7C118, 0x8000); + hpios_delay_micro_seconds(1000); /* ** SGT test to take GPO3 high when we start the PLL */ /* and low when the delay is completed */ /* FSX0 <- '1' (GPO3) */ - BootLoader_WriteMem32(pao, 0, (0x018C0024L), 0x00002A0A); + boot_loader_write_mem32(pao, 0, (0x018C0024L), 0x00002A0A); /* PLL not bypassed */ - BootLoader_WriteMem32(pao, nDSPIndex, 0x01B7C100, 0x0001); - HpiOs_DelayMicroSeconds(1000); + boot_loader_write_mem32(pao, dsp_index, 0x01B7C100, 0x0001); + hpios_delay_micro_seconds(1000); /* FSX0 <- '0' (GPO3) */ - BootLoader_WriteMem32(pao, 0, (0x018C0024L), 0x00002A02); + boot_loader_write_mem32(pao, 0, (0x018C0024L), 0x00002A02); /* 6205 EMIF CE1 resetup - 32 bit async. */ /* Now 6713 #1 is running at 189MHz can reduce waitstates */ - BootLoader_WriteMem32(pao, 0, 0x01800004, /* CE1 */ - (1L << WS_OFS) | - (8L << WST_OFS) | - (1L << WH_OFS) | - (1L << RS_OFS) | - (12L << RST_OFS) | - (1L << RH_OFS) | (2L << MTYPE_OFS)); + boot_loader_write_mem32(pao, 0, 0x01800004, /* CE1 */ + (1L << WS_OFS) | (8L << WST_OFS) | (1L << WH_OFS) | + (1L << RS_OFS) | (12L << RST_OFS) | (1L << RH_OFS) | + (2L << MTYPE_OFS)); - HpiOs_DelayMicroSeconds(1000); + hpios_delay_micro_seconds(1000); /* check that we can read one of the PLL registers */ /* PLL should not be bypassed! */ - if ((BootLoader_ReadMem32(pao, nDSPIndex, 0x01B7C100) & 0xF) + if ((boot_loader_read_mem32(pao, dsp_index, 0x01B7C100) & 0xF) != 0x0001) { - err = Hpi6205_Error(nDSPIndex, + err = hpi6205_error(dsp_index, HPI6205_ERROR_C6713_PLL); return err; } /* setup C67x EMIF (note this is the only use of BAR1 via BootLoader_WriteMem32) */ - BootLoader_WriteMem32(pao, nDSPIndex, C6713_EMIF_GCTL, + boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_GCTL, 0x000034A8); - BootLoader_WriteMem32(pao, nDSPIndex, C6713_EMIF_CE0, + boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_CE0, 0x00000030); - BootLoader_WriteMem32(pao, nDSPIndex, C6713_EMIF_SDRAMEXT, + boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMEXT, 0x001BDF29); - BootLoader_WriteMem32(pao, nDSPIndex, C6713_EMIF_SDRAMCTL, + boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMCTL, 0x47117000); - BootLoader_WriteMem32(pao, nDSPIndex, C6713_EMIF_SDRAMTIMING, - 0x00000410); + boot_loader_write_mem32(pao, dsp_index, + C6713_EMIF_SDRAMTIMING, 0x00000410); - HpiOs_DelayMicroSeconds(1000); - } else if (nDSPIndex == 2) { + hpios_delay_micro_seconds(1000); + } else if (dsp_index == 2) { /* DSP 2 is a C6713 */ } else - err = Hpi6205_Error(nDSPIndex, HPI6205_ERROR_BAD_DSPINDEX); + err = hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX); return err; } -static u16 BootLoader_TestMemory( - struct hpi_adapter_obj *pao, - int nDSPIndex, - u32 dwStartAddress, - u32 dwLength -) +static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index, + u32 start_address, u32 length) { u32 i = 0, j = 0; - u32 dwTestAddr = 0; - u32 dwTestData = 0, dwData = 0; + u32 test_addr = 0; + u32 test_data = 0, data = 0; - dwLength = 1000; + length = 1000; /* for 1st word, test each bit in the 32bit word, */ /* dwLength specifies number of 32bit words to test */ /*for(i=0; i<dwLength; i++) */ i = 0; { - dwTestAddr = dwStartAddress + i * 4; - dwTestData = 0x00000001; + test_addr = start_address + i * 4; + test_data = 0x00000001; for (j = 0; j < 32; j++) { - BootLoader_WriteMem32(pao, nDSPIndex, dwTestAddr, - dwTestData); - dwData = BootLoader_ReadMem32(pao, nDSPIndex, - dwTestAddr); - if (dwData != dwTestData) { + boot_loader_write_mem32(pao, dsp_index, test_addr, + test_data); + data = boot_loader_read_mem32(pao, dsp_index, + test_addr); + if (data != test_data) { HPI_DEBUG_LOG(VERBOSE, - "Memtest error details " - "%08x %08x %08x %i\n", - dwTestAddr, dwTestData, - dwData, nDSPIndex); + "memtest error details " + "%08x %08x %08x %i\n", test_addr, + test_data, data, dsp_index); return (1); /* error */ } - dwTestData = dwTestData << 1; + test_data = test_data << 1; } /* for(j) */ } /* for(i) */ @@ -2049,126 +1909,119 @@ static u16 BootLoader_TestMemory( /* write a zero to the next word in memory before we read */ /* the previous write to make sure every memory location is unique */ for (i = 0; i < 100; i++) { - dwTestAddr = dwStartAddress + i * 4; - dwTestData = 0xA5A55A5A; - BootLoader_WriteMem32(pao, nDSPIndex, dwTestAddr, dwTestData); - BootLoader_WriteMem32(pao, nDSPIndex, dwTestAddr + 4, 0); - dwData = BootLoader_ReadMem32(pao, nDSPIndex, dwTestAddr); - if (dwData != dwTestData) { + test_addr = start_address + i * 4; + test_data = 0xA5A55A5A; + boot_loader_write_mem32(pao, dsp_index, test_addr, test_data); + boot_loader_write_mem32(pao, dsp_index, test_addr + 4, 0); + data = boot_loader_read_mem32(pao, dsp_index, test_addr); + if (data != test_data) { HPI_DEBUG_LOG(VERBOSE, - "Memtest error details " - "%08x %08x %08x %i\n", - dwTestAddr, dwTestData, dwData, nDSPIndex); + "memtest error details " + "%08x %08x %08x %i\n", test_addr, test_data, + data, dsp_index); return (1); /* error */ } /* leave location as zero */ - BootLoader_WriteMem32(pao, nDSPIndex, dwTestAddr, 0x0); + boot_loader_write_mem32(pao, dsp_index, test_addr, 0x0); } /* zero out entire memory block */ - for (i = 0; i < dwLength; i++) { - dwTestAddr = dwStartAddress + i * 4; - BootLoader_WriteMem32(pao, nDSPIndex, dwTestAddr, 0x0); + for (i = 0; i < length; i++) { + test_addr = start_address + i * 4; + boot_loader_write_mem32(pao, dsp_index, test_addr, 0x0); } return (0); /*success! */ } -static u16 BootLoader_TestInternalMemory( - struct hpi_adapter_obj *pao, - int nDSPIndex -) +static u16 boot_loader_test_internal_memory(struct hpi_adapter_obj *pao, + int dsp_index) { int err = 0; - if (nDSPIndex == 0) { + if (dsp_index == 0) { /* DSP 0 is a C6205 */ /* 64K prog mem */ - err = BootLoader_TestMemory(pao, nDSPIndex, 0x00000000, + err = boot_loader_test_memory(pao, dsp_index, 0x00000000, 0x10000); if (!err) /* 64K data mem */ - err = BootLoader_TestMemory(pao, nDSPIndex, + err = boot_loader_test_memory(pao, dsp_index, 0x80000000, 0x10000); - } else if ((nDSPIndex == 1) || (nDSPIndex == 2)) { + } else if ((dsp_index == 1) || (dsp_index == 2)) { /* DSP 1&2 are a C6713 */ /* 192K internal mem */ - err = BootLoader_TestMemory(pao, nDSPIndex, 0x00000000, + err = boot_loader_test_memory(pao, dsp_index, 0x00000000, 0x30000); if (!err) /* 64K internal mem / L2 cache */ - err = BootLoader_TestMemory(pao, nDSPIndex, + err = boot_loader_test_memory(pao, dsp_index, 0x00030000, 0x10000); } else - return Hpi6205_Error(nDSPIndex, HPI6205_ERROR_BAD_DSPINDEX); + return hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX); if (err) - return (Hpi6205_Error(nDSPIndex, HPI6205_ERROR_DSP_INTMEM)); + return (hpi6205_error(dsp_index, HPI6205_ERROR_DSP_INTMEM)); else return 0; } -static u16 BootLoader_TestExternalMemory( - struct hpi_adapter_obj *pao, - int nDSPIndex -) +static u16 boot_loader_test_external_memory(struct hpi_adapter_obj *pao, + int dsp_index) { - u32 dwDRAMStartAddress = 0; - u32 dwDRAMSize = 0; + u32 dRAM_start_address = 0; + u32 dRAM_size = 0; - if (nDSPIndex == 0) { + if (dsp_index == 0) { /* only test for SDRAM if an ASI5000 card */ - if (pao->Pci.wSubSysDeviceId == 0x5000) { + if (pao->pci.subsys_device_id == 0x5000) { /* DSP 0 is always C6205 */ - dwDRAMStartAddress = 0x00400000; - dwDRAMSize = 0x200000; + dRAM_start_address = 0x00400000; + dRAM_size = 0x200000; /*dwDRAMinc=1024; */ } else return (0); - } else if ((nDSPIndex == 1) || (nDSPIndex == 2)) { + } else if ((dsp_index == 1) || (dsp_index == 2)) { /* DSP 1 is a C6713 */ - dwDRAMStartAddress = 0x80000000; - dwDRAMSize = 0x200000; + dRAM_start_address = 0x80000000; + dRAM_size = 0x200000; /*dwDRAMinc=1024; */ } else - return Hpi6205_Error(nDSPIndex, HPI6205_ERROR_BAD_DSPINDEX); + return hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX); - if (BootLoader_TestMemory - (pao, nDSPIndex, dwDRAMStartAddress, dwDRAMSize)) - return (Hpi6205_Error(nDSPIndex, HPI6205_ERROR_DSP_EXTMEM)); + if (boot_loader_test_memory(pao, dsp_index, dRAM_start_address, + dRAM_size)) + return (hpi6205_error(dsp_index, HPI6205_ERROR_DSP_EXTMEM)); return 0; } -static u16 BootLoader_TestPld( - struct hpi_adapter_obj *pao, - int nDSPIndex -) +static u16 boot_loader_test_pld(struct hpi_adapter_obj *pao, int dsp_index) { - u32 dwData = 0; - if (nDSPIndex == 0) { + u32 data = 0; + if (dsp_index == 0) { /* only test for DSP0 PLD on ASI5000 card */ - if (pao->Pci.wSubSysDeviceId == 0x5000) { + if (pao->pci.subsys_device_id == 0x5000) { /* PLD is located at CE3=0x03000000 */ - dwData = BootLoader_ReadMem32(pao, nDSPIndex, + data = boot_loader_read_mem32(pao, dsp_index, 0x03000008); - if ((dwData & 0xF) != 0x5) - return (Hpi6205_Error - (nDSPIndex, HPI6205_ERROR_DSP_PLD)); - dwData = BootLoader_ReadMem32(pao, nDSPIndex, + if ((data & 0xF) != 0x5) + return (hpi6205_error(dsp_index, + HPI6205_ERROR_DSP_PLD)); + data = boot_loader_read_mem32(pao, dsp_index, 0x0300000C); - if ((dwData & 0xF) != 0xA) - return (Hpi6205_Error - (nDSPIndex, HPI6205_ERROR_DSP_PLD)); + if ((data & 0xF) != 0xA) + return (hpi6205_error(dsp_index, + HPI6205_ERROR_DSP_PLD)); } - } else if (nDSPIndex == 1) { + } else if (dsp_index == 1) { /* DSP 1 is a C6713 */ - if (pao->Pci.wSubSysDeviceId == 0x8700) { + if (pao->pci.subsys_device_id == 0x8700) { /* PLD is located at CE1=0x90000000 */ - dwData = BootLoader_ReadMem32(pao, nDSPIndex, + data = boot_loader_read_mem32(pao, dsp_index, 0x90000010); - if ((dwData & 0xFF) != 0xAA) - return (Hpi6205_Error - (nDSPIndex, HPI6205_ERROR_DSP_PLD)); + if ((data & 0xFF) != 0xAA) + return (hpi6205_error(dsp_index, + HPI6205_ERROR_DSP_PLD)); /* 8713 - LED on */ - BootLoader_WriteMem32(pao, nDSPIndex, 0x90000000, + boot_loader_write_mem32(pao, dsp_index, 0x90000000, 0x02); } } @@ -2178,80 +2031,75 @@ static u16 BootLoader_TestPld( /** Transfer data to or from DSP nOperation = H620_H620_HIF_SEND_DATA or H620_HIF_GET_DATA */ -static short Hpi6205_TransferData( - struct hpi_adapter_obj *pao, - u8 *pData, - u32 dwDataSize, - int nOperation -) +static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data, + u32 data_size, int operation) { struct hpi_hw_obj *phw = pao->priv; - u32 dwDataTransferred = 0; + u32 data_transferred = 0; u16 err = 0; #ifndef HPI6205_NO_HSR_POLL - u32 dwTimeOut; + u32 time_out; #endif - u32 dwTemp2; - struct bus_master_interface *interface = phw->pInterfaceBuffer; + u32 temp2; + struct bus_master_interface *interface = phw->p_interface_buffer; - if (!pData) + if (!p_data) return HPI_ERROR_INVALID_DATA_TRANSFER; - dwDataSize &= ~3L; /* round dwDataSize down to nearest 4 bytes */ + data_size &= ~3L; /* round data_size down to nearest 4 bytes */ /* make sure state is IDLE */ - if (!WaitDspAck(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) + if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) return HPI_ERROR_DSP_HARDWARE; - while (dwDataTransferred < dwDataSize) { - u32 nThisCopy = dwDataSize - dwDataTransferred; + while (data_transferred < data_size) { + u32 this_copy = data_size - data_transferred; - if (nThisCopy > HPI6205_SIZEOF_DATA) - nThisCopy = HPI6205_SIZEOF_DATA; + if (this_copy > HPI6205_SIZEOF_DATA) + this_copy = HPI6205_SIZEOF_DATA; - if (nOperation == H620_HIF_SEND_DATA) - memcpy((void *)&interface->u.bData[0], - &pData[dwDataTransferred], nThisCopy); + if (operation == H620_HIF_SEND_DATA) + memcpy((void *)&interface->u.b_data[0], + &p_data[data_transferred], this_copy); - interface->dwTransferSizeInBytes = nThisCopy; + interface->transfer_size_in_bytes = this_copy; #ifdef HPI6205_NO_HSR_POLL /* DSP must change this back to nOperation */ - interface->dwDspAck = H620_HIF_IDLE; + interface->dsp_ack = H620_HIF_IDLE; #endif - SendDspCommand(phw, nOperation); + send_dsp_command(phw, operation); #ifdef HPI6205_NO_HSR_POLL - dwTemp2 = WaitDspAck(phw, nOperation, HPI6205_TIMEOUT); - HPI_DEBUG_LOG(DEBUG, "Spun %d times for data xfer of %d\n", - HPI6205_TIMEOUT - dwTemp2, nThisCopy); + temp2 = wait_dsp_ack(phw, operation, HPI6205_TIMEOUT); + HPI_DEBUG_LOG(DEBUG, "spun %d times for data xfer of %d\n", + HPI6205_TIMEOUT - temp2, this_copy); - if (!dwTemp2) { + if (!temp2) { /* timed out */ HPI_DEBUG_LOG(ERROR, - "Timed out waiting for " - "state %d got %d\n", - nOperation, interface->dwDspAck); + "timed out waiting for " "state %d got %d\n", + operation, interface->dsp_ack); break; } #else /* spin waiting on the result */ - dwTimeOut = HPI6205_TIMEOUT; - dwTemp2 = 0; - while ((dwTemp2 == 0) && dwTimeOut--) { + time_out = HPI6205_TIMEOUT; + temp2 = 0; + while ((temp2 == 0) && time_out--) { /* give 16k bus mastering transfer time to happen */ /*(16k / 132Mbytes/s = 122usec) */ - HpiOs_DelayMicroSeconds(20); - dwTemp2 = ioread32(phw->prHSR); - dwTemp2 &= C6205_HSR_INTSRC; + hpios_delay_micro_seconds(20); + temp2 = ioread32(phw->prHSR); + temp2 &= C6205_HSR_INTSRC; } - HPI_DEBUG_LOG(DEBUG, "Spun %d times for data xfer of %d\n", - HPI6205_TIMEOUT - dwTimeOut, nThisCopy); - if (dwTemp2 == C6205_HSR_INTSRC) { + HPI_DEBUG_LOG(DEBUG, "spun %d times for data xfer of %d\n", + HPI6205_TIMEOUT - time_out, this_copy); + if (temp2 == C6205_HSR_INTSRC) { HPI_DEBUG_LOG(VERBOSE, - "Interrupt from HIF <data> OK\n"); + "interrupt from HIF <data> OK\n"); /* if(interface->dwDspAck != nOperation) { HPI_DEBUG_LOG(DEBUG("interface->dwDspAck=%d, @@ -2263,25 +2111,25 @@ static short Hpi6205_TransferData( /* need to handle this differently... */ else { HPI_DEBUG_LOG(ERROR, - "Interrupt from HIF <data> BAD\n"); + "interrupt from HIF <data> BAD\n"); err = HPI_ERROR_DSP_HARDWARE; } /* reset the interrupt from the DSP */ iowrite32(C6205_HSR_INTSRC, phw->prHSR); #endif - if (nOperation == H620_HIF_GET_DATA) - memcpy(&pData[dwDataTransferred], - (void *)&interface->u.bData[0], nThisCopy); + if (operation == H620_HIF_GET_DATA) + memcpy(&p_data[data_transferred], + (void *)&interface->u.b_data[0], this_copy); - dwDataTransferred += nThisCopy; + data_transferred += this_copy; } - if (interface->dwDspAck != nOperation) - HPI_DEBUG_LOG(DEBUG, "interface->dwDspAck=%d, expected %d\n", - interface->dwDspAck, nOperation); + if (interface->dsp_ack != operation) + HPI_DEBUG_LOG(DEBUG, "interface->dsp_ack=%d, expected %d\n", + interface->dsp_ack, operation); /* err=HPI_ERROR_DSP_HARDWARE; */ - SendDspCommand(phw, H620_HIF_IDLE); + send_dsp_command(phw, H620_HIF_IDLE); return err; } @@ -2289,19 +2137,15 @@ static short Hpi6205_TransferData( /* wait for up to timeout_us microseconds for the DSP to signal state by DMA into dwDspAck */ -static int WaitDspAck( - struct hpi_hw_obj *phw, - int state, - int timeout_us -) +static int wait_dsp_ack(struct hpi_hw_obj *phw, int state, int timeout_us) { - struct bus_master_interface *interface = phw->pInterfaceBuffer; + struct bus_master_interface *interface = phw->p_interface_buffer; int t = timeout_us / 4; - rmb(); /* ensure interface->dwDspAck is up to date */ - while ((interface->dwDspAck != state) && --t) { - HpiOs_DelayMicroSeconds(4); - rmb(); /* DSP changes dwDspAck by DMA */ + rmb(); /* ensure interface->dsp_ack is up to date */ + while ((interface->dsp_ack != state) && --t) { + hpios_delay_micro_seconds(4); + rmb(); /* DSP changes dsp_ack by DMA */ } /*HPI_DEBUG_LOG(VERBOSE, "Spun %d for %d\n", timeout_us/4-t, state); */ @@ -2309,16 +2153,13 @@ static int WaitDspAck( } /* set the busmaster interface to cmd, then interrupt the DSP */ -static void SendDspCommand( - struct hpi_hw_obj *phw, - int cmd -) +static void send_dsp_command(struct hpi_hw_obj *phw, int cmd) { - struct bus_master_interface *interface = phw->pInterfaceBuffer; + struct bus_master_interface *interface = phw->p_interface_buffer; u32 r; - interface->dwHostCmd = cmd; + interface->host_cmd = cmd; wmb(); /* DSP gets state by DMA, make sure it is written to memory */ /* before we interrupt the DSP */ r = ioread32(phw->prHDCR); @@ -2328,76 +2169,72 @@ static void SendDspCommand( iowrite32(r, phw->prHDCR); } -static unsigned int messageCount; +static unsigned int message_count; -static u16 MessageResponseSequence( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static u16 message_response_sequence(struct hpi_adapter_obj *pao, + struct hpi_message *phm, struct hpi_response *phr) { #ifndef HPI6205_NO_HSR_POLL - u32 dwTemp2; + u32 temp2; #endif - u32 dwTimeOut, dwTimeOut2; + u32 time_out, time_out2; struct hpi_hw_obj *phw = pao->priv; - struct bus_master_interface *interface = phw->pInterfaceBuffer; + struct bus_master_interface *interface = phw->p_interface_buffer; u16 err = 0; - messageCount++; + message_count++; /* Assume buffer of type struct bus_master_interface is allocated "noncacheable" */ - if (!WaitDspAck(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) { - HPI_DEBUG_LOG(DEBUG, "Timeout waiting for idle\n"); - return (Hpi6205_Error - (0, HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT)); + if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) { + HPI_DEBUG_LOG(DEBUG, "timeout waiting for idle\n"); + return (hpi6205_error(0, + HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT)); } - interface->u.MessageBuffer = *phm; + interface->u.message_buffer = *phm; /* signal we want a response */ - SendDspCommand(phw, H620_HIF_GET_RESP); + send_dsp_command(phw, H620_HIF_GET_RESP); - dwTimeOut2 = WaitDspAck(phw, H620_HIF_GET_RESP, HPI6205_TIMEOUT); + time_out2 = wait_dsp_ack(phw, H620_HIF_GET_RESP, HPI6205_TIMEOUT); - if (dwTimeOut2 == 0) { + if (time_out2 == 0) { HPI_DEBUG_LOG(ERROR, - "(%u) Timed out waiting for " - "GET_RESP state [%x]\n", - messageCount, interface->dwDspAck); + "(%u) timed out waiting for " "GET_RESP state [%x]\n", + message_count, interface->dsp_ack); } else { HPI_DEBUG_LOG(VERBOSE, - "(%u) Transition to GET_RESP after %u\n", - messageCount, HPI6205_TIMEOUT - dwTimeOut2); + "(%u) transition to GET_RESP after %u\n", + message_count, HPI6205_TIMEOUT - time_out2); } /* spin waiting on HIF interrupt flag (end of msg process) */ - dwTimeOut = HPI6205_TIMEOUT; + time_out = HPI6205_TIMEOUT; #ifndef HPI6205_NO_HSR_POLL - dwTemp2 = 0; - while ((dwTemp2 == 0) && --dwTimeOut) { - dwTemp2 = ioread32(phw->prHSR); - dwTemp2 &= C6205_HSR_INTSRC; - HpiOs_DelayMicroSeconds(1); + temp2 = 0; + while ((temp2 == 0) && --time_out) { + temp2 = ioread32(phw->prHSR); + temp2 &= C6205_HSR_INTSRC; + hpios_delay_micro_seconds(1); } - if (dwTemp2 == C6205_HSR_INTSRC) { - rmb(); /* ensure we see latest value for dwDspAck */ - if ((interface->dwDspAck != H620_HIF_GET_RESP)) { + if (temp2 == C6205_HSR_INTSRC) { + rmb(); /* ensure we see latest value for dsp_ack */ + if ((interface->dsp_ack != H620_HIF_GET_RESP)) { HPI_DEBUG_LOG(DEBUG, - "(%u)interface->dwDspAck(0x%x) != " - "H620_HIF_GET_RESP, t=%u\n", - messageCount, interface->dwDspAck, - HPI6205_TIMEOUT - dwTimeOut); + "(%u)interface->dsp_ack(0x%x) != " + "H620_HIF_GET_RESP, t=%u\n", message_count, + interface->dsp_ack, + HPI6205_TIMEOUT - time_out); } else { HPI_DEBUG_LOG(VERBOSE, - "(%u)Int with GET_RESP after %u\n", - messageCount, HPI6205_TIMEOUT - dwTimeOut); + "(%u)int with GET_RESP after %u\n", + message_count, HPI6205_TIMEOUT - time_out); } } else { /* can we do anything else in response to the error ? */ HPI_DEBUG_LOG(ERROR, - "Interrupt from HIF module BAD (wFunction %x)\n", - phm->wFunction); + "interrupt from HIF module BAD (function %x)\n", + phm->function); } /* reset the interrupt from the DSP */ @@ -2405,96 +2242,91 @@ static u16 MessageResponseSequence( #endif /* read the result */ - if (dwTimeOut != 0) - *phr = interface->u.ResponseBuffer; + if (time_out != 0) + *phr = interface->u.response_buffer; /* set interface back to idle */ - SendDspCommand(phw, H620_HIF_IDLE); + send_dsp_command(phw, H620_HIF_IDLE); - if ((dwTimeOut == 0) || (dwTimeOut2 == 0)) { - HPI_DEBUG_LOG(DEBUG, "Something timed out!\n"); - return Hpi6205_Error(0, HPI6205_ERROR_MSG_RESP_TIMEOUT); + if ((time_out == 0) || (time_out2 == 0)) { + HPI_DEBUG_LOG(DEBUG, "something timed out!\n"); + return hpi6205_error(0, HPI6205_ERROR_MSG_RESP_TIMEOUT); } /* special case for adapter close - */ /* wait for the DSP to indicate it is idle */ - if (phm->wFunction == HPI_ADAPTER_CLOSE) { - if (!WaitDspAck(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) { + if (phm->function == HPI_ADAPTER_CLOSE) { + if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) { HPI_DEBUG_LOG(DEBUG, - "Timeout waiting for idle " - "(on AdapterClose)\n"); - return (Hpi6205_Error - (0, HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT)); + "timeout waiting for idle " + "(on adapter_close)\n"); + return (hpi6205_error(0, + HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT)); } } - err = HpiValidateResponse(phm, phr); + err = hpi_validate_response(phm, phr); return err; } -static void HW_Message( - struct hpi_adapter_obj *pao, - struct hpi_message *phm, - struct hpi_response *phr -) +static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, + struct hpi_response *phr) { u16 err = 0; - HpiOs_Dsplock_Lock(pao); + hpios_dsplock_lock(pao); - err = MessageResponseSequence(pao, phm, phr); + err = message_response_sequence(pao, phm, phr); /* maybe an error response */ if (err) { /* something failed in the HPI/DSP interface */ - phr->wError = err; - pao->wDspCrashed++; + phr->error = err; + pao->dsp_crashed++; /* just the header of the response is valid */ - phr->wSize = sizeof(struct hpi_response_header); + phr->size = sizeof(struct hpi_response_header); goto err; } else - pao->wDspCrashed = 0; + pao->dsp_crashed = 0; - if (phr->wError != 0) /* something failed in the DSP */ + if (phr->error != 0) /* something failed in the DSP */ goto err; - switch (phm->wFunction) { + switch (phm->function) { case HPI_OSTREAM_WRITE: case HPI_ISTREAM_ANC_WRITE: - err = Hpi6205_TransferData(pao, - phm->u.d.u.Data.pbData, - phm->u.d.u.Data.dwDataSize, H620_HIF_SEND_DATA); + err = hpi6205_transfer_data(pao, phm->u.d.u.data.pb_data, + phm->u.d.u.data.data_size, H620_HIF_SEND_DATA); break; case HPI_ISTREAM_READ: case HPI_OSTREAM_ANC_READ: - err = Hpi6205_TransferData(pao, - phm->u.d.u.Data.pbData, - phm->u.d.u.Data.dwDataSize, H620_HIF_GET_DATA); + err = hpi6205_transfer_data(pao, phm->u.d.u.data.pb_data, + phm->u.d.u.data.data_size, H620_HIF_GET_DATA); break; case HPI_CONTROL_SET_STATE: - if (phm->wObject == HPI_OBJ_CONTROLEX - && phm->u.cx.wAttribute == HPI_COBRANET_SET_DATA) - err = Hpi6205_TransferData(pao, - phm->u.cx.u.cobranet_bigdata.pbData, - phm->u.cx.u.cobranet_bigdata.dwByteCount, + if (phm->object == HPI_OBJ_CONTROLEX + && phm->u.cx.attribute == HPI_COBRANET_SET_DATA) + err = hpi6205_transfer_data(pao, + phm->u.cx.u.cobranet_bigdata.pb_data, + phm->u.cx.u.cobranet_bigdata.byte_count, H620_HIF_SEND_DATA); break; case HPI_CONTROL_GET_STATE: - if (phm->wObject == HPI_OBJ_CONTROLEX - && phm->u.cx.wAttribute == HPI_COBRANET_GET_DATA) - err = Hpi6205_TransferData(pao, - phm->u.cx.u.cobranet_bigdata.pbData, - phr->u.cx.u.cobranet_data.dwByteCount, + if (phm->object == HPI_OBJ_CONTROLEX + && phm->u.cx.attribute == HPI_COBRANET_GET_DATA) + err = hpi6205_transfer_data(pao, + phm->u.cx.u.cobranet_bigdata.pb_data, + phr->u.cx.u.cobranet_data.byte_count, H620_HIF_GET_DATA); break; } - phr->wError = err; + phr->error = err; err: - HpiOs_Dsplock_UnLock(pao); + hpios_dsplock_unlock(pao); return; } diff --git a/pci/asihpi/hpi6205.h b/pci/asihpi/hpi6205.h index a0c1517b0..8a7476eb0 100644 --- a/pci/asihpi/hpi6205.h +++ b/pci/asihpi/hpi6205.h @@ -54,17 +54,17 @@ Copyright AudioScience, Inc., 2003 This is used for dynamic control cache allocation **********************************************************************/ struct controlcache_6205 { - u32 dwNumberOfControls; - u32 dwPhysicalPCI32address; - u32 dwSizeInBytes; + u32 number_of_controls; + u32 physical_address32; + u32 size_in_bytes; }; /********************************************************************* This is used for dynamic allocation of async event array **********************************************************************/ struct async_event_buffer_6205 { - u32 dwPhysicalPCI32address; - u32 dwSpare; + u32 physical_address32; + u32 spare; struct hpi_fifo_buffer b; }; @@ -74,20 +74,20 @@ in and out of. ************************************************************/ #define HPI6205_SIZEOF_DATA (16*1024) struct bus_master_interface { - u32 dwHostCmd; - u32 dwDspAck; - u32 dwTransferSizeInBytes; + u32 host_cmd; + u32 dsp_ack; + u32 transfer_size_in_bytes; union { - struct hpi_message MessageBuffer; - struct hpi_response ResponseBuffer; - u8 bData[HPI6205_SIZEOF_DATA]; + struct hpi_message message_buffer; + struct hpi_response response_buffer; + u8 b_data[HPI6205_SIZEOF_DATA]; } u; - struct controlcache_6205 aControlCache; - struct async_event_buffer_6205 aAsyncBuffer; + struct controlcache_6205 control_cache; + struct async_event_buffer_6205 async_buffer; struct hpi_hostbuffer_status - aInStreamHostBufferStatus[H620_MAX_ISTREAMS]; + instream_host_buffer_status[H620_MAX_ISTREAMS]; struct hpi_hostbuffer_status - aOutStreamHostBufferStatus[H620_MAX_OSTREAMS]; + outstream_host_buffer_status[H620_MAX_OSTREAMS]; }; #endif diff --git a/pci/asihpi/hpi_internal.h b/pci/asihpi/hpi_internal.h index 6ea091fc3..7ac6c95a2 100644 --- a/pci/asihpi/hpi_internal.h +++ b/pci/asihpi/hpi_internal.h @@ -32,14 +32,12 @@ HPI internal definitions #include "hpios.h" /* physical memory allocation */ -void HpiOs_LockedMem_Init( - void -); -void HpiOs_LockedMem_FreeAll( - void -); -#define HpiOs_LockedMem_Prepare(a, b, c, d); -#define HpiOs_LockedMem_Unprepare(a) +void hpios_locked_mem_init(void + ); +void hpios_locked_mem_free_all(void + ); +#define hpios_locked_mem_prepare(a, b, c, d); +#define hpios_locked_mem_unprepare(a) /** Allocate and map an area of locked memory for bus master DMA operations. @@ -49,12 +47,12 @@ On error *pLockedMemHandle marked invalid, non-zero returned. If this function succeeds, then HpiOs_LockedMem_GetVirtAddr() and HpiOs_LockedMem_GetPyhsAddr() will always succed on the returned handle. */ -u16 HpiOs_LockedMem_Alloc( - struct consistent_dma_area *pLockedMemHandle, /**< memory handle */ - u32 dwSize, /**< Size in bytes to allocate */ - struct pci_dev *pOsReference +u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_locked_mem_handle, + /**< memory handle */ + u32 size, /**< size in bytes to allocate */ + struct pci_dev *p_os_reference /**< OS specific data required for memory allocation */ -); + ); /** Free mapping and memory represented by LockedMemHandle @@ -62,47 +60,34 @@ Frees any resources, then invalidates the handle. Returns 0 on success, 1 if handle is invalid. */ -u16 HpiOs_LockedMem_Free( - struct consistent_dma_area *LockedMemHandle -); +u16 hpios_locked_mem_free(struct consistent_dma_area *locked_mem_handle); /** Get the physical PCI address of memory represented by LockedMemHandle. If handle is invalid *pPhysicalAddr is set to zero and return 1 */ -u16 HpiOs_LockedMem_GetPhysAddr( - struct consistent_dma_area *LockedMemHandle, - u32 *pPhysicalAddr -); +u16 hpios_locked_mem_get_phys_addr(struct consistent_dma_area + *locked_mem_handle, u32 *p_physical_addr); /** Get the CPU address of of memory represented by LockedMemHandle. If handle is NULL *ppvVirtualAddr is set to NULL and return 1 */ -u16 HpiOs_LockedMem_GetVirtAddr( - struct consistent_dma_area *LockedMemHandle, - void **ppvVirtualAddr -); +u16 hpios_locked_mem_get_virt_addr(struct consistent_dma_area + *locked_mem_handle, void **ppv_virtual_addr); /** Check that handle is valid i.e it represents a valid memory area */ -u16 HpiOs_LockedMem_Valid( - struct consistent_dma_area *LockedMemHandle -); +u16 hpios_locked_mem_valid(struct consistent_dma_area *locked_mem_handle); /* timing/delay */ -void HpiOs_DelayMicroSeconds( - u32 dwNumMicroSec -); +void hpios_delay_micro_seconds(u32 num_micro_sec); struct hpi_message; struct hpi_response; -typedef void HPI_HandlerFunc( - struct hpi_message *, - struct hpi_response * -); +typedef void hpi_handler_func(struct hpi_message *, struct hpi_response *); /** init a buffer that can be sized, from a constant 'C'. Note that all the sizeof and conditionals are evaluated at @@ -379,30 +364,30 @@ Used for HPI_ChannelModeSet/Get() /*------------------------------------------------------------ Cobranet Chip Bridge - copied from HMI.H ------------------------------------------------------------*/ -#define HPI_COBRANET_HMI_cobraBridge 0x20000 -#define HPI_COBRANET_HMI_cobraBridgeTxPktBuf \ - (HPI_COBRANET_HMI_cobraBridge + 0x1000) -#define HPI_COBRANET_HMI_cobraBridgeRxPktBuf \ - (HPI_COBRANET_HMI_cobraBridge + 0x2000) -#define HPI_COBRANET_HMI_cobraIfTable1 0x110000 -#define HPI_COBRANET_HMI_cobraIfPhyAddress \ - (HPI_COBRANET_HMI_cobraIfTable1 + 0xd) -#define HPI_COBRANET_HMI_cobraProtocolIP 0x72000 -#define HPI_COBRANET_HMI_cobraIpMonCurrentIP \ - (HPI_COBRANET_HMI_cobraProtocolIP + 0x0) -#define HPI_COBRANET_HMI_cobraIpMonStaticIP \ - (HPI_COBRANET_HMI_cobraProtocolIP + 0x2) -#define HPI_COBRANET_HMI_cobraSys 0x100000 -#define HPI_COBRANET_HMI_cobraSysDesc \ - (HPI_COBRANET_HMI_cobraSys + 0x0) -#define HPI_COBRANET_HMI_cobraSysObjectID \ - (HPI_COBRANET_HMI_cobraSys + 0x100) -#define HPI_COBRANET_HMI_cobraSysContact \ - (HPI_COBRANET_HMI_cobraSys + 0x200) -#define HPI_COBRANET_HMI_cobraSysName \ - (HPI_COBRANET_HMI_cobraSys + 0x300) -#define HPI_COBRANET_HMI_cobraSysLocation \ - (HPI_COBRANET_HMI_cobraSys + 0x400) +#define HPI_COBRANET_HMI_cobra_bridge 0x20000 +#define HPI_COBRANET_HMI_cobra_bridge_tx_pkt_buf \ + (HPI_COBRANET_HMI_cobra_bridge + 0x1000) +#define HPI_COBRANET_HMI_cobra_bridge_rx_pkt_buf \ + (HPI_COBRANET_HMI_cobra_bridge + 0x2000) +#define HPI_COBRANET_HMI_cobra_if_table1 0x110000 +#define HPI_COBRANET_HMI_cobra_if_phy_address \ + (HPI_COBRANET_HMI_cobra_if_table1 + 0xd) +#define HPI_COBRANET_HMI_cobra_protocolIP 0x72000 +#define HPI_COBRANET_HMI_cobra_ip_mon_currentIP \ + (HPI_COBRANET_HMI_cobra_protocolIP + 0x0) +#define HPI_COBRANET_HMI_cobra_ip_mon_staticIP \ + (HPI_COBRANET_HMI_cobra_protocolIP + 0x2) +#define HPI_COBRANET_HMI_cobra_sys 0x100000 +#define HPI_COBRANET_HMI_cobra_sys_desc \ + (HPI_COBRANET_HMI_cobra_sys + 0x0) +#define HPI_COBRANET_HMI_cobra_sys_objectID \ + (HPI_COBRANET_HMI_cobra_sys + 0x100) +#define HPI_COBRANET_HMI_cobra_sys_contact \ + (HPI_COBRANET_HMI_cobra_sys + 0x200) +#define HPI_COBRANET_HMI_cobra_sys_name \ + (HPI_COBRANET_HMI_cobra_sys + 0x300) +#define HPI_COBRANET_HMI_cobra_sys_location \ + (HPI_COBRANET_HMI_cobra_sys + 0x400) /*------------------------------------------------------------ Cobranet Chip Status bits @@ -706,198 +691,198 @@ Threshold is a -ve number in units of dB/100, /** PCI bus resource */ struct hpi_pci { - u32 __iomem *apMemBase[HPI_MAX_ADAPTER_MEM_SPACES]; - struct pci_dev *pOsData; + u32 __iomem *ap_mem_base[HPI_MAX_ADAPTER_MEM_SPACES]; + struct pci_dev *p_os_data; #ifndef HPI64BIT /* keep structure size constant */ - u32 dwPadding[HPI_MAX_ADAPTER_MEM_SPACES + 1]; + u32 padding[HPI_MAX_ADAPTER_MEM_SPACES + 1]; #endif - u16 wVendorId; - u16 wDeviceId; - u16 wSubSysVendorId; - u16 wSubSysDeviceId; - u16 wBusNumber; - u16 wDeviceNumber; - u32 wInterrupt; + u16 vendor_id; + u16 device_id; + u16 subsys_vendor_id; + u16 subsys_device_id; + u16 bus_number; + u16 device_number; + u32 interrupt; }; struct hpi_resource { union { - const struct hpi_pci *Pci; + const struct hpi_pci *pci; const char *net_if; } r; #ifndef HPI64BIT /* keep structure size constant */ - u32 dwPadTo64; + u32 pad_to64; #endif - u16 wBusType; /* HPI_BUS_PNPISA, _PCI, _USB etc */ - u16 wPadding; + u16 bus_type; /* HPI_BUS_PNPISA, _PCI, _USB etc */ + u16 padding; }; /** Format info used inside struct hpi_message Not the same as public API struct hpi_format */ struct hpi_msg_format { - u32 dwSampleRate; + u32 sample_rate; /**< 11025, 32000, 44100 ... */ - u32 dwBitRate; /**< for MPEG */ - u32 dwAttributes; + u32 bit_rate; /**< for MPEG */ + u32 attributes; /**< Stereo/JointStereo/Mono */ - u16 wChannels; /**< 1,2..., (or ancillary mode or idle bit */ - u16 wFormat; /**< HPI_FORMAT_PCM16, _MPEG etc. see \ref HPI_FORMATS. */ + u16 channels; /**< 1,2..., (or ancillary mode or idle bit */ + u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see \ref HPI_FORMATS. */ }; /** Buffer+format structure. Must be kept 7 * 32 bits to match public struct hpi_datastruct */ struct hpi_msg_data { - struct hpi_msg_format Format; - u8 *pbData; + struct hpi_msg_format format; + u8 *pb_data; #ifndef HPI64BIT - u32 dwPadding; + u32 padding; #endif - u32 dwDataSize; + u32 data_size; }; /** struct hpi_datastructure used up to 3.04 driver */ struct hpi_data_legacy32 { - struct hpi_format Format; - u32 pbData; - u32 dwDataSize; + struct hpi_format format; + u32 pb_data; + u32 data_size; }; #ifdef HPI64BIT /* Compatibility version of struct hpi_data*/ struct hpi_data_compat32 { - struct hpi_msg_format Format; - u32 pbData; - u32 dwPadding; - u32 dwDataSize; + struct hpi_msg_format format; + u32 pb_data; + u32 padding; + u32 data_size; }; #endif struct hpi_buffer { /** placehoder for backward compatability (see dwBufferSize) */ struct hpi_msg_format reserved; - u32 dwCommand; /**< HPI_BUFFER_CMD_xxx*/ - u32 dwPciAddress; /**< PCI physical address of buffer for DSP DMA */ - u32 dwBufferSize; /**< must line up with dwDataSize of HPI_DATA*/ + u32 command; /**< HPI_BUFFER_CMD_xxx*/ + u32 pci_address; /**< PCI physical address of buffer for DSP DMA */ + u32 buffer_size; /**< must line up with data_size of HPI_DATA*/ }; /*/////////////////////////////////////////////////////////////////////////// */ /* This is used for background buffer bus mastering stream buffers. */ struct hpi_hostbuffer_status { - u32 dwSamplesProcessed; - u32 dwAuxiliaryDataAvailable; - u32 dwStreamState; + u32 samples_processed; + u32 auxiliary_data_available; + u32 stream_state; /* DSP index in to the host bus master buffer. */ - u32 dwDSPIndex; + u32 dSP_index; /* Host index in to the host bus master buffer. */ - u32 dwHostIndex; - u32 dwSizeInBytes; + u32 host_index; + u32 size_in_bytes; }; struct hpi_streamid { - u16 wObjectType; + u16 object_type; /**< Type of object, HPI_OBJ_OSTREAM or HPI_OBJ_ISTREAM. */ - u16 wStreamIndex; /**< OStream or IStream index. */ + u16 stream_index; /**< outstream or instream index. */ }; struct hpi_punchinout { - u32 dwPunchInSample; - u32 dwPunchOutSample; + u32 punch_in_sample; + u32 punch_out_sample; }; struct hpi_subsys_msg { - struct hpi_resource Resource; + struct hpi_resource resource; }; struct hpi_subsys_res { - u32 dwVersion; - u32 dwData; /* used to return extended version */ - u16 wNumAdapters; /* number of adapters */ - u16 wAdapterIndex; - u16 awAdapterList[HPI_MAX_ADAPTERS]; + u32 version; + u32 data; /* used to return extended version */ + u16 num_adapters; /* number of adapters */ + u16 adapter_index; + u16 aw_adapter_list[HPI_MAX_ADAPTERS]; }; struct hpi_adapter_msg { - u32 dwAdapterMode; /* adapter mode */ - u16 wAssertId; /* assert number for "test assert" call - wObjectIndex for find object call - wQueryOrSet for HPI_AdapterSetModeEx() */ - u16 wObjectType; /* for adapter find object call */ + u32 adapter_mode; /* adapter mode */ + u16 assert_id; /* assert number for "test assert" call + object_index for find object call + query_or_set for hpi_adapter_set_mode_ex() */ + u16 object_type; /* for adapter find object call */ }; union hpi_adapterx_msg { struct hpi_adapter_msg adapter; struct { - u32 dwOffset; + u32 offset; } query_flash; struct { - u32 dwOffset; - u32 dwLength; - u32 dwKey; + u32 offset; + u32 length; + u32 key; } start_flash; struct { - u32 dwChecksum; - u16 wSequence; - u16 wLength; - u16 wOffset; /**< offset from start of msg to data */ - u16 wUnused; + u32 checksum; + u16 sequence; + u16 length; + u16 offset; /**< offset from start of msg to data */ + u16 unused; } program_flash; struct { - u16 wProperty; - u16 wParameter1; - u16 wParameter2; + u16 property; + u16 parameter1; + u16 parameter2; } property_set; struct { - u16 wIndex; - u16 wWhat; - u16 wPropertyIndex; + u16 index; + u16 what; + u16 property_index; } property_enum; struct { u16 index; } module_info; struct { - u32 dwDspAddress; - u32 dwCountBytes; + u32 dsp_address; + u32 count_bytes; } debug_read; }; struct hpi_adapter_res { - u32 dwSerialNumber; - u16 wAdapterType; - u16 wAdapterIndex; /* Is this needed? also used for wDspIndex */ - u16 wNumIStreams; - u16 wNumOStreams; - u16 wNumMixers; - u16 wVersion; - u8 szAdapterAssert[HPI_STRING_LEN]; + u32 serial_number; + u16 adapter_type; + u16 adapter_index; /* is this needed? also used for dsp_index */ + u16 num_instreams; + u16 num_outstreams; + u16 num_mixers; + u16 version; + u8 sz_adapter_assert[HPI_STRING_LEN]; }; union hpi_adapterx_res { struct hpi_adapter_res adapter; struct { - u32 dwChecksum; - u32 dwLength; - u32 dwVersion; + u32 checksum; + u32 length; + u32 version; } query_flash; struct { - u16 wSequence; + u16 sequence; } program_flash; struct { - u16 wParameter1; - u16 wParameter2; + u16 parameter1; + u16 parameter2; } property_get; }; struct hpi_stream_msg { union { - struct hpi_msg_data Data; - struct hpi_data_legacy32 Data32; - u16 wVelocity; - struct hpi_punchinout Pio; - u32 dwTimeScale; - struct hpi_buffer Buffer; - struct hpi_streamid Stream; + struct hpi_msg_data data; + struct hpi_data_legacy32 data32; + u16 velocity; + struct hpi_punchinout pio; + u32 time_scale; + struct hpi_buffer buffer; + struct hpi_streamid stream; } u; }; @@ -905,113 +890,113 @@ struct hpi_stream_res { union { struct { /* size of hardware buffer */ - u32 dwBufferSize; + u32 buffer_size; /* OutStream - data to play, InStream - data recorded */ - u32 dwDataAvailable; + u32 data_available; /* OutStream - samples played, InStream - samples recorded */ - u32 dwSamplesTransferred; + u32 samples_transferred; /* Adapter - OutStream - data to play, InStream - data recorded */ - u32 dwAuxiliaryDataAvailable; - u16 wState; /* HPI_STATE_PLAYING, _STATE_STOPPED */ - u16 wPadding; + u32 auxiliary_data_available; + u16 state; /* HPI_STATE_PLAYING, _STATE_STOPPED */ + u16 padding; } stream_info; struct { - u32 dwBufferSize; - u32 dwDataAvailable; - u32 dwSamplesTransfered; - u16 wState; - u16 wOStreamIndex; - u16 wIStreamIndex; - u16 wPadding; - u32 dwAuxiliaryDataAvailable; + u32 buffer_size; + u32 data_available; + u32 samples_transfered; + u16 state; + u16 outstream_index; + u16 instream_index; + u16 padding; + u32 auxiliary_data_available; } legacy_stream_info; struct { /* bitmap of grouped OutStreams */ - u32 dwOutStreamGroupMap; + u32 outstream_group_map; /* bitmap of grouped InStreams */ - u32 dwInStreamGroupMap; + u32 instream_group_map; } group_info; struct { /* pointer to the buffer */ - u8 *pBuffer; + u8 *p_buffer; /* pointer to the hostbuffer status */ - struct hpi_hostbuffer_status *pStatus; + struct hpi_hostbuffer_status *p_status; } hostbuffer_info; } u; }; struct hpi_mixer_msg { - u16 wControlIndex; - u16 wControlType; /* = HPI_CONTROL_METER _VOLUME etc */ - u16 wPadding1; /* Maintain alignment of subsequent fields */ - u16 wNodeType1; /* = HPI_SOURCENODE_LINEIN etc */ - u16 wNodeIndex1; /* = 0..N */ - u16 wNodeType2; - u16 wNodeIndex2; - u16 wPadding2; /* round to 4 bytes */ + u16 control_index; + u16 control_type; /* = HPI_CONTROL_METER _VOLUME etc */ + u16 padding1; /* maintain alignment of subsequent fields */ + u16 node_type1; /* = HPI_SOURCENODE_LINEIN etc */ + u16 node_index1; /* = 0..N */ + u16 node_type2; + u16 node_index2; + u16 padding2; /* round to 4 bytes */ }; struct hpi_mixer_res { - u16 wSrcNodeType; /* = HPI_SOURCENODE_LINEIN etc */ - u16 wSrcNodeIndex; /* = 0..N */ - u16 wDstNodeType; - u16 wDstNodeIndex; + u16 src_node_type; /* = HPI_SOURCENODE_LINEIN etc */ + u16 src_node_index; /* = 0..N */ + u16 dst_node_type; + u16 dst_node_index; /* Also controlType for MixerGetControlByIndex */ - u16 wControlIndex; + u16 control_index; /* may indicate which DSP the control is located on */ - u16 wDspIndex; + u16 dsp_index; }; union hpi_mixerx_msg { struct { - u16 wStartingIndex; - u16 wFlags; - u32 dwLengthInBytes; /* length in bytes of pData */ - u32 pData; /* pointer to a data array */ + u16 starting_index; + u16 flags; + u32 length_in_bytes; /* length in bytes of p_data */ + u32 p_data; /* pointer to a data array */ } gcabi; struct { - u16 wCommand; - u16 wIndex; + u16 command; + u16 index; } store; /* for HPI_MIXER_STORE message */ }; union hpi_mixerx_res { struct { - u32 dwBytesReturned; /* size of items returned */ - u32 pData; /* pointer to data array */ - u16 wMoreToDo; /* indicates if there is more to do */ + u32 bytes_returned; /* size of items returned */ + u32 p_data; /* pointer to data array */ + u16 more_to_do; /* indicates if there is more to do */ } gcabi; }; struct hpi_control_msg { - u16 wAttribute; /* control attribute or property */ - u16 wSavedIndex; - u32 dwParam1; /* generic parameter 1 */ - u32 dwParam2; /* generic parameter 2 */ - short anLogValue[HPI_MAX_CHANNELS]; + u16 attribute; /* control attribute or property */ + u16 saved_index; + u32 param1; /* generic parameter 1 */ + u32 param2; /* generic parameter 2 */ + short an_log_value[HPI_MAX_CHANNELS]; }; struct hpi_control_union_msg { - u16 wAttribute; /* control attribute or property */ - u16 wSavedIndex; /* Only used in ctrl save/restore */ + u16 attribute; /* control attribute or property */ + u16 saved_index; /* only used in ctrl save/restore */ union { struct { - u32 dwParam1; /* generic parameter 1 */ - u32 dwParam2; /* generic parameter 2 */ - short anLogValue[HPI_MAX_CHANNELS]; + u32 param1; /* generic parameter 1 */ + u32 param2; /* generic parameter 2 */ + short an_log_value[HPI_MAX_CHANNELS]; } old; union { - u32 dwFrequency; - u32 dwGain; - u32 dwBand; - u32 dwDeemphasis; - u32 dwProgram; + u32 frequency; + u32 gain; + u32 band; + u32 deemphasis; + u32 program; struct { - u32 dwMode; - u32 dwValue; + u32 mode; + u32 value; } mode; } tuner; } u; @@ -1019,33 +1004,33 @@ struct hpi_control_union_msg { struct hpi_control_res { /* Could make union. dwParam, anLogValue never used in same response */ - u32 dwParam1; - u32 dwParam2; - short anLogValue[HPI_MAX_CHANNELS]; + u32 param1; + u32 param2; + short an_log_value[HPI_MAX_CHANNELS]; }; union hpi_control_union_res { struct { - u32 dwParam1; - u32 dwParam2; - short anLogValue[HPI_MAX_CHANNELS]; + u32 param1; + u32 param2; + short an_log_value[HPI_MAX_CHANNELS]; } old; union { - u32 dwBand; - u32 dwFrequency; - u32 dwGain; - u32 dwLevel; - u32 dwDeemphasis; + u32 band; + u32 frequency; + u32 gain; + u32 level; + u32 deemphasis; struct { - u32 dwData[2]; - u32 dwBLER; + u32 data[2]; + u32 bLER; } rds; } tuner; struct { - char szData[8]; - u32 dwRemainingChars; + char sz_data[8]; + u32 remaining_chars; } chars8; - char cData12[12]; + char c_data12[12]; }; /* HPI_CONTROLX_STRUCTURES */ @@ -1055,30 +1040,30 @@ union hpi_control_union_res { /** Used for all HMI variables where max length <= 8 bytes */ struct hpi_controlx_msg_cobranet_data { - u32 dwHmiAddress; - u32 dwByteCount; - u32 dwData[2]; + u32 hmi_address; + u32 byte_count; + u32 data[2]; }; /** Used for string data, and for packet bridge */ struct hpi_controlx_msg_cobranet_bigdata { - u32 dwHmiAddress; - u32 dwByteCount; - u8 *pbData; + u32 hmi_address; + u32 byte_count; + u8 *pb_data; #ifndef HPI64BIT - u32 dwPadding; + u32 padding; #endif }; /** Used for PADS control reading of string fields. */ struct hpi_controlx_msg_pad_data { - u32 dwField; - u32 dwByteCount; - u8 *pbData; + u32 field; + u32 byte_count; + u8 *pb_data; #ifndef HPI64BIT - u32 dwPadding; + u32 padding; #endif }; @@ -1086,13 +1071,13 @@ struct hpi_controlx_msg_pad_data { */ struct hpi_controlx_msg_generic { - u32 dwParam1; - u32 dwParam2; + u32 param1; + u32 param2; }; struct hpi_controlx_msg { - u16 wAttribute; /* control attribute or property */ - u16 wSavedIndex; + u16 attribute; /* control attribute or property */ + u16 saved_index; union { struct hpi_controlx_msg_cobranet_data cobranet_data; struct hpi_controlx_msg_cobranet_bigdata cobranet_bigdata; @@ -1107,23 +1092,23 @@ struct hpi_controlx_msg { /** */ struct hpi_controlx_res_cobranet_data { - u32 dwByteCount; - u32 dwData[2]; + u32 byte_count; + u32 data[2]; }; struct hpi_controlx_res_cobranet_bigdata { - u32 dwByteCount; + u32 byte_count; }; struct hpi_controlx_res_cobranet_status { - u32 dwStatus; - u32 dwReadableSize; - u32 dwWriteableSize; + u32 status; + u32 readable_size; + u32 writeable_size; }; struct hpi_controlx_res_generic { - u32 dwParam1; - u32 dwParam2; + u32 param1; + u32 param2; }; struct hpi_controlx_res { @@ -1138,89 +1123,89 @@ struct hpi_controlx_res { }; struct hpi_nvmemory_msg { - u16 wAddress; - u16 wData; + u16 address; + u16 data; }; struct hpi_nvmemory_res { - u16 wSizeInBytes; - u16 wData; + u16 size_in_bytes; + u16 data; }; struct hpi_gpio_msg { - u16 wBitIndex; - u16 wBitData; + u16 bit_index; + u16 bit_data; }; struct hpi_gpio_res { - u16 wNumberInputBits; - u16 wNumberOutputBits; - u16 wBitData[4]; + u16 number_input_bits; + u16 number_output_bits; + u16 bit_data[4]; }; struct hpi_async_msg { - u32 dwEvents; - u16 wMaximumEvents; - u16 wPadding; + u32 events; + u16 maximum_events; + u16 padding; }; struct hpi_async_res { union { struct { - u16 wCount; + u16 count; } count; struct { - u32 dwEvents; - u16 wNumberReturned; - u16 wPadding; + u32 events; + u16 number_returned; + u16 padding; } get; struct hpi_async_event event; } u; }; struct hpi_watchdog_msg { - u32 dwTimeMs; + u32 time_ms; }; struct hpi_watchdog_res { - u32 dwTimeMs; + u32 time_ms; }; struct hpi_clock_msg { - u16 wHours; - u16 wMinutes; - u16 wSeconds; - u16 wMilliSeconds; + u16 hours; + u16 minutes; + u16 seconds; + u16 milli_seconds; }; struct hpi_clock_res { - u16 wSizeInBytes; - u16 wHours; - u16 wMinutes; - u16 wSeconds; - u16 wMilliSeconds; - u16 wPadding; + u16 size_in_bytes; + u16 hours; + u16 minutes; + u16 seconds; + u16 milli_seconds; + u16 padding; }; struct hpi_profile_msg { - u16 wBinIndex; - u16 wPadding; + u16 bin_index; + u16 padding; }; struct hpi_profile_res_open { - u16 wMaxProfiles; + u16 max_profiles; }; struct hpi_profile_res_time { - u32 dwMicroSeconds; - u32 dwCallCount; - u32 dwMaxMicroSeconds; - u32 dwMinMicroSeconds; - u16 wSeconds; + u32 micro_seconds; + u32 call_count; + u32 max_micro_seconds; + u32 min_micro_seconds; + u16 seconds; }; struct hpi_profile_res_name { - u8 szName[32]; + u8 sz_name[32]; }; struct hpi_profile_res { @@ -1232,24 +1217,24 @@ struct hpi_profile_res { }; struct hpi_message_header { - u16 wSize; /* total size in bytes */ - u8 wType; /* HPI_TYPE_MESSAGE */ + u16 size; /* total size in bytes */ + u8 type; /* HPI_TYPE_MESSAGE */ u8 version; /* message version */ - u16 wObject; /* HPI_OBJ_* */ - u16 wFunction; /* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */ - u16 wAdapterIndex; /* the adapter index */ - u16 wObjIndex; /* */ + u16 object; /* HPI_OBJ_* */ + u16 function; /* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */ + u16 adapter_index; /* the adapter index */ + u16 obj_index; /* */ }; struct hpi_message { /* following fields must match HPI_MESSAGE_HEADER */ - u16 wSize; /* total size in bytes */ - u8 wType; /* HPI_TYPE_MESSAGE */ + u16 size; /* total size in bytes */ + u8 type; /* HPI_TYPE_MESSAGE */ u8 version; /* message version */ - u16 wObject; /* HPI_OBJ_* */ - u16 wFunction; /* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */ - u16 wAdapterIndex; /* the adapter index */ - u16 wObjIndex; /* */ + u16 object; /* HPI_OBJ_* */ + u16 function; /* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */ + u16 adapter_index; /* the adapter index */ + u16 obj_index; /* */ union { struct hpi_subsys_msg s; struct hpi_adapter_msg a; @@ -1273,7 +1258,7 @@ struct hpi_message { }; #define HPI_MESSAGE_SIZE_BY_OBJECT { \ - sizeof(struct hpi_message_header) , /* Default, no object type 0 */ \ + sizeof(struct hpi_message_header) , /* default, no object type 0 */ \ sizeof(struct hpi_message_header) + sizeof(struct hpi_subsys_msg),\ sizeof(struct hpi_message_header) + sizeof(union hpi_adapterx_msg),\ sizeof(struct hpi_message_header) + sizeof(struct hpi_stream_msg),\ @@ -1291,24 +1276,24 @@ struct hpi_message { } struct hpi_response_header { - u16 wSize; - u8 wType; /* HPI_TYPE_RESPONSE */ + u16 size; + u8 type; /* HPI_TYPE_RESPONSE */ u8 version; /* response version */ - u16 wObject; /* HPI_OBJ_* */ - u16 wFunction; /* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */ - u16 wError; /* HPI_ERROR_xxx */ - u16 wSpecificError; /* Adapter specific error */ + u16 object; /* HPI_OBJ_* */ + u16 function; /* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */ + u16 error; /* HPI_ERROR_xxx */ + u16 specific_error; /* adapter specific error */ }; struct hpi_response { /* following fields must match HPI_RESPONSE_HEADER */ - u16 wSize; - u8 wType; /* HPI_TYPE_RESPONSE */ + u16 size; + u8 type; /* HPI_TYPE_RESPONSE */ u8 version; /* response version */ - u16 wObject; /* HPI_OBJ_* */ - u16 wFunction; /* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */ - u16 wError; /* HPI_ERROR_xxx */ - u16 wSpecificError; /* Adapter specific error */ + u16 object; /* HPI_OBJ_* */ + u16 function; /* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */ + u16 error; /* HPI_ERROR_xxx */ + u16 specific_error; /* adapter specific error */ union { struct hpi_subsys_res s; struct hpi_adapter_res a; @@ -1331,7 +1316,7 @@ struct hpi_response { }; #define HPI_RESPONSE_SIZE_BY_OBJECT { \ - sizeof(struct hpi_response_header) ,/* Default, no object type 0 */ \ + sizeof(struct hpi_response_header) ,/* default, no object type 0 */ \ sizeof(struct hpi_response_header) + sizeof(struct hpi_subsys_res),\ sizeof(struct hpi_response_header) + sizeof(union hpi_adapterx_res),\ sizeof(struct hpi_response_header) + sizeof(struct hpi_stream_res),\ @@ -1372,7 +1357,7 @@ struct hpi_res_adapter_get_info { /* padding is so these are same size as v0 hpi_message */ struct hpi_msg_adapter_query_flash { struct hpi_message_header h; - u32 dwOffset; + u32 offset; u8 pad_to_version0_size[sizeof(struct hpi_message) - /* V0 res */ sizeof(struct hpi_message_header) - 1 * sizeof(u32)]; }; @@ -1380,18 +1365,18 @@ struct hpi_msg_adapter_query_flash { /* padding is so these are same size as v0 hpi_response */ struct hpi_res_adapter_query_flash { struct hpi_response_header h; - u32 dwChecksum; - u32 dwLength; - u32 dwVersion; + u32 checksum; + u32 length; + u32 version; u8 pad_to_version0_size[sizeof(struct hpi_response) - /* V0 res */ sizeof(struct hpi_response_header) - 3 * sizeof(u32)]; }; struct hpi_msg_adapter_start_flash { struct hpi_message_header h; - u32 dwOffset; - u32 dwLength; - u32 dwKey; + u32 offset; + u32 length; + u32 key; u8 pad_to_version0_size[sizeof(struct hpi_message) - /* V0 res */ sizeof(struct hpi_message_header) - 3 * sizeof(u32)]; }; @@ -1403,16 +1388,16 @@ struct hpi_res_adapter_start_flash { }; struct hpi_msg_adapter_program_flash_payload { - u32 dwChecksum; - u16 wSequence; - u16 wLength; - u16 wOffset; /**< offset from start of msg to data */ - u16 wUnused; + u32 checksum; + u16 sequence; + u16 length; + u16 offset; /**< offset from start of msg to data */ + u16 unused; /* ensure sizeof(header + payload) == sizeof(hpi_message_V0) because old firmware expects data after message of this size */ u8 pad_to_version0_size[sizeof(struct hpi_message) - /* V0 message */ - sizeof(struct hpi_message_header) - - sizeof(u32) - 4 * sizeof(u16)]; + sizeof(struct hpi_message_header) - sizeof(u32) - + 4 * sizeof(u16)]; }; struct hpi_msg_adapter_program_flash { @@ -1423,7 +1408,7 @@ struct hpi_msg_adapter_program_flash { struct hpi_res_adapter_program_flash { struct hpi_response_header h; - u16 wSequence; + u16 sequence; u8 pad_to_version0_size[sizeof(struct hpi_response) - /* V0 res */ sizeof(struct hpi_response_header) - sizeof(u16)]; }; @@ -1442,8 +1427,8 @@ struct hpi_message_header_v1 { struct hpi_response_header_v1 { struct hpi_response_header h0; struct { - u16 wAdapterIndex; /* the adapter index */ - u16 wObjIndex; /* object index */ + u16 adapter_index; /* the adapter index */ + u16 obj_index; /* object index */ } h1; }; #endif @@ -1522,12 +1507,12 @@ compile_time_assert((sizeof(union hpi_response_buffer_v1) <= /*////////////////////////////////////////////////////////////////////////// */ /* declarations for compact control calls */ struct hpi_control_defn { - u8 wType; - u8 wChannels; - u8 wSrcNodeType; - u8 wSrcNodeIndex; - u8 wDestNodeType; - u8 wDestNodeIndex; + u8 type; + u8 channels; + u8 src_node_type; + u8 src_node_index; + u8 dest_node_type; + u8 dest_node_index; }; /*////////////////////////////////////////////////////////////////////////// */ @@ -1539,60 +1524,60 @@ between DSP and host or across a network */ struct hpi_control_cache_info { /** one of HPI_CONTROL_* */ - u8 ControlType; + u8 control_type; /** The total size of cached information in 32-bit words. */ - u8 nSizeIn32bitWords; + u8 size_in32bit_words; /** The original index of the control on the DSP */ - u16 ControlIndex; + u16 control_index; }; struct hpi_control_cache_single { struct hpi_control_cache_info i; union { struct { /* volume */ - u16 anLog[2]; + u16 an_log[2]; } v; struct { /* peak meter */ - u16 anLogPeak[2]; - u16 anLogRMS[2]; + u16 an_log_peak[2]; + u16 an_logRMS[2]; } p; struct { /* channel mode */ - u16 wMode; + u16 mode; } m; struct { /* multiplexer */ - u16 wSourceNodeType; - u16 wSourceNodeIndex; + u16 source_node_type; + u16 source_node_index; } x; struct { /* level/trim */ - u16 anLog[2]; + u16 an_log[2]; } l; struct { /* tuner - partial caching. - Some attributes go to the DSP. */ - u32 dwFreqInkHz; - u16 wBand; - u16 wLevel; + some attributes go to the DSP. */ + u32 freq_ink_hz; + u16 band; + u16 level; } t; - struct { /* AESEBU Rx status */ - u32 dwErrorStatus; - u32 dwSource; + struct { /* AESEBU rx status */ + u32 error_status; + u32 source; } aes3rx; - struct { /* AESEBU Tx */ - u32 dwFormat; + struct { /* AESEBU tx */ + u32 format; } aes3tx; struct { /* tone detector */ - u16 wState; + u16 state; } tone; struct { /* silence detector */ - u32 dwState; - u32 dwCount; + u32 state; + u32 count; } silence; struct { /* sample clock */ - u16 wSource; - u16 wSourceIndex; - u32 dwSampleRate; + u16 source; + u16 source_index; + u32 sample_rate; } clk; struct { /* microphone control */ - u16 wState; + u16 state; } phantom_power; struct { /* generic control */ u32 dw1; @@ -1603,23 +1588,23 @@ struct hpi_control_cache_single { struct hpi_control_cache_pad { struct hpi_control_cache_info i; - u32 dwFieldValidFlags; - u8 cChannel[8]; - u8 cArtist[40]; - u8 cTitle[40]; - u8 cComment[200]; - u32 dwPTY; - u32 dwPI; - u32 dwTrafficSupported; - u32 dwTrafficAnouncement; + u32 field_valid_flags; + u8 c_channel[8]; + u8 c_artist[40]; + u8 c_title[40]; + u8 c_comment[200]; + u32 pTY; + u32 pI; + u32 traffic_supported; + u32 traffic_anouncement; }; /*/////////////////////////////////////////////////////////////////////////// */ /* declarations for 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */ struct hpi_fifo_buffer { - u32 dwSize; - u32 dwDSPIndex; - u32 dwHostIndex; + u32 size; + u32 dSP_index; + u32 host_index; }; #ifndef DISABLE_PRAGMA_PACK1 @@ -1629,63 +1614,39 @@ struct hpi_fifo_buffer { /* skip host side function declarations for DSP compile and documentation extraction */ -char HPI_HandleObject( - const u32 dwHandle -); +char hpi_handle_object(const u32 handle); -void HPI_HandleToIndexes( - const u32 dwHandle, - u16 *pwAdapterIndex, - u16 *pwObjectIndex -); +void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index, + u16 *pw_object_index); -u32 HPI_IndexesToHandle( - const char cObject, - const u16 wAdapterIndex, - const u16 wObjectIndex -); +u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index, + const u16 object_index); /*////////////////////////////////////////////////////////////////////////// */ /* main HPI entry point */ -HPI_HandlerFunc HPI_Message; +hpi_handler_func hpi_send_recv; /* UDP message */ -void HPI_MessageUDP( - struct hpi_message *phm, - struct hpi_response *phr, - const unsigned int nTimeout -); +void hpi_send_recvUDP(struct hpi_message *phm, struct hpi_response *phr, + const unsigned int timeout); /* used in PnP OS/driver */ -u16 HPI_SubSysCreateAdapter( - const struct hpi_hsubsys *phSubSys, - const struct hpi_resource *pResource, - u16 *pwAdapterIndex -); - -u16 HPI_SubSysDeleteAdapter( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex -); - -u16 HPI_OutStreamHostBufferGetInfo( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u8 **ppBuffer, - struct hpi_hostbuffer_status **ppStatus -); - -u16 HPI_InStreamHostBufferGetInfo( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u8 **ppBuffer, - struct hpi_hostbuffer_status **ppStatus -); - -u16 HPI_AdapterRestart( - u16 adapterIndex -); +u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys, + const struct hpi_resource *p_resource, u16 *pw_adapter_index); + +u16 hpi_subsys_delete_adapter(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index); + +u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u8 **pp_buffer, + struct hpi_hostbuffer_status **pp_status); + +u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u8 **pp_buffer, + struct hpi_hostbuffer_status **pp_status); + +u16 hpi_adapter_restart(u16 adapter_index); /* The following 3 functions were last declared in header files for @@ -1694,20 +1655,16 @@ of getting a volume range. Declared here for binary asihpi32.dll compatibility. */ -void HPI_FormatToMsg( - struct hpi_msg_format *pMF, - const struct hpi_format *pF -); -void HPI_StreamResponseToLegacy( - struct hpi_stream_res *pSR -); +void hpi_format_to_msg(struct hpi_msg_format *pMF, + const struct hpi_format *pF); +void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR); /*////////////////////////////////////////////////////////////////////////// */ /* declarations for individual HPI entry points */ -HPI_HandlerFunc HPI_1000; -HPI_HandlerFunc HPI_6000; -HPI_HandlerFunc HPI_6205; -HPI_HandlerFunc HPI_COMMON; +hpi_handler_func HPI_1000; +hpi_handler_func HPI_6000; +hpi_handler_func HPI_6205; +hpi_handler_func HPI_COMMON; #ifdef __cplusplus /* *INDENT-OFF* */ diff --git a/pci/asihpi/hpicmn.c b/pci/asihpi/hpicmn.c index 012fd0f1f..f4efea4b6 100644 --- a/pci/asihpi/hpicmn.c +++ b/pci/asihpi/hpicmn.c @@ -29,9 +29,9 @@ #include "hpicmn.h" struct hpi_adapters_list { - struct hpios_spinlock aListLock; + struct hpios_spinlock list_lock; struct hpi_adapter_obj adapter[HPI_MAX_ADAPTERS]; - u16 gwNumAdapters; + u16 gw_num_adapters; }; static struct hpi_adapters_list adapters; @@ -41,59 +41,52 @@ static struct hpi_adapters_list adapters; * validate that the response has the correct fields filled in, * i.e ObjectType, Function etc **/ -u16 HpiValidateResponse( - struct hpi_message *phm, - struct hpi_response *phr -) +u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr) { - u16 wError = 0; + u16 error = 0; - if ((phr->wType != HPI_TYPE_RESPONSE) - || (phr->wObject != phm->wObject) - || (phr->wFunction != phm->wFunction)) - wError = HPI_ERROR_INVALID_RESPONSE; + if ((phr->type != HPI_TYPE_RESPONSE) + || (phr->object != phm->object) + || (phr->function != phm->function)) + error = HPI_ERROR_INVALID_RESPONSE; - return wError; + return error; } -u16 HpiAddAdapter( - struct hpi_adapter_obj *pao -) +u16 hpi_add_adapter(struct hpi_adapter_obj *pao) { u16 retval = 0; /*HPI_ASSERT(pao->wAdapterType); */ - HpiOs_Alistlock_Lock(&adapters); + hpios_alistlock_lock(&adapters); - if (pao->wIndex >= HPI_MAX_ADAPTERS) { + if (pao->index >= HPI_MAX_ADAPTERS) { retval = HPI_ERROR_BAD_ADAPTER_NUMBER; goto unlock; } - if (adapters.adapter[pao->wIndex].wAdapterType) { + if (adapters.adapter[pao->index].adapter_type) { { retval = HPI_DUPLICATE_ADAPTER_NUMBER; goto unlock; } } - adapters.adapter[pao->wIndex] = *pao; - HpiOs_Dsplock_Init(&adapters.adapter[pao->wIndex]); - adapters.gwNumAdapters++; + adapters.adapter[pao->index] = *pao; + hpios_dsplock_init(&adapters.adapter[pao->index]); + adapters.gw_num_adapters++; unlock: - HpiOs_Alistlock_UnLock(&adapters); + hpios_alistlock_un_lock(&adapters); return retval; } -void HpiDeleteAdapter( - struct hpi_adapter_obj *pao -) +void hpi_delete_adapter(struct hpi_adapter_obj *pao) { memset(pao, 0, sizeof(struct hpi_adapter_obj)); - HpiOs_Alistlock_Lock(&adapters); - adapters.gwNumAdapters--; /* dec the number of adapters */ - HpiOs_Alistlock_UnLock(&adapters); + hpios_alistlock_lock(&adapters); + adapters.gw_num_adapters--; /* dec the number of adapters */ + hpios_alistlock_un_lock(&adapters); } /** @@ -101,20 +94,18 @@ void HpiDeleteAdapter( * index wAdapterIndex in an HPI_ADAPTERS_LIST structure. * */ -struct hpi_adapter_obj *HpiFindAdapter( - u16 wAdapterIndex -) +struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index) { struct hpi_adapter_obj *pao = NULL; - if (wAdapterIndex >= HPI_MAX_ADAPTERS) { - HPI_DEBUG_LOG(VERBOSE, - "FindAdapter invalid index %d ", wAdapterIndex); + if (adapter_index >= HPI_MAX_ADAPTERS) { + HPI_DEBUG_LOG(VERBOSE, "find_adapter invalid index %d ", + adapter_index); return NULL; } - pao = &adapters.adapter[wAdapterIndex]; - if (pao->wAdapterType != 0) { + pao = &adapters.adapter[adapter_index]; + if (pao->adapter_type != 0) { /* HPI_DEBUG_LOG(VERBOSE, "Found adapter index %d\n", wAdapterIndex); @@ -134,9 +125,8 @@ struct hpi_adapter_obj *HpiFindAdapter( * wipe an HPI_ADAPTERS_LIST structure. * **/ -static void WipeAdapterList( - void -) +static void wipe_adapter_list(void + ) { memset(&adapters, 0, sizeof(adapters)); } @@ -146,9 +136,7 @@ static void WipeAdapterList( * with all adapters in the given HPI_ADAPTERS_LIST. * */ -static void SubSysGetAdapters( - struct hpi_response *phr -) +static void subsys_get_adapters(struct hpi_response *phr) { /* fill in the response adapter array with the position */ /* identified by the adapter number/index of the adapters in */ @@ -166,123 +154,113 @@ static void SubSysGetAdapters( short i; struct hpi_adapter_obj *pao = NULL; - HPI_DEBUG_LOG(VERBOSE, "SubSysGetAdapters\n"); + HPI_DEBUG_LOG(VERBOSE, "subsys_get_adapters\n"); /* for each adapter, place it's type in the position of the array */ /* corresponding to it's adapter number */ - for (i = 0; i < adapters.gwNumAdapters; i++) { + for (i = 0; i < adapters.gw_num_adapters; i++) { pao = &adapters.adapter[i]; - if (phr->u.s.awAdapterList[pao->wIndex] != 0) { - phr->wError = HPI_DUPLICATE_ADAPTER_NUMBER; - phr->wSpecificError = pao->wIndex; + if (phr->u.s.aw_adapter_list[pao->index] != 0) { + phr->error = HPI_DUPLICATE_ADAPTER_NUMBER; + phr->specific_error = pao->index; return; } - phr->u.s.awAdapterList[pao->wIndex] = pao->wAdapterType; + phr->u.s.aw_adapter_list[pao->index] = pao->adapter_type; } - phr->u.s.wNumAdapters = adapters.gwNumAdapters; - phr->wError = 0; /* the function completed OK; */ + phr->u.s.num_adapters = adapters.gw_num_adapters; + phr->error = 0; /* the function completed OK; */ } -static unsigned int ControlCacheAllocCheck( - struct hpi_control_cache *pC -) +static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC) { unsigned int i; - int nCached = 0; + int cached = 0; if (!pC) return 0; - if ((!pC->dwInit) && - (pC->pCache != NULL) && - (pC->dwControlCount) && (pC->dwCacheSizeInBytes) + if ((!pC->init) && (pC->p_cache != NULL) && (pC->control_count) + && (pC->cache_size_in_bytes) ) { - u32 *pMasterCache; - pC->dwInit = 1; + u32 *p_master_cache; + pC->init = 1; - pMasterCache = (u32 *)pC->pCache; + p_master_cache = (u32 *)pC->p_cache; HPI_DEBUG_LOG(VERBOSE, "check %d controls\n", - pC->dwControlCount); - for (i = 0; i < pC->dwControlCount; i++) { + pC->control_count); + for (i = 0; i < pC->control_count; i++) { struct hpi_control_cache_info *info = - (struct hpi_control_cache_info *)pMasterCache; + (struct hpi_control_cache_info *) + p_master_cache; - if (info->ControlType) { - pC->pInfo[i] = info; - nCached++; + if (info->control_type) { + pC->p_info[i] = info; + cached++; } else - pC->pInfo[i] = NULL; + pC->p_info[i] = NULL; - if (info->nSizeIn32bitWords) - pMasterCache += info->nSizeIn32bitWords; + if (info->size_in32bit_words) + p_master_cache += info->size_in32bit_words; else - pMasterCache += + p_master_cache += sizeof(struct hpi_control_cache_single) / sizeof(u32); HPI_DEBUG_LOG(VERBOSE, - "nCached %d, pinfo %p index %d type %d\n", - nCached, pC->pInfo[i], info->ControlIndex, - info->ControlType); + "cached %d, pinfo %p index %d type %d\n", + cached, pC->p_info[i], info->control_index, + info->control_type); } /* We didn't find anything to cache, so try again later ! */ - if (!nCached) - pC->dwInit = 0; + if (!cached) + pC->init = 0; } - return pC->dwInit; + return pC->init; } /** Find a control. */ -static short FindControl( - struct hpi_message *phm, - struct hpi_control_cache *pCache, - struct hpi_control_cache_info **pI, - u16 *pwControlIndex -) +static short find_control(struct hpi_message *phm, + struct hpi_control_cache *p_cache, struct hpi_control_cache_info **pI, + u16 *pw_control_index) { - *pwControlIndex = phm->wObjIndex; + *pw_control_index = phm->obj_index; - if (!ControlCacheAllocCheck(pCache)) { + if (!control_cache_alloc_check(p_cache)) { HPI_DEBUG_LOG(VERBOSE, - "ControlCacheAllocCheck() failed. adap%d ci%d\n", - phm->wAdapterIndex, *pwControlIndex); + "control_cache_alloc_check() failed. adap%d ci%d\n", + phm->adapter_index, *pw_control_index); return 0; } - *pI = pCache->pInfo[*pwControlIndex]; + *pI = p_cache->p_info[*pw_control_index]; if (!*pI) { - HPI_DEBUG_LOG(VERBOSE, - "Uncached Adap %d, Control %d\n", - phm->wAdapterIndex, *pwControlIndex); + HPI_DEBUG_LOG(VERBOSE, "uncached adap %d, control %d\n", + phm->adapter_index, *pw_control_index); return 0; } else { - HPI_DEBUG_LOG(VERBOSE, - "FindControl() Type %d\n", (*pI)->ControlType); + HPI_DEBUG_LOG(VERBOSE, "find_control() type %d\n", + (*pI)->control_type); } return 1; } /** Used by the kernel driver to figure out if a buffer needs mapping. */ -short HpiCheckBufferMapping( - struct hpi_control_cache *pCache, - struct hpi_message *phm, - void **p, - unsigned int *pN -) +short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache, + struct hpi_message *phm, void **p, unsigned int *pN) { *pN = 0; *p = NULL; - if ((phm->wFunction == HPI_CONTROL_GET_STATE) && - (phm->wObject == HPI_OBJ_CONTROLEX) + if ((phm->function == HPI_CONTROL_GET_STATE) + && (phm->object == HPI_OBJ_CONTROLEX) ) { - u16 wControlIndex; + u16 control_index; struct hpi_control_cache_info *pI; - if (!FindControl(phm, pCache, &pI, &wControlIndex)) + if (!find_control(phm, p_cache, &pI, &control_index)) return 0; } return 0; @@ -298,76 +276,73 @@ struct pad_ofs_size { unsigned int field_size; }; -static struct pad_ofs_size aPadDesc[] = { - HPICMN_PAD_OFS_AND_SIZE(cChannel), /* HPI_PAD_CHANNEL_NAME */ - HPICMN_PAD_OFS_AND_SIZE(cArtist), /* HPI_PAD_ARTIST */ - HPICMN_PAD_OFS_AND_SIZE(cTitle), /* HPI_PAD_TITLE */ - HPICMN_PAD_OFS_AND_SIZE(cComment), /* HPI_PAD_COMMENT */ +static struct pad_ofs_size pad_desc[] = { + HPICMN_PAD_OFS_AND_SIZE(c_channel), /* HPI_PAD_CHANNEL_NAME */ + HPICMN_PAD_OFS_AND_SIZE(c_artist), /* HPI_PAD_ARTIST */ + HPICMN_PAD_OFS_AND_SIZE(c_title), /* HPI_PAD_TITLE */ + HPICMN_PAD_OFS_AND_SIZE(c_comment), /* HPI_PAD_COMMENT */ }; /** CheckControlCache checks the cache and fills the struct hpi_response * accordingly. It returns one if a cache hit occurred, zero otherwise. */ -short HpiCheckControlCache( - struct hpi_control_cache *pCache, - struct hpi_message *phm, - struct hpi_response *phr -) +short hpi_check_control_cache(struct hpi_control_cache *p_cache, + struct hpi_message *phm, struct hpi_response *phr) { short found = 1; - u16 wControlIndex; + u16 control_index; struct hpi_control_cache_info *pI; struct hpi_control_cache_single *pC; - struct hpi_control_cache_pad *pPad; + struct hpi_control_cache_pad *p_pad; - if (!FindControl(phm, pCache, &pI, &wControlIndex)) + if (!find_control(phm, p_cache, &pI, &control_index)) return 0; - phr->wError = 0; + phr->error = 0; /* pC is the default cached control strucure. May be cast to something else in the following switch statement. */ pC = (struct hpi_control_cache_single *)pI; - pPad = (struct hpi_control_cache_pad *)pI; + p_pad = (struct hpi_control_cache_pad *)pI; - switch (pI->ControlType) { + switch (pI->control_type) { case HPI_CONTROL_METER: - if (phm->u.c.wAttribute == HPI_METER_PEAK) { - phr->u.c.anLogValue[0] = pC->u.p.anLogPeak[0]; - phr->u.c.anLogValue[1] = pC->u.p.anLogPeak[1]; - } else if (phm->u.c.wAttribute == HPI_METER_RMS) { - phr->u.c.anLogValue[0] = pC->u.p.anLogRMS[0]; - phr->u.c.anLogValue[1] = pC->u.p.anLogRMS[1]; + if (phm->u.c.attribute == HPI_METER_PEAK) { + phr->u.c.an_log_value[0] = pC->u.p.an_log_peak[0]; + phr->u.c.an_log_value[1] = pC->u.p.an_log_peak[1]; + } else if (phm->u.c.attribute == HPI_METER_RMS) { + phr->u.c.an_log_value[0] = pC->u.p.an_logRMS[0]; + phr->u.c.an_log_value[1] = pC->u.p.an_logRMS[1]; } else found = 0; break; case HPI_CONTROL_VOLUME: - if (phm->u.c.wAttribute == HPI_VOLUME_GAIN) { - phr->u.c.anLogValue[0] = pC->u.v.anLog[0]; - phr->u.c.anLogValue[1] = pC->u.v.anLog[1]; + if (phm->u.c.attribute == HPI_VOLUME_GAIN) { + phr->u.c.an_log_value[0] = pC->u.v.an_log[0]; + phr->u.c.an_log_value[1] = pC->u.v.an_log[1]; } else found = 0; break; case HPI_CONTROL_MULTIPLEXER: - if (phm->u.c.wAttribute == HPI_MULTIPLEXER_SOURCE) { - phr->u.c.dwParam1 = pC->u.x.wSourceNodeType; - phr->u.c.dwParam2 = pC->u.x.wSourceNodeIndex; + if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) { + phr->u.c.param1 = pC->u.x.source_node_type; + phr->u.c.param2 = pC->u.x.source_node_index; } else { found = 0; } break; case HPI_CONTROL_CHANNEL_MODE: - if (phm->u.c.wAttribute == HPI_CHANNEL_MODE_MODE) - phr->u.c.dwParam1 = pC->u.m.wMode; + if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE) + phr->u.c.param1 = pC->u.m.mode; else found = 0; break; case HPI_CONTROL_LEVEL: - if (phm->u.c.wAttribute == HPI_LEVEL_GAIN) { - phr->u.c.anLogValue[0] = pC->u.l.anLog[0]; - phr->u.c.anLogValue[1] = pC->u.l.anLog[1]; + if (phm->u.c.attribute == HPI_LEVEL_GAIN) { + phr->u.c.an_log_value[0] = pC->u.l.an_log[0]; + phr->u.c.an_log_value[1] = pC->u.l.an_log[1]; } else found = 0; break; @@ -375,119 +350,119 @@ short HpiCheckControlCache( { struct hpi_control_cache_single *pCT = (struct hpi_control_cache_single *)pI; - if (phm->u.c.wAttribute == HPI_TUNER_FREQ) - phr->u.c.dwParam1 = pCT->u.t.dwFreqInkHz; - else if (phm->u.c.wAttribute == HPI_TUNER_BAND) - phr->u.c.dwParam1 = pCT->u.t.wBand; - else if ((phm->u.c.wAttribute == HPI_TUNER_LEVEL) && - (phm->u.c.dwParam1 == + if (phm->u.c.attribute == HPI_TUNER_FREQ) + phr->u.c.param1 = pCT->u.t.freq_ink_hz; + else if (phm->u.c.attribute == HPI_TUNER_BAND) + phr->u.c.param1 = pCT->u.t.band; + else if ((phm->u.c.attribute == HPI_TUNER_LEVEL) + && (phm->u.c.param1 == HPI_TUNER_LEVEL_AVERAGE)) - phr->u.c.dwParam1 = pCT->u.t.wLevel; + phr->u.c.param1 = pCT->u.t.level; else found = 0; } break; case HPI_CONTROL_AESEBU_RECEIVER: - if (phm->u.c.wAttribute == HPI_AESEBURX_ERRORSTATUS) - phr->u.c.dwParam1 = pC->u.aes3rx.dwErrorStatus; - else if (phm->u.c.wAttribute == HPI_AESEBURX_FORMAT) - phr->u.c.dwParam1 = pC->u.aes3rx.dwSource; + if (phm->u.c.attribute == HPI_AESEBURX_ERRORSTATUS) + phr->u.c.param1 = pC->u.aes3rx.error_status; + else if (phm->u.c.attribute == HPI_AESEBURX_FORMAT) + phr->u.c.param1 = pC->u.aes3rx.source; else found = 0; break; case HPI_CONTROL_AESEBU_TRANSMITTER: - if (phm->u.c.wAttribute == HPI_AESEBUTX_FORMAT) - phr->u.c.dwParam1 = pC->u.aes3tx.dwFormat; + if (phm->u.c.attribute == HPI_AESEBUTX_FORMAT) + phr->u.c.param1 = pC->u.aes3tx.format; else found = 0; break; case HPI_CONTROL_TONEDETECTOR: - if (phm->u.c.wAttribute == HPI_TONEDETECTOR_STATE) - phr->u.c.dwParam1 = pC->u.tone.wState; + if (phm->u.c.attribute == HPI_TONEDETECTOR_STATE) + phr->u.c.param1 = pC->u.tone.state; else found = 0; break; case HPI_CONTROL_SILENCEDETECTOR: - if (phm->u.c.wAttribute == HPI_SILENCEDETECTOR_STATE) { - phr->u.c.dwParam1 = pC->u.silence.dwState; - phr->u.c.dwParam2 = pC->u.silence.dwCount; + if (phm->u.c.attribute == HPI_SILENCEDETECTOR_STATE) { + phr->u.c.param1 = pC->u.silence.state; + phr->u.c.param2 = pC->u.silence.count; } else found = 0; break; case HPI_CONTROL_MICROPHONE: - if (phm->u.c.wAttribute == HPI_MICROPHONE_PHANTOM_POWER) { - phr->u.c.dwParam1 = pC->u.phantom_power.wState; - } else + if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER) + phr->u.c.param1 = pC->u.phantom_power.state; + else found = 0; break; case HPI_CONTROL_SAMPLECLOCK: - if (phm->u.c.wAttribute == HPI_SAMPLECLOCK_SOURCE) - phr->u.c.dwParam1 = pC->u.clk.wSource; - else if (phm->u.c.wAttribute == HPI_SAMPLECLOCK_SOURCE_INDEX) { - if (pC->u.clk.wSourceIndex == + if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE) + phr->u.c.param1 = pC->u.clk.source; + else if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE_INDEX) { + if (pC->u.clk.source_index == HPI_ERROR_ILLEGAL_CACHE_VALUE) { - phr->u.c.dwParam1 = 0; - phr->wError = HPI_ERROR_INVALID_OPERATION; + phr->u.c.param1 = 0; + phr->error = HPI_ERROR_INVALID_OPERATION; } else - phr->u.c.dwParam1 = pC->u.clk.wSourceIndex; - } else if (phm->u.c.wAttribute == HPI_SAMPLECLOCK_SAMPLERATE) - phr->u.c.dwParam1 = pC->u.clk.dwSampleRate; + phr->u.c.param1 = pC->u.clk.source_index; + } else if (phm->u.c.attribute == HPI_SAMPLECLOCK_SAMPLERATE) + phr->u.c.param1 = pC->u.clk.sample_rate; else found = 0; break; case HPI_CONTROL_PAD: - if (!(pPad->dwFieldValidFlags & - (1 << HPI_CTL_ATTR_INDEX(phm->u.c. - wAttribute)))) { - phr->wError = HPI_ERROR_INVALID_CONTROL_ATTRIBUTE; + if (!(p_pad->field_valid_flags & (1 << + HPI_CTL_ATTR_INDEX(phm->u.c. + attribute)))) { + phr->error = HPI_ERROR_INVALID_CONTROL_ATTRIBUTE; break; } - if (phm->u.c.wAttribute == HPI_PAD_PROGRAM_ID) - phr->u.c.dwParam1 = pPad->dwPI; - else if (phm->u.c.wAttribute == HPI_PAD_PROGRAM_TYPE) - phr->u.c.dwParam1 = pPad->dwPTY; + if (phm->u.c.attribute == HPI_PAD_PROGRAM_ID) + phr->u.c.param1 = p_pad->pI; + else if (phm->u.c.attribute == HPI_PAD_PROGRAM_TYPE) + phr->u.c.param1 = p_pad->pTY; else { unsigned int index = - HPI_CTL_ATTR_INDEX(phm->u.c.wAttribute) - 1; - unsigned int offset = phm->u.c.dwParam1; + HPI_CTL_ATTR_INDEX(phm->u.c.attribute) - 1; + unsigned int offset = phm->u.c.param1; unsigned int pad_string_len, field_size; char *pad_string; unsigned int tocopy; - HPI_DEBUG_LOG(VERBOSE, - "PADS HPI_PADS_ %d\n", phm->u.c.wAttribute); + HPI_DEBUG_LOG(VERBOSE, "PADS HPI_PADS_ %d\n", + phm->u.c.attribute); - if (index > ARRAY_SIZE(aPadDesc) - 1) { - phr->wError = + if (index > ARRAY_SIZE(pad_desc) - 1) { + phr->error = HPI_ERROR_INVALID_CONTROL_ATTRIBUTE; break; } - pad_string = ((char *)pPad) + aPadDesc[index].offset; - field_size = aPadDesc[index].field_size; + pad_string = ((char *)p_pad) + pad_desc[index].offset; + field_size = pad_desc[index].field_size; /* Ensure null terminator */ pad_string[field_size - 1] = 0; pad_string_len = strlen(pad_string) + 1; if (offset > pad_string_len) { - phr->wError = HPI_ERROR_INVALID_CONTROL_VALUE; + phr->error = HPI_ERROR_INVALID_CONTROL_VALUE; break; } tocopy = pad_string_len - offset; - if (tocopy > sizeof(phr->u.cu.chars8.szData)) - tocopy = sizeof(phr->u.cu.chars8.szData); + if (tocopy > sizeof(phr->u.cu.chars8.sz_data)) + tocopy = sizeof(phr->u.cu.chars8.sz_data); HPI_DEBUG_LOG(VERBOSE, "PADS memcpy(%d), offset %d \n", tocopy, offset); - memcpy(phr->u.cu.chars8.szData, &pad_string[offset], + memcpy(phr->u.cu.chars8.sz_data, &pad_string[offset], tocopy); - phr->u.cu.chars8.dwRemainingChars = + phr->u.cu.chars8.remaining_chars = pad_string_len - offset - tocopy; } break; @@ -498,17 +473,17 @@ short HpiCheckControlCache( if (found) HPI_DEBUG_LOG(VERBOSE, - "Cached Adap %d, Ctl %d, Type %d, Attr %d\n", - phm->wAdapterIndex, pI->ControlIndex, - pI->ControlType, phm->u.c.wAttribute); + "cached adap %d, ctl %d, type %d, attr %d\n", + phm->adapter_index, pI->control_index, + pI->control_type, phm->u.c.attribute); else HPI_DEBUG_LOG(VERBOSE, - "Uncached Adap %d, Ctl %d, Ctl type %d\n", - phm->wAdapterIndex, pI->ControlIndex, - pI->ControlType); + "uncached adap %d, ctl %d, ctl type %d\n", + phm->adapter_index, pI->control_index, + pI->control_type); if (found) - phr->wSize = + phr->size = sizeof(struct hpi_response_header) + sizeof(struct hpi_control_res); @@ -521,17 +496,14 @@ Only update if no error. Volume and Level return the limited values in the response, so use these Multiplexer does so use sent values */ -void HpiSyncControlCache( - struct hpi_control_cache *pCache, - struct hpi_message *phm, - struct hpi_response *phr -) +void hpi_sync_control_cache(struct hpi_control_cache *p_cache, + struct hpi_message *phm, struct hpi_response *phr) { - u16 wControlIndex; + u16 control_index; struct hpi_control_cache_single *pC; struct hpi_control_cache_info *pI; - if (!FindControl(phm, pCache, &pI, &wControlIndex)) + if (!find_control(phm, p_cache, &pI, &control_index)) return; /* pC is the default cached control strucure. @@ -539,142 +511,133 @@ void HpiSyncControlCache( */ pC = (struct hpi_control_cache_single *)pI; - switch (pI->ControlType) { + switch (pI->control_type) { case HPI_CONTROL_VOLUME: - if (phm->u.c.wAttribute == HPI_VOLUME_GAIN) { - pC->u.v.anLog[0] = phr->u.c.anLogValue[0]; - pC->u.v.anLog[1] = phr->u.c.anLogValue[1]; + if (phm->u.c.attribute == HPI_VOLUME_GAIN) { + pC->u.v.an_log[0] = phr->u.c.an_log_value[0]; + pC->u.v.an_log[1] = phr->u.c.an_log_value[1]; } break; case HPI_CONTROL_MULTIPLEXER: /* mux does not return its setting on Set command. */ - if (phr->wError) + if (phr->error) return; - if (phm->u.c.wAttribute == HPI_MULTIPLEXER_SOURCE) { - pC->u.x.wSourceNodeType = (u16)phm->u.c.dwParam1; - pC->u.x.wSourceNodeIndex = (u16)phm->u.c.dwParam2; + if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) { + pC->u.x.source_node_type = (u16)phm->u.c.param1; + pC->u.x.source_node_index = (u16)phm->u.c.param2; } break; case HPI_CONTROL_CHANNEL_MODE: /* mode does not return its setting on Set command. */ - if (phr->wError) + if (phr->error) return; - if (phm->u.c.wAttribute == HPI_CHANNEL_MODE_MODE) - pC->u.m.wMode = (u16)phm->u.c.dwParam1; + if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE) + pC->u.m.mode = (u16)phm->u.c.param1; break; case HPI_CONTROL_LEVEL: - if (phm->u.c.wAttribute == HPI_LEVEL_GAIN) { - pC->u.v.anLog[0] = phr->u.c.anLogValue[0]; - pC->u.v.anLog[1] = phr->u.c.anLogValue[1]; + if (phm->u.c.attribute == HPI_LEVEL_GAIN) { + pC->u.v.an_log[0] = phr->u.c.an_log_value[0]; + pC->u.v.an_log[1] = phr->u.c.an_log_value[1]; } break; case HPI_CONTROL_MICROPHONE: - if (phm->u.c.wAttribute == HPI_MICROPHONE_PHANTOM_POWER) - pC->u.phantom_power.wState = (u16)phm->u.c.dwParam1; + if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER) + pC->u.phantom_power.state = (u16)phm->u.c.param1; break; case HPI_CONTROL_AESEBU_TRANSMITTER: - if (phr->wError) + if (phr->error) return; - if (phm->u.c.wAttribute == HPI_AESEBUTX_FORMAT) - pC->u.aes3tx.dwFormat = phm->u.c.dwParam1; + if (phm->u.c.attribute == HPI_AESEBUTX_FORMAT) + pC->u.aes3tx.format = phm->u.c.param1; break; case HPI_CONTROL_AESEBU_RECEIVER: - if (phr->wError) + if (phr->error) return; - if (phm->u.c.wAttribute == HPI_AESEBURX_FORMAT) - pC->u.aes3rx.dwSource = phm->u.c.dwParam1; + if (phm->u.c.attribute == HPI_AESEBURX_FORMAT) + pC->u.aes3rx.source = phm->u.c.param1; break; case HPI_CONTROL_SAMPLECLOCK: - if (phr->wError) + if (phr->error) return; - if (phm->u.c.wAttribute == HPI_SAMPLECLOCK_SOURCE) - pC->u.clk.wSource = (u16)phm->u.c.dwParam1; - else if (phm->u.c.wAttribute == HPI_SAMPLECLOCK_SOURCE_INDEX) { - pC->u.clk.wSourceIndex = (u16)phm->u.c.dwParam1; - } else if (phm->u.c.wAttribute == HPI_SAMPLECLOCK_SAMPLERATE) - pC->u.clk.dwSampleRate = phm->u.c.dwParam1; + if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE) + pC->u.clk.source = (u16)phm->u.c.param1; + else if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE_INDEX) { + pC->u.clk.source_index = (u16)phm->u.c.param1; + } else if (phm->u.c.attribute == HPI_SAMPLECLOCK_SAMPLERATE) + pC->u.clk.sample_rate = phm->u.c.param1; break; default: break; } } -struct hpi_control_cache *HpiAllocControlCache( - const u32 dwNumberOfControls, - const u32 dwSizeInBytes, - struct hpi_control_cache_info *pDSPControlBuffer -) +struct hpi_control_cache *hpi_alloc_control_cache(const u32 + number_of_controls, const u32 size_in_bytes, + struct hpi_control_cache_info *pDSP_control_buffer) { - struct hpi_control_cache *pCache = - kmalloc(sizeof(*pCache), GFP_KERNEL); - pCache->dwCacheSizeInBytes = dwSizeInBytes; - pCache->dwControlCount = dwNumberOfControls; - pCache->pCache = (struct hpi_control_cache_single *)pDSPControlBuffer; - pCache->dwInit = 0; - pCache->pInfo = - kmalloc(sizeof(*pCache->pInfo) * pCache->dwControlCount, + struct hpi_control_cache *p_cache = + kmalloc(sizeof(*p_cache), GFP_KERNEL); + p_cache->cache_size_in_bytes = size_in_bytes; + p_cache->control_count = number_of_controls; + p_cache->p_cache = + (struct hpi_control_cache_single *)pDSP_control_buffer; + p_cache->init = 0; + p_cache->p_info = + kmalloc(sizeof(*p_cache->p_info) * p_cache->control_count, GFP_KERNEL); - return pCache; + return p_cache; } -void HpiFreeControlCache( - struct hpi_control_cache *pCache -) +void hpi_free_control_cache(struct hpi_control_cache *p_cache) { - if ((pCache->dwInit) && (pCache->pInfo)) { - kfree(pCache->pInfo); - pCache->pInfo = NULL; - pCache->dwInit = 0; - kfree(pCache); + if ((p_cache->init) && (p_cache->p_info)) { + kfree(p_cache->p_info); + p_cache->p_info = NULL; + p_cache->init = 0; + kfree(p_cache); } } -static void SubSysMessage( - struct hpi_message *phm, - struct hpi_response *phr -) +static void subsys_message(struct hpi_message *phm, struct hpi_response *phr) { - switch (phm->wFunction) { + switch (phm->function) { case HPI_SUBSYS_OPEN: case HPI_SUBSYS_CLOSE: case HPI_SUBSYS_DRIVER_UNLOAD: - phr->wError = 0; + phr->error = 0; break; case HPI_SUBSYS_DRIVER_LOAD: - WipeAdapterList(); - HpiOs_Alistlock_Init(&adapters); - phr->wError = 0; + wipe_adapter_list(); + hpios_alistlock_init(&adapters); + phr->error = 0; break; case HPI_SUBSYS_GET_INFO: - SubSysGetAdapters(phr); + subsys_get_adapters(phr); break; case HPI_SUBSYS_CREATE_ADAPTER: case HPI_SUBSYS_DELETE_ADAPTER: - phr->wError = 0; + phr->error = 0; break; default: - phr->wError = HPI_ERROR_INVALID_FUNC; + phr->error = HPI_ERROR_INVALID_FUNC; break; } } -void HPI_COMMON( - struct hpi_message *phm, - struct hpi_response *phr -) +void HPI_COMMON(struct hpi_message *phm, struct hpi_response *phr) { - switch (phm->wType) { + switch (phm->type) { case HPI_TYPE_MESSAGE: - switch (phm->wObject) { + switch (phm->object) { case HPI_OBJ_SUBSYSTEM: - SubSysMessage(phm, phr); + subsys_message(phm, phr); break; } break; default: - phr->wError = HPI_ERROR_INVALID_TYPE; + phr->error = HPI_ERROR_INVALID_TYPE; break; } } diff --git a/pci/asihpi/hpicmn.h b/pci/asihpi/hpicmn.h index b0763e291..05c2dcb3b 100644 --- a/pci/asihpi/hpicmn.h +++ b/pci/asihpi/hpicmn.h @@ -19,69 +19,46 @@ */ struct hpi_adapter_obj { - struct hpi_pci Pci; /* PCI info - bus#,dev#,address etc */ - u16 wAdapterType; /* ASI6701 etc */ - u16 wIndex; /* */ - u16 wOpen; /* =1 when adapter open */ - u16 wMixerOpen; + struct hpi_pci pci; /* PCI info - bus#,dev#,address etc */ + u16 adapter_type; /* ASI6701 etc */ + u16 index; /* */ + u16 open; /* =1 when adapter open */ + u16 mixer_open; - struct hpios_spinlock dspLock; + struct hpios_spinlock dsp_lock; - u16 wDspCrashed; - u16 wHasControlCache; + u16 dsp_crashed; + u16 has_control_cache; void *priv; }; struct hpi_control_cache { - u32 dwInit; /**< indicates whether the + u32 init; /**< indicates whether the structures are initialized */ - u32 dwControlCount; - u32 dwCacheSizeInBytes; + u32 control_count; + u32 cache_size_in_bytes; struct hpi_control_cache_info - **pInfo; /**< pointer to allocated memory of + **p_info; /**< pointer to allocated memory of lookup pointers. */ struct hpi_control_cache_single - *pCache; /**< pointer to DSP's control cache. */ + *p_cache; /**< pointer to DSP's control cache. */ }; -struct hpi_adapter_obj *HpiFindAdapter( - u16 wAdapterIndex -); -u16 HpiAddAdapter( - struct hpi_adapter_obj *pao -); +struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index); +u16 hpi_add_adapter(struct hpi_adapter_obj *pao); -void HpiDeleteAdapter( - struct hpi_adapter_obj *pao -); +void hpi_delete_adapter(struct hpi_adapter_obj *pao); -short HpiCheckControlCache( - struct hpi_control_cache *pC, - struct hpi_message *phm, - struct hpi_response *phr -); -struct hpi_control_cache *HpiAllocControlCache( - const u32 dwNumberOfControls, - const u32 dwSizeInBytes, +short hpi_check_control_cache(struct hpi_control_cache *pC, + struct hpi_message *phm, struct hpi_response *phr); +struct hpi_control_cache *hpi_alloc_control_cache(const u32 + number_of_controls, const u32 size_in_bytes, struct hpi_control_cache_info - *pDSPControlBuffer -); -void HpiFreeControlCache( - struct hpi_control_cache *pCache -); + *pDSP_control_buffer); +void hpi_free_control_cache(struct hpi_control_cache *p_cache); -void HpiSyncControlCache( - struct hpi_control_cache *pC, - struct hpi_message *phm, - struct hpi_response *phr -); -u16 HpiValidateResponse( - struct hpi_message *phm, - struct hpi_response *phr -); -short HpiCheckBufferMapping( - struct hpi_control_cache *pCache, - struct hpi_message *phm, - void **p, - unsigned int *pN -); +void hpi_sync_control_cache(struct hpi_control_cache *pC, + struct hpi_message *phm, struct hpi_response *phr); +u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr); +short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache, + struct hpi_message *phm, void **p, unsigned int *pN); diff --git a/pci/asihpi/hpidebug.c b/pci/asihpi/hpidebug.c index 4344da810..6b62d772b 100644 --- a/pci/asihpi/hpidebug.c +++ b/pci/asihpi/hpidebug.c @@ -24,41 +24,32 @@ Debug macro translation. #include "hpidebug.h" /* Debug level; 0 quiet; 1 informative, 2 debug, 3 verbose debug. */ -int hpiDebugLevel = HPI_DEBUG_LEVEL_DEFAULT; +int hpi_debug_level = HPI_DEBUG_LEVEL_DEFAULT; -void HPI_DebugInit( - void -) +void hpi_debug_init(void) { - printk(KERN_INFO "Debug Start\n"); + printk(KERN_INFO "debug start\n"); } -int HPI_DebugLevelSet( - int level -) +int hpi_debug_level_set(int level) { int old_level; - old_level = hpiDebugLevel; - hpiDebugLevel = level; + old_level = hpi_debug_level; + hpi_debug_level = level; return old_level; } -int HPI_DebugLevelGet( - void -) +int hpi_debug_level_get(void) { - return (hpiDebugLevel); + return (hpi_debug_level); } #ifdef HPIOS_DEBUG_PRINT /* implies OS has no printf-like function */ #include <stdarg.h> -void hpi_debug_printf( - char *fmt, - ... -) +void hpi_debug_printf(char *fmt, ...) { va_list arglist; char buffer[128]; @@ -73,7 +64,7 @@ void hpi_debug_printf( struct treenode { void *array; - unsigned int numElements; + unsigned int num_elements; }; #define make_treenode_from_array(nodename, array) \ @@ -125,9 +116,7 @@ make_treenode_from_array(hpi_control_type_strings, HPI_CONTROL_TYPE_STRINGS) compile_time_assert(HPI_OBJ_MAXINDEX == 14, obj_list_doesnt_match); -static char *hpi_function_string( - unsigned int function -) +static char *hpi_function_string(unsigned int function) { unsigned int object; struct treenode *tmp; @@ -136,38 +125,35 @@ static char *hpi_function_string( function = function - object * HPI_OBJ_FUNCTION_SPACING; if (object == 0 || object == HPI_OBJ_NODE - || object > hpi_function_strings.numElements) - return "Invalid object"; + || object > hpi_function_strings.num_elements) + return "invalid object"; tmp = get_treenode_elem(&hpi_function_strings, object - 1, struct treenode *); - if (function == 0 || function > tmp->numElements) - return "Invalid function"; + if (function == 0 || function > tmp->num_elements) + return "invalid function"; return get_treenode_elem(tmp, function - 1, char *); } -void hpi_debug_message( - struct hpi_message *phm, - char *szFileline -) +void hpi_debug_message(struct hpi_message *phm, char *sz_fileline) { if (phm) { - if ((phm->wObject <= HPI_OBJ_MAXINDEX) && phm->wObject) { - u16 wIndex = 0; - u16 wAttrib = 0; - int isControl = 0; + if ((phm->object <= HPI_OBJ_MAXINDEX) && phm->object) { + u16 index = 0; + u16 attrib = 0; + int is_control = 0; - wIndex = phm->wObjIndex; - switch (phm->wObject) { + index = phm->obj_index; + switch (phm->object) { case HPI_OBJ_ADAPTER: case HPI_OBJ_PROFILE: break; case HPI_OBJ_MIXER: - if (phm->wFunction == + if (phm->function == HPI_MIXER_GET_CONTROL_BY_INDEX) - wIndex = phm->u.m.wControlIndex; + index = phm->u.m.control_index; break; case HPI_OBJ_OSTREAM: case HPI_OBJ_ISTREAM: @@ -176,39 +162,34 @@ void hpi_debug_message( case HPI_OBJ_CONTROLEX: case HPI_OBJ_CONTROL: if (phm->version == 1) - wAttrib = HPI_CTL_ATTR(UNIVERSAL, 1); + attrib = HPI_CTL_ATTR(UNIVERSAL, 1); else - wAttrib = phm->u.c.wAttribute; - isControl = 1; + attrib = phm->u.c.attribute; + is_control = 1; break; default: break; } - if (isControl && (wAttrib & 0xFF00)) { - int controlType = (wAttrib & 0xFF00) >> 8; - int attrIndex = HPI_CTL_ATTR_INDEX(wAttrib); + if (is_control && (attrib & 0xFF00)) { + int control_type = (attrib & 0xFF00) >> 8; + int attr_index = HPI_CTL_ATTR_INDEX(attrib); /* note the KERN facility level is in szFileline already */ - printk("%s Adapter %d %s ctrl_index x%04x %s %d\n", szFileline, phm->wAdapterIndex, hpi_function_string(phm->wFunction), wIndex, get_treenode_elem(&hpi_control_type_strings, controlType, char *), - attrIndex - ); + printk("%s adapter %d %s ctrl_index x%04x %s %d\n", sz_fileline, phm->adapter_index, hpi_function_string(phm->function), index, get_treenode_elem(&hpi_control_type_strings, control_type, char *), attr_index); } else - printk("%s Adapter %d %s idx x%04x attr x%04x \n", szFileline, phm->wAdapterIndex, hpi_function_string(phm->wFunction), wIndex, wAttrib); + printk("%s adapter %d %s idx x%04x attr x%04x \n", sz_fileline, phm->adapter_index, hpi_function_string(phm->function), index, attrib); } else { - printk("Adap=%d, Invalid Obj=%d, Func=0x%x\n", - phm->wAdapterIndex, phm->wObject, - phm->wFunction); + printk("adap=%d, invalid obj=%d, func=0x%x\n", + phm->adapter_index, phm->object, + phm->function); } } else printk("NULL message pointer to hpi_debug_message!\n"); } -void hpi_debug_data( - u16 *pdata, - u32 len -) +void hpi_debug_data(u16 *pdata, u32 len) { u32 i; int j; diff --git a/pci/asihpi/hpidebug.h b/pci/asihpi/hpidebug.h index b20ec0686..e2928ab2a 100644 --- a/pci/asihpi/hpidebug.h +++ b/pci/asihpi/hpidebug.h @@ -32,12 +32,12 @@ extern "C" { #endif /* Define debugging levels. */ -enum { HPI_DEBUG_LEVEL_ERROR = 0, /* Always log errors */ +enum { HPI_DEBUG_LEVEL_ERROR = 0, /* always log errors */ HPI_DEBUG_LEVEL_WARNING = 1, HPI_DEBUG_LEVEL_NOTICE = 2, HPI_DEBUG_LEVEL_INFO = 3, HPI_DEBUG_LEVEL_DEBUG = 4, - HPI_DEBUG_LEVEL_VERBOSE = 5 /* Same printk level as DEBUG */ + HPI_DEBUG_LEVEL_VERBOSE = 5 /* same printk level as DEBUG */ }; #define HPI_DEBUG_LEVEL_DEFAULT HPI_DEBUG_LEVEL_NOTICE @@ -52,59 +52,47 @@ enum { HPI_DEBUG_LEVEL_ERROR = 0, /* Always log errors */ #endif #if defined(HPI_DEBUG) && defined(_WINDOWS) -#define HPI_DEBUGBREAK() DebugBreak() +#define HPI_DEBUGBREAK() debug_break() #else #define HPI_DEBUGBREAK() #endif -#define HPI_DEBUG_ASSERT(_expression) \ +#define HPI_DEBUG_ASSERT(expression) \ do { \ - if (!(_expression)) {\ + if (!(expression)) {\ printk(KERN_ERR FILE_LINE\ - "ASSERT " __stringify(_expression));\ + "ASSERT " __stringify(expression));\ HPI_DEBUGBREAK();\ } \ } while (0) #define HPI_DEBUG_LOG(level, ...) \ do { \ - if (hpiDebugLevel >= HPI_DEBUG_LEVEL_##level) { \ + if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \ printk(HPI_DEBUG_FLAG_##level \ FILE_LINE __VA_ARGS__); \ } \ } while (0) -void HPI_DebugInit( - void -); -int HPI_DebugLevelSet( - int level -); -int HPI_DebugLevelGet( - void -); +void hpi_debug_init(void); +int hpi_debug_level_set(int level); +int hpi_debug_level_get(void); /* needed by Linux driver for dynamic debug level changes */ -extern int hpiDebugLevel; +extern int hpi_debug_level; -void hpi_debug_message( - struct hpi_message *phm, - char *szFileline -); +void hpi_debug_message(struct hpi_message *phm, char *sz_fileline); -void hpi_debug_data( - u16 *pdata, - u32 len -); +void hpi_debug_data(u16 *pdata, u32 len); #define HPI_DEBUG_DATA(pdata, len) \ do { \ - if (hpiDebugLevel >= HPI_DEBUG_LEVEL_VERBOSE) \ + if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE) \ hpi_debug_data(pdata, len); \ } while (0) #define HPI_DEBUG_MESSAGE(level, phm) \ do { \ - if (hpiDebugLevel >= HPI_DEBUG_LEVEL_##level) { \ + if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \ hpi_debug_message(phm,HPI_DEBUG_FLAG_##level \ FILE_LINE __stringify(level));\ } \ @@ -112,12 +100,12 @@ void hpi_debug_data( #define HPI_DEBUG_RESPONSE(phr) \ do { \ - if ((hpiDebugLevel >= HPI_DEBUG_LEVEL_DEBUG) && (phr->wError))\ + if ((hpi_debug_level >= HPI_DEBUG_LEVEL_DEBUG) && (phr->error))\ HPI_DEBUG_LOG(ERROR, \ - "HPI Response - error# %d\n", \ - phr->wError); \ - else if (hpiDebugLevel >= HPI_DEBUG_LEVEL_VERBOSE) \ - HPI_DEBUG_LOG(VERBOSE, "HPI Response OK\n");\ + "HPI response - error# %d\n", \ + phr->error); \ + else if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE) \ + HPI_DEBUG_LOG(VERBOSE, "HPI response OK\n");\ } while (0) #ifndef compile_time_assert diff --git a/pci/asihpi/hpidspcd.c b/pci/asihpi/hpidspcd.c index f58d5a06a..a478be306 100644 --- a/pci/asihpi/hpidspcd.c +++ b/pci/asihpi/hpidspcd.c @@ -62,128 +62,115 @@ struct code_header { /***********************************************************************/ #include "linux/pci.h" /*-------------------------------------------------------------------*/ -short HpiDspCode_Open( - u32 nAdapter, - struct dsp_code *psDspCode, - u32 *pdwOsErrorCode -) +short hpi_dsp_code_open(u32 adapter, struct dsp_code *ps_dsp_code, + u32 *pos_error_code) { - const struct firmware *psFirmware = psDspCode->psFirmware; + const struct firmware *ps_firmware = ps_dsp_code->ps_firmware; struct code_header header; char fw_name[20]; int err; - sprintf(fw_name, "asihpi/dsp%04x.bin", nAdapter); - HPI_DEBUG_LOG(INFO, "Requesting firmware for %s\n", fw_name); + sprintf(fw_name, "asihpi/dsp%04x.bin", adapter); + HPI_DEBUG_LOG(INFO, "requesting firmware for %s\n", fw_name); #if (LINUX_VERSION_CODE < KERNEL_VERSION(2 , 5 , 0)) - err = request_firmware(&psFirmware, fw_name, - psDspCode->psDev->slot_name); + err = request_firmware(&ps_firmware, fw_name, + ps_dsp_code->ps_dev->slot_name); #else - err = request_firmware(&psFirmware, fw_name, &psDspCode->psDev->dev); + err = request_firmware(&ps_firmware, fw_name, + &ps_dsp_code->ps_dev->dev); #endif if (err != 0) { HPI_DEBUG_LOG(ERROR, "%d, request_firmware failed for %s\n", err, fw_name); goto error1; } - if (psFirmware->size < sizeof(header)) { - HPI_DEBUG_LOG(ERROR, "Header size too small %s\n", fw_name); + if (ps_firmware->size < sizeof(header)) { + HPI_DEBUG_LOG(ERROR, "header size too small %s\n", fw_name); goto error2; } - memcpy(&header, psFirmware->data, sizeof(header)); - if (header.adapter != nAdapter) { - HPI_DEBUG_LOG(ERROR, "Adapter type incorrect %4x != %4x\n", - header.adapter, nAdapter); + memcpy(&header, ps_firmware->data, sizeof(header)); + if (header.adapter != adapter) { + HPI_DEBUG_LOG(ERROR, "adapter type incorrect %4x != %4x\n", + header.adapter, adapter); goto error2; } - if (header.size != psFirmware->size) { - HPI_DEBUG_LOG(ERROR, "Code size wrong %d != %ld\n", - header.size, (unsigned long)psFirmware->size); + if (header.size != ps_firmware->size) { + HPI_DEBUG_LOG(ERROR, "code size wrong %d != %ld\n", + header.size, (unsigned long)ps_firmware->size); goto error2; } if (header.version / 10000 != HPI_VER_DECIMAL / 10000) { HPI_DEBUG_LOG(ERROR, - "Firmware Major Version mismatch DSP image %d != Driver %d\n", + "firmware major version mismatch DSP image %d != driver %d\n", header.version, HPI_VER_DECIMAL); goto error2; } if (header.version != HPI_VER_DECIMAL) { HPI_DEBUG_LOG(WARNING, - "Version mismatch DSP image %d != Driver %d\n", + "version mismatch DSP image %d != driver %d\n", header.version, HPI_VER_DECIMAL); /* goto error2; still allow driver to load */ } - HPI_DEBUG_LOG(INFO, "Dsp code %s opened\n", fw_name); - psDspCode->psFirmware = psFirmware; - psDspCode->dwBlockLength = header.size / sizeof(u32); - psDspCode->dwWordCount = sizeof(header) / sizeof(u32); - psDspCode->dwVersion = header.version; - psDspCode->dwCrc = header.crc; + HPI_DEBUG_LOG(INFO, "dsp code %s opened\n", fw_name); + ps_dsp_code->ps_firmware = ps_firmware; + ps_dsp_code->block_length = header.size / sizeof(u32); + ps_dsp_code->word_count = sizeof(header) / sizeof(u32); + ps_dsp_code->version = header.version; + ps_dsp_code->crc = header.crc; return 0; error2: - release_firmware(psFirmware); + release_firmware(ps_firmware); error1: - psDspCode->psFirmware = NULL; - psDspCode->dwBlockLength = 0; + ps_dsp_code->ps_firmware = NULL; + ps_dsp_code->block_length = 0; return (HPI_ERROR_DSP_FILE_NOT_FOUND); } /*-------------------------------------------------------------------*/ -void HpiDspCode_Close( - struct dsp_code *psDspCode -) +void hpi_dsp_code_close(struct dsp_code *ps_dsp_code) { - if (psDspCode->psFirmware != NULL) { - HPI_DEBUG_LOG(DEBUG, "Dsp code closed\n"); - release_firmware(psDspCode->psFirmware); - psDspCode->psFirmware = NULL; + if (ps_dsp_code->ps_firmware != NULL) { + HPI_DEBUG_LOG(DEBUG, "dsp code closed\n"); + release_firmware(ps_dsp_code->ps_firmware); + ps_dsp_code->ps_firmware = NULL; } } /*-------------------------------------------------------------------*/ -void HpiDspCode_Rewind( - struct dsp_code *psDspCode -) +void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code) { /* Go back to start of data, after header */ - psDspCode->dwWordCount = sizeof(struct code_header) / sizeof(u32); + ps_dsp_code->word_count = sizeof(struct code_header) / sizeof(u32); } /*-------------------------------------------------------------------*/ -short HpiDspCode_ReadWord( - struct dsp_code *psDspCode, - u32 *pdwWord -) +short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code, u32 *pword) { - if (psDspCode->dwWordCount + 1 > psDspCode->dwBlockLength) + if (ps_dsp_code->word_count + 1 > ps_dsp_code->block_length) return (HPI_ERROR_DSP_FILE_FORMAT); - *pdwWord = - ((u32 *)(psDspCode->psFirmware->data))[psDspCode-> - dwWordCount]; - psDspCode->dwWordCount++; + *pword = ((u32 *)(ps_dsp_code->ps_firmware->data))[ps_dsp_code-> + word_count]; + ps_dsp_code->word_count++; return 0; } /*-------------------------------------------------------------------*/ -short HpiDspCode_ReadBlock( - size_t nWordsRequested, - struct dsp_code *psDspCode, - u32 **ppdwBlock -) +short hpi_dsp_code_read_block(size_t words_requested, + struct dsp_code *ps_dsp_code, u32 **ppblock) { - if (psDspCode->dwWordCount + nWordsRequested > - psDspCode->dwBlockLength) + if (ps_dsp_code->word_count + words_requested > + ps_dsp_code->block_length) return (HPI_ERROR_DSP_FILE_FORMAT); - *ppdwBlock = - ((u32 *)(psDspCode->psFirmware->data)) + - psDspCode->dwWordCount; - psDspCode->dwWordCount += nWordsRequested; + *ppblock = + ((u32 *)(ps_dsp_code->ps_firmware->data)) + + ps_dsp_code->word_count; + ps_dsp_code->word_count += words_requested; return (0); } diff --git a/pci/asihpi/hpidspcd.h b/pci/asihpi/hpidspcd.h index 502167c20..0edc8837d 100644 --- a/pci/asihpi/hpidspcd.h +++ b/pci/asihpi/hpidspcd.h @@ -47,16 +47,16 @@ DSP code is read using the hotplug firmware loader module. /** Descriptor for dspcode from firmware loader */ struct dsp_code { /** Firmware descriptor */ - const struct firmware *psFirmware; - struct pci_dev *psDev; + const struct firmware *ps_firmware; + struct pci_dev *ps_dev; /** Expected number of words in the whole dsp code,INCL header */ - long int dwBlockLength; + long int block_length; /** Number of words read so far */ - long int dwWordCount; + long int word_count; /** Version read from dsp code file */ - u32 dwVersion; + u32 version; /** CRC read from dsp code file */ - u32 dwCrc; + u32 crc; }; #ifndef DISABLE_PRAGMA_PACK1 @@ -68,32 +68,27 @@ struct dsp_code { \return 0 for success, or error code if requested code is not available */ -short HpiDspCode_Open( +short hpi_dsp_code_open( /** Code identifier, usually adapter family */ - u32 nAdapter, + u32 adapter, /** Pointer to DSP code control structure */ - struct dsp_code *psDspCode, + struct dsp_code *ps_dsp_code, /** Pointer to dword to receive OS specific error code */ - u32 *pdwOsErrorCode -); + u32 *pos_error_code); /** Close the DSP code file */ -void HpiDspCode_Close( - struct dsp_code *psDspCode -); +void hpi_dsp_code_close(struct dsp_code *ps_dsp_code); /** Rewind to the beginning of the DSP code file (for verify) */ -void HpiDspCode_Rewind( - struct dsp_code *psDspCode -); +void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code); /** Read one word from the dsp code file \return 0 for success, or error code if eof, or block length exceeded */ -short HpiDspCode_ReadWord( - struct dsp_code *psDspCode, /**< DSP code descriptor */ - u32 *pdwWord /**< Where to store the read word */ -); +short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code, + /**< DSP code descriptor */ + u32 *pword /**< where to store the read word */ + ); /** Get a block of dsp code into an internal buffer, and provide a pointer to that buffer. (If dsp code is already an array in memory, it is referenced, @@ -101,11 +96,9 @@ not copied.) \return Error if requested number of words are not available */ -short HpiDspCode_ReadBlock( - size_t nWordsRequested, - struct dsp_code *psDspCode, +short hpi_dsp_code_read_block(size_t words_requested, + struct dsp_code *ps_dsp_code, /* Pointer to store (Pointer to code buffer) */ - u32 **ppdwBlock -); + u32 **ppblock); #endif diff --git a/pci/asihpi/hpifunc.c b/pci/asihpi/hpifunc.c index 805618f01..6932459f7 100644 --- a/pci/asihpi/hpifunc.c +++ b/pci/asihpi/hpifunc.c @@ -5,11 +5,11 @@ #include "hpidebug.h" struct hpi_handle { - unsigned int objIndex:12; - unsigned int objType:4; - unsigned int adapterIndex:14; + unsigned int obj_index:12; + unsigned int obj_type:4; + unsigned int adapter_index:14; unsigned int spare:1; - unsigned int readOnly:1; + unsigned int read_only:1; }; union handle_word { @@ -17,44 +17,36 @@ union handle_word { u32 w; }; -u32 HPI_IndexesToHandle( - const char cObject, - const u16 wAdapterIndex, - const u16 wObjectIndex -) +u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index, + const u16 object_index) { union handle_word handle; - handle.h.adapterIndex = wAdapterIndex; + handle.h.adapter_index = adapter_index; handle.h.spare = 0; - handle.h.readOnly = 0; - handle.h.objType = cObject; - handle.h.objIndex = wObjectIndex; + handle.h.read_only = 0; + handle.h.obj_type = c_object; + handle.h.obj_index = object_index; return handle.w; } -void HPI_HandleToIndexes( - const u32 dwHandle, - u16 *pwAdapterIndex, - u16 *pwObjectIndex -) +void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index, + u16 *pw_object_index) { - union handle_word handle; - handle.w = dwHandle; + union handle_word uhandle; + uhandle.w = handle; - if (pwAdapterIndex) - *pwAdapterIndex = (u16)handle.h.adapterIndex; - if (pwObjectIndex) - *pwObjectIndex = (u16)handle.h.objIndex; + if (pw_adapter_index) + *pw_adapter_index = (u16)uhandle.h.adapter_index; + if (pw_object_index) + *pw_object_index = (u16)uhandle.h.obj_index; } -char HPI_HandleObject( - const u32 dwHandle -) +char hpi_handle_object(const u32 handle) { - union handle_word handle; - handle.w = dwHandle; - return (char)handle.h.objType; + union handle_word uhandle; + uhandle.w = handle; + return (char)uhandle.h.obj_type; } #define u32TOINDEX(h, i1) \ @@ -62,7 +54,7 @@ do {\ if (h == 0) \ return HPI_ERROR_INVALID_OBJ; \ else \ - HPI_HandleToIndexes(h, i1, NULL); \ + hpi_handle_to_indexes(h, i1, NULL); \ } while (0) #define u32TOINDEXES(h, i1, i2) \ @@ -70,646 +62,543 @@ do {\ if (h == 0) \ return HPI_ERROR_INVALID_OBJ; \ else \ - HPI_HandleToIndexes(h, i1, i2);\ + hpi_handle_to_indexes(h, i1, i2);\ } while (0) -void HPI_FormatToMsg( - struct hpi_msg_format *pMF, - const struct hpi_format *pF -) +void hpi_format_to_msg(struct hpi_msg_format *pMF, + const struct hpi_format *pF) { - pMF->dwSampleRate = pF->dwSampleRate; - pMF->dwBitRate = pF->dwBitRate; - pMF->dwAttributes = pF->dwAttributes; - pMF->wChannels = pF->wChannels; - pMF->wFormat = pF->wFormat; + pMF->sample_rate = pF->sample_rate; + pMF->bit_rate = pF->bit_rate; + pMF->attributes = pF->attributes; + pMF->channels = pF->channels; + pMF->format = pF->format; } -static void HPI_MsgToFormat( - struct hpi_format *pF, - struct hpi_msg_format *pMF -) +static void hpi_msg_to_format(struct hpi_format *pF, + struct hpi_msg_format *pMF) { - pF->dwSampleRate = pMF->dwSampleRate; - pF->dwBitRate = pMF->dwBitRate; - pF->dwAttributes = pMF->dwAttributes; - pF->wChannels = pMF->wChannels; - pF->wFormat = pMF->wFormat; - pF->wModeLegacy = 0; - pF->wUnused = 0; + pF->sample_rate = pMF->sample_rate; + pF->bit_rate = pMF->bit_rate; + pF->attributes = pMF->attributes; + pF->channels = pMF->channels; + pF->format = pMF->format; + pF->mode_legacy = 0; + pF->unused = 0; } -void HPI_StreamResponseToLegacy( - struct hpi_stream_res *pSR -) +void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR) { - pSR->u.legacy_stream_info.dwAuxiliaryDataAvailable = - pSR->u.stream_info.dwAuxiliaryDataAvailable; - pSR->u.legacy_stream_info.wState = pSR->u.stream_info.wState; + pSR->u.legacy_stream_info.auxiliary_data_available = + pSR->u.stream_info.auxiliary_data_available; + pSR->u.legacy_stream_info.state = pSR->u.stream_info.state; } -static struct hpi_hsubsys ghSubSys; +static struct hpi_hsubsys gh_subsys; -struct hpi_hsubsys *HPI_SubSysCreate( - void -) +struct hpi_hsubsys *hpi_subsys_create(void + ) { struct hpi_message hm; struct hpi_response hr; - memset(&ghSubSys, 0, sizeof(struct hpi_hsubsys)); + memset(&gh_subsys, 0, sizeof(struct hpi_hsubsys)); { - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_OPEN); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (hr.wError == 0) - return (&ghSubSys); + if (hr.error == 0) + return (&gh_subsys); } return (NULL); } -void HPI_SubSysFree( - const struct hpi_hsubsys *phSubSys -) +void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CLOSE); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); } -u16 HPI_SubSysGetVersion( - const struct hpi_hsubsys *phSubSys, - u32 *pdwVersion -) +u16 hpi_subsys_get_version(const struct hpi_hsubsys *ph_subsys, u32 *pversion) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_GET_VERSION); - HPI_Message(&hm, &hr); - *pdwVersion = hr.u.s.dwVersion; - return hr.wError; + hpi_send_recv(&hm, &hr); + *pversion = hr.u.s.version; + return hr.error; } -u16 HPI_SubSysGetVersionEx( - const struct hpi_hsubsys *phSubSys, - u32 *pdwVersionEx -) +u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys, + u32 *pversion_ex) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_GET_VERSION); - HPI_Message(&hm, &hr); - *pdwVersionEx = hr.u.s.dwData; - return hr.wError; + hpi_send_recv(&hm, &hr); + *pversion_ex = hr.u.s.data; + return hr.error; } -u16 HPI_SubSysGetInfo( - const struct hpi_hsubsys *phSubSys, - u32 *pdwVersion, - u16 *pwNumAdapters, - u16 awAdapterList[], - u16 wListLength -) +u16 hpi_subsys_get_info(const struct hpi_hsubsys *ph_subsys, u32 *pversion, + u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_GET_INFO); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - *pdwVersion = hr.u.s.dwVersion; - if (wListLength > HPI_MAX_ADAPTERS) - memcpy(awAdapterList, &hr.u.s.awAdapterList, + *pversion = hr.u.s.version; + if (list_length > HPI_MAX_ADAPTERS) + memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list, HPI_MAX_ADAPTERS); else - memcpy(awAdapterList, &hr.u.s.awAdapterList, wListLength); - *pwNumAdapters = hr.u.s.wNumAdapters; - return hr.wError; + memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list, list_length); + *pw_num_adapters = hr.u.s.num_adapters; + return hr.error; } -u16 HPI_SubSysFindAdapters( - const struct hpi_hsubsys *phSubSys, - u16 *pwNumAdapters, - u16 awAdapterList[], - u16 wListLength -) +u16 hpi_subsys_find_adapters(const struct hpi_hsubsys *ph_subsys, + u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_FIND_ADAPTERS); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (wListLength > HPI_MAX_ADAPTERS) { - memcpy(awAdapterList, &hr.u.s.awAdapterList, + if (list_length > HPI_MAX_ADAPTERS) { + memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list, HPI_MAX_ADAPTERS * sizeof(u16)); - memset(&awAdapterList[HPI_MAX_ADAPTERS], 0, - (wListLength - HPI_MAX_ADAPTERS) * sizeof(u16)); + memset(&aw_adapter_list[HPI_MAX_ADAPTERS], 0, + (list_length - HPI_MAX_ADAPTERS) * sizeof(u16)); } else - memcpy(awAdapterList, &hr.u.s.awAdapterList, - wListLength * sizeof(u16)); - *pwNumAdapters = hr.u.s.wNumAdapters; + memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list, + list_length * sizeof(u16)); + *pw_num_adapters = hr.u.s.num_adapters; - return hr.wError; + return hr.error; } -u16 HPI_SubSysCreateAdapter( - const struct hpi_hsubsys *phSubSys, - const struct hpi_resource *pResource, - u16 *pwAdapterIndex -) +u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys, + const struct hpi_resource *p_resource, u16 *pw_adapter_index) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CREATE_ADAPTER); - hm.u.s.Resource = *pResource; + hm.u.s.resource = *p_resource; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - *pwAdapterIndex = hr.u.s.wAdapterIndex; - return hr.wError; + *pw_adapter_index = hr.u.s.adapter_index; + return hr.error; } -u16 HPI_SubSysDeleteAdapter( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex -) +u16 hpi_subsys_delete_adapter(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_DELETE_ADAPTER); - hm.wAdapterIndex = wAdapterIndex; - HPI_Message(&hm, &hr); - return hr.wError; + hm.adapter_index = adapter_index; + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_SubSysGetNumAdapters( - const struct hpi_hsubsys *phSubSys, - int *pnNumAdapters -) +u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys, + int *pn_num_adapters) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_GET_NUM_ADAPTERS); - HPI_Message(&hm, &hr); - *pnNumAdapters = (int)hr.u.s.wNumAdapters; - return hr.wError; + hpi_send_recv(&hm, &hr); + *pn_num_adapters = (int)hr.u.s.num_adapters; + return hr.error; } -u16 HPI_SubSysGetAdapter( - const struct hpi_hsubsys *phSubSys, - int nIterator, - u32 *pdwAdapterIndex, - u16 *pwAdapterType -) +u16 hpi_subsys_get_adapter(const struct hpi_hsubsys *ph_subsys, int iterator, + u32 *padapter_index, u16 *pw_adapter_type) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_GET_ADAPTER); - hm.wAdapterIndex = (u16)nIterator; - HPI_Message(&hm, &hr); - *pdwAdapterIndex = (int)hr.u.s.wAdapterIndex; - *pwAdapterType = hr.u.s.awAdapterList[0]; - return hr.wError; + hm.adapter_index = (u16)iterator; + hpi_send_recv(&hm, &hr); + *padapter_index = (int)hr.u.s.adapter_index; + *pw_adapter_type = hr.u.s.aw_adapter_list[0]; + return hr.error; } -u16 HPI_SubSysSetHostNetworkInterface( - const struct hpi_hsubsys *phSubSys, - const char *szInterface -) +u16 hpi_subsys_set_host_network_interface(const struct hpi_hsubsys *ph_subsys, + const char *sz_interface) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_SET_NETWORK_INTERFACE); - if (szInterface == NULL) + if (sz_interface == NULL) return HPI_ERROR_INVALID_RESOURCE; - hm.u.s.Resource.r.net_if = szInterface; - HPI_Message(&hm, &hr); - return hr.wError; + hm.u.s.resource.r.net_if = sz_interface; + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_AdapterOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex -) +u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_OPEN); - hm.wAdapterIndex = wAdapterIndex; + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, + HPI_ADAPTER_OPEN); + hm.adapter_index = adapter_index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_AdapterClose( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex -) +u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_CLOSE); - hm.wAdapterIndex = wAdapterIndex; + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, + HPI_ADAPTER_CLOSE); + hm.adapter_index = adapter_index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_AdapterFindObject( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wObjectType, - u16 wObjectIndex, - u16 *pDspIndex -) +u16 hpi_adapter_find_object(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 object_type, u16 object_index, + u16 *p_dsp_index) { return HPI_ERROR_UNIMPLEMENTED; } -u16 HPI_AdapterSetMode( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 dwAdapterMode -) +u16 hpi_adapter_set_mode(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u32 adapter_mode) { - return HPI_AdapterSetModeEx(phSubSys, wAdapterIndex, dwAdapterMode, + return hpi_adapter_set_mode_ex(ph_subsys, adapter_index, adapter_mode, HPI_ADAPTER_MODE_SET); } -u16 HPI_AdapterSetModeEx( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 dwAdapterMode, - u16 wQueryOrSet -) +u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u32 adapter_mode, u16 query_or_set) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_SET_MODE); - hm.wAdapterIndex = wAdapterIndex; - hm.u.a.dwAdapterMode = dwAdapterMode; - hm.u.a.wAssertId = wQueryOrSet; - HPI_Message(&hm, &hr); - return hr.wError; + hm.adapter_index = adapter_index; + hm.u.a.adapter_mode = adapter_mode; + hm.u.a.assert_id = query_or_set; + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_AdapterGetMode( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *pdwAdapterMode -) +u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u32 *padapter_mode) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_GET_MODE); - hm.wAdapterIndex = wAdapterIndex; - HPI_Message(&hm, &hr); - if (pdwAdapterMode) - *pdwAdapterMode = hr.u.a.dwSerialNumber; - return hr.wError; -} - -u16 HPI_AdapterGetInfo( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 *pwNumOutStreams, - u16 *pwNumInStreams, - u16 *pwVersion, - u32 *pdwSerialNumber, - u16 *pwAdapterType -) + hm.adapter_index = adapter_index; + hpi_send_recv(&hm, &hr); + if (padapter_mode) + *padapter_mode = hr.u.a.serial_number; + return hr.error; +} + +u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 *pw_num_outstreams, u16 *pw_num_instreams, + u16 *pw_version, u32 *pserial_number, u16 *pw_adapter_type) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_GET_INFO); - hm.wAdapterIndex = wAdapterIndex; - - HPI_Message(&hm, &hr); - - *pwAdapterType = hr.u.a.wAdapterType; - *pwNumOutStreams = hr.u.a.wNumOStreams; - *pwNumInStreams = hr.u.a.wNumIStreams; - *pwVersion = hr.u.a.wVersion; - *pdwSerialNumber = hr.u.a.dwSerialNumber; - return hr.wError; -} - -u16 HPI_AdapterGetModuleByIndex( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wModuleIndex, - u16 *pwNumOutputs, - u16 *pwNumInputs, - u16 *pwVersion, - u32 *pdwSerialNumber, - u16 *pwModuleType, - u32 *phModule -) + hm.adapter_index = adapter_index; + + hpi_send_recv(&hm, &hr); + + *pw_adapter_type = hr.u.a.adapter_type; + *pw_num_outstreams = hr.u.a.num_outstreams; + *pw_num_instreams = hr.u.a.num_instreams; + *pw_version = hr.u.a.version; + *pserial_number = hr.u.a.serial_number; + return hr.error; +} + +u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 module_index, u16 *pw_num_outputs, + u16 *pw_num_inputs, u16 *pw_version, u32 *pserial_number, + u16 *pw_module_type, u32 *ph_module) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_MODULE_INFO); - hm.wAdapterIndex = wAdapterIndex; - hm.u.ax.module_info.index = wModuleIndex; + hm.adapter_index = adapter_index; + hm.u.ax.module_info.index = module_index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - *pwModuleType = hr.u.a.wAdapterType; - *pwNumOutputs = hr.u.a.wNumOStreams; - *pwNumInputs = hr.u.a.wNumIStreams; - *pwVersion = hr.u.a.wVersion; - *pdwSerialNumber = hr.u.a.dwSerialNumber; - *phModule = 0; + *pw_module_type = hr.u.a.adapter_type; + *pw_num_outputs = hr.u.a.num_outstreams; + *pw_num_inputs = hr.u.a.num_instreams; + *pw_version = hr.u.a.version; + *pserial_number = hr.u.a.serial_number; + *ph_module = 0; - return hr.wError; + return hr.error; } -u16 HPI_AdapterGetAssert( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 *wAssertPresent, - char *pszAssert, - u16 *pwLineNumber -) +u16 hpi_adapter_get_assert(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 *assert_present, char *psz_assert, + u16 *pw_line_number) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_GET_ASSERT); - hm.wAdapterIndex = wAdapterIndex; - HPI_Message(&hm, &hr); + hm.adapter_index = adapter_index; + hpi_send_recv(&hm, &hr); - *wAssertPresent = 0; + *assert_present = 0; - if (!hr.wError) { + if (!hr.error) { - *pwLineNumber = (u16)hr.u.a.dwSerialNumber; - if (*pwLineNumber) { + *pw_line_number = (u16)hr.u.a.serial_number; + if (*pw_line_number) { int i; - char *Src = (char *)hr.u.a.szAdapterAssert; - char *Dst = pszAssert; + char *src = (char *)hr.u.a.sz_adapter_assert; + char *dst = psz_assert; - *wAssertPresent = 1; + *assert_present = 1; for (i = 0; i < HPI_STRING_LEN; i++) { char c; - c = *Src++; - *Dst++ = c; + c = *src++; + *dst++ = c; if (c == 0) break; } } } - return hr.wError; + return hr.error; } -u16 HPI_AdapterGetAssertEx( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 *wAssertPresent, - char *pszAssert, - u32 *pdwLineNumber, - u16 *pwAssertOnDsp -) +u16 hpi_adapter_get_assert_ex(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 *assert_present, char *psz_assert, + u32 *pline_number, u16 *pw_assert_on_dsp) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_GET_ASSERT); - hm.wAdapterIndex = wAdapterIndex; + hm.adapter_index = adapter_index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - *wAssertPresent = 0; + *assert_present = 0; - if (!hr.wError) { + if (!hr.error) { - *pdwLineNumber = hr.u.a.dwSerialNumber; + *pline_number = hr.u.a.serial_number; - *wAssertPresent = hr.u.a.wAdapterType; + *assert_present = hr.u.a.adapter_type; - *pwAssertOnDsp = hr.u.a.wAdapterIndex; + *pw_assert_on_dsp = hr.u.a.adapter_index; - if (!*wAssertPresent && *pdwLineNumber) + if (!*assert_present && *pline_number) - *wAssertPresent = 1; + *assert_present = 1; - if (*wAssertPresent) { + if (*assert_present) { int i; - char *Src = (char *)hr.u.a.szAdapterAssert; - char *Dst = pszAssert; + char *src = (char *)hr.u.a.sz_adapter_assert; + char *dst = psz_assert; for (i = 0; i < HPI_STRING_LEN; i++) { char c; - c = *Src++; - *Dst++ = c; + c = *src++; + *dst++ = c; if (c == 0) break; } } else { - *pszAssert = 0; + *psz_assert = 0; } } - return hr.wError; + return hr.error; } -u16 HPI_AdapterTestAssert( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wAssertId -) +u16 hpi_adapter_test_assert(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 assert_id) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_TEST_ASSERT); - hm.wAdapterIndex = wAdapterIndex; - hm.u.a.wAssertId = wAssertId; + hm.adapter_index = adapter_index; + hm.u.a.assert_id = assert_id; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_AdapterEnableCapability( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wCapability, - u32 dwKey -) +u16 hpi_adapter_enable_capability(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 capability, u32 key) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_ENABLE_CAPABILITY); - hm.wAdapterIndex = wAdapterIndex; - hm.u.a.wAssertId = wCapability; - hm.u.a.dwAdapterMode = dwKey; + hm.adapter_index = adapter_index; + hm.u.a.assert_id = capability; + hm.u.a.adapter_mode = key; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_AdapterSelfTest( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex -) +u16 hpi_adapter_self_test(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_SELFTEST); - hm.wAdapterIndex = wAdapterIndex; - HPI_Message(&hm, &hr); - return hr.wError; + hm.adapter_index = adapter_index; + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_AdapterDebugRead( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 dwDspAddress, - char *pBuffer, - int *dwCountBytes -) +u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u32 dsp_address, char *p_buffer, int *count_bytes) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_DEBUG_READ); - hr.wSize = sizeof(hr); + hr.size = sizeof(hr); - hm.wAdapterIndex = wAdapterIndex; - hm.u.ax.debug_read.dwDspAddress = dwDspAddress; + hm.adapter_index = adapter_index; + hm.u.ax.debug_read.dsp_address = dsp_address; - if (*dwCountBytes > sizeof(hr.u.bytes)) - *dwCountBytes = sizeof(hr.u.bytes); + if (*count_bytes > sizeof(hr.u.bytes)) + *count_bytes = sizeof(hr.u.bytes); - hm.u.ax.debug_read.dwCountBytes = *dwCountBytes; + hm.u.ax.debug_read.count_bytes = *count_bytes; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (!hr.wError) { - *dwCountBytes = hr.wSize - 12; - memcpy(pBuffer, &hr.u.bytes, *dwCountBytes); + if (!hr.error) { + *count_bytes = hr.size - 12; + memcpy(p_buffer, &hr.u.bytes, *count_bytes); } else - *dwCountBytes = 0; - return hr.wError; + *count_bytes = 0; + return hr.error; } -u16 HPI_AdapterSetProperty( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wProperty, - u16 wParameter1, - u16 wParameter2 -) +u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 property, u16 parameter1, u16 parameter2) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_SET_PROPERTY); - hm.wAdapterIndex = wAdapterIndex; - hm.u.ax.property_set.wProperty = wProperty; - hm.u.ax.property_set.wParameter1 = wParameter1; - hm.u.ax.property_set.wParameter2 = wParameter2; + hm.adapter_index = adapter_index; + hm.u.ax.property_set.property = property; + hm.u.ax.property_set.parameter1 = parameter1; + hm.u.ax.property_set.parameter2 = parameter2; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_AdapterGetProperty( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wProperty, - u16 *pwParameter1, - u16 *pwParameter2 -) +u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 property, u16 *pw_parameter1, + u16 *pw_parameter2) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_GET_PROPERTY); - hm.wAdapterIndex = wAdapterIndex; - hm.u.ax.property_set.wProperty = wProperty; - - HPI_Message(&hm, &hr); - if (!hr.wError) { - if (pwParameter1) - *pwParameter1 = hr.u.ax.property_get.wParameter1; - if (pwParameter2) - *pwParameter2 = hr.u.ax.property_get.wParameter2; + hm.adapter_index = adapter_index; + hm.u.ax.property_set.property = property; + + hpi_send_recv(&hm, &hr); + if (!hr.error) { + if (pw_parameter1) + *pw_parameter1 = hr.u.ax.property_get.parameter1; + if (pw_parameter2) + *pw_parameter2 = hr.u.ax.property_get.parameter2; } - return hr.wError; + return hr.error; } -u16 HPI_AdapterEnumerateProperty( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wIndex, - u16 wWhatToEnumerate, - u16 wPropertyIndex, - u32 *pdwSetting -) +u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 index, u16 what_to_enumerate, + u16 property_index, u32 *psetting) { return 0; } -u16 HPI_FormatCreate( - struct hpi_format *pFormat, - u16 wChannels, - u16 wFormat, - u32 dwSampleRate, - u32 dwBitRate, - u32 dwAttributes -) +u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, + u32 sample_rate, u32 bit_rate, u32 attributes) { - u16 wError = 0; - struct hpi_msg_format Format; - - if (wChannels < 1) - wChannels = 1; - if (wChannels > 8) - wChannels = 8; + u16 error = 0; + struct hpi_msg_format fmt; - Format.wChannels = wChannels; + switch (channels) { + case 1: + case 2: + case 4: + case 6: + case 8: + case 16: + break; + default: + error = HPI_ERROR_INVALID_CHANNELS; + return error; + } + fmt.channels = channels; - switch (wFormat) { + switch (format) { case HPI_FORMAT_PCM16_SIGNED: case HPI_FORMAT_PCM24_SIGNED: case HPI_FORMAT_PCM32_SIGNED: @@ -728,3118 +617,2531 @@ u16 HPI_FormatCreate( case HPI_FORMAT_OEM2: break; default: - wError = HPI_ERROR_INVALID_FORMAT; - return wError; + error = HPI_ERROR_INVALID_FORMAT; + return error; } - Format.wFormat = wFormat; + fmt.format = format; - if (dwSampleRate < 8000L) { - wError = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; - dwSampleRate = 8000L; + if (sample_rate < 8000L) { + error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; + sample_rate = 8000L; } - if (dwSampleRate > 200000L) { - wError = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; - dwSampleRate = 200000L; + if (sample_rate > 200000L) { + error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; + sample_rate = 200000L; } - Format.dwSampleRate = dwSampleRate; + fmt.sample_rate = sample_rate; - switch (wFormat) { + switch (format) { case HPI_FORMAT_MPEG_L1: case HPI_FORMAT_MPEG_L2: case HPI_FORMAT_MPEG_L3: - Format.dwBitRate = dwBitRate; + fmt.bit_rate = bit_rate; break; case HPI_FORMAT_PCM16_SIGNED: case HPI_FORMAT_PCM16_BIGENDIAN: - Format.dwBitRate = wChannels * dwSampleRate * 2; + fmt.bit_rate = channels * sample_rate * 2; break; case HPI_FORMAT_PCM32_SIGNED: case HPI_FORMAT_PCM32_FLOAT: - Format.dwBitRate = wChannels * dwSampleRate * 4; + fmt.bit_rate = channels * sample_rate * 4; break; case HPI_FORMAT_PCM8_UNSIGNED: - Format.dwBitRate = wChannels * dwSampleRate; + fmt.bit_rate = channels * sample_rate; break; default: - Format.dwBitRate = 0; + fmt.bit_rate = 0; } - switch (wFormat) { + switch (format) { case HPI_FORMAT_MPEG_L2: - if ((wChannels == 1) - && (dwAttributes != HPI_MPEG_MODE_DEFAULT)) { - dwAttributes = HPI_MPEG_MODE_DEFAULT; - wError = HPI_ERROR_INVALID_FORMAT; - } else if (dwAttributes > HPI_MPEG_MODE_DUALCHANNEL) { - dwAttributes = HPI_MPEG_MODE_DEFAULT; - wError = HPI_ERROR_INVALID_FORMAT; + if ((channels == 1) + && (attributes != HPI_MPEG_MODE_DEFAULT)) { + attributes = HPI_MPEG_MODE_DEFAULT; + error = HPI_ERROR_INVALID_FORMAT; + } else if (attributes > HPI_MPEG_MODE_DUALCHANNEL) { + attributes = HPI_MPEG_MODE_DEFAULT; + error = HPI_ERROR_INVALID_FORMAT; } - Format.dwAttributes = dwAttributes; + fmt.attributes = attributes; break; default: - Format.dwAttributes = dwAttributes; + fmt.attributes = attributes; } - HPI_MsgToFormat(pFormat, &Format); - return wError; + hpi_msg_to_format(p_format, &fmt); + return error; } -u16 HPI_StreamEstimateBufferSize( - struct hpi_format *pFormat, - u32 dwHostPollingRateInMilliSeconds, - u32 *dwRecommendedBufferSize -) +u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format, + u32 host_polling_rate_in_milli_seconds, u32 *recommended_buffer_size) { - u32 dwBytesPerSecond; - u32 dwSize; - u16 wChannels; - struct hpi_format *pF = pFormat; + u32 bytes_per_second; + u32 size; + u16 channels; + struct hpi_format *pF = p_format; - wChannels = pF->wChannels; + channels = pF->channels; - switch (pF->wFormat) { + switch (pF->format) { case HPI_FORMAT_PCM16_BIGENDIAN: case HPI_FORMAT_PCM16_SIGNED: - dwBytesPerSecond = pF->dwSampleRate * 2L * wChannels; + bytes_per_second = pF->sample_rate * 2L * channels; break; case HPI_FORMAT_PCM24_SIGNED: - dwBytesPerSecond = pF->dwSampleRate * 3L * wChannels; + bytes_per_second = pF->sample_rate * 3L * channels; break; case HPI_FORMAT_PCM32_SIGNED: case HPI_FORMAT_PCM32_FLOAT: - dwBytesPerSecond = pF->dwSampleRate * 4L * wChannels; + bytes_per_second = pF->sample_rate * 4L * channels; break; case HPI_FORMAT_PCM8_UNSIGNED: - dwBytesPerSecond = pF->dwSampleRate * 1L * wChannels; + bytes_per_second = pF->sample_rate * 1L * channels; break; case HPI_FORMAT_MPEG_L1: case HPI_FORMAT_MPEG_L2: case HPI_FORMAT_MPEG_L3: - dwBytesPerSecond = pF->dwBitRate / 8L; + bytes_per_second = pF->bit_rate / 8L; break; case HPI_FORMAT_DOLBY_AC2: - dwBytesPerSecond = 256000L / 8L; + bytes_per_second = 256000L / 8L; break; default: return HPI_ERROR_INVALID_FORMAT; } - dwSize = (dwBytesPerSecond * dwHostPollingRateInMilliSeconds * 2) / + size = (bytes_per_second * host_polling_rate_in_milli_seconds * 2) / 1000L; - *dwRecommendedBufferSize = - roundup_pow_of_two(((dwSize + 4095L) & ~4095L)); + *recommended_buffer_size = + roundup_pow_of_two(((size + 4095L) & ~4095L)); return 0; } -u16 HPI_OutStreamOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wOutStreamIndex, - u32 *phOutStream -) +u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u16 outstream_index, u32 *ph_outstream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_OPEN); - hm.wAdapterIndex = wAdapterIndex; - hm.wObjIndex = wOutStreamIndex; + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, + HPI_OSTREAM_OPEN); + hm.adapter_index = adapter_index; + hm.obj_index = outstream_index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (hr.wError == 0) - *phOutStream = - HPI_IndexesToHandle(HPI_OBJ_OSTREAM, wAdapterIndex, - wOutStreamIndex); + if (hr.error == 0) + *ph_outstream = + hpi_indexes_to_handle(HPI_OBJ_OSTREAM, adapter_index, + outstream_index); else - *phOutStream = 0; - return hr.wError; + *ph_outstream = 0; + return hr.error; } -u16 HPI_OutStreamClose( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -) +u16 hpi_outstream_close(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_HOSTBUFFER_FREE); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_GROUP_RESET); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_CLOSE); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, + HPI_OSTREAM_CLOSE); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_OutStreamGetInfoEx( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u16 *pwState, - u32 *pdwBufferSize, - u32 *pdwDataToPlay, - u32 *pdwSamplesPlayed, - u32 *pdwAuxiliaryDataToPlay -) +u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_to_play, + u32 *psamples_played, u32 *pauxiliary_data_to_play) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_GET_INFO); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - - HPI_Message(&hm, &hr); - - if (pwState) - *pwState = hr.u.d.u.stream_info.wState; - if (pdwBufferSize) - *pdwBufferSize = hr.u.d.u.stream_info.dwBufferSize; - if (pdwDataToPlay) - *pdwDataToPlay = hr.u.d.u.stream_info.dwDataAvailable; - if (pdwSamplesPlayed) - *pdwSamplesPlayed = hr.u.d.u.stream_info.dwSamplesTransferred; - if (pdwAuxiliaryDataToPlay) - *pdwAuxiliaryDataToPlay = - hr.u.d.u.stream_info.dwAuxiliaryDataAvailable; - return hr.wError; -} - -u16 HPI_OutStreamWriteBuf( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - const u8 *pbData, - u32 dwBytesToWrite, - const struct hpi_format *pFormat -) + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + + hpi_send_recv(&hm, &hr); + + if (pw_state) + *pw_state = hr.u.d.u.stream_info.state; + if (pbuffer_size) + *pbuffer_size = hr.u.d.u.stream_info.buffer_size; + if (pdata_to_play) + *pdata_to_play = hr.u.d.u.stream_info.data_available; + if (psamples_played) + *psamples_played = hr.u.d.u.stream_info.samples_transferred; + if (pauxiliary_data_to_play) + *pauxiliary_data_to_play = + hr.u.d.u.stream_info.auxiliary_data_available; + return hr.error; +} + +u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, const u8 *pb_data, u32 bytes_to_write, + const struct hpi_format *p_format) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_WRITE); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.d.u.Data.pbData = (u8 *)pbData; - hm.u.d.u.Data.dwDataSize = dwBytesToWrite; + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, + HPI_OSTREAM_WRITE); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hm.u.d.u.data.pb_data = (u8 *)pb_data; + hm.u.d.u.data.data_size = bytes_to_write; - HPI_FormatToMsg(&hm.u.d.u.Data.Format, pFormat); + hpi_format_to_msg(&hm.u.d.u.data.format, p_format); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_OutStreamStart( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -) +u16 hpi_outstream_start(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_START); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, + HPI_OSTREAM_START); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_OutStreamWaitStart( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -) +u16 hpi_outstream_wait_start(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_WAIT_START); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_OutStreamStop( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -) +u16 hpi_outstream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_STOP); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, + HPI_OSTREAM_STOP); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_OutStreamSinegen( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -) +u16 hpi_outstream_sinegen(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_SINEGEN); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_OutStreamReset( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -) +u16 hpi_outstream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_outstream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_RESET); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, + HPI_OSTREAM_RESET); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_OutStreamQueryFormat( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - struct hpi_format *pFormat -) +u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, struct hpi_format *p_format) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_QUERY_FORMAT); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); - HPI_FormatToMsg(&hm.u.d.u.Data.Format, pFormat); + hpi_format_to_msg(&hm.u.d.u.data.format, p_format); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_OutStreamSetFormat( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - struct hpi_format *pFormat -) +u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, struct hpi_format *p_format) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_SET_FORMAT); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); - HPI_FormatToMsg(&hm.u.d.u.Data.Format, pFormat); + hpi_format_to_msg(&hm.u.d.u.data.format, p_format); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_OutStreamSetVelocity( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - short nVelocity -) +u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, short velocity) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_SET_VELOCITY); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.d.u.wVelocity = nVelocity; + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hm.u.d.u.velocity = velocity; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_OutStreamSetPunchInOut( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u32 dwPunchInSample, - u32 dwPunchOutSample -) +u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u32 punch_in_sample, u32 punch_out_sample) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_SET_PUNCHINOUT); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); - hm.u.d.u.Pio.dwPunchInSample = dwPunchInSample; - hm.u.d.u.Pio.dwPunchOutSample = dwPunchOutSample; + hm.u.d.u.pio.punch_in_sample = punch_in_sample; + hm.u.d.u.pio.punch_out_sample = punch_out_sample; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_OutStreamAncillaryReset( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u16 wMode -) +u16 hpi_outstream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u16 mode) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_ANC_RESET); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.d.u.Data.Format.wChannels = wMode; - HPI_Message(&hm, &hr); - return hr.wError; + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hm.u.d.u.data.format.channels = mode; + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_OutStreamAncillaryGetInfo( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u32 *pdwFramesAvailable -) +u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u32 *pframes_available) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_ANC_GET_INFO); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); - if (hr.wError == 0) { - if (pdwFramesAvailable) - *pdwFramesAvailable = - hr.u.d.u.stream_info.dwDataAvailable / + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); + if (hr.error == 0) { + if (pframes_available) + *pframes_available = + hr.u.d.u.stream_info.data_available / sizeof(struct hpi_anc_frame); } - return hr.wError; + return hr.error; } -u16 HPI_OutStreamAncillaryRead( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - struct hpi_anc_frame *pAncFrameBuffer, - u32 dwAncFrameBufferSizeInBytes, - u32 dwNumberOfAncillaryFramesToRead -) +u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, struct hpi_anc_frame *p_anc_frame_buffer, + u32 anc_frame_buffer_size_in_bytes, + u32 number_of_ancillary_frames_to_read) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_ANC_READ); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.d.u.Data.pbData = (u8 *)pAncFrameBuffer; - hm.u.d.u.Data.dwDataSize = - dwNumberOfAncillaryFramesToRead * + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer; + hm.u.d.u.data.data_size = + number_of_ancillary_frames_to_read * sizeof(struct hpi_anc_frame); - if (hm.u.d.u.Data.dwDataSize <= dwAncFrameBufferSizeInBytes) - HPI_Message(&hm, &hr); + if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes) + hpi_send_recv(&hm, &hr); else - hr.wError = HPI_ERROR_INVALID_DATA_TRANSFER; - return hr.wError; + hr.error = HPI_ERROR_INVALID_DATA_TRANSFER; + return hr.error; } -u16 HPI_OutStreamSetTimeScale( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u32 dwTimeScale -) +u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u32 time_scale) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_SET_TIMESCALE); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); - hm.u.d.u.dwTimeScale = dwTimeScale; + hm.u.d.u.time_scale = time_scale; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_OutStreamHostBufferAllocate( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u32 dwSizeInBytes -) +u16 hpi_outstream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u32 size_in_bytes) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_HOSTBUFFER_ALLOC); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.d.u.Data.dwDataSize = dwSizeInBytes; - HPI_Message(&hm, &hr); - return hr.wError; + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hm.u.d.u.data.data_size = size_in_bytes; + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_OutStreamHostBufferGetInfo( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u8 **ppBuffer, - struct hpi_hostbuffer_status **ppStatus -) +u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u8 **pp_buffer, + struct hpi_hostbuffer_status **pp_status) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_HOSTBUFFER_GET_INFO); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); - - if (hr.wError == 0) { - if (ppBuffer) - *ppBuffer = hr.u.d.u.hostbuffer_info.pBuffer; - if (ppStatus) - *ppStatus = hr.u.d.u.hostbuffer_info.pStatus; + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); + + if (hr.error == 0) { + if (pp_buffer) + *pp_buffer = hr.u.d.u.hostbuffer_info.p_buffer; + if (pp_status) + *pp_status = hr.u.d.u.hostbuffer_info.p_status; } - return hr.wError; + return hr.error; } -u16 HPI_OutStreamHostBufferFree( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -) +u16 hpi_outstream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_HOSTBUFFER_FREE); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); - return hr.wError; + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_OutStreamGroupAdd( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u32 hStream -) +u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u32 h_stream) { struct hpi_message hm; struct hpi_response hr; - u16 wAdapter; - char cObjType; + u16 adapter; + char c_obj_type; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_GROUP_ADD); - hr.wError = 0; - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - cObjType = HPI_HandleObject(hStream); - switch (cObjType) { + hr.error = 0; + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + c_obj_type = hpi_handle_object(h_stream); + switch (c_obj_type) { case HPI_OBJ_OSTREAM: - hm.u.d.u.Stream.wObjectType = HPI_OBJ_OSTREAM; - u32TOINDEXES(hStream, &wAdapter, - &hm.u.d.u.Stream.wStreamIndex); + hm.u.d.u.stream.object_type = HPI_OBJ_OSTREAM; + u32TOINDEXES(h_stream, &adapter, + &hm.u.d.u.stream.stream_index); break; case HPI_OBJ_ISTREAM: - hm.u.d.u.Stream.wObjectType = HPI_OBJ_ISTREAM; - u32TOINDEXES(hStream, &wAdapter, - &hm.u.d.u.Stream.wStreamIndex); + hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM; + u32TOINDEXES(h_stream, &adapter, + &hm.u.d.u.stream.stream_index); break; default: return HPI_ERROR_INVALID_STREAM; } - if (wAdapter != hm.wAdapterIndex) + if (adapter != hm.adapter_index) return HPI_ERROR_NO_INTERADAPTER_GROUPS; - HPI_Message(&hm, &hr); - return hr.wError; + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_OutStreamGroupGetMap( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream, - u32 *pdwOutStreamMap, - u32 *pdwInStreamMap -) +u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream, u32 *poutstream_map, u32 *pinstream_map) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_GROUP_GETMAP); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); - if (pdwOutStreamMap) - *pdwOutStreamMap = hr.u.d.u.group_info.dwOutStreamGroupMap; - if (pdwInStreamMap) - *pdwInStreamMap = hr.u.d.u.group_info.dwInStreamGroupMap; + if (poutstream_map) + *poutstream_map = hr.u.d.u.group_info.outstream_group_map; + if (pinstream_map) + *pinstream_map = hr.u.d.u.group_info.instream_group_map; - return hr.wError; + return hr.error; } -u16 HPI_OutStreamGroupReset( - const struct hpi_hsubsys *phSubSys, - u32 hOutStream -) +u16 hpi_outstream_group_reset(const struct hpi_hsubsys *ph_subsys, + u32 h_outstream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_GROUP_RESET); - u32TOINDEXES(hOutStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); - return hr.wError; + u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_InStreamOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wInStreamIndex, - u32 *phInStream -) +u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u16 instream_index, u32 *ph_instream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_OPEN); - hm.wAdapterIndex = wAdapterIndex; - hm.wObjIndex = wInStreamIndex; + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, + HPI_ISTREAM_OPEN); + hm.adapter_index = adapter_index; + hm.obj_index = instream_index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (hr.wError == 0) - *phInStream = - HPI_IndexesToHandle(HPI_OBJ_ISTREAM, - wAdapterIndex, wInStreamIndex); + if (hr.error == 0) + *ph_instream = + hpi_indexes_to_handle(HPI_OBJ_ISTREAM, adapter_index, + instream_index); else - *phInStream = 0; + *ph_instream = 0; - return hr.wError; + return hr.error; } -u16 HPI_InStreamClose( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -) +u16 hpi_instream_close(const struct hpi_hsubsys *ph_subsys, u32 h_instream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_HOSTBUFFER_FREE); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_GROUP_RESET); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_CLOSE); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, + HPI_ISTREAM_CLOSE); + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_InStreamQueryFormat( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - const struct hpi_format *pFormat -) +u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, const struct hpi_format *p_format) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_QUERY_FORMAT); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_FormatToMsg(&hm.u.d.u.Data.Format, pFormat); + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hpi_format_to_msg(&hm.u.d.u.data.format, p_format); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_InStreamSetFormat( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - const struct hpi_format *pFormat -) +u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, const struct hpi_format *p_format) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_SET_FORMAT); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_FormatToMsg(&hm.u.d.u.Data.Format, pFormat); + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hpi_format_to_msg(&hm.u.d.u.data.format, p_format); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_InStreamReadBuf( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u8 *pbData, - u32 dwBytesToRead -) +u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream, + u8 *pb_data, u32 bytes_to_read) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_READ); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.d.u.Data.dwDataSize = dwBytesToRead; - hm.u.d.u.Data.pbData = pbData; + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, + HPI_ISTREAM_READ); + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hm.u.d.u.data.data_size = bytes_to_read; + hm.u.d.u.data.pb_data = pb_data; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_InStreamStart( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -) +u16 hpi_instream_start(const struct hpi_hsubsys *ph_subsys, u32 h_instream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_START); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, + HPI_ISTREAM_START); + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_InStreamWaitStart( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -) +u16 hpi_instream_wait_start(const struct hpi_hsubsys *ph_subsys, + u32 h_instream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_WAIT_START); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_InStreamStop( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -) +u16 hpi_instream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_instream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_STOP); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, + HPI_ISTREAM_STOP); + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_InStreamReset( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -) +u16 hpi_instream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_instream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_RESET); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, + HPI_ISTREAM_RESET); + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_InStreamGetInfoEx( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u16 *pwState, - u32 *pdwBufferSize, - u32 *pdwDataRecorded, - u32 *pdwSamplesRecorded, - u32 *pdwAuxiliaryDataRecorded -) +u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_recorded, + u32 *psamples_recorded, u32 *pauxiliary_data_recorded) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_GET_INFO); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - - HPI_Message(&hm, &hr); - - if (pwState) - *pwState = hr.u.d.u.stream_info.wState; - if (pdwBufferSize) - *pdwBufferSize = hr.u.d.u.stream_info.dwBufferSize; - if (pdwDataRecorded) - *pdwDataRecorded = hr.u.d.u.stream_info.dwDataAvailable; - if (pdwSamplesRecorded) - *pdwSamplesRecorded = - hr.u.d.u.stream_info.dwSamplesTransferred; - if (pdwAuxiliaryDataRecorded) - *pdwAuxiliaryDataRecorded = - hr.u.d.u.stream_info.dwAuxiliaryDataAvailable; - return hr.wError; -} - -u16 HPI_InStreamAncillaryReset( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u16 wBytesPerFrame, - u16 wMode, - u16 wAlignment, - u16 wIdleBit -) + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + + hpi_send_recv(&hm, &hr); + + if (pw_state) + *pw_state = hr.u.d.u.stream_info.state; + if (pbuffer_size) + *pbuffer_size = hr.u.d.u.stream_info.buffer_size; + if (pdata_recorded) + *pdata_recorded = hr.u.d.u.stream_info.data_available; + if (psamples_recorded) + *psamples_recorded = hr.u.d.u.stream_info.samples_transferred; + if (pauxiliary_data_recorded) + *pauxiliary_data_recorded = + hr.u.d.u.stream_info.auxiliary_data_available; + return hr.error; +} + +u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u16 bytes_per_frame, u16 mode, u16 alignment, + u16 idle_bit) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_ANC_RESET); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.d.u.Data.Format.dwAttributes = wBytesPerFrame; - hm.u.d.u.Data.Format.wFormat = (wMode << 8) | (wAlignment & 0xff); - hm.u.d.u.Data.Format.wChannels = wIdleBit; - HPI_Message(&hm, &hr); - return hr.wError; + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hm.u.d.u.data.format.attributes = bytes_per_frame; + hm.u.d.u.data.format.format = (mode << 8) | (alignment & 0xff); + hm.u.d.u.data.format.channels = idle_bit; + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_InStreamAncillaryGetInfo( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u32 *pdwFrameSpace -) +u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u32 *pframe_space) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_ANC_GET_INFO); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); - if (pdwFrameSpace) - *pdwFrameSpace = - (hr.u.d.u.stream_info.dwBufferSize - - hr.u.d.u.stream_info.dwDataAvailable) / + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); + if (pframe_space) + *pframe_space = + (hr.u.d.u.stream_info.buffer_size - + hr.u.d.u.stream_info.data_available) / sizeof(struct hpi_anc_frame); - return hr.wError; + return hr.error; } -u16 HPI_InStreamAncillaryWrite( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - const struct hpi_anc_frame *pAncFrameBuffer, - u32 dwAncFrameBufferSizeInBytes, - u32 dwNumberOfAncillaryFramesToWrite -) +u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, const struct hpi_anc_frame *p_anc_frame_buffer, + u32 anc_frame_buffer_size_in_bytes, + u32 number_of_ancillary_frames_to_write) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_ANC_WRITE); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.d.u.Data.pbData = (u8 *)pAncFrameBuffer; - hm.u.d.u.Data.dwDataSize = - dwNumberOfAncillaryFramesToWrite * + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer; + hm.u.d.u.data.data_size = + number_of_ancillary_frames_to_write * sizeof(struct hpi_anc_frame); - if (hm.u.d.u.Data.dwDataSize <= dwAncFrameBufferSizeInBytes) - HPI_Message(&hm, &hr); + if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes) + hpi_send_recv(&hm, &hr); else - hr.wError = HPI_ERROR_INVALID_DATA_TRANSFER; - return hr.wError; + hr.error = HPI_ERROR_INVALID_DATA_TRANSFER; + return hr.error; } -u16 HPI_InStreamHostBufferAllocate( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u32 dwSizeInBytes -) +u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u32 size_in_bytes) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_HOSTBUFFER_ALLOC); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.d.u.Data.dwDataSize = dwSizeInBytes; - HPI_Message(&hm, &hr); - return hr.wError; + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hm.u.d.u.data.data_size = size_in_bytes; + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_InStreamHostBufferGetInfo( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u8 **ppBuffer, - struct hpi_hostbuffer_status **ppStatus -) +u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u8 **pp_buffer, + struct hpi_hostbuffer_status **pp_status) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_HOSTBUFFER_GET_INFO); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); - - if (hr.wError == 0) { - if (ppBuffer) - *ppBuffer = hr.u.d.u.hostbuffer_info.pBuffer; - if (ppStatus) - *ppStatus = hr.u.d.u.hostbuffer_info.pStatus; + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); + + if (hr.error == 0) { + if (pp_buffer) + *pp_buffer = hr.u.d.u.hostbuffer_info.p_buffer; + if (pp_status) + *pp_status = hr.u.d.u.hostbuffer_info.p_status; } - return hr.wError; + return hr.error; } -u16 HPI_InStreamHostBufferFree( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -) +u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, + u32 h_instream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_HOSTBUFFER_FREE); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); - return hr.wError; + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_InStreamGroupAdd( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u32 hStream -) +u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u32 h_stream) { struct hpi_message hm; struct hpi_response hr; - u16 wAdapter; - char cObjType; + u16 adapter; + char c_obj_type; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_GROUP_ADD); - hr.wError = 0; - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - cObjType = HPI_HandleObject(hStream); + hr.error = 0; + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + c_obj_type = hpi_handle_object(h_stream); - switch (cObjType) { + switch (c_obj_type) { case HPI_OBJ_OSTREAM: - hm.u.d.u.Stream.wObjectType = HPI_OBJ_OSTREAM; - u32TOINDEXES(hStream, &wAdapter, - &hm.u.d.u.Stream.wStreamIndex); + hm.u.d.u.stream.object_type = HPI_OBJ_OSTREAM; + u32TOINDEXES(h_stream, &adapter, + &hm.u.d.u.stream.stream_index); break; case HPI_OBJ_ISTREAM: - hm.u.d.u.Stream.wObjectType = HPI_OBJ_ISTREAM; - u32TOINDEXES(hStream, &wAdapter, - &hm.u.d.u.Stream.wStreamIndex); + hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM; + u32TOINDEXES(h_stream, &adapter, + &hm.u.d.u.stream.stream_index); break; default: return HPI_ERROR_INVALID_STREAM; } - if (wAdapter != hm.wAdapterIndex) + if (adapter != hm.adapter_index) return HPI_ERROR_NO_INTERADAPTER_GROUPS; - HPI_Message(&hm, &hr); - return hr.wError; + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_InStreamGroupGetMap( - const struct hpi_hsubsys *phSubSys, - u32 hInStream, - u32 *pdwOutStreamMap, - u32 *pdwInStreamMap -) +u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys, + u32 h_instream, u32 *poutstream_map, u32 *pinstream_map) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_HOSTBUFFER_FREE); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); - if (pdwOutStreamMap) - *pdwOutStreamMap = hr.u.d.u.group_info.dwOutStreamGroupMap; - if (pdwInStreamMap) - *pdwInStreamMap = hr.u.d.u.group_info.dwInStreamGroupMap; + if (poutstream_map) + *poutstream_map = hr.u.d.u.group_info.outstream_group_map; + if (pinstream_map) + *pinstream_map = hr.u.d.u.group_info.instream_group_map; - return hr.wError; + return hr.error; } -u16 HPI_InStreamGroupReset( - const struct hpi_hsubsys *phSubSys, - u32 hInStream -) +u16 hpi_instream_group_reset(const struct hpi_hsubsys *ph_subsys, + u32 h_instream) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_GROUP_RESET); - u32TOINDEXES(hInStream, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); - return hr.wError; + u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); + return hr.error; } -u16 HPI_MixerOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *phMixer -) +u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u32 *ph_mixer) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN); - hm.wAdapterIndex = wAdapterIndex; + hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN); + hm.adapter_index = adapter_index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (hr.wError == 0) - *phMixer = - HPI_IndexesToHandle(HPI_OBJ_MIXER, wAdapterIndex, 0); + if (hr.error == 0) + *ph_mixer = + hpi_indexes_to_handle(HPI_OBJ_MIXER, adapter_index, + 0); else - *phMixer = 0; - return hr.wError; + *ph_mixer = 0; + return hr.error; } -u16 HPI_MixerClose( - const struct hpi_hsubsys *phSubSys, - u32 hMixer -) +u16 hpi_mixer_close(const struct hpi_hsubsys *ph_subsys, u32 h_mixer) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE); - u32TOINDEX(hMixer, &hm.wAdapterIndex); - HPI_Message(&hm, &hr); - return hr.wError; -} - -u16 HPI_MixerGetControl( - const struct hpi_hsubsys *phSubSys, - u32 hMixer, - u16 wSrcNodeType, - u16 wSrcNodeTypeIndex, - u16 wDstNodeType, - u16 wDstNodeTypeIndex, - u16 wControlType, - u32 *phControl -) + hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE); + u32TOINDEX(h_mixer, &hm.adapter_index); + hpi_send_recv(&hm, &hr); + return hr.error; +} + +u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, + u16 src_node_type, u16 src_node_type_index, u16 dst_node_type, + u16 dst_node_type_index, u16 control_type, u32 *ph_control) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_MIXER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_GET_CONTROL); - u32TOINDEX(hMixer, &hm.wAdapterIndex); - hm.u.m.wNodeType1 = wSrcNodeType; - hm.u.m.wNodeIndex1 = wSrcNodeTypeIndex; - hm.u.m.wNodeType2 = wDstNodeType; - hm.u.m.wNodeIndex2 = wDstNodeTypeIndex; - hm.u.m.wControlType = wControlType; - - HPI_Message(&hm, &hr); - - if (hr.wError == 0) - *phControl = - HPI_IndexesToHandle(HPI_OBJ_CONTROL, hm.wAdapterIndex, - hr.u.m.wControlIndex); + u32TOINDEX(h_mixer, &hm.adapter_index); + hm.u.m.node_type1 = src_node_type; + hm.u.m.node_index1 = src_node_type_index; + hm.u.m.node_type2 = dst_node_type; + hm.u.m.node_index2 = dst_node_type_index; + hm.u.m.control_type = control_type; + + hpi_send_recv(&hm, &hr); + + if (hr.error == 0) + *ph_control = + hpi_indexes_to_handle(HPI_OBJ_CONTROL, + hm.adapter_index, hr.u.m.control_index); else - *phControl = 0; - return hr.wError; -} - -u16 HPI_MixerGetControlByIndex( - const struct hpi_hsubsys *phSubSys, - u32 hMixer, - u16 wControlIndex, - u16 *pwSrcNodeType, - u16 *pwSrcNodeIndex, - u16 *pwDstNodeType, - u16 *pwDstNodeIndex, - u16 *pwControlType, - u32 *phControl -) + *ph_control = 0; + return hr.error; +} + +u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys, + u32 h_mixer, u16 control_index, u16 *pw_src_node_type, + u16 *pw_src_node_index, u16 *pw_dst_node_type, u16 *pw_dst_node_index, + u16 *pw_control_type, u32 *ph_control) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_MIXER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_GET_CONTROL_BY_INDEX); - u32TOINDEX(hMixer, &hm.wAdapterIndex); - hm.u.m.wControlIndex = wControlIndex; - HPI_Message(&hm, &hr); - - if (pwSrcNodeType) { - *pwSrcNodeType = hr.u.m.wSrcNodeType + HPI_SOURCENODE_NONE; - *pwSrcNodeIndex = hr.u.m.wSrcNodeIndex; - *pwDstNodeType = hr.u.m.wDstNodeType + HPI_DESTNODE_NONE; - *pwDstNodeIndex = hr.u.m.wDstNodeIndex; + u32TOINDEX(h_mixer, &hm.adapter_index); + hm.u.m.control_index = control_index; + hpi_send_recv(&hm, &hr); + + if (pw_src_node_type) { + *pw_src_node_type = + hr.u.m.src_node_type + HPI_SOURCENODE_NONE; + *pw_src_node_index = hr.u.m.src_node_index; + *pw_dst_node_type = hr.u.m.dst_node_type + HPI_DESTNODE_NONE; + *pw_dst_node_index = hr.u.m.dst_node_index; } - if (pwControlType) - *pwControlType = hr.u.m.wControlIndex; - - if (phControl) { - if (hr.wError == 0) - *phControl = - HPI_IndexesToHandle(HPI_OBJ_CONTROL, - hm.wAdapterIndex, wControlIndex); + if (pw_control_type) + *pw_control_type = hr.u.m.control_index; + + if (ph_control) { + if (hr.error == 0) + *ph_control = + hpi_indexes_to_handle(HPI_OBJ_CONTROL, + hm.adapter_index, control_index); else - *phControl = 0; + *ph_control = 0; } - return hr.wError; + return hr.error; } -u16 HPI_MixerStore( - const struct hpi_hsubsys *phSubSys, - u32 hMixer, - enum HPI_MIXER_STORE_COMMAND command, - u16 wIndex -) +u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, + enum HPI_MIXER_STORE_COMMAND command, u16 index) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_STORE); - u32TOINDEX(hMixer, &hm.wAdapterIndex); - hm.u.mx.store.wCommand = command; - hm.u.mx.store.wIndex = wIndex; - HPI_Message(&hm, &hr); - return hr.wError; + hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_STORE); + u32TOINDEX(h_mixer, &hm.adapter_index); + hm.u.mx.store.command = command; + hm.u.mx.store.index = index; + hpi_send_recv(&hm, &hr); + return hr.error; } static -u16 HPI_ControlParamSet( - const struct hpi_hsubsys *phSubSys, - const u32 hControl, - const u16 wAttrib, - const u32 dwParam1, - const u32 dwParam2 -) +u16 hpi_control_param_set(const struct hpi_hsubsys *ph_subsys, + const u32 h_control, const u16 attrib, const u32 param1, + const u32 param2) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = wAttrib; - hm.u.c.dwParam1 = dwParam1; - hm.u.c.dwParam2 = dwParam2; - HPI_Message(&hm, &hr); - return hr.wError; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = attrib; + hm.u.c.param1 = param1; + hm.u.c.param2 = param2; + hpi_send_recv(&hm, &hr); + return hr.error; } static -u16 HPI_ControlParamGet( - const struct hpi_hsubsys *phSubSys, - const u32 hControl, - const u16 wAttrib, - u32 dwParam1, - u32 dwParam2, - u32 *pdwParam1, - u32 *pdwParam2 -) +u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys, + const u32 h_control, const u16 attrib, u32 param1, u32 param2, + u32 *pparam1, u32 *pparam2) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = wAttrib; - hm.u.c.dwParam1 = dwParam1; - hm.u.c.dwParam2 = dwParam2; - HPI_Message(&hm, &hr); - if (pdwParam1) - *pdwParam1 = hr.u.c.dwParam1; - if (pdwParam2) - *pdwParam2 = hr.u.c.dwParam2; - - return hr.wError; -} - -#define HPI_ControlParam1Get(s, h, a, p1) \ - HPI_ControlParamGet(s, h, a, 0, 0, p1, NULL) -#define HPI_ControlParam2Get(s, h, a, p1, p2) \ - HPI_ControlParamGet(s, h, a, 0, 0, p1, p2) -#define HPI_ControlExParam1Get(s, h, a, p1) \ - HPI_ControlExParamGet(s, h, a, 0, 0, p1, NULL) -#define HPI_ControlExParam2Get(s, h, a, p1, p2) \ - HPI_ControlExParamGet(s, h, a, 0, 0, p1, p2) + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = attrib; + hm.u.c.param1 = param1; + hm.u.c.param2 = param2; + hpi_send_recv(&hm, &hr); + if (pparam1) + *pparam1 = hr.u.c.param1; + if (pparam2) + *pparam2 = hr.u.c.param2; + + return hr.error; +} + +#define hpi_control_param1_get(s, h, a, p1) \ + hpi_control_param_get(s, h, a, 0, 0, p1, NULL) +#define hpi_control_param2_get(s, h, a, p1, p2) \ + hpi_control_param_get(s, h, a, 0, 0, p1, p2) +#define hpi_control_ex_param1_get(s, h, a, p1) \ + hpi_control_ex_param_get(s, h, a, 0, 0, p1, NULL) +#define hpi_control_ex_param2_get(s, h, a, p1, p2) \ + hpi_control_ex_param_get(s, h, a, 0, 0, p1, p2) static -u16 HPI_ControlQuery( - const struct hpi_hsubsys *phSubSys, - const u32 hControl, - const u16 wAttrib, - const u32 dwIndex, - const u32 dwParam, - u32 *pdwSetting -) +u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys, + const u32 h_control, const u16 attrib, const u32 index, + const u32 param, u32 *psetting) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_INFO); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); - hm.u.c.wAttribute = wAttrib; - hm.u.c.dwParam1 = dwIndex; - hm.u.c.dwParam2 = dwParam; + hm.u.c.attribute = attrib; + hm.u.c.param1 = index; + hm.u.c.param2 = param; - HPI_Message(&hm, &hr); - *pdwSetting = hr.u.c.dwParam1; + hpi_send_recv(&hm, &hr); + *psetting = hr.u.c.param1; - return hr.wError; + return hr.error; } -static u16 HPI_Control_GetString( - const struct hpi_hsubsys *phSubSys, - const u32 hControl, - const u16 wAttribute, - char *pszString, - const u32 wStringLength -) +static u16 hpi_control_get_string(const struct hpi_hsubsys *ph_subsys, + const u32 h_control, const u16 attribute, char *psz_string, + const u32 string_length) { - unsigned int subStringIndex = 0, j = 0; + unsigned int sub_string_index = 0, j = 0; char c = 0; unsigned int n = 0; - u16 wHE = 0; + u16 hE = 0; - if ((wStringLength < 1) || (wStringLength > 256)) + if ((string_length < 1) || (string_length > 256)) return HPI_ERROR_INVALID_CONTROL_VALUE; - for (subStringIndex = 0; subStringIndex < wStringLength; - subStringIndex += 8) { + for (sub_string_index = 0; sub_string_index < string_length; + sub_string_index += 8) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = wAttribute; - hm.u.c.dwParam1 = subStringIndex; - hm.u.c.dwParam2 = 0; - HPI_Message(&hm, &hr); - - if (subStringIndex == 0 - && (hr.u.cu.chars8.dwRemainingChars + 8) > - wStringLength) + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = attribute; + hm.u.c.param1 = sub_string_index; + hm.u.c.param2 = 0; + hpi_send_recv(&hm, &hr); + + if (sub_string_index == 0 + && (hr.u.cu.chars8.remaining_chars + 8) > + string_length) return HPI_ERROR_INVALID_CONTROL_VALUE; - if (hr.wError) { - wHE = hr.wError; + if (hr.error) { + hE = hr.error; break; } for (j = 0; j < 8; j++) { - c = hr.u.cu.chars8.szData[j]; - pszString[subStringIndex + j] = c; + c = hr.u.cu.chars8.sz_data[j]; + psz_string[sub_string_index + j] = c; n++; - if (n >= wStringLength) { - pszString[wStringLength - 1] = 0; - wHE = HPI_ERROR_INVALID_CONTROL_VALUE; + if (n >= string_length) { + psz_string[string_length - 1] = 0; + hE = HPI_ERROR_INVALID_CONTROL_VALUE; break; } if (c == 0) break; } - if ((hr.u.cu.chars8.dwRemainingChars == 0) && - ((subStringIndex + j) < wStringLength) && (c != 0)) { + if ((hr.u.cu.chars8.remaining_chars == 0) + && ((sub_string_index + j) < string_length) + && (c != 0)) { c = 0; - pszString[subStringIndex + j] = c; + psz_string[sub_string_index + j] = c; } if (c == 0) break; } - return wHE; + return hE; } -u16 HPI_AESEBU_Receiver_QueryFormat( - const struct hpi_hsubsys *phSubSys, - const u32 hAesRx, - const u32 dwIndex, - u16 *pwFormat -) +u16 HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys *ph_subsys, + const u32 h_aes_rx, const u32 index, u16 *pw_format) { u32 qr; u16 err; - err = HPI_ControlQuery(phSubSys, hAesRx, HPI_AESEBURX_FORMAT, - dwIndex, 0, &qr); - *pwFormat = (u16)qr; + err = hpi_control_query(ph_subsys, h_aes_rx, HPI_AESEBURX_FORMAT, + index, 0, &qr); + *pw_format = (u16)qr; return err; } -u16 HPI_AESEBU_Receiver_SetFormat( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wFormat -) +u16 HPI_AESEBU__receiver_set_format(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 format) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_AESEBURX_FORMAT, wFormat, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_AESEBURX_FORMAT, format, 0); } -u16 HPI_AESEBU_Receiver_GetFormat( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwFormat -) +u16 HPI_AESEBU__receiver_get_format(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_format) { - u16 wErr; - u32 dwParam; + u16 err; + u32 param; - wErr = HPI_ControlParam1Get(phSubSys, hControl, - HPI_AESEBURX_FORMAT, &dwParam); - if (!wErr && pwFormat) - *pwFormat = (u16)dwParam; + err = hpi_control_param1_get(ph_subsys, h_control, + HPI_AESEBURX_FORMAT, ¶m); + if (!err && pw_format) + *pw_format = (u16)param; - return wErr; + return err; } -u16 HPI_AESEBU_Receiver_GetSampleRate( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwSampleRate -) +u16 HPI_AESEBU__receiver_get_sample_rate(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *psample_rate) { - return HPI_ControlParam1Get(phSubSys, hControl, - HPI_AESEBURX_SAMPLERATE, pdwSampleRate); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_AESEBURX_SAMPLERATE, psample_rate); } -u16 HPI_AESEBU_Receiver_GetUserData( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 *pwData -) +u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 index, u16 *pw_data) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_AESEBURX_USERDATA; - hm.u.c.dwParam1 = wIndex; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_AESEBURX_USERDATA; + hm.u.c.param1 = index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (pwData) - *pwData = (u16)hr.u.c.dwParam2; - return hr.wError; + if (pw_data) + *pw_data = (u16)hr.u.c.param2; + return hr.error; } -u16 HPI_AESEBU_Receiver_GetChannelStatus( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 *pwData -) +u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys + *ph_subsys, u32 h_control, u16 index, u16 *pw_data) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_AESEBURX_CHANNELSTATUS; - hm.u.c.dwParam1 = wIndex; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_AESEBURX_CHANNELSTATUS; + hm.u.c.param1 = index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (pwData) - *pwData = (u16)hr.u.c.dwParam2; - return hr.wError; + if (pw_data) + *pw_data = (u16)hr.u.c.param2; + return hr.error; } -u16 HPI_AESEBU_Receiver_GetErrorStatus( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwErrorData -) +u16 HPI_AESEBU__receiver_get_error_status(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_error_data) { - u32 dwErrorData = 0; - u16 wError = 0; + u32 error_data = 0; + u16 error = 0; - wError = HPI_ControlParam1Get(phSubSys, hControl, - HPI_AESEBURX_ERRORSTATUS, &dwErrorData); - if (pwErrorData) - *pwErrorData = (u16)dwErrorData; - return wError; + error = hpi_control_param1_get(ph_subsys, h_control, + HPI_AESEBURX_ERRORSTATUS, &error_data); + if (pw_error_data) + *pw_error_data = (u16)error_data; + return error; } -u16 HPI_AESEBU_Transmitter_SetSampleRate( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwSampleRate -) +u16 HPI_AESEBU__transmitter_set_sample_rate(const struct hpi_hsubsys + *ph_subsys, u32 h_control, u32 sample_rate) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_AESEBUTX_SAMPLERATE, dwSampleRate, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_AESEBUTX_SAMPLERATE, sample_rate, 0); } -u16 HPI_AESEBU_Transmitter_SetUserData( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 wData -) +u16 HPI_AESEBU__transmitter_set_user_data(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 index, u16 data) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_AESEBUTX_USERDATA, wIndex, wData); + return hpi_control_param_set(ph_subsys, h_control, + HPI_AESEBUTX_USERDATA, index, data); } -u16 HPI_AESEBU_Transmitter_SetChannelStatus( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 wData -) +u16 HPI_AESEBU__transmitter_set_channel_status(const struct hpi_hsubsys + *ph_subsys, u32 h_control, u16 index, u16 data) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_AESEBUTX_CHANNELSTATUS, wIndex, wData); + return hpi_control_param_set(ph_subsys, h_control, + HPI_AESEBUTX_CHANNELSTATUS, index, data); } -u16 HPI_AESEBU_Transmitter_GetChannelStatus( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 *pwData -) +u16 HPI_AESEBU__transmitter_get_channel_status(const struct hpi_hsubsys + *ph_subsys, u32 h_control, u16 index, u16 *pw_data) { return HPI_ERROR_INVALID_OPERATION; } -u16 HPI_AESEBU_Transmitter_QueryFormat( - const struct hpi_hsubsys *phSubSys, - const u32 hAesTx, - const u32 dwIndex, - u16 *pwFormat -) +u16 HPI_AESEBU__transmitter_query_format(const struct hpi_hsubsys *ph_subsys, + const u32 h_aes_tx, const u32 index, u16 *pw_format) { u32 qr; u16 err; - err = HPI_ControlQuery(phSubSys, hAesTx, HPI_AESEBUTX_FORMAT, - dwIndex, 0, &qr); - *pwFormat = (u16)qr; + err = hpi_control_query(ph_subsys, h_aes_tx, HPI_AESEBUTX_FORMAT, + index, 0, &qr); + *pw_format = (u16)qr; return err; } -u16 HPI_AESEBU_Transmitter_SetFormat( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wOutputFormat -) +u16 HPI_AESEBU__transmitter_set_format(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 output_format) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_AESEBUTX_FORMAT, wOutputFormat, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_AESEBUTX_FORMAT, output_format, 0); } -u16 HPI_AESEBU_Transmitter_GetFormat( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwOutputFormat -) +u16 HPI_AESEBU__transmitter_get_format(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_output_format) { - u16 wErr; - u32 dwParam; + u16 err; + u32 param; - wErr = HPI_ControlParam1Get(phSubSys, hControl, - HPI_AESEBUTX_FORMAT, &dwParam); - if (!wErr && pwOutputFormat) - *pwOutputFormat = (u16)dwParam; + err = hpi_control_param1_get(ph_subsys, h_control, + HPI_AESEBUTX_FORMAT, ¶m); + if (!err && pw_output_format) + *pw_output_format = (u16)param; - return wErr; + return err; } -u16 HPI_Bitstream_SetClockEdge( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wEdgeType -) +u16 hpi_bitstream_set_clock_edge(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 edge_type) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_BITSTREAM_CLOCK_EDGE, wEdgeType, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_BITSTREAM_CLOCK_EDGE, edge_type, 0); } -u16 HPI_Bitstream_SetDataPolarity( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wPolarity -) +u16 hpi_bitstream_set_data_polarity(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 polarity) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_BITSTREAM_DATA_POLARITY, wPolarity, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_BITSTREAM_DATA_POLARITY, polarity, 0); } -u16 HPI_Bitstream_GetActivity( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwClkActivity, - u16 *pwDataActivity -) +u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_clk_activity, u16 *pw_data_activity) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_BITSTREAM_ACTIVITY; - HPI_Message(&hm, &hr); - if (pwClkActivity) - *pwClkActivity = (u16)hr.u.c.dwParam1; - if (pwDataActivity) - *pwDataActivity = (u16)hr.u.c.dwParam2; - return hr.wError; -} - -u16 HPI_ChannelMode_QueryMode( - const struct hpi_hsubsys *phSubSys, - const u32 hMode, - const u32 dwIndex, - u16 *pwMode -) + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_BITSTREAM_ACTIVITY; + hpi_send_recv(&hm, &hr); + if (pw_clk_activity) + *pw_clk_activity = (u16)hr.u.c.param1; + if (pw_data_activity) + *pw_data_activity = (u16)hr.u.c.param2; + return hr.error; +} + +u16 hpi_channel_mode_query_mode(const struct hpi_hsubsys *ph_subsys, + const u32 h_mode, const u32 index, u16 *pw_mode) { u32 qr; u16 err; - err = HPI_ControlQuery(phSubSys, hMode, HPI_CHANNEL_MODE_MODE, - dwIndex, 0, &qr); - *pwMode = (u16)qr; + err = hpi_control_query(ph_subsys, h_mode, HPI_CHANNEL_MODE_MODE, + index, 0, &qr); + *pw_mode = (u16)qr; return err; } -u16 HPI_ChannelModeSet( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wMode -) +u16 hpi_channel_mode_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 mode) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_CHANNEL_MODE_MODE, wMode, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_CHANNEL_MODE_MODE, mode, 0); } -u16 HPI_ChannelModeGet( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *wMode -) +u16 hpi_channel_mode_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 *mode) { - u32 dwMode = 0; - u16 wError = HPI_ControlParam1Get(phSubSys, hControl, - HPI_CHANNEL_MODE_MODE, &dwMode); - if (wMode) - *wMode = (u16)dwMode; - return wError; + u32 mode32 = 0; + u16 error = hpi_control_param1_get(ph_subsys, h_control, + HPI_CHANNEL_MODE_MODE, &mode32); + if (mode) + *mode = (u16)mode32; + return error; } -u16 HPI_Cobranet_HmiWrite( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwHmiAddress, - u32 dwByteCount, - u8 *pbData -) +u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 hmi_address, u32 byte_count, u8 *pb_data) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROLEX, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, HPI_CONTROL_SET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); - hm.u.cx.u.cobranet_data.dwByteCount = dwByteCount; - hm.u.cx.u.cobranet_data.dwHmiAddress = dwHmiAddress; + hm.u.cx.u.cobranet_data.byte_count = byte_count; + hm.u.cx.u.cobranet_data.hmi_address = hmi_address; - if (dwByteCount <= 8) { - memcpy(hm.u.cx.u.cobranet_data.dwData, pbData, dwByteCount); - hm.u.cx.wAttribute = HPI_COBRANET_SET; + if (byte_count <= 8) { + memcpy(hm.u.cx.u.cobranet_data.data, pb_data, byte_count); + hm.u.cx.attribute = HPI_COBRANET_SET; } else { - hm.u.cx.u.cobranet_bigdata.pbData = pbData; - hm.u.cx.wAttribute = HPI_COBRANET_SET_DATA; + hm.u.cx.u.cobranet_bigdata.pb_data = pb_data; + hm.u.cx.attribute = HPI_COBRANET_SET_DATA; } - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_Cobranet_HmiRead( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwHmiAddress, - u32 dwMaxByteCount, - u32 *pdwByteCount, - u8 *pbData -) +u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 hmi_address, u32 max_byte_count, u32 *pbyte_count, u8 *pb_data) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROLEX, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); - hm.u.cx.u.cobranet_data.dwByteCount = dwMaxByteCount; - hm.u.cx.u.cobranet_data.dwHmiAddress = dwHmiAddress; + hm.u.cx.u.cobranet_data.byte_count = max_byte_count; + hm.u.cx.u.cobranet_data.hmi_address = hmi_address; - if (dwMaxByteCount <= 8) { - hm.u.cx.wAttribute = HPI_COBRANET_GET; + if (max_byte_count <= 8) { + hm.u.cx.attribute = HPI_COBRANET_GET; } else { - hm.u.cx.u.cobranet_bigdata.pbData = pbData; - hm.u.cx.wAttribute = HPI_COBRANET_GET_DATA; + hm.u.cx.u.cobranet_bigdata.pb_data = pb_data; + hm.u.cx.attribute = HPI_COBRANET_GET_DATA; } - HPI_Message(&hm, &hr); - if (!hr.wError && pbData) { + hpi_send_recv(&hm, &hr); + if (!hr.error && pb_data) { - *pdwByteCount = hr.u.cx.u.cobranet_data.dwByteCount; + *pbyte_count = hr.u.cx.u.cobranet_data.byte_count; - if (*pdwByteCount < dwMaxByteCount) - dwMaxByteCount = *pdwByteCount; + if (*pbyte_count < max_byte_count) + max_byte_count = *pbyte_count; - if (hm.u.cx.wAttribute == HPI_COBRANET_GET) { - memcpy(pbData, hr.u.cx.u.cobranet_data.dwData, - dwMaxByteCount); + if (hm.u.cx.attribute == HPI_COBRANET_GET) { + memcpy(pb_data, hr.u.cx.u.cobranet_data.data, + max_byte_count); } else { } } - return hr.wError; + return hr.error; } -u16 HPI_Cobranet_HmiGetStatus( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwStatus, - u32 *pdwReadableSize, - u32 *pdwWriteableSize -) +u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pstatus, u32 *preadable_size, + u32 *pwriteable_size) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROLEX, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - - hm.u.cx.wAttribute = HPI_COBRANET_GET_STATUS; - - HPI_Message(&hm, &hr); - if (!hr.wError) { - if (pdwStatus) - *pdwStatus = hr.u.cx.u.cobranet_status.dwStatus; - if (pdwReadableSize) - *pdwReadableSize = - hr.u.cx.u.cobranet_status.dwReadableSize; - if (pdwWriteableSize) - *pdwWriteableSize = - hr.u.cx.u.cobranet_status.dwWriteableSize; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + + hm.u.cx.attribute = HPI_COBRANET_GET_STATUS; + + hpi_send_recv(&hm, &hr); + if (!hr.error) { + if (pstatus) + *pstatus = hr.u.cx.u.cobranet_status.status; + if (preadable_size) + *preadable_size = + hr.u.cx.u.cobranet_status.readable_size; + if (pwriteable_size) + *pwriteable_size = + hr.u.cx.u.cobranet_status.writeable_size; } - return hr.wError; + return hr.error; } -u16 HPI_Cobranet_GetIPaddress( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwIPaddress -) +u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pi_paddress) { - u32 dwByteCount; - u32 dwIP; - u16 wError; - wError = HPI_Cobranet_HmiRead(phSubSys, hControl, - HPI_COBRANET_HMI_cobraIpMonCurrentIP, - 4, &dwByteCount, (u8 *)&dwIP); + u32 byte_count; + u32 iP; + u16 error; + error = hpi_cobranet_hmi_read(ph_subsys, h_control, + HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count, + (u8 *)&iP); - *pdwIPaddress = - ((dwIP & 0xff000000) >> 8) | - ((dwIP & 0x00ff0000) << 8) | - ((dwIP & 0x0000ff00) >> 8) | ((dwIP & 0x000000ff) << 8); + *pi_paddress = + ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP & + 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8); - if (wError) - *pdwIPaddress = 0; + if (error) + *pi_paddress = 0; - return wError; + return error; } -u16 HPI_Cobranet_SetIPaddress( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwIPaddress -) +u16 hpi_cobranet_setI_paddress(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 i_paddress) { - u32 dwIP; - u16 wError; + u32 iP; + u16 error; - dwIP = ((dwIPaddress & 0xff000000) >> 8) | - ((dwIPaddress & 0x00ff0000) << 8) | - ((dwIPaddress & 0x0000ff00) >> 8) | - ((dwIPaddress & 0x000000ff) << 8); + iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) << + 8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress & + 0x000000ff) << 8); - wError = HPI_Cobranet_HmiWrite(phSubSys, hControl, - HPI_COBRANET_HMI_cobraIpMonCurrentIP, 4, (u8 *)&dwIP); + error = hpi_cobranet_hmi_write(ph_subsys, h_control, + HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, (u8 *)&iP); - return wError; + return error; } -u16 HPI_Cobranet_GetStaticIPaddress( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwIPaddress -) +u16 hpi_cobranet_get_staticI_paddress(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pi_paddress) { - u32 dwByteCount; - u32 dwIP; - u16 wError; - wError = HPI_Cobranet_HmiRead(phSubSys, hControl, - HPI_COBRANET_HMI_cobraIpMonStaticIP, - 4, &dwByteCount, (u8 *)&dwIP); + u32 byte_count; + u32 iP; + u16 error; + error = hpi_cobranet_hmi_read(ph_subsys, h_control, + HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count, + (u8 *)&iP); - *pdwIPaddress = - ((dwIP & 0xff000000) >> 8) | - ((dwIP & 0x00ff0000) << 8) | - ((dwIP & 0x0000ff00) >> 8) | ((dwIP & 0x000000ff) << 8); + *pi_paddress = + ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP & + 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8); - if (wError) - *pdwIPaddress = 0; + if (error) + *pi_paddress = 0; - return wError; + return error; } -u16 HPI_Cobranet_SetStaticIPaddress( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwIPaddress -) +u16 hpi_cobranet_set_staticI_paddress(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 i_paddress) { - u32 dwIP; - u16 wError; + u32 iP; + u16 error; - dwIP = ((dwIPaddress & 0xff000000) >> 8) | - ((dwIPaddress & 0x00ff0000) << 8) | - ((dwIPaddress & 0x0000ff00) >> 8) | - ((dwIPaddress & 0x000000ff) << 8); + iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) << + 8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress & + 0x000000ff) << 8); - wError = HPI_Cobranet_HmiWrite(phSubSys, hControl, - HPI_COBRANET_HMI_cobraIpMonStaticIP, 4, (u8 *)&dwIP); + error = hpi_cobranet_hmi_write(ph_subsys, h_control, + HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, (u8 *)&iP); - return wError; + return error; } -u16 HPI_Cobranet_GetMACaddress( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwMAC_MSBs, - u32 *pdwMAC_LSBs -) +u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pmAC_MS_bs, u32 *pmAC_LS_bs) { - u32 dwByteCount; - u16 wError; - u32 dwMAC; - wError = HPI_Cobranet_HmiRead(phSubSys, hControl, - HPI_COBRANET_HMI_cobraIfPhyAddress, - 4, &dwByteCount, (u8 *)&dwMAC); - *pdwMAC_MSBs = - ((dwMAC & 0xff000000) >> 8) | - ((dwMAC & 0x00ff0000) << 8) | - ((dwMAC & 0x0000ff00) >> 8) | ((dwMAC & 0x000000ff) << 8); - wError += HPI_Cobranet_HmiRead(phSubSys, hControl, - HPI_COBRANET_HMI_cobraIfPhyAddress + 1, - 4, &dwByteCount, (u8 *)&dwMAC); - *pdwMAC_LSBs = - ((dwMAC & 0xff000000) >> 8) | - ((dwMAC & 0x00ff0000) << 8) | - ((dwMAC & 0x0000ff00) >> 8) | ((dwMAC & 0x000000ff) << 8); + u32 byte_count; + u16 error; + u32 mAC; + error = hpi_cobranet_hmi_read(ph_subsys, h_control, + HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count, + (u8 *)&mAC); + *pmAC_MS_bs = + ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC + & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8); + error += hpi_cobranet_hmi_read(ph_subsys, h_control, + HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4, &byte_count, + (u8 *)&mAC); + *pmAC_LS_bs = + ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC + & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8); - if (wError) { - *pdwMAC_MSBs = 0; - *pdwMAC_LSBs = 0; + if (error) { + *pmAC_MS_bs = 0; + *pmAC_LS_bs = 0; } - return wError; + return error; } -u16 HPI_Compander_Set( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wAttack, - u16 wDecay, - short wRatio100, - short nThreshold0_01dB, - short nMakeupGain0_01dB -) +u16 hpi_compander_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 attack, u16 decay, short ratio100, short threshold0_01dB, + short makeup_gain0_01dB) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); - hm.u.c.dwParam1 = wAttack + ((u32)wRatio100 << 16); - hm.u.c.dwParam2 = (wDecay & 0xFFFFL); - hm.u.c.anLogValue[0] = nThreshold0_01dB; - hm.u.c.anLogValue[1] = nMakeupGain0_01dB; - hm.u.c.wAttribute = HPI_COMPANDER_PARAMS; + hm.u.c.param1 = attack + ((u32)ratio100 << 16); + hm.u.c.param2 = (decay & 0xFFFFL); + hm.u.c.an_log_value[0] = threshold0_01dB; + hm.u.c.an_log_value[1] = makeup_gain0_01dB; + hm.u.c.attribute = HPI_COMPANDER_PARAMS; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_Compander_Get( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwAttack, - u16 *pwDecay, - short *pwRatio100, - short *pnThreshold0_01dB, - short *pnMakeupGain0_01dB -) +u16 hpi_compander_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 *pw_attack, u16 *pw_decay, short *pw_ratio100, + short *pn_threshold0_01dB, short *pn_makeup_gain0_01dB) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_COMPANDER_PARAMS; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_COMPANDER_PARAMS; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (pwAttack) - *pwAttack = (short)(hr.u.c.dwParam1 & 0xFFFF); - if (pwDecay) - *pwDecay = (short)(hr.u.c.dwParam2 & 0xFFFF); - if (pwRatio100) - *pwRatio100 = (short)(hr.u.c.dwParam1 >> 16); + if (pw_attack) + *pw_attack = (short)(hr.u.c.param1 & 0xFFFF); + if (pw_decay) + *pw_decay = (short)(hr.u.c.param2 & 0xFFFF); + if (pw_ratio100) + *pw_ratio100 = (short)(hr.u.c.param1 >> 16); - if (pnThreshold0_01dB) - *pnThreshold0_01dB = hr.u.c.anLogValue[0]; - if (pnMakeupGain0_01dB) - *pnMakeupGain0_01dB = hr.u.c.anLogValue[1]; + if (pn_threshold0_01dB) + *pn_threshold0_01dB = hr.u.c.an_log_value[0]; + if (pn_makeup_gain0_01dB) + *pn_makeup_gain0_01dB = hr.u.c.an_log_value[1]; - return hr.wError; + return hr.error; } -u16 HPI_LevelQueryRange( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short *nMinGain_01dB, - short *nMaxGain_01dB, - short *nStepGain_01dB -) +u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_LEVEL_RANGE; - - HPI_Message(&hm, &hr); - if (hr.wError) { - hr.u.c.anLogValue[0] = 0; - hr.u.c.anLogValue[1] = 0; - hr.u.c.dwParam1 = 0; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_LEVEL_RANGE; + + hpi_send_recv(&hm, &hr); + if (hr.error) { + hr.u.c.an_log_value[0] = 0; + hr.u.c.an_log_value[1] = 0; + hr.u.c.param1 = 0; } - if (nMinGain_01dB) - *nMinGain_01dB = hr.u.c.anLogValue[0]; - if (nMaxGain_01dB) - *nMaxGain_01dB = hr.u.c.anLogValue[1]; - if (nStepGain_01dB) - *nStepGain_01dB = (short)hr.u.c.dwParam1; - return hr.wError; + if (min_gain_01dB) + *min_gain_01dB = hr.u.c.an_log_value[0]; + if (max_gain_01dB) + *max_gain_01dB = hr.u.c.an_log_value[1]; + if (step_gain_01dB) + *step_gain_01dB = (short)hr.u.c.param1; + return hr.error; } -u16 HPI_LevelSetGain( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anGain0_01dB[HPI_MAX_CHANNELS] -) +u16 hpi_level_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_gain0_01dB[HPI_MAX_CHANNELS] + ) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - memcpy(hm.u.c.anLogValue, anGain0_01dB, + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + memcpy(hm.u.c.an_log_value, an_gain0_01dB, sizeof(short) * HPI_MAX_CHANNELS); - hm.u.c.wAttribute = HPI_LEVEL_GAIN; + hm.u.c.attribute = HPI_LEVEL_GAIN; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_LevelGetGain( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anGain0_01dB[HPI_MAX_CHANNELS] -) +u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_gain0_01dB[HPI_MAX_CHANNELS] + ) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_LEVEL_GAIN; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_LEVEL_GAIN; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - memcpy(anGain0_01dB, hr.u.c.anLogValue, + memcpy(an_gain0_01dB, hr.u.c.an_log_value, sizeof(short) * HPI_MAX_CHANNELS); - return hr.wError; + return hr.error; } -u16 HPI_Meter_QueryChannels( - const struct hpi_hsubsys *phSubSys, - const u32 hMeter, - u32 *pChannels -) +u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys, + const u32 h_meter, u32 *p_channels) { - return HPI_ControlQuery(phSubSys, hMeter, HPI_METER_NUM_CHANNELS, - 0, 0, pChannels); + return hpi_control_query(ph_subsys, h_meter, HPI_METER_NUM_CHANNELS, + 0, 0, p_channels); } -u16 HPI_MeterGetPeak( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anPeakdB[HPI_MAX_CHANNELS] -) +u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_peakdB[HPI_MAX_CHANNELS] + ) { short i = 0; struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.wObjIndex = hm.wObjIndex; - hm.u.c.wAttribute = HPI_METER_PEAK; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.obj_index = hm.obj_index; + hm.u.c.attribute = HPI_METER_PEAK; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (!hr.wError) - memcpy(anPeakdB, hr.u.c.anLogValue, + if (!hr.error) + memcpy(an_peakdB, hr.u.c.an_log_value, sizeof(short) * HPI_MAX_CHANNELS); else for (i = 0; i < HPI_MAX_CHANNELS; i++) - anPeakdB[i] = HPI_METER_MINIMUM; - return hr.wError; + an_peakdB[i] = HPI_METER_MINIMUM; + return hr.error; } -u16 HPI_MeterGetRms( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anRmsdB[HPI_MAX_CHANNELS] -) +u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_rmsdB[HPI_MAX_CHANNELS] + ) { short i = 0; struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_METER_RMS; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_METER_RMS; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (!hr.wError) - memcpy(anRmsdB, hr.u.c.anLogValue, + if (!hr.error) + memcpy(an_rmsdB, hr.u.c.an_log_value, sizeof(short) * HPI_MAX_CHANNELS); else for (i = 0; i < HPI_MAX_CHANNELS; i++) - anRmsdB[i] = HPI_METER_MINIMUM; + an_rmsdB[i] = HPI_METER_MINIMUM; - return hr.wError; + return hr.error; } -u16 HPI_MeterSetRmsBallistics( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 nAttack, - u16 nDecay -) +u16 hpi_meter_set_rms_ballistics(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 attack, u16 decay) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_METER_RMS_BALLISTICS, nAttack, nDecay); + return hpi_control_param_set(ph_subsys, h_control, + HPI_METER_RMS_BALLISTICS, attack, decay); } -u16 HPI_MeterGetRmsBallistics( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pnAttack, - u16 *pnDecay -) +u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pn_attack, u16 *pn_decay) { - u32 dwAttack; - u32 dwDecay; - u16 nError; + u32 attack; + u32 decay; + u16 error; - nError = HPI_ControlParam2Get(phSubSys, hControl, - HPI_METER_RMS_BALLISTICS, &dwAttack, &dwDecay); + error = hpi_control_param2_get(ph_subsys, h_control, + HPI_METER_RMS_BALLISTICS, &attack, &decay); - if (pnAttack) - *pnAttack = (unsigned short)dwAttack; - if (pnDecay) - *pnDecay = (unsigned short)dwDecay; + if (pn_attack) + *pn_attack = (unsigned short)attack; + if (pn_decay) + *pn_decay = (unsigned short)decay; - return nError; + return error; } -u16 HPI_MeterSetPeakBallistics( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 nAttack, - u16 nDecay -) +u16 hpi_meter_set_peak_ballistics(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 attack, u16 decay) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_METER_PEAK_BALLISTICS, nAttack, nDecay); + return hpi_control_param_set(ph_subsys, h_control, + HPI_METER_PEAK_BALLISTICS, attack, decay); } -u16 HPI_MeterGetPeakBallistics( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pnAttack, - u16 *pnDecay -) +u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pn_attack, u16 *pn_decay) { - u32 dwAttack; - u32 dwDecay; - u16 nError; + u32 attack; + u32 decay; + u16 error; - nError = HPI_ControlParam2Get(phSubSys, hControl, - HPI_METER_PEAK_BALLISTICS, &dwAttack, &dwDecay); + error = hpi_control_param2_get(ph_subsys, h_control, + HPI_METER_PEAK_BALLISTICS, &attack, &decay); - if (pnAttack) - *pnAttack = (short)dwAttack; - if (pnDecay) - *pnDecay = (short)dwDecay; + if (pn_attack) + *pn_attack = (short)attack; + if (pn_decay) + *pn_decay = (short)decay; - return nError; + return error; } -u16 HPI_Microphone_SetPhantomPower( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wOnOff -) +u16 hpi_microphone_set_phantom_power(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 on_off) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_MICROPHONE_PHANTOM_POWER, (u32)wOnOff, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_MICROPHONE_PHANTOM_POWER, (u32)on_off, 0); } -u16 HPI_Microphone_GetPhantomPower( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwOnOff -) +u16 hpi_microphone_get_phantom_power(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_on_off) { - u16 nError = 0; - u32 dwOnOff = 0; - nError = HPI_ControlParam1Get(phSubSys, hControl, - HPI_MICROPHONE_PHANTOM_POWER, &dwOnOff); - if (pwOnOff) - *pwOnOff = (u16)dwOnOff; - return (nError); + u16 error = 0; + u32 on_off = 0; + error = hpi_control_param1_get(ph_subsys, h_control, + HPI_MICROPHONE_PHANTOM_POWER, &on_off); + if (pw_on_off) + *pw_on_off = (u16)on_off; + return (error); } -u16 HPI_Multiplexer_SetSource( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wSourceNodeType, - u16 wSourceNodeIndex -) +u16 hpi_multiplexer_set_source(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 source_node_type, u16 source_node_index) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_MULTIPLEXER_SOURCE, wSourceNodeType, wSourceNodeIndex); -} + return hpi_control_param_set(ph_subsys, h_control, + HPI_MULTIPLEXER_SOURCE, source_node_type, source_node_index); +} -u16 HPI_Multiplexer_GetSource( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *wSourceNodeType, - u16 *wSourceNodeIndex -) +u16 hpi_multiplexer_get_source(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *source_node_type, u16 *source_node_index) { - u32 dwNode, dwIndex; - u16 wError = HPI_ControlParam2Get(phSubSys, hControl, - HPI_MULTIPLEXER_SOURCE, &dwNode, - &dwIndex); - if (wSourceNodeType) - *wSourceNodeType = (u16)dwNode; - if (wSourceNodeIndex) - *wSourceNodeIndex = (u16)dwIndex; - return wError; + u32 node, index; + u16 error = hpi_control_param2_get(ph_subsys, h_control, + HPI_MULTIPLEXER_SOURCE, &node, + &index); + if (source_node_type) + *source_node_type = (u16)node; + if (source_node_index) + *source_node_index = (u16)index; + return error; } -u16 HPI_Multiplexer_QuerySource( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 *wSourceNodeType, - u16 *wSourceNodeIndex -) +u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 index, u16 *source_node_type, + u16 *source_node_index) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_MULTIPLEXER_QUERYSOURCE; - hm.u.c.dwParam1 = wIndex; - - HPI_Message(&hm, &hr); - - if (wSourceNodeType) - *wSourceNodeType = (u16)hr.u.c.dwParam1; - if (wSourceNodeIndex) - *wSourceNodeIndex = (u16)hr.u.c.dwParam2; - return hr.wError; -} - -u16 HPI_ParametricEQ_GetInfo( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwNumberOfBands, - u16 *pwOnOff -) -{ - u32 dwNOB = 0; - u32 dwOO = 0; - u16 nError = 0; - - nError = HPI_ControlParam2Get(phSubSys, hControl, - HPI_EQUALIZER_NUM_FILTERS, &dwOO, &dwNOB); - if (pwNumberOfBands) - *pwNumberOfBands = (u16)dwNOB; - if (pwOnOff) - *pwOnOff = (u16)dwOO; - return nError; -} - -u16 HPI_ParametricEQ_SetState( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wOnOff -) -{ - return HPI_ControlParamSet(phSubSys, - hControl, HPI_EQUALIZER_NUM_FILTERS, wOnOff, 0); -} - -u16 HPI_ParametricEQ_GetBand( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 *pnType, - u32 *pdwFrequencyHz, - short *pnQ100, - short *pnGain0_01dB -) + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_MULTIPLEXER_QUERYSOURCE; + hm.u.c.param1 = index; + + hpi_send_recv(&hm, &hr); + + if (source_node_type) + *source_node_type = (u16)hr.u.c.param1; + if (source_node_index) + *source_node_index = (u16)hr.u.c.param2; + return hr.error; +} + +u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_number_of_bands, u16 *pw_on_off) +{ + u32 oB = 0; + u32 oO = 0; + u16 error = 0; + + error = hpi_control_param2_get(ph_subsys, h_control, + HPI_EQUALIZER_NUM_FILTERS, &oO, &oB); + if (pw_number_of_bands) + *pw_number_of_bands = (u16)oB; + if (pw_on_off) + *pw_on_off = (u16)oO; + return error; +} + +u16 hpi_parametricEQ__set_state(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 on_off) +{ + return hpi_control_param_set(ph_subsys, h_control, + HPI_EQUALIZER_NUM_FILTERS, on_off, 0); +} + +u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 index, u16 *pn_type, u32 *pfrequency_hz, + short *pnQ100, short *pn_gain0_01dB) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_EQUALIZER_FILTER; - hm.u.c.dwParam2 = wIndex; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_EQUALIZER_FILTER; + hm.u.c.param2 = index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (pdwFrequencyHz) - *pdwFrequencyHz = hr.u.c.dwParam1; - if (pnType) - *pnType = (u16)(hr.u.c.dwParam2 >> 16); + if (pfrequency_hz) + *pfrequency_hz = hr.u.c.param1; + if (pn_type) + *pn_type = (u16)(hr.u.c.param2 >> 16); if (pnQ100) - *pnQ100 = hr.u.c.anLogValue[1]; - if (pnGain0_01dB) - *pnGain0_01dB = hr.u.c.anLogValue[0]; + *pnQ100 = hr.u.c.an_log_value[1]; + if (pn_gain0_01dB) + *pn_gain0_01dB = hr.u.c.an_log_value[0]; - return hr.wError; + return hr.error; } -u16 HPI_ParametricEQ_SetBand( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - u16 nType, - u32 dwFrequencyHz, - short nQ100, - short nGain0_01dB -) +u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 index, u16 type, u32 frequency_hz, short q100, + short gain0_01dB) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); - hm.u.c.dwParam1 = dwFrequencyHz; - hm.u.c.dwParam2 = (wIndex & 0xFFFFL) + ((u32)nType << 16); - hm.u.c.anLogValue[0] = nGain0_01dB; - hm.u.c.anLogValue[1] = nQ100; - hm.u.c.wAttribute = HPI_EQUALIZER_FILTER; + hm.u.c.param1 = frequency_hz; + hm.u.c.param2 = (index & 0xFFFFL) + ((u32)type << 16); + hm.u.c.an_log_value[0] = gain0_01dB; + hm.u.c.an_log_value[1] = q100; + hm.u.c.attribute = HPI_EQUALIZER_FILTER; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_ParametricEQ_GetCoeffs( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wIndex, - short coeffs[5] -) +u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 index, short coeffs[5] + ) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_EQUALIZER_COEFFICIENTS; - hm.u.c.dwParam2 = wIndex; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_EQUALIZER_COEFFICIENTS; + hm.u.c.param2 = index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - coeffs[0] = (short)hr.u.c.anLogValue[0]; - coeffs[1] = (short)hr.u.c.anLogValue[1]; - coeffs[2] = (short)hr.u.c.dwParam1; - coeffs[3] = (short)(hr.u.c.dwParam1 >> 16); - coeffs[4] = (short)hr.u.c.dwParam2; + coeffs[0] = (short)hr.u.c.an_log_value[0]; + coeffs[1] = (short)hr.u.c.an_log_value[1]; + coeffs[2] = (short)hr.u.c.param1; + coeffs[3] = (short)(hr.u.c.param1 >> 16); + coeffs[4] = (short)hr.u.c.param2; - return hr.wError; + return hr.error; } -u16 HPI_SampleClock_QuerySource( - const struct hpi_hsubsys *phSubSys, - const u32 hClock, - const u32 dwIndex, - u16 *pwSource -) +u16 hpi_sample_clock_query_source(const struct hpi_hsubsys *ph_subsys, + const u32 h_clock, const u32 index, u16 *pw_source) { u32 qr; u16 err; - err = HPI_ControlQuery(phSubSys, hClock, HPI_SAMPLECLOCK_SOURCE, - dwIndex, 0, &qr); - *pwSource = (u16)qr; + err = hpi_control_query(ph_subsys, h_clock, HPI_SAMPLECLOCK_SOURCE, + index, 0, &qr); + *pw_source = (u16)qr; return err; } -u16 HPI_SampleClock_SetSource( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wSource -) +u16 hpi_sample_clock_set_source(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 source) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_SAMPLECLOCK_SOURCE, wSource, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_SAMPLECLOCK_SOURCE, source, 0); } -u16 HPI_SampleClock_GetSource( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwSource -) +u16 hpi_sample_clock_get_source(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_source) { - u16 wError = 0; - u32 dwSource = 0; - wError = HPI_ControlParam1Get(phSubSys, hControl, - HPI_SAMPLECLOCK_SOURCE, &dwSource); - if (!wError) - if (pwSource) - *pwSource = (u16)dwSource; - return wError; + u16 error = 0; + u32 source = 0; + error = hpi_control_param1_get(ph_subsys, h_control, + HPI_SAMPLECLOCK_SOURCE, &source); + if (!error) + if (pw_source) + *pw_source = (u16)source; + return error; } -u16 HPI_SampleClock_QuerySourceIndex( - const struct hpi_hsubsys *phSubSys, - const u32 hClock, - const u32 dwIndex, - const u32 dwSource, - u16 *pwSourceIndex -) +u16 hpi_sample_clock_query_source_index(const struct hpi_hsubsys *ph_subsys, + const u32 h_clock, const u32 index, const u32 source, + u16 *pw_source_index) { u32 qr; u16 err; - err = HPI_ControlQuery(phSubSys, hClock, HPI_SAMPLECLOCK_SOURCE_INDEX, - dwIndex, dwSource, &qr); - *pwSourceIndex = (u16)qr; + err = hpi_control_query(ph_subsys, h_clock, + HPI_SAMPLECLOCK_SOURCE_INDEX, index, source, &qr); + *pw_source_index = (u16)qr; return err; } -u16 HPI_SampleClock_SetSourceIndex( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wSourceIndex -) +u16 hpi_sample_clock_set_source_index(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 source_index) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_SAMPLECLOCK_SOURCE_INDEX, wSourceIndex, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_SAMPLECLOCK_SOURCE_INDEX, source_index, 0); } -u16 HPI_SampleClock_GetSourceIndex( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwSourceIndex -) +u16 hpi_sample_clock_get_source_index(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 *pw_source_index) { - u16 wError = 0; - u32 dwSourceIndex = 0; - wError = HPI_ControlParam1Get(phSubSys, hControl, - HPI_SAMPLECLOCK_SOURCE_INDEX, &dwSourceIndex); - if (!wError) - if (pwSourceIndex) - *pwSourceIndex = (u16)dwSourceIndex; - return wError; + u16 error = 0; + u32 source_index = 0; + error = hpi_control_param1_get(ph_subsys, h_control, + HPI_SAMPLECLOCK_SOURCE_INDEX, &source_index); + if (!error) + if (pw_source_index) + *pw_source_index = (u16)source_index; + return error; } -u16 HPI_SampleClock_QueryLocalRate( - const struct hpi_hsubsys *phSubSys, - const u32 hClock, - const u32 dwIndex, - u32 *pdwRate -) +u16 hpi_sample_clock_query_local_rate(const struct hpi_hsubsys *ph_subsys, + const u32 h_clock, const u32 index, u32 *prate) { u16 err; - err = HPI_ControlQuery(phSubSys, hClock, - HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, dwIndex, 0, pdwRate); + err = hpi_control_query(ph_subsys, h_clock, + HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, index, 0, prate); return err; } -u16 HPI_SampleClock_SetLocalRate( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwSampleRate -) +u16 hpi_sample_clock_set_local_rate(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 sample_rate) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, dwSampleRate, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, sample_rate, 0); } -u16 HPI_SampleClock_GetLocalRate( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwSampleRate -) +u16 hpi_sample_clock_get_local_rate(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *psample_rate) { - u16 wError = 0; - u32 dwSampleRate = 0; - wError = HPI_ControlParam1Get(phSubSys, hControl, - HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &dwSampleRate); - if (!wError) - if (pdwSampleRate) - *pdwSampleRate = dwSampleRate; - return wError; + u16 error = 0; + u32 sample_rate = 0; + error = hpi_control_param1_get(ph_subsys, h_control, + HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate); + if (!error) + if (psample_rate) + *psample_rate = sample_rate; + return error; } -u16 HPI_SampleClock_GetSampleRate( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwSampleRate -) +u16 hpi_sample_clock_get_sample_rate(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *psample_rate) { - u16 wError = 0; - u32 dwSampleRate = 0; - wError = HPI_ControlParam1Get(phSubSys, hControl, - HPI_SAMPLECLOCK_SAMPLERATE, &dwSampleRate); - if (!wError) - if (pdwSampleRate) - *pdwSampleRate = dwSampleRate; - return wError; + u16 error = 0; + u32 sample_rate = 0; + error = hpi_control_param1_get(ph_subsys, h_control, + HPI_SAMPLECLOCK_SAMPLERATE, &sample_rate); + if (!error) + if (psample_rate) + *psample_rate = sample_rate; + return error; } -u16 HPI_SampleClock_SetAuto( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwAuto -) +u16 hpi_sample_clock_set_auto(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 enable) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_SAMPLECLOCK_AUTO, dwAuto, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_SAMPLECLOCK_AUTO, enable, 0); } -u16 HPI_SampleClock_GetAuto( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwAuto -) +u16 hpi_sample_clock_get_auto(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *penable) { - return HPI_ControlParam1Get(phSubSys, hControl, - HPI_SAMPLECLOCK_AUTO, pdwAuto); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_SAMPLECLOCK_AUTO, penable); } -u16 HPI_SampleClock_SetLocalRateLock( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwLock -) +u16 hpi_sample_clock_set_local_rate_lock(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 lock) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_SAMPLECLOCK_LOCAL_LOCK, dwLock, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_SAMPLECLOCK_LOCAL_LOCK, lock, 0); } -u16 HPI_SampleClock_GetLocalRateLock( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwLock -) +u16 hpi_sample_clock_get_local_rate_lock(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *plock) { - return HPI_ControlParam1Get(phSubSys, hControl, - HPI_SAMPLECLOCK_LOCAL_LOCK, pdwLock); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_SAMPLECLOCK_LOCAL_LOCK, plock); } -u16 HPI_ToneDetector_GetFrequency( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 nIndex, - u32 *dwFrequency -) +u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 index, u32 *frequency) { - return HPI_ControlParamGet(phSubSys, hControl, - HPI_TONEDETECTOR_FREQUENCY, nIndex, 0, dwFrequency, NULL); + return hpi_control_param_get(ph_subsys, h_control, + HPI_TONEDETECTOR_FREQUENCY, index, 0, frequency, NULL); } -u16 HPI_ToneDetector_GetState( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *State -) +u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *state) { - return HPI_ControlParamGet(phSubSys, hControl, HPI_TONEDETECTOR_STATE, - 0, 0, (u32 *)State, NULL); + return hpi_control_param_get(ph_subsys, h_control, + HPI_TONEDETECTOR_STATE, 0, 0, (u32 *)state, NULL); } -u16 HPI_ToneDetector_SetEnable( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 Enable -) +u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 enable) { - return HPI_ControlParamSet(phSubSys, hControl, HPI_GENERIC_ENABLE, - (u32)Enable, 0); + return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, + (u32)enable, 0); } -u16 HPI_ToneDetector_GetEnable( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *Enable -) +u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *enable) { - return HPI_ControlParamGet(phSubSys, hControl, HPI_GENERIC_ENABLE, 0, - 0, (u32 *)Enable, NULL); + return hpi_control_param_get(ph_subsys, h_control, HPI_GENERIC_ENABLE, + 0, 0, (u32 *)enable, NULL); } -u16 HPI_ToneDetector_SetEventEnable( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 EventEnable -) +u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 event_enable) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_GENERIC_EVENT_ENABLE, (u32)EventEnable, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_GENERIC_EVENT_ENABLE, (u32)event_enable, 0); } -u16 HPI_ToneDetector_GetEventEnable( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *EventEnable -) +u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *event_enable) { - return HPI_ControlParamGet(phSubSys, hControl, - HPI_GENERIC_EVENT_ENABLE, 0, 0, (u32 *)EventEnable, NULL); + return hpi_control_param_get(ph_subsys, h_control, + HPI_GENERIC_EVENT_ENABLE, 0, 0, (u32 *)event_enable, NULL); } -u16 HPI_ToneDetector_SetThreshold( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - int Threshold -) +u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, + u32 h_control, int threshold) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_TONEDETECTOR_THRESHOLD, (u32)Threshold, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_TONEDETECTOR_THRESHOLD, (u32)threshold, 0); } -u16 HPI_ToneDetector_GetThreshold( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - int *Threshold -) +u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, + u32 h_control, int *threshold) { - return HPI_ControlParamGet(phSubSys, hControl, - HPI_TONEDETECTOR_THRESHOLD, 0, 0, (u32 *)Threshold, NULL); + return hpi_control_param_get(ph_subsys, h_control, + HPI_TONEDETECTOR_THRESHOLD, 0, 0, (u32 *)threshold, NULL); } -u16 HPI_SilenceDetector_GetState( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *State -) +u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *state) { - return HPI_ControlParamGet(phSubSys, hControl, - HPI_SILENCEDETECTOR_STATE, 0, 0, (u32 *)State, NULL); + return hpi_control_param_get(ph_subsys, h_control, + HPI_SILENCEDETECTOR_STATE, 0, 0, (u32 *)state, NULL); } -u16 HPI_SilenceDetector_SetEnable( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 Enable -) +u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 enable) { - return HPI_ControlParamSet(phSubSys, hControl, HPI_GENERIC_ENABLE, - (u32)Enable, 0); + return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, + (u32)enable, 0); } -u16 HPI_SilenceDetector_GetEnable( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *Enable -) +u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *enable) { - return HPI_ControlParamGet(phSubSys, hControl, HPI_GENERIC_ENABLE, 0, - 0, (u32 *)Enable, NULL); + return hpi_control_param_get(ph_subsys, h_control, HPI_GENERIC_ENABLE, + 0, 0, (u32 *)enable, NULL); } -u16 HPI_SilenceDetector_SetEventEnable( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 EventEnable -) +u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 event_enable) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_GENERIC_EVENT_ENABLE, (u32)EventEnable, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_GENERIC_EVENT_ENABLE, (u32)event_enable, 0); } -u16 HPI_SilenceDetector_GetEventEnable( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *EventEnable -) +u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *event_enable) { - return HPI_ControlParamGet(phSubSys, hControl, - HPI_GENERIC_EVENT_ENABLE, 0, 0, (u32 *)EventEnable, NULL); + return hpi_control_param_get(ph_subsys, h_control, + HPI_GENERIC_EVENT_ENABLE, 0, 0, (u32 *)event_enable, NULL); } -u16 HPI_SilenceDetector_SetDelay( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 Delay -) +u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 delay) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_SILENCEDETECTOR_DELAY, (u32)Delay, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_SILENCEDETECTOR_DELAY, (u32)delay, 0); } -u16 HPI_SilenceDetector_GetDelay( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *Delay -) +u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *delay) { - return HPI_ControlParamGet(phSubSys, hControl, - HPI_SILENCEDETECTOR_DELAY, 0, 0, (u32 *)Delay, NULL); + return hpi_control_param_get(ph_subsys, h_control, + HPI_SILENCEDETECTOR_DELAY, 0, 0, (u32 *)delay, NULL); } -u16 HPI_SilenceDetector_SetThreshold( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - int Threshold -) +u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, + u32 h_control, int threshold) { - return HPI_ControlParamSet(phSubSys, hControl, - HPI_SILENCEDETECTOR_THRESHOLD, (u32)Threshold, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_SILENCEDETECTOR_THRESHOLD, (u32)threshold, 0); } -u16 HPI_SilenceDetector_GetThreshold( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - int *Threshold -) +u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, + u32 h_control, int *threshold) { - return HPI_ControlParamGet(phSubSys, hControl, - HPI_SILENCEDETECTOR_THRESHOLD, 0, 0, (u32 *)Threshold, NULL); + return hpi_control_param_get(ph_subsys, h_control, + HPI_SILENCEDETECTOR_THRESHOLD, 0, 0, (u32 *)threshold, NULL); } -u16 HPI_Tuner_QueryBand( - const struct hpi_hsubsys *phSubSys, - const u32 hTuner, - const u32 dwIndex, - u16 *pwBand -) +u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys, + const u32 h_tuner, const u32 index, u16 *pw_band) { u32 qr; u16 err; - err = HPI_ControlQuery(phSubSys, hTuner, HPI_TUNER_BAND, - dwIndex, 0, &qr); - *pwBand = (u16)qr; + err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0, + &qr); + *pw_band = (u16)qr; return err; } -u16 HPI_Tuner_SetBand( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 wBand -) +u16 hpi_tuner_set_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 band) { - return HPI_ControlParamSet(phSubSys, hControl, HPI_TUNER_BAND, - wBand, 0); + return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_BAND, + band, 0); } -u16 HPI_Tuner_GetBand( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwBand -) +u16 hpi_tuner_get_band(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 *pw_band) { - u32 dwBand = 0; - u16 nError = 0; + u32 band = 0; + u16 error = 0; - nError = HPI_ControlParam1Get(phSubSys, hControl, - HPI_TUNER_BAND, &dwBand); - if (pwBand) - *pwBand = (u16)dwBand; - return nError; + error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_BAND, + &band); + if (pw_band) + *pw_band = (u16)band; + return error; } -u16 HPI_Tuner_QueryFrequency( - const struct hpi_hsubsys *phSubSys, - const u32 hTuner, - const u32 dwIndex, - const u16 band, - u32 *pdwFreq -) +u16 hpi_tuner_query_frequency(const struct hpi_hsubsys *ph_subsys, + const u32 h_tuner, const u32 index, const u16 band, u32 *pfreq) { - return HPI_ControlQuery(phSubSys, hTuner, HPI_TUNER_FREQ, - dwIndex, band, pdwFreq); + return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_FREQ, index, + band, pfreq); } -u16 HPI_Tuner_SetFrequency( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 wFreqInkHz -) +u16 hpi_tuner_set_frequency(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 freq_ink_hz) { - return HPI_ControlParamSet(phSubSys, hControl, HPI_TUNER_FREQ, - wFreqInkHz, 0); + return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_FREQ, + freq_ink_hz, 0); } -u16 HPI_Tuner_GetFrequency( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pwFreqInkHz -) +u16 hpi_tuner_get_frequency(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pw_freq_ink_hz) { - return HPI_ControlParam1Get(phSubSys, hControl, HPI_TUNER_FREQ, - pwFreqInkHz); + return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_FREQ, + pw_freq_ink_hz); } -u16 HPI_Tuner_QueryGain( - const struct hpi_hsubsys *phSubSys, - const u32 hTuner, - const u32 dwIndex, - u16 *pwGain -) +u16 hpi_tuner_query_gain(const struct hpi_hsubsys *ph_subsys, + const u32 h_tuner, const u32 index, u16 *pw_gain) { u32 qr; u16 err; - err = HPI_ControlQuery(phSubSys, hTuner, HPI_TUNER_BAND, - dwIndex, 0, &qr); - *pwGain = (u16)qr; + err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0, + &qr); + *pw_gain = (u16)qr; return err; } -u16 HPI_Tuner_SetGain( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short nGain -) +u16 hpi_tuner_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short gain) { - return HPI_ControlParamSet(phSubSys, hControl, HPI_TUNER_GAIN, - nGain, 0); + return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_GAIN, + gain, 0); } -u16 HPI_Tuner_GetGain( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short *pnGain -) +u16 hpi_tuner_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short *pn_gain) { - u32 dwGain = 0; - u16 nError = 0; + u32 gain = 0; + u16 error = 0; - nError = HPI_ControlParam1Get(phSubSys, hControl, - HPI_TUNER_GAIN, &dwGain); - if (pnGain) - *pnGain = (u16)dwGain; - return nError; + error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_GAIN, + &gain); + if (pn_gain) + *pn_gain = (u16)gain; + return error; } -u16 HPI_Tuner_GetRFLevel( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short *pwLevel -) +u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short *pw_level) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_TUNER_LEVEL; - hm.u.c.dwParam1 = HPI_TUNER_LEVEL_AVERAGE; - HPI_Message(&hm, &hr); - if (pwLevel) - *pwLevel = (short)hr.u.c.dwParam1; - return hr.wError; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_TUNER_LEVEL; + hm.u.c.param1 = HPI_TUNER_LEVEL_AVERAGE; + hpi_send_recv(&hm, &hr); + if (pw_level) + *pw_level = (short)hr.u.c.param1; + return hr.error; } -u16 HPI_Tuner_GetRawRFLevel( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short *pwLevel -) +u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys, + u32 h_control, short *pw_level) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_TUNER_LEVEL; - hm.u.c.dwParam1 = HPI_TUNER_LEVEL_RAW; - HPI_Message(&hm, &hr); - if (pwLevel) - *pwLevel = (short)hr.u.c.dwParam1; - return hr.wError; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_TUNER_LEVEL; + hm.u.c.param1 = HPI_TUNER_LEVEL_RAW; + hpi_send_recv(&hm, &hr); + if (pw_level) + *pw_level = (short)hr.u.c.param1; + return hr.error; } -u16 HPI_Tuner_QueryDeemphasis( - const struct hpi_hsubsys *phSubSys, - const u32 hTuner, - const u32 dwIndex, - const u16 band, - u32 *pdwDeemphasis -) +u16 hpi_tuner_query_deemphasis(const struct hpi_hsubsys *ph_subsys, + const u32 h_tuner, const u32 index, const u16 band, u32 *pdeemphasis) { - return HPI_ControlQuery(phSubSys, hTuner, HPI_TUNER_DEEMPHASIS, - dwIndex, band, pdwDeemphasis); + return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_DEEMPHASIS, + index, band, pdeemphasis); } -u16 HPI_Tuner_SetDeemphasis( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwDeemphasis -) +u16 hpi_tuner_set_deemphasis(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 deemphasis) { - return HPI_ControlParamSet(phSubSys, hControl, HPI_TUNER_DEEMPHASIS, - dwDeemphasis, 0); + return hpi_control_param_set(ph_subsys, h_control, + HPI_TUNER_DEEMPHASIS, deemphasis, 0); } -u16 HPI_Tuner_GetDeemphasis( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwDeemphasis -) +u16 hpi_tuner_get_deemphasis(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pdeemphasis) { - return HPI_ControlParam1Get(phSubSys, hControl, HPI_TUNER_DEEMPHASIS, - pdwDeemphasis); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_TUNER_DEEMPHASIS, pdeemphasis); } -u16 HPI_Tuner_QueryProgram( - const struct hpi_hsubsys *phSubSys, - const u32 hTuner, - u32 *pbitmapProgram -) +u16 hpi_tuner_query_program(const struct hpi_hsubsys *ph_subsys, + const u32 h_tuner, u32 *pbitmap_program) { - return HPI_ControlQuery(phSubSys, hTuner, HPI_TUNER_PROGRAM, - 0, 0, pbitmapProgram); + return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_PROGRAM, 0, 0, + pbitmap_program); } -u16 HPI_Tuner_SetProgram( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 dwProgram -) +u16 hpi_tuner_set_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 program) { - return HPI_ControlParamSet(phSubSys, hControl, HPI_TUNER_PROGRAM, - dwProgram, 0); + return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_PROGRAM, + program, 0); } -u16 HPI_Tuner_GetProgram( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwProgram -) +u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 *pprogram) { - return HPI_ControlParam1Get(phSubSys, hControl, HPI_TUNER_PROGRAM, - pdwProgram); + return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_PROGRAM, + pprogram); } -u16 HPI_Tuner_GetHdRadioDspVersion( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pszDspVersion, - const u32 dwStringSize -) +u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys, + u32 h_control, char *psz_dsp_version, const u32 string_size) { - return HPI_Control_GetString(phSubSys, - hControl, - HPI_TUNER_HDRADIO_DSP_VERSION, pszDspVersion, dwStringSize); + return hpi_control_get_string(ph_subsys, h_control, + HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size); } -u16 HPI_Tuner_GetHdRadioSdkVersion( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pszSdkVersion, - const u32 dwStringSize -) +u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys, + u32 h_control, char *psz_sdk_version, const u32 string_size) { - return HPI_Control_GetString(phSubSys, - hControl, - HPI_TUNER_HDRADIO_SDK_VERSION, pszSdkVersion, dwStringSize); + return hpi_control_get_string(ph_subsys, h_control, + HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size); } -u16 HPI_Tuner_GetStatus( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u16 *pwStatusMask, - u16 *pwStatus -) +u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u16 *pw_status_mask, u16 *pw_status) { - u32 dwStatus = 0; - u16 nError = 0; + u32 status = 0; + u16 error = 0; - nError = HPI_ControlParam1Get(phSubSys, hControl, - HPI_TUNER_STATUS, &dwStatus); - if (pwStatus) { - if (!nError) { - *pwStatusMask = (u16)(dwStatus >> 16); - *pwStatus = (u16)(dwStatus & 0xFFFF); + error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_STATUS, + &status); + if (pw_status) { + if (!error) { + *pw_status_mask = (u16)(status >> 16); + *pw_status = (u16)(status & 0xFFFF); } else { - *pwStatusMask = 0; - *pwStatus = 0; + *pw_status_mask = 0; + *pw_status = 0; } } - return nError; + return error; } -u16 HPI_Tuner_SetMode( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 nMode, - u32 nValue -) +u16 hpi_tuner_set_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 mode, u32 value) { - return HPI_ControlParamSet(phSubSys, hControl, HPI_TUNER_MODE, - nMode, nValue); + return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_MODE, + mode, value); } -u16 HPI_Tuner_GetMode( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 nMode, - u32 *pnValue -) +u16 hpi_tuner_get_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 mode, u32 *pn_value) { - return HPI_ControlParamGet(phSubSys, hControl, HPI_TUNER_MODE, - nMode, 0, pnValue, NULL); + return hpi_control_param_get(ph_subsys, h_control, HPI_TUNER_MODE, + mode, 0, pn_value, NULL); } -u16 HPI_Tuner_GetHdRadioSignalQuality( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwQuality -) +u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pquality) { - return HPI_ControlParamGet(phSubSys, hControl, - HPI_TUNER_HDRADIO_SIGNAL_QUALITY, 0, 0, pdwQuality, NULL); + return hpi_control_param_get(ph_subsys, h_control, + HPI_TUNER_HDRADIO_SIGNAL_QUALITY, 0, 0, pquality, NULL); } -u16 HPI_Tuner_GetRDS( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pData -) +u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control, + char *p_data) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_TUNER_RDS; - HPI_Message(&hm, &hr); - if (pData) { - *(u32 *)&pData[0] = hr.u.cu.tuner.rds.dwData[0]; - *(u32 *)&pData[4] = hr.u.cu.tuner.rds.dwData[1]; - *(u32 *)&pData[8] = hr.u.cu.tuner.rds.dwBLER; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_TUNER_RDS; + hpi_send_recv(&hm, &hr); + if (p_data) { + *(u32 *)&p_data[0] = hr.u.cu.tuner.rds.data[0]; + *(u32 *)&p_data[4] = hr.u.cu.tuner.rds.data[1]; + *(u32 *)&p_data[8] = hr.u.cu.tuner.rds.bLER; } - return hr.wError; + return hr.error; } -u16 HPI_PAD_GetChannelName( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pszString, - const u32 dwDataLength -) +u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys, + u32 h_control, char *psz_string, const u32 data_length) { - return HPI_Control_GetString(phSubSys, - hControl, HPI_PAD_CHANNEL_NAME, pszString, dwDataLength); + return hpi_control_get_string(ph_subsys, h_control, + HPI_PAD_CHANNEL_NAME, psz_string, data_length); } -u16 HPI_PAD_GetArtist( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pszString, - const u32 dwDataLength -) +u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control, + char *psz_string, const u32 data_length) { - return HPI_Control_GetString(phSubSys, - hControl, HPI_PAD_ARTIST, pszString, dwDataLength); + return hpi_control_get_string(ph_subsys, h_control, HPI_PAD_ARTIST, + psz_string, data_length); } -u16 HPI_PAD_GetTitle( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pszString, - const u32 dwDataLength -) +u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control, + char *psz_string, const u32 data_length) { - return HPI_Control_GetString(phSubSys, - hControl, HPI_PAD_TITLE, pszString, dwDataLength); + return hpi_control_get_string(ph_subsys, h_control, HPI_PAD_TITLE, + psz_string, data_length); } -u16 HPI_PAD_GetComment( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - char *pszString, - const u32 dwDataLength -) +u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control, + char *psz_string, const u32 data_length) { - return HPI_Control_GetString(phSubSys, - hControl, HPI_PAD_COMMENT, pszString, dwDataLength); + return hpi_control_get_string(ph_subsys, h_control, HPI_PAD_COMMENT, + psz_string, data_length); } -u16 HPI_PAD_GetProgramType( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwPTY -) +u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *ppTY) { - return HPI_ControlParamGet(phSubSys, hControl, HPI_PAD_PROGRAM_TYPE, - 0, 0, pdwPTY, NULL); + return hpi_control_param_get(ph_subsys, h_control, + HPI_PAD_PROGRAM_TYPE, 0, 0, ppTY, NULL); } -u16 HPI_PAD_GetRdsPI( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - u32 *pdwPI -) +u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control, + u32 *ppI) { - return HPI_ControlParamGet(phSubSys, hControl, HPI_PAD_PROGRAM_ID, - 0, 0, pdwPI, NULL); + return hpi_control_param_get(ph_subsys, h_control, HPI_PAD_PROGRAM_ID, + 0, 0, ppI, NULL); } -u16 HPI_Volume_QueryChannels( - const struct hpi_hsubsys *phSubSys, - const u32 hVolume, - u32 *pChannels -) +u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys, + const u32 h_volume, u32 *p_channels) { - return HPI_ControlQuery(phSubSys, hVolume, HPI_VOLUME_NUM_CHANNELS, - 0, 0, pChannels); + return hpi_control_query(ph_subsys, h_volume, HPI_VOLUME_NUM_CHANNELS, + 0, 0, p_channels); } -u16 HPI_VolumeSetGain( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anLogGain[HPI_MAX_CHANNELS] -) +u16 hpi_volume_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_log_gain[HPI_MAX_CHANNELS] + ) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - memcpy(hm.u.c.anLogValue, anLogGain, + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + memcpy(hm.u.c.an_log_value, an_log_gain, sizeof(short) * HPI_MAX_CHANNELS); - hm.u.c.wAttribute = HPI_VOLUME_GAIN; + hm.u.c.attribute = HPI_VOLUME_GAIN; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_VolumeGetGain( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anLogGain[HPI_MAX_CHANNELS] -) +u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_log_gain[HPI_MAX_CHANNELS] + ) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_VOLUME_GAIN; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_VOLUME_GAIN; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - memcpy(anLogGain, hr.u.c.anLogValue, + memcpy(an_log_gain, hr.u.c.an_log_value, sizeof(short) * HPI_MAX_CHANNELS); - return hr.wError; + return hr.error; } -u16 HPI_VolumeQueryRange( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short *nMinGain_01dB, - short *nMaxGain_01dB, - short *nStepGain_01dB -) +u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_VOLUME_RANGE; - - HPI_Message(&hm, &hr); - if (hr.wError) { - hr.u.c.anLogValue[0] = 0; - hr.u.c.anLogValue[1] = 0; - hr.u.c.dwParam1 = 0; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_VOLUME_RANGE; + + hpi_send_recv(&hm, &hr); + if (hr.error) { + hr.u.c.an_log_value[0] = 0; + hr.u.c.an_log_value[1] = 0; + hr.u.c.param1 = 0; } - if (nMinGain_01dB) - *nMinGain_01dB = hr.u.c.anLogValue[0]; - if (nMaxGain_01dB) - *nMaxGain_01dB = hr.u.c.anLogValue[1]; - if (nStepGain_01dB) - *nStepGain_01dB = (short)hr.u.c.dwParam1; - return hr.wError; -} - -u16 HPI_VolumeAutoFadeProfile( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anStopGain0_01dB[HPI_MAX_CHANNELS], - u32 dwDurationMs, - u16 wProfile -) + if (min_gain_01dB) + *min_gain_01dB = hr.u.c.an_log_value[0]; + if (max_gain_01dB) + *max_gain_01dB = hr.u.c.an_log_value[1]; + if (step_gain_01dB) + *step_gain_01dB = (short)hr.u.c.param1; + return hr.error; +} + +u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys, + u32 h_control, short an_stop_gain0_01dB[HPI_MAX_CHANNELS], + u32 duration_ms, u16 profile) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); - memcpy(hm.u.c.anLogValue, anStopGain0_01dB, + memcpy(hm.u.c.an_log_value, an_stop_gain0_01dB, sizeof(short) * HPI_MAX_CHANNELS); - hm.u.c.wAttribute = HPI_VOLUME_AUTOFADE; - hm.u.c.dwParam1 = dwDurationMs; - hm.u.c.dwParam2 = wProfile; + hm.u.c.attribute = HPI_VOLUME_AUTOFADE; + hm.u.c.param1 = duration_ms; + hm.u.c.param2 = profile; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_VolumeAutoFade( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anStopGain0_01dB[HPI_MAX_CHANNELS], - u32 dwDurationMs -) +u16 hpi_volume_auto_fade(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms) { - return HPI_VolumeAutoFadeProfile(phSubSys, - hControl, - anStopGain0_01dB, dwDurationMs, HPI_VOLUME_AUTOFADE_LOG); + return hpi_volume_auto_fade_profile(ph_subsys, h_control, + an_stop_gain0_01dB, duration_ms, HPI_VOLUME_AUTOFADE_LOG); } -u16 HPI_VoxSetThreshold( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short anGain0_01dB -) +u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short an_gain0_01dB) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_VOX_THRESHOLD; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_VOX_THRESHOLD; - hm.u.c.anLogValue[0] = anGain0_01dB; + hm.u.c.an_log_value[0] = an_gain0_01dB; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_VoxGetThreshold( - const struct hpi_hsubsys *phSubSys, - u32 hControl, - short *anGain0_01dB -) +u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, + short *an_gain0_01dB) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_CONTROL, + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hControl, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.c.wAttribute = HPI_VOX_THRESHOLD; + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = HPI_VOX_THRESHOLD; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - *anGain0_01dB = hr.u.c.anLogValue[0]; + *an_gain0_01dB = hr.u.c.an_log_value[0]; - return hr.wError; + return hr.error; } static size_t strv_packet_size = MIN_STRV_PACKET_SIZE; @@ -3861,68 +3163,51 @@ static size_t entity_type_to_size[LAST_ENTITY_TYPE] = { 6 * sizeof(char), }; -inline size_t hpi_entity_size( - struct hpi_entity *entity_ptr -) +inline size_t hpi_entity_size(struct hpi_entity *entity_ptr) { return entity_ptr->header.size; } -inline size_t hpi_entity_header_size( - struct hpi_entity *entity_ptr -) +inline size_t hpi_entity_header_size(struct hpi_entity *entity_ptr) { return sizeof(entity_ptr->header); } -inline size_t hpi_entity_value_size( - struct hpi_entity *entity_ptr -) +inline size_t hpi_entity_value_size(struct hpi_entity *entity_ptr) { return hpi_entity_size(entity_ptr) - hpi_entity_header_size(entity_ptr); } -inline size_t hpi_entity_item_count( - struct hpi_entity *entity_ptr -) +inline size_t hpi_entity_item_count(struct hpi_entity *entity_ptr) { return hpi_entity_value_size(entity_ptr) / entity_type_to_size[entity_ptr->header.type]; } -inline struct hpi_entity *hpi_entity_ptr_to_next( - struct hpi_entity *entity_ptr -) +inline struct hpi_entity *hpi_entity_ptr_to_next(struct hpi_entity + *entity_ptr) { return (void *)(((uint8_t *) entity_ptr) + hpi_entity_size(entity_ptr)); } -inline u16 hpi_entity_check_type( - const enum e_entity_type t -) +inline u16 hpi_entity_check_type(const enum e_entity_type t) { if (t >= 0 && t < STR_TYPE_FIELD_MAX) return 0; return HPI_ERROR_ENTITY_TYPE_INVALID; } -inline u16 hpi_entity_check_role( - const enum e_entity_role r -) +inline u16 hpi_entity_check_role(const enum e_entity_role r) { if (r >= 0 && r < STR_ROLE_FIELD_MAX) return 0; return HPI_ERROR_ENTITY_ROLE_INVALID; } -static u16 HPI_Entity_GetNext( - struct hpi_entity *entity, - int recursive_flag, - void *guard_p, - struct hpi_entity **next -) +static u16 hpi_entity_get_next(struct hpi_entity *entity, int recursive_flag, + void *guard_p, struct hpi_entity **next) { HPI_DEBUG_ASSERT(entity != NULL); HPI_DEBUG_ASSERT(next != NULL); @@ -3947,13 +3232,9 @@ static u16 HPI_Entity_GetNext( return 0; } -u16 HPI_Entity_FindNext( - struct hpi_entity *container_entity, - enum e_entity_type type, - enum e_entity_role role, - int recursive_flag, - struct hpi_entity **current_match -) +u16 hpi_entity_find_next(struct hpi_entity *container_entity, + enum e_entity_type type, enum e_entity_role role, int recursive_flag, + struct hpi_entity **current_match) { struct hpi_entity *tmp = NULL; void *guard_p = NULL; @@ -3962,10 +3243,10 @@ u16 HPI_Entity_FindNext( guard_p = hpi_entity_ptr_to_next(container_entity); if (*current_match != NULL) - HPI_Entity_GetNext(*current_match, recursive_flag, guard_p, + hpi_entity_get_next(*current_match, recursive_flag, guard_p, &tmp); else - HPI_Entity_GetNext(container_entity, 1, guard_p, &tmp); + hpi_entity_get_next(container_entity, 1, guard_p, &tmp); while (tmp) { u16 err; @@ -3978,7 +3259,7 @@ u16 HPI_Entity_FindNext( return 0; } - err = HPI_Entity_GetNext(tmp, recursive_flag, guard_p, + err = hpi_entity_get_next(tmp, recursive_flag, guard_p, current_match); if (err) return err; @@ -3990,18 +3271,13 @@ u16 HPI_Entity_FindNext( return 0; } -void HPI_Entity_Free( - struct hpi_entity *entity -) +void hpi_entity_free(struct hpi_entity *entity) { if (entity != NULL) kfree(entity); } -u16 HPI_Entity_AllocAndCopy( - struct hpi_entity *src, - struct hpi_entity **dst -) +u16 hpi_entity_alloc_and_copy(struct hpi_entity *src, struct hpi_entity **dst) { size_t buf_size; HPI_DEBUG_ASSERT(dst != NULL); @@ -4015,11 +3291,8 @@ u16 HPI_Entity_AllocAndCopy( return 0; } -u16 HPI_Universal_Info( - const struct hpi_hsubsys *phSubSys, - u32 hC, - struct hpi_entity **info -) +u16 hpi_universal_info(const struct hpi_hsubsys *ph_subsys, u32 hC, + struct hpi_entity **info) { struct hpi_msg_strv hm; struct hpi_res_strv *phr; @@ -4033,40 +3306,37 @@ u16 HPI_Universal_Info( phr = kmalloc(resp_packet_size, GFP_KERNEL); HPI_DEBUG_ASSERT(phr != NULL); - HPI_InitMessageResponseV1(&hm.h, (u16)sizeof(hm), &phr->h, + hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h, (u16)resp_packet_size, HPI_OBJ_CONTROL, HPI_CONTROL_GET_INFO); - u32TOINDEXES(hC, &hm.h.wAdapterIndex, &hm.h.wObjIndex); + u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index); hm.strv.header.size = sizeof(hm.strv); phr->strv.header.size = resp_packet_size - sizeof(phr->h); - HPI_Message((struct hpi_message *)&hm.h, + hpi_send_recv((struct hpi_message *)&hm.h, (struct hpi_response *)&phr->h); - if (phr->h.wError == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) { + if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) { - HPI_DEBUG_ASSERT(phr->h.wSpecificError > + HPI_DEBUG_ASSERT(phr->h.specific_error > MIN_STRV_PACKET_SIZE - && phr->h.wSpecificError < 1500); - resp_packet_size = phr->h.wSpecificError; + && phr->h.specific_error < 1500); + resp_packet_size = phr->h.specific_error; } else { remaining_attempts = 0; - if (!phr->h.wError) - HPI_Entity_AllocAndCopy(&phr->strv, info); + if (!phr->h.error) + hpi_entity_alloc_and_copy(&phr->strv, info); } - hpi_err = phr->h.wError; + hpi_err = phr->h.error; kfree(phr); } return hpi_err; } -u16 HPI_Universal_Get( - const struct hpi_hsubsys *phSubSys, - u32 hC, - struct hpi_entity **value -) +u16 hpi_universal_get(const struct hpi_hsubsys *ph_subsys, u32 hC, + struct hpi_entity **value) { struct hpi_msg_strv hm; struct hpi_res_strv *phr; @@ -4080,40 +3350,37 @@ u16 HPI_Universal_Get( if (!phr) return HPI_ERROR_MEMORY_ALLOC; - HPI_InitMessageResponseV1(&hm.h, (u16)sizeof(hm), &phr->h, + hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h, (u16)strv_packet_size, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); - u32TOINDEXES(hC, &hm.h.wAdapterIndex, &hm.h.wObjIndex); + u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index); hm.strv.header.size = sizeof(hm.strv); phr->strv.header.size = strv_packet_size - sizeof(phr->h); - HPI_Message((struct hpi_message *)&hm.h, + hpi_send_recv((struct hpi_message *)&hm.h, (struct hpi_response *)&phr->h); - if (phr->h.wError == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) { + if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) { - HPI_DEBUG_ASSERT(phr->h.wSpecificError > + HPI_DEBUG_ASSERT(phr->h.specific_error > MIN_STRV_PACKET_SIZE - && phr->h.wSpecificError < 1000); - strv_packet_size = phr->h.wSpecificError; + && phr->h.specific_error < 1000); + strv_packet_size = phr->h.specific_error; } else { remaining_attempts = 0; - if (!phr->h.wError) - HPI_Entity_AllocAndCopy(&phr->strv, value); + if (!phr->h.error) + hpi_entity_alloc_and_copy(&phr->strv, value); } - hpi_err = phr->h.wError; + hpi_err = phr->h.error; kfree(phr); } return hpi_err; } -u16 HPI_Universal_Set( - const struct hpi_hsubsys *phSubSys, - u32 hC, - struct hpi_entity *value -) +u16 hpi_universal_set(const struct hpi_hsubsys *ph_subsys, u32 hC, + struct hpi_entity *value) { struct hpi_msg_strv *phm; struct hpi_res_strv hr; @@ -4121,34 +3388,30 @@ u16 HPI_Universal_Set( phm = kmalloc(sizeof(phm->h) + value->header.size, GFP_KERNEL); HPI_DEBUG_ASSERT(phm != NULL); - HPI_InitMessageResponseV1(&phm->h, + hpi_init_message_responseV1(&phm->h, sizeof(phm->h) + value->header.size, &hr.h, sizeof(hr), HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); - u32TOINDEXES(hC, &phm->h.wAdapterIndex, &phm->h.wObjIndex); + u32TOINDEXES(hC, &phm->h.adapter_index, &phm->h.obj_index); hr.strv.header.size = sizeof(hr.strv); memcpy(&phm->strv, value, value->header.size); - HPI_Message((struct hpi_message *)&phm->h, + hpi_send_recv((struct hpi_message *)&phm->h, (struct hpi_response *)&hr.h); - return hr.h.wError; + return hr.h.error; } -u16 HPI_Entity_AllocAndPack( - const enum e_entity_type type, - const size_t item_count, - const enum e_entity_role role, - void *value, - struct hpi_entity **entity -) +u16 hpi_entity_alloc_and_pack(const enum e_entity_type type, + const size_t item_count, const enum e_entity_role role, void *value, + struct hpi_entity **entity) { size_t bytes_to_copy, total_size; - u16 wHE = 0; + u16 hE = 0; *entity = 0; - wHE = hpi_entity_check_type(type); - if (wHE) - return wHE; + hE = hpi_entity_check_type(type); + if (hE) + return hE; HPI_DEBUG_ASSERT(role > entity_role_null && type < LAST_ENTITY_ROLE); @@ -4169,12 +3432,8 @@ u16 HPI_Entity_AllocAndPack( return 0; } -u16 HPI_Entity_CopyValueFrom( - struct hpi_entity *entity, - enum e_entity_type type, - size_t item_count, - void *value_dst_p -) +u16 hpi_entity_copy_value_from(struct hpi_entity *entity, + enum e_entity_type type, size_t item_count, void *value_dst_p) { size_t bytes_to_copy; @@ -4189,13 +3448,8 @@ u16 HPI_Entity_CopyValueFrom( return 0; } -u16 HPI_Entity_Unpack( - struct hpi_entity *entity, - enum e_entity_type *type, - size_t *item_count, - enum e_entity_role *role, - void **value -) +u16 hpi_entity_unpack(struct hpi_entity *entity, enum e_entity_type *type, + size_t *item_count, enum e_entity_role *role, void **value) { u16 err = 0; HPI_DEBUG_ASSERT(entity != NULL); @@ -4218,8 +3472,8 @@ u16 HPI_Entity_Unpack( *item_count = 0; while (contents < guard_p) { (*item_count)++; - err = HPI_Entity_GetNext(contents, 0, guard_p, - &next); + err = hpi_entity_get_next(contents, 0, + guard_p, &next); if (next == NULL || err) break; contents = next; @@ -4231,465 +3485,386 @@ u16 HPI_Entity_Unpack( return err; } -u16 HPI_GpioOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *phGpio, - u16 *pwNumberInputBits, - u16 *pwNumberOutputBits -) +u16 hpi_gpio_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u32 *ph_gpio, u16 *pw_number_input_bits, u16 *pw_number_output_bits) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_OPEN); - hm.wAdapterIndex = wAdapterIndex; + hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_OPEN); + hm.adapter_index = adapter_index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (hr.wError == 0) { - *phGpio = HPI_IndexesToHandle(HPI_OBJ_GPIO, wAdapterIndex, 0); - if (pwNumberInputBits) - *pwNumberInputBits = hr.u.l.wNumberInputBits; - if (pwNumberOutputBits) - *pwNumberOutputBits = hr.u.l.wNumberOutputBits; + if (hr.error == 0) { + *ph_gpio = + hpi_indexes_to_handle(HPI_OBJ_GPIO, adapter_index, 0); + if (pw_number_input_bits) + *pw_number_input_bits = hr.u.l.number_input_bits; + if (pw_number_output_bits) + *pw_number_output_bits = hr.u.l.number_output_bits; } else - *phGpio = 0; - return hr.wError; + *ph_gpio = 0; + return hr.error; } -u16 HPI_GpioReadBit( - const struct hpi_hsubsys *phSubSys, - u32 hGpio, - u16 wBitIndex, - u16 *pwBitData -) +u16 hpi_gpio_read_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, + u16 bit_index, u16 *pw_bit_data) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_BIT); - u32TOINDEX(hGpio, &hm.wAdapterIndex); - hm.u.l.wBitIndex = wBitIndex; + hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_BIT); + u32TOINDEX(h_gpio, &hm.adapter_index); + hm.u.l.bit_index = bit_index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - *pwBitData = hr.u.l.wBitData[0]; - return hr.wError; + *pw_bit_data = hr.u.l.bit_data[0]; + return hr.error; } -u16 HPI_GpioReadAllBits( - const struct hpi_hsubsys *phSubSys, - u32 hGpio, - u16 awAllBitData[4] -) +u16 hpi_gpio_read_all_bits(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, + u16 aw_all_bit_data[4] + ) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_ALL); - u32TOINDEX(hGpio, &hm.wAdapterIndex); + hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_ALL); + u32TOINDEX(h_gpio, &hm.adapter_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (awAllBitData) { - awAllBitData[0] = hr.u.l.wBitData[0]; - awAllBitData[1] = hr.u.l.wBitData[1]; - awAllBitData[2] = hr.u.l.wBitData[2]; - awAllBitData[3] = hr.u.l.wBitData[3]; + if (aw_all_bit_data) { + aw_all_bit_data[0] = hr.u.l.bit_data[0]; + aw_all_bit_data[1] = hr.u.l.bit_data[1]; + aw_all_bit_data[2] = hr.u.l.bit_data[2]; + aw_all_bit_data[3] = hr.u.l.bit_data[3]; } - return hr.wError; + return hr.error; } -u16 HPI_GpioWriteBit( - const struct hpi_hsubsys *phSubSys, - u32 hGpio, - u16 wBitIndex, - u16 wBitData -) +u16 hpi_gpio_write_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, + u16 bit_index, u16 bit_data) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_WRITE_BIT); - u32TOINDEX(hGpio, &hm.wAdapterIndex); - hm.u.l.wBitIndex = wBitIndex; - hm.u.l.wBitData = wBitData; + hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_WRITE_BIT); + u32TOINDEX(h_gpio, &hm.adapter_index); + hm.u.l.bit_index = bit_index; + hm.u.l.bit_data = bit_data; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_GpioWriteStatus( - const struct hpi_hsubsys *phSubSys, - u32 hGpio, - u16 awAllBitData[4] -) +u16 hpi_gpio_write_status(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, + u16 aw_all_bit_data[4] + ) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_GPIO, + hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_WRITE_STATUS); - u32TOINDEX(hGpio, &hm.wAdapterIndex); + u32TOINDEX(h_gpio, &hm.adapter_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (awAllBitData) { - awAllBitData[0] = hr.u.l.wBitData[0]; - awAllBitData[1] = hr.u.l.wBitData[1]; - awAllBitData[2] = hr.u.l.wBitData[2]; - awAllBitData[3] = hr.u.l.wBitData[3]; + if (aw_all_bit_data) { + aw_all_bit_data[0] = hr.u.l.bit_data[0]; + aw_all_bit_data[1] = hr.u.l.bit_data[1]; + aw_all_bit_data[2] = hr.u.l.bit_data[2]; + aw_all_bit_data[3] = hr.u.l.bit_data[3]; } - return hr.wError; + return hr.error; } -u16 HPI_AsyncEventOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *phAsync -) +u16 hpi_async_event_open(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u32 *ph_async) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ASYNCEVENT, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT, HPI_ASYNCEVENT_OPEN); - hm.wAdapterIndex = wAdapterIndex; + hm.adapter_index = adapter_index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (hr.wError == 0) + if (hr.error == 0) - *phAsync = - HPI_IndexesToHandle(HPI_OBJ_ASYNCEVENT, wAdapterIndex, - 0); + *ph_async = + hpi_indexes_to_handle(HPI_OBJ_ASYNCEVENT, + adapter_index, 0); else - *phAsync = 0; - return hr.wError; + *ph_async = 0; + return hr.error; } -u16 HPI_AsyncEventClose( - const struct hpi_hsubsys *phSubSys, - u32 hAsync -) +u16 hpi_async_event_close(const struct hpi_hsubsys *ph_subsys, u32 h_async) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ASYNCEVENT, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT, HPI_ASYNCEVENT_OPEN); - u32TOINDEX(hAsync, &hm.wAdapterIndex); + u32TOINDEX(h_async, &hm.adapter_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_AsyncEventWait( - const struct hpi_hsubsys *phSubSys, - u32 hAsync, - u16 wMaximumEvents, - struct hpi_async_event *pEvents, - u16 *pwNumberReturned -) +u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async, + u16 maximum_events, struct hpi_async_event *p_events, + u16 *pw_number_returned) { return (0); } -u16 HPI_AsyncEventGetCount( - const struct hpi_hsubsys *phSubSys, - u32 hAsync, - u16 *pwCount -) +u16 hpi_async_event_get_count(const struct hpi_hsubsys *ph_subsys, + u32 h_async, u16 *pw_count) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ASYNCEVENT, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT, HPI_ASYNCEVENT_GETCOUNT); - u32TOINDEX(hAsync, &hm.wAdapterIndex); + u32TOINDEX(h_async, &hm.adapter_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (hr.wError == 0) - if (pwCount) - *pwCount = hr.u.as.u.count.wCount; + if (hr.error == 0) + if (pw_count) + *pw_count = hr.u.as.u.count.count; - return hr.wError; + return hr.error; } -u16 HPI_AsyncEventGet( - const struct hpi_hsubsys *phSubSys, - u32 hAsync, - u16 wMaximumEvents, - struct hpi_async_event *pEvents, - u16 *pwNumberReturned -) +u16 hpi_async_event_get(const struct hpi_hsubsys *ph_subsys, u32 h_async, + u16 maximum_events, struct hpi_async_event *p_events, + u16 *pw_number_returned) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ASYNCEVENT, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT, HPI_ASYNCEVENT_GET); - u32TOINDEX(hAsync, &hm.wAdapterIndex); + u32TOINDEX(h_async, &hm.adapter_index); - HPI_Message(&hm, &hr); - if (!hr.wError) { - memcpy(pEvents, &hr.u.as.u.event, + hpi_send_recv(&hm, &hr); + if (!hr.error) { + memcpy(p_events, &hr.u.as.u.event, sizeof(struct hpi_async_event)); - *pwNumberReturned = 1; + *pw_number_returned = 1; } - return hr.wError; + return hr.error; } -u16 HPI_NvMemoryOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *phNvMemory, - u16 *pwSizeInBytes -) +u16 hpi_nv_memory_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u32 *ph_nv_memory, u16 *pw_size_in_bytes) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_NVMEMORY, + hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY, HPI_NVMEMORY_OPEN); - hm.wAdapterIndex = wAdapterIndex; + hm.adapter_index = adapter_index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (hr.wError == 0) { - *phNvMemory = - HPI_IndexesToHandle(HPI_OBJ_NVMEMORY, wAdapterIndex, + if (hr.error == 0) { + *ph_nv_memory = + hpi_indexes_to_handle(HPI_OBJ_NVMEMORY, adapter_index, 0); - if (pwSizeInBytes) - *pwSizeInBytes = hr.u.n.wSizeInBytes; + if (pw_size_in_bytes) + *pw_size_in_bytes = hr.u.n.size_in_bytes; } else - *phNvMemory = 0; - return hr.wError; + *ph_nv_memory = 0; + return hr.error; } -u16 HPI_NvMemoryReadByte( - const struct hpi_hsubsys *phSubSys, - u32 hNvMemory, - u16 wIndex, - u16 *pwData -) +u16 hpi_nv_memory_read_byte(const struct hpi_hsubsys *ph_subsys, + u32 h_nv_memory, u16 index, u16 *pw_data) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_NVMEMORY, + hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY, HPI_NVMEMORY_READ_BYTE); - u32TOINDEX(hNvMemory, &hm.wAdapterIndex); - hm.u.n.wAddress = wIndex; + u32TOINDEX(h_nv_memory, &hm.adapter_index); + hm.u.n.address = index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - *pwData = hr.u.n.wData; - return hr.wError; + *pw_data = hr.u.n.data; + return hr.error; } -u16 HPI_NvMemoryWriteByte( - const struct hpi_hsubsys *phSubSys, - u32 hNvMemory, - u16 wIndex, - u16 wData -) +u16 hpi_nv_memory_write_byte(const struct hpi_hsubsys *ph_subsys, + u32 h_nv_memory, u16 index, u16 data) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_NVMEMORY, + hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY, HPI_NVMEMORY_WRITE_BYTE); - u32TOINDEX(hNvMemory, &hm.wAdapterIndex); - hm.u.n.wAddress = wIndex; - hm.u.n.wData = wData; + u32TOINDEX(h_nv_memory, &hm.adapter_index); + hm.u.n.address = index; + hm.u.n.data = data; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_ProfileOpenAll( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u16 wProfileIndex, - u32 *phProfile, - u16 *pwMaxProfiles -) +u16 hpi_profile_open_all(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 profile_index, u32 *ph_profile, + u16 *pw_max_profiles) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_PROFILE, + hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_OPEN_ALL); - hm.wAdapterIndex = wAdapterIndex; - hm.wObjIndex = wProfileIndex; - HPI_Message(&hm, &hr); - - *pwMaxProfiles = hr.u.p.u.o.wMaxProfiles; - if (hr.wError == 0) - *phProfile = - HPI_IndexesToHandle(HPI_OBJ_PROFILE, wAdapterIndex, - wProfileIndex); + hm.adapter_index = adapter_index; + hm.obj_index = profile_index; + hpi_send_recv(&hm, &hr); + + *pw_max_profiles = hr.u.p.u.o.max_profiles; + if (hr.error == 0) + *ph_profile = + hpi_indexes_to_handle(HPI_OBJ_PROFILE, adapter_index, + profile_index); else - *phProfile = 0; - return hr.wError; + *ph_profile = 0; + return hr.error; } -u16 HPI_ProfileGet( - const struct hpi_hsubsys *phSubSys, - u32 hProfile, - u16 wBinIndex, - u16 *pwSeconds, - u32 *pdwMicroSeconds, - u32 *pdwCallCount, - u32 *pdwMaxMicroSeconds, - u32 *pdwMinMicroSeconds -) +u16 hpi_profile_get(const struct hpi_hsubsys *ph_subsys, u32 h_profile, + u16 bin_index, u16 *pw_seconds, u32 *pmicro_seconds, u32 *pcall_count, + u32 *pmax_micro_seconds, u32 *pmin_micro_seconds) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_GET); - u32TOINDEXES(hProfile, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.p.wBinIndex = wBinIndex; - HPI_Message(&hm, &hr); - if (pwSeconds) - *pwSeconds = hr.u.p.u.t.wSeconds; - if (pdwMicroSeconds) - *pdwMicroSeconds = hr.u.p.u.t.dwMicroSeconds; - if (pdwCallCount) - *pdwCallCount = hr.u.p.u.t.dwCallCount; - if (pdwMaxMicroSeconds) - *pdwMaxMicroSeconds = hr.u.p.u.t.dwMaxMicroSeconds; - if (pdwMinMicroSeconds) - *pdwMinMicroSeconds = hr.u.p.u.t.dwMinMicroSeconds; - return hr.wError; -} - -u16 HPI_ProfileGetUtilization( - const struct hpi_hsubsys *phSubSys, - u32 hProfile, - u32 *pdwUtilization -) + hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_GET); + u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index); + hm.u.p.bin_index = bin_index; + hpi_send_recv(&hm, &hr); + if (pw_seconds) + *pw_seconds = hr.u.p.u.t.seconds; + if (pmicro_seconds) + *pmicro_seconds = hr.u.p.u.t.micro_seconds; + if (pcall_count) + *pcall_count = hr.u.p.u.t.call_count; + if (pmax_micro_seconds) + *pmax_micro_seconds = hr.u.p.u.t.max_micro_seconds; + if (pmin_micro_seconds) + *pmin_micro_seconds = hr.u.p.u.t.min_micro_seconds; + return hr.error; +} + +u16 hpi_profile_get_utilization(const struct hpi_hsubsys *ph_subsys, + u32 h_profile, u32 *putilization) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_PROFILE, + hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_GET_UTILIZATION); - u32TOINDEXES(hProfile, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); - if (hr.wError) { - if (pdwUtilization) - *pdwUtilization = 0; + u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); + if (hr.error) { + if (putilization) + *putilization = 0; } else { - if (pdwUtilization) - *pdwUtilization = hr.u.p.u.t.dwCallCount; + if (putilization) + *putilization = hr.u.p.u.t.call_count; } - return hr.wError; + return hr.error; } -u16 HPI_ProfileGetName( - const struct hpi_hsubsys *phSubSys, - u32 hProfile, - u16 wBinIndex, - char *szName, - u16 nNameLength -) +u16 hpi_profile_get_name(const struct hpi_hsubsys *ph_subsys, u32 h_profile, + u16 bin_index, char *sz_name, u16 name_length) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_PROFILE, + hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_GET_NAME); - u32TOINDEXES(hProfile, &hm.wAdapterIndex, &hm.wObjIndex); - hm.u.p.wBinIndex = wBinIndex; - HPI_Message(&hm, &hr); - if (hr.wError) { - if (szName) - strcpy(szName, "??"); + u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index); + hm.u.p.bin_index = bin_index; + hpi_send_recv(&hm, &hr); + if (hr.error) { + if (sz_name) + strcpy(sz_name, "??"); } else { - if (szName) - memcpy(szName, (char *)hr.u.p.u.n.szName, - nNameLength); + if (sz_name) + memcpy(sz_name, (char *)hr.u.p.u.n.sz_name, + name_length); } - return hr.wError; + return hr.error; } -u16 HPI_ProfileStartAll( - const struct hpi_hsubsys *phSubSys, - u32 hProfile -) +u16 hpi_profile_start_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_PROFILE, + hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_START_ALL); - u32TOINDEXES(hProfile, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); + u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_ProfileStopAll( - const struct hpi_hsubsys *phSubSys, - u32 hProfile -) +u16 hpi_profile_stop_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_PROFILE, + hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_STOP_ALL); - u32TOINDEXES(hProfile, &hm.wAdapterIndex, &hm.wObjIndex); - HPI_Message(&hm, &hr); + u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_WatchdogOpen( - const struct hpi_hsubsys *phSubSys, - u16 wAdapterIndex, - u32 *phWatchdog -) +u16 hpi_watchdog_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, + u32 *ph_watchdog) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_WATCHDOG, + hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG, HPI_WATCHDOG_OPEN); - hm.wAdapterIndex = wAdapterIndex; + hm.adapter_index = adapter_index; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - if (hr.wError == 0) - *phWatchdog = - HPI_IndexesToHandle(HPI_OBJ_WATCHDOG, wAdapterIndex, + if (hr.error == 0) + *ph_watchdog = + hpi_indexes_to_handle(HPI_OBJ_WATCHDOG, adapter_index, 0); else - *phWatchdog = 0; - return hr.wError; + *ph_watchdog = 0; + return hr.error; } -u16 HPI_WatchdogSetTime( - const struct hpi_hsubsys *phSubSys, - u32 hWatchdog, - u32 dwTimeMillisec -) +u16 hpi_watchdog_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog, + u32 time_millisec) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_WATCHDOG, + hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG, HPI_WATCHDOG_SET_TIME); - u32TOINDEX(hWatchdog, &hm.wAdapterIndex); - hm.u.w.dwTimeMs = dwTimeMillisec; + u32TOINDEX(h_watchdog, &hm.adapter_index); + hm.u.w.time_ms = time_millisec; - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } -u16 HPI_WatchdogPing( - const struct hpi_hsubsys *phSubSys, - u32 hWatchdog -) +u16 hpi_watchdog_ping(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_WATCHDOG, + hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG, HPI_WATCHDOG_PING); - u32TOINDEX(hWatchdog, &hm.wAdapterIndex); + u32TOINDEX(h_watchdog, &hm.adapter_index); - HPI_Message(&hm, &hr); + hpi_send_recv(&hm, &hr); - return hr.wError; + return hr.error; } diff --git a/pci/asihpi/hpimsginit.c b/pci/asihpi/hpimsginit.c index 6e14c493a..f104e4efe 100644 --- a/pci/asihpi/hpimsginit.c +++ b/pci/asihpi/hpimsginit.c @@ -25,11 +25,11 @@ #include "hpimsginit.h" /* The actual message size for each object type */ -static u16 aMsgSize[HPI_OBJ_MAXINDEX + 1] = HPI_MESSAGE_SIZE_BY_OBJECT; +static u16 msg_size[HPI_OBJ_MAXINDEX + 1] = HPI_MESSAGE_SIZE_BY_OBJECT; /* The actual response size for each object type */ -static u16 aResSize[HPI_OBJ_MAXINDEX + 1] = HPI_RESPONSE_SIZE_BY_OBJECT; +static u16 res_size[HPI_OBJ_MAXINDEX + 1] = HPI_RESPONSE_SIZE_BY_OBJECT; /* Flag to enable alternate message type for SSX2 bypass. */ -static u16 gwSSX2Bypass; +static u16 gwSSX2_bypass; /** \internal * Used by ASIO driver to disable SSX2 for a single process @@ -37,39 +37,33 @@ static u16 gwSSX2Bypass; * \param wBypass New bypass setting 0 = off, nonzero = on * \return Previous bypass setting. */ -u16 HPI_SubSysSsx2Bypass( - const struct hpi_hsubsys *phSubSys, - u16 wBypass -) +u16 hpi_subsys_ssx2_bypass(const struct hpi_hsubsys *ph_subsys, u16 bypass) { - u16 oldValue = gwSSX2Bypass; + u16 old_value = gwSSX2_bypass; - gwSSX2Bypass = wBypass; + gwSSX2_bypass = bypass; - return oldValue; + return old_value; } /** \internal * initialize the HPI message structure */ -static void HPI_InitMessage( - struct hpi_message *phm, - u16 wObject, - u16 wFunction -) +static void hpi_init_message(struct hpi_message *phm, u16 object, + u16 function) { memset(phm, 0, sizeof(*phm)); - if ((wObject > 0) && (wObject <= HPI_OBJ_MAXINDEX)) - phm->wSize = aMsgSize[wObject]; + if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) + phm->size = msg_size[object]; else - phm->wSize = sizeof(*phm); + phm->size = sizeof(*phm); - if (gwSSX2Bypass) - phm->wType = HPI_TYPE_SSX2BYPASS_MESSAGE; + if (gwSSX2_bypass) + phm->type = HPI_TYPE_SSX2BYPASS_MESSAGE; else - phm->wType = HPI_TYPE_MESSAGE; - phm->wObject = wObject; - phm->wFunction = wFunction; + phm->type = HPI_TYPE_MESSAGE; + phm->object = object; + phm->function = function; phm->version = 0; /* Expect adapter index to be set by caller */ } @@ -77,81 +71,60 @@ static void HPI_InitMessage( /** \internal * initialize the HPI response structure */ -void HPI_InitResponse( - struct hpi_response *phr, - u16 wObject, - u16 wFunction, - u16 wError -) +void hpi_init_response(struct hpi_response *phr, u16 object, u16 function, + u16 error) { memset(phr, 0, sizeof(*phr)); - phr->wType = HPI_TYPE_RESPONSE; - if ((wObject > 0) && (wObject <= HPI_OBJ_MAXINDEX)) - phr->wSize = aResSize[wObject]; + phr->type = HPI_TYPE_RESPONSE; + if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) + phr->size = res_size[object]; else - phr->wSize = sizeof(*phr); - phr->wObject = wObject; - phr->wFunction = wFunction; - phr->wError = wError; - phr->wSpecificError = 0; + phr->size = sizeof(*phr); + phr->object = object; + phr->function = function; + phr->error = error; + phr->specific_error = 0; phr->version = 0; } -void HPI_InitMessageResponse( - struct hpi_message *phm, - struct hpi_response *phr, - u16 wObject, - u16 wFunction -) +void hpi_init_message_response(struct hpi_message *phm, + struct hpi_response *phr, u16 object, u16 function) { - HPI_InitMessage(phm, wObject, wFunction); + hpi_init_message(phm, object, function); /* default error return if the response is not filled in by the callee */ - HPI_InitResponse(phr, wObject, wFunction, + hpi_init_response(phr, object, function, HPI_ERROR_PROCESSING_MESSAGE); } -static void HPI_InitMessageV1( - struct hpi_message_header *phm, - u16 wSize, - u16 wObject, - u16 wFunction -) +static void hpi_init_messageV1(struct hpi_message_header *phm, u16 size, + u16 object, u16 function) { memset(phm, 0, sizeof(*phm)); - if ((wObject > 0) && (wObject <= HPI_OBJ_MAXINDEX)) { - phm->wSize = wSize; - phm->wType = HPI_TYPE_MESSAGE; - phm->wObject = wObject; - phm->wFunction = wFunction; + if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) { + phm->size = size; + phm->type = HPI_TYPE_MESSAGE; + phm->object = object; + phm->function = function; phm->version = 1; /* Expect adapter index to be set by caller */ } } -void HPI_InitResponseV1( - struct hpi_response_header *phr, - u16 wSize, - u16 wObject, - u16 wFunction -) +void hpi_init_responseV1(struct hpi_response_header *phr, u16 size, + u16 object, u16 function) { memset(phr, 0, sizeof(*phr)); - phr->wSize = wSize; + phr->size = size; phr->version = 1; - phr->wType = HPI_TYPE_RESPONSE; - phr->wError = HPI_ERROR_PROCESSING_MESSAGE; + phr->type = HPI_TYPE_RESPONSE; + phr->error = HPI_ERROR_PROCESSING_MESSAGE; } -void HPI_InitMessageResponseV1( - struct hpi_message_header *phm, - u16 wMsgSize, - struct hpi_response_header *phr, - u16 wResSize, - u16 wObject, - u16 wFunction -) +void hpi_init_message_responseV1(struct hpi_message_header *phm, u16 msg_size, + struct hpi_response_header *phr, u16 res_size, u16 object, + u16 function) { - HPI_InitMessageV1(phm, wMsgSize, wObject, wFunction); - HPI_InitResponseV1(phr, wResSize, wObject, wFunction); + hpi_init_messageV1(phm, msg_size, object, function); + hpi_init_responseV1(phr, res_size, object, function); } diff --git a/pci/asihpi/hpimsginit.h b/pci/asihpi/hpimsginit.h index 4f7f11491..5ff42a0d1 100644 --- a/pci/asihpi/hpimsginit.h +++ b/pci/asihpi/hpimsginit.h @@ -26,32 +26,15 @@ a response to a message. However, when sending a message, a matching response buffer always must be prepared */ -void HPI_InitResponse( - struct hpi_response *phr, - u16 wObject, - u16 wFunction, - u16 wError -); - -void HPI_InitMessageResponse( - struct hpi_message *phm, - struct hpi_response *phr, - u16 wObject, - u16 wFunction -); - -void HPI_InitResponseV1( - struct hpi_response_header *phr, - u16 wSize, - u16 wObject, - u16 wFunction -); - -void HPI_InitMessageResponseV1( - struct hpi_message_header *phm, - u16 wMsgSize, - struct hpi_response_header *phr, - u16 wResSize, - u16 wObject, - u16 wFunction -); +void hpi_init_response(struct hpi_response *phr, u16 object, u16 function, + u16 error); + +void hpi_init_message_response(struct hpi_message *phm, + struct hpi_response *phr, u16 object, u16 function); + +void hpi_init_responseV1(struct hpi_response_header *phr, u16 size, + u16 object, u16 function); + +void hpi_init_message_responseV1(struct hpi_message_header *phm, u16 msg_size, + struct hpi_response_header *phr, u16 res_size, u16 object, + u16 function); diff --git a/pci/asihpi/hpimsgx.c b/pci/asihpi/hpimsgx.c index c7ddbcfa8..8bdb22087 100644 --- a/pci/asihpi/hpimsgx.c +++ b/pci/asihpi/hpimsgx.c @@ -30,51 +30,49 @@ static struct pci_device_id asihpi_pci_tbl[] = { #include "hpipcida.h" }; -static struct hpios_spinlock msgxLock; +static struct hpios_spinlock msgx_lock; -static HPI_HandlerFunc *hpi_entry_points[HPI_MAX_ADAPTERS]; +static hpi_handler_func *hpi_entry_points[HPI_MAX_ADAPTERS]; -static HPI_HandlerFunc *HPI_LookupEntryPointFunction( - const struct hpi_pci *PciInfo -) +static hpi_handler_func *hpi_lookup_entry_point_function(const struct hpi_pci + *pci_info) { int i; for (i = 0; asihpi_pci_tbl[i].vendor != 0; i++) { if (asihpi_pci_tbl[i].vendor != PCI_ANY_ID - && asihpi_pci_tbl[i].vendor != PciInfo->wVendorId) + && asihpi_pci_tbl[i].vendor != pci_info->vendor_id) continue; if (asihpi_pci_tbl[i].device != PCI_ANY_ID - && asihpi_pci_tbl[i].device != PciInfo->wDeviceId) + && asihpi_pci_tbl[i].device != pci_info->device_id) continue; if (asihpi_pci_tbl[i].subvendor != PCI_ANY_ID && asihpi_pci_tbl[i].subvendor != - PciInfo->wSubSysVendorId) + pci_info->subsys_vendor_id) continue; if (asihpi_pci_tbl[i].subdevice != PCI_ANY_ID && asihpi_pci_tbl[i].subdevice != - PciInfo->wSubSysDeviceId) + pci_info->subsys_device_id) continue; HPI_DEBUG_LOG(DEBUG, " %x,%lu\n", i, asihpi_pci_tbl[i].driver_data); - return (HPI_HandlerFunc *) asihpi_pci_tbl[i].driver_data; + return (hpi_handler_func *) asihpi_pci_tbl[i].driver_data; } return NULL; } -static inline void HW_EntryPoint( - struct hpi_message *phm, - struct hpi_response *phr -) +static inline void hw_entry_point(struct hpi_message *phm, + struct hpi_response *phr) { - HPI_HandlerFunc *ep; + hpi_handler_func *ep; - if (phm->wAdapterIndex < HPI_MAX_ADAPTERS) { - ep = (HPI_HandlerFunc *) hpi_entry_points[phm->wAdapterIndex]; + if (phm->adapter_index < HPI_MAX_ADAPTERS) { + ep = (hpi_handler_func *) hpi_entry_points[phm-> + adapter_index]; if (ep) { HPI_DEBUG_MESSAGE(DEBUG, phm); ep(phm, phr); @@ -82,60 +80,28 @@ static inline void HW_EntryPoint( return; } } - HPI_InitResponse(phr, phm->wObject, phm->wFunction, + hpi_init_response(phr, phm->object, phm->function, HPI_ERROR_PROCESSING_MESSAGE); } -static void AdapterOpen( - struct hpi_message *phm, - struct hpi_response *phr -); -static void AdapterClose( - struct hpi_message *phm, - struct hpi_response *phr -); +static void adapter_open(struct hpi_message *phm, struct hpi_response *phr); +static void adapter_close(struct hpi_message *phm, struct hpi_response *phr); -static void MixerOpen( - struct hpi_message *phm, - struct hpi_response *phr -); -static void MixerClose( - struct hpi_message *phm, - struct hpi_response *phr -); - -static void OutStreamOpen( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -); -static void OutStreamClose( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -); -static void InStreamOpen( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -); -static void InStreamClose( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -); - -static void HPIMSGX_Reset( - u16 wAdapterIndex -); -static u16 HPIMSGX_Init( - struct hpi_message *phm, - struct hpi_response *phr -); -static void HPIMSGX_Cleanup( - u16 wAdapterIndex, - void *hOwner -); +static void mixer_open(struct hpi_message *phm, struct hpi_response *phr); +static void mixer_close(struct hpi_message *phm, struct hpi_response *phr); + +static void outstream_open(struct hpi_message *phm, struct hpi_response *phr, + void *h_owner); +static void outstream_close(struct hpi_message *phm, struct hpi_response *phr, + void *h_owner); +static void instream_open(struct hpi_message *phm, struct hpi_response *phr, + void *h_owner); +static void instream_close(struct hpi_message *phm, struct hpi_response *phr, + void *h_owner); + +static void HPIMSGX__reset(u16 adapter_index); +static u16 HPIMSGX__init(struct hpi_message *phm, struct hpi_response *phr); +static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner); #ifndef DISABLE_PRAGMA_PACK1 #pragma pack(push, 1) @@ -162,14 +128,14 @@ struct hpi_stream_response { }; struct adapter_info { - u16 wType; - u16 wNumInStreams; - u16 wNumOutStreams; + u16 type; + u16 num_instreams; + u16 num_outstreams; }; struct asi_open_state { - int nOpenFlag; - void *hOwner; + int open_flag; + void *h_owner; }; #ifndef DISABLE_PRAGMA_PACK1 @@ -177,66 +143,64 @@ struct asi_open_state { #endif /* Globals */ -static struct hpi_adapter_response aRESP_HPI_ADAPTER_OPEN[HPI_MAX_ADAPTERS]; +static struct hpi_adapter_response rESP_HPI_ADAPTER_OPEN[HPI_MAX_ADAPTERS]; static struct hpi_stream_response - aRESP_HPI_OSTREAM_OPEN[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS]; + rESP_HPI_OSTREAM_OPEN[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS]; static struct hpi_stream_response - aRESP_HPI_ISTREAM_OPEN[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS]; + rESP_HPI_ISTREAM_OPEN[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS]; -static struct hpi_mixer_response aRESP_HPI_MIXER_OPEN[HPI_MAX_ADAPTERS]; +static struct hpi_mixer_response rESP_HPI_MIXER_OPEN[HPI_MAX_ADAPTERS]; static struct hpi_subsys_response gRESP_HPI_SUBSYS_FIND_ADAPTERS; -static struct adapter_info aADAPTER_INFO[HPI_MAX_ADAPTERS]; +static struct adapter_info aDAPTER_INFO[HPI_MAX_ADAPTERS]; /* use these to keep track of opens from user mode apps/DLLs */ static struct asi_open_state - aOStreamUserOpen[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS]; + outstream_user_open[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS]; static struct asi_open_state - aIStreamUserOpen[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS]; + instream_user_open[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS]; -static void SubSysMessage( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -) +static void subsys_message(struct hpi_message *phm, struct hpi_response *phr, + void *h_owner) { - switch (phm->wFunction) { + switch (phm->function) { case HPI_SUBSYS_GET_VERSION: - HPI_InitResponse(phr, HPI_OBJ_SUBSYSTEM, + hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_GET_VERSION, 0); - phr->u.s.dwVersion = HPI_VER >> 8; /* return major.minor */ - phr->u.s.dwData = HPI_VER; /* return major.minor.release */ + phr->u.s.version = HPI_VER >> 8; /* return major.minor */ + phr->u.s.data = HPI_VER; /* return major.minor.release */ break; case HPI_SUBSYS_OPEN: /*do not propagate the message down the chain */ - HPI_InitResponse(phr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_OPEN, 0); + hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_OPEN, 0); break; case HPI_SUBSYS_CLOSE: /*do not propagate the message down the chain */ - HPI_InitResponse(phr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CLOSE, 0); - HPIMSGX_Cleanup(HPIMSGX_ALLADAPTERS, hOwner); + hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CLOSE, + 0); + HPIMSGX__cleanup(HPIMSGX_ALLADAPTERS, h_owner); break; case HPI_SUBSYS_DRIVER_LOAD: /* Initialize this module's internal state */ - HpiOs_Msgxlock_Init(&msgxLock); + hpios_msgxlock_init(&msgx_lock); memset(&hpi_entry_points, 0, sizeof(hpi_entry_points)); - HpiOs_LockedMem_Init(); + hpios_locked_mem_init(); /* Init subsys_findadapters response to no-adapters */ - HPIMSGX_Reset(HPIMSGX_ALLADAPTERS); - HPI_InitResponse(phr, HPI_OBJ_SUBSYSTEM, + HPIMSGX__reset(HPIMSGX_ALLADAPTERS); + hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_DRIVER_LOAD, 0); /* individual HPIs dont implement driver load */ HPI_COMMON(phm, phr); break; case HPI_SUBSYS_DRIVER_UNLOAD: HPI_COMMON(phm, phr); - HPIMSGX_Cleanup(HPIMSGX_ALLADAPTERS, hOwner); - HpiOs_LockedMem_FreeAll(); - HPI_InitResponse(phr, HPI_OBJ_SUBSYSTEM, + HPIMSGX__cleanup(HPIMSGX_ALLADAPTERS, h_owner); + hpios_locked_mem_free_all(); + hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_DRIVER_UNLOAD, 0); return; @@ -251,13 +215,13 @@ static void SubSysMessage( case HPI_SUBSYS_GET_NUM_ADAPTERS: memcpy(phr, &gRESP_HPI_SUBSYS_FIND_ADAPTERS, sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS)); - phr->wFunction = HPI_SUBSYS_GET_NUM_ADAPTERS; + phr->function = HPI_SUBSYS_GET_NUM_ADAPTERS; break; case HPI_SUBSYS_GET_ADAPTER: { - int nCount = phm->wAdapterIndex; - int nIndex = 0; - HPI_InitResponse(phr, HPI_OBJ_SUBSYSTEM, + int count = phm->adapter_index; + int index = 0; + hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_GET_ADAPTER, 0); /* This is complicated by the fact that we want to @@ -266,147 +230,134 @@ static void SubSysMessage( * non-zero adapter type. */ while (gRESP_HPI_SUBSYS_FIND_ADAPTERS. - s.awAdapterList[nIndex] == 0) { - nIndex++; - if (nIndex >= HPI_MAX_ADAPTERS) + s.aw_adapter_list[index] == 0) { + index++; + if (index >= HPI_MAX_ADAPTERS) break; } - while (nCount) { + while (count) { /* move on to the next adapter */ - nIndex++; - if (nIndex >= HPI_MAX_ADAPTERS) + index++; + if (index >= HPI_MAX_ADAPTERS) break; while (gRESP_HPI_SUBSYS_FIND_ADAPTERS. - s.awAdapterList[nIndex] == 0) { - nIndex++; - if (nIndex >= HPI_MAX_ADAPTERS) + s.aw_adapter_list[index] == 0) { + index++; + if (index >= HPI_MAX_ADAPTERS) break; } - nCount--; + count--; } - if (nIndex < HPI_MAX_ADAPTERS) { - phr->u.s.wAdapterIndex = (u16)nIndex; - phr->u.s.awAdapterList[0] = + if (index < HPI_MAX_ADAPTERS) { + phr->u.s.adapter_index = (u16)index; + phr->u.s.aw_adapter_list[0] = gRESP_HPI_SUBSYS_FIND_ADAPTERS. - s.awAdapterList[nIndex]; + s.aw_adapter_list[index]; } else { - phr->u.s.wAdapterIndex = 0; - phr->u.s.awAdapterList[0] = 0; - phr->wError = HPI_ERROR_BAD_ADAPTER_NUMBER; + phr->u.s.adapter_index = 0; + phr->u.s.aw_adapter_list[0] = 0; + phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER; } break; } case HPI_SUBSYS_CREATE_ADAPTER: - HPIMSGX_Init(phm, phr); + HPIMSGX__init(phm, phr); break; case HPI_SUBSYS_DELETE_ADAPTER: - HPIMSGX_Cleanup(phm->wAdapterIndex, hOwner); + HPIMSGX__cleanup(phm->adapter_index, h_owner); { struct hpi_message hm; struct hpi_response hr; /* call to HPI_ADAPTER_CLOSE */ - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_CLOSE); - hm.wAdapterIndex = phm->wAdapterIndex; - HW_EntryPoint(&hm, &hr); + hm.adapter_index = phm->adapter_index; + hw_entry_point(&hm, &hr); } - HW_EntryPoint(phm, phr); + hw_entry_point(phm, phr); gRESP_HPI_SUBSYS_FIND_ADAPTERS.s. - awAdapterList[phm->wAdapterIndex] + aw_adapter_list[phm->adapter_index] = 0; - hpi_entry_points[phm->wAdapterIndex] = NULL; + hpi_entry_points[phm->adapter_index] = NULL; break; default: - HW_EntryPoint(phm, phr); + hw_entry_point(phm, phr); break; } } -static void AdapterMessage( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -) +static void adapter_message(struct hpi_message *phm, struct hpi_response *phr, + void *h_owner) { - switch (phm->wFunction) { + switch (phm->function) { case HPI_ADAPTER_OPEN: - AdapterOpen(phm, phr); + adapter_open(phm, phr); break; case HPI_ADAPTER_CLOSE: - AdapterClose(phm, phr); + adapter_close(phm, phr); break; default: - HW_EntryPoint(phm, phr); + hw_entry_point(phm, phr); break; } } -static void MixerMessage( - struct hpi_message *phm, - struct hpi_response *phr -) +static void mixer_message(struct hpi_message *phm, struct hpi_response *phr) { - switch (phm->wFunction) { + switch (phm->function) { case HPI_MIXER_OPEN: - MixerOpen(phm, phr); + mixer_open(phm, phr); break; case HPI_MIXER_CLOSE: - MixerClose(phm, phr); + mixer_close(phm, phr); break; default: - HW_EntryPoint(phm, phr); + hw_entry_point(phm, phr); break; } } -static void OStreamMessage( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -) +static void outstream_message(struct hpi_message *phm, + struct hpi_response *phr, void *h_owner) { - if (phm->wObjIndex >= - aADAPTER_INFO[phm->wAdapterIndex].wNumOutStreams) { - HPI_InitResponse(phr, HPI_OBJ_OSTREAM, phm->wFunction, + if (phm->obj_index >= aDAPTER_INFO[phm->adapter_index].num_outstreams) { + hpi_init_response(phr, HPI_OBJ_OSTREAM, phm->function, HPI_ERROR_INVALID_OBJ_INDEX); return; } - switch (phm->wFunction) { + switch (phm->function) { case HPI_OSTREAM_OPEN: - OutStreamOpen(phm, phr, hOwner); + outstream_open(phm, phr, h_owner); break; case HPI_OSTREAM_CLOSE: - OutStreamClose(phm, phr, hOwner); + outstream_close(phm, phr, h_owner); break; default: - HW_EntryPoint(phm, phr); + hw_entry_point(phm, phr); break; } } -static void IStreamMessage( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -) +static void instream_message(struct hpi_message *phm, + struct hpi_response *phr, void *h_owner) { - if (phm->wObjIndex >= aADAPTER_INFO[phm->wAdapterIndex].wNumInStreams) { - HPI_InitResponse(phr, HPI_OBJ_ISTREAM, phm->wFunction, + if (phm->obj_index >= aDAPTER_INFO[phm->adapter_index].num_instreams) { + hpi_init_response(phr, HPI_OBJ_ISTREAM, phm->function, HPI_ERROR_INVALID_OBJ_INDEX); return; } - switch (phm->wFunction) { + switch (phm->function) { case HPI_ISTREAM_OPEN: - InStreamOpen(phm, phr, hOwner); + instream_open(phm, phr, h_owner); break; case HPI_ISTREAM_CLOSE: - InStreamClose(phm, phr, hOwner); + instream_close(phm, phr, h_owner); break; default: - HW_EntryPoint(phm, phr); + hw_entry_point(phm, phr); break; } } @@ -414,62 +365,59 @@ static void IStreamMessage( /* NOTE: HPI_Message() must be defined in the driver as a wrapper for * HPI_MessageEx so that functions in hpifunc.c compile. */ -void HPI_MessageEx( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -) +void hpi_send_recv_ex(struct hpi_message *phm, struct hpi_response *phr, + void *h_owner) { HPI_DEBUG_MESSAGE(DEBUG, phm); - if (phm->wType != HPI_TYPE_MESSAGE) { - HPI_InitResponse(phr, phm->wObject, phm->wFunction, + if (phm->type != HPI_TYPE_MESSAGE) { + hpi_init_response(phr, phm->object, phm->function, HPI_ERROR_INVALID_TYPE); return; } - if (phm->wAdapterIndex >= HPI_MAX_ADAPTERS && - phm->wAdapterIndex != HPIMSGX_ALLADAPTERS) { - HPI_InitResponse(phr, phm->wObject, phm->wFunction, + if (phm->adapter_index >= HPI_MAX_ADAPTERS + && phm->adapter_index != HPIMSGX_ALLADAPTERS) { + hpi_init_response(phr, phm->object, phm->function, HPI_ERROR_BAD_ADAPTER_NUMBER); return; } - switch (phm->wObject) { + switch (phm->object) { case HPI_OBJ_SUBSYSTEM: - SubSysMessage(phm, phr, hOwner); + subsys_message(phm, phr, h_owner); break; case HPI_OBJ_ADAPTER: - AdapterMessage(phm, phr, hOwner); + adapter_message(phm, phr, h_owner); break; case HPI_OBJ_MIXER: - MixerMessage(phm, phr); + mixer_message(phm, phr); break; case HPI_OBJ_OSTREAM: - OStreamMessage(phm, phr, hOwner); + outstream_message(phm, phr, h_owner); break; case HPI_OBJ_ISTREAM: - IStreamMessage(phm, phr, hOwner); + instream_message(phm, phr, h_owner); break; default: - HW_EntryPoint(phm, phr); + hw_entry_point(phm, phr); break; } HPI_DEBUG_RESPONSE(phr); #if 1 - if (phr->wError >= HPI_ERROR_BACKEND_BASE) { + if (phr->error >= HPI_ERROR_BACKEND_BASE) { void *ep = NULL; char *ep_name; HPI_DEBUG_MESSAGE(ERROR, phm); - if (phm->wAdapterIndex < HPI_MAX_ADAPTERS) - ep = hpi_entry_points[phm->wAdapterIndex]; + if (phm->adapter_index < HPI_MAX_ADAPTERS) + ep = hpi_entry_points[phm->adapter_index]; /* Don't need this? Have adapter index in debug info Know at driver load time index->backend mapping */ @@ -480,263 +428,236 @@ void HPI_MessageEx( else ep_name = "unknown"; - HPI_DEBUG_LOG(ERROR, - "HPI %s Response - error# %d\n", - ep_name, phr->wError); + HPI_DEBUG_LOG(ERROR, "HPI %s response - error# %d\n", ep_name, + phr->error); - if (hpiDebugLevel >= HPI_DEBUG_LEVEL_VERBOSE) + if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE) hpi_debug_data((u16 *)phm, sizeof(*phm) / sizeof(u16)); } #endif } -static void AdapterOpen( - struct hpi_message *phm, - struct hpi_response *phr -) +static void adapter_open(struct hpi_message *phm, struct hpi_response *phr) { - HPI_DEBUG_LOG(VERBOSE, "AdapterOpen\n"); - memcpy(phr, &aRESP_HPI_ADAPTER_OPEN[phm->wAdapterIndex], - sizeof(aRESP_HPI_ADAPTER_OPEN[0])); + HPI_DEBUG_LOG(VERBOSE, "adapter_open\n"); + memcpy(phr, &rESP_HPI_ADAPTER_OPEN[phm->adapter_index], + sizeof(rESP_HPI_ADAPTER_OPEN[0])); } -static void AdapterClose( - struct hpi_message *phm, - struct hpi_response *phr -) +static void adapter_close(struct hpi_message *phm, struct hpi_response *phr) { - HPI_DEBUG_LOG(VERBOSE, "AdapterClose\n"); - HPI_InitResponse(phr, HPI_OBJ_ADAPTER, HPI_ADAPTER_CLOSE, 0); + HPI_DEBUG_LOG(VERBOSE, "adapter_close\n"); + hpi_init_response(phr, HPI_OBJ_ADAPTER, HPI_ADAPTER_CLOSE, 0); } -static void MixerOpen( - struct hpi_message *phm, - struct hpi_response *phr -) +static void mixer_open(struct hpi_message *phm, struct hpi_response *phr) { - memcpy(phr, &aRESP_HPI_MIXER_OPEN[phm->wAdapterIndex], - sizeof(aRESP_HPI_MIXER_OPEN[0])); + memcpy(phr, &rESP_HPI_MIXER_OPEN[phm->adapter_index], + sizeof(rESP_HPI_MIXER_OPEN[0])); } -static void MixerClose( - struct hpi_message *phm, - struct hpi_response *phr -) +static void mixer_close(struct hpi_message *phm, struct hpi_response *phr) { - HPI_InitResponse(phr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE, 0); + hpi_init_response(phr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE, 0); } -static void InStreamOpen( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -) +static void instream_open(struct hpi_message *phm, struct hpi_response *phr, + void *h_owner) { struct hpi_message hm; struct hpi_response hr; - HPI_InitResponse(phr, HPI_OBJ_ISTREAM, HPI_ISTREAM_OPEN, 0); + hpi_init_response(phr, HPI_OBJ_ISTREAM, HPI_ISTREAM_OPEN, 0); - HpiOs_Msgxlock_Lock(&msgxLock); + hpios_msgxlock_lock(&msgx_lock); - if (aIStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex].nOpenFlag) - phr->wError = HPI_ERROR_OBJ_ALREADY_OPEN; - else if (aRESP_HPI_ISTREAM_OPEN[phm->wAdapterIndex] - [phm->wObjIndex].h.wError) + if (instream_user_open[phm->adapter_index][phm->obj_index].open_flag) + phr->error = HPI_ERROR_OBJ_ALREADY_OPEN; + else if (rESP_HPI_ISTREAM_OPEN[phm->adapter_index] + [phm->obj_index].h.error) memcpy(phr, - &aRESP_HPI_ISTREAM_OPEN[phm->wAdapterIndex][phm-> - wObjIndex], - sizeof(aRESP_HPI_ISTREAM_OPEN[0][0])); + &rESP_HPI_ISTREAM_OPEN[phm->adapter_index][phm-> + obj_index], + sizeof(rESP_HPI_ISTREAM_OPEN[0][0])); else { - aIStreamUserOpen[phm->wAdapterIndex][phm-> - wObjIndex].nOpenFlag = 1; - HpiOs_Msgxlock_UnLock(&msgxLock); + instream_user_open[phm->adapter_index][phm-> + obj_index].open_flag = 1; + hpios_msgxlock_un_lock(&msgx_lock); /* issue a reset */ - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_RESET); - hm.wAdapterIndex = phm->wAdapterIndex; - hm.wObjIndex = phm->wObjIndex; - HW_EntryPoint(&hm, &hr); - - HpiOs_Msgxlock_Lock(&msgxLock); - if (hr.wError) { - aIStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - nOpenFlag = 0; - phr->wError = hr.wError; + hm.adapter_index = phm->adapter_index; + hm.obj_index = phm->obj_index; + hw_entry_point(&hm, &hr); + + hpios_msgxlock_lock(&msgx_lock); + if (hr.error) { + instream_user_open[phm->adapter_index][phm-> + obj_index].open_flag = 0; + phr->error = hr.error; } else { - aIStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - nOpenFlag = 1; - aIStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - hOwner = hOwner; + instream_user_open[phm->adapter_index][phm-> + obj_index].open_flag = 1; + instream_user_open[phm->adapter_index][phm-> + obj_index].h_owner = h_owner; memcpy(phr, - &aRESP_HPI_ISTREAM_OPEN[phm->wAdapterIndex] - [phm->wObjIndex], - sizeof(aRESP_HPI_ISTREAM_OPEN[0][0])); + &rESP_HPI_ISTREAM_OPEN[phm->adapter_index] + [phm->obj_index], + sizeof(rESP_HPI_ISTREAM_OPEN[0][0])); } } - HpiOs_Msgxlock_UnLock(&msgxLock); + hpios_msgxlock_un_lock(&msgx_lock); } -static void InStreamClose( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -) +static void instream_close(struct hpi_message *phm, struct hpi_response *phr, + void *h_owner) { struct hpi_message hm; struct hpi_response hr; - HPI_InitResponse(phr, HPI_OBJ_ISTREAM, HPI_ISTREAM_CLOSE, 0); + hpi_init_response(phr, HPI_OBJ_ISTREAM, HPI_ISTREAM_CLOSE, 0); - HpiOs_Msgxlock_Lock(&msgxLock); - if (hOwner == - aIStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex].hOwner) { + hpios_msgxlock_lock(&msgx_lock); + if (h_owner == + instream_user_open[phm->adapter_index][phm-> + obj_index].h_owner) { /* HPI_DEBUG_LOG(INFO,"closing adapter %d " "instream %d owned by %p\n", phm->wAdapterIndex, phm->wObjIndex, hOwner); */ - aIStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex].hOwner = - NULL; - HpiOs_Msgxlock_UnLock(&msgxLock); + instream_user_open[phm->adapter_index][phm-> + obj_index].h_owner = NULL; + hpios_msgxlock_un_lock(&msgx_lock); /* issue a reset */ - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_RESET); - hm.wAdapterIndex = phm->wAdapterIndex; - hm.wObjIndex = phm->wObjIndex; - HW_EntryPoint(&hm, &hr); - HpiOs_Msgxlock_Lock(&msgxLock); - if (hr.wError) { - aIStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - hOwner = hOwner; - phr->wError = hr.wError; + hm.adapter_index = phm->adapter_index; + hm.obj_index = phm->obj_index; + hw_entry_point(&hm, &hr); + hpios_msgxlock_lock(&msgx_lock); + if (hr.error) { + instream_user_open[phm->adapter_index][phm-> + obj_index].h_owner = h_owner; + phr->error = hr.error; } else { - aIStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - nOpenFlag = 0; - aIStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - hOwner = NULL; + instream_user_open[phm->adapter_index][phm-> + obj_index].open_flag = 0; + instream_user_open[phm->adapter_index][phm-> + obj_index].h_owner = NULL; } } else { HPI_DEBUG_LOG(WARNING, "%p trying to close %d instream %d owned by %p\n", - hOwner, phm->wAdapterIndex, - phm->wObjIndex, - aIStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - hOwner); - phr->wError = HPI_ERROR_OBJ_NOT_OPEN; + h_owner, phm->adapter_index, phm->obj_index, + instream_user_open[phm->adapter_index][phm-> + obj_index].h_owner); + phr->error = HPI_ERROR_OBJ_NOT_OPEN; } - HpiOs_Msgxlock_UnLock(&msgxLock); + hpios_msgxlock_un_lock(&msgx_lock); } -static void OutStreamOpen( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -) +static void outstream_open(struct hpi_message *phm, struct hpi_response *phr, + void *h_owner) { struct hpi_message hm; struct hpi_response hr; - HPI_InitResponse(phr, HPI_OBJ_OSTREAM, HPI_OSTREAM_OPEN, 0); + hpi_init_response(phr, HPI_OBJ_OSTREAM, HPI_OSTREAM_OPEN, 0); - HpiOs_Msgxlock_Lock(&msgxLock); + hpios_msgxlock_lock(&msgx_lock); - if (aOStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex].nOpenFlag) - phr->wError = HPI_ERROR_OBJ_ALREADY_OPEN; - else if (aRESP_HPI_OSTREAM_OPEN[phm->wAdapterIndex] - [phm->wObjIndex].h.wError) + if (outstream_user_open[phm->adapter_index][phm->obj_index].open_flag) + phr->error = HPI_ERROR_OBJ_ALREADY_OPEN; + else if (rESP_HPI_OSTREAM_OPEN[phm->adapter_index] + [phm->obj_index].h.error) memcpy(phr, - &aRESP_HPI_OSTREAM_OPEN[phm->wAdapterIndex][phm-> - wObjIndex], - sizeof(aRESP_HPI_OSTREAM_OPEN[0][0])); + &rESP_HPI_OSTREAM_OPEN[phm->adapter_index][phm-> + obj_index], + sizeof(rESP_HPI_OSTREAM_OPEN[0][0])); else { - aOStreamUserOpen[phm->wAdapterIndex][phm-> - wObjIndex].nOpenFlag = 1; - HpiOs_Msgxlock_UnLock(&msgxLock); + outstream_user_open[phm->adapter_index][phm-> + obj_index].open_flag = 1; + hpios_msgxlock_un_lock(&msgx_lock); /* issue a reset */ - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_RESET); - hm.wAdapterIndex = phm->wAdapterIndex; - hm.wObjIndex = phm->wObjIndex; - HW_EntryPoint(&hm, &hr); - - HpiOs_Msgxlock_Lock(&msgxLock); - if (hr.wError) { - aOStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - nOpenFlag = 0; - phr->wError = hr.wError; + hm.adapter_index = phm->adapter_index; + hm.obj_index = phm->obj_index; + hw_entry_point(&hm, &hr); + + hpios_msgxlock_lock(&msgx_lock); + if (hr.error) { + outstream_user_open[phm->adapter_index][phm-> + obj_index].open_flag = 0; + phr->error = hr.error; } else { - aOStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - nOpenFlag = 1; - aOStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - hOwner = hOwner; + outstream_user_open[phm->adapter_index][phm-> + obj_index].open_flag = 1; + outstream_user_open[phm->adapter_index][phm-> + obj_index].h_owner = h_owner; memcpy(phr, - &aRESP_HPI_OSTREAM_OPEN[phm->wAdapterIndex] - [phm->wObjIndex], - sizeof(aRESP_HPI_OSTREAM_OPEN[0][0])); + &rESP_HPI_OSTREAM_OPEN[phm->adapter_index] + [phm->obj_index], + sizeof(rESP_HPI_OSTREAM_OPEN[0][0])); } } - HpiOs_Msgxlock_UnLock(&msgxLock); + hpios_msgxlock_un_lock(&msgx_lock); } -static void OutStreamClose( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -) +static void outstream_close(struct hpi_message *phm, struct hpi_response *phr, + void *h_owner) { struct hpi_message hm; struct hpi_response hr; - HPI_InitResponse(phr, HPI_OBJ_OSTREAM, HPI_OSTREAM_CLOSE, 0); + hpi_init_response(phr, HPI_OBJ_OSTREAM, HPI_OSTREAM_CLOSE, 0); - HpiOs_Msgxlock_Lock(&msgxLock); + hpios_msgxlock_lock(&msgx_lock); - if (hOwner == - aOStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex].hOwner) { + if (h_owner == + outstream_user_open[phm->adapter_index][phm-> + obj_index].h_owner) { /* HPI_DEBUG_LOG(INFO,"closing adapter %d " "outstream %d owned by %p\n", phm->wAdapterIndex, phm->wObjIndex, hOwner); */ - aOStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex].hOwner = - NULL; - HpiOs_Msgxlock_UnLock(&msgxLock); + outstream_user_open[phm->adapter_index][phm-> + obj_index].h_owner = NULL; + hpios_msgxlock_un_lock(&msgx_lock); /* issue a reset */ - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_RESET); - hm.wAdapterIndex = phm->wAdapterIndex; - hm.wObjIndex = phm->wObjIndex; - HW_EntryPoint(&hm, &hr); - HpiOs_Msgxlock_Lock(&msgxLock); - if (hr.wError) { - aOStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - hOwner = hOwner; - phr->wError = hr.wError; + hm.adapter_index = phm->adapter_index; + hm.obj_index = phm->obj_index; + hw_entry_point(&hm, &hr); + hpios_msgxlock_lock(&msgx_lock); + if (hr.error) { + outstream_user_open[phm->adapter_index][phm-> + obj_index].h_owner = h_owner; + phr->error = hr.error; } else { - aOStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - nOpenFlag = 0; - aOStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - hOwner = NULL; + outstream_user_open[phm->adapter_index][phm-> + obj_index].open_flag = 0; + outstream_user_open[phm->adapter_index][phm-> + obj_index].h_owner = NULL; } } else { HPI_DEBUG_LOG(WARNING, "%p trying to close %d outstream %d owned by %p\n", - hOwner, phm->wAdapterIndex, - phm->wObjIndex, - aOStreamUserOpen[phm->wAdapterIndex][phm->wObjIndex]. - hOwner); - phr->wError = HPI_ERROR_OBJ_NOT_OPEN; + h_owner, phm->adapter_index, phm->obj_index, + outstream_user_open[phm->adapter_index][phm-> + obj_index].h_owner); + phr->error = HPI_ERROR_OBJ_NOT_OPEN; } - HpiOs_Msgxlock_UnLock(&msgxLock); + hpios_msgxlock_un_lock(&msgx_lock); } -static u16 AdapterPrepare( - u16 wAdapter -) +static u16 adapter_prepare(u16 adapter) { struct hpi_message hm; struct hpi_response hr; @@ -745,246 +666,241 @@ static u16 AdapterPrepare( u16 i; /* call to HPI_ADAPTER_OPEN */ - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_OPEN); - hm.wAdapterIndex = wAdapter; - HW_EntryPoint(&hm, &hr); - memcpy(&aRESP_HPI_ADAPTER_OPEN[wAdapter], &hr, - sizeof(aRESP_HPI_ADAPTER_OPEN[0])); - if (hr.wError) - return hr.wError; + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, + HPI_ADAPTER_OPEN); + hm.adapter_index = adapter; + hw_entry_point(&hm, &hr); + memcpy(&rESP_HPI_ADAPTER_OPEN[adapter], &hr, + sizeof(rESP_HPI_ADAPTER_OPEN[0])); + if (hr.error) + return hr.error; /* call to HPI_ADAPTER_GET_INFO */ - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ADAPTER, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_GET_INFO); - hm.wAdapterIndex = wAdapter; - HW_EntryPoint(&hm, &hr); - if (hr.wError) - return hr.wError; - - aADAPTER_INFO[wAdapter].wNumOutStreams = hr.u.a.wNumOStreams; - aADAPTER_INFO[wAdapter].wNumInStreams = hr.u.a.wNumIStreams; - aADAPTER_INFO[wAdapter].wType = hr.u.a.wAdapterType; - - gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.awAdapterList[wAdapter] = - hr.u.a.wAdapterType; - gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.wNumAdapters++; - if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.wNumAdapters > HPI_MAX_ADAPTERS) - gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.wNumAdapters = + hm.adapter_index = adapter; + hw_entry_point(&hm, &hr); + if (hr.error) + return hr.error; + + aDAPTER_INFO[adapter].num_outstreams = hr.u.a.num_outstreams; + aDAPTER_INFO[adapter].num_instreams = hr.u.a.num_instreams; + aDAPTER_INFO[adapter].type = hr.u.a.adapter_type; + + gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list[adapter] = + hr.u.a.adapter_type; + gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters++; + if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters > HPI_MAX_ADAPTERS) + gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters = HPI_MAX_ADAPTERS; /* call to HPI_OSTREAM_OPEN */ - for (i = 0; i < aADAPTER_INFO[wAdapter].wNumOutStreams; i++) { - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_OSTREAM, + for (i = 0; i < aDAPTER_INFO[adapter].num_outstreams; i++) { + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_OPEN); - hm.wAdapterIndex = wAdapter; - hm.wObjIndex = i; - HW_EntryPoint(&hm, &hr); - memcpy(&aRESP_HPI_OSTREAM_OPEN[wAdapter][i], &hr, - sizeof(aRESP_HPI_OSTREAM_OPEN[0][0])); - aOStreamUserOpen[wAdapter][i].nOpenFlag = 0; - aOStreamUserOpen[wAdapter][i].hOwner = NULL; + hm.adapter_index = adapter; + hm.obj_index = i; + hw_entry_point(&hm, &hr); + memcpy(&rESP_HPI_OSTREAM_OPEN[adapter][i], &hr, + sizeof(rESP_HPI_OSTREAM_OPEN[0][0])); + outstream_user_open[adapter][i].open_flag = 0; + outstream_user_open[adapter][i].h_owner = NULL; } /* call to HPI_ISTREAM_OPEN */ - for (i = 0; i < aADAPTER_INFO[wAdapter].wNumInStreams; i++) { - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_ISTREAM, + for (i = 0; i < aDAPTER_INFO[adapter].num_instreams; i++) { + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_OPEN); - hm.wAdapterIndex = wAdapter; - hm.wObjIndex = i; - HW_EntryPoint(&hm, &hr); - memcpy(&aRESP_HPI_ISTREAM_OPEN[wAdapter][i], &hr, - sizeof(aRESP_HPI_ISTREAM_OPEN[0][0])); - aIStreamUserOpen[wAdapter][i].nOpenFlag = 0; - aIStreamUserOpen[wAdapter][i].hOwner = NULL; + hm.adapter_index = adapter; + hm.obj_index = i; + hw_entry_point(&hm, &hr); + memcpy(&rESP_HPI_ISTREAM_OPEN[adapter][i], &hr, + sizeof(rESP_HPI_ISTREAM_OPEN[0][0])); + instream_user_open[adapter][i].open_flag = 0; + instream_user_open[adapter][i].h_owner = NULL; } /* call to HPI_MIXER_OPEN */ - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN); - hm.wAdapterIndex = wAdapter; - HW_EntryPoint(&hm, &hr); - memcpy(&aRESP_HPI_MIXER_OPEN[wAdapter], &hr, - sizeof(aRESP_HPI_MIXER_OPEN[0])); + hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN); + hm.adapter_index = adapter; + hw_entry_point(&hm, &hr); + memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr, + sizeof(rESP_HPI_MIXER_OPEN[0])); - return gRESP_HPI_SUBSYS_FIND_ADAPTERS.h.wError; + return gRESP_HPI_SUBSYS_FIND_ADAPTERS.h.error; } -static void HPIMSGX_Reset( - u16 wAdapterIndex -) +static void HPIMSGX__reset(u16 adapter_index) { int i; - u16 wAdapter; + u16 adapter; struct hpi_response hr; - if (wAdapterIndex == HPIMSGX_ALLADAPTERS) { + if (adapter_index == HPIMSGX_ALLADAPTERS) { /* reset all responses to contain errors */ - HPI_InitResponse(&hr, HPI_OBJ_SUBSYSTEM, + hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_FIND_ADAPTERS, 0); memcpy(&gRESP_HPI_SUBSYS_FIND_ADAPTERS, &hr, sizeof(&gRESP_HPI_SUBSYS_FIND_ADAPTERS)); - for (wAdapter = 0; wAdapter < HPI_MAX_ADAPTERS; wAdapter++) { + for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) { - HPI_InitResponse(&hr, HPI_OBJ_ADAPTER, + hpi_init_response(&hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_OPEN, HPI_ERROR_BAD_ADAPTER); - memcpy(&aRESP_HPI_ADAPTER_OPEN[wAdapter], &hr, - sizeof(aRESP_HPI_ADAPTER_OPEN[wAdapter])); + memcpy(&rESP_HPI_ADAPTER_OPEN[adapter], &hr, + sizeof(rESP_HPI_ADAPTER_OPEN[adapter])); - HPI_InitResponse(&hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN, + hpi_init_response(&hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN, HPI_ERROR_INVALID_OBJ); - memcpy(&aRESP_HPI_MIXER_OPEN[wAdapter], &hr, - sizeof(aRESP_HPI_MIXER_OPEN[wAdapter])); + memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr, + sizeof(rESP_HPI_MIXER_OPEN[adapter])); for (i = 0; i < HPI_MAX_STREAMS; i++) { - HPI_InitResponse(&hr, HPI_OBJ_OSTREAM, + hpi_init_response(&hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_OPEN, HPI_ERROR_INVALID_OBJ); - memcpy(&aRESP_HPI_OSTREAM_OPEN[wAdapter][i], + memcpy(&rESP_HPI_OSTREAM_OPEN[adapter][i], &hr, - sizeof(aRESP_HPI_OSTREAM_OPEN - [wAdapter] + sizeof(rESP_HPI_OSTREAM_OPEN[adapter] [i])); - HPI_InitResponse(&hr, HPI_OBJ_ISTREAM, + hpi_init_response(&hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_OPEN, HPI_ERROR_INVALID_OBJ); - memcpy(&aRESP_HPI_ISTREAM_OPEN[wAdapter][i], + memcpy(&rESP_HPI_ISTREAM_OPEN[adapter][i], &hr, - sizeof(aRESP_HPI_ISTREAM_OPEN - [wAdapter] + sizeof(rESP_HPI_ISTREAM_OPEN[adapter] [i])); } } - } else if (wAdapterIndex < HPI_MAX_ADAPTERS) { - aRESP_HPI_ADAPTER_OPEN[wAdapterIndex].h.wError = + } else if (adapter_index < HPI_MAX_ADAPTERS) { + rESP_HPI_ADAPTER_OPEN[adapter_index].h.error = HPI_ERROR_BAD_ADAPTER; - aRESP_HPI_MIXER_OPEN[wAdapterIndex].h.wError = + rESP_HPI_MIXER_OPEN[adapter_index].h.error = HPI_ERROR_INVALID_OBJ; for (i = 0; i < HPI_MAX_STREAMS; i++) { - aRESP_HPI_OSTREAM_OPEN[wAdapterIndex][i].h.wError = + rESP_HPI_OSTREAM_OPEN[adapter_index][i].h.error = HPI_ERROR_INVALID_OBJ; - aRESP_HPI_ISTREAM_OPEN[wAdapterIndex][i].h.wError = + rESP_HPI_ISTREAM_OPEN[adapter_index][i].h.error = HPI_ERROR_INVALID_OBJ; } if (gRESP_HPI_SUBSYS_FIND_ADAPTERS. - s.awAdapterList[wAdapterIndex]) { + s.aw_adapter_list[adapter_index]) { gRESP_HPI_SUBSYS_FIND_ADAPTERS. - s.awAdapterList[wAdapterIndex] = 0; - gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.wNumAdapters--; + s.aw_adapter_list[adapter_index] = 0; + gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters--; } } } -static u16 HPIMSGX_Init( - struct hpi_message *phm, +static u16 HPIMSGX__init(struct hpi_message *phm, /* HPI_SUBSYS_CREATE_ADAPTER structure with */ /* resource list or NULL=find all */ struct hpi_response *phr /* response from HPI_ADAPTER_GET_INFO */ -) + ) { - HPI_HandlerFunc *entry_point_func; + hpi_handler_func *entry_point_func; struct hpi_response hr; - if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.wNumAdapters >= HPI_MAX_ADAPTERS) + if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters >= HPI_MAX_ADAPTERS) return HPI_ERROR_BAD_ADAPTER_NUMBER; /* Init response here so we can pass in previous adapter list */ - HPI_InitResponse(&hr, phm->wObject, phm->wFunction, + hpi_init_response(&hr, phm->object, phm->function, HPI_ERROR_INVALID_OBJ); - memcpy(hr.u.s.awAdapterList, - gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.awAdapterList, - sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.awAdapterList)); + memcpy(hr.u.s.aw_adapter_list, + gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list, + sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list)); entry_point_func = - HPI_LookupEntryPointFunction(phm->u.s.Resource.r.Pci); + hpi_lookup_entry_point_function(phm->u.s.resource.r.pci); if (entry_point_func) { HPI_DEBUG_MESSAGE(DEBUG, phm); entry_point_func(phm, &hr); } else { - phr->wError = HPI_ERROR_PROCESSING_MESSAGE; - return phr->wError; + phr->error = HPI_ERROR_PROCESSING_MESSAGE; + return phr->error; } - if (hr.wError == 0) { + if (hr.error == 0) { /* the adapter was created succesfully save the mapping for future use */ - hpi_entry_points[hr.u.s.wAdapterIndex] = entry_point_func; + hpi_entry_points[hr.u.s.adapter_index] = entry_point_func; /* prepare adapter (pre-open streams etc.) */ HPI_DEBUG_LOG(DEBUG, "HPI_SUBSYS_CREATE_ADAPTER successful," " preparing adapter\n"); - AdapterPrepare(hr.u.s.wAdapterIndex); + adapter_prepare(hr.u.s.adapter_index); } - memcpy(phr, &hr, hr.wSize); - return phr->wError; + memcpy(phr, &hr, hr.size); + return phr->error; } -static void HPIMSGX_Cleanup( - u16 wAdapterIndex, - void *hOwner -) +static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner) { - int i, wAdapter, wAdapterLimit; + int i, adapter, adapter_limit; - if (!hOwner) + if (!h_owner) return; - if (wAdapterIndex == HPIMSGX_ALLADAPTERS) { - wAdapter = 0; - wAdapterLimit = HPI_MAX_ADAPTERS; + if (adapter_index == HPIMSGX_ALLADAPTERS) { + adapter = 0; + adapter_limit = HPI_MAX_ADAPTERS; } else { - wAdapter = wAdapterIndex; - wAdapterLimit = wAdapter + 1; + adapter = adapter_index; + adapter_limit = adapter + 1; } - for (; wAdapter < wAdapterLimit; wAdapter++) { + for (; adapter < adapter_limit; adapter++) { /* printk(KERN_INFO "Cleanup adapter #%d\n",wAdapter); */ for (i = 0; i < HPI_MAX_STREAMS; i++) { - if (hOwner == aOStreamUserOpen[wAdapter][i].hOwner) { + if (h_owner == + outstream_user_open[adapter][i].h_owner) { struct hpi_message hm; struct hpi_response hr; HPI_DEBUG_LOG(DEBUG, - "Close adapter %d ostream %d\n", - wAdapter, i); + "close adapter %d ostream %d\n", + adapter, i); - HPI_InitMessageResponse(&hm, &hr, + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_RESET); - hm.wAdapterIndex = (u16)wAdapter; - hm.wObjIndex = (u16)i; - HW_EntryPoint(&hm, &hr); + hm.adapter_index = (u16)adapter; + hm.obj_index = (u16)i; + hw_entry_point(&hm, &hr); - hm.wFunction = HPI_OSTREAM_HOSTBUFFER_FREE; - HW_EntryPoint(&hm, &hr); + hm.function = HPI_OSTREAM_HOSTBUFFER_FREE; + hw_entry_point(&hm, &hr); - hm.wFunction = HPI_OSTREAM_GROUP_RESET; - HW_EntryPoint(&hm, &hr); + hm.function = HPI_OSTREAM_GROUP_RESET; + hw_entry_point(&hm, &hr); - aOStreamUserOpen[wAdapter][i].nOpenFlag = 0; - aOStreamUserOpen[wAdapter][i].hOwner = NULL; + outstream_user_open[adapter][i].open_flag = 0; + outstream_user_open[adapter][i].h_owner = + NULL; } - if (hOwner == aIStreamUserOpen[wAdapter][i].hOwner) { + if (h_owner == instream_user_open[adapter][i].h_owner) { struct hpi_message hm; struct hpi_response hr; HPI_DEBUG_LOG(DEBUG, - "Close adapter %d istream %d\n", - wAdapter, i); + "close adapter %d istream %d\n", + adapter, i); - HPI_InitMessageResponse(&hm, &hr, + hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, HPI_ISTREAM_RESET); - hm.wAdapterIndex = (u16)wAdapter; - hm.wObjIndex = (u16)i; - HW_EntryPoint(&hm, &hr); + hm.adapter_index = (u16)adapter; + hm.obj_index = (u16)i; + hw_entry_point(&hm, &hr); - hm.wFunction = HPI_ISTREAM_HOSTBUFFER_FREE; - HW_EntryPoint(&hm, &hr); + hm.function = HPI_ISTREAM_HOSTBUFFER_FREE; + hw_entry_point(&hm, &hr); - hm.wFunction = HPI_ISTREAM_GROUP_RESET; - HW_EntryPoint(&hm, &hr); + hm.function = HPI_ISTREAM_GROUP_RESET; + hw_entry_point(&hm, &hr); - aIStreamUserOpen[wAdapter][i].nOpenFlag = 0; - aIStreamUserOpen[wAdapter][i].hOwner = NULL; + instream_user_open[adapter][i].open_flag = 0; + instream_user_open[adapter][i].h_owner = NULL; } } } diff --git a/pci/asihpi/hpimsgx.h b/pci/asihpi/hpimsgx.h index 1d8ec3352..3c9f9a398 100644 --- a/pci/asihpi/hpimsgx.h +++ b/pci/asihpi/hpimsgx.h @@ -34,13 +34,10 @@ extern "C" { #define HPIMSGX_ALLADAPTERS (0xFFFF) -void HPI_MessageEx( - struct hpi_message *phm, - struct hpi_response *phr, - void *hOwner -); +void hpi_send_recv_ex(struct hpi_message *phm, struct hpi_response *phr, + void *h_owner); -#define HPI_MESSAGE_LOWER_LAYER HPI_MessageEx +#define HPI_MESSAGE_LOWER_LAYER hpi_send_recv_ex #ifdef __cplusplus /* *INDENT-OFF* */ diff --git a/pci/asihpi/hpioctl.c b/pci/asihpi/hpioctl.c index dacef355c..92761ba7d 100644 --- a/pci/asihpi/hpioctl.c +++ b/pci/asihpi/hpioctl.c @@ -43,19 +43,15 @@ MODULE_FIRMWARE("asihpi/dsp8900.bin"); #endif static int prealloc_stream_buf; -module_param(prealloc_stream_buf, int, - S_IRUGO -); +module_param(prealloc_stream_buf, int, S_IRUGO); MODULE_PARM_DESC(prealloc_stream_buf, - "Preallocate size for per-adapter stream buffer"); + "preallocate size for per-adapter stream buffer"); /* Allow the debug level to be changed after module load. E.g. echo 2 > /sys/module/asihpi/parameters/hpiDebugLevel */ -module_param(hpiDebugLevel, int, - S_IRUGO | S_IWUSR -); -MODULE_PARM_DESC(hpiDebugLevel, "Debug verbosity 0..5"); +module_param(hpi_debug_level, int, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(hpi_debug_level, "debug verbosity 0..5"); /* List of adapters found */ static struct hpi_adapter adapters[HPI_MAX_ADAPTERS]; @@ -63,56 +59,44 @@ static struct hpi_adapter adapters[HPI_MAX_ADAPTERS]; /* Wrapper function to HPI_Message to enable dumping of the message and response types. */ -static void HPI_MessageF( - struct hpi_message *phm, - struct hpi_response *phr, - struct file *file -) +static void hpi_send_recvF(struct hpi_message *phm, struct hpi_response *phr, + struct file *file) { - int nAdapter = phm->wAdapterIndex; + int adapter = phm->adapter_index; - if ((nAdapter >= HPI_MAX_ADAPTERS || nAdapter < 0) && - (phm->wObject != HPI_OBJ_SUBSYSTEM)) - phr->wError = HPI_ERROR_INVALID_OBJ_INDEX; + if ((adapter >= HPI_MAX_ADAPTERS || adapter < 0) + && (phm->object != HPI_OBJ_SUBSYSTEM)) + phr->error = HPI_ERROR_INVALID_OBJ_INDEX; else - HPI_MessageEx(phm, phr, file); + hpi_send_recv_ex(phm, phr, file); } /* This is called from hpifunc.c functions, called by ALSA * (or other kernel process) In this case there is no file descriptor * available for the message cache code */ -void HPI_Message( - struct hpi_message *phm, - struct hpi_response *phr -) +void hpi_send_recv(struct hpi_message *phm, struct hpi_response *phr) { - HPI_MessageF(phm, phr, HOWNER_KERNEL); + hpi_send_recvF(phm, phr, HOWNER_KERNEL); } -EXPORT_SYMBOL(HPI_Message); +EXPORT_SYMBOL(hpi_send_recv); /* export HPI_Message for radio-asihpi */ -int asihpi_hpi_release( - struct file *file -) +int asihpi_hpi_release(struct file *file) { struct hpi_message hm; struct hpi_response hr; /* HPI_DEBUG_LOG(INFO,"hpi_release file %p, pid %d\n", file, current->pid); */ /* close the subsystem just in case the application forgot to. */ - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CLOSE); - HPI_MessageEx(&hm, &hr, file); + hpi_send_recv_ex(&hm, &hr, file); return 0; } -long asihpi_hpi_ioctl( - struct file *file, - unsigned int cmd, - unsigned long arg -) +long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct hpi_ioctl_linux __user *phpi_ioctl_data; void __user *puhm; @@ -133,13 +117,13 @@ long asihpi_hpi_ioctl( get_user(puhr, &phpi_ioctl_data->phr); /* Now read the message size and data from user space. */ - get_user(hm.h.wSize, (u16 __user *)puhm); - if (hm.h.wSize > sizeof(hm)) - hm.h.wSize = sizeof(hm); + get_user(hm.h.size, (u16 __user *)puhm); + if (hm.h.size > sizeof(hm)) + hm.h.size = sizeof(hm); /*printk(KERN_INFO "message size %d\n", hm.h.wSize); */ - uncopied_bytes = copy_from_user(&hm, puhm, hm.h.wSize); + uncopied_bytes = copy_from_user(&hm, puhm, hm.h.size); if (uncopied_bytes) { HPI_DEBUG_LOG(ERROR, "uncopied bytes %d\n", uncopied_bytes); return -EFAULT; @@ -148,26 +132,26 @@ long asihpi_hpi_ioctl( get_user(res_max_size, (u16 __user *)puhr); /* printk(KERN_INFO "user response size %d\n", res_max_size); */ if (res_max_size < sizeof(struct hpi_response_header)) { - HPI_DEBUG_LOG(WARNING, "Small res size %d\n", res_max_size); + HPI_DEBUG_LOG(WARNING, "small res size %d\n", res_max_size); return -EFAULT; } - pa = &adapters[hm.h.wAdapterIndex]; - hr.h.wSize = 0; - if (hm.h.wObject == HPI_OBJ_SUBSYSTEM) { - switch (hm.h.wFunction) { + pa = &adapters[hm.h.adapter_index]; + hr.h.size = 0; + if (hm.h.object == HPI_OBJ_SUBSYSTEM) { + switch (hm.h.function) { case HPI_SUBSYS_CREATE_ADAPTER: case HPI_SUBSYS_DELETE_ADAPTER: /* Application must not use these functions! */ - hr.h.wSize = sizeof(hr.h); - hr.h.wError = HPI_ERROR_INVALID_OPERATION; - hr.h.wFunction = hm.h.wFunction; - uncopied_bytes = copy_to_user(puhr, &hr, hr.h.wSize); + hr.h.size = sizeof(hr.h); + hr.h.error = HPI_ERROR_INVALID_OPERATION; + hr.h.function = hm.h.function; + uncopied_bytes = copy_to_user(puhr, &hr, hr.h.size); if (uncopied_bytes) return -EFAULT; return 0; default: - HPI_MessageF(&hm.m0, &hr.r0, file); + hpi_send_recvF(&hm.m0, &hr.r0, file); } } else { u16 __user *ptr = NULL; @@ -175,10 +159,10 @@ long asihpi_hpi_ioctl( /* -1=no data 0=read from user mem, 1=write to user mem */ int wrflag = -1; - u32 nAdapter = hm.h.wAdapterIndex; + u32 adapter = hm.h.adapter_index; - if ((hm.h.wAdapterIndex > HPI_MAX_ADAPTERS) || (!pa->type)) { - HPI_InitResponse(&hr.r0, HPI_OBJ_ADAPTER, + if ((hm.h.adapter_index > HPI_MAX_ADAPTERS) || (!pa->type)) { + hpi_init_response(&hr.r0, HPI_OBJ_ADAPTER, HPI_ADAPTER_OPEN, HPI_ERROR_BAD_ADAPTER_NUMBER); @@ -189,16 +173,16 @@ long asihpi_hpi_ioctl( return 0; } - if (mutex_lock_interruptible(&adapters[nAdapter].mutex)) + if (mutex_lock_interruptible(&adapters[adapter].mutex)) return -EINTR; /* Dig out any pointers embedded in the message. */ - switch (hm.h.wFunction) { + switch (hm.h.function) { case HPI_OSTREAM_WRITE: case HPI_ISTREAM_READ:{ /* Yes, sparse, this is correct. */ - ptr = (u16 __user *)hm.m0.u.d.u.Data.pbData; - size = hm.m0.u.d.u.Data.dwDataSize; + ptr = (u16 __user *)hm.m0.u.d.u.data.pb_data; + size = hm.m0.u.d.u.data.data_size; /* Allocate buffer according to application request. ?Is it better to alloc/free for the duration @@ -206,16 +190,16 @@ long asihpi_hpi_ioctl( */ if (pa->buffer_size < size) { HPI_DEBUG_LOG(DEBUG, - "Realloc adapter %d stream buffer " + "realloc adapter %d stream buffer " "from %zd to %d\n", - hm.h.wAdapterIndex, + hm.h.adapter_index, pa->buffer_size, size); - if (pa->pBuffer) { + if (pa->p_buffer) { pa->buffer_size = 0; - vfree(pa->pBuffer); + vfree(pa->p_buffer); } - pa->pBuffer = vmalloc(size); - if (pa->pBuffer) + pa->p_buffer = vmalloc(size); + if (pa->p_buffer) pa->buffer_size = size; else { HPI_DEBUG_LOG(ERROR, @@ -224,13 +208,13 @@ long asihpi_hpi_ioctl( size); mutex_unlock(&adapters - [nAdapter].mutex); + [adapter].mutex); return -EINVAL; } } - hm.m0.u.d.u.Data.pbData = pa->pBuffer; - if (hm.h.wFunction == HPI_ISTREAM_READ) + hm.m0.u.d.u.data.pb_data = pa->p_buffer; + if (hm.h.function == HPI_ISTREAM_READ) /* from card, WRITE to user mem */ wrflag = 1; else @@ -245,44 +229,44 @@ long asihpi_hpi_ioctl( if (size && (wrflag == 0)) { uncopied_bytes = - copy_from_user(pa->pBuffer, ptr, size); + copy_from_user(pa->p_buffer, ptr, size); if (uncopied_bytes) HPI_DEBUG_LOG(WARNING, - "Missed %d of %d " - "bytes from user\n", - uncopied_bytes, size); + "missed %d of %d " + "bytes from user\n", uncopied_bytes, + size); } - HPI_MessageF(&hm.m0, &hr.r0, file); + hpi_send_recvF(&hm.m0, &hr.r0, file); if (size && (wrflag == 1)) { - uncopied_bytes = copy_to_user(ptr, pa->pBuffer, size); + uncopied_bytes = + copy_to_user(ptr, pa->p_buffer, size); if (uncopied_bytes) HPI_DEBUG_LOG(WARNING, - "Missed %d of %d " - "bytes to user\n", + "missed %d of %d " "bytes to user\n", uncopied_bytes, size); } - mutex_unlock(&adapters[nAdapter].mutex); + mutex_unlock(&adapters[adapter].mutex); } /* on return response size must be set */ /*printk(KERN_INFO "response size %d\n", hr.h.wSize); */ - if (!hr.h.wSize) { + if (!hr.h.size) { HPI_DEBUG_LOG(ERROR, "response zero size\n"); return -EFAULT; } - if (hr.h.wSize > res_max_size) { - HPI_DEBUG_LOG(ERROR, "response too big %d %d\n", hr.h.wSize, + if (hr.h.size > res_max_size) { + HPI_DEBUG_LOG(ERROR, "response too big %d %d\n", hr.h.size, res_max_size); /*HPI_DEBUG_MESSAGE(ERROR, &hm); */ return -EFAULT; } - uncopied_bytes = copy_to_user(puhr, &hr, hr.h.wSize); + uncopied_bytes = copy_to_user(puhr, &hr, hr.h.size); if (uncopied_bytes) { HPI_DEBUG_LOG(ERROR, "uncopied bytes %d\n", uncopied_bytes); return -EFAULT; @@ -291,30 +275,28 @@ long asihpi_hpi_ioctl( return 0; } -int __devinit asihpi_adapter_probe( - struct pci_dev *pci_dev, - const struct pci_device_id *pci_id -) +int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, + const struct pci_device_id *pci_id) { int err, idx, nm; unsigned int memlen; struct hpi_message hm; struct hpi_response hr; struct hpi_adapter adapter; - struct hpi_pci Pci; + struct hpi_pci pci; memset(&adapter, 0, sizeof(adapter)); - printk(KERN_DEBUG "Probe PCI device (%04x:%04x,%04x:%04x,%04x)\n", + printk(KERN_DEBUG "probe PCI device (%04x:%04x,%04x:%04x,%04x)\n", pci_dev->vendor, pci_dev->device, pci_dev->subsystem_vendor, pci_dev->subsystem_device, pci_dev->devfn); - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CREATE_ADAPTER); - HPI_InitResponse(&hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CREATE_ADAPTER, + hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CREATE_ADAPTER, HPI_ERROR_PROCESSING_MESSAGE); - hm.wAdapterIndex = -1; /* an invalid index */ + hm.adapter_index = -1; /* an invalid index */ /* fill in HPI_PCI information from kernel provided information */ adapter.pci = pci_dev; @@ -322,7 +304,7 @@ int __devinit asihpi_adapter_probe( nm = HPI_MAX_ADAPTER_MEM_SPACES; for (idx = 0; idx < nm; idx++) { - HPI_DEBUG_LOG(INFO, "Resource %d %s %08llx-%08llx %04llx\n", + HPI_DEBUG_LOG(INFO, "resource %d %s %08llx-%08llx %04llx\n", idx, pci_dev->resource[idx].name, (unsigned long long)pci_resource_start(pci_dev, idx), (unsigned long long)pci_resource_end(pci_dev, idx), @@ -330,10 +312,10 @@ int __devinit asihpi_adapter_probe( if (pci_resource_flags(pci_dev, idx) & IORESOURCE_MEM) { memlen = pci_resource_len(pci_dev, idx); - adapter.apRemappedMemBase[idx] = + adapter.ap_remapped_mem_base[idx] = ioremap(pci_resource_start(pci_dev, idx), memlen); - if (!adapter.apRemappedMemBase[idx]) { + if (!adapter.ap_remapped_mem_base[idx]) { HPI_DEBUG_LOG(ERROR, "ioremap failed, aborting\n"); /* unmap previously mapped pci mem space */ @@ -341,33 +323,33 @@ int __devinit asihpi_adapter_probe( } } - Pci.apMemBase[idx] = adapter.apRemappedMemBase[idx]; + pci.ap_mem_base[idx] = adapter.ap_remapped_mem_base[idx]; } /* could replace Pci with direct pointer to pci_dev for linux Instead wrap accessor functions for IDs etc. Would it work for windows? */ - Pci.wBusNumber = pci_dev->bus->number; - Pci.wVendorId = (u16)pci_dev->vendor; - Pci.wDeviceId = (u16)pci_dev->device; - Pci.wSubSysVendorId = (u16)(pci_dev->subsystem_vendor & 0xffff); - Pci.wSubSysDeviceId = (u16)(pci_dev->subsystem_device & 0xffff); - Pci.wDeviceNumber = pci_dev->devfn; - Pci.wInterrupt = pci_dev->irq; - Pci.pOsData = pci_dev; - - hm.u.s.Resource.wBusType = HPI_BUS_PCI; - hm.u.s.Resource.r.Pci = &Pci; + pci.bus_number = pci_dev->bus->number; + pci.vendor_id = (u16)pci_dev->vendor; + pci.device_id = (u16)pci_dev->device; + pci.subsys_vendor_id = (u16)(pci_dev->subsystem_vendor & 0xffff); + pci.subsys_device_id = (u16)(pci_dev->subsystem_device & 0xffff); + pci.device_number = pci_dev->devfn; + pci.interrupt = pci_dev->irq; + pci.p_os_data = pci_dev; + + hm.u.s.resource.bus_type = HPI_BUS_PCI; + hm.u.s.resource.r.pci = &pci; /* call CreateAdapterObject on the relevant hpi module */ - HPI_MessageEx(&hm, &hr, HOWNER_KERNEL); - if (hr.wError) + hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); + if (hr.error) goto err; if (prealloc_stream_buf) { - adapter.pBuffer = vmalloc(prealloc_stream_buf); - if (!adapter.pBuffer) { + adapter.p_buffer = vmalloc(prealloc_stream_buf); + if (!adapter.p_buffer) { HPI_DEBUG_LOG(ERROR, "HPI could not allocate " "kernel buffer size %d\n", @@ -376,11 +358,11 @@ int __devinit asihpi_adapter_probe( } } - adapter.index = hr.u.s.wAdapterIndex; - adapter.type = hr.u.s.awAdapterList[adapter.index]; - hm.wAdapterIndex = adapter.index; + adapter.index = hr.u.s.adapter_index; + adapter.type = hr.u.s.aw_adapter_list[adapter.index]; + hm.adapter_index = adapter.index; - err = HPI_AdapterOpen(NULL, adapter.index); + err = hpi_adapter_open(NULL, adapter.index); if (err) goto err; @@ -388,36 +370,33 @@ int __devinit asihpi_adapter_probe( /* WARNING can't init mutex in 'adapter' * and then copy it to adapters[] ?!?! */ - adapters[hr.u.s.wAdapterIndex] = adapter; + adapters[hr.u.s.adapter_index] = adapter; mutex_init(&adapters[adapter.index].mutex); pci_set_drvdata(pci_dev, &adapters[adapter.index]); - printk(KERN_INFO - "Probe found adapter ASI%04X HPI index #%d.\n", + printk(KERN_INFO "probe found adapter ASI%04X HPI index #%d.\n", adapter.type, adapter.index); return 0; err: for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { - if (adapter.apRemappedMemBase[idx]) { - iounmap(adapter.apRemappedMemBase[idx]); - adapter.apRemappedMemBase[idx] = NULL; + if (adapter.ap_remapped_mem_base[idx]) { + iounmap(adapter.ap_remapped_mem_base[idx]); + adapter.ap_remapped_mem_base[idx] = NULL; } } - if (adapter.pBuffer) { + if (adapter.p_buffer) { adapter.buffer_size = 0; - vfree(adapter.pBuffer); + vfree(adapter.p_buffer); } HPI_DEBUG_LOG(ERROR, "adapter_probe failed\n"); return -ENODEV; } -void __devexit asihpi_adapter_remove( - struct pci_dev *pci_dev -) +void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev) { int idx; struct hpi_message hm; @@ -425,22 +404,22 @@ void __devexit asihpi_adapter_remove( struct hpi_adapter *pa; pa = (struct hpi_adapter *)pci_get_drvdata(pci_dev); - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_DELETE_ADAPTER); - hm.wAdapterIndex = pa->index; - HPI_MessageEx(&hm, &hr, HOWNER_KERNEL); + hm.adapter_index = pa->index; + hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); /* unmap PCI memory space, mapped during device init. */ for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { - if (pa->apRemappedMemBase[idx]) { - iounmap(pa->apRemappedMemBase[idx]); - pa->apRemappedMemBase[idx] = NULL; + if (pa->ap_remapped_mem_base[idx]) { + iounmap(pa->ap_remapped_mem_base[idx]); + pa->ap_remapped_mem_base[idx] = NULL; } } - if (pa->pBuffer) { + if (pa->p_buffer) { pa->buffer_size = 0; - vfree(pa->pBuffer); + vfree(pa->p_buffer); } pci_set_drvdata(pci_dev, NULL); @@ -454,9 +433,7 @@ void __devexit asihpi_adapter_remove( */ } -void __init asihpi_init( - void -) +void __init asihpi_init(void) { struct hpi_message hm; struct hpi_response hr; @@ -464,25 +441,20 @@ void __init asihpi_init( memset(adapters, 0, sizeof(adapters)); printk(KERN_INFO "ASIHPI driver %d.%02d.%02d\n", - HPI_VER_MAJOR(HPI_VER), - HPI_VER_MINOR(HPI_VER), HPI_VER_RELEASE(HPI_VER)); + HPI_VER_MAJOR(HPI_VER), HPI_VER_MINOR(HPI_VER), + HPI_VER_RELEASE(HPI_VER)); - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_DRIVER_LOAD); - HPI_MessageEx(&hm, &hr, HOWNER_KERNEL); + hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); } -void asihpi_exit( - void -) +void asihpi_exit(void) { struct hpi_message hm; struct hpi_response hr; - HPI_InitMessageResponse(&hm, &hr, HPI_OBJ_SUBSYSTEM, + hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_DRIVER_UNLOAD); - HPI_MessageEx(&hm, &hr, HOWNER_KERNEL); + hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); } - -/*********************************************************** -*/ diff --git a/pci/asihpi/hpioctl.h b/pci/asihpi/hpioctl.h index 53634723f..3aad2fdfa 100644 --- a/pci/asihpi/hpioctl.h +++ b/pci/asihpi/hpioctl.h @@ -19,40 +19,20 @@ Linux HPI ioctl, and shared module init functions *******************************************************************************/ -int __devinit asihpi_adapter_probe( - struct pci_dev *pci_dev, - const struct pci_device_id *pci_id -); -void __devexit asihpi_adapter_remove( - struct pci_dev *pci_dev -); -void __init asihpi_init( - void -); -void __exit asihpi_exit( - void -); - -int asihpi_hpi_release( - struct file *file -); - -long asihpi_hpi_ioctl( - struct file *file, - unsigned int cmd, - unsigned long arg -); +int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, + const struct pci_device_id *pci_id); +void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev); +void __init asihpi_init(void); +void __exit asihpi_exit(void); + +int asihpi_hpi_release(struct file *file); + +long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg); /* This is called from hpifunc.c functions, called by ALSA * (or other kernel process) In this case there is no file descriptor * available for the message cache code */ -void HPI_Message( - struct hpi_message *phm, - struct hpi_response *phr -); +void hpi_send_recv(struct hpi_message *phm, struct hpi_response *phr); #define HOWNER_KERNEL ((void *)-1) - - /*********************************************************** -*/ diff --git a/pci/asihpi/hpios.c b/pci/asihpi/hpios.c index b9d2f81c4..bef81d458 100644 --- a/pci/asihpi/hpios.c +++ b/pci/asihpi/hpios.c @@ -27,43 +27,37 @@ HPI Operating System function implementation for Linux #include <linux/sched.h> #ifndef __KERNEL__ -#error Using kernel source for userspace build +#error using kernel source for userspace build #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2 , 6 , 14) -void HpiOs_DelayMicroSeconds( - u32 dwNumMicroSec -) +void hpios_delay_micro_seconds(u32 num_micro_sec) { - if ((usecs_to_jiffies(dwNumMicroSec) > 1) && !in_interrupt()) { + if ((usecs_to_jiffies(num_micro_sec) > 1) && !in_interrupt()) { /* MUST NOT SCHEDULE IN INTERRUPT CONTEXT! */ schedule_timeout_uninterruptible(usecs_to_jiffies - (dwNumMicroSec)); - } else if (dwNumMicroSec <= 2000) - udelay(dwNumMicroSec); + (num_micro_sec)); + } else if (num_micro_sec <= 2000) + udelay(num_micro_sec); else - mdelay(dwNumMicroSec / 1000); + mdelay(num_micro_sec / 1000); } #else -void HpiOs_DelayMicroSeconds( - u32 dwNumMicroSec -) +void hpios_delay_micro_seconds(u32 num_micro_sec) { - if ((dwNumMicroSec / 1000 >= 1000000 / HZ) && !in_interrupt()) { + if ((num_micro_sec / 1000 >= 1000000 / HZ) && !in_interrupt()) { set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout((HZ * dwNumMicroSec + (HZ - 1)) / 1000000); - } else if (dwNumMicroSec <= 2000) - udelay(dwNumMicroSec); + schedule_timeout((HZ * num_micro_sec + (HZ - 1)) / 1000000); + } else if (num_micro_sec <= 2000) + udelay(num_micro_sec); else - mdelay(dwNumMicroSec / 1000); + mdelay(num_micro_sec / 1000); } #endif -void HpiOs_LockedMem_Init( - void -) +void hpios_locked_mem_init(void) { } @@ -71,62 +65,53 @@ void HpiOs_LockedMem_Init( On error, return -ENOMEM, and *pMemArea.size = 0 */ -u16 HpiOs_LockedMem_Alloc( - struct consistent_dma_area *pMemArea, - u32 size, - struct pci_dev *pdev -) +u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_mem_area, u32 size, + struct pci_dev *pdev) { /*?? any benefit in using managed dmam_alloc_coherent? */ - pMemArea->vaddr = - dma_alloc_coherent(&pdev->dev, size, - &pMemArea->dma_handle, GFP_DMA32 | GFP_KERNEL); - - if (pMemArea->vaddr) { - HPI_DEBUG_LOG(DEBUG, "Allocated %d bytes, dma 0x%x vma %p\n", - size, - (unsigned int)pMemArea->dma_handle, pMemArea->vaddr); - pMemArea->pdev = &pdev->dev; - pMemArea->size = size; + p_mem_area->vaddr = + dma_alloc_coherent(&pdev->dev, size, &p_mem_area->dma_handle, + GFP_DMA32 | GFP_KERNEL); + + if (p_mem_area->vaddr) { + HPI_DEBUG_LOG(DEBUG, "allocated %d bytes, dma 0x%x vma %p\n", + size, (unsigned int)p_mem_area->dma_handle, + p_mem_area->vaddr); + p_mem_area->pdev = &pdev->dev; + p_mem_area->size = size; return 0; } else { HPI_DEBUG_LOG(WARNING, - "Failed to allocate %d bytes locked memory\n", size); - pMemArea->size = 0; + "failed to allocate %d bytes locked memory\n", size); + p_mem_area->size = 0; return -ENOMEM; } } -u16 HpiOs_LockedMem_Free( - struct consistent_dma_area *pMemArea -) +u16 hpios_locked_mem_free(struct consistent_dma_area *p_mem_area) { - if (pMemArea->size) { - dma_free_coherent(pMemArea->pdev, pMemArea->size, - pMemArea->vaddr, pMemArea->dma_handle); - HPI_DEBUG_LOG(DEBUG, "Freed %lu bytes, dma 0x%x vma %p\n", - (unsigned long)pMemArea->size, - (unsigned int)pMemArea->dma_handle, pMemArea->vaddr); - pMemArea->size = 0; + if (p_mem_area->size) { + dma_free_coherent(p_mem_area->pdev, p_mem_area->size, + p_mem_area->vaddr, p_mem_area->dma_handle); + HPI_DEBUG_LOG(DEBUG, "freed %lu bytes, dma 0x%x vma %p\n", + (unsigned long)p_mem_area->size, + (unsigned int)p_mem_area->dma_handle, + p_mem_area->vaddr); + p_mem_area->size = 0; return 0; } else { return 1; } } -void HpiOs_LockedMem_FreeAll( - void -) +void hpios_locked_mem_free_all(void) { } -void __iomem *HpiOs_MapIo( - struct pci_dev *pci_dev, - int idx, - unsigned int length -) +void __iomem *hpios_map_io(struct pci_dev *pci_dev, int idx, + unsigned int length) { - HPI_DEBUG_LOG(DEBUG, "Mapping %d %s %08llx-%08llx %04llx len 0x%x\n", + HPI_DEBUG_LOG(DEBUG, "mapping %d %s %08llx-%08llx %04llx len 0x%x\n", idx, pci_dev->resource[idx].name, (unsigned long long)pci_resource_start(pci_dev, idx), (unsigned long long)pci_resource_end(pci_dev, idx), diff --git a/pci/asihpi/hpios.h b/pci/asihpi/hpios.h index a9bd2f3de..81ad30f2a 100644 --- a/pci/asihpi/hpios.h +++ b/pci/asihpi/hpios.h @@ -78,29 +78,24 @@ struct consistent_dma_area { dma_addr_t dma_handle; }; -static inline u16 HpiOs_LockedMem_GetPhysAddr( - struct consistent_dma_area *LockedMemHandle, - u32 *pPhysicalAddr -) +static inline u16 hpios_locked_mem_get_phys_addr(struct consistent_dma_area + *locked_mem_handle, u32 *p_physical_addr) { - *pPhysicalAddr = LockedMemHandle->dma_handle; + *p_physical_addr = locked_mem_handle->dma_handle; return 0; } -static inline u16 HpiOs_LockedMem_GetVirtAddr( - struct consistent_dma_area *LockedMemHandle, - void **ppVirtualAddr -) +static inline u16 hpios_locked_mem_get_virt_addr(struct consistent_dma_area + *locked_mem_handle, void **pp_virtual_addr) { - *ppVirtualAddr = LockedMemHandle->vaddr; + *pp_virtual_addr = locked_mem_handle->vaddr; return 0; } -static inline u16 HpiOs_LockedMem_Valid( - struct consistent_dma_area *LockedMemHandle -) +static inline u16 hpios_locked_mem_valid(struct consistent_dma_area + *locked_mem_handle) { - return LockedMemHandle->size != 0; + return locked_mem_handle->size != 0; } struct hpi_ioctl_linux { @@ -136,9 +131,7 @@ struct hpios_spinlock { */ #define IN_LOCK_BH 1 #define IN_LOCK_IRQ 0 -static inline void cond_lock( - struct hpios_spinlock *l -) +static inline void cond_lock(struct hpios_spinlock *l) { if (irqs_disabled()) { /* NO bh or isr can execute on this processor, @@ -152,9 +145,7 @@ static inline void cond_lock( } } -static inline void cond_unlock( - struct hpios_spinlock *l -) +static inline void cond_unlock(struct hpios_spinlock *l) { if (l->lock_context == IN_LOCK_BH) spin_unlock_bh(&((l)->lock)); @@ -162,22 +153,22 @@ static inline void cond_unlock( spin_unlock(&((l)->lock)); } -#define HpiOs_Msgxlock_Init(obj) spin_lock_init(&(obj)->lock) -#define HpiOs_Msgxlock_Lock(obj) cond_lock(obj) -#define HpiOs_Msgxlock_UnLock(obj) cond_unlock(obj) +#define hpios_msgxlock_init(obj) spin_lock_init(&(obj)->lock) +#define hpios_msgxlock_lock(obj) cond_lock(obj) +#define hpios_msgxlock_un_lock(obj) cond_unlock(obj) -#define HpiOs_Dsplock_Init(obj) spin_lock_init(&(obj)->dspLock.lock) -#define HpiOs_Dsplock_Lock(obj) cond_lock(&(obj)->dspLock) -#define HpiOs_Dsplock_UnLock(obj) cond_unlock(&(obj)->dspLock) +#define hpios_dsplock_init(obj) spin_lock_init(&(obj)->dsp_lock.lock) +#define hpios_dsplock_lock(obj) cond_lock(&(obj)->dsp_lock) +#define hpios_dsplock_unlock(obj) cond_unlock(&(obj)->dsp_lock) #ifdef CONFIG_SND_DEBUG #define HPI_DEBUG #endif #define HPI_ALIST_LOCKING -#define HpiOs_Alistlock_Init(obj) spin_lock_init(&((obj)->aListLock.lock)) -#define HpiOs_Alistlock_Lock(obj) spin_lock(&((obj)->aListLock.lock)) -#define HpiOs_Alistlock_UnLock(obj) spin_unlock(&((obj)->aListLock.lock)) +#define hpios_alistlock_init(obj) spin_lock_init(&((obj)->list_lock.lock)) +#define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock)) +#define hpios_alistlock_un_lock(obj) spin_unlock(&((obj)->list_lock.lock)) struct hpi_adapter { /* mutex prevents contention for one card @@ -189,24 +180,19 @@ struct hpi_adapter { /* ALSA card structure */ void *snd_card_asihpi; - char *pBuffer; + char *p_buffer; size_t buffer_size; struct pci_dev *pci; - void __iomem *apRemappedMemBase[HPI_MAX_ADAPTER_MEM_SPACES]; + void __iomem *ap_remapped_mem_base[HPI_MAX_ADAPTER_MEM_SPACES]; }; -static inline void HpiOs_UnmapIo( - volatile void __iomem * addr, - unsigned long size -) +static inline void hpios_unmap_io(volatile void __iomem * addr, + unsigned long size) { iounmap(addr); } -void __iomem *HpiOs_MapIo( - struct pci_dev *pci_dev, - int idx, - unsigned int length -); +void __iomem *hpios_map_io(struct pci_dev *pci_dev, int idx, + unsigned int length); #endif |