aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/als4000.c4
-rw-r--r--sound/pci/asihpi/asihpi.c16
-rw-r--r--sound/pci/asihpi/hpi.h68
-rw-r--r--sound/pci/asihpi/hpi6000.c7
-rw-r--r--sound/pci/asihpi/hpi_internal.h40
-rw-r--r--sound/pci/asihpi/hpicmn.c10
-rw-r--r--sound/pci/asihpi/hpidebug.c2
-rw-r--r--sound/pci/asihpi/hpidebug.h4
-rw-r--r--sound/pci/asihpi/hpifunc.c327
-rw-r--r--sound/pci/asihpi/hpimsgx.c2
-rw-r--r--sound/pci/asihpi/hpioctl.c21
-rw-r--r--sound/pci/echoaudio/echoaudio.c2
-rw-r--r--sound/pci/hda/hda_codec.c10
-rw-r--r--sound/pci/hda/hda_codec.h5
-rw-r--r--sound/pci/hda/hda_proc.c7
-rw-r--r--sound/pci/riptide/riptide.c18
-rw-r--r--sound/pci/sis7019.c16
-rw-r--r--sound/pci/via82xx.c9
18 files changed, 355 insertions, 213 deletions
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index 6cf1de8042e8..0e247cb90ecc 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -763,9 +763,9 @@ static void snd_als4000_configure(struct snd_sb *chip)
763 /* SPECS_PAGE: 39 */ 763 /* SPECS_PAGE: 39 */
764 for (i = ALS4K_GCR91_DMA0_ADDR; i <= ALS4K_GCR96_DMA3_MODE_COUNT; ++i) 764 for (i = ALS4K_GCR91_DMA0_ADDR; i <= ALS4K_GCR96_DMA3_MODE_COUNT; ++i)
765 snd_als4k_gcr_write(chip, i, 0); 765 snd_als4k_gcr_write(chip, i, 0);
766 766 /* enable burst mode to prevent dropouts during high PCI bus usage */
767 snd_als4k_gcr_write(chip, ALS4K_GCR99_DMA_EMULATION_CTRL, 767 snd_als4k_gcr_write(chip, ALS4K_GCR99_DMA_EMULATION_CTRL,
768 snd_als4k_gcr_read(chip, ALS4K_GCR99_DMA_EMULATION_CTRL)); 768 (snd_als4k_gcr_read(chip, ALS4K_GCR99_DMA_EMULATION_CTRL) & ~0x07) | 0x04);
769 spin_unlock_irq(&chip->reg_lock); 769 spin_unlock_irq(&chip->reg_lock);
770} 770}
771 771
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index 1db586af4f9c..c80b0b863c54 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -460,6 +460,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
460 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); 460 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream);
461 int err; 461 int err;
462 u16 format; 462 u16 format;
463 int width;
463 unsigned int bytes_per_sec; 464 unsigned int bytes_per_sec;
464 465
465 print_hwparams(params); 466 print_hwparams(params);
@@ -512,9 +513,10 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
512 dpcm->hpi_buffer_attached); 513 dpcm->hpi_buffer_attached);
513 } 514 }
514 bytes_per_sec = params_rate(params) * params_channels(params); 515 bytes_per_sec = params_rate(params) * params_channels(params);
515 bytes_per_sec *= snd_pcm_format_width(params_format(params)); 516 width = snd_pcm_format_width(params_format(params));
517 bytes_per_sec *= width;
516 bytes_per_sec /= 8; 518 bytes_per_sec /= 8;
517 if (bytes_per_sec <= 0) 519 if (width < 0 || bytes_per_sec == 0)
518 return -EINVAL; 520 return -EINVAL;
519 521
520 dpcm->bytes_per_sec = bytes_per_sec; 522 dpcm->bytes_per_sec = bytes_per_sec;
@@ -1383,7 +1385,7 @@ static char *asihpi_src_names[] =
1383 1385
1384compile_time_assert( 1386compile_time_assert(
1385 (ARRAY_SIZE(asihpi_src_names) == 1387 (ARRAY_SIZE(asihpi_src_names) ==
1386 (HPI_SOURCENODE_LAST_INDEX-HPI_SOURCENODE_BASE+1)), 1388 (HPI_SOURCENODE_LAST_INDEX-HPI_SOURCENODE_NONE+1)),
1387 assert_src_names_size); 1389 assert_src_names_size);
1388 1390
1389#if ASI_STYLE_NAMES 1391#if ASI_STYLE_NAMES
@@ -1414,7 +1416,7 @@ static char *asihpi_dst_names[] =
1414 1416
1415compile_time_assert( 1417compile_time_assert(
1416 (ARRAY_SIZE(asihpi_dst_names) == 1418 (ARRAY_SIZE(asihpi_dst_names) ==
1417 (HPI_DESTNODE_LAST_INDEX-HPI_DESTNODE_BASE+1)), 1419 (HPI_DESTNODE_LAST_INDEX-HPI_DESTNODE_NONE+1)),
1418 assert_dst_names_size); 1420 assert_dst_names_size);
1419 1421
1420static inline int ctl_add(struct snd_card *card, struct snd_kcontrol_new *ctl, 1422static inline int ctl_add(struct snd_card *card, struct snd_kcontrol_new *ctl,
@@ -2171,7 +2173,7 @@ static int snd_asihpi_mux_info(struct snd_kcontrol *kcontrol,
2171 &src_node_type, &src_node_index); 2173 &src_node_type, &src_node_index);
2172 2174
2173 sprintf(uinfo->value.enumerated.name, "%s %d", 2175 sprintf(uinfo->value.enumerated.name, "%s %d",
2174 asihpi_src_names[src_node_type - HPI_SOURCENODE_BASE], 2176 asihpi_src_names[src_node_type - HPI_SOURCENODE_NONE],
2175 src_node_index); 2177 src_node_index);
2176 return 0; 2178 return 0;
2177} 2179}
@@ -2603,8 +2605,8 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi)
2603 2605
2604 } 2606 }
2605 2607
2606 hpi_ctl.src_node_type -= HPI_SOURCENODE_BASE; 2608 hpi_ctl.src_node_type -= HPI_SOURCENODE_NONE;
2607 hpi_ctl.dst_node_type -= HPI_DESTNODE_BASE; 2609 hpi_ctl.dst_node_type -= HPI_DESTNODE_NONE;
2608 2610
2609 /* ASI50xx in SSX mode has multiple meters on the same node. 2611 /* ASI50xx in SSX mode has multiple meters on the same node.
2610 Use subindex to create distinct ALSA controls 2612 Use subindex to create distinct ALSA controls
diff --git a/sound/pci/asihpi/hpi.h b/sound/pci/asihpi/hpi.h
index 0173bbe62b67..23399d02f666 100644
--- a/sound/pci/asihpi/hpi.h
+++ b/sound/pci/asihpi/hpi.h
@@ -50,7 +50,8 @@ i.e 3.05.02 is a development version
50#define HPI_VER_RELEASE(v) ((int)(v & 0xFF)) 50#define HPI_VER_RELEASE(v) ((int)(v & 0xFF))
51 51
52/* Use single digits for versions less that 10 to avoid octal. */ 52/* Use single digits for versions less that 10 to avoid octal. */
53#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 3, 25) 53#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 4, 1)
54#define HPI_VER_STRING "4.04.01"
54 55
55/* Library version as documented in hpi-api-versions.txt */ 56/* Library version as documented in hpi-api-versions.txt */
56#define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0) 57#define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0)
@@ -203,8 +204,6 @@ enum HPI_SOURCENODES {
203 exists on a destination node can be searched for using a source 204 exists on a destination node can be searched for using a source
204 node value of either 0, or HPI_SOURCENODE_NONE */ 205 node value of either 0, or HPI_SOURCENODE_NONE */
205 HPI_SOURCENODE_NONE = 100, 206 HPI_SOURCENODE_NONE = 100,
206 /** \deprecated Use HPI_SOURCENODE_NONE instead. */
207 HPI_SOURCENODE_BASE = 100,
208 /** Out Stream (Play) node. */ 207 /** Out Stream (Play) node. */
209 HPI_SOURCENODE_OSTREAM = 101, 208 HPI_SOURCENODE_OSTREAM = 101,
210 /** Line in node - could be analog, AES/EBU or network. */ 209 /** Line in node - could be analog, AES/EBU or network. */
@@ -235,8 +234,6 @@ enum HPI_DESTNODES {
235 exists on a source node can be searched for using a destination 234 exists on a source node can be searched for using a destination
236 node value of either 0, or HPI_DESTNODE_NONE */ 235 node value of either 0, or HPI_DESTNODE_NONE */
237 HPI_DESTNODE_NONE = 200, 236 HPI_DESTNODE_NONE = 200,
238 /** \deprecated Use HPI_DESTNODE_NONE instead. */
239 HPI_DESTNODE_BASE = 200,
240 /** In Stream (Record) node. */ 237 /** In Stream (Record) node. */
241 HPI_DESTNODE_ISTREAM = 201, 238 HPI_DESTNODE_ISTREAM = 201,
242 HPI_DESTNODE_LINEOUT = 202, /**< line out node. */ 239 HPI_DESTNODE_LINEOUT = 202, /**< line out node. */
@@ -432,7 +429,18 @@ Property 2 - adapter can do stream grouping (supports SSX2)
432Property 1 - adapter can do samplerate conversion (MRX) 429Property 1 - adapter can do samplerate conversion (MRX)
433Property 2 - adapter can do timestretch (TSX) 430Property 2 - adapter can do timestretch (TSX)
434*/ 431*/
435 HPI_ADAPTER_PROPERTY_CAPS2 = 269 432 HPI_ADAPTER_PROPERTY_CAPS2 = 269,
433
434/** Readonly adapter sync header connection count.
435*/
436 HPI_ADAPTER_PROPERTY_SYNC_HEADER_CONNECTIONS = 270,
437/** Readonly supports SSX2 property.
438Indicates the adapter supports SSX2 in some mode setting. The
439return value is true (1) or false (0). If the current adapter
440mode is MONO SSX2 is disabled, even though this property will
441return true.
442*/
443 HPI_ADAPTER_PROPERTY_SUPPORTS_SSX2 = 271
436}; 444};
437 445
438/** Adapter mode commands 446/** Adapter mode commands
@@ -813,8 +821,6 @@ enum HPI_SAMPLECLOCK_SOURCES {
813/** The sampleclock output is derived from its local samplerate generator. 821/** The sampleclock output is derived from its local samplerate generator.
814 The local samplerate may be set using HPI_SampleClock_SetLocalRate(). */ 822 The local samplerate may be set using HPI_SampleClock_SetLocalRate(). */
815 HPI_SAMPLECLOCK_SOURCE_LOCAL = 1, 823 HPI_SAMPLECLOCK_SOURCE_LOCAL = 1,
816/** \deprecated Use HPI_SAMPLECLOCK_SOURCE_LOCAL instead */
817 HPI_SAMPLECLOCK_SOURCE_ADAPTER = 1,
818/** The adapter is clocked from a dedicated AES/EBU SampleClock input.*/ 824/** The adapter is clocked from a dedicated AES/EBU SampleClock input.*/
819 HPI_SAMPLECLOCK_SOURCE_AESEBU_SYNC = 2, 825 HPI_SAMPLECLOCK_SOURCE_AESEBU_SYNC = 2,
820/** From external wordclock connector */ 826/** From external wordclock connector */
@@ -825,10 +831,6 @@ enum HPI_SAMPLECLOCK_SOURCES {
825 HPI_SAMPLECLOCK_SOURCE_SMPTE = 5, 831 HPI_SAMPLECLOCK_SOURCE_SMPTE = 5,
826/** One of the aesebu inputs */ 832/** One of the aesebu inputs */
827 HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT = 6, 833 HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT = 6,
828/** \deprecated The first aesebu input with a valid signal
829Superseded by separate Auto enable flag
830*/
831 HPI_SAMPLECLOCK_SOURCE_AESEBU_AUTO = 7,
832/** From a network interface e.g. Cobranet or Livewire at either 48 or 96kHz */ 834/** From a network interface e.g. Cobranet or Livewire at either 48 or 96kHz */
833 HPI_SAMPLECLOCK_SOURCE_NETWORK = 8, 835 HPI_SAMPLECLOCK_SOURCE_NETWORK = 8,
834/** From previous adjacent module (ASI2416 only)*/ 836/** From previous adjacent module (ASI2416 only)*/
@@ -1015,8 +1017,6 @@ enum HPI_ERROR_CODES {
1015 HPI_ERROR_CONTROL_DISABLED = 404, 1017 HPI_ERROR_CONTROL_DISABLED = 404,
1016 /** I2C transaction failed due to a missing ACK. */ 1018 /** I2C transaction failed due to a missing ACK. */
1017 HPI_ERROR_CONTROL_I2C_MISSING_ACK = 405, 1019 HPI_ERROR_CONTROL_I2C_MISSING_ACK = 405,
1018 /** Control attribute is valid, but not supported by this hardware. */
1019 HPI_ERROR_UNSUPPORTED_CONTROL_ATTRIBUTE = 406,
1020 /** Control is busy, or coming out of 1020 /** Control is busy, or coming out of
1021 reset and cannot be accessed at this time. */ 1021 reset and cannot be accessed at this time. */
1022 HPI_ERROR_CONTROL_NOT_READY = 407, 1022 HPI_ERROR_CONTROL_NOT_READY = 407,
@@ -1827,13 +1827,41 @@ u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys,
1827 Compressor Expander control 1827 Compressor Expander control
1828*******************************/ 1828*******************************/
1829 1829
1830u16 hpi_compander_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1830u16 hpi_compander_set_enable(const struct hpi_hsubsys *ph_subsys,
1831 u16 attack, u16 decay, short ratio100, short threshold0_01dB, 1831 u32 h_control, u32 on);
1832 short makeup_gain0_01dB); 1832
1833u16 hpi_compander_get_enable(const struct hpi_hsubsys *ph_subsys,
1834 u32 h_control, u32 *pon);
1835
1836u16 hpi_compander_set_makeup_gain(const struct hpi_hsubsys *ph_subsys,
1837 u32 h_control, short makeup_gain0_01dB);
1838
1839u16 hpi_compander_get_makeup_gain(const struct hpi_hsubsys *ph_subsys,
1840 u32 h_control, short *pn_makeup_gain0_01dB);
1841
1842u16 hpi_compander_set_attack_time_constant(const struct hpi_hsubsys
1843 *ph_subsys, u32 h_control, u32 index, u32 attack);
1844
1845u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys
1846 *ph_subsys, u32 h_control, u32 index, u32 *pw_attack);
1847
1848u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
1849 u32 h_control, u32 index, u32 decay);
1850
1851u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
1852 u32 h_control, u32 index, u32 *pw_decay);
1853
1854u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys,
1855 u32 h_control, u32 index, short threshold0_01dB);
1856
1857u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys,
1858 u32 h_control, u32 index, short *pn_threshold0_01dB);
1859
1860u16 hpi_compander_set_ratio(const struct hpi_hsubsys *ph_subsys,
1861 u32 h_control, u32 index, u32 ratio100);
1833 1862
1834u16 hpi_compander_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, 1863u16 hpi_compander_get_ratio(const struct hpi_hsubsys *ph_subsys,
1835 u16 *pw_attack, u16 *pw_decay, short *pw_ratio100, 1864 u32 h_control, u32 index, u32 *pw_ratio100);
1836 short *pn_threshold0_01dB, short *pn_makeup_gain0_01dB);
1837 1865
1838/******************************* 1866/*******************************
1839 Cobranet HMI control 1867 Cobranet HMI control
diff --git a/sound/pci/asihpi/hpi6000.c b/sound/pci/asihpi/hpi6000.c
index 12dab5e4892c..f7e374ec4414 100644
--- a/sound/pci/asihpi/hpi6000.c
+++ b/sound/pci/asihpi/hpi6000.c
@@ -687,6 +687,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
687 switch (pao->pci.subsys_device_id) { 687 switch (pao->pci.subsys_device_id) {
688 case 0x5100: 688 case 0x5100:
689 case 0x5110: /* ASI5100 revB or higher with C6711D */ 689 case 0x5110: /* ASI5100 revB or higher with C6711D */
690 case 0x5200: /* ASI5200 PC_ie version of ASI5100 */
690 case 0x6100: 691 case 0x6100:
691 case 0x6200: 692 case 0x6200:
692 boot_load_family = HPI_ADAPTER_FAMILY_ASI(0x6200); 693 boot_load_family = HPI_ADAPTER_FAMILY_ASI(0x6200);
@@ -1133,6 +1134,12 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1133 subsys_device_id) == 1134 subsys_device_id) ==
1134 HPI_ADAPTER_FAMILY_ASI(0x5100)) 1135 HPI_ADAPTER_FAMILY_ASI(0x5100))
1135 mask = 0x00000000L; 1136 mask = 0x00000000L;
1137 /* ASI5200 uses AX6 code, */
1138 /* but has no PLD r/w register to test */
1139 if (HPI_ADAPTER_FAMILY_ASI(pao->pci.
1140 subsys_device_id) ==
1141 HPI_ADAPTER_FAMILY_ASI(0x5200))
1142 mask = 0x00000000L;
1136 break; 1143 break;
1137 case HPI_ADAPTER_FAMILY_ASI(0x8800): 1144 case HPI_ADAPTER_FAMILY_ASI(0x8800):
1138 /* ASI8800 has 16bit path to FPGA */ 1145 /* ASI8800 has 16bit path to FPGA */
diff --git a/sound/pci/asihpi/hpi_internal.h b/sound/pci/asihpi/hpi_internal.h
index fdd0ce02aa68..16f502d459de 100644
--- a/sound/pci/asihpi/hpi_internal.h
+++ b/sound/pci/asihpi/hpi_internal.h
@@ -104,9 +104,9 @@ typedef void hpi_handler_func(struct hpi_message *, struct hpi_response *);
104#define STR_ROLE_FIELD_MAX 255U 104#define STR_ROLE_FIELD_MAX 255U
105 105
106struct hpi_entity_str { 106struct hpi_entity_str {
107 uint16_t size; 107 u16 size;
108 uint8_t type; 108 u8 type;
109 uint8_t role; 109 u8 role;
110}; 110};
111 111
112#if defined(_MSC_VER) 112#if defined(_MSC_VER)
@@ -119,11 +119,11 @@ struct hpi_entity {
119#if ! defined(HPI_OS_DSP_C6000) || (defined(HPI_OS_DSP_C6000) && (__TI_COMPILER_VERSION__ > 6000008)) 119#if ! defined(HPI_OS_DSP_C6000) || (defined(HPI_OS_DSP_C6000) && (__TI_COMPILER_VERSION__ > 6000008))
120 /* DSP C6000 compiler v6.0.8 and lower 120 /* DSP C6000 compiler v6.0.8 and lower
121 do not support flexible array member */ 121 do not support flexible array member */
122 uint8_t value[]; 122 u8 value[];
123#else 123#else
124 /* NOTE! Using sizeof(struct hpi_entity) will give erroneous results */ 124 /* NOTE! Using sizeof(struct hpi_entity) will give erroneous results */
125#define HPI_INTERNAL_WARN_ABOUT_ENTITY_VALUE 125#define HPI_INTERNAL_WARN_ABOUT_ENTITY_VALUE
126 uint8_t value[1]; 126 u8 value[1];
127#endif 127#endif
128}; 128};
129 129
@@ -142,12 +142,15 @@ enum HPI_BUSES {
142/******************************************* CONTROL ATTRIBUTES ****/ 142/******************************************* CONTROL ATTRIBUTES ****/
143/* (in order of control type ID */ 143/* (in order of control type ID */
144 144
145 /* This allows for 255 control types, 256 unique attributes each */ 145/* This allows for 255 control types, 256 unique attributes each */
146#define HPI_CTL_ATTR(ctl, ai) (HPI_CONTROL_##ctl * 0x100 + ai) 146#define HPI_CTL_ATTR(ctl, ai) (HPI_CONTROL_##ctl * 0x100 + ai)
147 147
148/* Get the sub-index of the attribute for a control type */ 148/* Get the sub-index of the attribute for a control type */
149#define HPI_CTL_ATTR_INDEX(i) (i&0xff) 149#define HPI_CTL_ATTR_INDEX(i) (i&0xff)
150 150
151/* Extract the control from the control attribute */
152#define HPI_CTL_ATTR_CONTROL(i) (i>>8)
153
151/* Generic control attributes. */ 154/* Generic control attributes. */
152 155
153/** Enable a control. 156/** Enable a control.
@@ -311,8 +314,7 @@ Used for HPI_ChannelModeSet/Get()
311/* Microphone control attributes */ 314/* Microphone control attributes */
312#define HPI_MICROPHONE_PHANTOM_POWER HPI_CTL_ATTR(MICROPHONE, 1) 315#define HPI_MICROPHONE_PHANTOM_POWER HPI_CTL_ATTR(MICROPHONE, 1)
313 316
314/** Equalizer control attributes 317/** Equalizer control attributes */
315*/
316/** Used to get number of filters in an EQ. (Can't set) */ 318/** Used to get number of filters in an EQ. (Can't set) */
317#define HPI_EQUALIZER_NUM_FILTERS HPI_CTL_ATTR(EQUALIZER, 1) 319#define HPI_EQUALIZER_NUM_FILTERS HPI_CTL_ATTR(EQUALIZER, 1)
318/** Set/get the filter by type, freq, Q, gain */ 320/** Set/get the filter by type, freq, Q, gain */
@@ -320,13 +322,15 @@ Used for HPI_ChannelModeSet/Get()
320/** Get the biquad coefficients */ 322/** Get the biquad coefficients */
321#define HPI_EQUALIZER_COEFFICIENTS HPI_CTL_ATTR(EQUALIZER, 3) 323#define HPI_EQUALIZER_COEFFICIENTS HPI_CTL_ATTR(EQUALIZER, 3)
322 324
323#define HPI_COMPANDER_PARAMS HPI_CTL_ATTR(COMPANDER, 1) 325/* Note compander also uses HPI_GENERIC_ENABLE */
326#define HPI_COMPANDER_PARAMS HPI_CTL_ATTR(COMPANDER, 1)
327#define HPI_COMPANDER_MAKEUPGAIN HPI_CTL_ATTR(COMPANDER, 2)
328#define HPI_COMPANDER_THRESHOLD HPI_CTL_ATTR(COMPANDER, 3)
329#define HPI_COMPANDER_RATIO HPI_CTL_ATTR(COMPANDER, 4)
330#define HPI_COMPANDER_ATTACK HPI_CTL_ATTR(COMPANDER, 5)
331#define HPI_COMPANDER_DECAY HPI_CTL_ATTR(COMPANDER, 6)
324 332
325/* Cobranet control attributes. 333/* Cobranet control attributes. */
326 MUST be distinct from all other control attributes.
327 This is so that host side processing can easily identify a Cobranet control
328 and apply additional host side operations (like copying data) as required.
329*/
330#define HPI_COBRANET_SET HPI_CTL_ATTR(COBRANET, 1) 334#define HPI_COBRANET_SET HPI_CTL_ATTR(COBRANET, 1)
331#define HPI_COBRANET_GET HPI_CTL_ATTR(COBRANET, 2) 335#define HPI_COBRANET_GET HPI_CTL_ATTR(COBRANET, 2)
332#define HPI_COBRANET_SET_DATA HPI_CTL_ATTR(COBRANET, 3) 336#define HPI_COBRANET_SET_DATA HPI_CTL_ATTR(COBRANET, 3)
@@ -1512,11 +1516,11 @@ struct hpi_control_cache_single {
1512 struct hpi_control_cache_info i; 1516 struct hpi_control_cache_info i;
1513 union { 1517 union {
1514 struct { /* volume */ 1518 struct { /* volume */
1515 u16 an_log[2]; 1519 short an_log[2];
1516 } v; 1520 } v;
1517 struct { /* peak meter */ 1521 struct { /* peak meter */
1518 u16 an_log_peak[2]; 1522 short an_log_peak[2];
1519 u16 an_logRMS[2]; 1523 short an_logRMS[2];
1520 } p; 1524 } p;
1521 struct { /* channel mode */ 1525 struct { /* channel mode */
1522 u16 mode; 1526 u16 mode;
@@ -1526,7 +1530,7 @@ struct hpi_control_cache_single {
1526 u16 source_node_index; 1530 u16 source_node_index;
1527 } x; 1531 } x;
1528 struct { /* level/trim */ 1532 struct { /* level/trim */
1529 u16 an_log[2]; 1533 short an_log[2];
1530 } l; 1534 } l;
1531 struct { /* tuner - partial caching. 1535 struct { /* tuner - partial caching.
1532 some attributes go to the DSP. */ 1536 some attributes go to the DSP. */
diff --git a/sound/pci/asihpi/hpicmn.c b/sound/pci/asihpi/hpicmn.c
index fcd64539d9ef..dda4f1c6f658 100644
--- a/sound/pci/asihpi/hpicmn.c
+++ b/sound/pci/asihpi/hpicmn.c
@@ -353,7 +353,12 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
353 phr->u.c.param1 = pC->u.t.band; 353 phr->u.c.param1 = pC->u.t.band;
354 else if ((phm->u.c.attribute == HPI_TUNER_LEVEL) 354 else if ((phm->u.c.attribute == HPI_TUNER_LEVEL)
355 && (phm->u.c.param1 == HPI_TUNER_LEVEL_AVERAGE)) 355 && (phm->u.c.param1 == HPI_TUNER_LEVEL_AVERAGE))
356 phr->u.c.param1 = pC->u.t.level; 356 if (pC->u.t.level == HPI_ERROR_ILLEGAL_CACHE_VALUE) {
357 phr->u.c.param1 = 0;
358 phr->error =
359 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
360 } else
361 phr->u.c.param1 = pC->u.t.level;
357 else 362 else
358 found = 0; 363 found = 0;
359 break; 364 break;
@@ -397,7 +402,8 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
397 if (pC->u.clk.source_index == 402 if (pC->u.clk.source_index ==
398 HPI_ERROR_ILLEGAL_CACHE_VALUE) { 403 HPI_ERROR_ILLEGAL_CACHE_VALUE) {
399 phr->u.c.param1 = 0; 404 phr->u.c.param1 = 0;
400 phr->error = HPI_ERROR_INVALID_OPERATION; 405 phr->error =
406 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
401 } else 407 } else
402 phr->u.c.param1 = pC->u.clk.source_index; 408 phr->u.c.param1 = pC->u.clk.source_index;
403 } else if (phm->u.c.attribute == HPI_SAMPLECLOCK_SAMPLERATE) 409 } else if (phm->u.c.attribute == HPI_SAMPLECLOCK_SAMPLERATE)
diff --git a/sound/pci/asihpi/hpidebug.c b/sound/pci/asihpi/hpidebug.c
index 4cd85a401b34..949836ec913a 100644
--- a/sound/pci/asihpi/hpidebug.c
+++ b/sound/pci/asihpi/hpidebug.c
@@ -111,7 +111,7 @@ make_treenode_from_array(hpi_control_type_strings, HPI_CONTROL_TYPE_STRINGS)
111 &hpi_profile_strings,\ 111 &hpi_profile_strings,\
112 &hpi_control_strings, \ 112 &hpi_control_strings, \
113 &hpi_asyncevent_strings \ 113 &hpi_asyncevent_strings \
114}; 114}
115 make_treenode_from_array(hpi_function_strings, HPI_FUNCTION_STRINGS) 115 make_treenode_from_array(hpi_function_strings, HPI_FUNCTION_STRINGS)
116 116
117 compile_time_assert(HPI_OBJ_MAXINDEX == 14, obj_list_doesnt_match); 117 compile_time_assert(HPI_OBJ_MAXINDEX == 14, obj_list_doesnt_match);
diff --git a/sound/pci/asihpi/hpidebug.h b/sound/pci/asihpi/hpidebug.h
index 44dccadcc25b..a2f0952a99f0 100644
--- a/sound/pci/asihpi/hpidebug.h
+++ b/sound/pci/asihpi/hpidebug.h
@@ -356,7 +356,7 @@ compile_time_assert((HPI_CONTROL_LAST_INDEX + 1 == 27),
356 "HPI_SOURCENODE_ADAPTER" \ 356 "HPI_SOURCENODE_ADAPTER" \
357} 357}
358 358
359compile_time_assert((HPI_SOURCENODE_LAST_INDEX - HPI_SOURCENODE_BASE + 1) == 359compile_time_assert((HPI_SOURCENODE_LAST_INDEX - HPI_SOURCENODE_NONE + 1) ==
360 (12), sourcenode_strings_match_defs); 360 (12), sourcenode_strings_match_defs);
361 361
362#define HPI_DESTNODE_STRINGS \ 362#define HPI_DESTNODE_STRINGS \
@@ -370,7 +370,7 @@ compile_time_assert((HPI_SOURCENODE_LAST_INDEX - HPI_SOURCENODE_BASE + 1) ==
370 "HPI_DESTNODE_COBRANET", \ 370 "HPI_DESTNODE_COBRANET", \
371 "HPI_DESTNODE_ANALOG" \ 371 "HPI_DESTNODE_ANALOG" \
372} 372}
373compile_time_assert((HPI_DESTNODE_LAST_INDEX - HPI_DESTNODE_BASE + 1) == (8), 373compile_time_assert((HPI_DESTNODE_LAST_INDEX - HPI_DESTNODE_NONE + 1) == (8),
374 destnode_strings_match_defs); 374 destnode_strings_match_defs);
375 375
376#define HPI_CONTROL_CHANNEL_MODE_STRINGS \ 376#define HPI_CONTROL_CHANNEL_MODE_STRINGS \
diff --git a/sound/pci/asihpi/hpifunc.c b/sound/pci/asihpi/hpifunc.c
index 298eef3e20e9..1e92eb6dd509 100644
--- a/sound/pci/asihpi/hpifunc.c
+++ b/sound/pci/asihpi/hpifunc.c
@@ -96,8 +96,7 @@ void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR)
96 96
97static struct hpi_hsubsys gh_subsys; 97static struct hpi_hsubsys gh_subsys;
98 98
99struct hpi_hsubsys *hpi_subsys_create(void 99struct hpi_hsubsys *hpi_subsys_create(void)
100 )
101{ 100{
102 struct hpi_message hm; 101 struct hpi_message hm;
103 struct hpi_response hr; 102 struct hpi_response hr;
@@ -302,6 +301,7 @@ u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys,
302{ 301{
303 struct hpi_message hm; 302 struct hpi_message hm;
304 struct hpi_response hr; 303 struct hpi_response hr;
304
305 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 305 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
306 HPI_ADAPTER_SET_MODE); 306 HPI_ADAPTER_SET_MODE);
307 hm.adapter_index = adapter_index; 307 hm.adapter_index = adapter_index;
@@ -510,7 +510,7 @@ u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys,
510 hm.adapter_index = adapter_index; 510 hm.adapter_index = adapter_index;
511 hm.u.ax.debug_read.dsp_address = dsp_address; 511 hm.u.ax.debug_read.dsp_address = dsp_address;
512 512
513 if (*count_bytes > sizeof(hr.u.bytes)) 513 if (*count_bytes > (int)sizeof(hr.u.bytes))
514 *count_bytes = sizeof(hr.u.bytes); 514 *count_bytes = sizeof(hr.u.bytes);
515 515
516 hm.u.ax.debug_read.count_bytes = *count_bytes; 516 hm.u.ax.debug_read.count_bytes = *count_bytes;
@@ -976,6 +976,7 @@ u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys,
976{ 976{
977 struct hpi_message hm; 977 struct hpi_message hm;
978 struct hpi_response hr; 978 struct hpi_response hr;
979
979 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 980 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
980 HPI_OSTREAM_ANC_READ); 981 HPI_OSTREAM_ANC_READ);
981 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); 982 u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
@@ -1581,6 +1582,7 @@ u16 hpi_control_param_set(const struct hpi_hsubsys *ph_subsys,
1581{ 1582{
1582 struct hpi_message hm; 1583 struct hpi_message hm;
1583 struct hpi_response hr; 1584 struct hpi_response hr;
1585
1584 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1586 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1585 HPI_CONTROL_SET_STATE); 1587 HPI_CONTROL_SET_STATE);
1586 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1588 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -1591,6 +1593,22 @@ u16 hpi_control_param_set(const struct hpi_hsubsys *ph_subsys,
1591 return hr.error; 1593 return hr.error;
1592} 1594}
1593 1595
1596static u16 hpi_control_log_set2(u32 h_control, u16 attrib, short sv0,
1597 short sv1)
1598{
1599 struct hpi_message hm;
1600 struct hpi_response hr;
1601
1602 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1603 HPI_CONTROL_SET_STATE);
1604 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1605 hm.u.c.attribute = attrib;
1606 hm.u.c.an_log_value[0] = sv0;
1607 hm.u.c.an_log_value[1] = sv1;
1608 hpi_send_recv(&hm, &hr);
1609 return hr.error;
1610}
1611
1594static 1612static
1595u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys, 1613u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys,
1596 const u32 h_control, const u16 attrib, u32 param1, u32 param2, 1614 const u32 h_control, const u16 attrib, u32 param1, u32 param2,
@@ -1598,6 +1616,7 @@ u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys,
1598{ 1616{
1599 struct hpi_message hm; 1617 struct hpi_message hm;
1600 struct hpi_response hr; 1618 struct hpi_response hr;
1619
1601 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1620 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1602 HPI_CONTROL_GET_STATE); 1621 HPI_CONTROL_GET_STATE);
1603 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1622 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -1605,8 +1624,8 @@ u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys,
1605 hm.u.c.param1 = param1; 1624 hm.u.c.param1 = param1;
1606 hm.u.c.param2 = param2; 1625 hm.u.c.param2 = param2;
1607 hpi_send_recv(&hm, &hr); 1626 hpi_send_recv(&hm, &hr);
1608 if (pparam1) 1627
1609 *pparam1 = hr.u.c.param1; 1628 *pparam1 = hr.u.c.param1;
1610 if (pparam2) 1629 if (pparam2)
1611 *pparam2 = hr.u.c.param2; 1630 *pparam2 = hr.u.c.param2;
1612 1631
@@ -1617,10 +1636,23 @@ u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys,
1617 hpi_control_param_get(s, h, a, 0, 0, p1, NULL) 1636 hpi_control_param_get(s, h, a, 0, 0, p1, NULL)
1618#define hpi_control_param2_get(s, h, a, p1, p2) \ 1637#define hpi_control_param2_get(s, h, a, p1, p2) \
1619 hpi_control_param_get(s, h, a, 0, 0, p1, p2) 1638 hpi_control_param_get(s, h, a, 0, 0, p1, p2)
1620#define hpi_control_ex_param1_get(s, h, a, p1) \ 1639
1621 hpi_control_ex_param_get(s, h, a, 0, 0, p1, NULL) 1640static u16 hpi_control_log_get2(const struct hpi_hsubsys *ph_subsys,
1622#define hpi_control_ex_param2_get(s, h, a, p1, p2) \ 1641 u32 h_control, u16 attrib, short *sv0, short *sv1)
1623 hpi_control_ex_param_get(s, h, a, 0, 0, p1, p2) 1642{
1643 struct hpi_message hm;
1644 struct hpi_response hr;
1645 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1646 HPI_CONTROL_GET_STATE);
1647 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1648 hm.u.c.attribute = attrib;
1649
1650 hpi_send_recv(&hm, &hr);
1651 *sv0 = hr.u.c.an_log_value[0];
1652 if (sv1)
1653 *sv1 = hr.u.c.an_log_value[1];
1654 return hr.error;
1655}
1624 1656
1625static 1657static
1626u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys, 1658u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys,
@@ -1629,6 +1661,7 @@ u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys,
1629{ 1661{
1630 struct hpi_message hm; 1662 struct hpi_message hm;
1631 struct hpi_response hr; 1663 struct hpi_response hr;
1664
1632 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 1665 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1633 HPI_CONTROL_GET_INFO); 1666 HPI_CONTROL_GET_INFO);
1634 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1667 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -1643,9 +1676,8 @@ u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys,
1643 return hr.error; 1676 return hr.error;
1644} 1677}
1645 1678
1646static u16 hpi_control_get_string(const struct hpi_hsubsys *ph_subsys, 1679static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1647 const u32 h_control, const u16 attribute, char *psz_string, 1680 char *psz_string, const u32 string_length)
1648 const u32 string_length)
1649{ 1681{
1650 unsigned int sub_string_index = 0, j = 0; 1682 unsigned int sub_string_index = 0, j = 0;
1651 char c = 0; 1683 char c = 0;
@@ -1916,6 +1948,7 @@ u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1916{ 1948{
1917 struct hpi_message hm; 1949 struct hpi_message hm;
1918 struct hpi_response hr; 1950 struct hpi_response hr;
1951
1919 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1952 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
1920 HPI_CONTROL_SET_STATE); 1953 HPI_CONTROL_SET_STATE);
1921 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1954 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -1941,6 +1974,7 @@ u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1941{ 1974{
1942 struct hpi_message hm; 1975 struct hpi_message hm;
1943 struct hpi_response hr; 1976 struct hpi_response hr;
1977
1944 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1978 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
1945 HPI_CONTROL_GET_STATE); 1979 HPI_CONTROL_GET_STATE);
1946 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 1980 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -1980,6 +2014,7 @@ u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys,
1980{ 2014{
1981 struct hpi_message hm; 2015 struct hpi_message hm;
1982 struct hpi_response hr; 2016 struct hpi_response hr;
2017
1983 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 2018 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
1984 HPI_CONTROL_GET_STATE); 2019 HPI_CONTROL_GET_STATE);
1985 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2020 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -2006,6 +2041,7 @@ u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys,
2006 u32 byte_count; 2041 u32 byte_count;
2007 u32 iP; 2042 u32 iP;
2008 u16 error; 2043 u16 error;
2044
2009 error = hpi_cobranet_hmi_read(ph_subsys, h_control, 2045 error = hpi_cobranet_hmi_read(ph_subsys, h_control,
2010 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count, 2046 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count,
2011 (u8 *)&iP); 2047 (u8 *)&iP);
@@ -2082,6 +2118,7 @@ u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys,
2082 u32 byte_count; 2118 u32 byte_count;
2083 u16 error; 2119 u16 error;
2084 u32 mAC; 2120 u32 mAC;
2121
2085 error = hpi_cobranet_hmi_read(ph_subsys, h_control, 2122 error = hpi_cobranet_hmi_read(ph_subsys, h_control,
2086 HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count, 2123 HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count,
2087 (u8 *)&mAC); 2124 (u8 *)&mAC);
@@ -2103,53 +2140,111 @@ u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys,
2103 return error; 2140 return error;
2104} 2141}
2105 2142
2106u16 hpi_compander_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2143u16 hpi_compander_set_enable(const struct hpi_hsubsys *ph_subsys,
2107 u16 attack, u16 decay, short ratio100, short threshold0_01dB, 2144 u32 h_control, u32 enable)
2108 short makeup_gain0_01dB) 2145{
2146 return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE,
2147 enable, 0);
2148}
2149
2150u16 hpi_compander_get_enable(const struct hpi_hsubsys *ph_subsys,
2151 u32 h_control, u32 *enable)
2152{
2153 return hpi_control_param1_get(ph_subsys, h_control,
2154 HPI_GENERIC_ENABLE, enable);
2155}
2156
2157u16 hpi_compander_set_makeup_gain(const struct hpi_hsubsys *ph_subsys,
2158 u32 h_control, short makeup_gain0_01dB)
2159{
2160 return hpi_control_log_set2(h_control, HPI_COMPANDER_MAKEUPGAIN,
2161 makeup_gain0_01dB, 0);
2162}
2163
2164u16 hpi_compander_get_makeup_gain(const struct hpi_hsubsys *ph_subsys,
2165 u32 h_control, short *makeup_gain0_01dB)
2166{
2167 return hpi_control_log_get2(ph_subsys, h_control,
2168 HPI_COMPANDER_MAKEUPGAIN, makeup_gain0_01dB, NULL);
2169}
2170
2171u16 hpi_compander_set_attack_time_constant(const struct hpi_hsubsys
2172 *ph_subsys, u32 h_control, unsigned int index, u32 attack)
2173{
2174 return hpi_control_param_set(ph_subsys, h_control,
2175 HPI_COMPANDER_ATTACK, attack, index);
2176}
2177
2178u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys
2179 *ph_subsys, u32 h_control, unsigned int index, u32 *attack)
2180{
2181 return hpi_control_param_get(ph_subsys, h_control,
2182 HPI_COMPANDER_ATTACK, 0, index, attack, NULL);
2183}
2184
2185u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
2186 u32 h_control, unsigned int index, u32 decay)
2187{
2188 return hpi_control_param_set(ph_subsys, h_control,
2189 HPI_COMPANDER_DECAY, decay, index);
2190}
2191
2192u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
2193 u32 h_control, unsigned int index, u32 *decay)
2194{
2195 return hpi_control_param_get(ph_subsys, h_control,
2196 HPI_COMPANDER_DECAY, 0, index, decay, NULL);
2197
2198}
2199
2200u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys,
2201 u32 h_control, unsigned int index, short threshold0_01dB)
2109{ 2202{
2110 struct hpi_message hm; 2203 struct hpi_message hm;
2111 struct hpi_response hr; 2204 struct hpi_response hr;
2205
2112 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2206 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2113 HPI_CONTROL_SET_STATE); 2207 HPI_CONTROL_SET_STATE);
2114 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2208 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2115 2209 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
2116 hm.u.c.param1 = attack + ((u32)ratio100 << 16); 2210 hm.u.c.param2 = index;
2117 hm.u.c.param2 = (decay & 0xFFFFL);
2118 hm.u.c.an_log_value[0] = threshold0_01dB; 2211 hm.u.c.an_log_value[0] = threshold0_01dB;
2119 hm.u.c.an_log_value[1] = makeup_gain0_01dB;
2120 hm.u.c.attribute = HPI_COMPANDER_PARAMS;
2121 2212
2122 hpi_send_recv(&hm, &hr); 2213 hpi_send_recv(&hm, &hr);
2123 2214
2124 return hr.error; 2215 return hr.error;
2125} 2216}
2126 2217
2127u16 hpi_compander_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2218u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys,
2128 u16 *pw_attack, u16 *pw_decay, short *pw_ratio100, 2219 u32 h_control, unsigned int index, short *threshold0_01dB)
2129 short *pn_threshold0_01dB, short *pn_makeup_gain0_01dB)
2130{ 2220{
2131 struct hpi_message hm; 2221 struct hpi_message hm;
2132 struct hpi_response hr; 2222 struct hpi_response hr;
2223
2133 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2224 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2134 HPI_CONTROL_GET_STATE); 2225 HPI_CONTROL_GET_STATE);
2135 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2226 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2136 hm.u.c.attribute = HPI_COMPANDER_PARAMS; 2227 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
2228 hm.u.c.param2 = index;
2137 2229
2138 hpi_send_recv(&hm, &hr); 2230 hpi_send_recv(&hm, &hr);
2231 *threshold0_01dB = hr.u.c.an_log_value[0];
2139 2232
2140 if (pw_attack) 2233 return hr.error;
2141 *pw_attack = (short)(hr.u.c.param1 & 0xFFFF); 2234}
2142 if (pw_decay)
2143 *pw_decay = (short)(hr.u.c.param2 & 0xFFFF);
2144 if (pw_ratio100)
2145 *pw_ratio100 = (short)(hr.u.c.param1 >> 16);
2146 2235
2147 if (pn_threshold0_01dB) 2236u16 hpi_compander_set_ratio(const struct hpi_hsubsys *ph_subsys,
2148 *pn_threshold0_01dB = hr.u.c.an_log_value[0]; 2237 u32 h_control, u32 index, u32 ratio100)
2149 if (pn_makeup_gain0_01dB) 2238{
2150 *pn_makeup_gain0_01dB = hr.u.c.an_log_value[1]; 2239 return hpi_control_param_set(ph_subsys, h_control,
2240 HPI_COMPANDER_RATIO, ratio100, index);
2241}
2151 2242
2152 return hr.error; 2243u16 hpi_compander_get_ratio(const struct hpi_hsubsys *ph_subsys,
2244 u32 h_control, u32 index, u32 *ratio100)
2245{
2246 return hpi_control_param_get(ph_subsys, h_control,
2247 HPI_COMPANDER_RATIO, 0, index, ratio100, NULL);
2153} 2248}
2154 2249
2155u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2250u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
@@ -2157,6 +2252,7 @@ u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2157{ 2252{
2158 struct hpi_message hm; 2253 struct hpi_message hm;
2159 struct hpi_response hr; 2254 struct hpi_response hr;
2255
2160 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2256 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2161 HPI_CONTROL_GET_STATE); 2257 HPI_CONTROL_GET_STATE);
2162 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2258 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -2181,37 +2277,16 @@ u16 hpi_level_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2181 short an_gain0_01dB[HPI_MAX_CHANNELS] 2277 short an_gain0_01dB[HPI_MAX_CHANNELS]
2182 ) 2278 )
2183{ 2279{
2184 struct hpi_message hm; 2280 return hpi_control_log_set2(h_control, HPI_LEVEL_GAIN,
2185 struct hpi_response hr; 2281 an_gain0_01dB[0], an_gain0_01dB[1]);
2186
2187 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2188 HPI_CONTROL_SET_STATE);
2189 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2190 memcpy(hm.u.c.an_log_value, an_gain0_01dB,
2191 sizeof(short) * HPI_MAX_CHANNELS);
2192 hm.u.c.attribute = HPI_LEVEL_GAIN;
2193
2194 hpi_send_recv(&hm, &hr);
2195
2196 return hr.error;
2197} 2282}
2198 2283
2199u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 2284u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2200 short an_gain0_01dB[HPI_MAX_CHANNELS] 2285 short an_gain0_01dB[HPI_MAX_CHANNELS]
2201 ) 2286 )
2202{ 2287{
2203 struct hpi_message hm; 2288 return hpi_control_log_get2(ph_subsys, h_control, HPI_LEVEL_GAIN,
2204 struct hpi_response hr; 2289 &an_gain0_01dB[0], &an_gain0_01dB[1]);
2205 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2206 HPI_CONTROL_GET_STATE);
2207 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2208 hm.u.c.attribute = HPI_LEVEL_GAIN;
2209
2210 hpi_send_recv(&hm, &hr);
2211
2212 memcpy(an_gain0_01dB, hr.u.c.an_log_value,
2213 sizeof(short) * HPI_MAX_CHANNELS);
2214 return hr.error;
2215} 2290}
2216 2291
2217u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys, 2292u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys,
@@ -2413,6 +2488,7 @@ u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys,
2413{ 2488{
2414 struct hpi_message hm; 2489 struct hpi_message hm;
2415 struct hpi_response hr; 2490 struct hpi_response hr;
2491
2416 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2492 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2417 HPI_CONTROL_GET_STATE); 2493 HPI_CONTROL_GET_STATE);
2418 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2494 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -2439,6 +2515,7 @@ u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys,
2439{ 2515{
2440 struct hpi_message hm; 2516 struct hpi_message hm;
2441 struct hpi_response hr; 2517 struct hpi_response hr;
2518
2442 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2519 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2443 HPI_CONTROL_SET_STATE); 2520 HPI_CONTROL_SET_STATE);
2444 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2521 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -2460,6 +2537,7 @@ u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys,
2460{ 2537{
2461 struct hpi_message hm; 2538 struct hpi_message hm;
2462 struct hpi_response hr; 2539 struct hpi_response hr;
2540
2463 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2541 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2464 HPI_CONTROL_GET_STATE); 2542 HPI_CONTROL_GET_STATE);
2465 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2543 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -2623,8 +2701,8 @@ u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys,
2623u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys, 2701u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys,
2624 u32 h_control, u32 *state) 2702 u32 h_control, u32 *state)
2625{ 2703{
2626 return hpi_control_param_get(ph_subsys, h_control, 2704 return hpi_control_param1_get(ph_subsys, h_control,
2627 HPI_TONEDETECTOR_STATE, 0, 0, (u32 *)state, NULL); 2705 HPI_TONEDETECTOR_STATE, state);
2628} 2706}
2629 2707
2630u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys, 2708u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
@@ -2637,8 +2715,8 @@ u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
2637u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 2715u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys,
2638 u32 h_control, u32 *enable) 2716 u32 h_control, u32 *enable)
2639{ 2717{
2640 return hpi_control_param_get(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2718 return hpi_control_param1_get(ph_subsys, h_control,
2641 0, 0, (u32 *)enable, NULL); 2719 HPI_GENERIC_ENABLE, enable);
2642} 2720}
2643 2721
2644u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, 2722u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys,
@@ -2651,8 +2729,8 @@ u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys,
2651u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, 2729u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys,
2652 u32 h_control, u32 *event_enable) 2730 u32 h_control, u32 *event_enable)
2653{ 2731{
2654 return hpi_control_param_get(ph_subsys, h_control, 2732 return hpi_control_param1_get(ph_subsys, h_control,
2655 HPI_GENERIC_EVENT_ENABLE, 0, 0, (u32 *)event_enable, NULL); 2733 HPI_GENERIC_EVENT_ENABLE, event_enable);
2656} 2734}
2657 2735
2658u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, 2736u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys,
@@ -2665,15 +2743,15 @@ u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys,
2665u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, 2743u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys,
2666 u32 h_control, int *threshold) 2744 u32 h_control, int *threshold)
2667{ 2745{
2668 return hpi_control_param_get(ph_subsys, h_control, 2746 return hpi_control_param1_get(ph_subsys, h_control,
2669 HPI_TONEDETECTOR_THRESHOLD, 0, 0, (u32 *)threshold, NULL); 2747 HPI_TONEDETECTOR_THRESHOLD, (u32 *)threshold);
2670} 2748}
2671 2749
2672u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys, 2750u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys,
2673 u32 h_control, u32 *state) 2751 u32 h_control, u32 *state)
2674{ 2752{
2675 return hpi_control_param_get(ph_subsys, h_control, 2753 return hpi_control_param1_get(ph_subsys, h_control,
2676 HPI_SILENCEDETECTOR_STATE, 0, 0, (u32 *)state, NULL); 2754 HPI_SILENCEDETECTOR_STATE, state);
2677} 2755}
2678 2756
2679u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys, 2757u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
@@ -2686,50 +2764,50 @@ u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
2686u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 2764u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys,
2687 u32 h_control, u32 *enable) 2765 u32 h_control, u32 *enable)
2688{ 2766{
2689 return hpi_control_param_get(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2767 return hpi_control_param1_get(ph_subsys, h_control,
2690 0, 0, (u32 *)enable, NULL); 2768 HPI_GENERIC_ENABLE, enable);
2691} 2769}
2692 2770
2693u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, 2771u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys,
2694 u32 h_control, u32 event_enable) 2772 u32 h_control, u32 event_enable)
2695{ 2773{
2696 return hpi_control_param_set(ph_subsys, h_control, 2774 return hpi_control_param_set(ph_subsys, h_control,
2697 HPI_GENERIC_EVENT_ENABLE, (u32)event_enable, 0); 2775 HPI_GENERIC_EVENT_ENABLE, event_enable, 0);
2698} 2776}
2699 2777
2700u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, 2778u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys,
2701 u32 h_control, u32 *event_enable) 2779 u32 h_control, u32 *event_enable)
2702{ 2780{
2703 return hpi_control_param_get(ph_subsys, h_control, 2781 return hpi_control_param1_get(ph_subsys, h_control,
2704 HPI_GENERIC_EVENT_ENABLE, 0, 0, (u32 *)event_enable, NULL); 2782 HPI_GENERIC_EVENT_ENABLE, event_enable);
2705} 2783}
2706 2784
2707u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys, 2785u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys,
2708 u32 h_control, u32 delay) 2786 u32 h_control, u32 delay)
2709{ 2787{
2710 return hpi_control_param_set(ph_subsys, h_control, 2788 return hpi_control_param_set(ph_subsys, h_control,
2711 HPI_SILENCEDETECTOR_DELAY, (u32)delay, 0); 2789 HPI_SILENCEDETECTOR_DELAY, delay, 0);
2712} 2790}
2713 2791
2714u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys, 2792u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys,
2715 u32 h_control, u32 *delay) 2793 u32 h_control, u32 *delay)
2716{ 2794{
2717 return hpi_control_param_get(ph_subsys, h_control, 2795 return hpi_control_param1_get(ph_subsys, h_control,
2718 HPI_SILENCEDETECTOR_DELAY, 0, 0, (u32 *)delay, NULL); 2796 HPI_SILENCEDETECTOR_DELAY, delay);
2719} 2797}
2720 2798
2721u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, 2799u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys,
2722 u32 h_control, int threshold) 2800 u32 h_control, int threshold)
2723{ 2801{
2724 return hpi_control_param_set(ph_subsys, h_control, 2802 return hpi_control_param_set(ph_subsys, h_control,
2725 HPI_SILENCEDETECTOR_THRESHOLD, (u32)threshold, 0); 2803 HPI_SILENCEDETECTOR_THRESHOLD, threshold, 0);
2726} 2804}
2727 2805
2728u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, 2806u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys,
2729 u32 h_control, int *threshold) 2807 u32 h_control, int *threshold)
2730{ 2808{
2731 return hpi_control_param_get(ph_subsys, h_control, 2809 return hpi_control_param1_get(ph_subsys, h_control,
2732 HPI_SILENCEDETECTOR_THRESHOLD, 0, 0, (u32 *)threshold, NULL); 2810 HPI_SILENCEDETECTOR_THRESHOLD, (u32 *)threshold);
2733} 2811}
2734 2812
2735u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys, 2813u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys,
@@ -2822,6 +2900,7 @@ u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2822{ 2900{
2823 struct hpi_message hm; 2901 struct hpi_message hm;
2824 struct hpi_response hr; 2902 struct hpi_response hr;
2903
2825 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2904 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2826 HPI_CONTROL_GET_STATE); 2905 HPI_CONTROL_GET_STATE);
2827 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2906 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -2838,6 +2917,7 @@ u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys,
2838{ 2917{
2839 struct hpi_message hm; 2918 struct hpi_message hm;
2840 struct hpi_response hr; 2919 struct hpi_response hr;
2920
2841 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2921 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2842 HPI_CONTROL_GET_STATE); 2922 HPI_CONTROL_GET_STATE);
2843 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2923 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -2894,14 +2974,14 @@ u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2894u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys, 2974u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys,
2895 u32 h_control, char *psz_dsp_version, const u32 string_size) 2975 u32 h_control, char *psz_dsp_version, const u32 string_size)
2896{ 2976{
2897 return hpi_control_get_string(ph_subsys, h_control, 2977 return hpi_control_get_string(h_control,
2898 HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size); 2978 HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size);
2899} 2979}
2900 2980
2901u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys, 2981u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys,
2902 u32 h_control, char *psz_sdk_version, const u32 string_size) 2982 u32 h_control, char *psz_sdk_version, const u32 string_size)
2903{ 2983{
2904 return hpi_control_get_string(ph_subsys, h_control, 2984 return hpi_control_get_string(h_control,
2905 HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size); 2985 HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size);
2906} 2986}
2907 2987
@@ -2942,15 +3022,15 @@ u16 hpi_tuner_get_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2942u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys, 3022u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys,
2943 u32 h_control, u32 *pquality) 3023 u32 h_control, u32 *pquality)
2944{ 3024{
2945 return hpi_control_param_get(ph_subsys, h_control, 3025 return hpi_control_param1_get(ph_subsys, h_control,
2946 HPI_TUNER_HDRADIO_SIGNAL_QUALITY, 0, 0, pquality, NULL); 3026 HPI_TUNER_HDRADIO_SIGNAL_QUALITY, pquality);
2947} 3027}
2948 3028
2949u16 hpi_tuner_get_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys, 3029u16 hpi_tuner_get_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys,
2950 u32 h_control, u32 *pblend) 3030 u32 h_control, u32 *pblend)
2951{ 3031{
2952 return hpi_control_param_get(ph_subsys, h_control, 3032 return hpi_control_param1_get(ph_subsys, h_control,
2953 HPI_TUNER_HDRADIO_BLEND, 0, 0, pblend, NULL); 3033 HPI_TUNER_HDRADIO_BLEND, pblend);
2954} 3034}
2955 3035
2956u16 hpi_tuner_set_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys, 3036u16 hpi_tuner_set_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys,
@@ -2965,6 +3045,7 @@ u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2965{ 3045{
2966 struct hpi_message hm; 3046 struct hpi_message hm;
2967 struct hpi_response hr; 3047 struct hpi_response hr;
3048
2968 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3049 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2969 HPI_CONTROL_GET_STATE); 3050 HPI_CONTROL_GET_STATE);
2970 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3051 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -2981,43 +3062,43 @@ u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2981u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys, 3062u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys,
2982 u32 h_control, char *psz_string, const u32 data_length) 3063 u32 h_control, char *psz_string, const u32 data_length)
2983{ 3064{
2984 return hpi_control_get_string(ph_subsys, h_control, 3065 return hpi_control_get_string(h_control, HPI_PAD_CHANNEL_NAME,
2985 HPI_PAD_CHANNEL_NAME, psz_string, data_length); 3066 psz_string, data_length);
2986} 3067}
2987 3068
2988u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3069u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2989 char *psz_string, const u32 data_length) 3070 char *psz_string, const u32 data_length)
2990{ 3071{
2991 return hpi_control_get_string(ph_subsys, h_control, HPI_PAD_ARTIST, 3072 return hpi_control_get_string(h_control, HPI_PAD_ARTIST, psz_string,
2992 psz_string, data_length); 3073 data_length);
2993} 3074}
2994 3075
2995u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3076u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2996 char *psz_string, const u32 data_length) 3077 char *psz_string, const u32 data_length)
2997{ 3078{
2998 return hpi_control_get_string(ph_subsys, h_control, HPI_PAD_TITLE, 3079 return hpi_control_get_string(h_control, HPI_PAD_TITLE, psz_string,
2999 psz_string, data_length); 3080 data_length);
3000} 3081}
3001 3082
3002u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3083u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3003 char *psz_string, const u32 data_length) 3084 char *psz_string, const u32 data_length)
3004{ 3085{
3005 return hpi_control_get_string(ph_subsys, h_control, HPI_PAD_COMMENT, 3086 return hpi_control_get_string(h_control, HPI_PAD_COMMENT, psz_string,
3006 psz_string, data_length); 3087 data_length);
3007} 3088}
3008 3089
3009u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys, 3090u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys,
3010 u32 h_control, u32 *ppTY) 3091 u32 h_control, u32 *ppTY)
3011{ 3092{
3012 return hpi_control_param_get(ph_subsys, h_control, 3093 return hpi_control_param1_get(ph_subsys, h_control,
3013 HPI_PAD_PROGRAM_TYPE, 0, 0, ppTY, NULL); 3094 HPI_PAD_PROGRAM_TYPE, ppTY);
3014} 3095}
3015 3096
3016u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3097u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3017 u32 *ppI) 3098 u32 *ppI)
3018{ 3099{
3019 return hpi_control_param_get(ph_subsys, h_control, HPI_PAD_PROGRAM_ID, 3100 return hpi_control_param1_get(ph_subsys, h_control,
3020 0, 0, ppI, NULL); 3101 HPI_PAD_PROGRAM_ID, ppI);
3021} 3102}
3022 3103
3023u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys, 3104u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys,
@@ -3031,36 +3112,16 @@ u16 hpi_volume_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3031 short an_log_gain[HPI_MAX_CHANNELS] 3112 short an_log_gain[HPI_MAX_CHANNELS]
3032 ) 3113 )
3033{ 3114{
3034 struct hpi_message hm; 3115 return hpi_control_log_set2(h_control, HPI_VOLUME_GAIN,
3035 struct hpi_response hr; 3116 an_log_gain[0], an_log_gain[1]);
3036 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3037 HPI_CONTROL_SET_STATE);
3038 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
3039 memcpy(hm.u.c.an_log_value, an_log_gain,
3040 sizeof(short) * HPI_MAX_CHANNELS);
3041 hm.u.c.attribute = HPI_VOLUME_GAIN;
3042
3043 hpi_send_recv(&hm, &hr);
3044
3045 return hr.error;
3046} 3117}
3047 3118
3048u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3119u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3049 short an_log_gain[HPI_MAX_CHANNELS] 3120 short an_log_gain[HPI_MAX_CHANNELS]
3050 ) 3121 )
3051{ 3122{
3052 struct hpi_message hm; 3123 return hpi_control_log_get2(ph_subsys, h_control, HPI_VOLUME_GAIN,
3053 struct hpi_response hr; 3124 &an_log_gain[0], &an_log_gain[1]);
3054 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3055 HPI_CONTROL_GET_STATE);
3056 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
3057 hm.u.c.attribute = HPI_VOLUME_GAIN;
3058
3059 hpi_send_recv(&hm, &hr);
3060
3061 memcpy(an_log_gain, hr.u.c.an_log_value,
3062 sizeof(short) * HPI_MAX_CHANNELS);
3063 return hr.error;
3064} 3125}
3065 3126
3066u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, 3127u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
@@ -3068,6 +3129,7 @@ u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3068{ 3129{
3069 struct hpi_message hm; 3130 struct hpi_message hm;
3070 struct hpi_response hr; 3131 struct hpi_response hr;
3132
3071 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3133 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3072 HPI_CONTROL_GET_STATE); 3134 HPI_CONTROL_GET_STATE);
3073 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3135 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -3094,6 +3156,7 @@ u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys,
3094{ 3156{
3095 struct hpi_message hm; 3157 struct hpi_message hm;
3096 struct hpi_response hr; 3158 struct hpi_response hr;
3159
3097 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 3160 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
3098 HPI_CONTROL_SET_STATE); 3161 HPI_CONTROL_SET_STATE);
3099 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 3162 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
@@ -3170,43 +3233,42 @@ static size_t entity_type_to_size[LAST_ENTITY_TYPE] = {
3170 6 * sizeof(char), 3233 6 * sizeof(char),
3171}; 3234};
3172 3235
3173inline size_t hpi_entity_size(struct hpi_entity *entity_ptr) 3236static inline size_t hpi_entity_size(struct hpi_entity *entity_ptr)
3174{ 3237{
3175 return entity_ptr->header.size; 3238 return entity_ptr->header.size;
3176} 3239}
3177 3240
3178inline size_t hpi_entity_header_size(struct hpi_entity *entity_ptr) 3241static inline size_t hpi_entity_header_size(struct hpi_entity *entity_ptr)
3179{ 3242{
3180 return sizeof(entity_ptr->header); 3243 return sizeof(entity_ptr->header);
3181} 3244}
3182 3245
3183inline size_t hpi_entity_value_size(struct hpi_entity *entity_ptr) 3246static inline size_t hpi_entity_value_size(struct hpi_entity *entity_ptr)
3184{ 3247{
3185 return hpi_entity_size(entity_ptr) - 3248 return hpi_entity_size(entity_ptr) -
3186 hpi_entity_header_size(entity_ptr); 3249 hpi_entity_header_size(entity_ptr);
3187} 3250}
3188 3251
3189inline size_t hpi_entity_item_count(struct hpi_entity *entity_ptr) 3252static inline size_t hpi_entity_item_count(struct hpi_entity *entity_ptr)
3190{ 3253{
3191 return hpi_entity_value_size(entity_ptr) / 3254 return hpi_entity_value_size(entity_ptr) /
3192 entity_type_to_size[entity_ptr->header.type]; 3255 entity_type_to_size[entity_ptr->header.type];
3193} 3256}
3194 3257
3195inline struct hpi_entity *hpi_entity_ptr_to_next(struct hpi_entity 3258static inline struct hpi_entity *hpi_entity_ptr_to_next(struct hpi_entity
3196 *entity_ptr) 3259 *entity_ptr)
3197{ 3260{
3198 return (void *)(((uint8_t *) entity_ptr) + 3261 return (void *)(((u8 *)entity_ptr) + hpi_entity_size(entity_ptr));
3199 hpi_entity_size(entity_ptr));
3200} 3262}
3201 3263
3202inline u16 hpi_entity_check_type(const enum e_entity_type t) 3264static inline u16 hpi_entity_check_type(const enum e_entity_type t)
3203{ 3265{
3204 if (t >= 0 && t < STR_TYPE_FIELD_MAX) 3266 if (t >= 0 && t < STR_TYPE_FIELD_MAX)
3205 return 0; 3267 return 0;
3206 return HPI_ERROR_ENTITY_TYPE_INVALID; 3268 return HPI_ERROR_ENTITY_TYPE_INVALID;
3207} 3269}
3208 3270
3209inline u16 hpi_entity_check_role(const enum e_entity_role r) 3271static inline u16 hpi_entity_check_role(const enum e_entity_role r)
3210{ 3272{
3211 if (r >= 0 && r < STR_ROLE_FIELD_MAX) 3273 if (r >= 0 && r < STR_ROLE_FIELD_MAX)
3212 return 0; 3274 return 0;
@@ -3624,6 +3686,7 @@ u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async,
3624 u16 maximum_events, struct hpi_async_event *p_events, 3686 u16 maximum_events, struct hpi_async_event *p_events,
3625 u16 *pw_number_returned) 3687 u16 *pw_number_returned)
3626{ 3688{
3689
3627 return 0; 3690 return 0;
3628} 3691}
3629 3692
diff --git a/sound/pci/asihpi/hpimsgx.c b/sound/pci/asihpi/hpimsgx.c
index 2ee90dc3d897..f01ab964f602 100644
--- a/sound/pci/asihpi/hpimsgx.c
+++ b/sound/pci/asihpi/hpimsgx.c
@@ -741,7 +741,7 @@ static void HPIMSGX__reset(u16 adapter_index)
741 hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM, 741 hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM,
742 HPI_SUBSYS_FIND_ADAPTERS, 0); 742 HPI_SUBSYS_FIND_ADAPTERS, 0);
743 memcpy(&gRESP_HPI_SUBSYS_FIND_ADAPTERS, &hr, 743 memcpy(&gRESP_HPI_SUBSYS_FIND_ADAPTERS, &hr,
744 sizeof(&gRESP_HPI_SUBSYS_FIND_ADAPTERS)); 744 sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS));
745 745
746 for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) { 746 for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) {
747 747
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index 7396ac54e99f..62895a719fcb 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -121,11 +121,17 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
121 phpi_ioctl_data = (struct hpi_ioctl_linux __user *)arg; 121 phpi_ioctl_data = (struct hpi_ioctl_linux __user *)arg;
122 122
123 /* Read the message and response pointers from user space. */ 123 /* Read the message and response pointers from user space. */
124 get_user(puhm, &phpi_ioctl_data->phm); 124 if (get_user(puhm, &phpi_ioctl_data->phm) ||
125 get_user(puhr, &phpi_ioctl_data->phr); 125 get_user(puhr, &phpi_ioctl_data->phr)) {
126 err = -EFAULT;
127 goto out;
128 }
126 129
127 /* Now read the message size and data from user space. */ 130 /* Now read the message size and data from user space. */
128 get_user(hm->h.size, (u16 __user *)puhm); 131 if (get_user(hm->h.size, (u16 __user *)puhm)) {
132 err = -EFAULT;
133 goto out;
134 }
129 if (hm->h.size > sizeof(*hm)) 135 if (hm->h.size > sizeof(*hm))
130 hm->h.size = sizeof(*hm); 136 hm->h.size = sizeof(*hm);
131 137
@@ -138,7 +144,10 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
138 goto out; 144 goto out;
139 } 145 }
140 146
141 get_user(res_max_size, (u16 __user *)puhr); 147 if (get_user(res_max_size, (u16 __user *)puhr)) {
148 err = -EFAULT;
149 goto out;
150 }
142 /* printk(KERN_INFO "user response size %d\n", res_max_size); */ 151 /* printk(KERN_INFO "user response size %d\n", res_max_size); */
143 if (res_max_size < sizeof(struct hpi_response_header)) { 152 if (res_max_size < sizeof(struct hpi_response_header)) {
144 HPI_DEBUG_LOG(WARNING, "small res size %d\n", res_max_size); 153 HPI_DEBUG_LOG(WARNING, "small res size %d\n", res_max_size);
@@ -464,9 +473,7 @@ void __init asihpi_init(void)
464 473
465 memset(adapters, 0, sizeof(adapters)); 474 memset(adapters, 0, sizeof(adapters));
466 475
467 printk(KERN_INFO "ASIHPI driver %d.%02d.%02d\n", 476 printk(KERN_INFO "ASIHPI driver " HPI_VER_STRING "\n");
468 HPI_VER_MAJOR(HPI_VER), HPI_VER_MINOR(HPI_VER),
469 HPI_VER_RELEASE(HPI_VER));
470 477
471 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 478 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
472 HPI_SUBSYS_DRIVER_LOAD); 479 HPI_SUBSYS_DRIVER_LOAD);
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 668a5ec04499..20763dd03fa0 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -2250,6 +2250,8 @@ static int snd_echo_resume(struct pci_dev *pci)
2250 DE_INIT(("resume start\n")); 2250 DE_INIT(("resume start\n"));
2251 pci_restore_state(pci); 2251 pci_restore_state(pci);
2252 commpage_bak = kmalloc(sizeof(struct echoaudio), GFP_KERNEL); 2252 commpage_bak = kmalloc(sizeof(struct echoaudio), GFP_KERNEL);
2253 if (commpage_bak == NULL)
2254 return -ENOMEM;
2253 commpage = chip->comm_page; 2255 commpage = chip->comm_page;
2254 memcpy(commpage_bak, commpage, sizeof(struct comm_page)); 2256 memcpy(commpage_bak, commpage, sizeof(struct comm_page));
2255 2257
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 05e8995f9aec..a7802b99436c 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -733,15 +733,17 @@ static void /*__devinit*/ setup_fg_nodes(struct hda_codec *codec)
733 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid); 733 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid);
734 for (i = 0; i < total_nodes; i++, nid++) { 734 for (i = 0; i < total_nodes; i++, nid++) {
735 function_id = snd_hda_param_read(codec, nid, 735 function_id = snd_hda_param_read(codec, nid,
736 AC_PAR_FUNCTION_TYPE) & 0xff; 736 AC_PAR_FUNCTION_TYPE);
737 switch (function_id) { 737 switch (function_id & 0xff) {
738 case AC_GRP_AUDIO_FUNCTION: 738 case AC_GRP_AUDIO_FUNCTION:
739 codec->afg = nid; 739 codec->afg = nid;
740 codec->function_id = function_id; 740 codec->afg_function_id = function_id & 0xff;
741 codec->afg_unsol = (function_id >> 8) & 1;
741 break; 742 break;
742 case AC_GRP_MODEM_FUNCTION: 743 case AC_GRP_MODEM_FUNCTION:
743 codec->mfg = nid; 744 codec->mfg = nid;
744 codec->function_id = function_id; 745 codec->mfg_function_id = function_id & 0xff;
746 codec->mfg_unsol = (function_id >> 8) & 1;
745 break; 747 break;
746 default: 748 default:
747 break; 749 break;
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 46f75bccf0d3..0328cf55cdba 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -784,7 +784,10 @@ struct hda_codec {
784 hda_nid_t mfg; /* MFG node id */ 784 hda_nid_t mfg; /* MFG node id */
785 785
786 /* ids */ 786 /* ids */
787 u32 function_id; 787 u8 afg_function_id;
788 u8 mfg_function_id;
789 u8 afg_unsol;
790 u8 mfg_unsol;
788 u32 vendor_id; 791 u32 vendor_id;
789 u32 subsystem_id; 792 u32 subsystem_id;
790 u32 revision_id; 793 u32 revision_id;
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index f97d35de66c4..f025200f2a62 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -557,7 +557,12 @@ static void print_codec_info(struct snd_info_entry *entry,
557 else 557 else
558 snd_iprintf(buffer, "Not Set\n"); 558 snd_iprintf(buffer, "Not Set\n");
559 snd_iprintf(buffer, "Address: %d\n", codec->addr); 559 snd_iprintf(buffer, "Address: %d\n", codec->addr);
560 snd_iprintf(buffer, "Function Id: 0x%x\n", codec->function_id); 560 if (codec->afg)
561 snd_iprintf(buffer, "AFG Function Id: 0x%x (unsol %u)\n",
562 codec->afg_function_id, codec->afg_unsol);
563 if (codec->mfg)
564 snd_iprintf(buffer, "MFG Function Id: 0x%x (unsol %u)\n",
565 codec->mfg_function_id, codec->mfg_unsol);
561 snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id); 566 snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id);
562 snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id); 567 snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id);
563 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id); 568 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index ad4462677615..f64fb7d988cb 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -97,6 +97,7 @@
97#include <linux/gameport.h> 97#include <linux/gameport.h>
98#include <linux/device.h> 98#include <linux/device.h>
99#include <linux/firmware.h> 99#include <linux/firmware.h>
100#include <linux/kernel.h>
100#include <asm/io.h> 101#include <asm/io.h>
101#include <sound/core.h> 102#include <sound/core.h>
102#include <sound/info.h> 103#include <sound/info.h>
@@ -667,13 +668,12 @@ static u32 atoh(const unsigned char *in, unsigned int len)
667 unsigned char c; 668 unsigned char c;
668 669
669 while (len) { 670 while (len) {
671 int value;
672
670 c = in[len - 1]; 673 c = in[len - 1];
671 if ((c >= '0') && (c <= '9')) 674 value = hex_to_bin(c);
672 sum += mult * (c - '0'); 675 if (value >= 0)
673 else if ((c >= 'A') && (c <= 'F')) 676 sum += mult * value;
674 sum += mult * (c - ('A' - 10));
675 else if ((c >= 'a') && (c <= 'f'))
676 sum += mult * (c - ('a' - 10));
677 mult *= 16; 677 mult *= 16;
678 --len; 678 --len;
679 } 679 }
@@ -1615,7 +1615,10 @@ static int snd_riptide_playback_open(struct snd_pcm_substream *substream)
1615 1615
1616 chip->playback_substream[sub_num] = substream; 1616 chip->playback_substream[sub_num] = substream;
1617 runtime->hw = snd_riptide_playback; 1617 runtime->hw = snd_riptide_playback;
1618
1618 data = kzalloc(sizeof(struct pcmhw), GFP_KERNEL); 1619 data = kzalloc(sizeof(struct pcmhw), GFP_KERNEL);
1620 if (data == NULL)
1621 return -ENOMEM;
1619 data->paths = lbus_play_paths[sub_num]; 1622 data->paths = lbus_play_paths[sub_num];
1620 data->id = play_ids[sub_num]; 1623 data->id = play_ids[sub_num];
1621 data->source = play_sources[sub_num]; 1624 data->source = play_sources[sub_num];
@@ -1635,7 +1638,10 @@ static int snd_riptide_capture_open(struct snd_pcm_substream *substream)
1635 1638
1636 chip->capture_substream = substream; 1639 chip->capture_substream = substream;
1637 runtime->hw = snd_riptide_capture; 1640 runtime->hw = snd_riptide_capture;
1641
1638 data = kzalloc(sizeof(struct pcmhw), GFP_KERNEL); 1642 data = kzalloc(sizeof(struct pcmhw), GFP_KERNEL);
1643 if (data == NULL)
1644 return -ENOMEM;
1639 data->paths = lbus_rec_path; 1645 data->paths = lbus_rec_path;
1640 data->id = PADC; 1646 data->id = PADC;
1641 data->source = ACLNK2PADC; 1647 data->source = ACLNK2PADC;
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index 9cc1b5aa0148..1b8f6742b5fa 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -264,11 +264,13 @@ static void sis_update_voice(struct voice *voice)
264 * if using small periods. 264 * if using small periods.
265 * 265 *
266 * If we're less than 9 samples behind, we're on target. 266 * If we're less than 9 samples behind, we're on target.
267 * Otherwise, shorten the next vperiod by the amount we've
268 * been delayed.
267 */ 269 */
268 if (sync > -9) 270 if (sync > -9)
269 voice->vperiod = voice->sync_period_size + 1; 271 voice->vperiod = voice->sync_period_size + 1;
270 else 272 else
271 voice->vperiod = voice->sync_period_size - 4; 273 voice->vperiod = voice->sync_period_size + sync + 10;
272 274
273 if (voice->vperiod < voice->buffer_size) { 275 if (voice->vperiod < voice->buffer_size) {
274 sis_update_sso(voice, voice->vperiod); 276 sis_update_sso(voice, voice->vperiod);
@@ -736,7 +738,7 @@ static void sis_prepare_timing_voice(struct voice *voice,
736 period_size = buffer_size; 738 period_size = buffer_size;
737 739
738 /* Initially, we want to interrupt just a bit behind the end of 740 /* Initially, we want to interrupt just a bit behind the end of
739 * the period we're clocking out. 10 samples seems to give a good 741 * the period we're clocking out. 12 samples seems to give a good
740 * delay. 742 * delay.
741 * 743 *
742 * We want to spread our interrupts throughout the virtual period, 744 * We want to spread our interrupts throughout the virtual period,
@@ -747,7 +749,7 @@ static void sis_prepare_timing_voice(struct voice *voice,
747 * 749 *
748 * This is all moot if we don't need to use virtual periods. 750 * This is all moot if we don't need to use virtual periods.
749 */ 751 */
750 vperiod = runtime->period_size + 10; 752 vperiod = runtime->period_size + 12;
751 if (vperiod > period_size) { 753 if (vperiod > period_size) {
752 u16 tail = vperiod % period_size; 754 u16 tail = vperiod % period_size;
753 u16 quarter_period = period_size / 4; 755 u16 quarter_period = period_size / 4;
@@ -776,7 +778,7 @@ static void sis_prepare_timing_voice(struct voice *voice,
776 */ 778 */
777 timing->flags |= VOICE_SYNC_TIMING; 779 timing->flags |= VOICE_SYNC_TIMING;
778 timing->sync_base = voice->ctrl_base; 780 timing->sync_base = voice->ctrl_base;
779 timing->sync_cso = runtime->period_size - 1; 781 timing->sync_cso = runtime->period_size;
780 timing->sync_period_size = runtime->period_size; 782 timing->sync_period_size = runtime->period_size;
781 timing->sync_buffer_size = runtime->buffer_size; 783 timing->sync_buffer_size = runtime->buffer_size;
782 timing->period_size = period_size; 784 timing->period_size = period_size;
@@ -1047,7 +1049,7 @@ static int sis_chip_free(struct sis7019 *sis)
1047 /* Reset the chip, and disable all interrputs. 1049 /* Reset the chip, and disable all interrputs.
1048 */ 1050 */
1049 outl(SIS_GCR_SOFTWARE_RESET, sis->ioport + SIS_GCR); 1051 outl(SIS_GCR_SOFTWARE_RESET, sis->ioport + SIS_GCR);
1050 udelay(10); 1052 udelay(25);
1051 outl(0, sis->ioport + SIS_GCR); 1053 outl(0, sis->ioport + SIS_GCR);
1052 outl(0, sis->ioport + SIS_GIER); 1054 outl(0, sis->ioport + SIS_GIER);
1053 1055
@@ -1083,7 +1085,7 @@ static int sis_chip_init(struct sis7019 *sis)
1083 /* Reset the audio controller 1085 /* Reset the audio controller
1084 */ 1086 */
1085 outl(SIS_GCR_SOFTWARE_RESET, io + SIS_GCR); 1087 outl(SIS_GCR_SOFTWARE_RESET, io + SIS_GCR);
1086 udelay(10); 1088 udelay(25);
1087 outl(0, io + SIS_GCR); 1089 outl(0, io + SIS_GCR);
1088 1090
1089 /* Get the AC-link semaphore, and reset the codecs 1091 /* Get the AC-link semaphore, and reset the codecs
@@ -1096,7 +1098,7 @@ static int sis_chip_init(struct sis7019 *sis)
1096 return -EIO; 1098 return -EIO;
1097 1099
1098 outl(SIS_AC97_CMD_CODEC_COLD_RESET, io + SIS_AC97_CMD); 1100 outl(SIS_AC97_CMD_CODEC_COLD_RESET, io + SIS_AC97_CMD);
1099 udelay(10); 1101 udelay(250);
1100 1102
1101 count = 0xffff; 1103 count = 0xffff;
1102 while ((inw(io + SIS_AC97_STATUS) & SIS_AC97_STATUS_BUSY) && --count) 1104 while ((inw(io + SIS_AC97_STATUS) & SIS_AC97_STATUS_BUSY) && --count)
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 7e494b6a1d0e..8c5f8b5a59f0 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -85,6 +85,7 @@ static int joystick;
85static int ac97_clock = 48000; 85static int ac97_clock = 48000;
86static char *ac97_quirk; 86static char *ac97_quirk;
87static int dxs_support; 87static int dxs_support;
88static int dxs_init_volume = 31;
88static int nodelay; 89static int nodelay;
89 90
90module_param(index, int, 0444); 91module_param(index, int, 0444);
@@ -103,6 +104,8 @@ module_param(ac97_quirk, charp, 0444);
103MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); 104MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
104module_param(dxs_support, int, 0444); 105module_param(dxs_support, int, 0444);
105MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)"); 106MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)");
107module_param(dxs_init_volume, int, 0644);
108MODULE_PARM_DESC(dxs_init_volume, "initial DXS volume (0-31)");
106module_param(nodelay, int, 0444); 109module_param(nodelay, int, 0444);
107MODULE_PARM_DESC(nodelay, "Disable 500ms init delay"); 110MODULE_PARM_DESC(nodelay, "Disable 500ms init delay");
108 111
@@ -1245,8 +1248,10 @@ static int snd_via8233_playback_open(struct snd_pcm_substream *substream)
1245 return err; 1248 return err;
1246 stream = viadev->reg_offset / 0x10; 1249 stream = viadev->reg_offset / 0x10;
1247 if (chip->dxs_controls[stream]) { 1250 if (chip->dxs_controls[stream]) {
1248 chip->playback_volume[stream][0] = 0; 1251 chip->playback_volume[stream][0] =
1249 chip->playback_volume[stream][1] = 0; 1252 VIA_DXS_MAX_VOLUME - (dxs_init_volume & 31);
1253 chip->playback_volume[stream][1] =
1254 VIA_DXS_MAX_VOLUME - (dxs_init_volume & 31);
1250 chip->dxs_controls[stream]->vd[0].access &= 1255 chip->dxs_controls[stream]->vd[0].access &=
1251 ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; 1256 ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
1252 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | 1257 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE |