aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorEliot Blennerhassett <eblennerhassett@audioscience.com>2011-02-09 23:25:58 -0500
committerTakashi Iwai <tiwai@suse.de>2011-02-10 12:22:40 -0500
commit3285ea10e9b09d68da18d2f805980246ec53523a (patch)
treef6c7ccc09d07fd808357b50ddad25e5f5b4fa3c9 /sound
parentad210ad10ec96e32d32459545f54e4d3d9c6a088 (diff)
ALSA: asihpi - Interrelated HPI tidy up.
Remove many unused functions. Update some message and cache structs. Use pci info directly from pci_dev. Allow control cache elements with variable size, and handle large message/response from dsp. hpi6000 and hpi6205: fix error path when adapter bootload fails. hpimsgx.c get rid of code duplicated in hpicmn.c Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/asihpi/hpi6000.c252
-rw-r--r--sound/pci/asihpi/hpi6205.c375
-rw-r--r--sound/pci/asihpi/hpi6205.h4
-rw-r--r--sound/pci/asihpi/hpi_internal.h1022
-rw-r--r--sound/pci/asihpi/hpicmn.c406
-rw-r--r--sound/pci/asihpi/hpicmn.h9
-rw-r--r--sound/pci/asihpi/hpifunc.c985
-rw-r--r--sound/pci/asihpi/hpimsginit.c2
-rw-r--r--sound/pci/asihpi/hpimsgx.c203
-rw-r--r--sound/pci/asihpi/hpioctl.c75
-rw-r--r--sound/pci/asihpi/hpios.h4
11 files changed, 1114 insertions, 2223 deletions
diff --git a/sound/pci/asihpi/hpi6000.c b/sound/pci/asihpi/hpi6000.c
index 1b9bf9395cfe..c85db49e5ec5 100644
--- a/sound/pci/asihpi/hpi6000.c
+++ b/sound/pci/asihpi/hpi6000.c
@@ -43,16 +43,16 @@
43#define HPI_HIF_ERROR_MASK 0x4000 43#define HPI_HIF_ERROR_MASK 0x4000
44 44
45/* HPI6000 specific error codes */ 45/* HPI6000 specific error codes */
46 46#define HPI6000_ERROR_BASE 900 /* not actually used anywhere */
47#define HPI6000_ERROR_BASE 900 47/* operational/messaging errors */
48#define HPI6000_ERROR_MSG_RESP_IDLE_TIMEOUT 901 48#define HPI6000_ERROR_MSG_RESP_IDLE_TIMEOUT 901
49#define HPI6000_ERROR_MSG_RESP_SEND_MSG_ACK 902 49
50#define HPI6000_ERROR_MSG_RESP_GET_RESP_ACK 903 50#define HPI6000_ERROR_MSG_RESP_GET_RESP_ACK 903
51#define HPI6000_ERROR_MSG_GET_ADR 904 51#define HPI6000_ERROR_MSG_GET_ADR 904
52#define HPI6000_ERROR_RESP_GET_ADR 905 52#define HPI6000_ERROR_RESP_GET_ADR 905
53#define HPI6000_ERROR_MSG_RESP_BLOCKWRITE32 906 53#define HPI6000_ERROR_MSG_RESP_BLOCKWRITE32 906
54#define HPI6000_ERROR_MSG_RESP_BLOCKREAD32 907 54#define HPI6000_ERROR_MSG_RESP_BLOCKREAD32 907
55#define HPI6000_ERROR_MSG_INVALID_DSP_INDEX 908 55
56#define HPI6000_ERROR_CONTROL_CACHE_PARAMS 909 56#define HPI6000_ERROR_CONTROL_CACHE_PARAMS 909
57 57
58#define HPI6000_ERROR_SEND_DATA_IDLE_TIMEOUT 911 58#define HPI6000_ERROR_SEND_DATA_IDLE_TIMEOUT 911
@@ -62,7 +62,6 @@
62#define HPI6000_ERROR_SEND_DATA_CMD 915 62#define HPI6000_ERROR_SEND_DATA_CMD 915
63#define HPI6000_ERROR_SEND_DATA_WRITE 916 63#define HPI6000_ERROR_SEND_DATA_WRITE 916
64#define HPI6000_ERROR_SEND_DATA_IDLECMD 917 64#define HPI6000_ERROR_SEND_DATA_IDLECMD 917
65#define HPI6000_ERROR_SEND_DATA_VERIFY 918
66 65
67#define HPI6000_ERROR_GET_DATA_IDLE_TIMEOUT 921 66#define HPI6000_ERROR_GET_DATA_IDLE_TIMEOUT 921
68#define HPI6000_ERROR_GET_DATA_ACK 922 67#define HPI6000_ERROR_GET_DATA_ACK 922
@@ -76,9 +75,8 @@
76 75
77#define HPI6000_ERROR_MSG_RESP_GETRESPCMD 961 76#define HPI6000_ERROR_MSG_RESP_GETRESPCMD 961
78#define HPI6000_ERROR_MSG_RESP_IDLECMD 962 77#define HPI6000_ERROR_MSG_RESP_IDLECMD 962
79#define HPI6000_ERROR_MSG_RESP_BLOCKVERIFY32 963
80 78
81/* adapter init errors */ 79/* Initialisation/bootload errors */
82#define HPI6000_ERROR_UNHANDLED_SUBSYS_ID 930 80#define HPI6000_ERROR_UNHANDLED_SUBSYS_ID 930
83 81
84/* can't access PCI2040 */ 82/* can't access PCI2040 */
@@ -210,6 +208,8 @@ static void adapter_get_asserts(struct hpi_adapter_obj *pao,
210static short create_adapter_obj(struct hpi_adapter_obj *pao, 208static short create_adapter_obj(struct hpi_adapter_obj *pao,
211 u32 *pos_error_code); 209 u32 *pos_error_code);
212 210
211static void delete_adapter_obj(struct hpi_adapter_obj *pao);
212
213/* local globals */ 213/* local globals */
214 214
215static u16 gw_pci_read_asserts; /* used to count PCI2040 errors */ 215static u16 gw_pci_read_asserts; /* used to count PCI2040 errors */
@@ -217,17 +217,7 @@ static u16 gw_pci_write_asserts; /* used to count PCI2040 errors */
217 217
218static void subsys_message(struct hpi_message *phm, struct hpi_response *phr) 218static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
219{ 219{
220
221 switch (phm->function) { 220 switch (phm->function) {
222 case HPI_SUBSYS_OPEN:
223 case HPI_SUBSYS_CLOSE:
224 case HPI_SUBSYS_GET_INFO:
225 case HPI_SUBSYS_DRIVER_UNLOAD:
226 case HPI_SUBSYS_DRIVER_LOAD:
227 case HPI_SUBSYS_FIND_ADAPTERS:
228 /* messages that should not get here */
229 phr->error = HPI_ERROR_UNIMPLEMENTED;
230 break;
231 case HPI_SUBSYS_CREATE_ADAPTER: 221 case HPI_SUBSYS_CREATE_ADAPTER:
232 subsys_create_adapter(phm, phr); 222 subsys_create_adapter(phm, phr);
233 break; 223 break;
@@ -243,17 +233,13 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
243static void control_message(struct hpi_adapter_obj *pao, 233static void control_message(struct hpi_adapter_obj *pao,
244 struct hpi_message *phm, struct hpi_response *phr) 234 struct hpi_message *phm, struct hpi_response *phr)
245{ 235{
246
247 switch (phm->function) { 236 switch (phm->function) {
248 case HPI_CONTROL_GET_STATE: 237 case HPI_CONTROL_GET_STATE:
249 if (pao->has_control_cache) { 238 if (pao->has_control_cache) {
250 u16 err; 239 phr->error = hpi6000_update_control_cache(pao, phm);
251 err = hpi6000_update_control_cache(pao, phm);
252 240
253 if (err) { 241 if (phr->error)
254 phr->error = err;
255 break; 242 break;
256 }
257 243
258 if (hpi_check_control_cache(((struct hpi_hw_obj *) 244 if (hpi_check_control_cache(((struct hpi_hw_obj *)
259 pao->priv)->p_cache, phm, 245 pao->priv)->p_cache, phm,
@@ -262,16 +248,15 @@ static void control_message(struct hpi_adapter_obj *pao,
262 } 248 }
263 hw_message(pao, phm, phr); 249 hw_message(pao, phm, phr);
264 break; 250 break;
265 case HPI_CONTROL_GET_INFO:
266 hw_message(pao, phm, phr);
267 break;
268 case HPI_CONTROL_SET_STATE: 251 case HPI_CONTROL_SET_STATE:
269 hw_message(pao, phm, phr); 252 hw_message(pao, phm, phr);
270 hpi_sync_control_cache(((struct hpi_hw_obj *)pao->priv)-> 253 hpi_cmn_control_cache_sync_to_msg(((struct hpi_hw_obj *)pao->
271 p_cache, phm, phr); 254 priv)->p_cache, phm, phr);
272 break; 255 break;
256
257 case HPI_CONTROL_GET_INFO:
273 default: 258 default:
274 phr->error = HPI_ERROR_INVALID_FUNC; 259 hw_message(pao, phm, phr);
275 break; 260 break;
276 } 261 }
277} 262}
@@ -280,26 +265,12 @@ static void adapter_message(struct hpi_adapter_obj *pao,
280 struct hpi_message *phm, struct hpi_response *phr) 265 struct hpi_message *phm, struct hpi_response *phr)
281{ 266{
282 switch (phm->function) { 267 switch (phm->function) {
283 case HPI_ADAPTER_GET_INFO:
284 hw_message(pao, phm, phr);
285 break;
286 case HPI_ADAPTER_GET_ASSERT: 268 case HPI_ADAPTER_GET_ASSERT:
287 adapter_get_asserts(pao, phm, phr); 269 adapter_get_asserts(pao, phm, phr);
288 break; 270 break;
289 case HPI_ADAPTER_OPEN: 271
290 case HPI_ADAPTER_CLOSE:
291 case HPI_ADAPTER_TEST_ASSERT:
292 case HPI_ADAPTER_SELFTEST:
293 case HPI_ADAPTER_GET_MODE:
294 case HPI_ADAPTER_SET_MODE:
295 case HPI_ADAPTER_FIND_OBJECT:
296 case HPI_ADAPTER_GET_PROPERTY:
297 case HPI_ADAPTER_SET_PROPERTY:
298 case HPI_ADAPTER_ENUM_PROPERTY:
299 hw_message(pao, phm, phr);
300 break;
301 default: 272 default:
302 phr->error = HPI_ERROR_INVALID_FUNC; 273 hw_message(pao, phm, phr);
303 break; 274 break;
304 } 275 }
305} 276}
@@ -311,7 +282,7 @@ static void outstream_message(struct hpi_adapter_obj *pao,
311 case HPI_OSTREAM_HOSTBUFFER_ALLOC: 282 case HPI_OSTREAM_HOSTBUFFER_ALLOC:
312 case HPI_OSTREAM_HOSTBUFFER_FREE: 283 case HPI_OSTREAM_HOSTBUFFER_FREE:
313 /* Don't let these messages go to the HW function because 284 /* Don't let these messages go to the HW function because
314 * they're called without allocating the spinlock. 285 * they're called without locking the spinlock.
315 * For the HPI6000 adapters the HW would return 286 * For the HPI6000 adapters the HW would return
316 * HPI_ERROR_INVALID_FUNC anyway. 287 * HPI_ERROR_INVALID_FUNC anyway.
317 */ 288 */
@@ -331,7 +302,7 @@ static void instream_message(struct hpi_adapter_obj *pao,
331 case HPI_ISTREAM_HOSTBUFFER_ALLOC: 302 case HPI_ISTREAM_HOSTBUFFER_ALLOC:
332 case HPI_ISTREAM_HOSTBUFFER_FREE: 303 case HPI_ISTREAM_HOSTBUFFER_FREE:
333 /* Don't let these messages go to the HW function because 304 /* Don't let these messages go to the HW function because
334 * they're called without allocating the spinlock. 305 * they're called without locking the spinlock.
335 * For the HPI6000 adapters the HW would return 306 * For the HPI6000 adapters the HW would return
336 * HPI_ERROR_INVALID_FUNC anyway. 307 * HPI_ERROR_INVALID_FUNC anyway.
337 */ 308 */
@@ -355,7 +326,7 @@ void HPI_6000(struct hpi_message *phm, struct hpi_response *phr)
355 /* subsytem messages get executed by every HPI. */ 326 /* subsytem messages get executed by every HPI. */
356 /* All other messages are ignored unless the adapter index matches */ 327 /* All other messages are ignored unless the adapter index matches */
357 /* an adapter in the HPI */ 328 /* an adapter in the HPI */
358 HPI_DEBUG_LOG(DEBUG, "O %d,F %x\n", phm->object, phm->function); 329 /*HPI_DEBUG_LOG(DEBUG, "O %d,F %x\n", phm->wObject, phm->wFunction); */
359 330
360 /* if Dsp has crashed then do not communicate with it any more */ 331 /* if Dsp has crashed then do not communicate with it any more */
361 if (phm->object != HPI_OBJ_SUBSYSTEM) { 332 if (phm->object != HPI_OBJ_SUBSYSTEM) {
@@ -440,14 +411,6 @@ static void subsys_create_adapter(struct hpi_message *phm,
440 411
441 memset(&ao, 0, sizeof(ao)); 412 memset(&ao, 0, sizeof(ao));
442 413
443 /* this HPI only creates adapters for TI/PCI2040 based devices */
444 if (phm->u.s.resource.bus_type != HPI_BUS_PCI)
445 return;
446 if (phm->u.s.resource.r.pci->vendor_id != HPI_PCI_VENDOR_ID_TI)
447 return;
448 if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_PCI2040)
449 return;
450
451 ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL); 414 ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL);
452 if (!ao.priv) { 415 if (!ao.priv) {
453 HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n"); 416 HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n");
@@ -456,16 +419,13 @@ static void subsys_create_adapter(struct hpi_message *phm,
456 } 419 }
457 420
458 /* create the adapter object based on the resource information */ 421 /* create the adapter object based on the resource information */
459 /*? memcpy(&ao.Pci,&phm->u.s.Resource.r.Pci,sizeof(ao.Pci)); */
460 ao.pci = *phm->u.s.resource.r.pci; 422 ao.pci = *phm->u.s.resource.r.pci;
461 423
462 error = create_adapter_obj(&ao, &os_error_code); 424 error = create_adapter_obj(&ao, &os_error_code);
463 if (!error)
464 error = hpi_add_adapter(&ao);
465 if (error) { 425 if (error) {
466 phr->u.s.data = os_error_code; 426 delete_adapter_obj(&ao);
467 kfree(ao.priv);
468 phr->error = error; 427 phr->error = error;
428 phr->u.s.data = os_error_code;
469 return; 429 return;
470 } 430 }
471 /* need to update paParentAdapter */ 431 /* need to update paParentAdapter */
@@ -492,20 +452,13 @@ static void subsys_delete_adapter(struct hpi_message *phm,
492 struct hpi_response *phr) 452 struct hpi_response *phr)
493{ 453{
494 struct hpi_adapter_obj *pao = NULL; 454 struct hpi_adapter_obj *pao = NULL;
495 struct hpi_hw_obj *phw;
496 455
497 pao = hpi_find_adapter(phm->adapter_index); 456 pao = hpi_find_adapter(phm->obj_index);
498 if (!pao) 457 if (!pao)
499 return; 458 return;
500 459
501 phw = (struct hpi_hw_obj *)pao->priv; 460 delete_adapter_obj(pao);
502
503 if (pao->has_control_cache)
504 hpi_free_control_cache(phw->p_cache);
505
506 hpi_delete_adapter(pao); 461 hpi_delete_adapter(pao);
507 kfree(phw);
508
509 phr->error = 0; 462 phr->error = 0;
510} 463}
511 464
@@ -519,9 +472,6 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
519 u32 control_cache_count = 0; 472 u32 control_cache_count = 0;
520 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 473 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv;
521 474
522 /* init error reporting */
523 pao->dsp_crashed = 0;
524
525 /* The PCI2040 has the following address map */ 475 /* The PCI2040 has the following address map */
526 /* BAR0 - 4K = HPI control and status registers on PCI2040 (HPI CSR) */ 476 /* BAR0 - 4K = HPI control and status registers on PCI2040 (HPI CSR) */
527 /* BAR1 - 32K = HPI registers on DSP */ 477 /* BAR1 - 32K = HPI registers on DSP */
@@ -575,36 +525,36 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
575 /* get info about the adapter by asking the adapter */ 525 /* get info about the adapter by asking the adapter */
576 /* send a HPI_ADAPTER_GET_INFO message */ 526 /* send a HPI_ADAPTER_GET_INFO message */
577 { 527 {
578 struct hpi_message hM; 528 struct hpi_message hm;
579 struct hpi_response hR0; /* response from DSP 0 */ 529 struct hpi_response hr0; /* response from DSP 0 */
580 struct hpi_response hR1; /* response from DSP 1 */ 530 struct hpi_response hr1; /* response from DSP 1 */
581 u16 error = 0; 531 u16 error = 0;
582 532
583 HPI_DEBUG_LOG(VERBOSE, "send ADAPTER_GET_INFO\n"); 533 HPI_DEBUG_LOG(VERBOSE, "send ADAPTER_GET_INFO\n");
584 memset(&hM, 0, sizeof(hM)); 534 memset(&hm, 0, sizeof(hm));
585 hM.type = HPI_TYPE_MESSAGE; 535 hm.type = HPI_TYPE_MESSAGE;
586 hM.size = sizeof(struct hpi_message); 536 hm.size = sizeof(struct hpi_message);
587 hM.object = HPI_OBJ_ADAPTER; 537 hm.object = HPI_OBJ_ADAPTER;
588 hM.function = HPI_ADAPTER_GET_INFO; 538 hm.function = HPI_ADAPTER_GET_INFO;
589 hM.adapter_index = 0; 539 hm.adapter_index = 0;
590 memset(&hR0, 0, sizeof(hR0)); 540 memset(&hr0, 0, sizeof(hr0));
591 memset(&hR1, 0, sizeof(hR1)); 541 memset(&hr1, 0, sizeof(hr1));
592 hR0.size = sizeof(hR0); 542 hr0.size = sizeof(hr0);
593 hR1.size = sizeof(hR1); 543 hr1.size = sizeof(hr1);
594 544
595 error = hpi6000_message_response_sequence(pao, 0, &hM, &hR0); 545 error = hpi6000_message_response_sequence(pao, 0, &hm, &hr0);
596 if (hR0.error) { 546 if (hr0.error) {
597 HPI_DEBUG_LOG(DEBUG, "message error %d\n", hR0.error); 547 HPI_DEBUG_LOG(DEBUG, "message error %d\n", hr0.error);
598 return hR0.error; 548 return hr0.error;
599 } 549 }
600 if (phw->num_dsp == 2) { 550 if (phw->num_dsp == 2) {
601 error = hpi6000_message_response_sequence(pao, 1, &hM, 551 error = hpi6000_message_response_sequence(pao, 1, &hm,
602 &hR1); 552 &hr1);
603 if (error) 553 if (error)
604 return error; 554 return error;
605 } 555 }
606 pao->adapter_type = hR0.u.a.adapter_type; 556 pao->adapter_type = hr0.u.ax.info.adapter_type;
607 pao->index = hR0.u.a.adapter_index; 557 pao->index = hr0.u.ax.info.adapter_index;
608 } 558 }
609 559
610 memset(&phw->control_cache[0], 0, 560 memset(&phw->control_cache[0], 0,
@@ -618,22 +568,34 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
618 control_cache_count = 568 control_cache_count =
619 hpi_read_word(&phw->ado[0], 569 hpi_read_word(&phw->ado[0],
620 HPI_HIF_ADDR(control_cache_count)); 570 HPI_HIF_ADDR(control_cache_count));
621 pao->has_control_cache = 1;
622 571
623 phw->p_cache = 572 phw->p_cache =
624 hpi_alloc_control_cache(control_cache_count, 573 hpi_alloc_control_cache(control_cache_count,
625 control_cache_size, (struct hpi_control_cache_info *) 574 control_cache_size, (unsigned char *)
626 &phw->control_cache[0] 575 &phw->control_cache[0]
627 ); 576 );
628 if (!phw->p_cache) 577 if (phw->p_cache)
629 pao->has_control_cache = 0; 578 pao->has_control_cache = 1;
630 } else 579 }
631 pao->has_control_cache = 0;
632 580
633 HPI_DEBUG_LOG(DEBUG, "get adapter info ASI%04X index %d\n", 581 HPI_DEBUG_LOG(DEBUG, "get adapter info ASI%04X index %d\n",
634 pao->adapter_type, pao->index); 582 pao->adapter_type, pao->index);
635 pao->open = 0; /* upon creation the adapter is closed */ 583 pao->open = 0; /* upon creation the adapter is closed */
636 return 0; 584
585 return hpi_add_adapter(pao);
586}
587
588static void delete_adapter_obj(struct hpi_adapter_obj *pao)
589{
590 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv;
591
592 if (pao->has_control_cache)
593 hpi_free_control_cache(phw->p_cache);
594
595 /* reset DSPs on adapter */
596 iowrite32(0x0003000F, phw->dw2040_HPICSR + HPI_RESET);
597
598 kfree(phw);
637} 599}
638 600
639/************************************************************************/ 601/************************************************************************/
@@ -645,11 +607,13 @@ static void adapter_get_asserts(struct hpi_adapter_obj *pao,
645#ifndef HIDE_PCI_ASSERTS 607#ifndef HIDE_PCI_ASSERTS
646 /* if we have PCI2040 asserts then collect them */ 608 /* if we have PCI2040 asserts then collect them */
647 if ((gw_pci_read_asserts > 0) || (gw_pci_write_asserts > 0)) { 609 if ((gw_pci_read_asserts > 0) || (gw_pci_write_asserts > 0)) {
648 phr->u.a.serial_number = 610 phr->u.ax.assert.p1 =
649 gw_pci_read_asserts * 100 + gw_pci_write_asserts; 611 gw_pci_read_asserts * 100 + gw_pci_write_asserts;
650 phr->u.a.adapter_index = 1; /* assert count */ 612 phr->u.ax.assert.p2 = 0;
651 phr->u.a.adapter_type = -1; /* "dsp index" */ 613 phr->u.ax.assert.count = 1; /* assert count */
652 strcpy(phr->u.a.sz_adapter_assert, "PCI2040 error"); 614 phr->u.ax.assert.dsp_index = -1; /* "dsp index" */
615 strcpy(phr->u.ax.assert.sz_message, "PCI2040 error");
616 phr->u.ax.assert.dsp_msg_addr = 0;
653 gw_pci_read_asserts = 0; 617 gw_pci_read_asserts = 0;
654 gw_pci_write_asserts = 0; 618 gw_pci_write_asserts = 0;
655 phr->error = 0; 619 phr->error = 0;
@@ -686,10 +650,10 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
686 650
687 /* NOTE don't use wAdapterType in this routine. It is not setup yet */ 651 /* NOTE don't use wAdapterType in this routine. It is not setup yet */
688 652
689 switch (pao->pci.subsys_device_id) { 653 switch (pao->pci.pci_dev->subsystem_device) {
690 case 0x5100: 654 case 0x5100:
691 case 0x5110: /* ASI5100 revB or higher with C6711D */ 655 case 0x5110: /* ASI5100 revB or higher with C6711D */
692 case 0x5200: /* ASI5200 PC_ie version of ASI5100 */ 656 case 0x5200: /* ASI5200 PCIe version of ASI5100 */
693 case 0x6100: 657 case 0x6100:
694 case 0x6200: 658 case 0x6200:
695 boot_load_family = HPI_ADAPTER_FAMILY_ASI(0x6200); 659 boot_load_family = HPI_ADAPTER_FAMILY_ASI(0x6200);
@@ -709,8 +673,9 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
709 * note that bits 4..15 are read-only and so should always return zero, 673 * note that bits 4..15 are read-only and so should always return zero,
710 * even though we wrote 1 to them 674 * even though we wrote 1 to them
711 */ 675 */
712 for (i = 0; i < 1000; i++) 676 hpios_delay_micro_seconds(1000);
713 delay = ioread32(phw->dw2040_HPICSR + HPI_RESET); 677 delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
678
714 if (delay != dw2040_reset) { 679 if (delay != dw2040_reset) {
715 HPI_DEBUG_LOG(ERROR, "INIT_PCI2040 %x %x\n", dw2040_reset, 680 HPI_DEBUG_LOG(ERROR, "INIT_PCI2040 %x %x\n", dw2040_reset,
716 delay); 681 delay);
@@ -743,8 +708,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
743 dw2040_reset = dw2040_reset & (~0x00000008); 708 dw2040_reset = dw2040_reset & (~0x00000008);
744 iowrite32(dw2040_reset, phw->dw2040_HPICSR + HPI_RESET); 709 iowrite32(dw2040_reset, phw->dw2040_HPICSR + HPI_RESET);
745 /*delay to allow DSP to get going */ 710 /*delay to allow DSP to get going */
746 for (i = 0; i < 100; i++) 711 hpios_delay_micro_seconds(100);
747 delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
748 712
749 /* loop through all DSPs, downloading DSP code */ 713 /* loop through all DSPs, downloading DSP code */
750 for (dsp_index = 0; dsp_index < phw->num_dsp; dsp_index++) { 714 for (dsp_index = 0; dsp_index < phw->num_dsp; dsp_index++) {
@@ -783,27 +747,27 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
783 */ 747 */
784 /* bypass PLL */ 748 /* bypass PLL */
785 hpi_write_word(pdo, 0x01B7C100, 0x0000); 749 hpi_write_word(pdo, 0x01B7C100, 0x0000);
786 for (i = 0; i < 100; i++) 750 hpios_delay_micro_seconds(100);
787 delay = ioread32(phw->dw2040_HPICSR +
788 HPI_RESET);
789 751
790 /* ** use default of PLL x7 ** */ 752 /* ** use default of PLL x7 ** */
791 /* EMIF = 225/3=75MHz */ 753 /* EMIF = 225/3=75MHz */
792 hpi_write_word(pdo, 0x01B7C120, 0x8002); 754 hpi_write_word(pdo, 0x01B7C120, 0x8002);
755 hpios_delay_micro_seconds(100);
756
793 /* peri = 225/2 */ 757 /* peri = 225/2 */
794 hpi_write_word(pdo, 0x01B7C11C, 0x8001); 758 hpi_write_word(pdo, 0x01B7C11C, 0x8001);
759 hpios_delay_micro_seconds(100);
760
795 /* cpu = 225/1 */ 761 /* cpu = 225/1 */
796 hpi_write_word(pdo, 0x01B7C118, 0x8000); 762 hpi_write_word(pdo, 0x01B7C118, 0x8000);
797 /* ~200us delay */ 763
798 for (i = 0; i < 2000; i++) 764 /* ~2ms delay */
799 delay = ioread32(phw->dw2040_HPICSR + 765 hpios_delay_micro_seconds(2000);
800 HPI_RESET); 766
801 /* PLL not bypassed */ 767 /* PLL not bypassed */
802 hpi_write_word(pdo, 0x01B7C100, 0x0001); 768 hpi_write_word(pdo, 0x01B7C100, 0x0001);
803 /* ~200us delay */ 769 /* ~2ms delay */
804 for (i = 0; i < 2000; i++) 770 hpios_delay_micro_seconds(2000);
805 delay = ioread32(phw->dw2040_HPICSR +
806 HPI_RESET);
807 } 771 }
808 772
809 /* test r/w to internal DSP memory 773 /* test r/w to internal DSP memory
@@ -927,9 +891,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
927 } 891 }
928 892
929 /* delay a little to allow SDRAM and DSP to "get going" */ 893 /* delay a little to allow SDRAM and DSP to "get going" */
930 894 hpios_delay_micro_seconds(1000);
931 for (i = 0; i < 1000; i++)
932 delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
933 895
934 /* test access to SDRAM */ 896 /* test access to SDRAM */
935 { 897 {
@@ -976,7 +938,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
976 938
977 /* write the DSP code down into the DSPs memory */ 939 /* write the DSP code down into the DSPs memory */
978 /*HpiDspCode_Open(nBootLoadFamily,&DspCode,pdwOsErrorCode); */ 940 /*HpiDspCode_Open(nBootLoadFamily,&DspCode,pdwOsErrorCode); */
979 dsp_code.ps_dev = pao->pci.p_os_data; 941 dsp_code.ps_dev = pao->pci.pci_dev;
980 942
981 error = hpi_dsp_code_open(boot_load_family, &dsp_code, 943 error = hpi_dsp_code_open(boot_load_family, &dsp_code,
982 pos_error_code); 944 pos_error_code);
@@ -1073,8 +1035,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1073 1035
1074 /* step 3. Start code by sending interrupt */ 1036 /* step 3. Start code by sending interrupt */
1075 iowrite32(0x00030003, pdo->prHPI_control); 1037 iowrite32(0x00030003, pdo->prHPI_control);
1076 for (i = 0; i < 10000; i++) 1038 hpios_delay_micro_seconds(10000);
1077 delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
1078 1039
1079 /* wait for a non-zero value in hostcmd - 1040 /* wait for a non-zero value in hostcmd -
1080 * indicating initialization is complete 1041 * indicating initialization is complete
@@ -1101,7 +1062,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1101 * locks up with a bluescreen (NOT GPF or pagefault). 1062 * locks up with a bluescreen (NOT GPF or pagefault).
1102 */ 1063 */
1103 else 1064 else
1104 hpios_delay_micro_seconds(1000); 1065 hpios_delay_micro_seconds(10000);
1105 } 1066 }
1106 if (timeout == 0) 1067 if (timeout == 0)
1107 return HPI6000_ERROR_INIT_NOACK; 1068 return HPI6000_ERROR_INIT_NOACK;
@@ -1132,14 +1093,14 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1132 mask = 0xFFFFFF00L; 1093 mask = 0xFFFFFF00L;
1133 /* ASI5100 uses AX6 code, */ 1094 /* ASI5100 uses AX6 code, */
1134 /* but has no PLD r/w register to test */ 1095 /* but has no PLD r/w register to test */
1135 if (HPI_ADAPTER_FAMILY_ASI(pao->pci. 1096 if (HPI_ADAPTER_FAMILY_ASI(pao->pci.pci_dev->
1136 subsys_device_id) == 1097 subsystem_device) ==
1137 HPI_ADAPTER_FAMILY_ASI(0x5100)) 1098 HPI_ADAPTER_FAMILY_ASI(0x5100))
1138 mask = 0x00000000L; 1099 mask = 0x00000000L;
1139 /* ASI5200 uses AX6 code, */ 1100 /* ASI5200 uses AX6 code, */
1140 /* but has no PLD r/w register to test */ 1101 /* but has no PLD r/w register to test */
1141 if (HPI_ADAPTER_FAMILY_ASI(pao->pci. 1102 if (HPI_ADAPTER_FAMILY_ASI(pao->pci.pci_dev->
1142 subsys_device_id) == 1103 subsystem_device) ==
1143 HPI_ADAPTER_FAMILY_ASI(0x5200)) 1104 HPI_ADAPTER_FAMILY_ASI(0x5200))
1144 mask = 0x00000000L; 1105 mask = 0x00000000L;
1145 break; 1106 break;
@@ -1204,7 +1165,7 @@ static u32 hpi_read_word(struct dsp_obj *pdo, u32 address)
1204 u32 data = 0; 1165 u32 data = 0;
1205 1166
1206 if (hpi_set_address(pdo, address)) 1167 if (hpi_set_address(pdo, address))
1207 return 0; /*? no way to return error */ 1168 return 0; /*? No way to return error */
1208 1169
1209 /* take care of errata in revB DSP (2.0.1) */ 1170 /* take care of errata in revB DSP (2.0.1) */
1210 data = ioread32(pdo->prHPI_data); 1171 data = ioread32(pdo->prHPI_data);
@@ -1340,10 +1301,6 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1340 u32 *p_data; 1301 u32 *p_data;
1341 u16 error = 0; 1302 u16 error = 0;
1342 1303
1343 /* does the DSP we are referencing exist? */
1344 if (dsp_index >= phw->num_dsp)
1345 return HPI6000_ERROR_MSG_INVALID_DSP_INDEX;
1346
1347 ack = hpi6000_wait_dsp_ack(pao, dsp_index, HPI_HIF_IDLE); 1304 ack = hpi6000_wait_dsp_ack(pao, dsp_index, HPI_HIF_IDLE);
1348 if (ack & HPI_HIF_ERROR_MASK) { 1305 if (ack & HPI_HIF_ERROR_MASK) {
1349 pao->dsp_crashed++; 1306 pao->dsp_crashed++;
@@ -1351,9 +1308,7 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1351 } 1308 }
1352 pao->dsp_crashed = 0; 1309 pao->dsp_crashed = 0;
1353 1310
1354 /* send the message */ 1311 /* get the message address and size */
1355
1356 /* get the address and size */
1357 if (phw->message_buffer_address_on_dsp == 0) { 1312 if (phw->message_buffer_address_on_dsp == 0) {
1358 timeout = TIMEOUT; 1313 timeout = TIMEOUT;
1359 do { 1314 do {
@@ -1368,10 +1323,9 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1368 } else 1323 } else
1369 address = phw->message_buffer_address_on_dsp; 1324 address = phw->message_buffer_address_on_dsp;
1370 1325
1371 /* dwLength = sizeof(struct hpi_message); */
1372 length = phm->size; 1326 length = phm->size;
1373 1327
1374 /* send it */ 1328 /* send the message */
1375 p_data = (u32 *)phm; 1329 p_data = (u32 *)phm;
1376 if (hpi6000_dsp_block_write32(pao, dsp_index, address, p_data, 1330 if (hpi6000_dsp_block_write32(pao, dsp_index, address, p_data,
1377 (u16)length / 4)) 1331 (u16)length / 4))
@@ -1385,7 +1339,7 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1385 if (ack & HPI_HIF_ERROR_MASK) 1339 if (ack & HPI_HIF_ERROR_MASK)
1386 return HPI6000_ERROR_MSG_RESP_GET_RESP_ACK; 1340 return HPI6000_ERROR_MSG_RESP_GET_RESP_ACK;
1387 1341
1388 /* get the address and size */ 1342 /* get the response address */
1389 if (phw->response_buffer_address_on_dsp == 0) { 1343 if (phw->response_buffer_address_on_dsp == 0) {
1390 timeout = TIMEOUT; 1344 timeout = TIMEOUT;
1391 do { 1345 do {
@@ -1409,7 +1363,7 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1409 if (!timeout) 1363 if (!timeout)
1410 length = sizeof(struct hpi_response); 1364 length = sizeof(struct hpi_response);
1411 1365
1412 /* get it */ 1366 /* get the response */
1413 p_data = (u32 *)phr; 1367 p_data = (u32 *)phr;
1414 if (hpi6000_dsp_block_read32(pao, dsp_index, address, p_data, 1368 if (hpi6000_dsp_block_read32(pao, dsp_index, address, p_data,
1415 (u16)length / 4)) 1369 (u16)length / 4))
@@ -1827,13 +1781,13 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm,
1827 error = hpi6000_get_data(pao, dsp_index, phm, phr); 1781 error = hpi6000_get_data(pao, dsp_index, phm, phr);
1828 break; 1782 break;
1829 case HPI_ADAPTER_GET_ASSERT: 1783 case HPI_ADAPTER_GET_ASSERT:
1830 phr->u.a.adapter_index = 0; /* dsp 0 default */ 1784 phr->u.ax.assert.dsp_index = 0; /* dsp 0 default */
1831 if (num_dsp == 2) { 1785 if (num_dsp == 2) {
1832 if (!phr->u.a.adapter_type) { 1786 if (!phr->u.ax.assert.count) {
1833 /* no assert from dsp 0, check dsp 1 */ 1787 /* no assert from dsp 0, check dsp 1 */
1834 error = hpi6000_message_response_sequence(pao, 1788 error = hpi6000_message_response_sequence(pao,
1835 1, phm, phr); 1789 1, phm, phr);
1836 phr->u.a.adapter_index = 1; 1790 phr->u.ax.assert.dsp_index = 1;
1837 } 1791 }
1838 } 1792 }
1839 } 1793 }
diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c
index 2672f6591ceb..b740edc29b1c 100644
--- a/sound/pci/asihpi/hpi6205.c
+++ b/sound/pci/asihpi/hpi6205.c
@@ -38,27 +38,26 @@
38 38
39/*****************************************************************************/ 39/*****************************************************************************/
40/* HPI6205 specific error codes */ 40/* HPI6205 specific error codes */
41#define HPI6205_ERROR_BASE 1000 41#define HPI6205_ERROR_BASE 1000 /* not actually used anywhere */
42/*#define HPI6205_ERROR_MEM_ALLOC 1001 */ 42
43/* operational/messaging errors */
44#define HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT 1015
45#define HPI6205_ERROR_MSG_RESP_TIMEOUT 1016
46
47/* initialization/bootload errors */
43#define HPI6205_ERROR_6205_NO_IRQ 1002 48#define HPI6205_ERROR_6205_NO_IRQ 1002
44#define HPI6205_ERROR_6205_INIT_FAILED 1003 49#define HPI6205_ERROR_6205_INIT_FAILED 1003
45/*#define HPI6205_ERROR_MISSING_DSPCODE 1004 */
46#define HPI6205_ERROR_UNKNOWN_PCI_DEVICE 1005
47#define HPI6205_ERROR_6205_REG 1006 50#define HPI6205_ERROR_6205_REG 1006
48#define HPI6205_ERROR_6205_DSPPAGE 1007 51#define HPI6205_ERROR_6205_DSPPAGE 1007
49#define HPI6205_ERROR_BAD_DSPINDEX 1008
50#define HPI6205_ERROR_C6713_HPIC 1009 52#define HPI6205_ERROR_C6713_HPIC 1009
51#define HPI6205_ERROR_C6713_HPIA 1010 53#define HPI6205_ERROR_C6713_HPIA 1010
52#define HPI6205_ERROR_C6713_PLL 1011 54#define HPI6205_ERROR_C6713_PLL 1011
53#define HPI6205_ERROR_DSP_INTMEM 1012 55#define HPI6205_ERROR_DSP_INTMEM 1012
54#define HPI6205_ERROR_DSP_EXTMEM 1013 56#define HPI6205_ERROR_DSP_EXTMEM 1013
55#define HPI6205_ERROR_DSP_PLD 1014 57#define HPI6205_ERROR_DSP_PLD 1014
56#define HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT 1015
57#define HPI6205_ERROR_MSG_RESP_TIMEOUT 1016
58#define HPI6205_ERROR_6205_EEPROM 1017 58#define HPI6205_ERROR_6205_EEPROM 1017
59#define HPI6205_ERROR_DSP_EMIF 1018 59#define HPI6205_ERROR_DSP_EMIF 1018
60 60
61#define hpi6205_error(dsp_index, err) (err)
62/*****************************************************************************/ 61/*****************************************************************************/
63/* for C6205 PCI i/f */ 62/* for C6205 PCI i/f */
64/* Host Status Register (HSR) bitfields */ 63/* Host Status Register (HSR) bitfields */
@@ -208,8 +207,8 @@ static void instream_start(struct hpi_adapter_obj *pao,
208static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index, 207static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index,
209 u32 address); 208 u32 address);
210 209
211static u16 boot_loader_write_mem32(struct hpi_adapter_obj *pao, int dsp_index, 210static void boot_loader_write_mem32(struct hpi_adapter_obj *pao,
212 u32 address, u32 data); 211 int dsp_index, u32 address, u32 data);
213 212
214static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, 213static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao,
215 int dsp_index); 214 int dsp_index);
@@ -229,17 +228,7 @@ static u16 boot_loader_test_pld(struct hpi_adapter_obj *pao, int dsp_index);
229 228
230static void subsys_message(struct hpi_message *phm, struct hpi_response *phr) 229static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
231{ 230{
232
233 switch (phm->function) { 231 switch (phm->function) {
234 case HPI_SUBSYS_OPEN:
235 case HPI_SUBSYS_CLOSE:
236 case HPI_SUBSYS_GET_INFO:
237 case HPI_SUBSYS_DRIVER_UNLOAD:
238 case HPI_SUBSYS_DRIVER_LOAD:
239 case HPI_SUBSYS_FIND_ADAPTERS:
240 /* messages that should not get here */
241 phr->error = HPI_ERROR_UNIMPLEMENTED;
242 break;
243 case HPI_SUBSYS_CREATE_ADAPTER: 232 case HPI_SUBSYS_CREATE_ADAPTER:
244 subsys_create_adapter(phm, phr); 233 subsys_create_adapter(phm, phr);
245 break; 234 break;
@@ -257,15 +246,22 @@ static void control_message(struct hpi_adapter_obj *pao,
257{ 246{
258 247
259 struct hpi_hw_obj *phw = pao->priv; 248 struct hpi_hw_obj *phw = pao->priv;
249 u16 pending_cache_error = 0;
260 250
261 switch (phm->function) { 251 switch (phm->function) {
262 case HPI_CONTROL_GET_STATE: 252 case HPI_CONTROL_GET_STATE:
263 if (pao->has_control_cache) { 253 if (pao->has_control_cache) {
264 rmb(); /* make sure we see updates DM_aed from DSP */ 254 rmb(); /* make sure we see updates DMAed from DSP */
265 if (hpi_check_control_cache(phw->p_cache, phm, phr)) 255 if (hpi_check_control_cache(phw->p_cache, phm, phr)) {
266 break; 256 break;
257 } else if (phm->u.c.attribute == HPI_METER_PEAK) {
258 pending_cache_error =
259 HPI_ERROR_CONTROL_CACHING;
260 }
267 } 261 }
268 hw_message(pao, phm, phr); 262 hw_message(pao, phm, phr);
263 if (pending_cache_error && !phr->error)
264 phr->error = pending_cache_error;
269 break; 265 break;
270 case HPI_CONTROL_GET_INFO: 266 case HPI_CONTROL_GET_INFO:
271 hw_message(pao, phm, phr); 267 hw_message(pao, phm, phr);
@@ -273,7 +269,8 @@ static void control_message(struct hpi_adapter_obj *pao,
273 case HPI_CONTROL_SET_STATE: 269 case HPI_CONTROL_SET_STATE:
274 hw_message(pao, phm, phr); 270 hw_message(pao, phm, phr);
275 if (pao->has_control_cache) 271 if (pao->has_control_cache)
276 hpi_sync_control_cache(phw->p_cache, phm, phr); 272 hpi_cmn_control_cache_sync_to_msg(phw->p_cache, phm,
273 phr);
277 break; 274 break;
278 default: 275 default:
279 phr->error = HPI_ERROR_INVALID_FUNC; 276 phr->error = HPI_ERROR_INVALID_FUNC;
@@ -298,7 +295,7 @@ static void outstream_message(struct hpi_adapter_obj *pao,
298 if (phm->obj_index >= HPI_MAX_STREAMS) { 295 if (phm->obj_index >= HPI_MAX_STREAMS) {
299 phr->error = HPI_ERROR_INVALID_STREAM; 296 phr->error = HPI_ERROR_INVALID_STREAM;
300 HPI_DEBUG_LOG(WARNING, 297 HPI_DEBUG_LOG(WARNING,
301 "message referencing invalid stream %d " 298 "Message referencing invalid stream %d "
302 "on adapter index %d\n", phm->obj_index, 299 "on adapter index %d\n", phm->obj_index,
303 phm->adapter_index); 300 phm->adapter_index);
304 return; 301 return;
@@ -342,7 +339,7 @@ static void instream_message(struct hpi_adapter_obj *pao,
342 if (phm->obj_index >= HPI_MAX_STREAMS) { 339 if (phm->obj_index >= HPI_MAX_STREAMS) {
343 phr->error = HPI_ERROR_INVALID_STREAM; 340 phr->error = HPI_ERROR_INVALID_STREAM;
344 HPI_DEBUG_LOG(WARNING, 341 HPI_DEBUG_LOG(WARNING,
345 "message referencing invalid stream %d " 342 "Message referencing invalid stream %d "
346 "on adapter index %d\n", phm->obj_index, 343 "on adapter index %d\n", phm->obj_index,
347 phm->adapter_index); 344 phm->adapter_index);
348 return; 345 return;
@@ -385,8 +382,8 @@ void HPI_6205(struct hpi_message *phm, struct hpi_response *phr)
385 * All other messages are ignored unless the adapter index matches 382 * All other messages are ignored unless the adapter index matches
386 * an adapter in the HPI 383 * an adapter in the HPI
387 */ 384 */
388 HPI_DEBUG_LOG(DEBUG, "HPI obj=%d, func=%d\n", phm->object, 385 /* HPI_DEBUG_LOG(DEBUG, "HPI Obj=%d, Func=%d\n", phm->wObject,
389 phm->function); 386 phm->wFunction); */
390 387
391 /* if Dsp has crashed then do not communicate with it any more */ 388 /* if Dsp has crashed then do not communicate with it any more */
392 if (phm->object != HPI_OBJ_SUBSYSTEM) { 389 if (phm->object != HPI_OBJ_SUBSYSTEM) {
@@ -411,8 +408,7 @@ void HPI_6205(struct hpi_message *phm, struct hpi_response *phr)
411 408
412 /* Init default response */ 409 /* Init default response */
413 if (phm->function != HPI_SUBSYS_CREATE_ADAPTER) 410 if (phm->function != HPI_SUBSYS_CREATE_ADAPTER)
414 hpi_init_response(phr, phm->object, phm->function, 411 phr->error = HPI_ERROR_PROCESSING_MESSAGE;
415 HPI_ERROR_PROCESSING_MESSAGE);
416 412
417 HPI_DEBUG_LOG(VERBOSE, "start of switch\n"); 413 HPI_DEBUG_LOG(VERBOSE, "start of switch\n");
418 switch (phm->type) { 414 switch (phm->type) {
@@ -423,9 +419,6 @@ void HPI_6205(struct hpi_message *phm, struct hpi_response *phr)
423 break; 419 break;
424 420
425 case HPI_OBJ_ADAPTER: 421 case HPI_OBJ_ADAPTER:
426 phr->size =
427 sizeof(struct hpi_response_header) +
428 sizeof(struct hpi_adapter_res);
429 adapter_message(pao, phm, phr); 422 adapter_message(pao, phm, phr);
430 break; 423 break;
431 424
@@ -474,14 +467,6 @@ static void subsys_create_adapter(struct hpi_message *phm,
474 467
475 memset(&ao, 0, sizeof(ao)); 468 memset(&ao, 0, sizeof(ao));
476 469
477 /* this HPI only creates adapters for TI/PCI devices */
478 if (phm->u.s.resource.bus_type != HPI_BUS_PCI)
479 return;
480 if (phm->u.s.resource.r.pci->vendor_id != HPI_PCI_VENDOR_ID_TI)
481 return;
482 if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_DSP6205)
483 return;
484
485 ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL); 470 ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL);
486 if (!ao.priv) { 471 if (!ao.priv) {
487 HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n"); 472 HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n");
@@ -491,12 +476,10 @@ static void subsys_create_adapter(struct hpi_message *phm,
491 476
492 ao.pci = *phm->u.s.resource.r.pci; 477 ao.pci = *phm->u.s.resource.r.pci;
493 err = create_adapter_obj(&ao, &os_error_code); 478 err = create_adapter_obj(&ao, &os_error_code);
494 if (!err)
495 err = hpi_add_adapter(&ao);
496 if (err) { 479 if (err) {
497 phr->u.s.data = os_error_code;
498 delete_adapter_obj(&ao); 480 delete_adapter_obj(&ao);
499 phr->error = err; 481 phr->error = err;
482 phr->u.s.data = os_error_code;
500 return; 483 return;
501 } 484 }
502 485
@@ -513,7 +496,7 @@ static void subsys_delete_adapter(struct hpi_message *phm,
513 struct hpi_adapter_obj *pao; 496 struct hpi_adapter_obj *pao;
514 struct hpi_hw_obj *phw; 497 struct hpi_hw_obj *phw;
515 498
516 pao = hpi_find_adapter(phm->adapter_index); 499 pao = hpi_find_adapter(phm->obj_index);
517 if (!pao) { 500 if (!pao) {
518 phr->error = HPI_ERROR_INVALID_OBJ_INDEX; 501 phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
519 return; 502 return;
@@ -526,6 +509,7 @@ static void subsys_delete_adapter(struct hpi_message *phm,
526 iowrite32(C6205_HDCR_WARMRESET, phw->prHDCR); 509 iowrite32(C6205_HDCR_WARMRESET, phw->prHDCR);
527 510
528 delete_adapter_obj(pao); 511 delete_adapter_obj(pao);
512 hpi_delete_adapter(pao);
529 phr->error = 0; 513 phr->error = 0;
530} 514}
531 515
@@ -566,7 +550,7 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
566 550
567 if (hpios_locked_mem_alloc(&phw->h_locked_mem, 551 if (hpios_locked_mem_alloc(&phw->h_locked_mem,
568 sizeof(struct bus_master_interface), 552 sizeof(struct bus_master_interface),
569 pao->pci.p_os_data)) 553 pao->pci.pci_dev))
570 phw->p_interface_buffer = NULL; 554 phw->p_interface_buffer = NULL;
571 else if (hpios_locked_mem_get_virt_addr(&phw->h_locked_mem, 555 else if (hpios_locked_mem_get_virt_addr(&phw->h_locked_mem,
572 (void *)&phw->p_interface_buffer)) 556 (void *)&phw->p_interface_buffer))
@@ -591,7 +575,7 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
591 575
592 /* allow boot load even if mem alloc wont work */ 576 /* allow boot load even if mem alloc wont work */
593 if (!phw->p_interface_buffer) 577 if (!phw->p_interface_buffer)
594 return hpi6205_error(0, HPI_ERROR_MEMORY_ALLOC); 578 return HPI_ERROR_MEMORY_ALLOC;
595 579
596 interface = phw->p_interface_buffer; 580 interface = phw->p_interface_buffer;
597 581
@@ -604,12 +588,12 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
604 588
605 if (temp1 & C6205_HSR_INTSRC) 589 if (temp1 & C6205_HSR_INTSRC)
606 HPI_DEBUG_LOG(INFO, 590 HPI_DEBUG_LOG(INFO,
607 "interrupt confirming DSP code running OK\n"); 591 "Interrupt confirming DSP code running OK\n");
608 else { 592 else {
609 HPI_DEBUG_LOG(ERROR, 593 HPI_DEBUG_LOG(ERROR,
610 "timed out waiting for interrupt " 594 "Timed out waiting for interrupt "
611 "confirming DSP code running\n"); 595 "confirming DSP code running\n");
612 return hpi6205_error(0, HPI6205_ERROR_6205_NO_IRQ); 596 return HPI6205_ERROR_6205_NO_IRQ;
613 } 597 }
614 598
615 /* reset the interrupt */ 599 /* reset the interrupt */
@@ -619,21 +603,22 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
619 /* make sure the DSP has started ok */ 603 /* make sure the DSP has started ok */
620 if (!wait_dsp_ack(phw, H620_HIF_RESET, HPI6205_TIMEOUT * 10)) { 604 if (!wait_dsp_ack(phw, H620_HIF_RESET, HPI6205_TIMEOUT * 10)) {
621 HPI_DEBUG_LOG(ERROR, "timed out waiting reset state \n"); 605 HPI_DEBUG_LOG(ERROR, "timed out waiting reset state \n");
622 return hpi6205_error(0, HPI6205_ERROR_6205_INIT_FAILED); 606 return HPI6205_ERROR_6205_INIT_FAILED;
623 } 607 }
624 /* Note that *pao, *phw are zeroed after allocation, 608 /* Note that *pao, *phw are zeroed after allocation,
625 * so pointers and flags are NULL by default. 609 * so pointers and flags are NULL by default.
626 * Allocate bus mastering control cache buffer and tell the DSP about it 610 * Allocate bus mastering control cache buffer and tell the DSP about it
627 */ 611 */
628 if (interface->control_cache.number_of_controls) { 612 if (interface->control_cache.number_of_controls) {
629 void *p_control_cache_virtual; 613 u8 *p_control_cache_virtual;
630 614
631 err = hpios_locked_mem_alloc(&phw->h_control_cache, 615 err = hpios_locked_mem_alloc(&phw->h_control_cache,
632 interface->control_cache.size_in_bytes, 616 interface->control_cache.size_in_bytes,
633 pao->pci.p_os_data); 617 pao->pci.pci_dev);
634 if (!err) 618 if (!err)
635 err = hpios_locked_mem_get_virt_addr(&phw-> 619 err = hpios_locked_mem_get_virt_addr(&phw->
636 h_control_cache, &p_control_cache_virtual); 620 h_control_cache,
621 (void *)&p_control_cache_virtual);
637 if (!err) { 622 if (!err) {
638 memset(p_control_cache_virtual, 0, 623 memset(p_control_cache_virtual, 0,
639 interface->control_cache.size_in_bytes); 624 interface->control_cache.size_in_bytes);
@@ -642,7 +627,6 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
642 hpi_alloc_control_cache(interface-> 627 hpi_alloc_control_cache(interface->
643 control_cache.number_of_controls, 628 control_cache.number_of_controls,
644 interface->control_cache.size_in_bytes, 629 interface->control_cache.size_in_bytes,
645 (struct hpi_control_cache_info *)
646 p_control_cache_virtual); 630 p_control_cache_virtual);
647 if (!phw->p_cache) 631 if (!phw->p_cache)
648 err = HPI_ERROR_MEMORY_ALLOC; 632 err = HPI_ERROR_MEMORY_ALLOC;
@@ -666,7 +650,7 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
666 if (interface->async_buffer.b.size) { 650 if (interface->async_buffer.b.size) {
667 err = hpios_locked_mem_alloc(&phw->h_async_event_buffer, 651 err = hpios_locked_mem_alloc(&phw->h_async_event_buffer,
668 interface->async_buffer.b.size * 652 interface->async_buffer.b.size *
669 sizeof(struct hpi_async_event), pao->pci.p_os_data); 653 sizeof(struct hpi_async_event), pao->pci.pci_dev);
670 if (!err) 654 if (!err)
671 err = hpios_locked_mem_get_virt_addr 655 err = hpios_locked_mem_get_virt_addr
672 (&phw->h_async_event_buffer, (void *) 656 (&phw->h_async_event_buffer, (void *)
@@ -693,47 +677,50 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
693 send_dsp_command(phw, H620_HIF_IDLE); 677 send_dsp_command(phw, H620_HIF_IDLE);
694 678
695 { 679 {
696 struct hpi_message hM; 680 struct hpi_message hm;
697 struct hpi_response hR; 681 struct hpi_response hr;
698 u32 max_streams; 682 u32 max_streams;
699 683
700 HPI_DEBUG_LOG(VERBOSE, "init ADAPTER_GET_INFO\n"); 684 HPI_DEBUG_LOG(VERBOSE, "init ADAPTER_GET_INFO\n");
701 memset(&hM, 0, sizeof(hM)); 685 memset(&hm, 0, sizeof(hm));
702 hM.type = HPI_TYPE_MESSAGE; 686 hm.type = HPI_TYPE_MESSAGE;
703 hM.size = sizeof(hM); 687 hm.size = sizeof(hm);
704 hM.object = HPI_OBJ_ADAPTER; 688 hm.object = HPI_OBJ_ADAPTER;
705 hM.function = HPI_ADAPTER_GET_INFO; 689 hm.function = HPI_ADAPTER_GET_INFO;
706 hM.adapter_index = 0; 690 hm.adapter_index = 0;
707 memset(&hR, 0, sizeof(hR)); 691 memset(&hr, 0, sizeof(hr));
708 hR.size = sizeof(hR); 692 hr.size = sizeof(hr);
709 693
710 err = message_response_sequence(pao, &hM, &hR); 694 err = message_response_sequence(pao, &hm, &hr);
711 if (err) { 695 if (err) {
712 HPI_DEBUG_LOG(ERROR, "message transport error %d\n", 696 HPI_DEBUG_LOG(ERROR, "message transport error %d\n",
713 err); 697 err);
714 return err; 698 return err;
715 } 699 }
716 if (hR.error) 700 if (hr.error)
717 return hR.error; 701 return hr.error;
718 702
719 pao->adapter_type = hR.u.a.adapter_type; 703 pao->adapter_type = hr.u.ax.info.adapter_type;
720 pao->index = hR.u.a.adapter_index; 704 pao->index = hr.u.ax.info.adapter_index;
721 705
722 max_streams = hR.u.a.num_outstreams + hR.u.a.num_instreams; 706 max_streams =
707 hr.u.ax.info.num_outstreams +
708 hr.u.ax.info.num_instreams;
723 709
724 hpios_locked_mem_prepare((max_streams * 6) / 10, max_streams, 710 hpios_locked_mem_prepare((max_streams * 6) / 10, max_streams,
725 65536, pao->pci.p_os_data); 711 65536, pao->pci.pci_dev);
726 712
727 HPI_DEBUG_LOG(VERBOSE, 713 HPI_DEBUG_LOG(VERBOSE,
728 "got adapter info type %x index %d serial %d\n", 714 "got adapter info type %x index %d serial %d\n",
729 hR.u.a.adapter_type, hR.u.a.adapter_index, 715 hr.u.ax.info.adapter_type, hr.u.ax.info.adapter_index,
730 hR.u.a.serial_number); 716 hr.u.ax.info.serial_number);
731 } 717 }
732 718
733 pao->open = 0; /* upon creation the adapter is closed */ 719 pao->open = 0; /* upon creation the adapter is closed */
734 720
735 HPI_DEBUG_LOG(INFO, "bootload DSP OK\n"); 721 HPI_DEBUG_LOG(INFO, "bootload DSP OK\n");
736 return 0; 722
723 return hpi_add_adapter(pao);
737} 724}
738 725
739/** Free memory areas allocated by adapter 726/** Free memory areas allocated by adapter
@@ -776,9 +763,8 @@ static void delete_adapter_obj(struct hpi_adapter_obj *pao)
776 phw->outstream_host_buffer_size[i] = 0; 763 phw->outstream_host_buffer_size[i] = 0;
777 } 764 }
778 765
779 hpios_locked_mem_unprepare(pao->pci.p_os_data); 766 hpios_locked_mem_unprepare(pao->pci.pci_dev);
780 767
781 hpi_delete_adapter(pao);
782 kfree(phw); 768 kfree(phw);
783} 769}
784 770
@@ -824,7 +810,7 @@ static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao,
824 810
825 err = hpios_locked_mem_alloc(&phw->outstream_host_buffers 811 err = hpios_locked_mem_alloc(&phw->outstream_host_buffers
826 [phm->obj_index], phm->u.d.u.buffer.buffer_size, 812 [phm->obj_index], phm->u.d.u.buffer.buffer_size,
827 pao->pci.p_os_data); 813 pao->pci.pci_dev);
828 814
829 if (err) { 815 if (err) {
830 phr->error = HPI_ERROR_INVALID_DATASIZE; 816 phr->error = HPI_ERROR_INVALID_DATASIZE;
@@ -861,7 +847,7 @@ static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao,
861 if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer. 847 if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer.
862 buffer_size - 1)) { 848 buffer_size - 1)) {
863 HPI_DEBUG_LOG(ERROR, 849 HPI_DEBUG_LOG(ERROR,
864 "buffer size must be 2^N not %d\n", 850 "Buffer size must be 2^N not %d\n",
865 phm->u.d.u.buffer.buffer_size); 851 phm->u.d.u.buffer.buffer_size);
866 phr->error = HPI_ERROR_INVALID_DATASIZE; 852 phr->error = HPI_ERROR_INVALID_DATASIZE;
867 return; 853 return;
@@ -966,51 +952,6 @@ static void outstream_write(struct hpi_adapter_obj *pao,
966 hpi_init_response(phr, phm->object, phm->function, 0); 952 hpi_init_response(phr, phm->object, phm->function, 0);
967 status = &interface->outstream_host_buffer_status[phm->obj_index]; 953 status = &interface->outstream_host_buffer_status[phm->obj_index];
968 954
969 if (phw->flag_outstream_just_reset[phm->obj_index]) {
970 /* First OutStremWrite() call following reset will write data to the
971 adapter's buffers, reducing delay before stream can start. The DSP
972 takes care of setting the stream data format using format information
973 embedded in phm.
974 */
975 int partial_write = 0;
976 unsigned int original_size = 0;
977
978 phw->flag_outstream_just_reset[phm->obj_index] = 0;
979
980 /* Send the first buffer to the DSP the old way. */
981 /* Limit size of first transfer - */
982 /* expect that this will not usually be triggered. */
983 if (phm->u.d.u.data.data_size > HPI6205_SIZEOF_DATA) {
984 partial_write = 1;
985 original_size = phm->u.d.u.data.data_size;
986 phm->u.d.u.data.data_size = HPI6205_SIZEOF_DATA;
987 }
988 /* write it */
989 phm->function = HPI_OSTREAM_WRITE;
990 hw_message(pao, phm, phr);
991
992 if (phr->error)
993 return;
994
995 /* update status information that the DSP would typically
996 * update (and will update next time the DSP
997 * buffer update task reads data from the host BBM buffer)
998 */
999 status->auxiliary_data_available = phm->u.d.u.data.data_size;
1000 status->host_index += phm->u.d.u.data.data_size;
1001 status->dSP_index += phm->u.d.u.data.data_size;
1002
1003 /* if we did a full write, we can return from here. */
1004 if (!partial_write)
1005 return;
1006
1007 /* tweak buffer parameters and let the rest of the */
1008 /* buffer land in internal BBM buffer */
1009 phm->u.d.u.data.data_size =
1010 original_size - HPI6205_SIZEOF_DATA;
1011 phm->u.d.u.data.pb_data += HPI6205_SIZEOF_DATA;
1012 }
1013
1014 space_available = outstream_get_space_available(status); 955 space_available = outstream_get_space_available(status);
1015 if (space_available < phm->u.d.u.data.data_size) { 956 if (space_available < phm->u.d.u.data.data_size) {
1016 phr->error = HPI_ERROR_INVALID_DATASIZE; 957 phr->error = HPI_ERROR_INVALID_DATASIZE;
@@ -1047,6 +988,24 @@ static void outstream_write(struct hpi_adapter_obj *pao,
1047 memcpy(p_bbm_data, p_app_data + l_first_write, 988 memcpy(p_bbm_data, p_app_data + l_first_write,
1048 phm->u.d.u.data.data_size - l_first_write); 989 phm->u.d.u.data.data_size - l_first_write);
1049 } 990 }
991
992 /*
993 * This version relies on the DSP code triggering an OStream buffer
994 * update immediately following a SET_FORMAT call. The host has
995 * already written data into the BBM buffer, but the DSP won't know about
996 * it until dwHostIndex is adjusted.
997 */
998 if (phw->flag_outstream_just_reset[phm->obj_index]) {
999 /* Format can only change after reset. Must tell DSP. */
1000 u16 function = phm->function;
1001 phw->flag_outstream_just_reset[phm->obj_index] = 0;
1002 phm->function = HPI_OSTREAM_SET_FORMAT;
1003 hw_message(pao, phm, phr); /* send the format to the DSP */
1004 phm->function = function;
1005 if (phr->error)
1006 return;
1007 }
1008
1050 status->host_index += phm->u.d.u.data.data_size; 1009 status->host_index += phm->u.d.u.data.data_size;
1051} 1010}
1052 1011
@@ -1132,7 +1091,7 @@ static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao,
1132 1091
1133 err = hpios_locked_mem_alloc(&phw->instream_host_buffers[phm-> 1092 err = hpios_locked_mem_alloc(&phw->instream_host_buffers[phm->
1134 obj_index], phm->u.d.u.buffer.buffer_size, 1093 obj_index], phm->u.d.u.buffer.buffer_size,
1135 pao->pci.p_os_data); 1094 pao->pci.pci_dev);
1136 1095
1137 if (err) { 1096 if (err) {
1138 phr->error = HPI_ERROR_INVALID_DATASIZE; 1097 phr->error = HPI_ERROR_INVALID_DATASIZE;
@@ -1163,7 +1122,7 @@ static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao,
1163 if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer. 1122 if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer.
1164 buffer_size - 1)) { 1123 buffer_size - 1)) {
1165 HPI_DEBUG_LOG(ERROR, 1124 HPI_DEBUG_LOG(ERROR,
1166 "buffer size must be 2^N not %d\n", 1125 "Buffer size must be 2^N not %d\n",
1167 phm->u.d.u.buffer.buffer_size); 1126 phm->u.d.u.buffer.buffer_size);
1168 phr->error = HPI_ERROR_INVALID_DATASIZE; 1127 phr->error = HPI_ERROR_INVALID_DATASIZE;
1169 return; 1128 return;
@@ -1344,7 +1303,7 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1344 struct hpi_hw_obj *phw = pao->priv; 1303 struct hpi_hw_obj *phw = pao->priv;
1345 struct dsp_code dsp_code; 1304 struct dsp_code dsp_code;
1346 u16 boot_code_id[HPI6205_MAX_FILES_TO_LOAD]; 1305 u16 boot_code_id[HPI6205_MAX_FILES_TO_LOAD];
1347 u16 firmware_id = pao->pci.subsys_device_id; 1306 u16 firmware_id = pao->pci.pci_dev->subsystem_device;
1348 u32 temp; 1307 u32 temp;
1349 int dsp = 0, i = 0; 1308 int dsp = 0, i = 0;
1350 u16 err = 0; 1309 u16 err = 0;
@@ -1381,7 +1340,7 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1381 temp = ioread32(phw->prHSR); 1340 temp = ioread32(phw->prHSR);
1382 if ((temp & (C6205_HSR_CFGERR | C6205_HSR_EEREAD)) != 1341 if ((temp & (C6205_HSR_CFGERR | C6205_HSR_EEREAD)) !=
1383 C6205_HSR_EEREAD) 1342 C6205_HSR_EEREAD)
1384 return hpi6205_error(0, HPI6205_ERROR_6205_EEPROM); 1343 return HPI6205_ERROR_6205_EEPROM;
1385 temp |= 0x04; 1344 temp |= 0x04;
1386 /* disable PINTA interrupt */ 1345 /* disable PINTA interrupt */
1387 iowrite32(temp, phw->prHSR); 1346 iowrite32(temp, phw->prHSR);
@@ -1389,27 +1348,27 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1389 /* check control register reports PCI boot mode */ 1348 /* check control register reports PCI boot mode */
1390 temp = ioread32(phw->prHDCR); 1349 temp = ioread32(phw->prHDCR);
1391 if (!(temp & C6205_HDCR_PCIBOOT)) 1350 if (!(temp & C6205_HDCR_PCIBOOT))
1392 return hpi6205_error(0, HPI6205_ERROR_6205_REG); 1351 return HPI6205_ERROR_6205_REG;
1393 1352
1394 /* try writing a couple of numbers to the DSP page register */ 1353 /* try writing a few numbers to the DSP page register */
1395 /* and reading them back. */ 1354 /* and reading them back. */
1396 temp = 1; 1355 temp = 3;
1397 iowrite32(temp, phw->prDSPP); 1356 iowrite32(temp, phw->prDSPP);
1398 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) 1357 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP))
1399 return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE); 1358 return HPI6205_ERROR_6205_DSPPAGE;
1400 temp = 2; 1359 temp = 2;
1401 iowrite32(temp, phw->prDSPP); 1360 iowrite32(temp, phw->prDSPP);
1402 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) 1361 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP))
1403 return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE); 1362 return HPI6205_ERROR_6205_DSPPAGE;
1404 temp = 3; 1363 temp = 1;
1405 iowrite32(temp, phw->prDSPP); 1364 iowrite32(temp, phw->prDSPP);
1406 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) 1365 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP))
1407 return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE); 1366 return HPI6205_ERROR_6205_DSPPAGE;
1408 /* reset DSP page to the correct number */ 1367 /* reset DSP page to the correct number */
1409 temp = 0; 1368 temp = 0;
1410 iowrite32(temp, phw->prDSPP); 1369 iowrite32(temp, phw->prDSPP);
1411 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) 1370 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP))
1412 return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE); 1371 return HPI6205_ERROR_6205_DSPPAGE;
1413 phw->dsp_page = 0; 1372 phw->dsp_page = 0;
1414 1373
1415 /* release 6713 from reset before 6205 is bootloaded. 1374 /* release 6713 from reset before 6205 is bootloaded.
@@ -1455,7 +1414,7 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1455 return err; 1414 return err;
1456 1415
1457 /* write the DSP code down into the DSPs memory */ 1416 /* write the DSP code down into the DSPs memory */
1458 dsp_code.ps_dev = pao->pci.p_os_data; 1417 dsp_code.ps_dev = pao->pci.pci_dev;
1459 err = hpi_dsp_code_open(boot_code_id[dsp], &dsp_code, 1418 err = hpi_dsp_code_open(boot_code_id[dsp], &dsp_code,
1460 pos_error_code); 1419 pos_error_code);
1461 if (err) 1420 if (err)
@@ -1484,10 +1443,8 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1484 if (err) 1443 if (err)
1485 break; 1444 break;
1486 for (i = 0; i < (int)length; i++) { 1445 for (i = 0; i < (int)length; i++) {
1487 err = boot_loader_write_mem32(pao, dsp, 1446 boot_loader_write_mem32(pao, dsp, address,
1488 address, *pcode); 1447 *pcode);
1489 if (err)
1490 break;
1491 /* dummy read every 4 words */ 1448 /* dummy read every 4 words */
1492 /* for 6205 advisory 1.4.4 */ 1449 /* for 6205 advisory 1.4.4 */
1493 if (i % 4 == 0) 1450 if (i % 4 == 0)
@@ -1561,7 +1518,7 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
1561 host_mailbox_address_on_dsp = 0x80000000; 1518 host_mailbox_address_on_dsp = 0x80000000;
1562 while ((physicalPC_iaddress != physicalPC_iaddress_verify) 1519 while ((physicalPC_iaddress != physicalPC_iaddress_verify)
1563 && time_out--) { 1520 && time_out--) {
1564 err = boot_loader_write_mem32(pao, 0, 1521 boot_loader_write_mem32(pao, 0,
1565 host_mailbox_address_on_dsp, 1522 host_mailbox_address_on_dsp,
1566 physicalPC_iaddress); 1523 physicalPC_iaddress);
1567 physicalPC_iaddress_verify = 1524 physicalPC_iaddress_verify =
@@ -1631,11 +1588,10 @@ static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index,
1631 return data; 1588 return data;
1632} 1589}
1633 1590
1634static u16 boot_loader_write_mem32(struct hpi_adapter_obj *pao, int dsp_index, 1591static void boot_loader_write_mem32(struct hpi_adapter_obj *pao,
1635 u32 address, u32 data) 1592 int dsp_index, u32 address, u32 data)
1636{ 1593{
1637 struct hpi_hw_obj *phw = pao->priv; 1594 struct hpi_hw_obj *phw = pao->priv;
1638 u16 err = 0;
1639 __iomem u32 *p_data; 1595 __iomem u32 *p_data;
1640 /* u32 dwVerifyData=0; */ 1596 /* u32 dwVerifyData=0; */
1641 1597
@@ -1675,15 +1631,11 @@ static u16 boot_loader_write_mem32(struct hpi_adapter_obj *pao, int dsp_index,
1675 1631
1676 /* dummy read every 4 words for 6205 advisory 1.4.4 */ 1632 /* dummy read every 4 words for 6205 advisory 1.4.4 */
1677 boot_loader_read_mem32(pao, 0, 0); 1633 boot_loader_read_mem32(pao, 0, 0);
1678 } else 1634 }
1679 err = hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX);
1680 return err;
1681} 1635}
1682 1636
1683static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) 1637static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1684{ 1638{
1685 u16 err = 0;
1686
1687 if (dsp_index == 0) { 1639 if (dsp_index == 0) {
1688 u32 setting; 1640 u32 setting;
1689 1641
@@ -1711,8 +1663,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1711 boot_loader_write_mem32(pao, dsp_index, 0x01800008, setting); 1663 boot_loader_write_mem32(pao, dsp_index, 0x01800008, setting);
1712 if (setting != boot_loader_read_mem32(pao, dsp_index, 1664 if (setting != boot_loader_read_mem32(pao, dsp_index,
1713 0x01800008)) 1665 0x01800008))
1714 return hpi6205_error(dsp_index, 1666 return HPI6205_ERROR_DSP_EMIF;
1715 HPI6205_ERROR_DSP_EMIF);
1716 1667
1717 /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */ 1668 /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */
1718 /* which occupies D15..0. 6713 starts at 27MHz, so need */ 1669 /* which occupies D15..0. 6713 starts at 27MHz, so need */
@@ -1725,8 +1676,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1725 boot_loader_write_mem32(pao, dsp_index, 0x01800004, setting); 1676 boot_loader_write_mem32(pao, dsp_index, 0x01800004, setting);
1726 if (setting != boot_loader_read_mem32(pao, dsp_index, 1677 if (setting != boot_loader_read_mem32(pao, dsp_index,
1727 0x01800004)) 1678 0x01800004))
1728 return hpi6205_error(dsp_index, 1679 return HPI6205_ERROR_DSP_EMIF;
1729 HPI6205_ERROR_DSP_EMIF);
1730 1680
1731 /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */ 1681 /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */
1732 /* which occupies D15..0. 6713 starts at 27MHz, so need */ 1682 /* which occupies D15..0. 6713 starts at 27MHz, so need */
@@ -1738,8 +1688,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1738 boot_loader_write_mem32(pao, dsp_index, 0x01800010, setting); 1688 boot_loader_write_mem32(pao, dsp_index, 0x01800010, setting);
1739 if (setting != boot_loader_read_mem32(pao, dsp_index, 1689 if (setting != boot_loader_read_mem32(pao, dsp_index,
1740 0x01800010)) 1690 0x01800010))
1741 return hpi6205_error(dsp_index, 1691 return HPI6205_ERROR_DSP_EMIF;
1742 HPI6205_ERROR_DSP_EMIF);
1743 1692
1744 /* EMIF CE3 setup - 32 bit async. */ 1693 /* EMIF CE3 setup - 32 bit async. */
1745 /* This is the PLD on the ASI5000 cards only */ 1694 /* This is the PLD on the ASI5000 cards only */
@@ -1750,8 +1699,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1750 boot_loader_write_mem32(pao, dsp_index, 0x01800014, setting); 1699 boot_loader_write_mem32(pao, dsp_index, 0x01800014, setting);
1751 if (setting != boot_loader_read_mem32(pao, dsp_index, 1700 if (setting != boot_loader_read_mem32(pao, dsp_index,
1752 0x01800014)) 1701 0x01800014))
1753 return hpi6205_error(dsp_index, 1702 return HPI6205_ERROR_DSP_EMIF;
1754 HPI6205_ERROR_DSP_EMIF);
1755 1703
1756 /* set EMIF SDRAM control for 2Mx32 SDRAM (512x32x4 bank) */ 1704 /* set EMIF SDRAM control for 2Mx32 SDRAM (512x32x4 bank) */
1757 /* need to use this else DSP code crashes? */ 1705 /* need to use this else DSP code crashes? */
@@ -1775,12 +1723,9 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1775 read_data = 1723 read_data =
1776 0xFFF7 & boot_loader_read_mem32(pao, 0, HPICL_ADDR); 1724 0xFFF7 & boot_loader_read_mem32(pao, 0, HPICL_ADDR);
1777 if (write_data != read_data) { 1725 if (write_data != read_data) {
1778 err = hpi6205_error(dsp_index,
1779 HPI6205_ERROR_C6713_HPIC);
1780 HPI_DEBUG_LOG(ERROR, "HPICL %x %x\n", write_data, 1726 HPI_DEBUG_LOG(ERROR, "HPICL %x %x\n", write_data,
1781 read_data); 1727 read_data);
1782 1728 return HPI6205_ERROR_C6713_HPIC;
1783 return err;
1784 } 1729 }
1785 /* HPIA - walking ones test */ 1730 /* HPIA - walking ones test */
1786 write_data = 1; 1731 write_data = 1;
@@ -1798,11 +1743,9 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1798 HPIAH_ADDR)) 1743 HPIAH_ADDR))
1799 << 16); 1744 << 16);
1800 if (read_data != write_data) { 1745 if (read_data != write_data) {
1801 err = hpi6205_error(dsp_index,
1802 HPI6205_ERROR_C6713_HPIA);
1803 HPI_DEBUG_LOG(ERROR, "HPIA %x %x\n", 1746 HPI_DEBUG_LOG(ERROR, "HPIA %x %x\n",
1804 write_data, read_data); 1747 write_data, read_data);
1805 return err; 1748 return HPI6205_ERROR_C6713_HPIA;
1806 } 1749 }
1807 write_data = write_data << 1; 1750 write_data = write_data << 1;
1808 } 1751 }
@@ -1847,9 +1790,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1847 /* PLL should not be bypassed! */ 1790 /* PLL should not be bypassed! */
1848 if ((boot_loader_read_mem32(pao, dsp_index, 0x01B7C100) & 0xF) 1791 if ((boot_loader_read_mem32(pao, dsp_index, 0x01B7C100) & 0xF)
1849 != 0x0001) { 1792 != 0x0001) {
1850 err = hpi6205_error(dsp_index, 1793 return HPI6205_ERROR_C6713_PLL;
1851 HPI6205_ERROR_C6713_PLL);
1852 return err;
1853 } 1794 }
1854 /* setup C67x EMIF (note this is the only use of 1795 /* setup C67x EMIF (note this is the only use of
1855 BAR1 via BootLoader_WriteMem32) */ 1796 BAR1 via BootLoader_WriteMem32) */
@@ -1867,10 +1808,9 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1867 hpios_delay_micro_seconds(1000); 1808 hpios_delay_micro_seconds(1000);
1868 } else if (dsp_index == 2) { 1809 } else if (dsp_index == 2) {
1869 /* DSP 2 is a C6713 */ 1810 /* DSP 2 is a C6713 */
1811 }
1870 1812
1871 } else 1813 return 0;
1872 err = hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX);
1873 return err;
1874} 1814}
1875 1815
1876static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index, 1816static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index,
@@ -1896,7 +1836,7 @@ static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index,
1896 test_addr); 1836 test_addr);
1897 if (data != test_data) { 1837 if (data != test_data) {
1898 HPI_DEBUG_LOG(VERBOSE, 1838 HPI_DEBUG_LOG(VERBOSE,
1899 "memtest error details " 1839 "Memtest error details "
1900 "%08x %08x %08x %i\n", test_addr, 1840 "%08x %08x %08x %i\n", test_addr,
1901 test_data, data, dsp_index); 1841 test_data, data, dsp_index);
1902 return 1; /* error */ 1842 return 1; /* error */
@@ -1916,7 +1856,7 @@ static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index,
1916 data = boot_loader_read_mem32(pao, dsp_index, test_addr); 1856 data = boot_loader_read_mem32(pao, dsp_index, test_addr);
1917 if (data != test_data) { 1857 if (data != test_data) {
1918 HPI_DEBUG_LOG(VERBOSE, 1858 HPI_DEBUG_LOG(VERBOSE,
1919 "memtest error details " 1859 "Memtest error details "
1920 "%08x %08x %08x %i\n", test_addr, test_data, 1860 "%08x %08x %08x %i\n", test_addr, test_data,
1921 data, dsp_index); 1861 data, dsp_index);
1922 return 1; /* error */ 1862 return 1; /* error */
@@ -1946,8 +1886,8 @@ static u16 boot_loader_test_internal_memory(struct hpi_adapter_obj *pao,
1946 /* 64K data mem */ 1886 /* 64K data mem */
1947 err = boot_loader_test_memory(pao, dsp_index, 1887 err = boot_loader_test_memory(pao, dsp_index,
1948 0x80000000, 0x10000); 1888 0x80000000, 0x10000);
1949 } else if ((dsp_index == 1) || (dsp_index == 2)) { 1889 } else if (dsp_index == 1) {
1950 /* DSP 1&2 are a C6713 */ 1890 /* DSP 1 is a C6713 */
1951 /* 192K internal mem */ 1891 /* 192K internal mem */
1952 err = boot_loader_test_memory(pao, dsp_index, 0x00000000, 1892 err = boot_loader_test_memory(pao, dsp_index, 0x00000000,
1953 0x30000); 1893 0x30000);
@@ -1955,11 +1895,10 @@ static u16 boot_loader_test_internal_memory(struct hpi_adapter_obj *pao,
1955 /* 64K internal mem / L2 cache */ 1895 /* 64K internal mem / L2 cache */
1956 err = boot_loader_test_memory(pao, dsp_index, 1896 err = boot_loader_test_memory(pao, dsp_index,
1957 0x00030000, 0x10000); 1897 0x00030000, 0x10000);
1958 } else 1898 }
1959 return hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX);
1960 1899
1961 if (err) 1900 if (err)
1962 return hpi6205_error(dsp_index, HPI6205_ERROR_DSP_INTMEM); 1901 return HPI6205_ERROR_DSP_INTMEM;
1963 else 1902 else
1964 return 0; 1903 return 0;
1965} 1904}
@@ -1972,24 +1911,23 @@ static u16 boot_loader_test_external_memory(struct hpi_adapter_obj *pao,
1972 1911
1973 if (dsp_index == 0) { 1912 if (dsp_index == 0) {
1974 /* only test for SDRAM if an ASI5000 card */ 1913 /* only test for SDRAM if an ASI5000 card */
1975 if (pao->pci.subsys_device_id == 0x5000) { 1914 if (pao->pci.pci_dev->subsystem_device == 0x5000) {
1976 /* DSP 0 is always C6205 */ 1915 /* DSP 0 is always C6205 */
1977 dRAM_start_address = 0x00400000; 1916 dRAM_start_address = 0x00400000;
1978 dRAM_size = 0x200000; 1917 dRAM_size = 0x200000;
1979 /*dwDRAMinc=1024; */ 1918 /*dwDRAMinc=1024; */
1980 } else 1919 } else
1981 return 0; 1920 return 0;
1982 } else if ((dsp_index == 1) || (dsp_index == 2)) { 1921 } else if (dsp_index == 1) {
1983 /* DSP 1 is a C6713 */ 1922 /* DSP 1 is a C6713 */
1984 dRAM_start_address = 0x80000000; 1923 dRAM_start_address = 0x80000000;
1985 dRAM_size = 0x200000; 1924 dRAM_size = 0x200000;
1986 /*dwDRAMinc=1024; */ 1925 /*dwDRAMinc=1024; */
1987 } else 1926 }
1988 return hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX);
1989 1927
1990 if (boot_loader_test_memory(pao, dsp_index, dRAM_start_address, 1928 if (boot_loader_test_memory(pao, dsp_index, dRAM_start_address,
1991 dRAM_size)) 1929 dRAM_size))
1992 return hpi6205_error(dsp_index, HPI6205_ERROR_DSP_EXTMEM); 1930 return HPI6205_ERROR_DSP_EXTMEM;
1993 return 0; 1931 return 0;
1994} 1932}
1995 1933
@@ -1998,28 +1936,25 @@ static u16 boot_loader_test_pld(struct hpi_adapter_obj *pao, int dsp_index)
1998 u32 data = 0; 1936 u32 data = 0;
1999 if (dsp_index == 0) { 1937 if (dsp_index == 0) {
2000 /* only test for DSP0 PLD on ASI5000 card */ 1938 /* only test for DSP0 PLD on ASI5000 card */
2001 if (pao->pci.subsys_device_id == 0x5000) { 1939 if (pao->pci.pci_dev->subsystem_device == 0x5000) {
2002 /* PLD is located at CE3=0x03000000 */ 1940 /* PLD is located at CE3=0x03000000 */
2003 data = boot_loader_read_mem32(pao, dsp_index, 1941 data = boot_loader_read_mem32(pao, dsp_index,
2004 0x03000008); 1942 0x03000008);
2005 if ((data & 0xF) != 0x5) 1943 if ((data & 0xF) != 0x5)
2006 return hpi6205_error(dsp_index, 1944 return HPI6205_ERROR_DSP_PLD;
2007 HPI6205_ERROR_DSP_PLD);
2008 data = boot_loader_read_mem32(pao, dsp_index, 1945 data = boot_loader_read_mem32(pao, dsp_index,
2009 0x0300000C); 1946 0x0300000C);
2010 if ((data & 0xF) != 0xA) 1947 if ((data & 0xF) != 0xA)
2011 return hpi6205_error(dsp_index, 1948 return HPI6205_ERROR_DSP_PLD;
2012 HPI6205_ERROR_DSP_PLD);
2013 } 1949 }
2014 } else if (dsp_index == 1) { 1950 } else if (dsp_index == 1) {
2015 /* DSP 1 is a C6713 */ 1951 /* DSP 1 is a C6713 */
2016 if (pao->pci.subsys_device_id == 0x8700) { 1952 if (pao->pci.pci_dev->subsystem_device == 0x8700) {
2017 /* PLD is located at CE1=0x90000000 */ 1953 /* PLD is located at CE1=0x90000000 */
2018 data = boot_loader_read_mem32(pao, dsp_index, 1954 data = boot_loader_read_mem32(pao, dsp_index,
2019 0x90000010); 1955 0x90000010);
2020 if ((data & 0xFF) != 0xAA) 1956 if ((data & 0xFF) != 0xAA)
2021 return hpi6205_error(dsp_index, 1957 return HPI6205_ERROR_DSP_PLD;
2022 HPI6205_ERROR_DSP_PLD);
2023 /* 8713 - LED on */ 1958 /* 8713 - LED on */
2024 boot_loader_write_mem32(pao, dsp_index, 0x90000000, 1959 boot_loader_write_mem32(pao, dsp_index, 0x90000000,
2025 0x02); 1960 0x02);
@@ -2079,7 +2014,7 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data,
2079 if (!temp2) { 2014 if (!temp2) {
2080 /* timed out */ 2015 /* timed out */
2081 HPI_DEBUG_LOG(ERROR, 2016 HPI_DEBUG_LOG(ERROR,
2082 "timed out waiting for " "state %d got %d\n", 2017 "Timed out waiting for " "state %d got %d\n",
2083 operation, interface->dsp_ack); 2018 operation, interface->dsp_ack);
2084 2019
2085 break; 2020 break;
@@ -2099,7 +2034,7 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data,
2099 HPI6205_TIMEOUT - time_out, this_copy); 2034 HPI6205_TIMEOUT - time_out, this_copy);
2100 if (temp2 == C6205_HSR_INTSRC) { 2035 if (temp2 == C6205_HSR_INTSRC) {
2101 HPI_DEBUG_LOG(VERBOSE, 2036 HPI_DEBUG_LOG(VERBOSE,
2102 "interrupt from HIF <data> OK\n"); 2037 "Interrupt from HIF <data> OK\n");
2103 /* 2038 /*
2104 if(interface->dwDspAck != nOperation) { 2039 if(interface->dwDspAck != nOperation) {
2105 HPI_DEBUG_LOG(DEBUG("interface->dwDspAck=%d, 2040 HPI_DEBUG_LOG(DEBUG("interface->dwDspAck=%d,
@@ -2111,7 +2046,7 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data,
2111/* need to handle this differently... */ 2046/* need to handle this differently... */
2112 else { 2047 else {
2113 HPI_DEBUG_LOG(ERROR, 2048 HPI_DEBUG_LOG(ERROR,
2114 "interrupt from HIF <data> BAD\n"); 2049 "Interrupt from HIF <data> BAD\n");
2115 err = HPI_ERROR_DSP_HARDWARE; 2050 err = HPI_ERROR_DSP_HARDWARE;
2116 } 2051 }
2117 2052
@@ -2183,22 +2118,34 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao,
2183 u16 err = 0; 2118 u16 err = 0;
2184 2119
2185 message_count++; 2120 message_count++;
2121 if (phm->size > sizeof(interface->u)) {
2122 /* really MESSAGE buffer too small */
2123 phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
2124 phr->specific_error = sizeof(interface->u);
2125 phr->size = sizeof(struct hpi_response_header);
2126 HPI_DEBUG_LOG(ERROR,
2127 "message len %d too big for buffer %ld \n", phm->size,
2128 sizeof(interface->u));
2129 return 0;
2130 }
2131
2186 /* Assume buffer of type struct bus_master_interface 2132 /* Assume buffer of type struct bus_master_interface
2187 is allocated "noncacheable" */ 2133 is allocated "noncacheable" */
2188 2134
2189 if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) { 2135 if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) {
2190 HPI_DEBUG_LOG(DEBUG, "timeout waiting for idle\n"); 2136 HPI_DEBUG_LOG(DEBUG, "timeout waiting for idle\n");
2191 return hpi6205_error(0, HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT); 2137 return HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT;
2192 } 2138 }
2193 interface->u.message_buffer = *phm; 2139
2140 memcpy(&interface->u.message_buffer, phm, phm->size);
2194 /* signal we want a response */ 2141 /* signal we want a response */
2195 send_dsp_command(phw, H620_HIF_GET_RESP); 2142 send_dsp_command(phw, H620_HIF_GET_RESP);
2196 2143
2197 time_out2 = wait_dsp_ack(phw, H620_HIF_GET_RESP, HPI6205_TIMEOUT); 2144 time_out2 = wait_dsp_ack(phw, H620_HIF_GET_RESP, HPI6205_TIMEOUT);
2198 2145
2199 if (time_out2 == 0) { 2146 if (!time_out2) {
2200 HPI_DEBUG_LOG(ERROR, 2147 HPI_DEBUG_LOG(ERROR,
2201 "(%u) timed out waiting for " "GET_RESP state [%x]\n", 2148 "(%u) Timed out waiting for " "GET_RESP state [%x]\n",
2202 message_count, interface->dsp_ack); 2149 message_count, interface->dsp_ack);
2203 } else { 2150 } else {
2204 HPI_DEBUG_LOG(VERBOSE, 2151 HPI_DEBUG_LOG(VERBOSE,
@@ -2232,7 +2179,7 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao,
2232 } else { 2179 } else {
2233 /* can we do anything else in response to the error ? */ 2180 /* can we do anything else in response to the error ? */
2234 HPI_DEBUG_LOG(ERROR, 2181 HPI_DEBUG_LOG(ERROR,
2235 "interrupt from HIF module BAD (function %x)\n", 2182 "Interrupt from HIF module BAD (function %x)\n",
2236 phm->function); 2183 phm->function);
2237 } 2184 }
2238 2185
@@ -2241,25 +2188,37 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao,
2241#endif 2188#endif
2242 2189
2243 /* read the result */ 2190 /* read the result */
2244 if (time_out != 0) 2191 if (time_out) {
2245 *phr = interface->u.response_buffer; 2192 if (interface->u.response_buffer.size <= phr->size)
2246 2193 memcpy(phr, &interface->u.response_buffer,
2194 interface->u.response_buffer.size);
2195 else {
2196 HPI_DEBUG_LOG(ERROR,
2197 "response len %d too big for buffer %d\n",
2198 interface->u.response_buffer.size, phr->size);
2199 memcpy(phr, &interface->u.response_buffer,
2200 sizeof(struct hpi_response_header));
2201 phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
2202 phr->specific_error =
2203 interface->u.response_buffer.size;
2204 phr->size = sizeof(struct hpi_response_header);
2205 }
2206 }
2247 /* set interface back to idle */ 2207 /* set interface back to idle */
2248 send_dsp_command(phw, H620_HIF_IDLE); 2208 send_dsp_command(phw, H620_HIF_IDLE);
2249 2209
2250 if ((time_out == 0) || (time_out2 == 0)) { 2210 if (!time_out || !time_out2) {
2251 HPI_DEBUG_LOG(DEBUG, "something timed out!\n"); 2211 HPI_DEBUG_LOG(DEBUG, "something timed out!\n");
2252 return hpi6205_error(0, HPI6205_ERROR_MSG_RESP_TIMEOUT); 2212 return HPI6205_ERROR_MSG_RESP_TIMEOUT;
2253 } 2213 }
2254 /* special case for adapter close - */ 2214 /* special case for adapter close - */
2255 /* wait for the DSP to indicate it is idle */ 2215 /* wait for the DSP to indicate it is idle */
2256 if (phm->function == HPI_ADAPTER_CLOSE) { 2216 if (phm->function == HPI_ADAPTER_CLOSE) {
2257 if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) { 2217 if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) {
2258 HPI_DEBUG_LOG(DEBUG, 2218 HPI_DEBUG_LOG(DEBUG,
2259 "timeout waiting for idle " 2219 "Timeout waiting for idle "
2260 "(on adapter_close)\n"); 2220 "(on adapter_close)\n");
2261 return hpi6205_error(0, 2221 return HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT;
2262 HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT);
2263 } 2222 }
2264 } 2223 }
2265 err = hpi_validate_response(phm, phr); 2224 err = hpi_validate_response(phm, phr);
diff --git a/sound/pci/asihpi/hpi6205.h b/sound/pci/asihpi/hpi6205.h
index 1adae0857cda..e00edb0cedda 100644
--- a/sound/pci/asihpi/hpi6205.h
+++ b/sound/pci/asihpi/hpi6205.h
@@ -78,8 +78,8 @@ struct bus_master_interface {
78 u32 dsp_ack; 78 u32 dsp_ack;
79 u32 transfer_size_in_bytes; 79 u32 transfer_size_in_bytes;
80 union { 80 union {
81 struct hpi_message message_buffer; 81 struct hpi_message_header message_buffer;
82 struct hpi_response response_buffer; 82 struct hpi_response_header response_buffer;
83 u8 b_data[HPI6205_SIZEOF_DATA]; 83 u8 b_data[HPI6205_SIZEOF_DATA];
84 } u; 84 } u;
85 struct controlcache_6205 control_cache; 85 struct controlcache_6205 control_cache;
diff --git a/sound/pci/asihpi/hpi_internal.h b/sound/pci/asihpi/hpi_internal.h
index 16f502d459de..0d500841f1a5 100644
--- a/sound/pci/asihpi/hpi_internal.h
+++ b/sound/pci/asihpi/hpi_internal.h
@@ -28,7 +28,7 @@ HPI internal definitions
28/** maximum number of memory regions mapped to an adapter */ 28/** maximum number of memory regions mapped to an adapter */
29#define HPI_MAX_ADAPTER_MEM_SPACES (2) 29#define HPI_MAX_ADAPTER_MEM_SPACES (2)
30 30
31/* Each OS needs its own hpios.h, or specific define as above */ 31/* Each OS needs its own hpios.h */
32#include "hpios.h" 32#include "hpios.h"
33 33
34/* physical memory allocation */ 34/* physical memory allocation */
@@ -49,7 +49,7 @@ HpiOs_LockedMem_GetPyhsAddr() will always succed on the returned handle.
49*/ 49*/
50u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_locked_mem_handle, 50u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_locked_mem_handle,
51 /**< memory handle */ 51 /**< memory handle */
52 u32 size, /**< size in bytes to allocate */ 52 u32 size, /**< Size in bytes to allocate */
53 struct pci_dev *p_os_reference 53 struct pci_dev *p_os_reference
54 /**< OS specific data required for memory allocation */ 54 /**< OS specific data required for memory allocation */
55 ); 55 );
@@ -96,41 +96,6 @@ typedef void hpi_handler_func(struct hpi_message *, struct hpi_response *);
96#define compile_time_assert(cond, msg) \ 96#define compile_time_assert(cond, msg) \
97 typedef char ASSERT_##msg[(cond) ? 1 : -1] 97 typedef char ASSERT_##msg[(cond) ? 1 : -1]
98 98
99/*/////////////////////////////////////////////////////////////////////////// */
100/* Private HPI Entity related definitions */
101
102#define STR_SIZE_FIELD_MAX 65535U
103#define STR_TYPE_FIELD_MAX 255U
104#define STR_ROLE_FIELD_MAX 255U
105
106struct hpi_entity_str {
107 u16 size;
108 u8 type;
109 u8 role;
110};
111
112#if defined(_MSC_VER)
113#pragma warning(push)
114#pragma warning(disable : 4200)
115#endif
116
117struct hpi_entity {
118 struct hpi_entity_str header;
119#if ! defined(HPI_OS_DSP_C6000) || (defined(HPI_OS_DSP_C6000) && (__TI_COMPILER_VERSION__ > 6000008))
120 /* DSP C6000 compiler v6.0.8 and lower
121 do not support flexible array member */
122 u8 value[];
123#else
124 /* NOTE! Using sizeof(struct hpi_entity) will give erroneous results */
125#define HPI_INTERNAL_WARN_ABOUT_ENTITY_VALUE
126 u8 value[1];
127#endif
128};
129
130#if defined(_MSC_VER)
131#pragma warning(pop)
132#endif
133
134/******************************************* bus types */ 99/******************************************* bus types */
135enum HPI_BUSES { 100enum HPI_BUSES {
136 HPI_BUS_ISAPNP = 1, 101 HPI_BUS_ISAPNP = 1,
@@ -143,202 +108,127 @@ enum HPI_BUSES {
143/* (in order of control type ID */ 108/* (in order of control type ID */
144 109
145/* This allows for 255 control types, 256 unique attributes each */ 110/* This allows for 255 control types, 256 unique attributes each */
146#define HPI_CTL_ATTR(ctl, ai) (HPI_CONTROL_##ctl * 0x100 + ai) 111#define HPI_CTL_ATTR(ctl, ai) ((HPI_CONTROL_##ctl << 8) + ai)
147 112
148/* Get the sub-index of the attribute for a control type */ 113/* Get the sub-index of the attribute for a control type */
149#define HPI_CTL_ATTR_INDEX(i) (i&0xff) 114#define HPI_CTL_ATTR_INDEX(i) (i & 0xff)
150 115
151/* Extract the control from the control attribute */ 116/* Extract the control from the control attribute */
152#define HPI_CTL_ATTR_CONTROL(i) (i>>8) 117#define HPI_CTL_ATTR_CONTROL(i) (i >> 8)
153
154/* Generic control attributes. */
155
156/** Enable a control.
1570=disable, 1=enable
158\note generic to all mixer plugins?
159*/
160#define HPI_GENERIC_ENABLE HPI_CTL_ATTR(GENERIC, 1)
161 118
162/** Enable event generation for a control. 119/** Enable event generation for a control.
1630=disable, 1=enable 1200=disable, 1=enable
164\note generic to all controls that can generate events 121\note generic to all controls that can generate events
165*/ 122*/
166#define HPI_GENERIC_EVENT_ENABLE HPI_CTL_ATTR(GENERIC, 2) 123
167 124/** Unique identifiers for every control attribute
168/* Volume Control attributes */
169#define HPI_VOLUME_GAIN HPI_CTL_ATTR(VOLUME, 1)
170#define HPI_VOLUME_AUTOFADE HPI_CTL_ATTR(VOLUME, 2)
171
172/** For HPI_ControlQuery() to get the number of channels of a volume control*/
173#define HPI_VOLUME_NUM_CHANNELS HPI_CTL_ATTR(VOLUME, 6)
174#define HPI_VOLUME_RANGE HPI_CTL_ATTR(VOLUME, 10)
175
176/** Level Control attributes */
177#define HPI_LEVEL_GAIN HPI_CTL_ATTR(LEVEL, 1)
178#define HPI_LEVEL_RANGE HPI_CTL_ATTR(LEVEL, 10)
179
180/* Meter Control attributes */
181/** return RMS signal level */
182#define HPI_METER_RMS HPI_CTL_ATTR(METER, 1)
183/** return peak signal level */
184#define HPI_METER_PEAK HPI_CTL_ATTR(METER, 2)
185/** ballistics for ALL rms meters on adapter */
186#define HPI_METER_RMS_BALLISTICS HPI_CTL_ATTR(METER, 3)
187/** ballistics for ALL peak meters on adapter */
188#define HPI_METER_PEAK_BALLISTICS HPI_CTL_ATTR(METER, 4)
189
190/** For HPI_ControlQuery() to get the number of channels of a meter control*/
191#define HPI_METER_NUM_CHANNELS HPI_CTL_ATTR(METER, 5)
192
193/* Multiplexer control attributes */
194#define HPI_MULTIPLEXER_SOURCE HPI_CTL_ATTR(MULTIPLEXER, 1)
195#define HPI_MULTIPLEXER_QUERYSOURCE HPI_CTL_ATTR(MULTIPLEXER, 2)
196
197/** AES/EBU transmitter control attributes */
198/** AESEBU or SPDIF */
199#define HPI_AESEBUTX_FORMAT HPI_CTL_ATTR(AESEBUTX, 1)
200#define HPI_AESEBUTX_SAMPLERATE HPI_CTL_ATTR(AESEBUTX, 3)
201#define HPI_AESEBUTX_CHANNELSTATUS HPI_CTL_ATTR(AESEBUTX, 4)
202#define HPI_AESEBUTX_USERDATA HPI_CTL_ATTR(AESEBUTX, 5)
203
204/** AES/EBU receiver control attributes */
205#define HPI_AESEBURX_FORMAT HPI_CTL_ATTR(AESEBURX, 1)
206#define HPI_AESEBURX_ERRORSTATUS HPI_CTL_ATTR(AESEBURX, 2)
207#define HPI_AESEBURX_SAMPLERATE HPI_CTL_ATTR(AESEBURX, 3)
208#define HPI_AESEBURX_CHANNELSTATUS HPI_CTL_ATTR(AESEBURX, 4)
209#define HPI_AESEBURX_USERDATA HPI_CTL_ATTR(AESEBURX, 5)
210
211/** \defgroup tuner_defs Tuners
212\{
213*/
214/** \defgroup tuner_attrs Tuner control attributes
215\{
216*/
217#define HPI_TUNER_BAND HPI_CTL_ATTR(TUNER, 1)
218#define HPI_TUNER_FREQ HPI_CTL_ATTR(TUNER, 2)
219#define HPI_TUNER_LEVEL HPI_CTL_ATTR(TUNER, 3)
220#define HPI_TUNER_AUDIOMUTE HPI_CTL_ATTR(TUNER, 4)
221/* use TUNER_STATUS instead */
222#define HPI_TUNER_VIDEO_STATUS HPI_CTL_ATTR(TUNER, 5)
223#define HPI_TUNER_GAIN HPI_CTL_ATTR(TUNER, 6)
224#define HPI_TUNER_STATUS HPI_CTL_ATTR(TUNER, 7)
225#define HPI_TUNER_MODE HPI_CTL_ATTR(TUNER, 8)
226/** RDS data. */
227#define HPI_TUNER_RDS HPI_CTL_ATTR(TUNER, 9)
228/** Audio pre-emphasis. */
229#define HPI_TUNER_DEEMPHASIS HPI_CTL_ATTR(TUNER, 10)
230/** HD Radio tuner program control. */
231#define HPI_TUNER_PROGRAM HPI_CTL_ATTR(TUNER, 11)
232/** HD Radio tuner digital signal quality. */
233#define HPI_TUNER_HDRADIO_SIGNAL_QUALITY HPI_CTL_ATTR(TUNER, 12)
234/** HD Radio SDK firmware version. */
235#define HPI_TUNER_HDRADIO_SDK_VERSION HPI_CTL_ATTR(TUNER, 13)
236/** HD Radio DSP firmware version. */
237#define HPI_TUNER_HDRADIO_DSP_VERSION HPI_CTL_ATTR(TUNER, 14)
238/** HD Radio signal blend (force analog, or automatic). */
239#define HPI_TUNER_HDRADIO_BLEND HPI_CTL_ATTR(TUNER, 15)
240
241/** \} */
242
243/** \defgroup pads_attrs Tuner PADs control attributes
244\{
245*/
246/** The text string containing the station/channel combination. */
247#define HPI_PAD_CHANNEL_NAME HPI_CTL_ATTR(PAD, 1)
248/** The text string containing the artist. */
249#define HPI_PAD_ARTIST HPI_CTL_ATTR(PAD, 2)
250/** The text string containing the title. */
251#define HPI_PAD_TITLE HPI_CTL_ATTR(PAD, 3)
252/** The text string containing the comment. */
253#define HPI_PAD_COMMENT HPI_CTL_ATTR(PAD, 4)
254/** The integer containing the PTY code. */
255#define HPI_PAD_PROGRAM_TYPE HPI_CTL_ATTR(PAD, 5)
256/** The integer containing the program identification. */
257#define HPI_PAD_PROGRAM_ID HPI_CTL_ATTR(PAD, 6)
258/** The integer containing whether traffic information is supported.
259Contains either 1 or 0. */
260#define HPI_PAD_TA_SUPPORT HPI_CTL_ATTR(PAD, 7)
261/** The integer containing whether traffic announcement is in progress.
262Contains either 1 or 0. */
263#define HPI_PAD_TA_ACTIVE HPI_CTL_ATTR(PAD, 8)
264/** \} */
265/** \} */
266
267/* VOX control attributes */
268#define HPI_VOX_THRESHOLD HPI_CTL_ATTR(VOX, 1)
269
270/*?? channel mode used hpi_multiplexer_source attribute == 1 */
271#define HPI_CHANNEL_MODE_MODE HPI_CTL_ATTR(CHANNEL_MODE, 1)
272
273/** \defgroup channel_modes Channel Modes
274Used for HPI_ChannelModeSet/Get()
275\{
276*/ 125*/
277/** Left channel out = left channel in, Right channel out = right channel in. */ 126enum HPI_CONTROL_ATTRIBUTES {
278#define HPI_CHANNEL_MODE_NORMAL 1 127 HPI_GENERIC_ENABLE = HPI_CTL_ATTR(GENERIC, 1),
279/** Left channel out = right channel in, Right channel out = left channel in. */ 128 HPI_GENERIC_EVENT_ENABLE = HPI_CTL_ATTR(GENERIC, 2),
280#define HPI_CHANNEL_MODE_SWAP 2 129
281/** Left channel out = left channel in, Right channel out = left channel in. */ 130 HPI_VOLUME_GAIN = HPI_CTL_ATTR(VOLUME, 1),
282#define HPI_CHANNEL_MODE_LEFT_TO_STEREO 3 131 HPI_VOLUME_AUTOFADE = HPI_CTL_ATTR(VOLUME, 2),
283/** Left channel out = right channel in, Right channel out = right channel in.*/ 132 HPI_VOLUME_NUM_CHANNELS = HPI_CTL_ATTR(VOLUME, 6),
284#define HPI_CHANNEL_MODE_RIGHT_TO_STEREO 4 133 HPI_VOLUME_RANGE = HPI_CTL_ATTR(VOLUME, 10),
285/** Left channel out = (left channel in + right channel in)/2, 134
286 Right channel out = mute. */ 135 HPI_METER_RMS = HPI_CTL_ATTR(METER, 1),
287#define HPI_CHANNEL_MODE_STEREO_TO_LEFT 5 136 HPI_METER_PEAK = HPI_CTL_ATTR(METER, 2),
288/** Left channel out = mute, 137 HPI_METER_RMS_BALLISTICS = HPI_CTL_ATTR(METER, 3),
289 Right channel out = (right channel in + left channel in)/2. */ 138 HPI_METER_PEAK_BALLISTICS = HPI_CTL_ATTR(METER, 4),
290#define HPI_CHANNEL_MODE_STEREO_TO_RIGHT 6 139 HPI_METER_NUM_CHANNELS = HPI_CTL_ATTR(METER, 5),
291#define HPI_CHANNEL_MODE_LAST 6 140
292/** \} */ 141 HPI_MULTIPLEXER_SOURCE = HPI_CTL_ATTR(MULTIPLEXER, 1),
293 142 HPI_MULTIPLEXER_QUERYSOURCE = HPI_CTL_ATTR(MULTIPLEXER, 2),
294/* Bitstream control set attributes */ 143
295#define HPI_BITSTREAM_DATA_POLARITY HPI_CTL_ATTR(BITSTREAM, 1) 144 HPI_AESEBUTX_FORMAT = HPI_CTL_ATTR(AESEBUTX, 1),
296#define HPI_BITSTREAM_CLOCK_EDGE HPI_CTL_ATTR(BITSTREAM, 2) 145 HPI_AESEBUTX_SAMPLERATE = HPI_CTL_ATTR(AESEBUTX, 3),
297#define HPI_BITSTREAM_CLOCK_SOURCE HPI_CTL_ATTR(BITSTREAM, 3) 146 HPI_AESEBUTX_CHANNELSTATUS = HPI_CTL_ATTR(AESEBUTX, 4),
147 HPI_AESEBUTX_USERDATA = HPI_CTL_ATTR(AESEBUTX, 5),
148
149 HPI_AESEBURX_FORMAT = HPI_CTL_ATTR(AESEBURX, 1),
150 HPI_AESEBURX_ERRORSTATUS = HPI_CTL_ATTR(AESEBURX, 2),
151 HPI_AESEBURX_SAMPLERATE = HPI_CTL_ATTR(AESEBURX, 3),
152 HPI_AESEBURX_CHANNELSTATUS = HPI_CTL_ATTR(AESEBURX, 4),
153 HPI_AESEBURX_USERDATA = HPI_CTL_ATTR(AESEBURX, 5),
154
155 HPI_LEVEL_GAIN = HPI_CTL_ATTR(LEVEL, 1),
156 HPI_LEVEL_RANGE = HPI_CTL_ATTR(LEVEL, 10),
157
158 HPI_TUNER_BAND = HPI_CTL_ATTR(TUNER, 1),
159 HPI_TUNER_FREQ = HPI_CTL_ATTR(TUNER, 2),
160 HPI_TUNER_LEVEL_AVG = HPI_CTL_ATTR(TUNER, 3),
161 HPI_TUNER_LEVEL_RAW = HPI_CTL_ATTR(TUNER, 4),
162 HPI_TUNER_SNR = HPI_CTL_ATTR(TUNER, 5),
163 HPI_TUNER_GAIN = HPI_CTL_ATTR(TUNER, 6),
164 HPI_TUNER_STATUS = HPI_CTL_ATTR(TUNER, 7),
165 HPI_TUNER_MODE = HPI_CTL_ATTR(TUNER, 8),
166 HPI_TUNER_RDS = HPI_CTL_ATTR(TUNER, 9),
167 HPI_TUNER_DEEMPHASIS = HPI_CTL_ATTR(TUNER, 10),
168 HPI_TUNER_PROGRAM = HPI_CTL_ATTR(TUNER, 11),
169 HPI_TUNER_HDRADIO_SIGNAL_QUALITY = HPI_CTL_ATTR(TUNER, 12),
170 HPI_TUNER_HDRADIO_SDK_VERSION = HPI_CTL_ATTR(TUNER, 13),
171 HPI_TUNER_HDRADIO_DSP_VERSION = HPI_CTL_ATTR(TUNER, 14),
172 HPI_TUNER_HDRADIO_BLEND = HPI_CTL_ATTR(TUNER, 15),
173
174 HPI_VOX_THRESHOLD = HPI_CTL_ATTR(VOX, 1),
175
176 HPI_CHANNEL_MODE_MODE = HPI_CTL_ATTR(CHANNEL_MODE, 1),
177
178 HPI_BITSTREAM_DATA_POLARITY = HPI_CTL_ATTR(BITSTREAM, 1),
179 HPI_BITSTREAM_CLOCK_EDGE = HPI_CTL_ATTR(BITSTREAM, 2),
180 HPI_BITSTREAM_CLOCK_SOURCE = HPI_CTL_ATTR(BITSTREAM, 3),
181 HPI_BITSTREAM_ACTIVITY = HPI_CTL_ATTR(BITSTREAM, 4),
182
183 HPI_SAMPLECLOCK_SOURCE = HPI_CTL_ATTR(SAMPLECLOCK, 1),
184 HPI_SAMPLECLOCK_SAMPLERATE = HPI_CTL_ATTR(SAMPLECLOCK, 2),
185 HPI_SAMPLECLOCK_SOURCE_INDEX = HPI_CTL_ATTR(SAMPLECLOCK, 3),
186 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE = HPI_CTL_ATTR(SAMPLECLOCK, 4),
187 HPI_SAMPLECLOCK_AUTO = HPI_CTL_ATTR(SAMPLECLOCK, 5),
188 HPI_SAMPLECLOCK_LOCAL_LOCK = HPI_CTL_ATTR(SAMPLECLOCK, 6),
189
190 HPI_MICROPHONE_PHANTOM_POWER = HPI_CTL_ATTR(MICROPHONE, 1),
191
192 HPI_EQUALIZER_NUM_FILTERS = HPI_CTL_ATTR(EQUALIZER, 1),
193 HPI_EQUALIZER_FILTER = HPI_CTL_ATTR(EQUALIZER, 2),
194 HPI_EQUALIZER_COEFFICIENTS = HPI_CTL_ATTR(EQUALIZER, 3),
195
196 HPI_COMPANDER_PARAMS = HPI_CTL_ATTR(COMPANDER, 1),
197 HPI_COMPANDER_MAKEUPGAIN = HPI_CTL_ATTR(COMPANDER, 2),
198 HPI_COMPANDER_THRESHOLD = HPI_CTL_ATTR(COMPANDER, 3),
199 HPI_COMPANDER_RATIO = HPI_CTL_ATTR(COMPANDER, 4),
200 HPI_COMPANDER_ATTACK = HPI_CTL_ATTR(COMPANDER, 5),
201 HPI_COMPANDER_DECAY = HPI_CTL_ATTR(COMPANDER, 6),
202
203 HPI_COBRANET_SET = HPI_CTL_ATTR(COBRANET, 1),
204 HPI_COBRANET_GET = HPI_CTL_ATTR(COBRANET, 2),
205 HPI_COBRANET_SET_DATA = HPI_CTL_ATTR(COBRANET, 3),
206 HPI_COBRANET_GET_DATA = HPI_CTL_ATTR(COBRANET, 4),
207 HPI_COBRANET_GET_STATUS = HPI_CTL_ATTR(COBRANET, 5),
208 HPI_COBRANET_SEND_PACKET = HPI_CTL_ATTR(COBRANET, 6),
209 HPI_COBRANET_GET_PACKET = HPI_CTL_ATTR(COBRANET, 7),
210
211 HPI_TONEDETECTOR_THRESHOLD = HPI_CTL_ATTR(TONEDETECTOR, 1),
212 HPI_TONEDETECTOR_STATE = HPI_CTL_ATTR(TONEDETECTOR, 2),
213 HPI_TONEDETECTOR_FREQUENCY = HPI_CTL_ATTR(TONEDETECTOR, 3),
214
215 HPI_SILENCEDETECTOR_THRESHOLD = HPI_CTL_ATTR(SILENCEDETECTOR, 1),
216 HPI_SILENCEDETECTOR_STATE = HPI_CTL_ATTR(SILENCEDETECTOR, 2),
217 HPI_SILENCEDETECTOR_DELAY = HPI_CTL_ATTR(SILENCEDETECTOR, 3),
218
219 HPI_PAD_CHANNEL_NAME = HPI_CTL_ATTR(PAD, 1),
220 HPI_PAD_ARTIST = HPI_CTL_ATTR(PAD, 2),
221 HPI_PAD_TITLE = HPI_CTL_ATTR(PAD, 3),
222 HPI_PAD_COMMENT = HPI_CTL_ATTR(PAD, 4),
223 HPI_PAD_PROGRAM_TYPE = HPI_CTL_ATTR(PAD, 5),
224 HPI_PAD_PROGRAM_ID = HPI_CTL_ATTR(PAD, 6),
225 HPI_PAD_TA_SUPPORT = HPI_CTL_ATTR(PAD, 7),
226 HPI_PAD_TA_ACTIVE = HPI_CTL_ATTR(PAD, 8)
227};
298 228
299#define HPI_POLARITY_POSITIVE 0 229#define HPI_POLARITY_POSITIVE 0
300#define HPI_POLARITY_NEGATIVE 1 230#define HPI_POLARITY_NEGATIVE 1
301 231
302/* Bitstream control get attributes */
303#define HPI_BITSTREAM_ACTIVITY 1
304
305/* SampleClock control attributes */
306#define HPI_SAMPLECLOCK_SOURCE HPI_CTL_ATTR(SAMPLECLOCK, 1)
307#define HPI_SAMPLECLOCK_SAMPLERATE HPI_CTL_ATTR(SAMPLECLOCK, 2)
308#define HPI_SAMPLECLOCK_SOURCE_INDEX HPI_CTL_ATTR(SAMPLECLOCK, 3)
309#define HPI_SAMPLECLOCK_LOCAL_SAMPLERATE\
310 HPI_CTL_ATTR(SAMPLECLOCK, 4)
311#define HPI_SAMPLECLOCK_AUTO HPI_CTL_ATTR(SAMPLECLOCK, 5)
312#define HPI_SAMPLECLOCK_LOCAL_LOCK HPI_CTL_ATTR(SAMPLECLOCK, 6)
313
314/* Microphone control attributes */
315#define HPI_MICROPHONE_PHANTOM_POWER HPI_CTL_ATTR(MICROPHONE, 1)
316
317/** Equalizer control attributes */
318/** Used to get number of filters in an EQ. (Can't set) */
319#define HPI_EQUALIZER_NUM_FILTERS HPI_CTL_ATTR(EQUALIZER, 1)
320/** Set/get the filter by type, freq, Q, gain */
321#define HPI_EQUALIZER_FILTER HPI_CTL_ATTR(EQUALIZER, 2)
322/** Get the biquad coefficients */
323#define HPI_EQUALIZER_COEFFICIENTS HPI_CTL_ATTR(EQUALIZER, 3)
324
325/* Note compander also uses HPI_GENERIC_ENABLE */
326#define HPI_COMPANDER_PARAMS HPI_CTL_ATTR(COMPANDER, 1)
327#define HPI_COMPANDER_MAKEUPGAIN HPI_CTL_ATTR(COMPANDER, 2)
328#define HPI_COMPANDER_THRESHOLD HPI_CTL_ATTR(COMPANDER, 3)
329#define HPI_COMPANDER_RATIO HPI_CTL_ATTR(COMPANDER, 4)
330#define HPI_COMPANDER_ATTACK HPI_CTL_ATTR(COMPANDER, 5)
331#define HPI_COMPANDER_DECAY HPI_CTL_ATTR(COMPANDER, 6)
332
333/* Cobranet control attributes. */
334#define HPI_COBRANET_SET HPI_CTL_ATTR(COBRANET, 1)
335#define HPI_COBRANET_GET HPI_CTL_ATTR(COBRANET, 2)
336#define HPI_COBRANET_SET_DATA HPI_CTL_ATTR(COBRANET, 3)
337#define HPI_COBRANET_GET_DATA HPI_CTL_ATTR(COBRANET, 4)
338#define HPI_COBRANET_GET_STATUS HPI_CTL_ATTR(COBRANET, 5)
339#define HPI_COBRANET_SEND_PACKET HPI_CTL_ATTR(COBRANET, 6)
340#define HPI_COBRANET_GET_PACKET HPI_CTL_ATTR(COBRANET, 7)
341
342/*------------------------------------------------------------ 232/*------------------------------------------------------------
343 Cobranet Chip Bridge - copied from HMI.H 233 Cobranet Chip Bridge - copied from HMI.H
344------------------------------------------------------------*/ 234------------------------------------------------------------*/
@@ -398,66 +288,19 @@ Used for HPI_ChannelModeSet/Get()
398/** Base network time out is set to 100 milli-seconds. */ 288/** Base network time out is set to 100 milli-seconds. */
399#define HPI_ETHERNET_TIMEOUT_MS (100) 289#define HPI_ETHERNET_TIMEOUT_MS (100)
400 290
401/** \defgroup tonedet_attr Tonedetector attributes 291/** Locked memory buffer alloc/free phases */
402\{ 292enum HPI_BUFFER_CMDS {
403Used by HPI_ToneDetector_Set() and HPI_ToneDetector_Get() 293 /** use one message to allocate or free physical memory */
404*/ 294 HPI_BUFFER_CMD_EXTERNAL = 0,
405 295 /** alloc physical memory */
406/** Set the threshold level of a tonedetector, 296 HPI_BUFFER_CMD_INTERNAL_ALLOC = 1,
407Threshold is a -ve number in units of dB/100, 297 /** send physical memory address to adapter */
408*/ 298 HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER = 2,
409#define HPI_TONEDETECTOR_THRESHOLD HPI_CTL_ATTR(TONEDETECTOR, 1) 299 /** notify adapter to stop using physical buffer */
410 300 HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER = 3,
411/** Get the current state of tonedetection 301 /** free physical buffer */
412The result is a bitmap of detected tones. pairs of bits represent the left 302 HPI_BUFFER_CMD_INTERNAL_FREE = 4
413and right channels, with left channel in LSB. 303};
414The lowest frequency detector state is in the LSB
415*/
416#define HPI_TONEDETECTOR_STATE HPI_CTL_ATTR(TONEDETECTOR, 2)
417
418/** Get the frequency of a tonedetector band.
419*/
420#define HPI_TONEDETECTOR_FREQUENCY HPI_CTL_ATTR(TONEDETECTOR, 3)
421
422/**\}*/
423
424/** \defgroup silencedet_attr SilenceDetector attributes
425\{
426*/
427
428/** Get the current state of tonedetection
429The result is a bitmap with 1s for silent channels. Left channel is in LSB
430*/
431#define HPI_SILENCEDETECTOR_STATE \
432 HPI_CTL_ATTR(SILENCEDETECTOR, 2)
433
434/** Set the threshold level of a SilenceDetector,
435Threshold is a -ve number in units of dB/100,
436*/
437#define HPI_SILENCEDETECTOR_THRESHOLD \
438 HPI_CTL_ATTR(SILENCEDETECTOR, 1)
439
440/** get/set the silence time before the detector triggers
441*/
442#define HPI_SILENCEDETECTOR_DELAY \
443 HPI_CTL_ATTR(SILENCEDETECTOR, 3)
444
445/**\}*/
446
447/* Locked memory buffer alloc/free phases */
448/** use one message to allocate or free physical memory */
449#define HPI_BUFFER_CMD_EXTERNAL 0
450/** alloc physical memory */
451#define HPI_BUFFER_CMD_INTERNAL_ALLOC 1
452/** send physical memory address to adapter */
453#define HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER 2
454/** notify adapter to stop using physical buffer */
455#define HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER 3
456/** free physical buffer */
457#define HPI_BUFFER_CMD_INTERNAL_FREE 4
458
459/******************************************* CONTROLX ATTRIBUTES ****/
460/* NOTE: All controlx attributes must be unique, unlike control attributes */
461 304
462/*****************************************************************************/ 305/*****************************************************************************/
463/*****************************************************************************/ 306/*****************************************************************************/
@@ -482,6 +325,12 @@ Threshold is a -ve number in units of dB/100,
482#define HPI_USB_W2K_TAG 0x57495341 /* "ASIW" */ 325#define HPI_USB_W2K_TAG 0x57495341 /* "ASIW" */
483#define HPI_USB_LINUX_TAG 0x4C495341 /* "ASIL" */ 326#define HPI_USB_LINUX_TAG 0x4C495341 /* "ASIL" */
484 327
328/** Invalid Adapter index
329Used in HPI messages that are not addressed to a specific adapter
330Used in DLL to indicate device not present
331*/
332#define HPI_ADAPTER_INDEX_INVALID 0xFFFF
333
485/** First 2 hex digits define the adapter family */ 334/** First 2 hex digits define the adapter family */
486#define HPI_ADAPTER_FAMILY_MASK 0xff00 335#define HPI_ADAPTER_FAMILY_MASK 0xff00
487#define HPI_MODULE_FAMILY_MASK 0xfff0 336#define HPI_MODULE_FAMILY_MASK 0xfff0
@@ -490,178 +339,180 @@ Threshold is a -ve number in units of dB/100,
490#define HPI_MODULE_FAMILY_ASI(f) (f & HPI_MODULE_FAMILY_MASK) 339#define HPI_MODULE_FAMILY_ASI(f) (f & HPI_MODULE_FAMILY_MASK)
491#define HPI_ADAPTER_ASI(f) (f) 340#define HPI_ADAPTER_ASI(f) (f)
492 341
493/******************************************* message types */ 342enum HPI_MESSAGE_TYPES {
494#define HPI_TYPE_MESSAGE 1 343 HPI_TYPE_MESSAGE = 1,
495#define HPI_TYPE_RESPONSE 2 344 HPI_TYPE_RESPONSE = 2,
496#define HPI_TYPE_DATA 3 345 HPI_TYPE_DATA = 3,
497#define HPI_TYPE_SSX2BYPASS_MESSAGE 4 346 HPI_TYPE_SSX2BYPASS_MESSAGE = 4
498 347};
499/******************************************* object types */ 348
500#define HPI_OBJ_SUBSYSTEM 1 349enum HPI_OBJECT_TYPES {
501#define HPI_OBJ_ADAPTER 2 350 HPI_OBJ_SUBSYSTEM = 1,
502#define HPI_OBJ_OSTREAM 3 351 HPI_OBJ_ADAPTER = 2,
503#define HPI_OBJ_ISTREAM 4 352 HPI_OBJ_OSTREAM = 3,
504#define HPI_OBJ_MIXER 5 353 HPI_OBJ_ISTREAM = 4,
505#define HPI_OBJ_NODE 6 354 HPI_OBJ_MIXER = 5,
506#define HPI_OBJ_CONTROL 7 355 HPI_OBJ_NODE = 6,
507#define HPI_OBJ_NVMEMORY 8 356 HPI_OBJ_CONTROL = 7,
508#define HPI_OBJ_GPIO 9 357 HPI_OBJ_NVMEMORY = 8,
509#define HPI_OBJ_WATCHDOG 10 358 HPI_OBJ_GPIO = 9,
510#define HPI_OBJ_CLOCK 11 359 HPI_OBJ_WATCHDOG = 10,
511#define HPI_OBJ_PROFILE 12 360 HPI_OBJ_CLOCK = 11,
512#define HPI_OBJ_CONTROLEX 13 361 HPI_OBJ_PROFILE = 12,
513#define HPI_OBJ_ASYNCEVENT 14 362 HPI_OBJ_CONTROLEX = 13,
514 363 HPI_OBJ_ASYNCEVENT = 14
515#define HPI_OBJ_MAXINDEX 14 364#define HPI_OBJ_MAXINDEX 14
516 365};
517/******************************************* methods/functions */ 366
518 367#define HPI_OBJ_FUNCTION_SPACING 0x100
519#define HPI_OBJ_FUNCTION_SPACING 0x100 368#define HPI_FUNC_ID(obj, index) (HPI_OBJ_##obj * HPI_OBJ_FUNCTION_SPACING + index)
520#define HPI_MAKE_INDEX(obj, index) (obj * HPI_OBJ_FUNCTION_SPACING + index) 369
521#define HPI_EXTRACT_INDEX(fn) (fn & 0xff) 370#define HPI_EXTRACT_INDEX(fn) (fn & 0xff)
522 371
523/* SUB-SYSTEM */ 372enum HPI_FUNCTION_IDS {
524#define HPI_SUBSYS_OPEN HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 1) 373 HPI_SUBSYS_OPEN = HPI_FUNC_ID(SUBSYSTEM, 1),
525#define HPI_SUBSYS_GET_VERSION HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 2) 374 HPI_SUBSYS_GET_VERSION = HPI_FUNC_ID(SUBSYSTEM, 2),
526#define HPI_SUBSYS_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 3) 375 HPI_SUBSYS_GET_INFO = HPI_FUNC_ID(SUBSYSTEM, 3),
527#define HPI_SUBSYS_FIND_ADAPTERS HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 4) 376 HPI_SUBSYS_FIND_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 4),
528#define HPI_SUBSYS_CREATE_ADAPTER HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 5) 377 HPI_SUBSYS_CREATE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 5),
529#define HPI_SUBSYS_CLOSE HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 6) 378 HPI_SUBSYS_CLOSE = HPI_FUNC_ID(SUBSYSTEM, 6),
530#define HPI_SUBSYS_DELETE_ADAPTER HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 7) 379 HPI_SUBSYS_DELETE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 7),
531#define HPI_SUBSYS_DRIVER_LOAD HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 8) 380 HPI_SUBSYS_DRIVER_LOAD = HPI_FUNC_ID(SUBSYSTEM, 8),
532#define HPI_SUBSYS_DRIVER_UNLOAD HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 9) 381 HPI_SUBSYS_DRIVER_UNLOAD = HPI_FUNC_ID(SUBSYSTEM, 9),
533#define HPI_SUBSYS_READ_PORT_8 HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 10) 382 HPI_SUBSYS_READ_PORT_8 = HPI_FUNC_ID(SUBSYSTEM, 10),
534#define HPI_SUBSYS_WRITE_PORT_8 HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 11) 383 HPI_SUBSYS_WRITE_PORT_8 = HPI_FUNC_ID(SUBSYSTEM, 11),
535#define HPI_SUBSYS_GET_NUM_ADAPTERS HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 12) 384 HPI_SUBSYS_GET_NUM_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 12),
536#define HPI_SUBSYS_GET_ADAPTER HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 13) 385 HPI_SUBSYS_GET_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 13),
537#define HPI_SUBSYS_SET_NETWORK_INTERFACE HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 14) 386 HPI_SUBSYS_SET_NETWORK_INTERFACE = HPI_FUNC_ID(SUBSYSTEM, 14),
538#define HPI_SUBSYS_FUNCTION_COUNT 14 387 HPI_SUBSYS_OPTION_INFO = HPI_FUNC_ID(SUBSYSTEM, 15),
539/* ADAPTER */ 388 HPI_SUBSYS_OPTION_GET = HPI_FUNC_ID(SUBSYSTEM, 16),
540#define HPI_ADAPTER_OPEN HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 1) 389 HPI_SUBSYS_OPTION_SET = HPI_FUNC_ID(SUBSYSTEM, 17),
541#define HPI_ADAPTER_CLOSE HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 2) 390#define HPI_SUBSYS_FUNCTION_COUNT 17
542#define HPI_ADAPTER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 3) 391
543#define HPI_ADAPTER_GET_ASSERT HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 4) 392 HPI_ADAPTER_OPEN = HPI_FUNC_ID(ADAPTER, 1),
544#define HPI_ADAPTER_TEST_ASSERT HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 5) 393 HPI_ADAPTER_CLOSE = HPI_FUNC_ID(ADAPTER, 2),
545#define HPI_ADAPTER_SET_MODE HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 6) 394 HPI_ADAPTER_GET_INFO = HPI_FUNC_ID(ADAPTER, 3),
546#define HPI_ADAPTER_GET_MODE HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 7) 395 HPI_ADAPTER_GET_ASSERT = HPI_FUNC_ID(ADAPTER, 4),
547#define HPI_ADAPTER_ENABLE_CAPABILITY HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 8) 396 HPI_ADAPTER_TEST_ASSERT = HPI_FUNC_ID(ADAPTER, 5),
548#define HPI_ADAPTER_SELFTEST HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 9) 397 HPI_ADAPTER_SET_MODE = HPI_FUNC_ID(ADAPTER, 6),
549#define HPI_ADAPTER_FIND_OBJECT HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 10) 398 HPI_ADAPTER_GET_MODE = HPI_FUNC_ID(ADAPTER, 7),
550#define HPI_ADAPTER_QUERY_FLASH HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 11) 399 HPI_ADAPTER_ENABLE_CAPABILITY = HPI_FUNC_ID(ADAPTER, 8),
551#define HPI_ADAPTER_START_FLASH HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 12) 400 HPI_ADAPTER_SELFTEST = HPI_FUNC_ID(ADAPTER, 9),
552#define HPI_ADAPTER_PROGRAM_FLASH HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 13) 401 HPI_ADAPTER_FIND_OBJECT = HPI_FUNC_ID(ADAPTER, 10),
553#define HPI_ADAPTER_SET_PROPERTY HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 14) 402 HPI_ADAPTER_QUERY_FLASH = HPI_FUNC_ID(ADAPTER, 11),
554#define HPI_ADAPTER_GET_PROPERTY HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 15) 403 HPI_ADAPTER_START_FLASH = HPI_FUNC_ID(ADAPTER, 12),
555#define HPI_ADAPTER_ENUM_PROPERTY HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 16) 404 HPI_ADAPTER_PROGRAM_FLASH = HPI_FUNC_ID(ADAPTER, 13),
556#define HPI_ADAPTER_MODULE_INFO HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 17) 405 HPI_ADAPTER_SET_PROPERTY = HPI_FUNC_ID(ADAPTER, 14),
557#define HPI_ADAPTER_DEBUG_READ HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 18) 406 HPI_ADAPTER_GET_PROPERTY = HPI_FUNC_ID(ADAPTER, 15),
407 HPI_ADAPTER_ENUM_PROPERTY = HPI_FUNC_ID(ADAPTER, 16),
408 HPI_ADAPTER_MODULE_INFO = HPI_FUNC_ID(ADAPTER, 17),
409 HPI_ADAPTER_DEBUG_READ = HPI_FUNC_ID(ADAPTER, 18),
558#define HPI_ADAPTER_FUNCTION_COUNT 18 410#define HPI_ADAPTER_FUNCTION_COUNT 18
559/* OUTPUT STREAM */ 411
560#define HPI_OSTREAM_OPEN HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 1) 412 HPI_OSTREAM_OPEN = HPI_FUNC_ID(OSTREAM, 1),
561#define HPI_OSTREAM_CLOSE HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 2) 413 HPI_OSTREAM_CLOSE = HPI_FUNC_ID(OSTREAM, 2),
562#define HPI_OSTREAM_WRITE HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 3) 414 HPI_OSTREAM_WRITE = HPI_FUNC_ID(OSTREAM, 3),
563#define HPI_OSTREAM_START HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 4) 415 HPI_OSTREAM_START = HPI_FUNC_ID(OSTREAM, 4),
564#define HPI_OSTREAM_STOP HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 5) 416 HPI_OSTREAM_STOP = HPI_FUNC_ID(OSTREAM, 5),
565#define HPI_OSTREAM_RESET HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 6) 417 HPI_OSTREAM_RESET = HPI_FUNC_ID(OSTREAM, 6),
566#define HPI_OSTREAM_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 7) 418 HPI_OSTREAM_GET_INFO = HPI_FUNC_ID(OSTREAM, 7),
567#define HPI_OSTREAM_QUERY_FORMAT HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 8) 419 HPI_OSTREAM_QUERY_FORMAT = HPI_FUNC_ID(OSTREAM, 8),
568#define HPI_OSTREAM_DATA HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 9) 420 HPI_OSTREAM_DATA = HPI_FUNC_ID(OSTREAM, 9),
569#define HPI_OSTREAM_SET_VELOCITY HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 10) 421 HPI_OSTREAM_SET_VELOCITY = HPI_FUNC_ID(OSTREAM, 10),
570#define HPI_OSTREAM_SET_PUNCHINOUT HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 11) 422 HPI_OSTREAM_SET_PUNCHINOUT = HPI_FUNC_ID(OSTREAM, 11),
571#define HPI_OSTREAM_SINEGEN HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 12) 423 HPI_OSTREAM_SINEGEN = HPI_FUNC_ID(OSTREAM, 12),
572#define HPI_OSTREAM_ANC_RESET HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 13) 424 HPI_OSTREAM_ANC_RESET = HPI_FUNC_ID(OSTREAM, 13),
573#define HPI_OSTREAM_ANC_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 14) 425 HPI_OSTREAM_ANC_GET_INFO = HPI_FUNC_ID(OSTREAM, 14),
574#define HPI_OSTREAM_ANC_READ HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 15) 426 HPI_OSTREAM_ANC_READ = HPI_FUNC_ID(OSTREAM, 15),
575#define HPI_OSTREAM_SET_TIMESCALE HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 16) 427 HPI_OSTREAM_SET_TIMESCALE = HPI_FUNC_ID(OSTREAM, 16),
576#define HPI_OSTREAM_SET_FORMAT HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 17) 428 HPI_OSTREAM_SET_FORMAT = HPI_FUNC_ID(OSTREAM, 17),
577#define HPI_OSTREAM_HOSTBUFFER_ALLOC HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 18) 429 HPI_OSTREAM_HOSTBUFFER_ALLOC = HPI_FUNC_ID(OSTREAM, 18),
578#define HPI_OSTREAM_HOSTBUFFER_FREE HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 19) 430 HPI_OSTREAM_HOSTBUFFER_FREE = HPI_FUNC_ID(OSTREAM, 19),
579#define HPI_OSTREAM_GROUP_ADD HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 20) 431 HPI_OSTREAM_GROUP_ADD = HPI_FUNC_ID(OSTREAM, 20),
580#define HPI_OSTREAM_GROUP_GETMAP HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 21) 432 HPI_OSTREAM_GROUP_GETMAP = HPI_FUNC_ID(OSTREAM, 21),
581#define HPI_OSTREAM_GROUP_RESET HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 22) 433 HPI_OSTREAM_GROUP_RESET = HPI_FUNC_ID(OSTREAM, 22),
582#define HPI_OSTREAM_HOSTBUFFER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 23) 434 HPI_OSTREAM_HOSTBUFFER_GET_INFO = HPI_FUNC_ID(OSTREAM, 23),
583#define HPI_OSTREAM_WAIT_START HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 24) 435 HPI_OSTREAM_WAIT_START = HPI_FUNC_ID(OSTREAM, 24),
584#define HPI_OSTREAM_FUNCTION_COUNT 24 436#define HPI_OSTREAM_FUNCTION_COUNT 24
585/* INPUT STREAM */ 437
586#define HPI_ISTREAM_OPEN HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 1) 438 HPI_ISTREAM_OPEN = HPI_FUNC_ID(ISTREAM, 1),
587#define HPI_ISTREAM_CLOSE HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 2) 439 HPI_ISTREAM_CLOSE = HPI_FUNC_ID(ISTREAM, 2),
588#define HPI_ISTREAM_SET_FORMAT HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 3) 440 HPI_ISTREAM_SET_FORMAT = HPI_FUNC_ID(ISTREAM, 3),
589#define HPI_ISTREAM_READ HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 4) 441 HPI_ISTREAM_READ = HPI_FUNC_ID(ISTREAM, 4),
590#define HPI_ISTREAM_START HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 5) 442 HPI_ISTREAM_START = HPI_FUNC_ID(ISTREAM, 5),
591#define HPI_ISTREAM_STOP HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 6) 443 HPI_ISTREAM_STOP = HPI_FUNC_ID(ISTREAM, 6),
592#define HPI_ISTREAM_RESET HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 7) 444 HPI_ISTREAM_RESET = HPI_FUNC_ID(ISTREAM, 7),
593#define HPI_ISTREAM_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 8) 445 HPI_ISTREAM_GET_INFO = HPI_FUNC_ID(ISTREAM, 8),
594#define HPI_ISTREAM_QUERY_FORMAT HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 9) 446 HPI_ISTREAM_QUERY_FORMAT = HPI_FUNC_ID(ISTREAM, 9),
595#define HPI_ISTREAM_ANC_RESET HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 10) 447 HPI_ISTREAM_ANC_RESET = HPI_FUNC_ID(ISTREAM, 10),
596#define HPI_ISTREAM_ANC_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 11) 448 HPI_ISTREAM_ANC_GET_INFO = HPI_FUNC_ID(ISTREAM, 11),
597#define HPI_ISTREAM_ANC_WRITE HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 12) 449 HPI_ISTREAM_ANC_WRITE = HPI_FUNC_ID(ISTREAM, 12),
598#define HPI_ISTREAM_HOSTBUFFER_ALLOC HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 13) 450 HPI_ISTREAM_HOSTBUFFER_ALLOC = HPI_FUNC_ID(ISTREAM, 13),
599#define HPI_ISTREAM_HOSTBUFFER_FREE HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 14) 451 HPI_ISTREAM_HOSTBUFFER_FREE = HPI_FUNC_ID(ISTREAM, 14),
600#define HPI_ISTREAM_GROUP_ADD HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 15) 452 HPI_ISTREAM_GROUP_ADD = HPI_FUNC_ID(ISTREAM, 15),
601#define HPI_ISTREAM_GROUP_GETMAP HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 16) 453 HPI_ISTREAM_GROUP_GETMAP = HPI_FUNC_ID(ISTREAM, 16),
602#define HPI_ISTREAM_GROUP_RESET HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 17) 454 HPI_ISTREAM_GROUP_RESET = HPI_FUNC_ID(ISTREAM, 17),
603#define HPI_ISTREAM_HOSTBUFFER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 18) 455 HPI_ISTREAM_HOSTBUFFER_GET_INFO = HPI_FUNC_ID(ISTREAM, 18),
604#define HPI_ISTREAM_WAIT_START HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 19) 456 HPI_ISTREAM_WAIT_START = HPI_FUNC_ID(ISTREAM, 19),
605#define HPI_ISTREAM_FUNCTION_COUNT 19 457#define HPI_ISTREAM_FUNCTION_COUNT 19
606/* MIXER */ 458
607/* NOTE: 459/* NOTE:
608 GET_NODE_INFO, SET_CONNECTION, GET_CONNECTIONS are not currently used */ 460 GET_NODE_INFO, SET_CONNECTION, GET_CONNECTIONS are not currently used */
609#define HPI_MIXER_OPEN HPI_MAKE_INDEX(HPI_OBJ_MIXER, 1) 461 HPI_MIXER_OPEN = HPI_FUNC_ID(MIXER, 1),
610#define HPI_MIXER_CLOSE HPI_MAKE_INDEX(HPI_OBJ_MIXER, 2) 462 HPI_MIXER_CLOSE = HPI_FUNC_ID(MIXER, 2),
611#define HPI_MIXER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_MIXER, 3) 463 HPI_MIXER_GET_INFO = HPI_FUNC_ID(MIXER, 3),
612#define HPI_MIXER_GET_NODE_INFO HPI_MAKE_INDEX(HPI_OBJ_MIXER, 4) 464 HPI_MIXER_GET_NODE_INFO = HPI_FUNC_ID(MIXER, 4),
613#define HPI_MIXER_GET_CONTROL HPI_MAKE_INDEX(HPI_OBJ_MIXER, 5) 465 HPI_MIXER_GET_CONTROL = HPI_FUNC_ID(MIXER, 5),
614#define HPI_MIXER_SET_CONNECTION HPI_MAKE_INDEX(HPI_OBJ_MIXER, 6) 466 HPI_MIXER_SET_CONNECTION = HPI_FUNC_ID(MIXER, 6),
615#define HPI_MIXER_GET_CONNECTIONS HPI_MAKE_INDEX(HPI_OBJ_MIXER, 7) 467 HPI_MIXER_GET_CONNECTIONS = HPI_FUNC_ID(MIXER, 7),
616#define HPI_MIXER_GET_CONTROL_BY_INDEX HPI_MAKE_INDEX(HPI_OBJ_MIXER, 8) 468 HPI_MIXER_GET_CONTROL_BY_INDEX = HPI_FUNC_ID(MIXER, 8),
617#define HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX HPI_MAKE_INDEX(HPI_OBJ_MIXER, 9) 469 HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX = HPI_FUNC_ID(MIXER, 9),
618#define HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES HPI_MAKE_INDEX(HPI_OBJ_MIXER, 10) 470 HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES = HPI_FUNC_ID(MIXER, 10),
619#define HPI_MIXER_STORE HPI_MAKE_INDEX(HPI_OBJ_MIXER, 11) 471 HPI_MIXER_STORE = HPI_FUNC_ID(MIXER, 11),
620#define HPI_MIXER_FUNCTION_COUNT 11 472#define HPI_MIXER_FUNCTION_COUNT 11
621/* MIXER CONTROLS */ 473
622#define HPI_CONTROL_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_CONTROL, 1) 474 HPI_CONTROL_GET_INFO = HPI_FUNC_ID(CONTROL, 1),
623#define HPI_CONTROL_GET_STATE HPI_MAKE_INDEX(HPI_OBJ_CONTROL, 2) 475 HPI_CONTROL_GET_STATE = HPI_FUNC_ID(CONTROL, 2),
624#define HPI_CONTROL_SET_STATE HPI_MAKE_INDEX(HPI_OBJ_CONTROL, 3) 476 HPI_CONTROL_SET_STATE = HPI_FUNC_ID(CONTROL, 3),
625#define HPI_CONTROL_FUNCTION_COUNT 3 477#define HPI_CONTROL_FUNCTION_COUNT 3
626/* NONVOL MEMORY */ 478
627#define HPI_NVMEMORY_OPEN HPI_MAKE_INDEX(HPI_OBJ_NVMEMORY, 1) 479 HPI_NVMEMORY_OPEN = HPI_FUNC_ID(NVMEMORY, 1),
628#define HPI_NVMEMORY_READ_BYTE HPI_MAKE_INDEX(HPI_OBJ_NVMEMORY, 2) 480 HPI_NVMEMORY_READ_BYTE = HPI_FUNC_ID(NVMEMORY, 2),
629#define HPI_NVMEMORY_WRITE_BYTE HPI_MAKE_INDEX(HPI_OBJ_NVMEMORY, 3) 481 HPI_NVMEMORY_WRITE_BYTE = HPI_FUNC_ID(NVMEMORY, 3),
630#define HPI_NVMEMORY_FUNCTION_COUNT 3 482#define HPI_NVMEMORY_FUNCTION_COUNT 3
631/* GPIO */ 483
632#define HPI_GPIO_OPEN HPI_MAKE_INDEX(HPI_OBJ_GPIO, 1) 484 HPI_GPIO_OPEN = HPI_FUNC_ID(GPIO, 1),
633#define HPI_GPIO_READ_BIT HPI_MAKE_INDEX(HPI_OBJ_GPIO, 2) 485 HPI_GPIO_READ_BIT = HPI_FUNC_ID(GPIO, 2),
634#define HPI_GPIO_WRITE_BIT HPI_MAKE_INDEX(HPI_OBJ_GPIO, 3) 486 HPI_GPIO_WRITE_BIT = HPI_FUNC_ID(GPIO, 3),
635#define HPI_GPIO_READ_ALL HPI_MAKE_INDEX(HPI_OBJ_GPIO, 4) 487 HPI_GPIO_READ_ALL = HPI_FUNC_ID(GPIO, 4),
636#define HPI_GPIO_WRITE_STATUS HPI_MAKE_INDEX(HPI_OBJ_GPIO, 5) 488 HPI_GPIO_WRITE_STATUS = HPI_FUNC_ID(GPIO, 5),
637#define HPI_GPIO_FUNCTION_COUNT 5 489#define HPI_GPIO_FUNCTION_COUNT 5
638/* ASYNC EVENT */ 490
639#define HPI_ASYNCEVENT_OPEN HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 1) 491 HPI_ASYNCEVENT_OPEN = HPI_FUNC_ID(ASYNCEVENT, 1),
640#define HPI_ASYNCEVENT_CLOSE HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 2) 492 HPI_ASYNCEVENT_CLOSE = HPI_FUNC_ID(ASYNCEVENT, 2),
641#define HPI_ASYNCEVENT_WAIT HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 3) 493 HPI_ASYNCEVENT_WAIT = HPI_FUNC_ID(ASYNCEVENT, 3),
642#define HPI_ASYNCEVENT_GETCOUNT HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 4) 494 HPI_ASYNCEVENT_GETCOUNT = HPI_FUNC_ID(ASYNCEVENT, 4),
643#define HPI_ASYNCEVENT_GET HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 5) 495 HPI_ASYNCEVENT_GET = HPI_FUNC_ID(ASYNCEVENT, 5),
644#define HPI_ASYNCEVENT_SENDEVENTS HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 6) 496 HPI_ASYNCEVENT_SENDEVENTS = HPI_FUNC_ID(ASYNCEVENT, 6),
645#define HPI_ASYNCEVENT_FUNCTION_COUNT 6 497#define HPI_ASYNCEVENT_FUNCTION_COUNT 6
646/* WATCH-DOG */ 498
647#define HPI_WATCHDOG_OPEN HPI_MAKE_INDEX(HPI_OBJ_WATCHDOG, 1) 499 HPI_WATCHDOG_OPEN = HPI_FUNC_ID(WATCHDOG, 1),
648#define HPI_WATCHDOG_SET_TIME HPI_MAKE_INDEX(HPI_OBJ_WATCHDOG, 2) 500 HPI_WATCHDOG_SET_TIME = HPI_FUNC_ID(WATCHDOG, 2),
649#define HPI_WATCHDOG_PING HPI_MAKE_INDEX(HPI_OBJ_WATCHDOG, 3) 501 HPI_WATCHDOG_PING = HPI_FUNC_ID(WATCHDOG, 3),
650/* CLOCK */ 502
651#define HPI_CLOCK_OPEN HPI_MAKE_INDEX(HPI_OBJ_CLOCK, 1) 503 HPI_CLOCK_OPEN = HPI_FUNC_ID(CLOCK, 1),
652#define HPI_CLOCK_SET_TIME HPI_MAKE_INDEX(HPI_OBJ_CLOCK, 2) 504 HPI_CLOCK_SET_TIME = HPI_FUNC_ID(CLOCK, 2),
653#define HPI_CLOCK_GET_TIME HPI_MAKE_INDEX(HPI_OBJ_CLOCK, 3) 505 HPI_CLOCK_GET_TIME = HPI_FUNC_ID(CLOCK, 3),
654/* PROFILE */ 506
655#define HPI_PROFILE_OPEN_ALL HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 1) 507 HPI_PROFILE_OPEN_ALL = HPI_FUNC_ID(PROFILE, 1),
656#define HPI_PROFILE_START_ALL HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 2) 508 HPI_PROFILE_START_ALL = HPI_FUNC_ID(PROFILE, 2),
657#define HPI_PROFILE_STOP_ALL HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 3) 509 HPI_PROFILE_STOP_ALL = HPI_FUNC_ID(PROFILE, 3),
658#define HPI_PROFILE_GET HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 4) 510 HPI_PROFILE_GET = HPI_FUNC_ID(PROFILE, 4),
659#define HPI_PROFILE_GET_IDLECOUNT HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 5) 511 HPI_PROFILE_GET_IDLECOUNT = HPI_FUNC_ID(PROFILE, 5),
660#define HPI_PROFILE_GET_NAME HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 6) 512 HPI_PROFILE_GET_NAME = HPI_FUNC_ID(PROFILE, 6),
661#define HPI_PROFILE_GET_UTILIZATION HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 7) 513 HPI_PROFILE_GET_UTILIZATION = HPI_FUNC_ID(PROFILE, 7)
662#define HPI_PROFILE_FUNCTION_COUNT 7 514#define HPI_PROFILE_FUNCTION_COUNT 7
663/* ////////////////////////////////////////////////////////////////////// */ 515};
664/* PRIVATE ATTRIBUTES */
665 516
666/* ////////////////////////////////////////////////////////////////////// */ 517/* ////////////////////////////////////////////////////////////////////// */
667/* STRUCTURES */ 518/* STRUCTURES */
@@ -672,18 +523,7 @@ Threshold is a -ve number in units of dB/100,
672/** PCI bus resource */ 523/** PCI bus resource */
673struct hpi_pci { 524struct hpi_pci {
674 u32 __iomem *ap_mem_base[HPI_MAX_ADAPTER_MEM_SPACES]; 525 u32 __iomem *ap_mem_base[HPI_MAX_ADAPTER_MEM_SPACES];
675 struct pci_dev *p_os_data; 526 struct pci_dev *pci_dev;
676
677#ifndef HPI64BIT /* keep structure size constant */
678 u32 padding[HPI_MAX_ADAPTER_MEM_SPACES + 1];
679#endif
680 u16 vendor_id;
681 u16 device_id;
682 u16 subsys_vendor_id;
683 u16 subsys_device_id;
684 u16 bus_number;
685 u16 device_number;
686 u32 interrupt;
687}; 527};
688 528
689struct hpi_resource { 529struct hpi_resource {
@@ -783,24 +623,18 @@ struct hpi_subsys_res {
783 u16 aw_adapter_list[HPI_MAX_ADAPTERS]; 623 u16 aw_adapter_list[HPI_MAX_ADAPTERS];
784}; 624};
785 625
786struct hpi_adapter_msg {
787 u32 adapter_mode; /* adapter mode */
788 u16 assert_id; /* assert number for "test assert" call
789 object_index for find object call
790 query_or_set for hpi_adapter_set_mode_ex() */
791 u16 object_type; /* for adapter find object call */
792};
793
794union hpi_adapterx_msg { 626union hpi_adapterx_msg {
795 struct hpi_adapter_msg adapter;
796 struct { 627 struct {
797 u32 offset; 628 u32 dsp_address;
798 } query_flash; 629 u32 count_bytes;
630 } debug_read;
799 struct { 631 struct {
800 u32 offset; 632 u32 adapter_mode;
801 u32 length; 633 u16 query_or_set;
802 u32 key; 634 } mode;
803 } start_flash; 635 struct {
636 u16 index;
637 } module_info;
804 struct { 638 struct {
805 u32 checksum; 639 u32 checksum;
806 u16 sequence; 640 u16 sequence;
@@ -809,28 +643,38 @@ union hpi_adapterx_msg {
809 u16 unused; 643 u16 unused;
810 } program_flash; 644 } program_flash;
811 struct { 645 struct {
646 u16 index;
647 u16 what;
648 u16 property_index;
649 } property_enum;
650 struct {
812 u16 property; 651 u16 property;
813 u16 parameter1; 652 u16 parameter1;
814 u16 parameter2; 653 u16 parameter2;
815 } property_set; 654 } property_set;
816 struct { 655 struct {
817 u16 index; 656 u32 offset;
818 u16 what; 657 } query_flash;
819 u16 property_index;
820 } property_enum;
821 struct { 658 struct {
822 u16 index; 659 u32 pad32;
823 } module_info; 660 u16 key1;
661 u16 key2;
662 } restart;
824 struct { 663 struct {
825 u32 dsp_address; 664 u32 offset;
826 u32 count_bytes; 665 u32 length;
827 } debug_read; 666 u32 key;
667 } start_flash;
668 struct {
669 u32 pad32;
670 u16 value;
671 } test_assert;
828}; 672};
829 673
830struct hpi_adapter_res { 674struct hpi_adapter_res {
831 u32 serial_number; 675 u32 serial_number;
832 u16 adapter_type; 676 u16 adapter_type;
833 u16 adapter_index; /* is this needed? also used for dsp_index */ 677 u16 adapter_index;
834 u16 num_instreams; 678 u16 num_instreams;
835 u16 num_outstreams; 679 u16 num_outstreams;
836 u16 num_mixers; 680 u16 num_mixers;
@@ -839,12 +683,18 @@ struct hpi_adapter_res {
839}; 683};
840 684
841union hpi_adapterx_res { 685union hpi_adapterx_res {
842 struct hpi_adapter_res adapter; 686 struct hpi_adapter_res info;
843 struct { 687 struct {
844 u32 checksum; 688 u32 p1;
845 u32 length; 689 u16 count;
846 u32 version; 690 u16 dsp_index;
847 } query_flash; 691 u32 p2;
692 u32 dsp_msg_addr;
693 char sz_message[HPI_STRING_LEN];
694 } assert;
695 struct {
696 u32 adapter_mode;
697 } mode;
848 struct { 698 struct {
849 u16 sequence; 699 u16 sequence;
850 } program_flash; 700 } program_flash;
@@ -852,6 +702,11 @@ union hpi_adapterx_res {
852 u16 parameter1; 702 u16 parameter1;
853 u16 parameter2; 703 u16 parameter2;
854 } property_get; 704 } property_get;
705 struct {
706 u32 checksum;
707 u32 length;
708 u32 version;
709 } query_flash;
855}; 710};
856 711
857struct hpi_stream_msg { 712struct hpi_stream_msg {
@@ -911,7 +766,7 @@ struct hpi_stream_res {
911struct hpi_mixer_msg { 766struct hpi_mixer_msg {
912 u16 control_index; 767 u16 control_index;
913 u16 control_type; /* = HPI_CONTROL_METER _VOLUME etc */ 768 u16 control_type; /* = HPI_CONTROL_METER _VOLUME etc */
914 u16 padding1; /* maintain alignment of subsequent fields */ 769 u16 padding1; /* Maintain alignment of subsequent fields */
915 u16 node_type1; /* = HPI_SOURCENODE_LINEIN etc */ 770 u16 node_type1; /* = HPI_SOURCENODE_LINEIN etc */
916 u16 node_index1; /* = 0..N */ 771 u16 node_index1; /* = 0..N */
917 u16 node_type2; 772 u16 node_type2;
@@ -1000,12 +855,16 @@ union hpi_control_union_res {
1000 u32 band; 855 u32 band;
1001 u32 frequency; 856 u32 frequency;
1002 u32 gain; 857 u32 gain;
1003 u32 level;
1004 u32 deemphasis; 858 u32 deemphasis;
1005 struct { 859 struct {
1006 u32 data[2]; 860 u32 data[2];
1007 u32 bLER; 861 u32 bLER;
1008 } rds; 862 } rds;
863 short s_level;
864 struct {
865 u16 value;
866 u16 mask;
867 } status;
1009 } tuner; 868 } tuner;
1010 struct { 869 struct {
1011 char sz_data[8]; 870 char sz_data[8];
@@ -1178,11 +1037,11 @@ struct hpi_profile_res_open {
1178}; 1037};
1179 1038
1180struct hpi_profile_res_time { 1039struct hpi_profile_res_time {
1181 u32 micro_seconds; 1040 u32 total_tick_count;
1182 u32 call_count; 1041 u32 call_count;
1183 u32 max_micro_seconds; 1042 u32 max_tick_count;
1184 u32 min_micro_seconds; 1043 u32 ticks_per_millisecond;
1185 u16 seconds; 1044 u16 profile_interval;
1186}; 1045};
1187 1046
1188struct hpi_profile_res_name { 1047struct hpi_profile_res_name {
@@ -1218,7 +1077,6 @@ struct hpi_message {
1218 u16 obj_index; /* */ 1077 u16 obj_index; /* */
1219 union { 1078 union {
1220 struct hpi_subsys_msg s; 1079 struct hpi_subsys_msg s;
1221 struct hpi_adapter_msg a;
1222 union hpi_adapterx_msg ax; 1080 union hpi_adapterx_msg ax;
1223 struct hpi_stream_msg d; 1081 struct hpi_stream_msg d;
1224 struct hpi_mixer_msg m; 1082 struct hpi_mixer_msg m;
@@ -1239,7 +1097,7 @@ struct hpi_message {
1239}; 1097};
1240 1098
1241#define HPI_MESSAGE_SIZE_BY_OBJECT { \ 1099#define HPI_MESSAGE_SIZE_BY_OBJECT { \
1242 sizeof(struct hpi_message_header) , /* default, no object type 0 */ \ 1100 sizeof(struct hpi_message_header) , /* Default, no object type 0 */ \
1243 sizeof(struct hpi_message_header) + sizeof(struct hpi_subsys_msg),\ 1101 sizeof(struct hpi_message_header) + sizeof(struct hpi_subsys_msg),\
1244 sizeof(struct hpi_message_header) + sizeof(union hpi_adapterx_msg),\ 1102 sizeof(struct hpi_message_header) + sizeof(union hpi_adapterx_msg),\
1245 sizeof(struct hpi_message_header) + sizeof(struct hpi_stream_msg),\ 1103 sizeof(struct hpi_message_header) + sizeof(struct hpi_stream_msg),\
@@ -1277,7 +1135,6 @@ struct hpi_response {
1277 u16 specific_error; /* adapter specific error */ 1135 u16 specific_error; /* adapter specific error */
1278 union { 1136 union {
1279 struct hpi_subsys_res s; 1137 struct hpi_subsys_res s;
1280 struct hpi_adapter_res a;
1281 union hpi_adapterx_res ax; 1138 union hpi_adapterx_res ax;
1282 struct hpi_stream_res d; 1139 struct hpi_stream_res d;
1283 struct hpi_mixer_res m; 1140 struct hpi_mixer_res m;
@@ -1297,7 +1154,7 @@ struct hpi_response {
1297}; 1154};
1298 1155
1299#define HPI_RESPONSE_SIZE_BY_OBJECT { \ 1156#define HPI_RESPONSE_SIZE_BY_OBJECT { \
1300 sizeof(struct hpi_response_header) ,/* default, no object type 0 */ \ 1157 sizeof(struct hpi_response_header) ,/* Default, no object type 0 */ \
1301 sizeof(struct hpi_response_header) + sizeof(struct hpi_subsys_res),\ 1158 sizeof(struct hpi_response_header) + sizeof(struct hpi_subsys_res),\
1302 sizeof(struct hpi_response_header) + sizeof(union hpi_adapterx_res),\ 1159 sizeof(struct hpi_response_header) + sizeof(union hpi_adapterx_res),\
1303 sizeof(struct hpi_response_header) + sizeof(struct hpi_stream_res),\ 1160 sizeof(struct hpi_response_header) + sizeof(struct hpi_stream_res),\
@@ -1394,6 +1251,17 @@ struct hpi_res_adapter_program_flash {
1394 sizeof(struct hpi_response_header) - sizeof(u16)]; 1251 sizeof(struct hpi_response_header) - sizeof(u16)];
1395}; 1252};
1396 1253
1254struct hpi_msg_adapter_debug_read {
1255 struct hpi_message_header h;
1256 u32 dsp_address;
1257 u32 count_bytes;
1258};
1259
1260struct hpi_res_adapter_debug_read {
1261 struct hpi_response_header h;
1262 u8 bytes[256];
1263};
1264
1397#if 1 1265#if 1
1398#define hpi_message_header_v1 hpi_message_header 1266#define hpi_message_header_v1 hpi_message_header
1399#define hpi_response_header_v1 hpi_response_header 1267#define hpi_response_header_v1 hpi_response_header
@@ -1414,23 +1282,10 @@ struct hpi_response_header_v1 {
1414}; 1282};
1415#endif 1283#endif
1416 1284
1417/* STRV HPI Packet */
1418struct hpi_msg_strv {
1419 struct hpi_message_header h;
1420 struct hpi_entity strv;
1421};
1422
1423struct hpi_res_strv {
1424 struct hpi_response_header h;
1425 struct hpi_entity strv;
1426};
1427#define MIN_STRV_PACKET_SIZE sizeof(struct hpi_res_strv)
1428
1429struct hpi_msg_payload_v0 { 1285struct hpi_msg_payload_v0 {
1430 struct hpi_message_header h; 1286 struct hpi_message_header h;
1431 union { 1287 union {
1432 struct hpi_subsys_msg s; 1288 struct hpi_subsys_msg s;
1433 struct hpi_adapter_msg a;
1434 union hpi_adapterx_msg ax; 1289 union hpi_adapterx_msg ax;
1435 struct hpi_stream_msg d; 1290 struct hpi_stream_msg d;
1436 struct hpi_mixer_msg m; 1291 struct hpi_mixer_msg m;
@@ -1451,7 +1306,6 @@ struct hpi_res_payload_v0 {
1451 struct hpi_response_header h; 1306 struct hpi_response_header h;
1452 union { 1307 union {
1453 struct hpi_subsys_res s; 1308 struct hpi_subsys_res s;
1454 struct hpi_adapter_res a;
1455 union hpi_adapterx_res ax; 1309 union hpi_adapterx_res ax;
1456 struct hpi_stream_res d; 1310 struct hpi_stream_res d;
1457 struct hpi_mixer_res m; 1311 struct hpi_mixer_res m;
@@ -1471,13 +1325,13 @@ struct hpi_res_payload_v0 {
1471union hpi_message_buffer_v1 { 1325union hpi_message_buffer_v1 {
1472 struct hpi_message m0; /* version 0 */ 1326 struct hpi_message m0; /* version 0 */
1473 struct hpi_message_header_v1 h; 1327 struct hpi_message_header_v1 h;
1474 unsigned char buf[HPI_MAX_PAYLOAD_SIZE]; 1328 u8 buf[HPI_MAX_PAYLOAD_SIZE];
1475}; 1329};
1476 1330
1477union hpi_response_buffer_v1 { 1331union hpi_response_buffer_v1 {
1478 struct hpi_response r0; /* version 0 */ 1332 struct hpi_response r0; /* version 0 */
1479 struct hpi_response_header_v1 h; 1333 struct hpi_response_header_v1 h;
1480 unsigned char buf[HPI_MAX_PAYLOAD_SIZE]; 1334 u8 buf[HPI_MAX_PAYLOAD_SIZE];
1481}; 1335};
1482 1336
1483compile_time_assert((sizeof(union hpi_message_buffer_v1) <= 1337compile_time_assert((sizeof(union hpi_message_buffer_v1) <=
@@ -1499,6 +1353,11 @@ struct hpi_control_defn {
1499/*////////////////////////////////////////////////////////////////////////// */ 1353/*////////////////////////////////////////////////////////////////////////// */
1500/* declarations for control caching (internal to HPI<->DSP interaction) */ 1354/* declarations for control caching (internal to HPI<->DSP interaction) */
1501 1355
1356/** indicates a cached u16 value is invalid. */
1357#define HPI_CACHE_INVALID_UINT16 0xFFFF
1358/** indicates a cached short value is invalid. */
1359#define HPI_CACHE_INVALID_SHORT -32768
1360
1502/** A compact representation of (part of) a controls state. 1361/** A compact representation of (part of) a controls state.
1503Used for efficient transfer of the control state 1362Used for efficient transfer of the control state
1504between DSP and host or across a network 1363between DSP and host or across a network
@@ -1512,58 +1371,103 @@ struct hpi_control_cache_info {
1512 u16 control_index; 1371 u16 control_index;
1513}; 1372};
1514 1373
1515struct hpi_control_cache_single { 1374struct hpi_control_cache_vol {
1375 struct hpi_control_cache_info i;
1376 short an_log[2];
1377 char temp_padding[4];
1378};
1379
1380struct hpi_control_cache_meter {
1381 struct hpi_control_cache_info i;
1382 short an_log_peak[2];
1383 short an_logRMS[2];
1384};
1385
1386struct hpi_control_cache_channelmode {
1387 struct hpi_control_cache_info i;
1388 u16 mode;
1389 char temp_padding[6];
1390};
1391
1392struct hpi_control_cache_mux {
1393 struct hpi_control_cache_info i;
1394 u16 source_node_type;
1395 u16 source_node_index;
1396 char temp_padding[4];
1397};
1398
1399struct hpi_control_cache_level {
1400 struct hpi_control_cache_info i;
1401 short an_log[2];
1402 char temp_padding[4];
1403};
1404
1405struct hpi_control_cache_tuner {
1406 struct hpi_control_cache_info i;
1407 u32 freq_ink_hz;
1408 u16 band;
1409 short s_level_avg;
1410};
1411
1412struct hpi_control_cache_aes3rx {
1413 struct hpi_control_cache_info i;
1414 u32 error_status;
1415 u32 format;
1416};
1417
1418struct hpi_control_cache_aes3tx {
1419 struct hpi_control_cache_info i;
1420 u32 format;
1421 char temp_padding[4];
1422};
1423
1424struct hpi_control_cache_tonedetector {
1425 struct hpi_control_cache_info i;
1426 u16 state;
1427 char temp_padding[6];
1428};
1429
1430struct hpi_control_cache_silencedetector {
1431 struct hpi_control_cache_info i;
1432 u32 state;
1433 char temp_padding[4];
1434};
1435
1436struct hpi_control_cache_sampleclock {
1437 struct hpi_control_cache_info i;
1438 u16 source;
1439 u16 source_index;
1440 u32 sample_rate;
1441};
1442
1443struct hpi_control_cache_microphone {
1444 struct hpi_control_cache_info i;
1445 u16 phantom_state;
1446 char temp_padding[6];
1447};
1448
1449struct hpi_control_cache_generic {
1516 struct hpi_control_cache_info i; 1450 struct hpi_control_cache_info i;
1451 u32 dw1;
1452 u32 dw2;
1453};
1454
1455struct hpi_control_cache_single {
1517 union { 1456 union {
1518 struct { /* volume */ 1457 struct hpi_control_cache_info i;
1519 short an_log[2]; 1458 struct hpi_control_cache_vol vol;
1520 } v; 1459 struct hpi_control_cache_meter meter;
1521 struct { /* peak meter */ 1460 struct hpi_control_cache_channelmode mode;
1522 short an_log_peak[2]; 1461 struct hpi_control_cache_mux mux;
1523 short an_logRMS[2]; 1462 struct hpi_control_cache_level level;
1524 } p; 1463 struct hpi_control_cache_tuner tuner;
1525 struct { /* channel mode */ 1464 struct hpi_control_cache_aes3rx aes3rx;
1526 u16 mode; 1465 struct hpi_control_cache_aes3tx aes3tx;
1527 } m; 1466 struct hpi_control_cache_tonedetector tone;
1528 struct { /* multiplexer */ 1467 struct hpi_control_cache_silencedetector silence;
1529 u16 source_node_type; 1468 struct hpi_control_cache_sampleclock clk;
1530 u16 source_node_index; 1469 struct hpi_control_cache_microphone microphone;
1531 } x; 1470 struct hpi_control_cache_generic generic;
1532 struct { /* level/trim */
1533 short an_log[2];
1534 } l;
1535 struct { /* tuner - partial caching.
1536 some attributes go to the DSP. */
1537 u32 freq_ink_hz;
1538 u16 band;
1539 u16 level;
1540 } t;
1541 struct { /* AESEBU rx status */
1542 u32 error_status;
1543 u32 source;
1544 } aes3rx;
1545 struct { /* AESEBU tx */
1546 u32 format;
1547 } aes3tx;
1548 struct { /* tone detector */
1549 u16 state;
1550 } tone;
1551 struct { /* silence detector */
1552 u32 state;
1553 u32 count;
1554 } silence;
1555 struct { /* sample clock */
1556 u16 source;
1557 u16 source_index;
1558 u32 sample_rate;
1559 } clk;
1560 struct { /* microphone control */
1561 u16 state;
1562 } phantom_power;
1563 struct { /* generic control */
1564 u32 dw1;
1565 u32 dw2;
1566 } g;
1567 } u; 1471 } u;
1568}; 1472};
1569 1473
diff --git a/sound/pci/asihpi/hpicmn.c b/sound/pci/asihpi/hpicmn.c
index d67f4d3db911..793236ef0a54 100644
--- a/sound/pci/asihpi/hpicmn.c
+++ b/sound/pci/asihpi/hpicmn.c
@@ -26,6 +26,8 @@
26 26
27#include "hpi_internal.h" 27#include "hpi_internal.h"
28#include "hpidebug.h" 28#include "hpidebug.h"
29#include "hpimsginit.h"
30
29#include "hpicmn.h" 31#include "hpicmn.h"
30 32
31struct hpi_adapters_list { 33struct hpi_adapters_list {
@@ -43,14 +45,22 @@ static struct hpi_adapters_list adapters;
43**/ 45**/
44u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr) 46u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr)
45{ 47{
46 u16 error = 0; 48 if (phr->type != HPI_TYPE_RESPONSE) {
49 HPI_DEBUG_LOG(ERROR, "header type %d invalid", phr->type);
50 return HPI_ERROR_INVALID_RESPONSE;
51 }
52
53 if (phr->object != phm->object) {
54 HPI_DEBUG_LOG(ERROR, "header object %d invalid", phr->object);
55 return HPI_ERROR_INVALID_RESPONSE;
56 }
47 57
48 if ((phr->type != HPI_TYPE_RESPONSE) 58 if (phr->function != phm->function) {
49 || (phr->object != phm->object) 59 HPI_DEBUG_LOG(ERROR, "header type %d invalid", phr->function);
50 || (phr->function != phm->function)) 60 return HPI_ERROR_INVALID_RESPONSE;
51 error = HPI_ERROR_INVALID_RESPONSE; 61 }
52 62
53 return error; 63 return 0;
54} 64}
55 65
56u16 hpi_add_adapter(struct hpi_adapter_obj *pao) 66u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
@@ -76,17 +86,22 @@ u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
76 adapters.gw_num_adapters++; 86 adapters.gw_num_adapters++;
77 87
78unlock: 88unlock:
79 hpios_alistlock_un_lock(&adapters); 89 hpios_alistlock_unlock(&adapters);
80 return retval; 90 return retval;
81} 91}
82 92
83void hpi_delete_adapter(struct hpi_adapter_obj *pao) 93void hpi_delete_adapter(struct hpi_adapter_obj *pao)
84{ 94{
85 memset(pao, 0, sizeof(struct hpi_adapter_obj)); 95 if (!pao->adapter_type) {
96 HPI_DEBUG_LOG(ERROR, "removing null adapter?\n");
97 return;
98 }
86 99
87 hpios_alistlock_lock(&adapters); 100 hpios_alistlock_lock(&adapters);
88 adapters.gw_num_adapters--; /* dec the number of adapters */ 101 if (adapters.adapter[pao->index].adapter_type)
89 hpios_alistlock_un_lock(&adapters); 102 adapters.gw_num_adapters--;
103 memset(&adapters.adapter[pao->index], 0, sizeof(adapters.adapter[0]));
104 hpios_alistlock_unlock(&adapters);
90} 105}
91 106
92/** 107/**
@@ -125,51 +140,35 @@ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index)
125* wipe an HPI_ADAPTERS_LIST structure. 140* wipe an HPI_ADAPTERS_LIST structure.
126* 141*
127**/ 142**/
128static void wipe_adapter_list(void 143static void wipe_adapter_list(void)
129 )
130{ 144{
131 memset(&adapters, 0, sizeof(adapters)); 145 memset(&adapters, 0, sizeof(adapters));
132} 146}
133 147
134/** 148static void subsys_get_adapter(struct hpi_message *phm,
135* SubSysGetAdapters fills awAdapterList in an struct hpi_response structure 149 struct hpi_response *phr)
136* with all adapters in the given HPI_ADAPTERS_LIST.
137*
138*/
139static void subsys_get_adapters(struct hpi_response *phr)
140{ 150{
141 /* fill in the response adapter array with the position */ 151 int count = phm->obj_index;
142 /* identified by the adapter number/index of the adapters in */ 152 u16 index = 0;
143 /* this HPI */
144 /* i.e. if we have an A120 with it's jumper set to */
145 /* Adapter Number 2 then put an Adapter type A120 in the */
146 /* array in position 1 */
147 /* NOTE: AdapterNumber is 1..N, Index is 0..N-1 */
148
149 /* input: NONE */
150 /* output: wNumAdapters */
151 /* awAdapter[] */
152 /* */
153
154 short i;
155 struct hpi_adapter_obj *pao = NULL;
156 153
157 HPI_DEBUG_LOG(VERBOSE, "subsys_get_adapters\n"); 154 /* find the nCount'th nonzero adapter in array */
158 155 for (index = 0; index < HPI_MAX_ADAPTERS; index++) {
159 /* for each adapter, place it's type in the position of the array */ 156 if (adapters.adapter[index].adapter_type) {
160 /* corresponding to it's adapter number */ 157 if (count == 0)
161 for (i = 0; i < adapters.gw_num_adapters; i++) { 158 break;
162 pao = &adapters.adapter[i]; 159 count--;
163 if (phr->u.s.aw_adapter_list[pao->index] != 0) {
164 phr->error = HPI_DUPLICATE_ADAPTER_NUMBER;
165 phr->specific_error = pao->index;
166 return;
167 } 160 }
168 phr->u.s.aw_adapter_list[pao->index] = pao->adapter_type;
169 } 161 }
170 162
171 phr->u.s.num_adapters = adapters.gw_num_adapters; 163 if (index < HPI_MAX_ADAPTERS) {
172 phr->error = 0; /* the function completed OK; */ 164 phr->u.s.adapter_index = adapters.adapter[index].index;
165 phr->u.s.aw_adapter_list[0] =
166 adapters.adapter[index].adapter_type;
167 } else {
168 phr->u.s.adapter_index = 0;
169 phr->u.s.aw_adapter_list[0] = 0;
170 phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER;
171 }
173} 172}
174 173
175static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC) 174static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC)
@@ -178,67 +177,88 @@ static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC)
178 int cached = 0; 177 int cached = 0;
179 if (!pC) 178 if (!pC)
180 return 0; 179 return 0;
181 if ((!pC->init) && (pC->p_cache != NULL) && (pC->control_count)
182 && (pC->cache_size_in_bytes)
183 ) {
184 u32 *p_master_cache;
185 pC->init = 1;
186 180
187 p_master_cache = (u32 *)pC->p_cache; 181 if (pC->init)
188 HPI_DEBUG_LOG(VERBOSE, "check %d controls\n", 182 return pC->init;
183
184 if (!pC->p_cache)
185 return 0;
186
187 if (pC->control_count && pC->cache_size_in_bytes) {
188 char *p_master_cache;
189 unsigned int byte_count = 0;
190
191 p_master_cache = (char *)pC->p_cache;
192 HPI_DEBUG_LOG(DEBUG, "check %d controls\n",
189 pC->control_count); 193 pC->control_count);
190 for (i = 0; i < pC->control_count; i++) { 194 for (i = 0; i < pC->control_count; i++) {
191 struct hpi_control_cache_info *info = 195 struct hpi_control_cache_info *info =
192 (struct hpi_control_cache_info *) 196 (struct hpi_control_cache_info *)
193 p_master_cache; 197 &p_master_cache[byte_count];
198
199 if (!info->size_in32bit_words) {
200 /* ? This is a severe error, the cache is probably
201 corrupted. Minimum valid entry size is
202 sizeof(struct hpi_control_cache_info) */
203 HPI_DEBUG_LOG(ERROR,
204 "zero size cache entry %d\n", i);
205 break;
206 }
194 207
195 if (info->control_type) { 208 if (info->control_type) {
196 pC->p_info[i] = info; 209 pC->p_info[info->control_index] = info;
197 cached++; 210 cached++;
198 } else 211 } else /* dummy cache entry */
199 pC->p_info[i] = NULL; 212 pC->p_info[info->control_index] = NULL;
200 213
201 if (info->size_in32bit_words) 214 byte_count += info->size_in32bit_words * 4;
202 p_master_cache += info->size_in32bit_words;
203 else
204 p_master_cache +=
205 sizeof(struct
206 hpi_control_cache_single) /
207 sizeof(u32);
208 215
209 HPI_DEBUG_LOG(VERBOSE, 216 HPI_DEBUG_LOG(VERBOSE,
210 "cached %d, pinfo %p index %d type %d\n", 217 "cached %d, pinfo %p index %d type %d size %d\n",
211 cached, pC->p_info[i], info->control_index, 218 cached, pC->p_info[info->control_index],
212 info->control_type); 219 info->control_index, info->control_type,
220 info->size_in32bit_words);
221
222 /* quit loop early if whole cache has been scanned. */
223 /* pC->dwControlCount is the maximum possible entries, */
224 /* but some may not be in the cache at all */
225 if (byte_count >= pC->cache_size_in_bytes)
226 break;
227 /* have seen last control index */
228 if (info->control_index == pC->control_count - 1)
229 break;
213 } 230 }
214 /* 231
215 We didn't find anything to cache, so try again later ! 232 if (byte_count != pC->cache_size_in_bytes)
216 */ 233 HPI_DEBUG_LOG(WARNING,
217 if (!cached) 234 "bytecount %d != cache size %d", byte_count,
218 pC->init = 0; 235 pC->cache_size_in_bytes);
236 else
237 HPI_DEBUG_LOG(DEBUG,
238 "cache good. bytecount == cache size = %d",
239 byte_count);
240
241 pC->init = cached;
219 } 242 }
220 return pC->init; 243 return pC->init;
221} 244}
222 245
223/** Find a control. 246/** Find a control.
224*/ 247*/
225static short find_control(struct hpi_message *phm, 248static short find_control(u16 control_index,
226 struct hpi_control_cache *p_cache, struct hpi_control_cache_info **pI, 249 struct hpi_control_cache *p_cache, struct hpi_control_cache_info **pI)
227 u16 *pw_control_index)
228{ 250{
229 *pw_control_index = phm->obj_index;
230
231 if (!control_cache_alloc_check(p_cache)) { 251 if (!control_cache_alloc_check(p_cache)) {
232 HPI_DEBUG_LOG(VERBOSE, 252 HPI_DEBUG_LOG(VERBOSE,
233 "control_cache_alloc_check() failed. adap%d ci%d\n", 253 "control_cache_alloc_check() failed %d\n",
234 phm->adapter_index, *pw_control_index); 254 control_index);
235 return 0; 255 return 0;
236 } 256 }
237 257
238 *pI = p_cache->p_info[*pw_control_index]; 258 *pI = p_cache->p_info[control_index];
239 if (!*pI) { 259 if (!*pI) {
240 HPI_DEBUG_LOG(VERBOSE, "uncached adap %d, control %d\n", 260 HPI_DEBUG_LOG(VERBOSE, "Uncached Control %d\n",
241 phm->adapter_index, *pw_control_index); 261 control_index);
242 return 0; 262 return 0;
243 } else { 263 } else {
244 HPI_DEBUG_LOG(VERBOSE, "find_control() type %d\n", 264 HPI_DEBUG_LOG(VERBOSE, "find_control() type %d\n",
@@ -257,11 +277,14 @@ short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache,
257 if ((phm->function == HPI_CONTROL_GET_STATE) 277 if ((phm->function == HPI_CONTROL_GET_STATE)
258 && (phm->object == HPI_OBJ_CONTROLEX) 278 && (phm->object == HPI_OBJ_CONTROLEX)
259 ) { 279 ) {
260 u16 control_index;
261 struct hpi_control_cache_info *pI; 280 struct hpi_control_cache_info *pI;
262 281
263 if (!find_control(phm, p_cache, &pI, &control_index)) 282 if (!find_control(phm->obj_index, p_cache, &pI)) {
283 HPI_DEBUG_LOG(VERBOSE,
284 "HPICMN find_control() failed for adap %d\n",
285 phm->adapter_index);
264 return 0; 286 return 0;
287 }
265 } 288 }
266 return 0; 289 return 0;
267} 290}
@@ -290,13 +313,16 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
290 struct hpi_message *phm, struct hpi_response *phr) 313 struct hpi_message *phm, struct hpi_response *phr)
291{ 314{
292 short found = 1; 315 short found = 1;
293 u16 control_index;
294 struct hpi_control_cache_info *pI; 316 struct hpi_control_cache_info *pI;
295 struct hpi_control_cache_single *pC; 317 struct hpi_control_cache_single *pC;
296 struct hpi_control_cache_pad *p_pad; 318 struct hpi_control_cache_pad *p_pad;
297 319
298 if (!find_control(phm, p_cache, &pI, &control_index)) 320 if (!find_control(phm->obj_index, p_cache, &pI)) {
321 HPI_DEBUG_LOG(VERBOSE,
322 "HPICMN find_control() failed for adap %d\n",
323 phm->adapter_index);
299 return 0; 324 return 0;
325 }
300 326
301 phr->error = 0; 327 phr->error = 0;
302 328
@@ -310,55 +336,66 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
310 336
311 case HPI_CONTROL_METER: 337 case HPI_CONTROL_METER:
312 if (phm->u.c.attribute == HPI_METER_PEAK) { 338 if (phm->u.c.attribute == HPI_METER_PEAK) {
313 phr->u.c.an_log_value[0] = pC->u.p.an_log_peak[0]; 339 phr->u.c.an_log_value[0] = pC->u.meter.an_log_peak[0];
314 phr->u.c.an_log_value[1] = pC->u.p.an_log_peak[1]; 340 phr->u.c.an_log_value[1] = pC->u.meter.an_log_peak[1];
315 } else if (phm->u.c.attribute == HPI_METER_RMS) { 341 } else if (phm->u.c.attribute == HPI_METER_RMS) {
316 phr->u.c.an_log_value[0] = pC->u.p.an_logRMS[0]; 342 if (pC->u.meter.an_logRMS[0] ==
317 phr->u.c.an_log_value[1] = pC->u.p.an_logRMS[1]; 343 HPI_CACHE_INVALID_SHORT) {
344 phr->error =
345 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
346 phr->u.c.an_log_value[0] = HPI_METER_MINIMUM;
347 phr->u.c.an_log_value[1] = HPI_METER_MINIMUM;
348 } else {
349 phr->u.c.an_log_value[0] =
350 pC->u.meter.an_logRMS[0];
351 phr->u.c.an_log_value[1] =
352 pC->u.meter.an_logRMS[1];
353 }
318 } else 354 } else
319 found = 0; 355 found = 0;
320 break; 356 break;
321 case HPI_CONTROL_VOLUME: 357 case HPI_CONTROL_VOLUME:
322 if (phm->u.c.attribute == HPI_VOLUME_GAIN) { 358 if (phm->u.c.attribute == HPI_VOLUME_GAIN) {
323 phr->u.c.an_log_value[0] = pC->u.v.an_log[0]; 359 phr->u.c.an_log_value[0] = pC->u.vol.an_log[0];
324 phr->u.c.an_log_value[1] = pC->u.v.an_log[1]; 360 phr->u.c.an_log_value[1] = pC->u.vol.an_log[1];
325 } else 361 } else
326 found = 0; 362 found = 0;
327 break; 363 break;
328 case HPI_CONTROL_MULTIPLEXER: 364 case HPI_CONTROL_MULTIPLEXER:
329 if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) { 365 if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) {
330 phr->u.c.param1 = pC->u.x.source_node_type; 366 phr->u.c.param1 = pC->u.mux.source_node_type;
331 phr->u.c.param2 = pC->u.x.source_node_index; 367 phr->u.c.param2 = pC->u.mux.source_node_index;
332 } else { 368 } else {
333 found = 0; 369 found = 0;
334 } 370 }
335 break; 371 break;
336 case HPI_CONTROL_CHANNEL_MODE: 372 case HPI_CONTROL_CHANNEL_MODE:
337 if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE) 373 if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE)
338 phr->u.c.param1 = pC->u.m.mode; 374 phr->u.c.param1 = pC->u.mode.mode;
339 else 375 else
340 found = 0; 376 found = 0;
341 break; 377 break;
342 case HPI_CONTROL_LEVEL: 378 case HPI_CONTROL_LEVEL:
343 if (phm->u.c.attribute == HPI_LEVEL_GAIN) { 379 if (phm->u.c.attribute == HPI_LEVEL_GAIN) {
344 phr->u.c.an_log_value[0] = pC->u.l.an_log[0]; 380 phr->u.c.an_log_value[0] = pC->u.level.an_log[0];
345 phr->u.c.an_log_value[1] = pC->u.l.an_log[1]; 381 phr->u.c.an_log_value[1] = pC->u.level.an_log[1];
346 } else 382 } else
347 found = 0; 383 found = 0;
348 break; 384 break;
349 case HPI_CONTROL_TUNER: 385 case HPI_CONTROL_TUNER:
350 if (phm->u.c.attribute == HPI_TUNER_FREQ) 386 if (phm->u.c.attribute == HPI_TUNER_FREQ)
351 phr->u.c.param1 = pC->u.t.freq_ink_hz; 387 phr->u.c.param1 = pC->u.tuner.freq_ink_hz;
352 else if (phm->u.c.attribute == HPI_TUNER_BAND) 388 else if (phm->u.c.attribute == HPI_TUNER_BAND)
353 phr->u.c.param1 = pC->u.t.band; 389 phr->u.c.param1 = pC->u.tuner.band;
354 else if ((phm->u.c.attribute == HPI_TUNER_LEVEL) 390 else if (phm->u.c.attribute == HPI_TUNER_LEVEL_AVG)
355 && (phm->u.c.param1 == HPI_TUNER_LEVEL_AVERAGE)) 391 if (pC->u.tuner.s_level_avg ==
356 if (pC->u.t.level == HPI_ERROR_ILLEGAL_CACHE_VALUE) { 392 HPI_CACHE_INVALID_SHORT) {
357 phr->u.c.param1 = 0; 393 phr->u.cu.tuner.s_level = 0;
358 phr->error = 394 phr->error =
359 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE; 395 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
360 } else 396 } else
361 phr->u.c.param1 = pC->u.t.level; 397 phr->u.cu.tuner.s_level =
398 pC->u.tuner.s_level_avg;
362 else 399 else
363 found = 0; 400 found = 0;
364 break; 401 break;
@@ -366,7 +403,7 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
366 if (phm->u.c.attribute == HPI_AESEBURX_ERRORSTATUS) 403 if (phm->u.c.attribute == HPI_AESEBURX_ERRORSTATUS)
367 phr->u.c.param1 = pC->u.aes3rx.error_status; 404 phr->u.c.param1 = pC->u.aes3rx.error_status;
368 else if (phm->u.c.attribute == HPI_AESEBURX_FORMAT) 405 else if (phm->u.c.attribute == HPI_AESEBURX_FORMAT)
369 phr->u.c.param1 = pC->u.aes3rx.source; 406 phr->u.c.param1 = pC->u.aes3rx.format;
370 else 407 else
371 found = 0; 408 found = 0;
372 break; 409 break;
@@ -385,13 +422,13 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
385 case HPI_CONTROL_SILENCEDETECTOR: 422 case HPI_CONTROL_SILENCEDETECTOR:
386 if (phm->u.c.attribute == HPI_SILENCEDETECTOR_STATE) { 423 if (phm->u.c.attribute == HPI_SILENCEDETECTOR_STATE) {
387 phr->u.c.param1 = pC->u.silence.state; 424 phr->u.c.param1 = pC->u.silence.state;
388 phr->u.c.param2 = pC->u.silence.count; 425 /*? phr->u.c.dwParam2 = pC->u.silence.dwCount; */
389 } else 426 } else
390 found = 0; 427 found = 0;
391 break; 428 break;
392 case HPI_CONTROL_MICROPHONE: 429 case HPI_CONTROL_MICROPHONE:
393 if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER) 430 if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER)
394 phr->u.c.param1 = pC->u.phantom_power.state; 431 phr->u.c.param1 = pC->u.microphone.phantom_state;
395 else 432 else
396 found = 0; 433 found = 0;
397 break; 434 break;
@@ -400,7 +437,7 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
400 phr->u.c.param1 = pC->u.clk.source; 437 phr->u.c.param1 = pC->u.clk.source;
401 else if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE_INDEX) { 438 else if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE_INDEX) {
402 if (pC->u.clk.source_index == 439 if (pC->u.clk.source_index ==
403 HPI_ERROR_ILLEGAL_CACHE_VALUE) { 440 HPI_CACHE_INVALID_UINT16) {
404 phr->u.c.param1 = 0; 441 phr->u.c.param1 = 0;
405 phr->error = 442 phr->error =
406 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE; 443 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
@@ -411,60 +448,63 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
411 else 448 else
412 found = 0; 449 found = 0;
413 break; 450 break;
414 case HPI_CONTROL_PAD: 451 case HPI_CONTROL_PAD:{
415 452 struct hpi_control_cache_pad *p_pad;
416 if (!(p_pad->field_valid_flags & (1 << 453 p_pad = (struct hpi_control_cache_pad *)pI;
417 HPI_CTL_ATTR_INDEX(phm->u.c.
418 attribute)))) {
419 phr->error = HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
420 break;
421 }
422 454
423 if (phm->u.c.attribute == HPI_PAD_PROGRAM_ID) 455 if (!(p_pad->field_valid_flags & (1 <<
424 phr->u.c.param1 = p_pad->pI; 456 HPI_CTL_ATTR_INDEX(phm->u.c.
425 else if (phm->u.c.attribute == HPI_PAD_PROGRAM_TYPE) 457 attribute)))) {
426 phr->u.c.param1 = p_pad->pTY;
427 else {
428 unsigned int index =
429 HPI_CTL_ATTR_INDEX(phm->u.c.attribute) - 1;
430 unsigned int offset = phm->u.c.param1;
431 unsigned int pad_string_len, field_size;
432 char *pad_string;
433 unsigned int tocopy;
434
435 HPI_DEBUG_LOG(VERBOSE, "PADS HPI_PADS_ %d\n",
436 phm->u.c.attribute);
437
438 if (index > ARRAY_SIZE(pad_desc) - 1) {
439 phr->error = 458 phr->error =
440 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE; 459 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
441 break; 460 break;
442 } 461 }
443 462
444 pad_string = ((char *)p_pad) + pad_desc[index].offset; 463 if (phm->u.c.attribute == HPI_PAD_PROGRAM_ID)
445 field_size = pad_desc[index].field_size; 464 phr->u.c.param1 = p_pad->pI;
446 /* Ensure null terminator */ 465 else if (phm->u.c.attribute == HPI_PAD_PROGRAM_TYPE)
447 pad_string[field_size - 1] = 0; 466 phr->u.c.param1 = p_pad->pTY;
448 467 else {
449 pad_string_len = strlen(pad_string) + 1; 468 unsigned int index =
450 469 HPI_CTL_ATTR_INDEX(phm->u.c.
451 if (offset > pad_string_len) { 470 attribute) - 1;
452 phr->error = HPI_ERROR_INVALID_CONTROL_VALUE; 471 unsigned int offset = phm->u.c.param1;
453 break; 472 unsigned int pad_string_len, field_size;
473 char *pad_string;
474 unsigned int tocopy;
475
476 if (index > ARRAY_SIZE(pad_desc) - 1) {
477 phr->error =
478 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
479 break;
480 }
481
482 pad_string =
483 ((char *)p_pad) +
484 pad_desc[index].offset;
485 field_size = pad_desc[index].field_size;
486 /* Ensure null terminator */
487 pad_string[field_size - 1] = 0;
488
489 pad_string_len = strlen(pad_string) + 1;
490
491 if (offset > pad_string_len) {
492 phr->error =
493 HPI_ERROR_INVALID_CONTROL_VALUE;
494 break;
495 }
496
497 tocopy = pad_string_len - offset;
498 if (tocopy > sizeof(phr->u.cu.chars8.sz_data))
499 tocopy = sizeof(phr->u.cu.chars8.
500 sz_data);
501
502 memcpy(phr->u.cu.chars8.sz_data,
503 &pad_string[offset], tocopy);
504
505 phr->u.cu.chars8.remaining_chars =
506 pad_string_len - offset - tocopy;
454 } 507 }
455
456 tocopy = pad_string_len - offset;
457 if (tocopy > sizeof(phr->u.cu.chars8.sz_data))
458 tocopy = sizeof(phr->u.cu.chars8.sz_data);
459
460 HPI_DEBUG_LOG(VERBOSE,
461 "PADS memcpy(%d), offset %d \n", tocopy,
462 offset);
463 memcpy(phr->u.cu.chars8.sz_data, &pad_string[offset],
464 tocopy);
465
466 phr->u.cu.chars8.remaining_chars =
467 pad_string_len - offset - tocopy;
468 } 508 }
469 break; 509 break;
470 default: 510 default:
@@ -472,16 +512,9 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
472 break; 512 break;
473 } 513 }
474 514
475 if (found) 515 HPI_DEBUG_LOG(VERBOSE, "%s Adap %d, Ctl %d, Type %d, Attr %d\n",
476 HPI_DEBUG_LOG(VERBOSE, 516 found ? "Cached" : "Uncached", phm->adapter_index,
477 "cached adap %d, ctl %d, type %d, attr %d\n", 517 pI->control_index, pI->control_type, phm->u.c.attribute);
478 phm->adapter_index, pI->control_index,
479 pI->control_type, phm->u.c.attribute);
480 else
481 HPI_DEBUG_LOG(VERBOSE,
482 "uncached adap %d, ctl %d, ctl type %d\n",
483 phm->adapter_index, pI->control_index,
484 pI->control_type);
485 518
486 if (found) 519 if (found)
487 phr->size = 520 phr->size =
@@ -497,18 +530,21 @@ Only update if no error.
497Volume and Level return the limited values in the response, so use these 530Volume and Level return the limited values in the response, so use these
498Multiplexer does so use sent values 531Multiplexer does so use sent values
499*/ 532*/
500void hpi_sync_control_cache(struct hpi_control_cache *p_cache, 533void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *p_cache,
501 struct hpi_message *phm, struct hpi_response *phr) 534 struct hpi_message *phm, struct hpi_response *phr)
502{ 535{
503 u16 control_index;
504 struct hpi_control_cache_single *pC; 536 struct hpi_control_cache_single *pC;
505 struct hpi_control_cache_info *pI; 537 struct hpi_control_cache_info *pI;
506 538
507 if (phr->error) 539 if (phr->error)
508 return; 540 return;
509 541
510 if (!find_control(phm, p_cache, &pI, &control_index)) 542 if (!find_control(phm->obj_index, p_cache, &pI)) {
543 HPI_DEBUG_LOG(VERBOSE,
544 "HPICMN find_control() failed for adap %d\n",
545 phm->adapter_index);
511 return; 546 return;
547 }
512 548
513 /* pC is the default cached control strucure. 549 /* pC is the default cached control strucure.
514 May be cast to something else in the following switch statement. 550 May be cast to something else in the following switch statement.
@@ -518,31 +554,31 @@ void hpi_sync_control_cache(struct hpi_control_cache *p_cache,
518 switch (pI->control_type) { 554 switch (pI->control_type) {
519 case HPI_CONTROL_VOLUME: 555 case HPI_CONTROL_VOLUME:
520 if (phm->u.c.attribute == HPI_VOLUME_GAIN) { 556 if (phm->u.c.attribute == HPI_VOLUME_GAIN) {
521 pC->u.v.an_log[0] = phr->u.c.an_log_value[0]; 557 pC->u.vol.an_log[0] = phr->u.c.an_log_value[0];
522 pC->u.v.an_log[1] = phr->u.c.an_log_value[1]; 558 pC->u.vol.an_log[1] = phr->u.c.an_log_value[1];
523 } 559 }
524 break; 560 break;
525 case HPI_CONTROL_MULTIPLEXER: 561 case HPI_CONTROL_MULTIPLEXER:
526 /* mux does not return its setting on Set command. */ 562 /* mux does not return its setting on Set command. */
527 if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) { 563 if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) {
528 pC->u.x.source_node_type = (u16)phm->u.c.param1; 564 pC->u.mux.source_node_type = (u16)phm->u.c.param1;
529 pC->u.x.source_node_index = (u16)phm->u.c.param2; 565 pC->u.mux.source_node_index = (u16)phm->u.c.param2;
530 } 566 }
531 break; 567 break;
532 case HPI_CONTROL_CHANNEL_MODE: 568 case HPI_CONTROL_CHANNEL_MODE:
533 /* mode does not return its setting on Set command. */ 569 /* mode does not return its setting on Set command. */
534 if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE) 570 if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE)
535 pC->u.m.mode = (u16)phm->u.c.param1; 571 pC->u.mode.mode = (u16)phm->u.c.param1;
536 break; 572 break;
537 case HPI_CONTROL_LEVEL: 573 case HPI_CONTROL_LEVEL:
538 if (phm->u.c.attribute == HPI_LEVEL_GAIN) { 574 if (phm->u.c.attribute == HPI_LEVEL_GAIN) {
539 pC->u.v.an_log[0] = phr->u.c.an_log_value[0]; 575 pC->u.vol.an_log[0] = phr->u.c.an_log_value[0];
540 pC->u.v.an_log[1] = phr->u.c.an_log_value[1]; 576 pC->u.vol.an_log[1] = phr->u.c.an_log_value[1];
541 } 577 }
542 break; 578 break;
543 case HPI_CONTROL_MICROPHONE: 579 case HPI_CONTROL_MICROPHONE:
544 if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER) 580 if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER)
545 pC->u.phantom_power.state = (u16)phm->u.c.param1; 581 pC->u.microphone.phantom_state = (u16)phm->u.c.param1;
546 break; 582 break;
547 case HPI_CONTROL_AESEBU_TRANSMITTER: 583 case HPI_CONTROL_AESEBU_TRANSMITTER:
548 if (phm->u.c.attribute == HPI_AESEBUTX_FORMAT) 584 if (phm->u.c.attribute == HPI_AESEBUTX_FORMAT)
@@ -550,7 +586,7 @@ void hpi_sync_control_cache(struct hpi_control_cache *p_cache,
550 break; 586 break;
551 case HPI_CONTROL_AESEBU_RECEIVER: 587 case HPI_CONTROL_AESEBU_RECEIVER:
552 if (phm->u.c.attribute == HPI_AESEBURX_FORMAT) 588 if (phm->u.c.attribute == HPI_AESEBURX_FORMAT)
553 pC->u.aes3rx.source = phm->u.c.param1; 589 pC->u.aes3rx.format = phm->u.c.param1;
554 break; 590 break;
555 case HPI_CONTROL_SAMPLECLOCK: 591 case HPI_CONTROL_SAMPLECLOCK:
556 if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE) 592 if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE)
@@ -566,8 +602,7 @@ void hpi_sync_control_cache(struct hpi_control_cache *p_cache,
566} 602}
567 603
568struct hpi_control_cache *hpi_alloc_control_cache(const u32 604struct hpi_control_cache *hpi_alloc_control_cache(const u32
569 number_of_controls, const u32 size_in_bytes, 605 number_of_controls, const u32 size_in_bytes, u8 *pDSP_control_buffer)
570 struct hpi_control_cache_info *pDSP_control_buffer)
571{ 606{
572 struct hpi_control_cache *p_cache = 607 struct hpi_control_cache *p_cache =
573 kmalloc(sizeof(*p_cache), GFP_KERNEL); 608 kmalloc(sizeof(*p_cache), GFP_KERNEL);
@@ -590,7 +625,7 @@ struct hpi_control_cache *hpi_alloc_control_cache(const u32
590 625
591void hpi_free_control_cache(struct hpi_control_cache *p_cache) 626void hpi_free_control_cache(struct hpi_control_cache *p_cache)
592{ 627{
593 if (p_cache->init) { 628 if (p_cache) {
594 kfree(p_cache->p_info); 629 kfree(p_cache->p_info);
595 p_cache->p_info = NULL; 630 p_cache->p_info = NULL;
596 p_cache->init = 0; 631 p_cache->init = 0;
@@ -600,24 +635,25 @@ void hpi_free_control_cache(struct hpi_control_cache *p_cache)
600 635
601static void subsys_message(struct hpi_message *phm, struct hpi_response *phr) 636static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
602{ 637{
638 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, phm->function, 0);
603 639
604 switch (phm->function) { 640 switch (phm->function) {
605 case HPI_SUBSYS_OPEN: 641 case HPI_SUBSYS_OPEN:
606 case HPI_SUBSYS_CLOSE: 642 case HPI_SUBSYS_CLOSE:
607 case HPI_SUBSYS_DRIVER_UNLOAD: 643 case HPI_SUBSYS_DRIVER_UNLOAD:
608 phr->error = 0;
609 break; 644 break;
610 case HPI_SUBSYS_DRIVER_LOAD: 645 case HPI_SUBSYS_DRIVER_LOAD:
611 wipe_adapter_list(); 646 wipe_adapter_list();
612 hpios_alistlock_init(&adapters); 647 hpios_alistlock_init(&adapters);
613 phr->error = 0;
614 break; 648 break;
615 case HPI_SUBSYS_GET_INFO: 649 case HPI_SUBSYS_GET_ADAPTER:
616 subsys_get_adapters(phr); 650 subsys_get_adapter(phm, phr);
651 break;
652 case HPI_SUBSYS_GET_NUM_ADAPTERS:
653 phr->u.s.num_adapters = adapters.gw_num_adapters;
617 break; 654 break;
618 case HPI_SUBSYS_CREATE_ADAPTER: 655 case HPI_SUBSYS_CREATE_ADAPTER:
619 case HPI_SUBSYS_DELETE_ADAPTER: 656 case HPI_SUBSYS_DELETE_ADAPTER:
620 phr->error = 0;
621 break; 657 break;
622 default: 658 default:
623 phr->error = HPI_ERROR_INVALID_FUNC; 659 phr->error = HPI_ERROR_INVALID_FUNC;
diff --git a/sound/pci/asihpi/hpicmn.h b/sound/pci/asihpi/hpicmn.h
index 6229022f56cb..e2f6f1f11a66 100644
--- a/sound/pci/asihpi/hpicmn.h
+++ b/sound/pci/asihpi/hpicmn.h
@@ -40,8 +40,7 @@ struct hpi_control_cache {
40 struct hpi_control_cache_info 40 struct hpi_control_cache_info
41 **p_info; /**< pointer to allocated memory of 41 **p_info; /**< pointer to allocated memory of
42 lookup pointers. */ 42 lookup pointers. */
43 struct hpi_control_cache_single 43 u8 *p_cache; /**< pointer to DSP's control cache. */
44 *p_cache; /**< pointer to DSP's control cache. */
45}; 44};
46 45
47struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index); 46struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index);
@@ -52,12 +51,10 @@ void hpi_delete_adapter(struct hpi_adapter_obj *pao);
52short hpi_check_control_cache(struct hpi_control_cache *pC, 51short hpi_check_control_cache(struct hpi_control_cache *pC,
53 struct hpi_message *phm, struct hpi_response *phr); 52 struct hpi_message *phm, struct hpi_response *phr);
54struct hpi_control_cache *hpi_alloc_control_cache(const u32 53struct hpi_control_cache *hpi_alloc_control_cache(const u32
55 number_of_controls, const u32 size_in_bytes, 54 number_of_controls, const u32 size_in_bytes, u8 *pDSP_control_buffer);
56 struct hpi_control_cache_info
57 *pDSP_control_buffer);
58void hpi_free_control_cache(struct hpi_control_cache *p_cache); 55void hpi_free_control_cache(struct hpi_control_cache *p_cache);
59 56
60void hpi_sync_control_cache(struct hpi_control_cache *pC, 57void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *pC,
61 struct hpi_message *phm, struct hpi_response *phr); 58 struct hpi_message *phm, struct hpi_response *phr);
62u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr); 59u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr);
63short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache, 60short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache,
diff --git a/sound/pci/asihpi/hpifunc.c b/sound/pci/asihpi/hpifunc.c
index 1e92eb6dd509..aafb76955f69 100644
--- a/sound/pci/asihpi/hpifunc.c
+++ b/sound/pci/asihpi/hpifunc.c
@@ -98,21 +98,7 @@ static struct hpi_hsubsys gh_subsys;
98 98
99struct hpi_hsubsys *hpi_subsys_create(void) 99struct hpi_hsubsys *hpi_subsys_create(void)
100{ 100{
101 struct hpi_message hm; 101 return &gh_subsys;
102 struct hpi_response hr;
103
104 memset(&gh_subsys, 0, sizeof(struct hpi_hsubsys));
105
106 {
107 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
108 HPI_SUBSYS_OPEN);
109 hpi_send_recv(&hm, &hr);
110
111 if (hr.error == 0)
112 return &gh_subsys;
113
114 }
115 return NULL;
116} 102}
117 103
118void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys) 104void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys)
@@ -126,18 +112,6 @@ void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys)
126 112
127} 113}
128 114
129u16 hpi_subsys_get_version(const struct hpi_hsubsys *ph_subsys, u32 *pversion)
130{
131 struct hpi_message hm;
132 struct hpi_response hr;
133
134 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
135 HPI_SUBSYS_GET_VERSION);
136 hpi_send_recv(&hm, &hr);
137 *pversion = hr.u.s.version;
138 return hr.error;
139}
140
141u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys, 115u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys,
142 u32 *pversion_ex) 116 u32 *pversion_ex)
143{ 117{
@@ -151,49 +125,6 @@ u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys,
151 return hr.error; 125 return hr.error;
152} 126}
153 127
154u16 hpi_subsys_get_info(const struct hpi_hsubsys *ph_subsys, u32 *pversion,
155 u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length)
156{
157 struct hpi_message hm;
158 struct hpi_response hr;
159 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
160 HPI_SUBSYS_GET_INFO);
161
162 hpi_send_recv(&hm, &hr);
163
164 *pversion = hr.u.s.version;
165 if (list_length > HPI_MAX_ADAPTERS)
166 memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list,
167 HPI_MAX_ADAPTERS);
168 else
169 memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list, list_length);
170 *pw_num_adapters = hr.u.s.num_adapters;
171 return hr.error;
172}
173
174u16 hpi_subsys_find_adapters(const struct hpi_hsubsys *ph_subsys,
175 u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length)
176{
177 struct hpi_message hm;
178 struct hpi_response hr;
179 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
180 HPI_SUBSYS_FIND_ADAPTERS);
181
182 hpi_send_recv(&hm, &hr);
183
184 if (list_length > HPI_MAX_ADAPTERS) {
185 memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list,
186 HPI_MAX_ADAPTERS * sizeof(u16));
187 memset(&aw_adapter_list[HPI_MAX_ADAPTERS], 0,
188 (list_length - HPI_MAX_ADAPTERS) * sizeof(u16));
189 } else
190 memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list,
191 list_length * sizeof(u16));
192 *pw_num_adapters = hr.u.s.num_adapters;
193
194 return hr.error;
195}
196
197u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys, 128u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys,
198 const struct hpi_resource *p_resource, u16 *pw_adapter_index) 129 const struct hpi_resource *p_resource, u16 *pw_adapter_index)
199{ 130{
@@ -217,7 +148,7 @@ u16 hpi_subsys_delete_adapter(const struct hpi_hsubsys *ph_subsys,
217 struct hpi_response hr; 148 struct hpi_response hr;
218 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 149 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
219 HPI_SUBSYS_DELETE_ADAPTER); 150 HPI_SUBSYS_DELETE_ADAPTER);
220 hm.adapter_index = adapter_index; 151 hm.obj_index = adapter_index;
221 hpi_send_recv(&hm, &hr); 152 hpi_send_recv(&hm, &hr);
222 return hr.error; 153 return hr.error;
223} 154}
@@ -241,27 +172,13 @@ u16 hpi_subsys_get_adapter(const struct hpi_hsubsys *ph_subsys, int iterator,
241 struct hpi_response hr; 172 struct hpi_response hr;
242 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 173 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
243 HPI_SUBSYS_GET_ADAPTER); 174 HPI_SUBSYS_GET_ADAPTER);
244 hm.adapter_index = (u16)iterator; 175 hm.obj_index = (u16)iterator;
245 hpi_send_recv(&hm, &hr); 176 hpi_send_recv(&hm, &hr);
246 *padapter_index = (int)hr.u.s.adapter_index; 177 *padapter_index = (int)hr.u.s.adapter_index;
247 *pw_adapter_type = hr.u.s.aw_adapter_list[0]; 178 *pw_adapter_type = hr.u.s.aw_adapter_list[0];
248 return hr.error; 179 return hr.error;
249} 180}
250 181
251u16 hpi_subsys_set_host_network_interface(const struct hpi_hsubsys *ph_subsys,
252 const char *sz_interface)
253{
254 struct hpi_message hm;
255 struct hpi_response hr;
256 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
257 HPI_SUBSYS_SET_NETWORK_INTERFACE);
258 if (sz_interface == NULL)
259 return HPI_ERROR_INVALID_RESOURCE;
260 hm.u.s.resource.r.net_if = sz_interface;
261 hpi_send_recv(&hm, &hr);
262 return hr.error;
263}
264
265u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) 182u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index)
266{ 183{
267 struct hpi_message hm; 184 struct hpi_message hm;
@@ -305,8 +222,8 @@ u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys,
305 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 222 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
306 HPI_ADAPTER_SET_MODE); 223 HPI_ADAPTER_SET_MODE);
307 hm.adapter_index = adapter_index; 224 hm.adapter_index = adapter_index;
308 hm.u.a.adapter_mode = adapter_mode; 225 hm.u.ax.mode.adapter_mode = adapter_mode;
309 hm.u.a.assert_id = query_or_set; 226 hm.u.ax.mode.query_or_set = query_or_set;
310 hpi_send_recv(&hm, &hr); 227 hpi_send_recv(&hm, &hr);
311 return hr.error; 228 return hr.error;
312} 229}
@@ -321,7 +238,7 @@ u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys,
321 hm.adapter_index = adapter_index; 238 hm.adapter_index = adapter_index;
322 hpi_send_recv(&hm, &hr); 239 hpi_send_recv(&hm, &hr);
323 if (padapter_mode) 240 if (padapter_mode)
324 *padapter_mode = hr.u.a.serial_number; 241 *padapter_mode = hr.u.ax.mode.adapter_mode;
325 return hr.error; 242 return hr.error;
326} 243}
327 244
@@ -337,11 +254,11 @@ u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys,
337 254
338 hpi_send_recv(&hm, &hr); 255 hpi_send_recv(&hm, &hr);
339 256
340 *pw_adapter_type = hr.u.a.adapter_type; 257 *pw_adapter_type = hr.u.ax.info.adapter_type;
341 *pw_num_outstreams = hr.u.a.num_outstreams; 258 *pw_num_outstreams = hr.u.ax.info.num_outstreams;
342 *pw_num_instreams = hr.u.a.num_instreams; 259 *pw_num_instreams = hr.u.ax.info.num_instreams;
343 *pw_version = hr.u.a.version; 260 *pw_version = hr.u.ax.info.version;
344 *pserial_number = hr.u.a.serial_number; 261 *pserial_number = hr.u.ax.info.serial_number;
345 return hr.error; 262 return hr.error;
346} 263}
347 264
@@ -360,56 +277,20 @@ u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys,
360 277
361 hpi_send_recv(&hm, &hr); 278 hpi_send_recv(&hm, &hr);
362 279
363 *pw_module_type = hr.u.a.adapter_type; 280 *pw_module_type = hr.u.ax.info.adapter_type;
364 *pw_num_outputs = hr.u.a.num_outstreams; 281 *pw_num_outputs = hr.u.ax.info.num_outstreams;
365 *pw_num_inputs = hr.u.a.num_instreams; 282 *pw_num_inputs = hr.u.ax.info.num_instreams;
366 *pw_version = hr.u.a.version; 283 *pw_version = hr.u.ax.info.version;
367 *pserial_number = hr.u.a.serial_number; 284 *pserial_number = hr.u.ax.info.serial_number;
368 *ph_module = 0; 285 *ph_module = 0;
369 286
370 return hr.error; 287 return hr.error;
371} 288}
372 289
373u16 hpi_adapter_get_assert(const struct hpi_hsubsys *ph_subsys, 290u16 hpi_adapter_get_assert2(const struct hpi_hsubsys *ph_subsys,
374 u16 adapter_index, u16 *assert_present, char *psz_assert, 291 u16 adapter_index, u16 *p_assert_count, char *psz_assert,
375 u16 *pw_line_number) 292 u32 *p_param1, u32 *p_param2, u32 *p_dsp_string_addr,
376{ 293 u16 *p_processor_id)
377 struct hpi_message hm;
378 struct hpi_response hr;
379 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
380 HPI_ADAPTER_GET_ASSERT);
381 hm.adapter_index = adapter_index;
382 hpi_send_recv(&hm, &hr);
383
384 *assert_present = 0;
385
386 if (!hr.error) {
387
388 *pw_line_number = (u16)hr.u.a.serial_number;
389 if (*pw_line_number) {
390
391 int i;
392 char *src = (char *)hr.u.a.sz_adapter_assert;
393 char *dst = psz_assert;
394
395 *assert_present = 1;
396
397 for (i = 0; i < HPI_STRING_LEN; i++) {
398 char c;
399 c = *src++;
400 *dst++ = c;
401 if (c == 0)
402 break;
403 }
404
405 }
406 }
407 return hr.error;
408}
409
410u16 hpi_adapter_get_assert_ex(const struct hpi_hsubsys *ph_subsys,
411 u16 adapter_index, u16 *assert_present, char *psz_assert,
412 u32 *pline_number, u16 *pw_assert_on_dsp)
413{ 294{
414 struct hpi_message hm; 295 struct hpi_message hm;
415 struct hpi_response hr; 296 struct hpi_response hr;
@@ -419,34 +300,18 @@ u16 hpi_adapter_get_assert_ex(const struct hpi_hsubsys *ph_subsys,
419 300
420 hpi_send_recv(&hm, &hr); 301 hpi_send_recv(&hm, &hr);
421 302
422 *assert_present = 0; 303 *p_assert_count = 0;
423 304
424 if (!hr.error) { 305 if (!hr.error) {
425 306 *p_assert_count = hr.u.ax.assert.count;
426 *pline_number = hr.u.a.serial_number; 307
427 308 if (*p_assert_count) {
428 *assert_present = hr.u.a.adapter_type; 309 *p_param1 = hr.u.ax.assert.p1;
429 310 *p_param2 = hr.u.ax.assert.p2;
430 *pw_assert_on_dsp = hr.u.a.adapter_index; 311 *p_processor_id = hr.u.ax.assert.dsp_index;
431 312 *p_dsp_string_addr = hr.u.ax.assert.dsp_msg_addr;
432 if (!*assert_present && *pline_number) 313 memcpy(psz_assert, hr.u.ax.assert.sz_message,
433 314 HPI_STRING_LEN);
434 *assert_present = 1;
435
436 if (*assert_present) {
437
438 int i;
439 char *src = (char *)hr.u.a.sz_adapter_assert;
440 char *dst = psz_assert;
441
442 for (i = 0; i < HPI_STRING_LEN; i++) {
443 char c;
444 c = *src++;
445 *dst++ = c;
446 if (c == 0)
447 break;
448 }
449
450 } else { 315 } else {
451 *psz_assert = 0; 316 *psz_assert = 0;
452 } 317 }
@@ -462,7 +327,7 @@ u16 hpi_adapter_test_assert(const struct hpi_hsubsys *ph_subsys,
462 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 327 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
463 HPI_ADAPTER_TEST_ASSERT); 328 HPI_ADAPTER_TEST_ASSERT);
464 hm.adapter_index = adapter_index; 329 hm.adapter_index = adapter_index;
465 hm.u.a.assert_id = assert_id; 330 hm.u.ax.test_assert.value = assert_id;
466 331
467 hpi_send_recv(&hm, &hr); 332 hpi_send_recv(&hm, &hr);
468 333
@@ -472,17 +337,21 @@ u16 hpi_adapter_test_assert(const struct hpi_hsubsys *ph_subsys,
472u16 hpi_adapter_enable_capability(const struct hpi_hsubsys *ph_subsys, 337u16 hpi_adapter_enable_capability(const struct hpi_hsubsys *ph_subsys,
473 u16 adapter_index, u16 capability, u32 key) 338 u16 adapter_index, u16 capability, u32 key)
474{ 339{
340#if 1
341 return HPI_ERROR_UNIMPLEMENTED;
342#else
475 struct hpi_message hm; 343 struct hpi_message hm;
476 struct hpi_response hr; 344 struct hpi_response hr;
477 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 345 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
478 HPI_ADAPTER_ENABLE_CAPABILITY); 346 HPI_ADAPTER_ENABLE_CAPABILITY);
479 hm.adapter_index = adapter_index; 347 hm.adapter_index = adapter_index;
480 hm.u.a.assert_id = capability; 348 hm.u.ax.enable_cap.cap = capability;
481 hm.u.a.adapter_mode = key; 349 hm.u.ax.enable_cap.key = key;
482 350
483 hpi_send_recv(&hm, &hr); 351 hpi_send_recv(&hm, &hr);
484 352
485 return hr.error; 353 return hr.error;
354#endif
486} 355}
487 356
488u16 hpi_adapter_self_test(const struct hpi_hsubsys *ph_subsys, 357u16 hpi_adapter_self_test(const struct hpi_hsubsys *ph_subsys,
@@ -500,29 +369,32 @@ u16 hpi_adapter_self_test(const struct hpi_hsubsys *ph_subsys,
500u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys, 369u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys,
501 u16 adapter_index, u32 dsp_address, char *p_buffer, int *count_bytes) 370 u16 adapter_index, u32 dsp_address, char *p_buffer, int *count_bytes)
502{ 371{
503 struct hpi_message hm; 372 struct hpi_msg_adapter_debug_read hm;
504 struct hpi_response hr; 373 struct hpi_res_adapter_debug_read hr;
505 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
506 HPI_ADAPTER_DEBUG_READ);
507 374
508 hr.size = sizeof(hr); 375 hpi_init_message_responseV1(&hm.h, sizeof(hm), &hr.h, sizeof(hr),
376 HPI_OBJ_ADAPTER, HPI_ADAPTER_DEBUG_READ);
509 377
510 hm.adapter_index = adapter_index; 378 hm.h.adapter_index = adapter_index;
511 hm.u.ax.debug_read.dsp_address = dsp_address; 379 hm.dsp_address = dsp_address;
512 380
513 if (*count_bytes > (int)sizeof(hr.u.bytes)) 381 if (*count_bytes > (int)sizeof(hr.bytes))
514 *count_bytes = sizeof(hr.u.bytes); 382 *count_bytes = (int)sizeof(hr.bytes);
515 383
516 hm.u.ax.debug_read.count_bytes = *count_bytes; 384 hm.count_bytes = *count_bytes;
517 385
518 hpi_send_recv(&hm, &hr); 386 hpi_send_recv((struct hpi_message *)&hm, (struct hpi_response *)&hr);
519 387
520 if (!hr.error) { 388 if (!hr.h.error) {
521 *count_bytes = hr.size - 12; 389 int res_bytes = hr.h.size - sizeof(hr.h);
522 memcpy(p_buffer, &hr.u.bytes, *count_bytes); 390 if (res_bytes > *count_bytes)
391 res_bytes = *count_bytes;
392 *count_bytes = res_bytes;
393 memcpy(p_buffer, &hr.bytes, res_bytes);
523 } else 394 } else
524 *count_bytes = 0; 395 *count_bytes = 0;
525 return hr.error; 396
397 return hr.h.error;
526} 398}
527 399
528u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys, 400u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys,
@@ -1682,7 +1554,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1682 unsigned int sub_string_index = 0, j = 0; 1554 unsigned int sub_string_index = 0, j = 0;
1683 char c = 0; 1555 char c = 0;
1684 unsigned int n = 0; 1556 unsigned int n = 0;
1685 u16 hE = 0; 1557 u16 err = 0;
1686 1558
1687 if ((string_length < 1) || (string_length > 256)) 1559 if ((string_length < 1) || (string_length > 256))
1688 return HPI_ERROR_INVALID_CONTROL_VALUE; 1560 return HPI_ERROR_INVALID_CONTROL_VALUE;
@@ -1705,7 +1577,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1705 return HPI_ERROR_INVALID_CONTROL_VALUE; 1577 return HPI_ERROR_INVALID_CONTROL_VALUE;
1706 1578
1707 if (hr.error) { 1579 if (hr.error) {
1708 hE = hr.error; 1580 err = hr.error;
1709 break; 1581 break;
1710 } 1582 }
1711 for (j = 0; j < 8; j++) { 1583 for (j = 0; j < 8; j++) {
@@ -1714,7 +1586,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1714 n++; 1586 n++;
1715 if (n >= string_length) { 1587 if (n >= string_length) {
1716 psz_string[string_length - 1] = 0; 1588 psz_string[string_length - 1] = 0;
1717 hE = HPI_ERROR_INVALID_CONTROL_VALUE; 1589 err = HPI_ERROR_INVALID_CONTROL_VALUE;
1718 break; 1590 break;
1719 } 1591 }
1720 if (c == 0) 1592 if (c == 0)
@@ -1730,7 +1602,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute,
1730 if (c == 0) 1602 if (c == 0)
1731 break; 1603 break;
1732 } 1604 }
1733 return hE; 1605 return err;
1734} 1606}
1735 1607
1736u16 HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys *ph_subsys, 1608u16 HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys *ph_subsys,
@@ -2709,7 +2581,7 @@ u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
2709 u32 h_control, u32 enable) 2581 u32 h_control, u32 enable)
2710{ 2582{
2711 return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2583 return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE,
2712 (u32)enable, 0); 2584 enable, 0);
2713} 2585}
2714 2586
2715u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 2587u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys,
@@ -2758,7 +2630,7 @@ u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
2758 u32 h_control, u32 enable) 2630 u32 h_control, u32 enable)
2759{ 2631{
2760 return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, 2632 return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE,
2761 (u32)enable, 0); 2633 enable, 0);
2762} 2634}
2763 2635
2764u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys, 2636u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys,
@@ -2904,11 +2776,10 @@ u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2904 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2776 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2905 HPI_CONTROL_GET_STATE); 2777 HPI_CONTROL_GET_STATE);
2906 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2778 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2907 hm.u.c.attribute = HPI_TUNER_LEVEL; 2779 hm.u.cu.attribute = HPI_TUNER_LEVEL_AVG;
2908 hm.u.c.param1 = HPI_TUNER_LEVEL_AVERAGE;
2909 hpi_send_recv(&hm, &hr); 2780 hpi_send_recv(&hm, &hr);
2910 if (pw_level) 2781 if (pw_level)
2911 *pw_level = (short)hr.u.c.param1; 2782 *pw_level = hr.u.cu.tuner.s_level;
2912 return hr.error; 2783 return hr.error;
2913} 2784}
2914 2785
@@ -2921,11 +2792,10 @@ u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys,
2921 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, 2792 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2922 HPI_CONTROL_GET_STATE); 2793 HPI_CONTROL_GET_STATE);
2923 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); 2794 u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2924 hm.u.c.attribute = HPI_TUNER_LEVEL; 2795 hm.u.cu.attribute = HPI_TUNER_LEVEL_RAW;
2925 hm.u.c.param1 = HPI_TUNER_LEVEL_RAW;
2926 hpi_send_recv(&hm, &hr); 2796 hpi_send_recv(&hm, &hr);
2927 if (pw_level) 2797 if (pw_level)
2928 *pw_level = (short)hr.u.c.param1; 2798 *pw_level = hr.u.cu.tuner.s_level;
2929 return hr.error; 2799 return hr.error;
2930} 2800}
2931 2801
@@ -3213,728 +3083,3 @@ u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3213 3083
3214 return hr.error; 3084 return hr.error;
3215} 3085}
3216
3217static size_t strv_packet_size = MIN_STRV_PACKET_SIZE;
3218
3219static size_t entity_type_to_size[LAST_ENTITY_TYPE] = {
3220 0,
3221 sizeof(struct hpi_entity),
3222 sizeof(void *),
3223
3224 sizeof(int),
3225 sizeof(float),
3226 sizeof(double),
3227
3228 sizeof(char),
3229 sizeof(char),
3230
3231 4 * sizeof(char),
3232 16 * sizeof(char),
3233 6 * sizeof(char),
3234};
3235
3236static inline size_t hpi_entity_size(struct hpi_entity *entity_ptr)
3237{
3238 return entity_ptr->header.size;
3239}
3240
3241static inline size_t hpi_entity_header_size(struct hpi_entity *entity_ptr)
3242{
3243 return sizeof(entity_ptr->header);
3244}
3245
3246static inline size_t hpi_entity_value_size(struct hpi_entity *entity_ptr)
3247{
3248 return hpi_entity_size(entity_ptr) -
3249 hpi_entity_header_size(entity_ptr);
3250}
3251
3252static inline size_t hpi_entity_item_count(struct hpi_entity *entity_ptr)
3253{
3254 return hpi_entity_value_size(entity_ptr) /
3255 entity_type_to_size[entity_ptr->header.type];
3256}
3257
3258static inline struct hpi_entity *hpi_entity_ptr_to_next(struct hpi_entity
3259 *entity_ptr)
3260{
3261 return (void *)(((u8 *)entity_ptr) + hpi_entity_size(entity_ptr));
3262}
3263
3264static inline u16 hpi_entity_check_type(const enum e_entity_type t)
3265{
3266 if (t >= 0 && t < STR_TYPE_FIELD_MAX)
3267 return 0;
3268 return HPI_ERROR_ENTITY_TYPE_INVALID;
3269}
3270
3271static inline u16 hpi_entity_check_role(const enum e_entity_role r)
3272{
3273 if (r >= 0 && r < STR_ROLE_FIELD_MAX)
3274 return 0;
3275 return HPI_ERROR_ENTITY_ROLE_INVALID;
3276}
3277
3278static u16 hpi_entity_get_next(struct hpi_entity *entity, int recursive_flag,
3279 void *guard_p, struct hpi_entity **next)
3280{
3281 HPI_DEBUG_ASSERT(entity != NULL);
3282 HPI_DEBUG_ASSERT(next != NULL);
3283 HPI_DEBUG_ASSERT(hpi_entity_size(entity) != 0);
3284
3285 if (guard_p <= (void *)entity) {
3286 *next = NULL;
3287 return 0;
3288 }
3289
3290 if (recursive_flag && entity->header.type == entity_type_sequence)
3291 *next = (struct hpi_entity *)entity->value;
3292 else
3293 *next = (struct hpi_entity *)hpi_entity_ptr_to_next(entity);
3294
3295 if (guard_p <= (void *)*next) {
3296 *next = NULL;
3297 return 0;
3298 }
3299
3300 HPI_DEBUG_ASSERT(guard_p >= (void *)hpi_entity_ptr_to_next(*next));
3301 return 0;
3302}
3303
3304u16 hpi_entity_find_next(struct hpi_entity *container_entity,
3305 enum e_entity_type type, enum e_entity_role role, int recursive_flag,
3306 struct hpi_entity **current_match)
3307{
3308 struct hpi_entity *tmp = NULL;
3309 void *guard_p = NULL;
3310
3311 HPI_DEBUG_ASSERT(container_entity != NULL);
3312 guard_p = hpi_entity_ptr_to_next(container_entity);
3313
3314 if (*current_match != NULL)
3315 hpi_entity_get_next(*current_match, recursive_flag, guard_p,
3316 &tmp);
3317 else
3318 hpi_entity_get_next(container_entity, 1, guard_p, &tmp);
3319
3320 while (tmp) {
3321 u16 err;
3322
3323 HPI_DEBUG_ASSERT((void *)tmp >= (void *)container_entity);
3324
3325 if ((!type || tmp->header.type == type) && (!role
3326 || tmp->header.role == role)) {
3327 *current_match = tmp;
3328 return 0;
3329 }
3330
3331 err = hpi_entity_get_next(tmp, recursive_flag, guard_p,
3332 current_match);
3333 if (err)
3334 return err;
3335
3336 tmp = *current_match;
3337 }
3338
3339 *current_match = NULL;
3340 return 0;
3341}
3342
3343void hpi_entity_free(struct hpi_entity *entity)
3344{
3345 kfree(entity);
3346}
3347
3348static u16 hpi_entity_alloc_and_copy(struct hpi_entity *src,
3349 struct hpi_entity **dst)
3350{
3351 size_t buf_size;
3352 HPI_DEBUG_ASSERT(dst != NULL);
3353 HPI_DEBUG_ASSERT(src != NULL);
3354
3355 buf_size = hpi_entity_size(src);
3356 *dst = kmalloc(buf_size, GFP_KERNEL);
3357 if (*dst == NULL)
3358 return HPI_ERROR_MEMORY_ALLOC;
3359 memcpy(*dst, src, buf_size);
3360 return 0;
3361}
3362
3363u16 hpi_universal_info(const struct hpi_hsubsys *ph_subsys, u32 hC,
3364 struct hpi_entity **info)
3365{
3366 struct hpi_msg_strv hm;
3367 struct hpi_res_strv *phr;
3368 u16 hpi_err;
3369 int remaining_attempts = 2;
3370 size_t resp_packet_size = 1024;
3371
3372 *info = NULL;
3373
3374 while (remaining_attempts--) {
3375 phr = kmalloc(resp_packet_size, GFP_KERNEL);
3376 HPI_DEBUG_ASSERT(phr != NULL);
3377
3378 hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h,
3379 (u16)resp_packet_size, HPI_OBJ_CONTROL,
3380 HPI_CONTROL_GET_INFO);
3381 u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index);
3382
3383 hm.strv.header.size = sizeof(hm.strv);
3384 phr->strv.header.size = resp_packet_size - sizeof(phr->h);
3385
3386 hpi_send_recv((struct hpi_message *)&hm.h,
3387 (struct hpi_response *)&phr->h);
3388 if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) {
3389
3390 HPI_DEBUG_ASSERT(phr->h.specific_error >
3391 MIN_STRV_PACKET_SIZE
3392 && phr->h.specific_error < 1500);
3393 resp_packet_size = phr->h.specific_error;
3394 } else {
3395 remaining_attempts = 0;
3396 if (!phr->h.error)
3397 hpi_entity_alloc_and_copy(&phr->strv, info);
3398 }
3399
3400 hpi_err = phr->h.error;
3401 kfree(phr);
3402 }
3403
3404 return hpi_err;
3405}
3406
3407u16 hpi_universal_get(const struct hpi_hsubsys *ph_subsys, u32 hC,
3408 struct hpi_entity **value)
3409{
3410 struct hpi_msg_strv hm;
3411 struct hpi_res_strv *phr;
3412 u16 hpi_err;
3413 int remaining_attempts = 2;
3414
3415 *value = NULL;
3416
3417 while (remaining_attempts--) {
3418 phr = kmalloc(strv_packet_size, GFP_KERNEL);
3419 if (!phr)
3420 return HPI_ERROR_MEMORY_ALLOC;
3421
3422 hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h,
3423 (u16)strv_packet_size, HPI_OBJ_CONTROL,
3424 HPI_CONTROL_GET_STATE);
3425 u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index);
3426
3427 hm.strv.header.size = sizeof(hm.strv);
3428 phr->strv.header.size = strv_packet_size - sizeof(phr->h);
3429
3430 hpi_send_recv((struct hpi_message *)&hm.h,
3431 (struct hpi_response *)&phr->h);
3432 if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) {
3433
3434 HPI_DEBUG_ASSERT(phr->h.specific_error >
3435 MIN_STRV_PACKET_SIZE
3436 && phr->h.specific_error < 1000);
3437 strv_packet_size = phr->h.specific_error;
3438 } else {
3439 remaining_attempts = 0;
3440 if (!phr->h.error)
3441 hpi_entity_alloc_and_copy(&phr->strv, value);
3442 }
3443
3444 hpi_err = phr->h.error;
3445 kfree(phr);
3446 }
3447
3448 return hpi_err;
3449}
3450
3451u16 hpi_universal_set(const struct hpi_hsubsys *ph_subsys, u32 hC,
3452 struct hpi_entity *value)
3453{
3454 struct hpi_msg_strv *phm;
3455 struct hpi_res_strv hr;
3456
3457 phm = kmalloc(sizeof(phm->h) + value->header.size, GFP_KERNEL);
3458 HPI_DEBUG_ASSERT(phm != NULL);
3459
3460 hpi_init_message_responseV1(&phm->h,
3461 sizeof(phm->h) + value->header.size, &hr.h, sizeof(hr),
3462 HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE);
3463 u32TOINDEXES(hC, &phm->h.adapter_index, &phm->h.obj_index);
3464 hr.strv.header.size = sizeof(hr.strv);
3465
3466 memcpy(&phm->strv, value, value->header.size);
3467 hpi_send_recv((struct hpi_message *)&phm->h,
3468 (struct hpi_response *)&hr.h);
3469
3470 return hr.h.error;
3471}
3472
3473u16 hpi_entity_alloc_and_pack(const enum e_entity_type type,
3474 const size_t item_count, const enum e_entity_role role, void *value,
3475 struct hpi_entity **entity)
3476{
3477 size_t bytes_to_copy, total_size;
3478 u16 hE = 0;
3479 *entity = NULL;
3480
3481 hE = hpi_entity_check_type(type);
3482 if (hE)
3483 return hE;
3484
3485 HPI_DEBUG_ASSERT(role > entity_role_null && type < LAST_ENTITY_TYPE);
3486
3487 bytes_to_copy = entity_type_to_size[type] * item_count;
3488 total_size = hpi_entity_header_size(*entity) + bytes_to_copy;
3489
3490 HPI_DEBUG_ASSERT(total_size >= hpi_entity_header_size(*entity)
3491 && total_size < STR_SIZE_FIELD_MAX);
3492
3493 *entity = kmalloc(total_size, GFP_KERNEL);
3494 if (*entity == NULL)
3495 return HPI_ERROR_MEMORY_ALLOC;
3496 memcpy((*entity)->value, value, bytes_to_copy);
3497 (*entity)->header.size =
3498 hpi_entity_header_size(*entity) + bytes_to_copy;
3499 (*entity)->header.type = type;
3500 (*entity)->header.role = role;
3501 return 0;
3502}
3503
3504u16 hpi_entity_copy_value_from(struct hpi_entity *entity,
3505 enum e_entity_type type, size_t item_count, void *value_dst_p)
3506{
3507 size_t bytes_to_copy;
3508
3509 if (entity->header.type != type)
3510 return HPI_ERROR_ENTITY_TYPE_MISMATCH;
3511
3512 if (hpi_entity_item_count(entity) != item_count)
3513 return HPI_ERROR_ENTITY_ITEM_COUNT;
3514
3515 bytes_to_copy = entity_type_to_size[type] * item_count;
3516 memcpy(value_dst_p, entity->value, bytes_to_copy);
3517 return 0;
3518}
3519
3520u16 hpi_entity_unpack(struct hpi_entity *entity, enum e_entity_type *type,
3521 size_t *item_count, enum e_entity_role *role, void **value)
3522{
3523 u16 err = 0;
3524 HPI_DEBUG_ASSERT(entity != NULL);
3525
3526 if (type)
3527 *type = entity->header.type;
3528
3529 if (role)
3530 *role = entity->header.role;
3531
3532 if (value)
3533 *value = entity->value;
3534
3535 if (item_count != NULL) {
3536 if (entity->header.type == entity_type_sequence) {
3537 void *guard_p = hpi_entity_ptr_to_next(entity);
3538 struct hpi_entity *next = NULL;
3539 void *contents = entity->value;
3540
3541 *item_count = 0;
3542 while (contents < guard_p) {
3543 (*item_count)++;
3544 err = hpi_entity_get_next(contents, 0,
3545 guard_p, &next);
3546 if (next == NULL || err)
3547 break;
3548 contents = next;
3549 }
3550 } else {
3551 *item_count = hpi_entity_item_count(entity);
3552 }
3553 }
3554 return err;
3555}
3556
3557u16 hpi_gpio_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3558 u32 *ph_gpio, u16 *pw_number_input_bits, u16 *pw_number_output_bits)
3559{
3560 struct hpi_message hm;
3561 struct hpi_response hr;
3562 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_OPEN);
3563 hm.adapter_index = adapter_index;
3564
3565 hpi_send_recv(&hm, &hr);
3566
3567 if (hr.error == 0) {
3568 *ph_gpio =
3569 hpi_indexes_to_handle(HPI_OBJ_GPIO, adapter_index, 0);
3570 if (pw_number_input_bits)
3571 *pw_number_input_bits = hr.u.l.number_input_bits;
3572 if (pw_number_output_bits)
3573 *pw_number_output_bits = hr.u.l.number_output_bits;
3574 } else
3575 *ph_gpio = 0;
3576 return hr.error;
3577}
3578
3579u16 hpi_gpio_read_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3580 u16 bit_index, u16 *pw_bit_data)
3581{
3582 struct hpi_message hm;
3583 struct hpi_response hr;
3584 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_BIT);
3585 u32TOINDEX(h_gpio, &hm.adapter_index);
3586 hm.u.l.bit_index = bit_index;
3587
3588 hpi_send_recv(&hm, &hr);
3589
3590 *pw_bit_data = hr.u.l.bit_data[0];
3591 return hr.error;
3592}
3593
3594u16 hpi_gpio_read_all_bits(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3595 u16 aw_all_bit_data[4]
3596 )
3597{
3598 struct hpi_message hm;
3599 struct hpi_response hr;
3600 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_ALL);
3601 u32TOINDEX(h_gpio, &hm.adapter_index);
3602
3603 hpi_send_recv(&hm, &hr);
3604
3605 if (aw_all_bit_data) {
3606 aw_all_bit_data[0] = hr.u.l.bit_data[0];
3607 aw_all_bit_data[1] = hr.u.l.bit_data[1];
3608 aw_all_bit_data[2] = hr.u.l.bit_data[2];
3609 aw_all_bit_data[3] = hr.u.l.bit_data[3];
3610 }
3611 return hr.error;
3612}
3613
3614u16 hpi_gpio_write_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3615 u16 bit_index, u16 bit_data)
3616{
3617 struct hpi_message hm;
3618 struct hpi_response hr;
3619 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_WRITE_BIT);
3620 u32TOINDEX(h_gpio, &hm.adapter_index);
3621 hm.u.l.bit_index = bit_index;
3622 hm.u.l.bit_data = bit_data;
3623
3624 hpi_send_recv(&hm, &hr);
3625
3626 return hr.error;
3627}
3628
3629u16 hpi_gpio_write_status(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3630 u16 aw_all_bit_data[4]
3631 )
3632{
3633 struct hpi_message hm;
3634 struct hpi_response hr;
3635 hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO,
3636 HPI_GPIO_WRITE_STATUS);
3637 u32TOINDEX(h_gpio, &hm.adapter_index);
3638
3639 hpi_send_recv(&hm, &hr);
3640
3641 if (aw_all_bit_data) {
3642 aw_all_bit_data[0] = hr.u.l.bit_data[0];
3643 aw_all_bit_data[1] = hr.u.l.bit_data[1];
3644 aw_all_bit_data[2] = hr.u.l.bit_data[2];
3645 aw_all_bit_data[3] = hr.u.l.bit_data[3];
3646 }
3647 return hr.error;
3648}
3649
3650u16 hpi_async_event_open(const struct hpi_hsubsys *ph_subsys,
3651 u16 adapter_index, u32 *ph_async)
3652{
3653 struct hpi_message hm;
3654 struct hpi_response hr;
3655 hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3656 HPI_ASYNCEVENT_OPEN);
3657 hm.adapter_index = adapter_index;
3658
3659 hpi_send_recv(&hm, &hr);
3660
3661 if (hr.error == 0)
3662
3663 *ph_async =
3664 hpi_indexes_to_handle(HPI_OBJ_ASYNCEVENT,
3665 adapter_index, 0);
3666 else
3667 *ph_async = 0;
3668 return hr.error;
3669
3670}
3671
3672u16 hpi_async_event_close(const struct hpi_hsubsys *ph_subsys, u32 h_async)
3673{
3674 struct hpi_message hm;
3675 struct hpi_response hr;
3676 hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3677 HPI_ASYNCEVENT_OPEN);
3678 u32TOINDEX(h_async, &hm.adapter_index);
3679
3680 hpi_send_recv(&hm, &hr);
3681
3682 return hr.error;
3683}
3684
3685u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async,
3686 u16 maximum_events, struct hpi_async_event *p_events,
3687 u16 *pw_number_returned)
3688{
3689
3690 return 0;
3691}
3692
3693u16 hpi_async_event_get_count(const struct hpi_hsubsys *ph_subsys,
3694 u32 h_async, u16 *pw_count)
3695{
3696 struct hpi_message hm;
3697 struct hpi_response hr;
3698 hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3699 HPI_ASYNCEVENT_GETCOUNT);
3700 u32TOINDEX(h_async, &hm.adapter_index);
3701
3702 hpi_send_recv(&hm, &hr);
3703
3704 if (hr.error == 0)
3705 if (pw_count)
3706 *pw_count = hr.u.as.u.count.count;
3707
3708 return hr.error;
3709}
3710
3711u16 hpi_async_event_get(const struct hpi_hsubsys *ph_subsys, u32 h_async,
3712 u16 maximum_events, struct hpi_async_event *p_events,
3713 u16 *pw_number_returned)
3714{
3715 struct hpi_message hm;
3716 struct hpi_response hr;
3717 hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3718 HPI_ASYNCEVENT_GET);
3719 u32TOINDEX(h_async, &hm.adapter_index);
3720
3721 hpi_send_recv(&hm, &hr);
3722 if (!hr.error) {
3723 memcpy(p_events, &hr.u.as.u.event,
3724 sizeof(struct hpi_async_event));
3725 *pw_number_returned = 1;
3726 }
3727
3728 return hr.error;
3729}
3730
3731u16 hpi_nv_memory_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3732 u32 *ph_nv_memory, u16 *pw_size_in_bytes)
3733{
3734 struct hpi_message hm;
3735 struct hpi_response hr;
3736 hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3737 HPI_NVMEMORY_OPEN);
3738 hm.adapter_index = adapter_index;
3739
3740 hpi_send_recv(&hm, &hr);
3741
3742 if (hr.error == 0) {
3743 *ph_nv_memory =
3744 hpi_indexes_to_handle(HPI_OBJ_NVMEMORY, adapter_index,
3745 0);
3746 if (pw_size_in_bytes)
3747 *pw_size_in_bytes = hr.u.n.size_in_bytes;
3748 } else
3749 *ph_nv_memory = 0;
3750 return hr.error;
3751}
3752
3753u16 hpi_nv_memory_read_byte(const struct hpi_hsubsys *ph_subsys,
3754 u32 h_nv_memory, u16 index, u16 *pw_data)
3755{
3756 struct hpi_message hm;
3757 struct hpi_response hr;
3758 hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3759 HPI_NVMEMORY_READ_BYTE);
3760 u32TOINDEX(h_nv_memory, &hm.adapter_index);
3761 hm.u.n.address = index;
3762
3763 hpi_send_recv(&hm, &hr);
3764
3765 *pw_data = hr.u.n.data;
3766 return hr.error;
3767}
3768
3769u16 hpi_nv_memory_write_byte(const struct hpi_hsubsys *ph_subsys,
3770 u32 h_nv_memory, u16 index, u16 data)
3771{
3772 struct hpi_message hm;
3773 struct hpi_response hr;
3774 hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3775 HPI_NVMEMORY_WRITE_BYTE);
3776 u32TOINDEX(h_nv_memory, &hm.adapter_index);
3777 hm.u.n.address = index;
3778 hm.u.n.data = data;
3779
3780 hpi_send_recv(&hm, &hr);
3781
3782 return hr.error;
3783}
3784
3785u16 hpi_profile_open_all(const struct hpi_hsubsys *ph_subsys,
3786 u16 adapter_index, u16 profile_index, u32 *ph_profile,
3787 u16 *pw_max_profiles)
3788{
3789 struct hpi_message hm;
3790 struct hpi_response hr;
3791 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3792 HPI_PROFILE_OPEN_ALL);
3793 hm.adapter_index = adapter_index;
3794 hm.obj_index = profile_index;
3795 hpi_send_recv(&hm, &hr);
3796
3797 *pw_max_profiles = hr.u.p.u.o.max_profiles;
3798 if (hr.error == 0)
3799 *ph_profile =
3800 hpi_indexes_to_handle(HPI_OBJ_PROFILE, adapter_index,
3801 profile_index);
3802 else
3803 *ph_profile = 0;
3804 return hr.error;
3805}
3806
3807u16 hpi_profile_get(const struct hpi_hsubsys *ph_subsys, u32 h_profile,
3808 u16 bin_index, u16 *pw_seconds, u32 *pmicro_seconds, u32 *pcall_count,
3809 u32 *pmax_micro_seconds, u32 *pmin_micro_seconds)
3810{
3811 struct hpi_message hm;
3812 struct hpi_response hr;
3813 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_GET);
3814 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3815 hm.u.p.bin_index = bin_index;
3816 hpi_send_recv(&hm, &hr);
3817 if (pw_seconds)
3818 *pw_seconds = hr.u.p.u.t.seconds;
3819 if (pmicro_seconds)
3820 *pmicro_seconds = hr.u.p.u.t.micro_seconds;
3821 if (pcall_count)
3822 *pcall_count = hr.u.p.u.t.call_count;
3823 if (pmax_micro_seconds)
3824 *pmax_micro_seconds = hr.u.p.u.t.max_micro_seconds;
3825 if (pmin_micro_seconds)
3826 *pmin_micro_seconds = hr.u.p.u.t.min_micro_seconds;
3827 return hr.error;
3828}
3829
3830u16 hpi_profile_get_utilization(const struct hpi_hsubsys *ph_subsys,
3831 u32 h_profile, u32 *putilization)
3832{
3833 struct hpi_message hm;
3834 struct hpi_response hr;
3835 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3836 HPI_PROFILE_GET_UTILIZATION);
3837 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3838 hpi_send_recv(&hm, &hr);
3839 if (hr.error) {
3840 if (putilization)
3841 *putilization = 0;
3842 } else {
3843 if (putilization)
3844 *putilization = hr.u.p.u.t.call_count;
3845 }
3846 return hr.error;
3847}
3848
3849u16 hpi_profile_get_name(const struct hpi_hsubsys *ph_subsys, u32 h_profile,
3850 u16 bin_index, char *sz_name, u16 name_length)
3851{
3852 struct hpi_message hm;
3853 struct hpi_response hr;
3854 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3855 HPI_PROFILE_GET_NAME);
3856 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3857 hm.u.p.bin_index = bin_index;
3858 hpi_send_recv(&hm, &hr);
3859 if (hr.error) {
3860 if (sz_name)
3861 strcpy(sz_name, "??");
3862 } else {
3863 if (sz_name)
3864 memcpy(sz_name, (char *)hr.u.p.u.n.sz_name,
3865 name_length);
3866 }
3867 return hr.error;
3868}
3869
3870u16 hpi_profile_start_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile)
3871{
3872 struct hpi_message hm;
3873 struct hpi_response hr;
3874 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3875 HPI_PROFILE_START_ALL);
3876 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3877 hpi_send_recv(&hm, &hr);
3878
3879 return hr.error;
3880}
3881
3882u16 hpi_profile_stop_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile)
3883{
3884 struct hpi_message hm;
3885 struct hpi_response hr;
3886 hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3887 HPI_PROFILE_STOP_ALL);
3888 u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3889 hpi_send_recv(&hm, &hr);
3890
3891 return hr.error;
3892}
3893
3894u16 hpi_watchdog_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3895 u32 *ph_watchdog)
3896{
3897 struct hpi_message hm;
3898 struct hpi_response hr;
3899 hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3900 HPI_WATCHDOG_OPEN);
3901 hm.adapter_index = adapter_index;
3902
3903 hpi_send_recv(&hm, &hr);
3904
3905 if (hr.error == 0)
3906 *ph_watchdog =
3907 hpi_indexes_to_handle(HPI_OBJ_WATCHDOG, adapter_index,
3908 0);
3909 else
3910 *ph_watchdog = 0;
3911 return hr.error;
3912}
3913
3914u16 hpi_watchdog_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog,
3915 u32 time_millisec)
3916{
3917 struct hpi_message hm;
3918 struct hpi_response hr;
3919 hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3920 HPI_WATCHDOG_SET_TIME);
3921 u32TOINDEX(h_watchdog, &hm.adapter_index);
3922 hm.u.w.time_ms = time_millisec;
3923
3924 hpi_send_recv(&hm, &hr);
3925
3926 return hr.error;
3927}
3928
3929u16 hpi_watchdog_ping(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog)
3930{
3931 struct hpi_message hm;
3932 struct hpi_response hr;
3933 hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3934 HPI_WATCHDOG_PING);
3935 u32TOINDEX(h_watchdog, &hm.adapter_index);
3936
3937 hpi_send_recv(&hm, &hr);
3938
3939 return hr.error;
3940}
diff --git a/sound/pci/asihpi/hpimsginit.c b/sound/pci/asihpi/hpimsginit.c
index 42f918220ee4..628376ce4a49 100644
--- a/sound/pci/asihpi/hpimsginit.c
+++ b/sound/pci/asihpi/hpimsginit.c
@@ -50,7 +50,7 @@ static void hpi_init_message(struct hpi_message *phm, u16 object,
50 phm->object = object; 50 phm->object = object;
51 phm->function = function; 51 phm->function = function;
52 phm->version = 0; 52 phm->version = 0;
53 phm->adapter_index = 0xFFFF; 53 phm->adapter_index = HPI_ADAPTER_INDEX_INVALID;
54 /* Expect actual adapter index to be set by caller */ 54 /* Expect actual adapter index to be set by caller */
55} 55}
56 56
diff --git a/sound/pci/asihpi/hpimsgx.c b/sound/pci/asihpi/hpimsgx.c
index f01ab964f602..b4e7d9a19472 100644
--- a/sound/pci/asihpi/hpimsgx.c
+++ b/sound/pci/asihpi/hpimsgx.c
@@ -23,6 +23,7 @@ Extended Message Function With Response Cacheing
23#define SOURCEFILE_NAME "hpimsgx.c" 23#define SOURCEFILE_NAME "hpimsgx.c"
24#include "hpi_internal.h" 24#include "hpi_internal.h"
25#include "hpimsginit.h" 25#include "hpimsginit.h"
26#include "hpicmn.h"
26#include "hpimsgx.h" 27#include "hpimsgx.h"
27#include "hpidebug.h" 28#include "hpidebug.h"
28 29
@@ -42,22 +43,24 @@ static hpi_handler_func *hpi_lookup_entry_point_function(const struct hpi_pci
42 43
43 for (i = 0; asihpi_pci_tbl[i].vendor != 0; i++) { 44 for (i = 0; asihpi_pci_tbl[i].vendor != 0; i++) {
44 if (asihpi_pci_tbl[i].vendor != PCI_ANY_ID 45 if (asihpi_pci_tbl[i].vendor != PCI_ANY_ID
45 && asihpi_pci_tbl[i].vendor != pci_info->vendor_id) 46 && asihpi_pci_tbl[i].vendor !=
47 pci_info->pci_dev->vendor)
46 continue; 48 continue;
47 if (asihpi_pci_tbl[i].device != PCI_ANY_ID 49 if (asihpi_pci_tbl[i].device != PCI_ANY_ID
48 && asihpi_pci_tbl[i].device != pci_info->device_id) 50 && asihpi_pci_tbl[i].device !=
51 pci_info->pci_dev->device)
49 continue; 52 continue;
50 if (asihpi_pci_tbl[i].subvendor != PCI_ANY_ID 53 if (asihpi_pci_tbl[i].subvendor != PCI_ANY_ID
51 && asihpi_pci_tbl[i].subvendor != 54 && asihpi_pci_tbl[i].subvendor !=
52 pci_info->subsys_vendor_id) 55 pci_info->pci_dev->subsystem_vendor)
53 continue; 56 continue;
54 if (asihpi_pci_tbl[i].subdevice != PCI_ANY_ID 57 if (asihpi_pci_tbl[i].subdevice != PCI_ANY_ID
55 && asihpi_pci_tbl[i].subdevice != 58 && asihpi_pci_tbl[i].subdevice !=
56 pci_info->subsys_device_id) 59 pci_info->pci_dev->subsystem_device)
57 continue; 60 continue;
58 61
59 HPI_DEBUG_LOG(DEBUG, " %x,%lu\n", i, 62 /* HPI_DEBUG_LOG(DEBUG, " %x,%lx\n", i,
60 asihpi_pci_tbl[i].driver_data); 63 asihpi_pci_tbl[i].driver_data); */
61 return (hpi_handler_func *) asihpi_pci_tbl[i].driver_data; 64 return (hpi_handler_func *) asihpi_pci_tbl[i].driver_data;
62 } 65 }
63 66
@@ -67,21 +70,12 @@ static hpi_handler_func *hpi_lookup_entry_point_function(const struct hpi_pci
67static inline void hw_entry_point(struct hpi_message *phm, 70static inline void hw_entry_point(struct hpi_message *phm,
68 struct hpi_response *phr) 71 struct hpi_response *phr)
69{ 72{
70 73 if ((phm->adapter_index < HPI_MAX_ADAPTERS)
71 hpi_handler_func *ep; 74 && hpi_entry_points[phm->adapter_index])
72 75 hpi_entry_points[phm->adapter_index] (phm, phr);
73 if (phm->adapter_index < HPI_MAX_ADAPTERS) { 76 else
74 ep = (hpi_handler_func *) hpi_entry_points[phm-> 77 hpi_init_response(phr, phm->object, phm->function,
75 adapter_index]; 78 HPI_ERROR_PROCESSING_MESSAGE);
76 if (ep) {
77 HPI_DEBUG_MESSAGE(DEBUG, phm);
78 ep(phm, phr);
79 HPI_DEBUG_RESPONSE(phr);
80 return;
81 }
82 }
83 hpi_init_response(phr, phm->object, phm->function,
84 HPI_ERROR_PROCESSING_MESSAGE);
85} 79}
86 80
87static void adapter_open(struct hpi_message *phm, struct hpi_response *phr); 81static void adapter_open(struct hpi_message *phm, struct hpi_response *phr);
@@ -100,6 +94,7 @@ static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
100 void *h_owner); 94 void *h_owner);
101 95
102static void HPIMSGX__reset(u16 adapter_index); 96static void HPIMSGX__reset(u16 adapter_index);
97
103static u16 HPIMSGX__init(struct hpi_message *phm, struct hpi_response *phr); 98static u16 HPIMSGX__init(struct hpi_message *phm, struct hpi_response *phr);
104static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner); 99static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner);
105 100
@@ -153,8 +148,6 @@ static struct hpi_stream_response
153 148
154static struct hpi_mixer_response rESP_HPI_MIXER_OPEN[HPI_MAX_ADAPTERS]; 149static struct hpi_mixer_response rESP_HPI_MIXER_OPEN[HPI_MAX_ADAPTERS];
155 150
156static struct hpi_subsys_response gRESP_HPI_SUBSYS_FIND_ADAPTERS;
157
158static struct adapter_info aDAPTER_INFO[HPI_MAX_ADAPTERS]; 151static struct adapter_info aDAPTER_INFO[HPI_MAX_ADAPTERS];
159 152
160/* use these to keep track of opens from user mode apps/DLLs */ 153/* use these to keep track of opens from user mode apps/DLLs */
@@ -167,6 +160,11 @@ static struct asi_open_state
167static void subsys_message(struct hpi_message *phm, struct hpi_response *phr, 160static void subsys_message(struct hpi_message *phm, struct hpi_response *phr,
168 void *h_owner) 161 void *h_owner)
169{ 162{
163 if (phm->adapter_index != HPI_ADAPTER_INDEX_INVALID)
164 HPI_DEBUG_LOG(WARNING,
165 "suspicious adapter index %d in subsys message 0x%x.\n",
166 phm->adapter_index, phm->function);
167
170 switch (phm->function) { 168 switch (phm->function) {
171 case HPI_SUBSYS_GET_VERSION: 169 case HPI_SUBSYS_GET_VERSION:
172 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, 170 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
@@ -204,85 +202,37 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr,
204 HPI_SUBSYS_DRIVER_UNLOAD, 0); 202 HPI_SUBSYS_DRIVER_UNLOAD, 0);
205 return; 203 return;
206 204
207 case HPI_SUBSYS_GET_INFO:
208 HPI_COMMON(phm, phr);
209 break;
210
211 case HPI_SUBSYS_FIND_ADAPTERS:
212 memcpy(phr, &gRESP_HPI_SUBSYS_FIND_ADAPTERS,
213 sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS));
214 break;
215 case HPI_SUBSYS_GET_NUM_ADAPTERS: 205 case HPI_SUBSYS_GET_NUM_ADAPTERS:
216 memcpy(phr, &gRESP_HPI_SUBSYS_FIND_ADAPTERS,
217 sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS));
218 phr->function = HPI_SUBSYS_GET_NUM_ADAPTERS;
219 break;
220 case HPI_SUBSYS_GET_ADAPTER: 206 case HPI_SUBSYS_GET_ADAPTER:
221 { 207 HPI_COMMON(phm, phr);
222 int count = phm->adapter_index; 208 break;
223 int index = 0;
224 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
225 HPI_SUBSYS_GET_ADAPTER, 0);
226
227 /* This is complicated by the fact that we want to
228 * "skip" 0's in the adapter list.
229 * First, make sure we are pointing to a
230 * non-zero adapter type.
231 */
232 while (gRESP_HPI_SUBSYS_FIND_ADAPTERS.
233 s.aw_adapter_list[index] == 0) {
234 index++;
235 if (index >= HPI_MAX_ADAPTERS)
236 break;
237 }
238 while (count) {
239 /* move on to the next adapter */
240 index++;
241 if (index >= HPI_MAX_ADAPTERS)
242 break;
243 while (gRESP_HPI_SUBSYS_FIND_ADAPTERS.
244 s.aw_adapter_list[index] == 0) {
245 index++;
246 if (index >= HPI_MAX_ADAPTERS)
247 break;
248 }
249 count--;
250 }
251 209
252 if (index < HPI_MAX_ADAPTERS) {
253 phr->u.s.adapter_index = (u16)index;
254 phr->u.s.aw_adapter_list[0] =
255 gRESP_HPI_SUBSYS_FIND_ADAPTERS.
256 s.aw_adapter_list[index];
257 } else {
258 phr->u.s.adapter_index = 0;
259 phr->u.s.aw_adapter_list[0] = 0;
260 phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER;
261 }
262 break;
263 }
264 case HPI_SUBSYS_CREATE_ADAPTER: 210 case HPI_SUBSYS_CREATE_ADAPTER:
265 HPIMSGX__init(phm, phr); 211 HPIMSGX__init(phm, phr);
266 break; 212 break;
213
267 case HPI_SUBSYS_DELETE_ADAPTER: 214 case HPI_SUBSYS_DELETE_ADAPTER:
268 HPIMSGX__cleanup(phm->adapter_index, h_owner); 215 HPIMSGX__cleanup(phm->obj_index, h_owner);
269 { 216 {
270 struct hpi_message hm; 217 struct hpi_message hm;
271 struct hpi_response hr; 218 struct hpi_response hr;
272 /* call to HPI_ADAPTER_CLOSE */
273 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 219 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
274 HPI_ADAPTER_CLOSE); 220 HPI_ADAPTER_CLOSE);
275 hm.adapter_index = phm->adapter_index; 221 hm.adapter_index = phm->obj_index;
276 hw_entry_point(&hm, &hr); 222 hw_entry_point(&hm, &hr);
277 } 223 }
278 hw_entry_point(phm, phr); 224 if ((phm->obj_index < HPI_MAX_ADAPTERS)
279 gRESP_HPI_SUBSYS_FIND_ADAPTERS.s. 225 && hpi_entry_points[phm->obj_index]) {
280 aw_adapter_list[phm->adapter_index] 226 hpi_entry_points[phm->obj_index] (phm, phr);
281 = 0; 227 hpi_entry_points[phm->obj_index] = NULL;
282 hpi_entry_points[phm->adapter_index] = NULL; 228 } else
229 phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
230
283 break; 231 break;
284 default: 232 default:
285 hw_entry_point(phm, phr); 233 /* Must explicitly send subsys messages to individual backends */
234 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, phm->function,
235 HPI_ERROR_INVALID_FUNC);
286 break; 236 break;
287 } 237 }
288} 238}
@@ -409,33 +359,7 @@ void hpi_send_recv_ex(struct hpi_message *phm, struct hpi_response *phr,
409 break; 359 break;
410 } 360 }
411 HPI_DEBUG_RESPONSE(phr); 361 HPI_DEBUG_RESPONSE(phr);
412#if 1 362
413 if (phr->error >= HPI_ERROR_BACKEND_BASE) {
414 void *ep = NULL;
415 char *ep_name;
416
417 HPI_DEBUG_MESSAGE(ERROR, phm);
418
419 if (phm->adapter_index < HPI_MAX_ADAPTERS)
420 ep = hpi_entry_points[phm->adapter_index];
421
422 /* Don't need this? Have adapter index in debug info
423 Know at driver load time index->backend mapping */
424 if (ep == HPI_6000)
425 ep_name = "HPI_6000";
426 else if (ep == HPI_6205)
427 ep_name = "HPI_6205";
428 else
429 ep_name = "unknown";
430
431 HPI_DEBUG_LOG(ERROR, "HPI %s response - error# %d\n", ep_name,
432 phr->error);
433
434 if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE)
435 hpi_debug_data((u16 *)phm,
436 sizeof(*phm) / sizeof(u16));
437 }
438#endif
439} 363}
440 364
441static void adapter_open(struct hpi_message *phm, struct hpi_response *phr) 365static void adapter_open(struct hpi_message *phm, struct hpi_response *phr)
@@ -484,7 +408,7 @@ static void instream_open(struct hpi_message *phm, struct hpi_response *phr,
484 else { 408 else {
485 instream_user_open[phm->adapter_index][phm-> 409 instream_user_open[phm->adapter_index][phm->
486 obj_index].open_flag = 1; 410 obj_index].open_flag = 1;
487 hpios_msgxlock_un_lock(&msgx_lock); 411 hpios_msgxlock_unlock(&msgx_lock);
488 412
489 /* issue a reset */ 413 /* issue a reset */
490 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 414 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
@@ -509,7 +433,7 @@ static void instream_open(struct hpi_message *phm, struct hpi_response *phr,
509 sizeof(rESP_HPI_ISTREAM_OPEN[0][0])); 433 sizeof(rESP_HPI_ISTREAM_OPEN[0][0]));
510 } 434 }
511 } 435 }
512 hpios_msgxlock_un_lock(&msgx_lock); 436 hpios_msgxlock_unlock(&msgx_lock);
513} 437}
514 438
515static void instream_close(struct hpi_message *phm, struct hpi_response *phr, 439static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
@@ -530,7 +454,7 @@ static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
530 phm->wAdapterIndex, phm->wObjIndex, hOwner); */ 454 phm->wAdapterIndex, phm->wObjIndex, hOwner); */
531 instream_user_open[phm->adapter_index][phm-> 455 instream_user_open[phm->adapter_index][phm->
532 obj_index].h_owner = NULL; 456 obj_index].h_owner = NULL;
533 hpios_msgxlock_un_lock(&msgx_lock); 457 hpios_msgxlock_unlock(&msgx_lock);
534 /* issue a reset */ 458 /* issue a reset */
535 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, 459 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
536 HPI_ISTREAM_RESET); 460 HPI_ISTREAM_RESET);
@@ -556,7 +480,7 @@ static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
556 obj_index].h_owner); 480 obj_index].h_owner);
557 phr->error = HPI_ERROR_OBJ_NOT_OPEN; 481 phr->error = HPI_ERROR_OBJ_NOT_OPEN;
558 } 482 }
559 hpios_msgxlock_un_lock(&msgx_lock); 483 hpios_msgxlock_unlock(&msgx_lock);
560} 484}
561 485
562static void outstream_open(struct hpi_message *phm, struct hpi_response *phr, 486static void outstream_open(struct hpi_message *phm, struct hpi_response *phr,
@@ -581,7 +505,7 @@ static void outstream_open(struct hpi_message *phm, struct hpi_response *phr,
581 else { 505 else {
582 outstream_user_open[phm->adapter_index][phm-> 506 outstream_user_open[phm->adapter_index][phm->
583 obj_index].open_flag = 1; 507 obj_index].open_flag = 1;
584 hpios_msgxlock_un_lock(&msgx_lock); 508 hpios_msgxlock_unlock(&msgx_lock);
585 509
586 /* issue a reset */ 510 /* issue a reset */
587 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 511 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
@@ -606,7 +530,7 @@ static void outstream_open(struct hpi_message *phm, struct hpi_response *phr,
606 sizeof(rESP_HPI_OSTREAM_OPEN[0][0])); 530 sizeof(rESP_HPI_OSTREAM_OPEN[0][0]));
607 } 531 }
608 } 532 }
609 hpios_msgxlock_un_lock(&msgx_lock); 533 hpios_msgxlock_unlock(&msgx_lock);
610} 534}
611 535
612static void outstream_close(struct hpi_message *phm, struct hpi_response *phr, 536static void outstream_close(struct hpi_message *phm, struct hpi_response *phr,
@@ -628,7 +552,7 @@ static void outstream_close(struct hpi_message *phm, struct hpi_response *phr,
628 phm->wAdapterIndex, phm->wObjIndex, hOwner); */ 552 phm->wAdapterIndex, phm->wObjIndex, hOwner); */
629 outstream_user_open[phm->adapter_index][phm-> 553 outstream_user_open[phm->adapter_index][phm->
630 obj_index].h_owner = NULL; 554 obj_index].h_owner = NULL;
631 hpios_msgxlock_un_lock(&msgx_lock); 555 hpios_msgxlock_unlock(&msgx_lock);
632 /* issue a reset */ 556 /* issue a reset */
633 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, 557 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
634 HPI_OSTREAM_RESET); 558 HPI_OSTREAM_RESET);
@@ -654,7 +578,7 @@ static void outstream_close(struct hpi_message *phm, struct hpi_response *phr,
654 obj_index].h_owner); 578 obj_index].h_owner);
655 phr->error = HPI_ERROR_OBJ_NOT_OPEN; 579 phr->error = HPI_ERROR_OBJ_NOT_OPEN;
656 } 580 }
657 hpios_msgxlock_un_lock(&msgx_lock); 581 hpios_msgxlock_unlock(&msgx_lock);
658} 582}
659 583
660static u16 adapter_prepare(u16 adapter) 584static u16 adapter_prepare(u16 adapter)
@@ -683,16 +607,9 @@ static u16 adapter_prepare(u16 adapter)
683 if (hr.error) 607 if (hr.error)
684 return hr.error; 608 return hr.error;
685 609
686 aDAPTER_INFO[adapter].num_outstreams = hr.u.a.num_outstreams; 610 aDAPTER_INFO[adapter].num_outstreams = hr.u.ax.info.num_outstreams;
687 aDAPTER_INFO[adapter].num_instreams = hr.u.a.num_instreams; 611 aDAPTER_INFO[adapter].num_instreams = hr.u.ax.info.num_instreams;
688 aDAPTER_INFO[adapter].type = hr.u.a.adapter_type; 612 aDAPTER_INFO[adapter].type = hr.u.ax.info.adapter_type;
689
690 gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list[adapter] =
691 hr.u.a.adapter_type;
692 gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters++;
693 if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters > HPI_MAX_ADAPTERS)
694 gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters =
695 HPI_MAX_ADAPTERS;
696 613
697 /* call to HPI_OSTREAM_OPEN */ 614 /* call to HPI_OSTREAM_OPEN */
698 for (i = 0; i < aDAPTER_INFO[adapter].num_outstreams; i++) { 615 for (i = 0; i < aDAPTER_INFO[adapter].num_outstreams; i++) {
@@ -727,7 +644,7 @@ static u16 adapter_prepare(u16 adapter)
727 memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr, 644 memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr,
728 sizeof(rESP_HPI_MIXER_OPEN[0])); 645 sizeof(rESP_HPI_MIXER_OPEN[0]));
729 646
730 return gRESP_HPI_SUBSYS_FIND_ADAPTERS.h.error; 647 return 0;
731} 648}
732 649
733static void HPIMSGX__reset(u16 adapter_index) 650static void HPIMSGX__reset(u16 adapter_index)
@@ -737,12 +654,6 @@ static void HPIMSGX__reset(u16 adapter_index)
737 struct hpi_response hr; 654 struct hpi_response hr;
738 655
739 if (adapter_index == HPIMSGX_ALLADAPTERS) { 656 if (adapter_index == HPIMSGX_ALLADAPTERS) {
740 /* reset all responses to contain errors */
741 hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM,
742 HPI_SUBSYS_FIND_ADAPTERS, 0);
743 memcpy(&gRESP_HPI_SUBSYS_FIND_ADAPTERS, &hr,
744 sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS));
745
746 for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) { 657 for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) {
747 658
748 hpi_init_response(&hr, HPI_OBJ_ADAPTER, 659 hpi_init_response(&hr, HPI_OBJ_ADAPTER,
@@ -783,12 +694,6 @@ static void HPIMSGX__reset(u16 adapter_index)
783 rESP_HPI_ISTREAM_OPEN[adapter_index][i].h.error = 694 rESP_HPI_ISTREAM_OPEN[adapter_index][i].h.error =
784 HPI_ERROR_INVALID_OBJ; 695 HPI_ERROR_INVALID_OBJ;
785 } 696 }
786 if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.
787 s.aw_adapter_list[adapter_index]) {
788 gRESP_HPI_SUBSYS_FIND_ADAPTERS.
789 s.aw_adapter_list[adapter_index] = 0;
790 gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters--;
791 }
792 } 697 }
793} 698}
794 699
@@ -802,15 +707,9 @@ static u16 HPIMSGX__init(struct hpi_message *phm,
802 hpi_handler_func *entry_point_func; 707 hpi_handler_func *entry_point_func;
803 struct hpi_response hr; 708 struct hpi_response hr;
804 709
805 if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters >= HPI_MAX_ADAPTERS)
806 return HPI_ERROR_BAD_ADAPTER_NUMBER;
807
808 /* Init response here so we can pass in previous adapter list */ 710 /* Init response here so we can pass in previous adapter list */
809 hpi_init_response(&hr, phm->object, phm->function, 711 hpi_init_response(&hr, phm->object, phm->function,
810 HPI_ERROR_INVALID_OBJ); 712 HPI_ERROR_INVALID_OBJ);
811 memcpy(hr.u.s.aw_adapter_list,
812 gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list,
813 sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list));
814 713
815 entry_point_func = 714 entry_point_func =
816 hpi_lookup_entry_point_function(phm->u.s.resource.r.pci); 715 hpi_lookup_entry_point_function(phm->u.s.resource.r.pci);
@@ -860,7 +759,7 @@ static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner)
860 struct hpi_response hr; 759 struct hpi_response hr;
861 760
862 HPI_DEBUG_LOG(DEBUG, 761 HPI_DEBUG_LOG(DEBUG,
863 "close adapter %d ostream %d\n", 762 "Close adapter %d ostream %d\n",
864 adapter, i); 763 adapter, i);
865 764
866 hpi_init_message_response(&hm, &hr, 765 hpi_init_message_response(&hm, &hr,
@@ -884,7 +783,7 @@ static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner)
884 struct hpi_response hr; 783 struct hpi_response hr;
885 784
886 HPI_DEBUG_LOG(DEBUG, 785 HPI_DEBUG_LOG(DEBUG,
887 "close adapter %d istream %d\n", 786 "Close adapter %d istream %d\n",
888 adapter, i); 787 adapter, i);
889 788
890 hpi_init_message_response(&hm, &hr, 789 hpi_init_message_response(&hm, &hr,
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index 22dbd91811a4..dd8cadf1e686 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -30,6 +30,7 @@ Common Linux HPI ioctl and module probe/remove functions
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33#include <linux/pci.h>
33#include <linux/stringify.h> 34#include <linux/stringify.h>
34 35
35#ifdef MODULE_FIRMWARE 36#ifdef MODULE_FIRMWARE
@@ -45,7 +46,7 @@ MODULE_FIRMWARE("asihpi/dsp8900.bin");
45static int prealloc_stream_buf; 46static int prealloc_stream_buf;
46module_param(prealloc_stream_buf, int, S_IRUGO); 47module_param(prealloc_stream_buf, int, S_IRUGO);
47MODULE_PARM_DESC(prealloc_stream_buf, 48MODULE_PARM_DESC(prealloc_stream_buf,
48 "preallocate size for per-adapter stream buffer"); 49 "Preallocate size for per-adapter stream buffer");
49 50
50/* Allow the debug level to be changed after module load. 51/* Allow the debug level to be changed after module load.
51 E.g. echo 2 > /sys/module/asihpi/parameters/hpiDebugLevel 52 E.g. echo 2 > /sys/module/asihpi/parameters/hpiDebugLevel
@@ -121,8 +122,8 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
121 phpi_ioctl_data = (struct hpi_ioctl_linux __user *)arg; 122 phpi_ioctl_data = (struct hpi_ioctl_linux __user *)arg;
122 123
123 /* Read the message and response pointers from user space. */ 124 /* Read the message and response pointers from user space. */
124 if (get_user(puhm, &phpi_ioctl_data->phm) || 125 if (get_user(puhm, &phpi_ioctl_data->phm)
125 get_user(puhr, &phpi_ioctl_data->phr)) { 126 || get_user(puhr, &phpi_ioctl_data->phr)) {
126 err = -EFAULT; 127 err = -EFAULT;
127 goto out; 128 goto out;
128 } 129 }
@@ -135,7 +136,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
135 if (hm->h.size > sizeof(*hm)) 136 if (hm->h.size > sizeof(*hm))
136 hm->h.size = sizeof(*hm); 137 hm->h.size = sizeof(*hm);
137 138
138 /*printk(KERN_INFO "message size %d\n", hm->h.wSize); */ 139 /* printk(KERN_INFO "message size %d\n", hm->h.wSize); */
139 140
140 uncopied_bytes = copy_from_user(hm, puhm, hm->h.size); 141 uncopied_bytes = copy_from_user(hm, puhm, hm->h.size);
141 if (uncopied_bytes) { 142 if (uncopied_bytes) {
@@ -156,7 +157,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
156 } 157 }
157 158
158 pa = &adapters[hm->h.adapter_index]; 159 pa = &adapters[hm->h.adapter_index];
159 hr->h.size = 0; 160 hr->h.size = res_max_size;
160 if (hm->h.object == HPI_OBJ_SUBSYSTEM) { 161 if (hm->h.object == HPI_OBJ_SUBSYSTEM) {
161 switch (hm->h.function) { 162 switch (hm->h.function) {
162 case HPI_SUBSYS_CREATE_ADAPTER: 163 case HPI_SUBSYS_CREATE_ADAPTER:
@@ -216,7 +217,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
216 */ 217 */
217 if (pa->buffer_size < size) { 218 if (pa->buffer_size < size) {
218 HPI_DEBUG_LOG(DEBUG, 219 HPI_DEBUG_LOG(DEBUG,
219 "realloc adapter %d stream " 220 "Realloc adapter %d stream "
220 "buffer from %zd to %d\n", 221 "buffer from %zd to %d\n",
221 hm->h.adapter_index, 222 hm->h.adapter_index,
222 pa->buffer_size, size); 223 pa->buffer_size, size);
@@ -259,7 +260,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
259 copy_from_user(pa->p_buffer, ptr, size); 260 copy_from_user(pa->p_buffer, ptr, size);
260 if (uncopied_bytes) 261 if (uncopied_bytes)
261 HPI_DEBUG_LOG(WARNING, 262 HPI_DEBUG_LOG(WARNING,
262 "missed %d of %d " 263 "Missed %d of %d "
263 "bytes from user\n", uncopied_bytes, 264 "bytes from user\n", uncopied_bytes,
264 size); 265 size);
265 } 266 }
@@ -271,7 +272,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
271 copy_to_user(ptr, pa->p_buffer, size); 272 copy_to_user(ptr, pa->p_buffer, size);
272 if (uncopied_bytes) 273 if (uncopied_bytes)
273 HPI_DEBUG_LOG(WARNING, 274 HPI_DEBUG_LOG(WARNING,
274 "missed %d of %d " "bytes to user\n", 275 "Missed %d of %d " "bytes to user\n",
275 uncopied_bytes, size); 276 uncopied_bytes, size);
276 } 277 }
277 278
@@ -290,9 +291,9 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
290 if (hr->h.size > res_max_size) { 291 if (hr->h.size > res_max_size) {
291 HPI_DEBUG_LOG(ERROR, "response too big %d %d\n", hr->h.size, 292 HPI_DEBUG_LOG(ERROR, "response too big %d %d\n", hr->h.size,
292 res_max_size); 293 res_max_size);
293 /*HPI_DEBUG_MESSAGE(ERROR, hm); */ 294 hr->h.error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
294 err = -EFAULT; 295 hr->h.specific_error = hr->h.size;
295 goto out; 296 hr->h.size = sizeof(hr->h);
296 } 297 }
297 298
298 uncopied_bytes = copy_to_user(puhr, hr, hr->h.size); 299 uncopied_bytes = copy_to_user(puhr, hr, hr->h.size);
@@ -320,18 +321,26 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
320 321
321 memset(&adapter, 0, sizeof(adapter)); 322 memset(&adapter, 0, sizeof(adapter));
322 323
323 printk(KERN_DEBUG "probe PCI device (%04x:%04x,%04x:%04x,%04x)\n", 324 dev_printk(KERN_DEBUG, &pci_dev->dev,
324 pci_dev->vendor, pci_dev->device, pci_dev->subsystem_vendor, 325 "probe %04x:%04x,%04x:%04x,%04x\n", pci_dev->vendor,
326 pci_dev->device, pci_dev->subsystem_vendor,
325 pci_dev->subsystem_device, pci_dev->devfn); 327 pci_dev->subsystem_device, pci_dev->devfn);
326 328
329 if (pci_enable_device(pci_dev) < 0) {
330 dev_printk(KERN_ERR, &pci_dev->dev,
331 "pci_enable_device failed, disabling device\n");
332 return -EIO;
333 }
334
335 pci_set_master(pci_dev); /* also sets latency timer if < 16 */
336
327 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 337 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
328 HPI_SUBSYS_CREATE_ADAPTER); 338 HPI_SUBSYS_CREATE_ADAPTER);
329 hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CREATE_ADAPTER, 339 hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CREATE_ADAPTER,
330 HPI_ERROR_PROCESSING_MESSAGE); 340 HPI_ERROR_PROCESSING_MESSAGE);
331 341
332 hm.adapter_index = -1; /* an invalid index */ 342 hm.adapter_index = HPI_ADAPTER_INDEX_INVALID;
333 343
334 /* fill in HPI_PCI information from kernel provided information */
335 adapter.pci = pci_dev; 344 adapter.pci = pci_dev;
336 345
337 nm = HPI_MAX_ADAPTER_MEM_SPACES; 346 nm = HPI_MAX_ADAPTER_MEM_SPACES;
@@ -359,19 +368,7 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
359 pci.ap_mem_base[idx] = adapter.ap_remapped_mem_base[idx]; 368 pci.ap_mem_base[idx] = adapter.ap_remapped_mem_base[idx];
360 } 369 }
361 370
362 /* could replace Pci with direct pointer to pci_dev for linux 371 pci.pci_dev = pci_dev;
363 Instead wrap accessor functions for IDs etc.
364 Would it work for windows?
365 */
366 pci.bus_number = pci_dev->bus->number;
367 pci.vendor_id = (u16)pci_dev->vendor;
368 pci.device_id = (u16)pci_dev->device;
369 pci.subsys_vendor_id = (u16)(pci_dev->subsystem_vendor & 0xffff);
370 pci.subsys_device_id = (u16)(pci_dev->subsystem_device & 0xffff);
371 pci.device_number = pci_dev->devfn;
372 pci.interrupt = pci_dev->irq;
373 pci.p_os_data = pci_dev;
374
375 hm.u.s.resource.bus_type = HPI_BUS_PCI; 372 hm.u.s.resource.bus_type = HPI_BUS_PCI;
376 hm.u.s.resource.r.pci = &pci; 373 hm.u.s.resource.r.pci = &pci;
377 374
@@ -407,8 +404,9 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
407 mutex_init(&adapters[adapter.index].mutex); 404 mutex_init(&adapters[adapter.index].mutex);
408 pci_set_drvdata(pci_dev, &adapters[adapter.index]); 405 pci_set_drvdata(pci_dev, &adapters[adapter.index]);
409 406
410 printk(KERN_INFO "probe found adapter ASI%04X HPI index #%d.\n", 407 dev_printk(KERN_INFO, &pci_dev->dev,
411 adapter.type, adapter.index); 408 "probe succeeded for ASI%04X HPI index %d\n", adapter.type,
409 adapter.index);
412 410
413 return 0; 411 return 0;
414 412
@@ -439,7 +437,8 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev)
439 437
440 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 438 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
441 HPI_SUBSYS_DELETE_ADAPTER); 439 HPI_SUBSYS_DELETE_ADAPTER);
442 hm.adapter_index = pa->index; 440 hm.obj_index = pa->index;
441 hm.adapter_index = HPI_ADAPTER_INDEX_INVALID;
443 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); 442 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL);
444 443
445 /* unmap PCI memory space, mapped during device init. */ 444 /* unmap PCI memory space, mapped during device init. */
@@ -456,14 +455,12 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev)
456 } 455 }
457 456
458 pci_set_drvdata(pci_dev, NULL); 457 pci_set_drvdata(pci_dev, NULL);
459 /* 458 if (1)
460 printk(KERN_INFO "PCI device (%04x:%04x,%04x:%04x,%04x)," 459 dev_printk(KERN_INFO, &pci_dev->dev,
461 " HPI index # %d, removed.\n", 460 "remove %04x:%04x,%04x:%04x,%04x," " HPI index %d.\n",
462 pci_dev->vendor, pci_dev->device, 461 pci_dev->vendor, pci_dev->device,
463 pci_dev->subsystem_vendor, 462 pci_dev->subsystem_vendor, pci_dev->subsystem_device,
464 pci_dev->subsystem_device, pci_dev->devfn, 463 pci_dev->devfn, pa->index);
465 pa->index);
466 */
467} 464}
468 465
469void __init asihpi_init(void) 466void __init asihpi_init(void)
diff --git a/sound/pci/asihpi/hpios.h b/sound/pci/asihpi/hpios.h
index 370f39b43f85..90879b15d3c6 100644
--- a/sound/pci/asihpi/hpios.h
+++ b/sound/pci/asihpi/hpios.h
@@ -135,7 +135,7 @@ static inline void cond_unlock(struct hpios_spinlock *l)
135 135
136#define hpios_msgxlock_init(obj) spin_lock_init(&(obj)->lock) 136#define hpios_msgxlock_init(obj) spin_lock_init(&(obj)->lock)
137#define hpios_msgxlock_lock(obj) cond_lock(obj) 137#define hpios_msgxlock_lock(obj) cond_lock(obj)
138#define hpios_msgxlock_un_lock(obj) cond_unlock(obj) 138#define hpios_msgxlock_unlock(obj) cond_unlock(obj)
139 139
140#define hpios_dsplock_init(obj) spin_lock_init(&(obj)->dsp_lock.lock) 140#define hpios_dsplock_init(obj) spin_lock_init(&(obj)->dsp_lock.lock)
141#define hpios_dsplock_lock(obj) cond_lock(&(obj)->dsp_lock) 141#define hpios_dsplock_lock(obj) cond_lock(&(obj)->dsp_lock)
@@ -148,7 +148,7 @@ static inline void cond_unlock(struct hpios_spinlock *l)
148#define HPI_ALIST_LOCKING 148#define HPI_ALIST_LOCKING
149#define hpios_alistlock_init(obj) spin_lock_init(&((obj)->list_lock.lock)) 149#define hpios_alistlock_init(obj) spin_lock_init(&((obj)->list_lock.lock))
150#define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock)) 150#define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock))
151#define hpios_alistlock_un_lock(obj) spin_unlock(&((obj)->list_lock.lock)) 151#define hpios_alistlock_unlock(obj) spin_unlock(&((obj)->list_lock.lock))
152 152
153struct hpi_adapter { 153struct hpi_adapter {
154 /* mutex prevents contention for one card 154 /* mutex prevents contention for one card