aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/asihpi
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/asihpi')
-rw-r--r--sound/pci/asihpi/asihpi.c81
-rw-r--r--sound/pci/asihpi/hpi.h24
-rw-r--r--sound/pci/asihpi/hpi6000.c11
-rw-r--r--sound/pci/asihpi/hpi6205.c52
-rw-r--r--sound/pci/asihpi/hpi6205.h25
-rw-r--r--sound/pci/asihpi/hpi_internal.h155
-rw-r--r--sound/pci/asihpi/hpicmn.c17
-rw-r--r--sound/pci/asihpi/hpidspcd.c136
-rw-r--r--sound/pci/asihpi/hpidspcd.h72
-rw-r--r--sound/pci/asihpi/hpifunc.c86
-rw-r--r--sound/pci/asihpi/hpimsginit.c4
-rw-r--r--sound/pci/asihpi/hpimsgx.c6
-rw-r--r--sound/pci/asihpi/hpioctl.c10
-rw-r--r--sound/pci/asihpi/hpios.c8
-rw-r--r--sound/pci/asihpi/hpios.h1
15 files changed, 311 insertions, 377 deletions
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index e3569bdd3b64..b941d2541dda 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -49,19 +49,21 @@ MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx");
49#if defined CONFIG_SND_DEBUG 49#if defined CONFIG_SND_DEBUG
50/* copied from pcm_lib.c, hope later patch will make that version public 50/* copied from pcm_lib.c, hope later patch will make that version public
51and this copy can be removed */ 51and this copy can be removed */
52static void pcm_debug_name(struct snd_pcm_substream *substream, 52static inline void
53 char *name, size_t len) 53snd_pcm_debug_name(struct snd_pcm_substream *substream, char *buf, size_t size)
54{ 54{
55 snprintf(name, len, "pcmC%dD%d%c:%d", 55 snprintf(buf, size, "pcmC%dD%d%c:%d",
56 substream->pcm->card->number, 56 substream->pcm->card->number,
57 substream->pcm->device, 57 substream->pcm->device,
58 substream->stream ? 'c' : 'p', 58 substream->stream ? 'c' : 'p',
59 substream->number); 59 substream->number);
60} 60}
61#define DEBUG_NAME(substream, name) char name[16]; pcm_debug_name(substream, name, sizeof(name))
62#else 61#else
63#define pcm_debug_name(s, n, l) do { } while (0) 62static inline void
64#define DEBUG_NAME(name, substream) do { } while (0) 63snd_pcm_debug_name(struct snd_pcm_substream *substream, char *buf, size_t size)
64{
65 *buf = 0;
66}
65#endif 67#endif
66 68
67#if defined CONFIG_SND_DEBUG_VERBOSE 69#if defined CONFIG_SND_DEBUG_VERBOSE
@@ -304,7 +306,8 @@ static u16 handle_error(u16 err, int line, char *filename)
304static void print_hwparams(struct snd_pcm_substream *substream, 306static void print_hwparams(struct snd_pcm_substream *substream,
305 struct snd_pcm_hw_params *p) 307 struct snd_pcm_hw_params *p)
306{ 308{
307 DEBUG_NAME(substream, name); 309 char name[16];
310 snd_pcm_debug_name(substream, name, sizeof(name));
308 snd_printd("%s HWPARAMS\n", name); 311 snd_printd("%s HWPARAMS\n", name);
309 snd_printd(" samplerate %d Hz\n", params_rate(p)); 312 snd_printd(" samplerate %d Hz\n", params_rate(p));
310 snd_printd(" channels %d\n", params_channels(p)); 313 snd_printd(" channels %d\n", params_channels(p));
@@ -576,8 +579,9 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
576 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); 579 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream);
577 struct snd_pcm_substream *s; 580 struct snd_pcm_substream *s;
578 u16 e; 581 u16 e;
579 DEBUG_NAME(substream, name); 582 char name[16];
580 583
584 snd_pcm_debug_name(substream, name, sizeof(name));
581 snd_printdd("%s trigger\n", name); 585 snd_printdd("%s trigger\n", name);
582 586
583 switch (cmd) { 587 switch (cmd) {
@@ -741,7 +745,9 @@ static void snd_card_asihpi_timer_function(unsigned long data)
741 int loops = 0; 745 int loops = 0;
742 u16 state; 746 u16 state;
743 u32 buffer_size, bytes_avail, samples_played, on_card_bytes; 747 u32 buffer_size, bytes_avail, samples_played, on_card_bytes;
744 DEBUG_NAME(substream, name); 748 char name[16];
749
750 snd_pcm_debug_name(substream, name, sizeof(name));
745 751
746 snd_printdd("%s snd_card_asihpi_timer_function\n", name); 752 snd_printdd("%s snd_card_asihpi_timer_function\n", name);
747 753
@@ -1323,10 +1329,12 @@ static const char * const asihpi_src_names[] = {
1323 "RF", 1329 "RF",
1324 "Clock", 1330 "Clock",
1325 "Bitstream", 1331 "Bitstream",
1326 "Microphone", 1332 "Mic",
1327 "Cobranet", 1333 "Net",
1328 "Analog", 1334 "Analog",
1329 "Adapter", 1335 "Adapter",
1336 "RTP",
1337 "GPI",
1330}; 1338};
1331 1339
1332compile_time_assert( 1340compile_time_assert(
@@ -1341,8 +1349,10 @@ static const char * const asihpi_dst_names[] = {
1341 "Digital", 1349 "Digital",
1342 "RF", 1350 "RF",
1343 "Speaker", 1351 "Speaker",
1344 "Cobranet Out", 1352 "Net",
1345 "Analog" 1353 "Analog",
1354 "RTP",
1355 "GPO",
1346}; 1356};
1347 1357
1348compile_time_assert( 1358compile_time_assert(
@@ -1476,11 +1486,40 @@ static int snd_asihpi_volume_put(struct snd_kcontrol *kcontrol,
1476 1486
1477static const DECLARE_TLV_DB_SCALE(db_scale_100, -10000, VOL_STEP_mB, 0); 1487static const DECLARE_TLV_DB_SCALE(db_scale_100, -10000, VOL_STEP_mB, 0);
1478 1488
1489#define snd_asihpi_volume_mute_info snd_ctl_boolean_mono_info
1490
1491static int snd_asihpi_volume_mute_get(struct snd_kcontrol *kcontrol,
1492 struct snd_ctl_elem_value *ucontrol)
1493{
1494 u32 h_control = kcontrol->private_value;
1495 u32 mute;
1496
1497 hpi_handle_error(hpi_volume_get_mute(h_control, &mute));
1498 ucontrol->value.integer.value[0] = mute ? 0 : 1;
1499
1500 return 0;
1501}
1502
1503static int snd_asihpi_volume_mute_put(struct snd_kcontrol *kcontrol,
1504 struct snd_ctl_elem_value *ucontrol)
1505{
1506 u32 h_control = kcontrol->private_value;
1507 int change = 1;
1508 /* HPI currently only supports all or none muting of multichannel volume
1509 ALSA Switch element has opposite sense to HPI mute: on==unmuted, off=muted
1510 */
1511 int mute = ucontrol->value.integer.value[0] ? 0 : HPI_BITMASK_ALL_CHANNELS;
1512 hpi_handle_error(hpi_volume_set_mute(h_control, mute));
1513 return change;
1514}
1515
1479static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, 1516static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi,
1480 struct hpi_control *hpi_ctl) 1517 struct hpi_control *hpi_ctl)
1481{ 1518{
1482 struct snd_card *card = asihpi->card; 1519 struct snd_card *card = asihpi->card;
1483 struct snd_kcontrol_new snd_control; 1520 struct snd_kcontrol_new snd_control;
1521 int err;
1522 u32 mute;
1484 1523
1485 asihpi_ctl_init(&snd_control, hpi_ctl, "Volume"); 1524 asihpi_ctl_init(&snd_control, hpi_ctl, "Volume");
1486 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | 1525 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
@@ -1490,7 +1529,19 @@ static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi,
1490 snd_control.put = snd_asihpi_volume_put; 1529 snd_control.put = snd_asihpi_volume_put;
1491 snd_control.tlv.p = db_scale_100; 1530 snd_control.tlv.p = db_scale_100;
1492 1531
1493 return ctl_add(card, &snd_control, asihpi); 1532 err = ctl_add(card, &snd_control, asihpi);
1533 if (err)
1534 return err;
1535
1536 if (hpi_volume_get_mute(hpi_ctl->h_control, &mute) == 0) {
1537 asihpi_ctl_init(&snd_control, hpi_ctl, "Switch");
1538 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
1539 snd_control.info = snd_asihpi_volume_mute_info;
1540 snd_control.get = snd_asihpi_volume_mute_get;
1541 snd_control.put = snd_asihpi_volume_mute_put;
1542 err = ctl_add(card, &snd_control, asihpi);
1543 }
1544 return err;
1494} 1545}
1495 1546
1496/*------------------------------------------------------------ 1547/*------------------------------------------------------------
@@ -2923,7 +2974,7 @@ static DEFINE_PCI_DEVICE_TABLE(asihpi_pci_tbl) = {
2923MODULE_DEVICE_TABLE(pci, asihpi_pci_tbl); 2974MODULE_DEVICE_TABLE(pci, asihpi_pci_tbl);
2924 2975
2925static struct pci_driver driver = { 2976static struct pci_driver driver = {
2926 .name = "asihpi", 2977 .name = KBUILD_MODNAME,
2927 .id_table = asihpi_pci_tbl, 2978 .id_table = asihpi_pci_tbl,
2928 .probe = snd_asihpi_probe, 2979 .probe = snd_asihpi_probe,
2929 .remove = __devexit_p(snd_asihpi_remove), 2980 .remove = __devexit_p(snd_asihpi_remove),
diff --git a/sound/pci/asihpi/hpi.h b/sound/pci/asihpi/hpi.h
index 255429c32c1c..f20727288994 100644
--- a/sound/pci/asihpi/hpi.h
+++ b/sound/pci/asihpi/hpi.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -42,12 +42,11 @@ i.e 3.05.02 is a development version
42#define HPI_VER_MINOR(v) ((int)((v >> 8) & 0xFF)) 42#define HPI_VER_MINOR(v) ((int)((v >> 8) & 0xFF))
43#define HPI_VER_RELEASE(v) ((int)(v & 0xFF)) 43#define HPI_VER_RELEASE(v) ((int)(v & 0xFF))
44 44
45/* Use single digits for versions less that 10 to avoid octal. */ 45#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 8, 0)
46#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 6, 0) 46#define HPI_VER_STRING "4.08.00"
47#define HPI_VER_STRING "4.06.00"
48 47
49/* Library version as documented in hpi-api-versions.txt */ 48/* Library version as documented in hpi-api-versions.txt */
50#define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0) 49#define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(10, 0, 0)
51 50
52#include <linux/types.h> 51#include <linux/types.h>
53#define HPI_BUILD_EXCLUDE_DEPRECATED 52#define HPI_BUILD_EXCLUDE_DEPRECATED
@@ -211,8 +210,12 @@ enum HPI_SOURCENODES {
211 HPI_SOURCENODE_COBRANET = 109, 210 HPI_SOURCENODE_COBRANET = 109,
212 HPI_SOURCENODE_ANALOG = 110, /**< analog input node. */ 211 HPI_SOURCENODE_ANALOG = 110, /**< analog input node. */
213 HPI_SOURCENODE_ADAPTER = 111, /**< adapter node. */ 212 HPI_SOURCENODE_ADAPTER = 111, /**< adapter node. */
213 /** RTP stream input node - This node is a destination for
214 packets of RTP audio samples from other devices. */
215 HPI_SOURCENODE_RTP_DESTINATION = 112,
216 HPI_SOURCENODE_GP_IN = 113, /**< general purpose input. */
214 /* !!!Update this AND hpidebug.h if you add a new sourcenode type!!! */ 217 /* !!!Update this AND hpidebug.h if you add a new sourcenode type!!! */
215 HPI_SOURCENODE_LAST_INDEX = 111 /**< largest ID */ 218 HPI_SOURCENODE_LAST_INDEX = 113 /**< largest ID */
216 /* AX6 max sourcenode types = 15 */ 219 /* AX6 max sourcenode types = 15 */
217}; 220};
218 221
@@ -228,7 +231,7 @@ enum HPI_DESTNODES {
228 HPI_DESTNODE_NONE = 200, 231 HPI_DESTNODE_NONE = 200,
229 /** In Stream (Record) node. */ 232 /** In Stream (Record) node. */
230 HPI_DESTNODE_ISTREAM = 201, 233 HPI_DESTNODE_ISTREAM = 201,
231 HPI_DESTNODE_LINEOUT = 202, /**< line out node. */ 234 HPI_DESTNODE_LINEOUT = 202, /**< line out node. */
232 HPI_DESTNODE_AESEBU_OUT = 203, /**< AES/EBU output node. */ 235 HPI_DESTNODE_AESEBU_OUT = 203, /**< AES/EBU output node. */
233 HPI_DESTNODE_RF = 204, /**< RF output node. */ 236 HPI_DESTNODE_RF = 204, /**< RF output node. */
234 HPI_DESTNODE_SPEAKER = 205, /**< speaker output node. */ 237 HPI_DESTNODE_SPEAKER = 205, /**< speaker output node. */
@@ -236,9 +239,12 @@ enum HPI_DESTNODES {
236 Audio samples from the device are sent out on the Cobranet network.*/ 239 Audio samples from the device are sent out on the Cobranet network.*/
237 HPI_DESTNODE_COBRANET = 206, 240 HPI_DESTNODE_COBRANET = 206,
238 HPI_DESTNODE_ANALOG = 207, /**< analog output node. */ 241 HPI_DESTNODE_ANALOG = 207, /**< analog output node. */
239 242 /** RTP stream output node - This node is a source for
243 packets of RTP audio samples that are sent to other devices. */
244 HPI_DESTNODE_RTP_SOURCE = 208,
245 HPI_DESTNODE_GP_OUT = 209, /**< general purpose output node. */
240 /* !!!Update this AND hpidebug.h if you add a new destnode type!!! */ 246 /* !!!Update this AND hpidebug.h if you add a new destnode type!!! */
241 HPI_DESTNODE_LAST_INDEX = 207 /**< largest ID */ 247 HPI_DESTNODE_LAST_INDEX = 209 /**< largest ID */
242 /* AX6 max destnode types = 15 */ 248 /* AX6 max destnode types = 15 */
243}; 249};
244 250
diff --git a/sound/pci/asihpi/hpi6000.c b/sound/pci/asihpi/hpi6000.c
index df4aed5295dd..3cc6f11c20aa 100644
--- a/sound/pci/asihpi/hpi6000.c
+++ b/sound/pci/asihpi/hpi6000.c
@@ -359,7 +359,7 @@ void HPI_6000(struct hpi_message *phm, struct hpi_response *phr)
359 HPI_ERROR_PROCESSING_MESSAGE); 359 HPI_ERROR_PROCESSING_MESSAGE);
360 360
361 switch (phm->type) { 361 switch (phm->type) {
362 case HPI_TYPE_MESSAGE: 362 case HPI_TYPE_REQUEST:
363 switch (phm->object) { 363 switch (phm->object) {
364 case HPI_OBJ_SUBSYSTEM: 364 case HPI_OBJ_SUBSYSTEM:
365 subsys_message(phm, phr); 365 subsys_message(phm, phr);
@@ -538,7 +538,7 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
538 538
539 HPI_DEBUG_LOG(VERBOSE, "send ADAPTER_GET_INFO\n"); 539 HPI_DEBUG_LOG(VERBOSE, "send ADAPTER_GET_INFO\n");
540 memset(&hm, 0, sizeof(hm)); 540 memset(&hm, 0, sizeof(hm));
541 hm.type = HPI_TYPE_MESSAGE; 541 hm.type = HPI_TYPE_REQUEST;
542 hm.size = sizeof(struct hpi_message); 542 hm.size = sizeof(struct hpi_message);
543 hm.object = HPI_OBJ_ADAPTER; 543 hm.object = HPI_OBJ_ADAPTER;
544 hm.function = HPI_ADAPTER_GET_INFO; 544 hm.function = HPI_ADAPTER_GET_INFO;
@@ -946,11 +946,8 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
946 } 946 }
947 947
948 /* write the DSP code down into the DSPs memory */ 948 /* write the DSP code down into the DSPs memory */
949 /*HpiDspCode_Open(nBootLoadFamily,&DspCode,pdwOsErrorCode); */ 949 error = hpi_dsp_code_open(boot_load_family, pao->pci.pci_dev,
950 dsp_code.ps_dev = pao->pci.pci_dev; 950 &dsp_code, pos_error_code);
951
952 error = hpi_dsp_code_open(boot_load_family, &dsp_code,
953 pos_error_code);
954 951
955 if (error) 952 if (error)
956 return error; 953 return error;
diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c
index 9d5df54a6b46..e041a6ae1c5a 100644
--- a/sound/pci/asihpi/hpi6205.c
+++ b/sound/pci/asihpi/hpi6205.c
@@ -373,6 +373,7 @@ static void instream_message(struct hpi_adapter_obj *pao,
373/** Entry point to this HPI backend 373/** Entry point to this HPI backend
374 * All calls to the HPI start here 374 * All calls to the HPI start here
375 */ 375 */
376static
376void _HPI_6205(struct hpi_adapter_obj *pao, struct hpi_message *phm, 377void _HPI_6205(struct hpi_adapter_obj *pao, struct hpi_message *phm,
377 struct hpi_response *phr) 378 struct hpi_response *phr)
378{ 379{
@@ -392,7 +393,7 @@ void _HPI_6205(struct hpi_adapter_obj *pao, struct hpi_message *phm,
392 393
393 HPI_DEBUG_LOG(VERBOSE, "start of switch\n"); 394 HPI_DEBUG_LOG(VERBOSE, "start of switch\n");
394 switch (phm->type) { 395 switch (phm->type) {
395 case HPI_TYPE_MESSAGE: 396 case HPI_TYPE_REQUEST:
396 switch (phm->object) { 397 switch (phm->object) {
397 case HPI_OBJ_SUBSYSTEM: 398 case HPI_OBJ_SUBSYSTEM:
398 subsys_message(pao, phm, phr); 399 subsys_message(pao, phm, phr);
@@ -402,7 +403,6 @@ void _HPI_6205(struct hpi_adapter_obj *pao, struct hpi_message *phm,
402 adapter_message(pao, phm, phr); 403 adapter_message(pao, phm, phr);
403 break; 404 break;
404 405
405 case HPI_OBJ_CONTROLEX:
406 case HPI_OBJ_CONTROL: 406 case HPI_OBJ_CONTROL:
407 control_message(pao, phm, phr); 407 control_message(pao, phm, phr);
408 break; 408 break;
@@ -634,11 +634,12 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
634 634
635 HPI_DEBUG_LOG(VERBOSE, "init ADAPTER_GET_INFO\n"); 635 HPI_DEBUG_LOG(VERBOSE, "init ADAPTER_GET_INFO\n");
636 memset(&hm, 0, sizeof(hm)); 636 memset(&hm, 0, sizeof(hm));
637 hm.type = HPI_TYPE_MESSAGE; 637 /* wAdapterIndex == version == 0 */
638 hm.type = HPI_TYPE_REQUEST;
638 hm.size = sizeof(hm); 639 hm.size = sizeof(hm);
639 hm.object = HPI_OBJ_ADAPTER; 640 hm.object = HPI_OBJ_ADAPTER;
640 hm.function = HPI_ADAPTER_GET_INFO; 641 hm.function = HPI_ADAPTER_GET_INFO;
641 hm.adapter_index = 0; 642
642 memset(&hr, 0, sizeof(hr)); 643 memset(&hr, 0, sizeof(hr));
643 hr.size = sizeof(hr); 644 hr.size = sizeof(hr);
644 645
@@ -658,9 +659,6 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
658 hr.u.ax.info.num_outstreams + 659 hr.u.ax.info.num_outstreams +
659 hr.u.ax.info.num_instreams; 660 hr.u.ax.info.num_instreams;
660 661
661 hpios_locked_mem_prepare((max_streams * 6) / 10, max_streams,
662 65536, pao->pci.pci_dev);
663
664 HPI_DEBUG_LOG(VERBOSE, 662 HPI_DEBUG_LOG(VERBOSE,
665 "got adapter info type %x index %d serial %d\n", 663 "got adapter info type %x index %d serial %d\n",
666 hr.u.ax.info.adapter_type, hr.u.ax.info.adapter_index, 664 hr.u.ax.info.adapter_type, hr.u.ax.info.adapter_index,
@@ -709,9 +707,6 @@ static void delete_adapter_obj(struct hpi_adapter_obj *pao)
709 [i]); 707 [i]);
710 phw->outstream_host_buffer_size[i] = 0; 708 phw->outstream_host_buffer_size[i] = 0;
711 } 709 }
712
713 hpios_locked_mem_unprepare(pao->pci.pci_dev);
714
715 kfree(phw); 710 kfree(phw);
716} 711}
717 712
@@ -1371,9 +1366,8 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1371 return err; 1366 return err;
1372 1367
1373 /* write the DSP code down into the DSPs memory */ 1368 /* write the DSP code down into the DSPs memory */
1374 dsp_code.ps_dev = pao->pci.pci_dev; 1369 err = hpi_dsp_code_open(boot_code_id[dsp], pao->pci.pci_dev,
1375 err = hpi_dsp_code_open(boot_code_id[dsp], &dsp_code, 1370 &dsp_code, pos_error_code);
1376 pos_error_code);
1377 if (err) 1371 if (err)
1378 return err; 1372 return err;
1379 1373
@@ -2084,13 +2078,13 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao,
2084 u16 err = 0; 2078 u16 err = 0;
2085 2079
2086 message_count++; 2080 message_count++;
2087 if (phm->size > sizeof(interface->u)) { 2081 if (phm->size > sizeof(interface->u.message_buffer)) {
2088 phr->error = HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL; 2082 phr->error = HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL;
2089 phr->specific_error = sizeof(interface->u); 2083 phr->specific_error = sizeof(interface->u.message_buffer);
2090 phr->size = sizeof(struct hpi_response_header); 2084 phr->size = sizeof(struct hpi_response_header);
2091 HPI_DEBUG_LOG(ERROR, 2085 HPI_DEBUG_LOG(ERROR,
2092 "message len %d too big for buffer %zd \n", phm->size, 2086 "message len %d too big for buffer %zd \n", phm->size,
2093 sizeof(interface->u)); 2087 sizeof(interface->u.message_buffer));
2094 return 0; 2088 return 0;
2095 } 2089 }
2096 2090
@@ -2122,18 +2116,19 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao,
2122 2116
2123 /* read the result */ 2117 /* read the result */
2124 if (time_out) { 2118 if (time_out) {
2125 if (interface->u.response_buffer.size <= phr->size) 2119 if (interface->u.response_buffer.response.size <= phr->size)
2126 memcpy(phr, &interface->u.response_buffer, 2120 memcpy(phr, &interface->u.response_buffer,
2127 interface->u.response_buffer.size); 2121 interface->u.response_buffer.response.size);
2128 else { 2122 else {
2129 HPI_DEBUG_LOG(ERROR, 2123 HPI_DEBUG_LOG(ERROR,
2130 "response len %d too big for buffer %d\n", 2124 "response len %d too big for buffer %d\n",
2131 interface->u.response_buffer.size, phr->size); 2125 interface->u.response_buffer.response.size,
2126 phr->size);
2132 memcpy(phr, &interface->u.response_buffer, 2127 memcpy(phr, &interface->u.response_buffer,
2133 sizeof(struct hpi_response_header)); 2128 sizeof(struct hpi_response_header));
2134 phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL; 2129 phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
2135 phr->specific_error = 2130 phr->specific_error =
2136 interface->u.response_buffer.size; 2131 interface->u.response_buffer.response.size;
2137 phr->size = sizeof(struct hpi_response_header); 2132 phr->size = sizeof(struct hpi_response_header);
2138 } 2133 }
2139 } 2134 }
@@ -2202,23 +2197,6 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm,
2202 phm->u.d.u.data.data_size, H620_HIF_GET_DATA); 2197 phm->u.d.u.data.data_size, H620_HIF_GET_DATA);
2203 break; 2198 break;
2204 2199
2205 case HPI_CONTROL_SET_STATE:
2206 if (phm->object == HPI_OBJ_CONTROLEX
2207 && phm->u.cx.attribute == HPI_COBRANET_SET_DATA)
2208 err = hpi6205_transfer_data(pao,
2209 phm->u.cx.u.cobranet_bigdata.pb_data,
2210 phm->u.cx.u.cobranet_bigdata.byte_count,
2211 H620_HIF_SEND_DATA);
2212 break;
2213
2214 case HPI_CONTROL_GET_STATE:
2215 if (phm->object == HPI_OBJ_CONTROLEX
2216 && phm->u.cx.attribute == HPI_COBRANET_GET_DATA)
2217 err = hpi6205_transfer_data(pao,
2218 phm->u.cx.u.cobranet_bigdata.pb_data,
2219 phr->u.cx.u.cobranet_data.byte_count,
2220 H620_HIF_GET_DATA);
2221 break;
2222 } 2200 }
2223 phr->error = err; 2201 phr->error = err;
2224 2202
diff --git a/sound/pci/asihpi/hpi6205.h b/sound/pci/asihpi/hpi6205.h
index df2f02c0c7b4..ec0827b633a6 100644
--- a/sound/pci/asihpi/hpi6205.h
+++ b/sound/pci/asihpi/hpi6205.h
@@ -1,7 +1,7 @@
1/***************************************************************************** 1/*****************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -70,15 +70,28 @@ The Host located memory buffer that the 6205 will bus master
70in and out of. 70in and out of.
71************************************************************/ 71************************************************************/
72#define HPI6205_SIZEOF_DATA (16*1024) 72#define HPI6205_SIZEOF_DATA (16*1024)
73
74struct message_buffer_6205 {
75 struct hpi_message message;
76 char data[256];
77};
78
79struct response_buffer_6205 {
80 struct hpi_response response;
81 char data[256];
82};
83
84union buffer_6205 {
85 struct message_buffer_6205 message_buffer;
86 struct response_buffer_6205 response_buffer;
87 u8 b_data[HPI6205_SIZEOF_DATA];
88};
89
73struct bus_master_interface { 90struct bus_master_interface {
74 u32 host_cmd; 91 u32 host_cmd;
75 u32 dsp_ack; 92 u32 dsp_ack;
76 u32 transfer_size_in_bytes; 93 u32 transfer_size_in_bytes;
77 union { 94 union buffer_6205 u;
78 struct hpi_message_header message_buffer;
79 struct hpi_response_header response_buffer;
80 u8 b_data[HPI6205_SIZEOF_DATA];
81 } u;
82 struct controlcache_6205 control_cache; 95 struct controlcache_6205 control_cache;
83 struct async_event_buffer_6205 async_buffer; 96 struct async_event_buffer_6205 async_buffer;
84 struct hpi_hostbuffer_status 97 struct hpi_hostbuffer_status
diff --git a/sound/pci/asihpi/hpi_internal.h b/sound/pci/asihpi/hpi_internal.h
index bf5eced76bac..d497030c160f 100644
--- a/sound/pci/asihpi/hpi_internal.h
+++ b/sound/pci/asihpi/hpi_internal.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -32,12 +32,6 @@ HPI internal definitions
32#include "hpios.h" 32#include "hpios.h"
33 33
34/* physical memory allocation */ 34/* physical memory allocation */
35void hpios_locked_mem_init(void
36 );
37void hpios_locked_mem_free_all(void
38 );
39#define hpios_locked_mem_prepare(a, b, c, d);
40#define hpios_locked_mem_unprepare(a)
41 35
42/** Allocate and map an area of locked memory for bus master DMA operations. 36/** Allocate and map an area of locked memory for bus master DMA operations.
43 37
@@ -226,8 +220,8 @@ enum HPI_CONTROL_ATTRIBUTES {
226 220
227 HPI_COBRANET_SET = HPI_CTL_ATTR(COBRANET, 1), 221 HPI_COBRANET_SET = HPI_CTL_ATTR(COBRANET, 1),
228 HPI_COBRANET_GET = HPI_CTL_ATTR(COBRANET, 2), 222 HPI_COBRANET_GET = HPI_CTL_ATTR(COBRANET, 2),
229 HPI_COBRANET_SET_DATA = HPI_CTL_ATTR(COBRANET, 3), 223 /*HPI_COBRANET_SET_DATA = HPI_CTL_ATTR(COBRANET, 3), */
230 HPI_COBRANET_GET_DATA = HPI_CTL_ATTR(COBRANET, 4), 224 /*HPI_COBRANET_GET_DATA = HPI_CTL_ATTR(COBRANET, 4), */
231 HPI_COBRANET_GET_STATUS = HPI_CTL_ATTR(COBRANET, 5), 225 HPI_COBRANET_GET_STATUS = HPI_CTL_ATTR(COBRANET, 5),
232 HPI_COBRANET_SEND_PACKET = HPI_CTL_ATTR(COBRANET, 6), 226 HPI_COBRANET_SEND_PACKET = HPI_CTL_ATTR(COBRANET, 6),
233 HPI_COBRANET_GET_PACKET = HPI_CTL_ATTR(COBRANET, 7), 227 HPI_COBRANET_GET_PACKET = HPI_CTL_ATTR(COBRANET, 7),
@@ -364,10 +358,12 @@ Used in DLL to indicate device not present
364#define HPI_ADAPTER_ASI(f) (f) 358#define HPI_ADAPTER_ASI(f) (f)
365 359
366enum HPI_MESSAGE_TYPES { 360enum HPI_MESSAGE_TYPES {
367 HPI_TYPE_MESSAGE = 1, 361 HPI_TYPE_REQUEST = 1,
368 HPI_TYPE_RESPONSE = 2, 362 HPI_TYPE_RESPONSE = 2,
369 HPI_TYPE_DATA = 3, 363 HPI_TYPE_DATA = 3,
370 HPI_TYPE_SSX2BYPASS_MESSAGE = 4 364 HPI_TYPE_SSX2BYPASS_MESSAGE = 4,
365 HPI_TYPE_COMMAND = 5,
366 HPI_TYPE_NOTIFICATION = 6
371}; 367};
372 368
373enum HPI_OBJECT_TYPES { 369enum HPI_OBJECT_TYPES {
@@ -383,7 +379,7 @@ enum HPI_OBJECT_TYPES {
383 HPI_OBJ_WATCHDOG = 10, 379 HPI_OBJ_WATCHDOG = 10,
384 HPI_OBJ_CLOCK = 11, 380 HPI_OBJ_CLOCK = 11,
385 HPI_OBJ_PROFILE = 12, 381 HPI_OBJ_PROFILE = 12,
386 HPI_OBJ_CONTROLEX = 13, 382 /* HPI_ OBJ_ CONTROLEX = 13, */
387 HPI_OBJ_ASYNCEVENT = 14 383 HPI_OBJ_ASYNCEVENT = 14
388#define HPI_OBJ_MAXINDEX 14 384#define HPI_OBJ_MAXINDEX 14
389}; 385};
@@ -608,7 +604,7 @@ struct hpi_data_compat32 {
608#endif 604#endif
609 605
610struct hpi_buffer { 606struct hpi_buffer {
611 /** placehoder for backward compatibility (see dwBufferSize) */ 607 /** placeholder for backward compatibility (see dwBufferSize) */
612 struct hpi_msg_format reserved; 608 struct hpi_msg_format reserved;
613 u32 command; /**< HPI_BUFFER_CMD_xxx*/ 609 u32 command; /**< HPI_BUFFER_CMD_xxx*/
614 u32 pci_address; /**< PCI physical address of buffer for DSP DMA */ 610 u32 pci_address; /**< PCI physical address of buffer for DSP DMA */
@@ -912,95 +908,13 @@ union hpi_control_union_res {
912 u32 remaining_chars; 908 u32 remaining_chars;
913 } chars8; 909 } chars8;
914 char c_data12[12]; 910 char c_data12[12];
915};
916
917/* HPI_CONTROLX_STRUCTURES */
918
919/* Message */
920
921/** Used for all HMI variables where max length <= 8 bytes
922*/
923struct hpi_controlx_msg_cobranet_data {
924 u32 hmi_address;
925 u32 byte_count;
926 u32 data[2];
927};
928
929/** Used for string data, and for packet bridge
930*/
931struct hpi_controlx_msg_cobranet_bigdata {
932 u32 hmi_address;
933 u32 byte_count;
934 u8 *pb_data;
935#ifndef HPI64BIT
936 u32 padding;
937#endif
938};
939
940/** Used for PADS control reading of string fields.
941*/
942struct hpi_controlx_msg_pad_data {
943 u32 field;
944 u32 byte_count;
945 u8 *pb_data;
946#ifndef HPI64BIT
947 u32 padding;
948#endif
949};
950
951/** Used for generic data
952*/
953
954struct hpi_controlx_msg_generic {
955 u32 param1;
956 u32 param2;
957};
958
959struct hpi_controlx_msg {
960 u16 attribute; /* control attribute or property */
961 u16 saved_index;
962 union {
963 struct hpi_controlx_msg_cobranet_data cobranet_data;
964 struct hpi_controlx_msg_cobranet_bigdata cobranet_bigdata;
965 struct hpi_controlx_msg_generic generic;
966 struct hpi_controlx_msg_pad_data pad_data;
967 /*struct param_value universal_value; */
968 /* nothing extra to send for status read */
969 } u;
970};
971
972/* Response */
973/**
974*/
975struct hpi_controlx_res_cobranet_data {
976 u32 byte_count;
977 u32 data[2];
978};
979
980struct hpi_controlx_res_cobranet_bigdata {
981 u32 byte_count;
982};
983
984struct hpi_controlx_res_cobranet_status {
985 u32 status;
986 u32 readable_size;
987 u32 writeable_size;
988};
989
990struct hpi_controlx_res_generic {
991 u32 param1;
992 u32 param2;
993};
994
995struct hpi_controlx_res {
996 union { 911 union {
997 struct hpi_controlx_res_cobranet_bigdata cobranet_bigdata; 912 struct {
998 struct hpi_controlx_res_cobranet_data cobranet_data; 913 u32 status;
999 struct hpi_controlx_res_cobranet_status cobranet_status; 914 u32 readable_size;
1000 struct hpi_controlx_res_generic generic; 915 u32 writeable_size;
1001 /*struct param_info universal_info; */ 916 } status;
1002 /*struct param_value universal_value; */ 917 } cobranet;
1003 } u;
1004}; 918};
1005 919
1006struct hpi_nvmemory_msg { 920struct hpi_nvmemory_msg {
@@ -1126,7 +1040,6 @@ struct hpi_message {
1126 /* identical to struct hpi_control_msg, 1040 /* identical to struct hpi_control_msg,
1127 but field naming is improved */ 1041 but field naming is improved */
1128 struct hpi_control_union_msg cu; 1042 struct hpi_control_union_msg cu;
1129 struct hpi_controlx_msg cx; /* extended mixer control; */
1130 struct hpi_nvmemory_msg n; 1043 struct hpi_nvmemory_msg n;
1131 struct hpi_gpio_msg l; /* digital i/o */ 1044 struct hpi_gpio_msg l; /* digital i/o */
1132 struct hpi_watchdog_msg w; 1045 struct hpi_watchdog_msg w;
@@ -1151,7 +1064,7 @@ struct hpi_message {
1151 sizeof(struct hpi_message_header) + sizeof(struct hpi_watchdog_msg),\ 1064 sizeof(struct hpi_message_header) + sizeof(struct hpi_watchdog_msg),\
1152 sizeof(struct hpi_message_header) + sizeof(struct hpi_clock_msg),\ 1065 sizeof(struct hpi_message_header) + sizeof(struct hpi_clock_msg),\
1153 sizeof(struct hpi_message_header) + sizeof(struct hpi_profile_msg),\ 1066 sizeof(struct hpi_message_header) + sizeof(struct hpi_profile_msg),\
1154 sizeof(struct hpi_message_header) + sizeof(struct hpi_controlx_msg),\ 1067 sizeof(struct hpi_message_header), /* controlx obj removed */ \
1155 sizeof(struct hpi_message_header) + sizeof(struct hpi_async_msg) \ 1068 sizeof(struct hpi_message_header) + sizeof(struct hpi_async_msg) \
1156} 1069}
1157 1070
@@ -1188,7 +1101,6 @@ struct hpi_response {
1188 struct hpi_control_res c; /* mixer control; */ 1101 struct hpi_control_res c; /* mixer control; */
1189 /* identical to hpi_control_res, but field naming is improved */ 1102 /* identical to hpi_control_res, but field naming is improved */
1190 union hpi_control_union_res cu; 1103 union hpi_control_union_res cu;
1191 struct hpi_controlx_res cx; /* extended mixer control; */
1192 struct hpi_nvmemory_res n; 1104 struct hpi_nvmemory_res n;
1193 struct hpi_gpio_res l; /* digital i/o */ 1105 struct hpi_gpio_res l; /* digital i/o */
1194 struct hpi_watchdog_res w; 1106 struct hpi_watchdog_res w;
@@ -1213,7 +1125,7 @@ struct hpi_response {
1213 sizeof(struct hpi_response_header) + sizeof(struct hpi_watchdog_res),\ 1125 sizeof(struct hpi_response_header) + sizeof(struct hpi_watchdog_res),\
1214 sizeof(struct hpi_response_header) + sizeof(struct hpi_clock_res),\ 1126 sizeof(struct hpi_response_header) + sizeof(struct hpi_clock_res),\
1215 sizeof(struct hpi_response_header) + sizeof(struct hpi_profile_res),\ 1127 sizeof(struct hpi_response_header) + sizeof(struct hpi_profile_res),\
1216 sizeof(struct hpi_response_header) + sizeof(struct hpi_controlx_res),\ 1128 sizeof(struct hpi_response_header), /* controlx obj removed */ \
1217 sizeof(struct hpi_response_header) + sizeof(struct hpi_async_res) \ 1129 sizeof(struct hpi_response_header) + sizeof(struct hpi_async_res) \
1218} 1130}
1219 1131
@@ -1308,6 +1220,30 @@ struct hpi_res_adapter_debug_read {
1308 u8 bytes[256]; 1220 u8 bytes[256];
1309}; 1221};
1310 1222
1223struct hpi_msg_cobranet_hmi {
1224 u16 attribute;
1225 u16 padding;
1226 u32 hmi_address;
1227 u32 byte_count;
1228};
1229
1230struct hpi_msg_cobranet_hmiwrite {
1231 struct hpi_message_header h;
1232 struct hpi_msg_cobranet_hmi p;
1233 u8 bytes[256];
1234};
1235
1236struct hpi_msg_cobranet_hmiread {
1237 struct hpi_message_header h;
1238 struct hpi_msg_cobranet_hmi p;
1239};
1240
1241struct hpi_res_cobranet_hmiread {
1242 struct hpi_response_header h;
1243 u32 byte_count;
1244 u8 bytes[256];
1245};
1246
1311#if 1 1247#if 1
1312#define hpi_message_header_v1 hpi_message_header 1248#define hpi_message_header_v1 hpi_message_header
1313#define hpi_response_header_v1 hpi_response_header 1249#define hpi_response_header_v1 hpi_response_header
@@ -1338,7 +1274,6 @@ struct hpi_msg_payload_v0 {
1338 union hpi_mixerx_msg mx; 1274 union hpi_mixerx_msg mx;
1339 struct hpi_control_msg c; 1275 struct hpi_control_msg c;
1340 struct hpi_control_union_msg cu; 1276 struct hpi_control_union_msg cu;
1341 struct hpi_controlx_msg cx;
1342 struct hpi_nvmemory_msg n; 1277 struct hpi_nvmemory_msg n;
1343 struct hpi_gpio_msg l; 1278 struct hpi_gpio_msg l;
1344 struct hpi_watchdog_msg w; 1279 struct hpi_watchdog_msg w;
@@ -1358,7 +1293,6 @@ struct hpi_res_payload_v0 {
1358 union hpi_mixerx_res mx; 1293 union hpi_mixerx_res mx;
1359 struct hpi_control_res c; 1294 struct hpi_control_res c;
1360 union hpi_control_union_res cu; 1295 union hpi_control_union_res cu;
1361 struct hpi_controlx_res cx;
1362 struct hpi_nvmemory_res n; 1296 struct hpi_nvmemory_res n;
1363 struct hpi_gpio_res l; 1297 struct hpi_gpio_res l;
1364 struct hpi_watchdog_res w; 1298 struct hpi_watchdog_res w;
@@ -1493,12 +1427,6 @@ struct hpi_control_cache_microphone {
1493 char temp_padding[6]; 1427 char temp_padding[6];
1494}; 1428};
1495 1429
1496struct hpi_control_cache_generic {
1497 struct hpi_control_cache_info i;
1498 u32 dw1;
1499 u32 dw2;
1500};
1501
1502struct hpi_control_cache_single { 1430struct hpi_control_cache_single {
1503 union { 1431 union {
1504 struct hpi_control_cache_info i; 1432 struct hpi_control_cache_info i;
@@ -1514,7 +1442,6 @@ struct hpi_control_cache_single {
1514 struct hpi_control_cache_silencedetector silence; 1442 struct hpi_control_cache_silencedetector silence;
1515 struct hpi_control_cache_sampleclock clk; 1443 struct hpi_control_cache_sampleclock clk;
1516 struct hpi_control_cache_microphone microphone; 1444 struct hpi_control_cache_microphone microphone;
1517 struct hpi_control_cache_generic generic;
1518 } u; 1445 } u;
1519}; 1446};
1520 1447
diff --git a/sound/pci/asihpi/hpicmn.c b/sound/pci/asihpi/hpicmn.c
index b15a02e91f82..65b7ca13115b 100644
--- a/sound/pci/asihpi/hpicmn.c
+++ b/sound/pci/asihpi/hpicmn.c
@@ -57,7 +57,7 @@ u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr)
57 } 57 }
58 58
59 if (phr->function != phm->function) { 59 if (phr->function != phm->function) {
60 HPI_DEBUG_LOG(ERROR, "header type %d invalid\n", 60 HPI_DEBUG_LOG(ERROR, "header function %d invalid\n",
61 phr->function); 61 phr->function);
62 return HPI_ERROR_INVALID_RESPONSE; 62 return HPI_ERROR_INVALID_RESPONSE;
63 } 63 }
@@ -315,8 +315,7 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
315 short found = 1; 315 short found = 1;
316 struct hpi_control_cache_info *pI; 316 struct hpi_control_cache_info *pI;
317 struct hpi_control_cache_single *pC; 317 struct hpi_control_cache_single *pC;
318 struct hpi_control_cache_pad *p_pad; 318 size_t response_size;
319
320 if (!find_control(phm->obj_index, p_cache, &pI)) { 319 if (!find_control(phm->obj_index, p_cache, &pI)) {
321 HPI_DEBUG_LOG(VERBOSE, 320 HPI_DEBUG_LOG(VERBOSE,
322 "HPICMN find_control() failed for adap %d\n", 321 "HPICMN find_control() failed for adap %d\n",
@@ -326,11 +325,15 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
326 325
327 phr->error = 0; 326 phr->error = 0;
328 327
328 /* set the default response size */
329 response_size =
330 sizeof(struct hpi_response_header) +
331 sizeof(struct hpi_control_res);
332
329 /* pC is the default cached control strucure. May be cast to 333 /* pC is the default cached control strucure. May be cast to
330 something else in the following switch statement. 334 something else in the following switch statement.
331 */ 335 */
332 pC = (struct hpi_control_cache_single *)pI; 336 pC = (struct hpi_control_cache_single *)pI;
333 p_pad = (struct hpi_control_cache_pad *)pI;
334 337
335 switch (pI->control_type) { 338 switch (pI->control_type) {
336 339
@@ -529,9 +532,7 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
529 pI->control_index, pI->control_type, phm->u.c.attribute); 532 pI->control_index, pI->control_type, phm->u.c.attribute);
530 533
531 if (found) 534 if (found)
532 phr->size = 535 phr->size = (u16)response_size;
533 sizeof(struct hpi_response_header) +
534 sizeof(struct hpi_control_res);
535 536
536 return found; 537 return found;
537} 538}
@@ -682,7 +683,7 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
682void HPI_COMMON(struct hpi_message *phm, struct hpi_response *phr) 683void HPI_COMMON(struct hpi_message *phm, struct hpi_response *phr)
683{ 684{
684 switch (phm->type) { 685 switch (phm->type) {
685 case HPI_TYPE_MESSAGE: 686 case HPI_TYPE_REQUEST:
686 switch (phm->object) { 687 switch (phm->object) {
687 case HPI_OBJ_SUBSYSTEM: 688 case HPI_OBJ_SUBSYSTEM:
688 subsys_message(phm, phr); 689 subsys_message(phm, phr);
diff --git a/sound/pci/asihpi/hpidspcd.c b/sound/pci/asihpi/hpidspcd.c
index 5c6ea113d219..3a7afa31c1d8 100644
--- a/sound/pci/asihpi/hpidspcd.c
+++ b/sound/pci/asihpi/hpidspcd.c
@@ -1,8 +1,8 @@
1/***********************************************************************/ 1/***********************************************************************/
2/*! 2/**
3 3
4 AudioScience HPI driver 4 AudioScience HPI driver
5 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 5 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of version 2 of the GNU General Public License as 8 it under the terms of version 2 of the GNU General Public License as
@@ -18,90 +18,59 @@
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 19
20\file 20\file
21Functions for reading DSP code to load into DSP 21Functions for reading DSP code using
22
23(Linux only:) If DSPCODE_FIRMWARE_LOADER is defined, code is read using
24hotplug firmware loader from individual dsp code files 22hotplug firmware loader from individual dsp code files
25 23*/
26If neither of the above is defined, code is read from linked arrays.
27DSPCODE_ARRAY is defined.
28
29HPI_INCLUDE_**** must be defined
30and the appropriate hzz?????.c or hex?????.c linked in
31
32 */
33/***********************************************************************/ 24/***********************************************************************/
34#define SOURCEFILE_NAME "hpidspcd.c" 25#define SOURCEFILE_NAME "hpidspcd.c"
35#include "hpidspcd.h" 26#include "hpidspcd.h"
36#include "hpidebug.h" 27#include "hpidebug.h"
37 28
38/** 29struct dsp_code_private {
39 Header structure for binary dsp code file (see asidsp.doc) 30 /** Firmware descriptor */
40 This structure must match that used in s2bin.c for generation of asidsp.bin 31 const struct firmware *firmware;
41 */ 32 struct pci_dev *dev;
42
43#ifndef DISABLE_PRAGMA_PACK1
44#pragma pack(push, 1)
45#endif
46
47struct code_header {
48 u32 size;
49 char type[4];
50 u32 adapter;
51 u32 version;
52 u32 crc;
53}; 33};
54 34
55#ifndef DISABLE_PRAGMA_PACK1
56#pragma pack(pop)
57#endif
58
59#define HPI_VER_DECIMAL ((int)(HPI_VER_MAJOR(HPI_VER) * 10000 + \ 35#define HPI_VER_DECIMAL ((int)(HPI_VER_MAJOR(HPI_VER) * 10000 + \
60 HPI_VER_MINOR(HPI_VER) * 100 + HPI_VER_RELEASE(HPI_VER))) 36 HPI_VER_MINOR(HPI_VER) * 100 + HPI_VER_RELEASE(HPI_VER)))
61 37
62/***********************************************************************/
63#include <linux/pci.h>
64/*-------------------------------------------------------------------*/ 38/*-------------------------------------------------------------------*/
65short hpi_dsp_code_open(u32 adapter, struct dsp_code *ps_dsp_code, 39short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
66 u32 *pos_error_code) 40 u32 *os_error_code)
67{ 41{
68 const struct firmware *ps_firmware = ps_dsp_code->ps_firmware; 42 const struct firmware *firmware;
43 struct pci_dev *dev = os_data;
69 struct code_header header; 44 struct code_header header;
70 char fw_name[20]; 45 char fw_name[20];
71 int err; 46 int err;
72 47
73 sprintf(fw_name, "asihpi/dsp%04x.bin", adapter); 48 sprintf(fw_name, "asihpi/dsp%04x.bin", adapter);
74 49
75 err = request_firmware(&ps_firmware, fw_name, 50 err = request_firmware(&firmware, fw_name, &dev->dev);
76 &ps_dsp_code->ps_dev->dev);
77 51
78 if (err != 0) { 52 if (err || !firmware) {
79 dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev, 53 dev_printk(KERN_ERR, &dev->dev,
80 "%d, request_firmware failed for %s\n", err, 54 "%d, request_firmware failed for %s\n", err,
81 fw_name); 55 fw_name);
82 goto error1; 56 goto error1;
83 } 57 }
84 if (ps_firmware->size < sizeof(header)) { 58 if (firmware->size < sizeof(header)) {
85 dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev, 59 dev_printk(KERN_ERR, &dev->dev, "Header size too small %s\n",
86 "Header size too small %s\n", fw_name); 60 fw_name);
87 goto error2;
88 }
89 memcpy(&header, ps_firmware->data, sizeof(header));
90 if (header.adapter != adapter) {
91 dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev,
92 "Adapter type incorrect %4x != %4x\n", header.adapter,
93 adapter);
94 goto error2; 61 goto error2;
95 } 62 }
96 if (header.size != ps_firmware->size) { 63 memcpy(&header, firmware->data, sizeof(header));
97 dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev, 64
98 "Code size wrong %d != %ld\n", header.size, 65 if ((header.type != 0x45444F43) || /* "CODE" */
99 (unsigned long)ps_firmware->size); 66 (header.adapter != adapter)
67 || (header.size != firmware->size)) {
68 dev_printk(KERN_ERR, &dev->dev, "Invalid firmware file\n");
100 goto error2; 69 goto error2;
101 } 70 }
102 71
103 if (header.version / 100 != HPI_VER_DECIMAL / 100) { 72 if ((header.version / 100 & ~1) != (HPI_VER_DECIMAL / 100 & ~1)) {
104 dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev, 73 dev_printk(KERN_ERR, &dev->dev,
105 "Incompatible firmware version " 74 "Incompatible firmware version "
106 "DSP image %d != Driver %d\n", header.version, 75 "DSP image %d != Driver %d\n", header.version,
107 HPI_VER_DECIMAL); 76 HPI_VER_DECIMAL);
@@ -109,67 +78,70 @@ short hpi_dsp_code_open(u32 adapter, struct dsp_code *ps_dsp_code,
109 } 78 }
110 79
111 if (header.version != HPI_VER_DECIMAL) { 80 if (header.version != HPI_VER_DECIMAL) {
112 dev_printk(KERN_WARNING, &ps_dsp_code->ps_dev->dev, 81 dev_printk(KERN_WARNING, &dev->dev,
113 "Firmware: release version mismatch DSP image %d != Driver %d\n", 82 "Firmware: release version mismatch DSP image %d != Driver %d\n",
114 header.version, HPI_VER_DECIMAL); 83 header.version, HPI_VER_DECIMAL);
115 } 84 }
116 85
117 HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name); 86 HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name);
118 ps_dsp_code->ps_firmware = ps_firmware; 87 dsp_code->pvt = kmalloc(sizeof(*dsp_code->pvt), GFP_KERNEL);
119 ps_dsp_code->block_length = header.size / sizeof(u32); 88 if (!dsp_code->pvt)
120 ps_dsp_code->word_count = sizeof(header) / sizeof(u32); 89 return HPI_ERROR_MEMORY_ALLOC;
121 ps_dsp_code->version = header.version; 90
122 ps_dsp_code->crc = header.crc; 91 dsp_code->pvt->dev = dev;
92 dsp_code->pvt->firmware = firmware;
93 dsp_code->header = header;
94 dsp_code->block_length = header.size / sizeof(u32);
95 dsp_code->word_count = sizeof(header) / sizeof(u32);
123 return 0; 96 return 0;
124 97
125error2: 98error2:
126 release_firmware(ps_firmware); 99 release_firmware(firmware);
127error1: 100error1:
128 ps_dsp_code->ps_firmware = NULL; 101 dsp_code->block_length = 0;
129 ps_dsp_code->block_length = 0;
130 return HPI_ERROR_DSP_FILE_NOT_FOUND; 102 return HPI_ERROR_DSP_FILE_NOT_FOUND;
131} 103}
132 104
133/*-------------------------------------------------------------------*/ 105/*-------------------------------------------------------------------*/
134void hpi_dsp_code_close(struct dsp_code *ps_dsp_code) 106void hpi_dsp_code_close(struct dsp_code *dsp_code)
135{ 107{
136 if (ps_dsp_code->ps_firmware != NULL) { 108 if (dsp_code->pvt->firmware) {
137 HPI_DEBUG_LOG(DEBUG, "dsp code closed\n"); 109 HPI_DEBUG_LOG(DEBUG, "dsp code closed\n");
138 release_firmware(ps_dsp_code->ps_firmware); 110 release_firmware(dsp_code->pvt->firmware);
139 ps_dsp_code->ps_firmware = NULL; 111 dsp_code->pvt->firmware = NULL;
140 } 112 }
113 kfree(dsp_code->pvt);
141} 114}
142 115
143/*-------------------------------------------------------------------*/ 116/*-------------------------------------------------------------------*/
144void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code) 117void hpi_dsp_code_rewind(struct dsp_code *dsp_code)
145{ 118{
146 /* Go back to start of data, after header */ 119 /* Go back to start of data, after header */
147 ps_dsp_code->word_count = sizeof(struct code_header) / sizeof(u32); 120 dsp_code->word_count = sizeof(struct code_header) / sizeof(u32);
148} 121}
149 122
150/*-------------------------------------------------------------------*/ 123/*-------------------------------------------------------------------*/
151short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code, u32 *pword) 124short hpi_dsp_code_read_word(struct dsp_code *dsp_code, u32 *pword)
152{ 125{
153 if (ps_dsp_code->word_count + 1 > ps_dsp_code->block_length) 126 if (dsp_code->word_count + 1 > dsp_code->block_length)
154 return HPI_ERROR_DSP_FILE_FORMAT; 127 return HPI_ERROR_DSP_FILE_FORMAT;
155 128
156 *pword = ((u32 *)(ps_dsp_code->ps_firmware->data))[ps_dsp_code-> 129 *pword = ((u32 *)(dsp_code->pvt->firmware->data))[dsp_code->
157 word_count]; 130 word_count];
158 ps_dsp_code->word_count++; 131 dsp_code->word_count++;
159 return 0; 132 return 0;
160} 133}
161 134
162/*-------------------------------------------------------------------*/ 135/*-------------------------------------------------------------------*/
163short hpi_dsp_code_read_block(size_t words_requested, 136short hpi_dsp_code_read_block(size_t words_requested,
164 struct dsp_code *ps_dsp_code, u32 **ppblock) 137 struct dsp_code *dsp_code, u32 **ppblock)
165{ 138{
166 if (ps_dsp_code->word_count + words_requested > 139 if (dsp_code->word_count + words_requested > dsp_code->block_length)
167 ps_dsp_code->block_length)
168 return HPI_ERROR_DSP_FILE_FORMAT; 140 return HPI_ERROR_DSP_FILE_FORMAT;
169 141
170 *ppblock = 142 *ppblock =
171 ((u32 *)(ps_dsp_code->ps_firmware->data)) + 143 ((u32 *)(dsp_code->pvt->firmware->data)) +
172 ps_dsp_code->word_count; 144 dsp_code->word_count;
173 ps_dsp_code->word_count += words_requested; 145 dsp_code->word_count += words_requested;
174 return 0; 146 return 0;
175} 147}
diff --git a/sound/pci/asihpi/hpidspcd.h b/sound/pci/asihpi/hpidspcd.h
index 65f0ca732704..b22881122f19 100644
--- a/sound/pci/asihpi/hpidspcd.h
+++ b/sound/pci/asihpi/hpidspcd.h
@@ -2,7 +2,7 @@
2/** 2/**
3 3
4 AudioScience HPI driver 4 AudioScience HPI driver
5 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 5 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of version 2 of the GNU General Public License as 8 it under the terms of version 2 of the GNU General Public License as
@@ -20,19 +20,6 @@
20\file 20\file
21Functions for reading DSP code to load into DSP 21Functions for reading DSP code to load into DSP
22 22
23 hpi_dspcode_defines HPI DSP code loading method
24Define exactly one of these to select how the DSP code is supplied to
25the adapter.
26
27End users writing applications that use the HPI interface do not have to
28use any of the below defines; they are only necessary for building drivers
29
30HPI_DSPCODE_FILE:
31DSP code is supplied as a file that is opened and read from by the driver.
32
33HPI_DSPCODE_FIRMWARE:
34DSP code is read using the hotplug firmware loader module.
35 Only valid when compiling the HPI kernel driver under Linux.
36*/ 23*/
37/***********************************************************************/ 24/***********************************************************************/
38#ifndef _HPIDSPCD_H_ 25#ifndef _HPIDSPCD_H_
@@ -40,37 +27,56 @@ DSP code is read using the hotplug firmware loader module.
40 27
41#include "hpi_internal.h" 28#include "hpi_internal.h"
42 29
43#ifndef DISABLE_PRAGMA_PACK1 30/** Code header version is decimal encoded e.g. 4.06.10 is 40601 */
44#pragma pack(push, 1) 31#define HPI_VER_DECIMAL ((int)(HPI_VER_MAJOR(HPI_VER) * 10000 + \
45#endif 32HPI_VER_MINOR(HPI_VER) * 100 + HPI_VER_RELEASE(HPI_VER)))
33
34/** Header structure for dsp firmware file
35 This structure must match that used in s2bin.c for generation of asidsp.bin
36 */
37/*#ifndef DISABLE_PRAGMA_PACK1 */
38/*#pragma pack(push, 1) */
39/*#endif */
40struct code_header {
41 /** Size in bytes including header */
42 u32 size;
43 /** File type tag "CODE" == 0x45444F43 */
44 u32 type;
45 /** Adapter model number */
46 u32 adapter;
47 /** Firmware version*/
48 u32 version;
49 /** Data checksum */
50 u32 checksum;
51};
52/*#ifndef DISABLE_PRAGMA_PACK1 */
53/*#pragma pack(pop) */
54/*#endif */
55
56/*? Don't need the pragmas? */
57compile_time_assert((sizeof(struct code_header) == 20), code_header_size);
46 58
47/** Descriptor for dspcode from firmware loader */ 59/** Descriptor for dspcode from firmware loader */
48struct dsp_code { 60struct dsp_code {
49 /** Firmware descriptor */ 61 /** copy of file header */
50 const struct firmware *ps_firmware; 62 struct code_header header;
51 struct pci_dev *ps_dev;
52 /** Expected number of words in the whole dsp code,INCL header */ 63 /** Expected number of words in the whole dsp code,INCL header */
53 long int block_length; 64 u32 block_length;
54 /** Number of words read so far */ 65 /** Number of words read so far */
55 long int word_count; 66 u32 word_count;
56 /** Version read from dsp code file */
57 u32 version;
58 /** CRC read from dsp code file */
59 u32 crc;
60};
61 67
62#ifndef DISABLE_PRAGMA_PACK1 68 /** internal state of DSP code reader */
63#pragma pack(pop) 69 struct dsp_code_private *pvt;
64#endif 70};
65 71
66/** Prepare *psDspCode to refer to the requuested adapter. 72/** Prepare *psDspCode to refer to the requested adapter's firmware.
67 Searches the file, or selects the appropriate linked array 73Code file name is obtained from HpiOs_GetDspCodePath
68 74
69\return 0 for success, or error code if requested code is not available 75\return 0 for success, or error code if requested code is not available
70*/ 76*/
71short hpi_dsp_code_open( 77short hpi_dsp_code_open(
72 /** Code identifier, usually adapter family */ 78 /** Code identifier, usually adapter family */
73 u32 adapter, 79 u32 adapter, void *pci_dev,
74 /** Pointer to DSP code control structure */ 80 /** Pointer to DSP code control structure */
75 struct dsp_code *ps_dsp_code, 81 struct dsp_code *ps_dsp_code,
76 /** Pointer to dword to receive OS specific error code */ 82 /** Pointer to dword to receive OS specific error code */
diff --git a/sound/pci/asihpi/hpifunc.c b/sound/pci/asihpi/hpifunc.c
index 7397b169b89f..ebb568d695f1 100644
--- a/sound/pci/asihpi/hpifunc.c
+++ b/sound/pci/asihpi/hpifunc.c
@@ -1663,68 +1663,64 @@ u16 hpi_channel_mode_get(u32 h_control, u16 *mode)
1663u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count, 1663u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count,
1664 u8 *pb_data) 1664 u8 *pb_data)
1665{ 1665{
1666 struct hpi_message hm; 1666 struct hpi_msg_cobranet_hmiwrite hm;
1667 struct hpi_response hr; 1667 struct hpi_response_header hr;
1668 1668
1669 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1669 hpi_init_message_responseV1(&hm.h, sizeof(hm), &hr, sizeof(hr),
1670 HPI_CONTROL_SET_STATE); 1670 HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE);
1671 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1672 return HPI_ERROR_INVALID_HANDLE;
1673 1671
1674 hm.u.cx.u.cobranet_data.byte_count = byte_count; 1672 if (hpi_handle_indexes(h_control, &hm.h.adapter_index,
1675 hm.u.cx.u.cobranet_data.hmi_address = hmi_address; 1673 &hm.h.obj_index))
1674 return HPI_ERROR_INVALID_HANDLE;
1676 1675
1677 if (byte_count <= 8) { 1676 if (byte_count > sizeof(hm.bytes))
1678 memcpy(hm.u.cx.u.cobranet_data.data, pb_data, byte_count); 1677 return HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL;
1679 hm.u.cx.attribute = HPI_COBRANET_SET;
1680 } else {
1681 hm.u.cx.u.cobranet_bigdata.pb_data = pb_data;
1682 hm.u.cx.attribute = HPI_COBRANET_SET_DATA;
1683 }
1684 1678
1685 hpi_send_recv(&hm, &hr); 1679 hm.p.attribute = HPI_COBRANET_SET;
1680 hm.p.byte_count = byte_count;
1681 hm.p.hmi_address = hmi_address;
1682 memcpy(hm.bytes, pb_data, byte_count);
1683 hm.h.size = (u16)(sizeof(hm.h) + sizeof(hm.p) + byte_count);
1686 1684
1685 hpi_send_recvV1(&hm.h, &hr);
1687 return hr.error; 1686 return hr.error;
1688} 1687}
1689 1688
1690u16 hpi_cobranet_hmi_read(u32 h_control, u32 hmi_address, u32 max_byte_count, 1689u16 hpi_cobranet_hmi_read(u32 h_control, u32 hmi_address, u32 max_byte_count,
1691 u32 *pbyte_count, u8 *pb_data) 1690 u32 *pbyte_count, u8 *pb_data)
1692{ 1691{
1693 struct hpi_message hm; 1692 struct hpi_msg_cobranet_hmiread hm;
1694 struct hpi_response hr; 1693 struct hpi_res_cobranet_hmiread hr;
1695 1694
1696 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1695 hpi_init_message_responseV1(&hm.h, sizeof(hm), &hr.h, sizeof(hr),
1697 HPI_CONTROL_GET_STATE); 1696 HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE);
1698 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index)) 1697
1698 if (hpi_handle_indexes(h_control, &hm.h.adapter_index,
1699 &hm.h.obj_index))
1699 return HPI_ERROR_INVALID_HANDLE; 1700 return HPI_ERROR_INVALID_HANDLE;
1700 1701
1701 hm.u.cx.u.cobranet_data.byte_count = max_byte_count; 1702 if (max_byte_count > sizeof(hr.bytes))
1702 hm.u.cx.u.cobranet_data.hmi_address = hmi_address; 1703 return HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
1703 1704
1704 if (max_byte_count <= 8) { 1705 hm.p.attribute = HPI_COBRANET_GET;
1705 hm.u.cx.attribute = HPI_COBRANET_GET; 1706 hm.p.byte_count = max_byte_count;
1706 } else { 1707 hm.p.hmi_address = hmi_address;
1707 hm.u.cx.u.cobranet_bigdata.pb_data = pb_data;
1708 hm.u.cx.attribute = HPI_COBRANET_GET_DATA;
1709 }
1710 1708
1711 hpi_send_recv(&hm, &hr); 1709 hpi_send_recvV1(&hm.h, &hr.h);
1712 if (!hr.error && pb_data) {
1713 1710
1714 *pbyte_count = hr.u.cx.u.cobranet_data.byte_count; 1711 if (!hr.h.error && pb_data) {
1712 if (hr.byte_count > sizeof(hr.bytes))
1715 1713
1716 if (*pbyte_count < max_byte_count) 1714 return HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
1717 max_byte_count = *pbyte_count;
1718 1715
1719 if (hm.u.cx.attribute == HPI_COBRANET_GET) { 1716 *pbyte_count = hr.byte_count;
1720 memcpy(pb_data, hr.u.cx.u.cobranet_data.data,
1721 max_byte_count);
1722 } else {
1723 1717
1724 } 1718 if (hr.byte_count < max_byte_count)
1719 max_byte_count = *pbyte_count;
1725 1720
1721 memcpy(pb_data, hr.bytes, max_byte_count);
1726 } 1722 }
1727 return hr.error; 1723 return hr.h.error;
1728} 1724}
1729 1725
1730u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus, 1726u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus,
@@ -1733,23 +1729,23 @@ u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus,
1733 struct hpi_message hm; 1729 struct hpi_message hm;
1734 struct hpi_response hr; 1730 struct hpi_response hr;
1735 1731
1736 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, 1732 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1737 HPI_CONTROL_GET_STATE); 1733 HPI_CONTROL_GET_STATE);
1738 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index)) 1734 if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1739 return HPI_ERROR_INVALID_HANDLE; 1735 return HPI_ERROR_INVALID_HANDLE;
1740 1736
1741 hm.u.cx.attribute = HPI_COBRANET_GET_STATUS; 1737 hm.u.c.attribute = HPI_COBRANET_GET_STATUS;
1742 1738
1743 hpi_send_recv(&hm, &hr); 1739 hpi_send_recv(&hm, &hr);
1744 if (!hr.error) { 1740 if (!hr.error) {
1745 if (pstatus) 1741 if (pstatus)
1746 *pstatus = hr.u.cx.u.cobranet_status.status; 1742 *pstatus = hr.u.cu.cobranet.status.status;
1747 if (preadable_size) 1743 if (preadable_size)
1748 *preadable_size = 1744 *preadable_size =
1749 hr.u.cx.u.cobranet_status.readable_size; 1745 hr.u.cu.cobranet.status.readable_size;
1750 if (pwriteable_size) 1746 if (pwriteable_size)
1751 *pwriteable_size = 1747 *pwriteable_size =
1752 hr.u.cx.u.cobranet_status.writeable_size; 1748 hr.u.cu.cobranet.status.writeable_size;
1753 } 1749 }
1754 return hr.error; 1750 return hr.error;
1755} 1751}
diff --git a/sound/pci/asihpi/hpimsginit.c b/sound/pci/asihpi/hpimsginit.c
index 628376ce4a49..52400a6b5f15 100644
--- a/sound/pci/asihpi/hpimsginit.c
+++ b/sound/pci/asihpi/hpimsginit.c
@@ -46,7 +46,7 @@ static void hpi_init_message(struct hpi_message *phm, u16 object,
46 if (gwSSX2_bypass) 46 if (gwSSX2_bypass)
47 phm->type = HPI_TYPE_SSX2BYPASS_MESSAGE; 47 phm->type = HPI_TYPE_SSX2BYPASS_MESSAGE;
48 else 48 else
49 phm->type = HPI_TYPE_MESSAGE; 49 phm->type = HPI_TYPE_REQUEST;
50 phm->object = object; 50 phm->object = object;
51 phm->function = function; 51 phm->function = function;
52 phm->version = 0; 52 phm->version = 0;
@@ -89,7 +89,7 @@ static void hpi_init_messageV1(struct hpi_message_header *phm, u16 size,
89 memset(phm, 0, sizeof(*phm)); 89 memset(phm, 0, sizeof(*phm));
90 if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) { 90 if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) {
91 phm->size = size; 91 phm->size = size;
92 phm->type = HPI_TYPE_MESSAGE; 92 phm->type = HPI_TYPE_REQUEST;
93 phm->object = object; 93 phm->object = object;
94 phm->function = function; 94 phm->function = function;
95 phm->version = 1; 95 phm->version = 1;
diff --git a/sound/pci/asihpi/hpimsgx.c b/sound/pci/asihpi/hpimsgx.c
index 7352a5f7b4f7..2e779421a618 100644
--- a/sound/pci/asihpi/hpimsgx.c
+++ b/sound/pci/asihpi/hpimsgx.c
@@ -16,7 +16,7 @@
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18
19Extended Message Function With Response Cacheing 19Extended Message Function With Response Caching
20 20
21(C) Copyright AudioScience Inc. 2002 21(C) Copyright AudioScience Inc. 2002
22*****************************************************************************/ 22*****************************************************************************/
@@ -186,7 +186,6 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr,
186 /* Initialize this module's internal state */ 186 /* Initialize this module's internal state */
187 hpios_msgxlock_init(&msgx_lock); 187 hpios_msgxlock_init(&msgx_lock);
188 memset(&hpi_entry_points, 0, sizeof(hpi_entry_points)); 188 memset(&hpi_entry_points, 0, sizeof(hpi_entry_points));
189 hpios_locked_mem_init();
190 /* Init subsys_findadapters response to no-adapters */ 189 /* Init subsys_findadapters response to no-adapters */
191 HPIMSGX__reset(HPIMSGX_ALLADAPTERS); 190 HPIMSGX__reset(HPIMSGX_ALLADAPTERS);
192 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, 191 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
@@ -197,7 +196,6 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr,
197 case HPI_SUBSYS_DRIVER_UNLOAD: 196 case HPI_SUBSYS_DRIVER_UNLOAD:
198 HPI_COMMON(phm, phr); 197 HPI_COMMON(phm, phr);
199 HPIMSGX__cleanup(HPIMSGX_ALLADAPTERS, h_owner); 198 HPIMSGX__cleanup(HPIMSGX_ALLADAPTERS, h_owner);
200 hpios_locked_mem_free_all();
201 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, 199 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
202 HPI_SUBSYS_DRIVER_UNLOAD, 0); 200 HPI_SUBSYS_DRIVER_UNLOAD, 0);
203 return; 201 return;
@@ -315,7 +313,7 @@ void hpi_send_recv_ex(struct hpi_message *phm, struct hpi_response *phr,
315{ 313{
316 HPI_DEBUG_MESSAGE(DEBUG, phm); 314 HPI_DEBUG_MESSAGE(DEBUG, phm);
317 315
318 if (phm->type != HPI_TYPE_MESSAGE) { 316 if (phm->type != HPI_TYPE_REQUEST) {
319 hpi_init_response(phr, phm->object, phm->function, 317 hpi_init_response(phr, phm->object, phm->function,
320 HPI_ERROR_INVALID_TYPE); 318 HPI_ERROR_INVALID_TYPE);
321 return; 319 return;
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index d8e7047512f8..65fcf4770731 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -157,11 +157,6 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
157 goto out; 157 goto out;
158 } 158 }
159 159
160 if (hm->h.adapter_index >= HPI_MAX_ADAPTERS) {
161 err = -EINVAL;
162 goto out;
163 }
164
165 switch (hm->h.function) { 160 switch (hm->h.function) {
166 case HPI_SUBSYS_CREATE_ADAPTER: 161 case HPI_SUBSYS_CREATE_ADAPTER:
167 case HPI_ADAPTER_DELETE: 162 case HPI_ADAPTER_DELETE:
@@ -187,7 +182,6 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
187 /* -1=no data 0=read from user mem, 1=write to user mem */ 182 /* -1=no data 0=read from user mem, 1=write to user mem */
188 int wrflag = -1; 183 int wrflag = -1;
189 u32 adapter = hm->h.adapter_index; 184 u32 adapter = hm->h.adapter_index;
190 pa = &adapters[adapter];
191 185
192 if ((adapter > HPI_MAX_ADAPTERS) || (!pa->type)) { 186 if ((adapter > HPI_MAX_ADAPTERS) || (!pa->type)) {
193 hpi_init_response(&hr->r0, HPI_OBJ_ADAPTER, 187 hpi_init_response(&hr->r0, HPI_OBJ_ADAPTER,
@@ -203,6 +197,8 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
203 goto out; 197 goto out;
204 } 198 }
205 199
200 pa = &adapters[adapter];
201
206 if (mutex_lock_interruptible(&adapters[adapter].mutex)) { 202 if (mutex_lock_interruptible(&adapters[adapter].mutex)) {
207 err = -EINTR; 203 err = -EINTR;
208 goto out; 204 goto out;
diff --git a/sound/pci/asihpi/hpios.c b/sound/pci/asihpi/hpios.c
index 742ee12a9e17..ff2a19b544fa 100644
--- a/sound/pci/asihpi/hpios.c
+++ b/sound/pci/asihpi/hpios.c
@@ -39,10 +39,6 @@ void hpios_delay_micro_seconds(u32 num_micro_sec)
39 39
40} 40}
41 41
42void hpios_locked_mem_init(void)
43{
44}
45
46/** Allocated an area of locked memory for bus master DMA operations. 42/** Allocated an area of locked memory for bus master DMA operations.
47 43
48On error, return -ENOMEM, and *pMemArea.size = 0 44On error, return -ENOMEM, and *pMemArea.size = 0
@@ -85,7 +81,3 @@ u16 hpios_locked_mem_free(struct consistent_dma_area *p_mem_area)
85 return 1; 81 return 1;
86 } 82 }
87} 83}
88
89void hpios_locked_mem_free_all(void)
90{
91}
diff --git a/sound/pci/asihpi/hpios.h b/sound/pci/asihpi/hpios.h
index 03273e729f99..2f605e34bad0 100644
--- a/sound/pci/asihpi/hpios.h
+++ b/sound/pci/asihpi/hpios.h
@@ -38,6 +38,7 @@ HPI Operating System Specific macros for Linux Kernel driver
38#include <linux/firmware.h> 38#include <linux/firmware.h>
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/pci.h> 40#include <linux/pci.h>
41#include <linux/mutex.h>
41 42
42#define HPI_NO_OS_FILE_OPS 43#define HPI_NO_OS_FILE_OPS
43 44