^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) AudioScience HPI driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) Copyright (C) 1997-2014 AudioScience Inc. <support@audioscience.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) Extended Message Function With Response Caching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) (C) Copyright AudioScience Inc. 2002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define SOURCEFILE_NAME "hpimsgx.c"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "hpi_internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "hpi_version.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "hpimsginit.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "hpicmn.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "hpimsgx.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "hpidebug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static const struct pci_device_id asihpi_pci_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "hpipcida.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static struct hpios_spinlock msgx_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static hpi_handler_func *hpi_entry_points[HPI_MAX_ADAPTERS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static int logging_enabled = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static hpi_handler_func *hpi_lookup_entry_point_function(const struct hpi_pci
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *pci_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) for (i = 0; asihpi_pci_tbl[i].vendor != 0; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (asihpi_pci_tbl[i].vendor != PCI_ANY_ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) && asihpi_pci_tbl[i].vendor !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) pci_info->pci_dev->vendor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) if (asihpi_pci_tbl[i].device != PCI_ANY_ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) && asihpi_pci_tbl[i].device !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) pci_info->pci_dev->device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) if (asihpi_pci_tbl[i].subvendor != PCI_ANY_ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) && asihpi_pci_tbl[i].subvendor !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) pci_info->pci_dev->subsystem_vendor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) if (asihpi_pci_tbl[i].subdevice != PCI_ANY_ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) && asihpi_pci_tbl[i].subdevice !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) pci_info->pci_dev->subsystem_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* HPI_DEBUG_LOG(DEBUG, " %x,%lx\n", i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) asihpi_pci_tbl[i].driver_data); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) return (hpi_handler_func *) asihpi_pci_tbl[i].driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static inline void hw_entry_point(struct hpi_message *phm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct hpi_response *phr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) if ((phm->adapter_index < HPI_MAX_ADAPTERS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) && hpi_entry_points[phm->adapter_index])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) hpi_entry_points[phm->adapter_index] (phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) hpi_init_response(phr, phm->object, phm->function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) HPI_ERROR_PROCESSING_MESSAGE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static void adapter_open(struct hpi_message *phm, struct hpi_response *phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static void adapter_close(struct hpi_message *phm, struct hpi_response *phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) static void mixer_open(struct hpi_message *phm, struct hpi_response *phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static void mixer_close(struct hpi_message *phm, struct hpi_response *phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) static void outstream_open(struct hpi_message *phm, struct hpi_response *phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) void *h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) static void outstream_close(struct hpi_message *phm, struct hpi_response *phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) void *h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static void instream_open(struct hpi_message *phm, struct hpi_response *phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) void *h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) void *h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static void HPIMSGX__reset(u16 adapter_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) static u16 HPIMSGX__init(struct hpi_message *phm, struct hpi_response *phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #ifndef DISABLE_PRAGMA_PACK1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #pragma pack(push, 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct hpi_subsys_response {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct hpi_response_header h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct hpi_subsys_res s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct hpi_adapter_response {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct hpi_response_header h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct hpi_adapter_res a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct hpi_mixer_response {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) struct hpi_response_header h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct hpi_mixer_res m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct hpi_stream_response {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct hpi_response_header h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct hpi_stream_res d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct adapter_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) u16 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) u16 num_instreams;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) u16 num_outstreams;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct asi_open_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int open_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) void *h_owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #ifndef DISABLE_PRAGMA_PACK1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #pragma pack(pop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /* Globals */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static struct hpi_adapter_response rESP_HPI_ADAPTER_OPEN[HPI_MAX_ADAPTERS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static struct hpi_stream_response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) rESP_HPI_OSTREAM_OPEN[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static struct hpi_stream_response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) rESP_HPI_ISTREAM_OPEN[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static struct hpi_mixer_response rESP_HPI_MIXER_OPEN[HPI_MAX_ADAPTERS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static struct adapter_info aDAPTER_INFO[HPI_MAX_ADAPTERS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* use these to keep track of opens from user mode apps/DLLs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static struct asi_open_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) outstream_user_open[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static struct asi_open_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) instream_user_open[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static void subsys_message(struct hpi_message *phm, struct hpi_response *phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) void *h_owner)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if (phm->adapter_index != HPI_ADAPTER_INDEX_INVALID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) HPI_DEBUG_LOG(WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) "suspicious adapter index %d in subsys message 0x%x.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) phm->adapter_index, phm->function);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) switch (phm->function) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) case HPI_SUBSYS_GET_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) HPI_SUBSYS_GET_VERSION, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) phr->u.s.version = HPI_VER >> 8; /* return major.minor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) phr->u.s.data = HPI_VER; /* return major.minor.release */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) case HPI_SUBSYS_OPEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /*do not propagate the message down the chain */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_OPEN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) case HPI_SUBSYS_CLOSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /*do not propagate the message down the chain */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CLOSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) HPIMSGX__cleanup(HPIMSGX_ALLADAPTERS, h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) case HPI_SUBSYS_DRIVER_LOAD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) /* Initialize this module's internal state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) hpios_msgxlock_init(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) memset(&hpi_entry_points, 0, sizeof(hpi_entry_points));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) /* Init subsys_findadapters response to no-adapters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) HPIMSGX__reset(HPIMSGX_ALLADAPTERS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) HPI_SUBSYS_DRIVER_LOAD, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) /* individual HPIs dont implement driver load */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) HPI_COMMON(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) case HPI_SUBSYS_DRIVER_UNLOAD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) HPI_COMMON(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) HPIMSGX__cleanup(HPIMSGX_ALLADAPTERS, h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) HPI_SUBSYS_DRIVER_UNLOAD, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) case HPI_SUBSYS_GET_NUM_ADAPTERS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) case HPI_SUBSYS_GET_ADAPTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) HPI_COMMON(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) case HPI_SUBSYS_CREATE_ADAPTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) HPIMSGX__init(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) /* Must explicitly handle every subsys message in this switch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, phm->function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) HPI_ERROR_INVALID_FUNC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static void adapter_message(struct hpi_message *phm, struct hpi_response *phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) void *h_owner)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) switch (phm->function) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) case HPI_ADAPTER_OPEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) adapter_open(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) case HPI_ADAPTER_CLOSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) adapter_close(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) case HPI_ADAPTER_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) HPIMSGX__cleanup(phm->adapter_index, h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) HPI_ADAPTER_CLOSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) hm.adapter_index = phm->adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) hw_entry_point(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) hw_entry_point(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) static void mixer_message(struct hpi_message *phm, struct hpi_response *phr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) switch (phm->function) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) case HPI_MIXER_OPEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) mixer_open(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) case HPI_MIXER_CLOSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) mixer_close(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) hw_entry_point(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static void outstream_message(struct hpi_message *phm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) struct hpi_response *phr, void *h_owner)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) if (phm->obj_index >= aDAPTER_INFO[phm->adapter_index].num_outstreams) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) hpi_init_response(phr, HPI_OBJ_OSTREAM, phm->function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) HPI_ERROR_INVALID_OBJ_INDEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) switch (phm->function) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) case HPI_OSTREAM_OPEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) outstream_open(phm, phr, h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) case HPI_OSTREAM_CLOSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) outstream_close(phm, phr, h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) hw_entry_point(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) static void instream_message(struct hpi_message *phm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) struct hpi_response *phr, void *h_owner)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if (phm->obj_index >= aDAPTER_INFO[phm->adapter_index].num_instreams) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) hpi_init_response(phr, HPI_OBJ_ISTREAM, phm->function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) HPI_ERROR_INVALID_OBJ_INDEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) switch (phm->function) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) case HPI_ISTREAM_OPEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) instream_open(phm, phr, h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) case HPI_ISTREAM_CLOSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) instream_close(phm, phr, h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) hw_entry_point(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /* NOTE: HPI_Message() must be defined in the driver as a wrapper for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * HPI_MessageEx so that functions in hpifunc.c compile.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) void hpi_send_recv_ex(struct hpi_message *phm, struct hpi_response *phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) void *h_owner)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) if (logging_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) HPI_DEBUG_MESSAGE(DEBUG, phm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) if (phm->type != HPI_TYPE_REQUEST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) hpi_init_response(phr, phm->object, phm->function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) HPI_ERROR_INVALID_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) if (phm->adapter_index >= HPI_MAX_ADAPTERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) && phm->adapter_index != HPIMSGX_ALLADAPTERS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) hpi_init_response(phr, phm->object, phm->function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) HPI_ERROR_BAD_ADAPTER_NUMBER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) switch (phm->object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) case HPI_OBJ_SUBSYSTEM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) subsys_message(phm, phr, h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) case HPI_OBJ_ADAPTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) adapter_message(phm, phr, h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) case HPI_OBJ_MIXER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) mixer_message(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) case HPI_OBJ_OSTREAM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) outstream_message(phm, phr, h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) case HPI_OBJ_ISTREAM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) instream_message(phm, phr, h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) hw_entry_point(phm, phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) if (logging_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) HPI_DEBUG_RESPONSE(phr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) if (phr->error >= HPI_ERROR_DSP_COMMUNICATION) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) hpi_debug_level_set(HPI_DEBUG_LEVEL_ERROR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) logging_enabled = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) static void adapter_open(struct hpi_message *phm, struct hpi_response *phr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) HPI_DEBUG_LOG(VERBOSE, "adapter_open\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) memcpy(phr, &rESP_HPI_ADAPTER_OPEN[phm->adapter_index],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) sizeof(rESP_HPI_ADAPTER_OPEN[0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) static void adapter_close(struct hpi_message *phm, struct hpi_response *phr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) HPI_DEBUG_LOG(VERBOSE, "adapter_close\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) hpi_init_response(phr, HPI_OBJ_ADAPTER, HPI_ADAPTER_CLOSE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) static void mixer_open(struct hpi_message *phm, struct hpi_response *phr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) memcpy(phr, &rESP_HPI_MIXER_OPEN[phm->adapter_index],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) sizeof(rESP_HPI_MIXER_OPEN[0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) static void mixer_close(struct hpi_message *phm, struct hpi_response *phr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) hpi_init_response(phr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) static void instream_open(struct hpi_message *phm, struct hpi_response *phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) void *h_owner)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) hpi_init_response(phr, HPI_OBJ_ISTREAM, HPI_ISTREAM_OPEN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) hpios_msgxlock_lock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) if (instream_user_open[phm->adapter_index][phm->obj_index].open_flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) phr->error = HPI_ERROR_OBJ_ALREADY_OPEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) else if (rESP_HPI_ISTREAM_OPEN[phm->adapter_index]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) [phm->obj_index].h.error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) memcpy(phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) &rESP_HPI_ISTREAM_OPEN[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) obj_index],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) sizeof(rESP_HPI_ISTREAM_OPEN[0][0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) instream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) obj_index].open_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) hpios_msgxlock_unlock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) /* issue a reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) HPI_ISTREAM_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) hm.adapter_index = phm->adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) hm.obj_index = phm->obj_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) hpios_msgxlock_lock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) if (hr.error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) instream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) obj_index].open_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) phr->error = hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) instream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) obj_index].open_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) instream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) obj_index].h_owner = h_owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) memcpy(phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) &rESP_HPI_ISTREAM_OPEN[phm->adapter_index]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) [phm->obj_index],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) sizeof(rESP_HPI_ISTREAM_OPEN[0][0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) hpios_msgxlock_unlock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) void *h_owner)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) hpi_init_response(phr, HPI_OBJ_ISTREAM, HPI_ISTREAM_CLOSE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) hpios_msgxlock_lock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) if (h_owner ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) instream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) obj_index].h_owner) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) /* HPI_DEBUG_LOG(INFO,"closing adapter %d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) "instream %d owned by %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) phm->wAdapterIndex, phm->wObjIndex, hOwner); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) instream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) obj_index].h_owner = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) hpios_msgxlock_unlock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) /* issue a reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) HPI_ISTREAM_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) hm.adapter_index = phm->adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) hm.obj_index = phm->obj_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) hpios_msgxlock_lock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) if (hr.error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) instream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) obj_index].h_owner = h_owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) phr->error = hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) instream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) obj_index].open_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) instream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) obj_index].h_owner = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) HPI_DEBUG_LOG(WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) "%p trying to close %d instream %d owned by %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) h_owner, phm->adapter_index, phm->obj_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) instream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) obj_index].h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) phr->error = HPI_ERROR_OBJ_NOT_OPEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) hpios_msgxlock_unlock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) static void outstream_open(struct hpi_message *phm, struct hpi_response *phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) void *h_owner)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) hpi_init_response(phr, HPI_OBJ_OSTREAM, HPI_OSTREAM_OPEN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) hpios_msgxlock_lock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) if (outstream_user_open[phm->adapter_index][phm->obj_index].open_flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) phr->error = HPI_ERROR_OBJ_ALREADY_OPEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) else if (rESP_HPI_OSTREAM_OPEN[phm->adapter_index]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) [phm->obj_index].h.error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) memcpy(phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) &rESP_HPI_OSTREAM_OPEN[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) obj_index],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) sizeof(rESP_HPI_OSTREAM_OPEN[0][0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) outstream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) obj_index].open_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) hpios_msgxlock_unlock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) /* issue a reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) HPI_OSTREAM_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) hm.adapter_index = phm->adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) hm.obj_index = phm->obj_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) hpios_msgxlock_lock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) if (hr.error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) outstream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) obj_index].open_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) phr->error = hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) outstream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) obj_index].open_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) outstream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) obj_index].h_owner = h_owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) memcpy(phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) &rESP_HPI_OSTREAM_OPEN[phm->adapter_index]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) [phm->obj_index],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) sizeof(rESP_HPI_OSTREAM_OPEN[0][0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) hpios_msgxlock_unlock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) static void outstream_close(struct hpi_message *phm, struct hpi_response *phr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) void *h_owner)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) hpi_init_response(phr, HPI_OBJ_OSTREAM, HPI_OSTREAM_CLOSE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) hpios_msgxlock_lock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) if (h_owner ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) outstream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) obj_index].h_owner) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) /* HPI_DEBUG_LOG(INFO,"closing adapter %d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) "outstream %d owned by %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) phm->wAdapterIndex, phm->wObjIndex, hOwner); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) outstream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) obj_index].h_owner = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) hpios_msgxlock_unlock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) /* issue a reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) HPI_OSTREAM_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) hm.adapter_index = phm->adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) hm.obj_index = phm->obj_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) hpios_msgxlock_lock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if (hr.error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) outstream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) obj_index].h_owner = h_owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) phr->error = hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) outstream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) obj_index].open_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) outstream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) obj_index].h_owner = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) HPI_DEBUG_LOG(WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) "%p trying to close %d outstream %d owned by %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) h_owner, phm->adapter_index, phm->obj_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) outstream_user_open[phm->adapter_index][phm->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) obj_index].h_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) phr->error = HPI_ERROR_OBJ_NOT_OPEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) hpios_msgxlock_unlock(&msgx_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) static u16 adapter_prepare(u16 adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) /* Open the adapter and streams */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) u16 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) /* call to HPI_ADAPTER_OPEN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) HPI_ADAPTER_OPEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) hm.adapter_index = adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) memcpy(&rESP_HPI_ADAPTER_OPEN[adapter], &hr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) sizeof(rESP_HPI_ADAPTER_OPEN[0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) if (hr.error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) /* call to HPI_ADAPTER_GET_INFO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) HPI_ADAPTER_GET_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) hm.adapter_index = adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) if (hr.error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) return hr.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) aDAPTER_INFO[adapter].num_outstreams = hr.u.ax.info.num_outstreams;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) aDAPTER_INFO[adapter].num_instreams = hr.u.ax.info.num_instreams;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) aDAPTER_INFO[adapter].type = hr.u.ax.info.adapter_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) /* call to HPI_OSTREAM_OPEN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) for (i = 0; i < aDAPTER_INFO[adapter].num_outstreams; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) HPI_OSTREAM_OPEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) hm.adapter_index = adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) hm.obj_index = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) memcpy(&rESP_HPI_OSTREAM_OPEN[adapter][i], &hr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) sizeof(rESP_HPI_OSTREAM_OPEN[0][0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) outstream_user_open[adapter][i].open_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) outstream_user_open[adapter][i].h_owner = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) /* call to HPI_ISTREAM_OPEN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) for (i = 0; i < aDAPTER_INFO[adapter].num_instreams; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) HPI_ISTREAM_OPEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) hm.adapter_index = adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) hm.obj_index = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) memcpy(&rESP_HPI_ISTREAM_OPEN[adapter][i], &hr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) sizeof(rESP_HPI_ISTREAM_OPEN[0][0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) instream_user_open[adapter][i].open_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) instream_user_open[adapter][i].h_owner = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) /* call to HPI_MIXER_OPEN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) hm.adapter_index = adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) sizeof(rESP_HPI_MIXER_OPEN[0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) static void HPIMSGX__reset(u16 adapter_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) u16 adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) if (adapter_index == HPIMSGX_ALLADAPTERS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) hpi_init_response(&hr, HPI_OBJ_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) HPI_ADAPTER_OPEN, HPI_ERROR_BAD_ADAPTER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) memcpy(&rESP_HPI_ADAPTER_OPEN[adapter], &hr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) sizeof(rESP_HPI_ADAPTER_OPEN[adapter]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) hpi_init_response(&hr, HPI_OBJ_MIXER, HPI_MIXER_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) HPI_ERROR_INVALID_OBJ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) sizeof(rESP_HPI_MIXER_OPEN[adapter]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) for (i = 0; i < HPI_MAX_STREAMS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) hpi_init_response(&hr, HPI_OBJ_OSTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) HPI_OSTREAM_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) HPI_ERROR_INVALID_OBJ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) memcpy(&rESP_HPI_OSTREAM_OPEN[adapter][i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) &hr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) sizeof(rESP_HPI_OSTREAM_OPEN[adapter]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) [i]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) hpi_init_response(&hr, HPI_OBJ_ISTREAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) HPI_ISTREAM_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) HPI_ERROR_INVALID_OBJ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) memcpy(&rESP_HPI_ISTREAM_OPEN[adapter][i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) &hr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) sizeof(rESP_HPI_ISTREAM_OPEN[adapter]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) [i]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) } else if (adapter_index < HPI_MAX_ADAPTERS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) rESP_HPI_ADAPTER_OPEN[adapter_index].h.error =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) HPI_ERROR_BAD_ADAPTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) rESP_HPI_MIXER_OPEN[adapter_index].h.error =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) HPI_ERROR_INVALID_OBJ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) for (i = 0; i < HPI_MAX_STREAMS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) rESP_HPI_OSTREAM_OPEN[adapter_index][i].h.error =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) HPI_ERROR_INVALID_OBJ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) rESP_HPI_ISTREAM_OPEN[adapter_index][i].h.error =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) HPI_ERROR_INVALID_OBJ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) static u16 HPIMSGX__init(struct hpi_message *phm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) /* HPI_SUBSYS_CREATE_ADAPTER structure with */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) /* resource list or NULL=find all */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) struct hpi_response *phr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) /* response from HPI_ADAPTER_GET_INFO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) hpi_handler_func *entry_point_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) /* Init response here so we can pass in previous adapter list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) hpi_init_response(&hr, phm->object, phm->function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) HPI_ERROR_INVALID_OBJ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) entry_point_func =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) hpi_lookup_entry_point_function(phm->u.s.resource.r.pci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) if (entry_point_func) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) HPI_DEBUG_MESSAGE(DEBUG, phm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) entry_point_func(phm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) phr->error = HPI_ERROR_PROCESSING_MESSAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) return phr->error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) if (hr.error == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) /* the adapter was created successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) save the mapping for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) hpi_entry_points[hr.u.s.adapter_index] = entry_point_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) /* prepare adapter (pre-open streams etc.) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) HPI_DEBUG_LOG(DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) "HPI_SUBSYS_CREATE_ADAPTER successful,"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) " preparing adapter\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) adapter_prepare(hr.u.s.adapter_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) memcpy(phr, &hr, hr.size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) return phr->error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) int i, adapter, adapter_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) if (!h_owner)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) if (adapter_index == HPIMSGX_ALLADAPTERS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) adapter = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) adapter_limit = HPI_MAX_ADAPTERS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) adapter = adapter_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) adapter_limit = adapter + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) for (; adapter < adapter_limit; adapter++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) /* printk(KERN_INFO "Cleanup adapter #%d\n",wAdapter); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) for (i = 0; i < HPI_MAX_STREAMS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) if (h_owner ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) outstream_user_open[adapter][i].h_owner) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) HPI_DEBUG_LOG(DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) "Close adapter %d ostream %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) adapter, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) hpi_init_message_response(&hm, &hr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) HPI_OBJ_OSTREAM, HPI_OSTREAM_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) hm.adapter_index = (u16)adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) hm.obj_index = (u16)i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) hm.function = HPI_OSTREAM_HOSTBUFFER_FREE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) hm.function = HPI_OSTREAM_GROUP_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) outstream_user_open[adapter][i].open_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) outstream_user_open[adapter][i].h_owner =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) if (h_owner == instream_user_open[adapter][i].h_owner) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) struct hpi_message hm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) struct hpi_response hr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) HPI_DEBUG_LOG(DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) "Close adapter %d istream %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) adapter, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) hpi_init_message_response(&hm, &hr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) HPI_OBJ_ISTREAM, HPI_ISTREAM_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) hm.adapter_index = (u16)adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) hm.obj_index = (u16)i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) hm.function = HPI_ISTREAM_HOSTBUFFER_FREE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) hm.function = HPI_ISTREAM_GROUP_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) hw_entry_point(&hm, &hr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) instream_user_open[adapter][i].open_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) instream_user_open[adapter][i].h_owner = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) }