1 // SPDX-License-Identifier: GPL-2.0-only
2 /******************************************************************************
4 AudioScience HPI driver
5 Copyright (C) 1997-2014 AudioScience Inc. <support@audioscience.com>
8 Extended Message Function With Response Caching
10 (C) Copyright AudioScience Inc. 2002
11 *****************************************************************************/
12 #define SOURCEFILE_NAME "hpimsgx.c"
13 #include "hpi_internal.h"
14 #include "hpi_version.h"
15 #include "hpimsginit.h"
20 static const struct pci_device_id asihpi_pci_tbl[] = {
24 static struct hpios_spinlock msgx_lock;
26 static hpi_handler_func *hpi_entry_points[HPI_MAX_ADAPTERS];
27 static int logging_enabled = 1;
29 static hpi_handler_func *hpi_lookup_entry_point_function(const struct hpi_pci
35 for (i = 0; asihpi_pci_tbl[i].vendor != 0; i++) {
36 if (asihpi_pci_tbl[i].vendor != PCI_ANY_ID
37 && asihpi_pci_tbl[i].vendor !=
38 pci_info->pci_dev->vendor)
40 if (asihpi_pci_tbl[i].device != PCI_ANY_ID
41 && asihpi_pci_tbl[i].device !=
42 pci_info->pci_dev->device)
44 if (asihpi_pci_tbl[i].subvendor != PCI_ANY_ID
45 && asihpi_pci_tbl[i].subvendor !=
46 pci_info->pci_dev->subsystem_vendor)
48 if (asihpi_pci_tbl[i].subdevice != PCI_ANY_ID
49 && asihpi_pci_tbl[i].subdevice !=
50 pci_info->pci_dev->subsystem_device)
53 /* HPI_DEBUG_LOG(DEBUG, " %x,%lx\n", i,
54 asihpi_pci_tbl[i].driver_data); */
55 return (hpi_handler_func *) asihpi_pci_tbl[i].driver_data;
61 static inline void hw_entry_point(struct hpi_message *phm,
62 struct hpi_response *phr)
64 if ((phm->adapter_index < HPI_MAX_ADAPTERS)
65 && hpi_entry_points[phm->adapter_index])
66 hpi_entry_points[phm->adapter_index] (phm, phr);
68 hpi_init_response(phr, phm->object, phm->function,
69 HPI_ERROR_PROCESSING_MESSAGE);
72 static void adapter_open(struct hpi_message *phm, struct hpi_response *phr);
73 static void adapter_close(struct hpi_message *phm, struct hpi_response *phr);
75 static void mixer_open(struct hpi_message *phm, struct hpi_response *phr);
76 static void mixer_close(struct hpi_message *phm, struct hpi_response *phr);
78 static void outstream_open(struct hpi_message *phm, struct hpi_response *phr,
80 static void outstream_close(struct hpi_message *phm, struct hpi_response *phr,
82 static void instream_open(struct hpi_message *phm, struct hpi_response *phr,
84 static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
87 static void HPIMSGX__reset(u16 adapter_index);
89 static u16 HPIMSGX__init(struct hpi_message *phm, struct hpi_response *phr);
90 static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner);
92 #ifndef DISABLE_PRAGMA_PACK1
96 struct hpi_adapter_response {
97 struct hpi_response_header h;
98 struct hpi_adapter_res a;
101 struct hpi_mixer_response {
102 struct hpi_response_header h;
103 struct hpi_mixer_res m;
106 struct hpi_stream_response {
107 struct hpi_response_header h;
108 struct hpi_stream_res d;
111 struct adapter_info {
117 struct asi_open_state {
122 #ifndef DISABLE_PRAGMA_PACK1
127 static struct hpi_adapter_response rESP_HPI_ADAPTER_OPEN[HPI_MAX_ADAPTERS];
129 static struct hpi_stream_response
130 rESP_HPI_OSTREAM_OPEN[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS];
132 static struct hpi_stream_response
133 rESP_HPI_ISTREAM_OPEN[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS];
135 static struct hpi_mixer_response rESP_HPI_MIXER_OPEN[HPI_MAX_ADAPTERS];
137 static struct adapter_info aDAPTER_INFO[HPI_MAX_ADAPTERS];
139 /* use these to keep track of opens from user mode apps/DLLs */
140 static struct asi_open_state
141 outstream_user_open[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS];
143 static struct asi_open_state
144 instream_user_open[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS];
146 static void subsys_message(struct hpi_message *phm, struct hpi_response *phr,
149 if (phm->adapter_index != HPI_ADAPTER_INDEX_INVALID)
150 HPI_DEBUG_LOG(WARNING,
151 "suspicious adapter index %d in subsys message 0x%x.\n",
152 phm->adapter_index, phm->function);
154 switch (phm->function) {
155 case HPI_SUBSYS_GET_VERSION:
156 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
157 HPI_SUBSYS_GET_VERSION, 0);
158 phr->u.s.version = HPI_VER >> 8; /* return major.minor */
159 phr->u.s.data = HPI_VER; /* return major.minor.release */
161 case HPI_SUBSYS_OPEN:
162 /*do not propagate the message down the chain */
163 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_OPEN, 0);
165 case HPI_SUBSYS_CLOSE:
166 /*do not propagate the message down the chain */
167 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CLOSE,
169 HPIMSGX__cleanup(HPIMSGX_ALLADAPTERS, h_owner);
171 case HPI_SUBSYS_DRIVER_LOAD:
172 /* Initialize this module's internal state */
173 hpios_msgxlock_init(&msgx_lock);
174 memset(&hpi_entry_points, 0, sizeof(hpi_entry_points));
175 /* Init subsys_findadapters response to no-adapters */
176 HPIMSGX__reset(HPIMSGX_ALLADAPTERS);
177 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
178 HPI_SUBSYS_DRIVER_LOAD, 0);
179 /* individual HPIs dont implement driver load */
180 HPI_COMMON(phm, phr);
182 case HPI_SUBSYS_DRIVER_UNLOAD:
183 HPI_COMMON(phm, phr);
184 HPIMSGX__cleanup(HPIMSGX_ALLADAPTERS, h_owner);
185 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
186 HPI_SUBSYS_DRIVER_UNLOAD, 0);
189 case HPI_SUBSYS_GET_NUM_ADAPTERS:
190 case HPI_SUBSYS_GET_ADAPTER:
191 HPI_COMMON(phm, phr);
194 case HPI_SUBSYS_CREATE_ADAPTER:
195 HPIMSGX__init(phm, phr);
199 /* Must explicitly handle every subsys message in this switch */
200 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, phm->function,
201 HPI_ERROR_INVALID_FUNC);
206 static void adapter_message(struct hpi_message *phm, struct hpi_response *phr,
209 switch (phm->function) {
210 case HPI_ADAPTER_OPEN:
211 adapter_open(phm, phr);
213 case HPI_ADAPTER_CLOSE:
214 adapter_close(phm, phr);
216 case HPI_ADAPTER_DELETE:
217 HPIMSGX__cleanup(phm->adapter_index, h_owner);
219 struct hpi_message hm;
220 struct hpi_response hr;
221 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
223 hm.adapter_index = phm->adapter_index;
224 hw_entry_point(&hm, &hr);
226 hw_entry_point(phm, phr);
230 hw_entry_point(phm, phr);
235 static void mixer_message(struct hpi_message *phm, struct hpi_response *phr)
237 switch (phm->function) {
239 mixer_open(phm, phr);
241 case HPI_MIXER_CLOSE:
242 mixer_close(phm, phr);
245 hw_entry_point(phm, phr);
250 static void outstream_message(struct hpi_message *phm,
251 struct hpi_response *phr, void *h_owner)
253 if (phm->obj_index >= aDAPTER_INFO[phm->adapter_index].num_outstreams) {
254 hpi_init_response(phr, HPI_OBJ_OSTREAM, phm->function,
255 HPI_ERROR_INVALID_OBJ_INDEX);
259 switch (phm->function) {
260 case HPI_OSTREAM_OPEN:
261 outstream_open(phm, phr, h_owner);
263 case HPI_OSTREAM_CLOSE:
264 outstream_close(phm, phr, h_owner);
267 hw_entry_point(phm, phr);
272 static void instream_message(struct hpi_message *phm,
273 struct hpi_response *phr, void *h_owner)
275 if (phm->obj_index >= aDAPTER_INFO[phm->adapter_index].num_instreams) {
276 hpi_init_response(phr, HPI_OBJ_ISTREAM, phm->function,
277 HPI_ERROR_INVALID_OBJ_INDEX);
281 switch (phm->function) {
282 case HPI_ISTREAM_OPEN:
283 instream_open(phm, phr, h_owner);
285 case HPI_ISTREAM_CLOSE:
286 instream_close(phm, phr, h_owner);
289 hw_entry_point(phm, phr);
294 /* NOTE: HPI_Message() must be defined in the driver as a wrapper for
295 * HPI_MessageEx so that functions in hpifunc.c compile.
297 void hpi_send_recv_ex(struct hpi_message *phm, struct hpi_response *phr,
302 HPI_DEBUG_MESSAGE(DEBUG, phm);
304 if (phm->type != HPI_TYPE_REQUEST) {
305 hpi_init_response(phr, phm->object, phm->function,
306 HPI_ERROR_INVALID_TYPE);
310 if (phm->adapter_index >= HPI_MAX_ADAPTERS
311 && phm->adapter_index != HPIMSGX_ALLADAPTERS) {
312 hpi_init_response(phr, phm->object, phm->function,
313 HPI_ERROR_BAD_ADAPTER_NUMBER);
317 switch (phm->object) {
318 case HPI_OBJ_SUBSYSTEM:
319 subsys_message(phm, phr, h_owner);
322 case HPI_OBJ_ADAPTER:
323 adapter_message(phm, phr, h_owner);
327 mixer_message(phm, phr);
330 case HPI_OBJ_OSTREAM:
331 outstream_message(phm, phr, h_owner);
334 case HPI_OBJ_ISTREAM:
335 instream_message(phm, phr, h_owner);
339 hw_entry_point(phm, phr);
344 HPI_DEBUG_RESPONSE(phr);
346 if (phr->error >= HPI_ERROR_DSP_COMMUNICATION) {
347 hpi_debug_level_set(HPI_DEBUG_LEVEL_ERROR);
352 static void adapter_open(struct hpi_message *phm, struct hpi_response *phr)
354 HPI_DEBUG_LOG(VERBOSE, "adapter_open\n");
355 memcpy(phr, &rESP_HPI_ADAPTER_OPEN[phm->adapter_index],
356 sizeof(rESP_HPI_ADAPTER_OPEN[0]));
359 static void adapter_close(struct hpi_message *phm, struct hpi_response *phr)
361 HPI_DEBUG_LOG(VERBOSE, "adapter_close\n");
362 hpi_init_response(phr, HPI_OBJ_ADAPTER, HPI_ADAPTER_CLOSE, 0);
365 static void mixer_open(struct hpi_message *phm, struct hpi_response *phr)
367 memcpy(phr, &rESP_HPI_MIXER_OPEN[phm->adapter_index],
368 sizeof(rESP_HPI_MIXER_OPEN[0]));
371 static void mixer_close(struct hpi_message *phm, struct hpi_response *phr)
373 hpi_init_response(phr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE, 0);
376 static void instream_open(struct hpi_message *phm, struct hpi_response *phr,
380 struct hpi_message hm;
381 struct hpi_response hr;
383 hpi_init_response(phr, HPI_OBJ_ISTREAM, HPI_ISTREAM_OPEN, 0);
385 hpios_msgxlock_lock(&msgx_lock);
387 if (instream_user_open[phm->adapter_index][phm->obj_index].open_flag)
388 phr->error = HPI_ERROR_OBJ_ALREADY_OPEN;
389 else if (rESP_HPI_ISTREAM_OPEN[phm->adapter_index]
390 [phm->obj_index].h.error)
392 &rESP_HPI_ISTREAM_OPEN[phm->adapter_index][phm->
394 sizeof(rESP_HPI_ISTREAM_OPEN[0][0]));
396 instream_user_open[phm->adapter_index][phm->
397 obj_index].open_flag = 1;
398 hpios_msgxlock_unlock(&msgx_lock);
401 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
403 hm.adapter_index = phm->adapter_index;
404 hm.obj_index = phm->obj_index;
405 hw_entry_point(&hm, &hr);
407 hpios_msgxlock_lock(&msgx_lock);
409 instream_user_open[phm->adapter_index][phm->
410 obj_index].open_flag = 0;
411 phr->error = hr.error;
413 instream_user_open[phm->adapter_index][phm->
414 obj_index].open_flag = 1;
415 instream_user_open[phm->adapter_index][phm->
416 obj_index].h_owner = h_owner;
418 &rESP_HPI_ISTREAM_OPEN[phm->adapter_index]
420 sizeof(rESP_HPI_ISTREAM_OPEN[0][0]));
423 hpios_msgxlock_unlock(&msgx_lock);
426 static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
430 struct hpi_message hm;
431 struct hpi_response hr;
433 hpi_init_response(phr, HPI_OBJ_ISTREAM, HPI_ISTREAM_CLOSE, 0);
435 hpios_msgxlock_lock(&msgx_lock);
437 instream_user_open[phm->adapter_index][phm->
438 obj_index].h_owner) {
439 /* HPI_DEBUG_LOG(INFO,"closing adapter %d "
440 "instream %d owned by %p\n",
441 phm->wAdapterIndex, phm->wObjIndex, hOwner); */
442 instream_user_open[phm->adapter_index][phm->
443 obj_index].h_owner = NULL;
444 hpios_msgxlock_unlock(&msgx_lock);
446 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
448 hm.adapter_index = phm->adapter_index;
449 hm.obj_index = phm->obj_index;
450 hw_entry_point(&hm, &hr);
451 hpios_msgxlock_lock(&msgx_lock);
453 instream_user_open[phm->adapter_index][phm->
454 obj_index].h_owner = h_owner;
455 phr->error = hr.error;
457 instream_user_open[phm->adapter_index][phm->
458 obj_index].open_flag = 0;
459 instream_user_open[phm->adapter_index][phm->
460 obj_index].h_owner = NULL;
463 HPI_DEBUG_LOG(WARNING,
464 "%p trying to close %d instream %d owned by %p\n",
465 h_owner, phm->adapter_index, phm->obj_index,
466 instream_user_open[phm->adapter_index][phm->
468 phr->error = HPI_ERROR_OBJ_NOT_OPEN;
470 hpios_msgxlock_unlock(&msgx_lock);
473 static void outstream_open(struct hpi_message *phm, struct hpi_response *phr,
477 struct hpi_message hm;
478 struct hpi_response hr;
480 hpi_init_response(phr, HPI_OBJ_OSTREAM, HPI_OSTREAM_OPEN, 0);
482 hpios_msgxlock_lock(&msgx_lock);
484 if (outstream_user_open[phm->adapter_index][phm->obj_index].open_flag)
485 phr->error = HPI_ERROR_OBJ_ALREADY_OPEN;
486 else if (rESP_HPI_OSTREAM_OPEN[phm->adapter_index]
487 [phm->obj_index].h.error)
489 &rESP_HPI_OSTREAM_OPEN[phm->adapter_index][phm->
491 sizeof(rESP_HPI_OSTREAM_OPEN[0][0]));
493 outstream_user_open[phm->adapter_index][phm->
494 obj_index].open_flag = 1;
495 hpios_msgxlock_unlock(&msgx_lock);
498 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
500 hm.adapter_index = phm->adapter_index;
501 hm.obj_index = phm->obj_index;
502 hw_entry_point(&hm, &hr);
504 hpios_msgxlock_lock(&msgx_lock);
506 outstream_user_open[phm->adapter_index][phm->
507 obj_index].open_flag = 0;
508 phr->error = hr.error;
510 outstream_user_open[phm->adapter_index][phm->
511 obj_index].open_flag = 1;
512 outstream_user_open[phm->adapter_index][phm->
513 obj_index].h_owner = h_owner;
515 &rESP_HPI_OSTREAM_OPEN[phm->adapter_index]
517 sizeof(rESP_HPI_OSTREAM_OPEN[0][0]));
520 hpios_msgxlock_unlock(&msgx_lock);
523 static void outstream_close(struct hpi_message *phm, struct hpi_response *phr,
527 struct hpi_message hm;
528 struct hpi_response hr;
530 hpi_init_response(phr, HPI_OBJ_OSTREAM, HPI_OSTREAM_CLOSE, 0);
532 hpios_msgxlock_lock(&msgx_lock);
535 outstream_user_open[phm->adapter_index][phm->
536 obj_index].h_owner) {
537 /* HPI_DEBUG_LOG(INFO,"closing adapter %d "
538 "outstream %d owned by %p\n",
539 phm->wAdapterIndex, phm->wObjIndex, hOwner); */
540 outstream_user_open[phm->adapter_index][phm->
541 obj_index].h_owner = NULL;
542 hpios_msgxlock_unlock(&msgx_lock);
544 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
546 hm.adapter_index = phm->adapter_index;
547 hm.obj_index = phm->obj_index;
548 hw_entry_point(&hm, &hr);
549 hpios_msgxlock_lock(&msgx_lock);
551 outstream_user_open[phm->adapter_index][phm->
552 obj_index].h_owner = h_owner;
553 phr->error = hr.error;
555 outstream_user_open[phm->adapter_index][phm->
556 obj_index].open_flag = 0;
557 outstream_user_open[phm->adapter_index][phm->
558 obj_index].h_owner = NULL;
561 HPI_DEBUG_LOG(WARNING,
562 "%p trying to close %d outstream %d owned by %p\n",
563 h_owner, phm->adapter_index, phm->obj_index,
564 outstream_user_open[phm->adapter_index][phm->
566 phr->error = HPI_ERROR_OBJ_NOT_OPEN;
568 hpios_msgxlock_unlock(&msgx_lock);
571 static u16 adapter_prepare(u16 adapter)
573 struct hpi_message hm;
574 struct hpi_response hr;
576 /* Open the adapter and streams */
579 /* call to HPI_ADAPTER_OPEN */
580 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
582 hm.adapter_index = adapter;
583 hw_entry_point(&hm, &hr);
584 memcpy(&rESP_HPI_ADAPTER_OPEN[adapter], &hr,
585 sizeof(rESP_HPI_ADAPTER_OPEN[0]));
589 /* call to HPI_ADAPTER_GET_INFO */
590 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
591 HPI_ADAPTER_GET_INFO);
592 hm.adapter_index = adapter;
593 hw_entry_point(&hm, &hr);
597 aDAPTER_INFO[adapter].num_outstreams = hr.u.ax.info.num_outstreams;
598 aDAPTER_INFO[adapter].num_instreams = hr.u.ax.info.num_instreams;
599 aDAPTER_INFO[adapter].type = hr.u.ax.info.adapter_type;
601 /* call to HPI_OSTREAM_OPEN */
602 for (i = 0; i < aDAPTER_INFO[adapter].num_outstreams; i++) {
603 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
605 hm.adapter_index = adapter;
607 hw_entry_point(&hm, &hr);
608 memcpy(&rESP_HPI_OSTREAM_OPEN[adapter][i], &hr,
609 sizeof(rESP_HPI_OSTREAM_OPEN[0][0]));
610 outstream_user_open[adapter][i].open_flag = 0;
611 outstream_user_open[adapter][i].h_owner = NULL;
614 /* call to HPI_ISTREAM_OPEN */
615 for (i = 0; i < aDAPTER_INFO[adapter].num_instreams; i++) {
616 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
618 hm.adapter_index = adapter;
620 hw_entry_point(&hm, &hr);
621 memcpy(&rESP_HPI_ISTREAM_OPEN[adapter][i], &hr,
622 sizeof(rESP_HPI_ISTREAM_OPEN[0][0]));
623 instream_user_open[adapter][i].open_flag = 0;
624 instream_user_open[adapter][i].h_owner = NULL;
627 /* call to HPI_MIXER_OPEN */
628 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN);
629 hm.adapter_index = adapter;
630 hw_entry_point(&hm, &hr);
631 memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr,
632 sizeof(rESP_HPI_MIXER_OPEN[0]));
637 static void HPIMSGX__reset(u16 adapter_index)
641 struct hpi_response hr;
643 if (adapter_index == HPIMSGX_ALLADAPTERS) {
644 for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) {
646 hpi_init_response(&hr, HPI_OBJ_ADAPTER,
647 HPI_ADAPTER_OPEN, HPI_ERROR_BAD_ADAPTER);
648 memcpy(&rESP_HPI_ADAPTER_OPEN[adapter], &hr,
649 sizeof(rESP_HPI_ADAPTER_OPEN[adapter]));
651 hpi_init_response(&hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN,
652 HPI_ERROR_INVALID_OBJ);
653 memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr,
654 sizeof(rESP_HPI_MIXER_OPEN[adapter]));
656 for (i = 0; i < HPI_MAX_STREAMS; i++) {
657 hpi_init_response(&hr, HPI_OBJ_OSTREAM,
659 HPI_ERROR_INVALID_OBJ);
660 memcpy(&rESP_HPI_OSTREAM_OPEN[adapter][i],
662 sizeof(rESP_HPI_OSTREAM_OPEN[adapter]
664 hpi_init_response(&hr, HPI_OBJ_ISTREAM,
666 HPI_ERROR_INVALID_OBJ);
667 memcpy(&rESP_HPI_ISTREAM_OPEN[adapter][i],
669 sizeof(rESP_HPI_ISTREAM_OPEN[adapter]
673 } else if (adapter_index < HPI_MAX_ADAPTERS) {
674 rESP_HPI_ADAPTER_OPEN[adapter_index].h.error =
675 HPI_ERROR_BAD_ADAPTER;
676 rESP_HPI_MIXER_OPEN[adapter_index].h.error =
677 HPI_ERROR_INVALID_OBJ;
678 for (i = 0; i < HPI_MAX_STREAMS; i++) {
679 rESP_HPI_OSTREAM_OPEN[adapter_index][i].h.error =
680 HPI_ERROR_INVALID_OBJ;
681 rESP_HPI_ISTREAM_OPEN[adapter_index][i].h.error =
682 HPI_ERROR_INVALID_OBJ;
687 static u16 HPIMSGX__init(struct hpi_message *phm,
688 /* HPI_SUBSYS_CREATE_ADAPTER structure with */
689 /* resource list or NULL=find all */
690 struct hpi_response *phr
691 /* response from HPI_ADAPTER_GET_INFO */
694 hpi_handler_func *entry_point_func;
695 struct hpi_response hr;
697 /* Init response here so we can pass in previous adapter list */
698 hpi_init_response(&hr, phm->object, phm->function,
699 HPI_ERROR_INVALID_OBJ);
702 hpi_lookup_entry_point_function(phm->u.s.resource.r.pci);
704 if (entry_point_func) {
705 HPI_DEBUG_MESSAGE(DEBUG, phm);
706 entry_point_func(phm, &hr);
708 phr->error = HPI_ERROR_PROCESSING_MESSAGE;
712 /* the adapter was created successfully
713 save the mapping for future use */
714 hpi_entry_points[hr.u.s.adapter_index] = entry_point_func;
715 /* prepare adapter (pre-open streams etc.) */
717 "HPI_SUBSYS_CREATE_ADAPTER successful,"
718 " preparing adapter\n");
719 adapter_prepare(hr.u.s.adapter_index);
721 memcpy(phr, &hr, hr.size);
725 static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner)
727 int i, adapter, adapter_limit;
732 if (adapter_index == HPIMSGX_ALLADAPTERS) {
734 adapter_limit = HPI_MAX_ADAPTERS;
736 adapter = adapter_index;
737 adapter_limit = adapter + 1;
740 for (; adapter < adapter_limit; adapter++) {
741 /* printk(KERN_INFO "Cleanup adapter #%d\n",wAdapter); */
742 for (i = 0; i < HPI_MAX_STREAMS; i++) {
744 outstream_user_open[adapter][i].h_owner) {
745 struct hpi_message hm;
746 struct hpi_response hr;
749 "Close adapter %d ostream %d\n",
752 hpi_init_message_response(&hm, &hr,
753 HPI_OBJ_OSTREAM, HPI_OSTREAM_RESET);
754 hm.adapter_index = (u16)adapter;
755 hm.obj_index = (u16)i;
756 hw_entry_point(&hm, &hr);
758 hm.function = HPI_OSTREAM_HOSTBUFFER_FREE;
759 hw_entry_point(&hm, &hr);
761 hm.function = HPI_OSTREAM_GROUP_RESET;
762 hw_entry_point(&hm, &hr);
764 outstream_user_open[adapter][i].open_flag = 0;
765 outstream_user_open[adapter][i].h_owner =
768 if (h_owner == instream_user_open[adapter][i].h_owner) {
769 struct hpi_message hm;
770 struct hpi_response hr;
773 "Close adapter %d istream %d\n",
776 hpi_init_message_response(&hm, &hr,
777 HPI_OBJ_ISTREAM, HPI_ISTREAM_RESET);
778 hm.adapter_index = (u16)adapter;
779 hm.obj_index = (u16)i;
780 hw_entry_point(&hm, &hr);
782 hm.function = HPI_ISTREAM_HOSTBUFFER_FREE;
783 hw_entry_point(&hm, &hr);
785 hm.function = HPI_ISTREAM_GROUP_RESET;
786 hw_entry_point(&hm, &hr);
788 instream_user_open[adapter][i].open_flag = 0;
789 instream_user_open[adapter][i].h_owner = NULL;