linux/sound/pci/asihpi/hpi_internal.h

/* SPDX-License-Identifier: GPL-2.0-only */
/******************************************************************************

    AudioScience HPI driver
    Copyright (C) 1997-2012  AudioScience Inc. <[email protected]>


HPI internal definitions

(C) Copyright AudioScience Inc. 1996-2009
******************************************************************************/

#ifndef _HPI_INTERNAL_H_
#define _HPI_INTERNAL_H_

#include "hpi.h"

/** maximum number of memory regions mapped to an adapter */
#define HPI_MAX_ADAPTER_MEM_SPACES

/* Each OS needs its own hpios.h */
#include "hpios.h"

/* physical memory allocation */

/** Allocate and map an area of locked memory for bus master DMA operations.

On success, *pLockedMemeHandle is a valid handle, and 0 is returned
On error *pLockedMemHandle marked invalid, non-zero returned.

If this function succeeds, then HpiOs_LockedMem_GetVirtAddr() and
HpiOs_LockedMem_GetPyhsAddr() will always succed on the returned handle.
*/
u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_locked_mem_handle,
							   /**< memory handle */
	u32 size, /**< Size in bytes to allocate */
	struct pci_dev *p_os_reference
	/**< OS specific data required for memory allocation */
	);

/** Free mapping and memory represented by LockedMemHandle

Frees any resources, then invalidates the handle.
Returns 0 on success, 1 if handle is invalid.

*/
u16 hpios_locked_mem_free(struct consistent_dma_area *locked_mem_handle);

/** Get the physical PCI address of memory represented by LockedMemHandle.

If handle is invalid *pPhysicalAddr is set to zero and return 1
*/
u16 hpios_locked_mem_get_phys_addr(struct consistent_dma_area
	*locked_mem_handle, u32 *p_physical_addr);

/** Get the CPU address of memory represented by LockedMemHandle.

If handle is NULL *ppvVirtualAddr is set to NULL and return 1
*/
u16 hpios_locked_mem_get_virt_addr(struct consistent_dma_area
	*locked_mem_handle, void **ppv_virtual_addr);

/** Check that handle is valid
i.e it represents a valid memory area
*/
u16 hpios_locked_mem_valid(struct consistent_dma_area *locked_mem_handle);

/* timing/delay */
void hpios_delay_micro_seconds(u32 num_micro_sec);

struct hpi_message;
struct hpi_response;

hpi_handler_func;

/* If the assert fails, compiler complains
   something like size of array `msg' is negative.
   Unlike linux BUILD_BUG_ON, this works outside function scope.
*/
#define compile_time_assert(cond, msg)

/******************************************* bus types */
enum HPI_BUSES {};

enum HPI_SUBSYS_OPTIONS {};

/** Volume flags
*/
enum HPI_VOLUME_FLAGS {};

/******************************************* CONTROL ATTRIBUTES ****/
/* (in order of control type ID */

/* This allows for 255 control types, 256 unique attributes each */
#define HPI_CTL_ATTR(ctl, ai)

/* Get the sub-index of the attribute for a control type */
#define HPI_CTL_ATTR_INDEX(i)

/* Extract the control from the control attribute */
#define HPI_CTL_ATTR_CONTROL(i)

/** Enable event generation for a control.
0=disable, 1=enable
\note generic to all controls that can generate events
*/

/** Unique identifiers for every control attribute
*/
enum HPI_CONTROL_ATTRIBUTES {};

#define HPI_POLARITY_POSITIVE
#define HPI_POLARITY_NEGATIVE

/*------------------------------------------------------------
 Cobranet Chip Bridge - copied from HMI.H
------------------------------------------------------------*/
#define HPI_COBRANET_HMI_cobra_bridge
#define HPI_COBRANET_HMI_cobra_bridge_tx_pkt_buf
#define HPI_COBRANET_HMI_cobra_bridge_rx_pkt_buf
#define HPI_COBRANET_HMI_cobra_if_table1
#define HPI_COBRANET_HMI_cobra_if_phy_address
#define HPI_COBRANET_HMI_cobra_protocolIP
#define HPI_COBRANET_HMI_cobra_ip_mon_currentIP
#define HPI_COBRANET_HMI_cobra_ip_mon_staticIP
#define HPI_COBRANET_HMI_cobra_sys
#define HPI_COBRANET_HMI_cobra_sys_desc
#define HPI_COBRANET_HMI_cobra_sys_objectID
#define HPI_COBRANET_HMI_cobra_sys_contact
#define HPI_COBRANET_HMI_cobra_sys_name
#define HPI_COBRANET_HMI_cobra_sys_location

/*------------------------------------------------------------
 Cobranet Chip Status bits
------------------------------------------------------------*/
#define HPI_COBRANET_HMI_STATUS_RXPACKET
#define HPI_COBRANET_HMI_STATUS_TXPACKET

/*------------------------------------------------------------
 Ethernet header size
------------------------------------------------------------*/
#define HPI_ETHERNET_HEADER_SIZE

/* These defines are used to fill in protocol information for an Ethernet packet
    sent using HMI on CS18102 */
/** ID supplied by Cirrus for ASI packets. */
#define HPI_ETHERNET_PACKET_ID
/** Simple packet - no special routing required */
#define HPI_ETHERNET_PACKET_V1
/** This packet must make its way to the host across the HPI interface */
#define HPI_ETHERNET_PACKET_HOSTED_VIA_HMI
/** This packet must make its way to the host across the HPI interface */
#define HPI_ETHERNET_PACKET_HOSTED_VIA_HMI_V1
/** This packet must make its way to the host across the HPI interface */
#define HPI_ETHERNET_PACKET_HOSTED_VIA_HPI
/** This packet must make its way to the host across the HPI interface */
#define HPI_ETHERNET_PACKET_HOSTED_VIA_HPI_V1

#define HPI_ETHERNET_UDP_PORT

/** Default network timeout in milli-seconds. */
#define HPI_ETHERNET_TIMEOUT_MS

/** Locked memory buffer alloc/free phases */
enum HPI_BUFFER_CMDS {};

/*****************************************************************************/
/*****************************************************************************/
/********               HPI LOW LEVEL MESSAGES                  *******/
/*****************************************************************************/
/*****************************************************************************/
/** Pnp ids */
/** "ASI"  - actual is "ASX" - need to change */
#define HPI_ID_ISAPNP_AUDIOSCIENCE
/** PCI vendor ID that AudioScience uses */
#define HPI_PCI_VENDOR_ID_AUDIOSCIENCE
/** PCI vendor ID that the DSP56301 has */
#define HPI_PCI_VENDOR_ID_MOTOROLA
/** PCI vendor ID that TI uses */
#define HPI_PCI_VENDOR_ID_TI

#define HPI_PCI_DEV_ID_PCI2040
/** TI's C6205 PCI interface has this ID */
#define HPI_PCI_DEV_ID_DSP6205

#define HPI_USB_VENDOR_ID_AUDIOSCIENCE
#define HPI_USB_W2K_TAG
#define HPI_USB_LINUX_TAG

/** Invalid Adapter index
Used in HPI messages that are not addressed to a specific adapter
Used in DLL to indicate device not present
*/
#define HPI_ADAPTER_INDEX_INVALID

/** First 2 hex digits define the adapter family */
#define HPI_ADAPTER_FAMILY_MASK
#define HPI_MODULE_FAMILY_MASK

#define HPI_ADAPTER_FAMILY_ASI(f)
#define HPI_MODULE_FAMILY_ASI(f)
#define HPI_ADAPTER_ASI(f)

enum HPI_MESSAGE_TYPES {};

enum HPI_OBJECT_TYPES {};

#define HPI_OBJ_FUNCTION_SPACING
#define HPI_FUNC_ID(obj, i)

#define HPI_EXTRACT_INDEX(fn)

enum HPI_FUNCTION_IDS {};

/* ////////////////////////////////////////////////////////////////////// */
/* STRUCTURES */
#ifndef DISABLE_PRAGMA_PACK1
#pragma pack(push, 1)
#endif

/** PCI bus resource */
struct hpi_pci {};

/** Adapter specification resource */
struct hpi_adapter_specification {};

struct hpi_resource {};

/** Format info used inside struct hpi_message
    Not the same as public API struct hpi_format */
struct hpi_msg_format {};

/**  Buffer+format structure.
	 Must be kept 7 * 32 bits to match public struct hpi_datastruct */
struct hpi_msg_data {};

/** struct hpi_datastructure used up to 3.04 driver */
struct hpi_data_legacy32 {};

#ifdef CONFIG_64BIT
/* Compatibility version of struct hpi_data*/
struct hpi_data_compat32 {};
#endif

struct hpi_buffer {};

/*/////////////////////////////////////////////////////////////////////////// */
/* This is used for background buffer bus mastering stream buffers.           */
struct hpi_hostbuffer_status {};

struct hpi_streamid {};

struct hpi_punchinout {};

struct hpi_subsys_msg {};

struct hpi_subsys_res {};

hpi_adapterx_msg;

struct hpi_adapter_res {};

hpi_adapterx_res;

struct hpi_stream_msg {};

struct hpi_stream_res {};

struct hpi_mixer_msg {};

struct hpi_mixer_res {};

hpi_mixerx_msg;

hpi_mixerx_res;

struct hpi_control_msg {};

struct hpi_control_union_msg {};

struct hpi_control_res {};

hpi_control_union_res;

struct hpi_nvmemory_msg {};

struct hpi_nvmemory_res {};

struct hpi_gpio_msg {};

struct hpi_gpio_res {};

struct hpi_async_msg {};

struct hpi_async_res {};

struct hpi_watchdog_msg {};

struct hpi_watchdog_res {};

struct hpi_clock_msg {};

struct hpi_clock_res {};

struct hpi_profile_msg {};

struct hpi_profile_res_open {};

struct hpi_profile_res_time {};

struct hpi_profile_res_name {};

struct hpi_profile_res {};

struct hpi_message_header {};

struct hpi_message {};

#define HPI_MESSAGE_SIZE_BY_OBJECT

/*
Note that the wSpecificError error field should be inspected and potentially
reported whenever HPI_ERROR_DSP_COMMUNICATION or HPI_ERROR_DSP_BOOTLOAD is
returned in wError.
*/
struct hpi_response_header {};

struct hpi_response {};

#define HPI_RESPONSE_SIZE_BY_OBJECT

/*********************** version 1 message/response **************************/
#define HPINET_ETHERNET_DATA_SIZE
#define HPINET_IP_HDR_SIZE
#define HPINET_IP_DATA_SIZE
#define HPINET_UDP_HDR_SIZE
#define HPINET_UDP_DATA_SIZE
#define HPINET_ASI_HDR_SIZE
#define HPINET_ASI_DATA_SIZE

#define HPI_MAX_PAYLOAD_SIZE

/* New style message/response, but still V0 compatible */
struct hpi_msg_adapter_get_info {};

struct hpi_res_adapter_get_info {};

struct hpi_res_adapter_debug_read {};

struct hpi_msg_cobranet_hmi {};

struct hpi_msg_cobranet_hmiwrite {};

struct hpi_msg_cobranet_hmiread {};

struct hpi_res_cobranet_hmiread {};

#if 1
#define hpi_message_header_v1
#define hpi_response_header_v1
#else
/* V1 headers in Addition to v0 headers */
struct hpi_message_header_v1 {
	struct hpi_message_header h0;
/* struct {
} h1; */
};

struct hpi_response_header_v1 {
	struct hpi_response_header h0;
	struct {
		u16 adapter_index;	/* the adapter index */
		u16 obj_index;	/* object index */
	} h1;
};
#endif

struct hpi_msg_payload_v0 {};

struct hpi_res_payload_v0 {};

hpi_message_buffer_v1;

hpi_response_buffer_v1;

compile_time_assert();
compile_time_assert();

/*////////////////////////////////////////////////////////////////////////// */
/* declarations for compact control calls  */
struct hpi_control_defn {};

/*////////////////////////////////////////////////////////////////////////// */
/* declarations for control caching (internal to HPI<->DSP interaction)      */

/** indicates a cached u16 value is invalid. */
#define HPI_CACHE_INVALID_UINT16
/** indicates a cached short value is invalid. */
#define HPI_CACHE_INVALID_SHORT

/** A compact representation of (part of) a controls state.
Used for efficient transfer of the control state
between DSP and host or across a network
*/
struct hpi_control_cache_info {};

struct hpi_control_cache_vol {};

struct hpi_control_cache_meter {};

struct hpi_control_cache_channelmode {};

struct hpi_control_cache_mux {};

struct hpi_control_cache_level {};

struct hpi_control_cache_tuner {};

struct hpi_control_cache_aes3rx {};

struct hpi_control_cache_aes3tx {};

struct hpi_control_cache_tonedetector {};

struct hpi_control_cache_silencedetector {};

struct hpi_control_cache_sampleclock {};

struct hpi_control_cache_microphone {};

struct hpi_control_cache_single {};

struct hpi_control_cache_pad {};

/* 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */
struct hpi_fifo_buffer {};

#ifndef DISABLE_PRAGMA_PACK1
#pragma pack(pop)
#endif

/* skip host side function declarations for DSP
   compile and documentation extraction */

char hpi_handle_object(const u32 handle);

void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index,
	u16 *pw_object_index);

u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index,
	const u16 object_index);

/*////////////////////////////////////////////////////////////////////////// */

/* main HPI entry point */
void hpi_send_recv(struct hpi_message *phm, struct hpi_response *phr);

/* used in PnP OS/driver */
u16 hpi_outstream_host_buffer_get_info(u32 h_outstream, u8 **pp_buffer,
	struct hpi_hostbuffer_status **pp_status);

u16 hpi_instream_host_buffer_get_info(u32 h_instream, u8 **pp_buffer,
	struct hpi_hostbuffer_status **pp_status);

/*
The following 3 functions were last declared in header files for
driver 3.10. HPI_ControlQuery() used to be the recommended way
of getting a volume range. Declared here for binary asihpi32.dll
compatibility.
*/

void hpi_format_to_msg(struct hpi_msg_format *pMF,
	const struct hpi_format *pF);
void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR);

/*////////////////////////////////////////////////////////////////////////// */
/* declarations for individual HPI entry points */
hpi_handler_func HPI_6000;
hpi_handler_func HPI_6205;

#endif				/* _HPI_INTERNAL_H_ */