From: Takashi Iwai Date: Wed, 19 Feb 2003 15:39:35 +0000 (+0000) Subject: - added the hwdep DSP loader API functions. X-Git-Tag: v1.0.3~270 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=74f0165c976637fbaf7920594bcbba094369f44f;p=alsa-lib.git - added the hwdep DSP loader API functions. - updated the internal asound.h. --- diff --git a/include/hwdep.h b/include/hwdep.h index 7d08edd3..786b0fde 100644 --- a/include/hwdep.h +++ b/include/hwdep.h @@ -44,6 +44,12 @@ extern "C" { /** HwDep information container */ typedef struct _snd_hwdep_info snd_hwdep_info_t; +/** HwDep DSP status container */ +typedef struct _snd_hwdep_dsp_status snd_hwdep_dsp_status_t; + +/** HwDep DSP image container */ +typedef struct _snd_hwdep_dsp_image snd_hwdep_dsp_image_t; + /** HwDep interface */ typedef enum _snd_hwdep_iface { SND_HWDEP_IFACE_OPL2 = 0, /**< OPL2 raw driver */ @@ -53,7 +59,9 @@ typedef enum _snd_hwdep_iface { SND_HWDEP_IFACE_EMU10K1, /**< EMU10K1 driver */ SND_HWDEP_IFACE_YSS225, /**< YSS225 driver */ SND_HWDEP_IFACE_ICS2115, /**< ICS2115 driver */ - SND_HWDEP_IFACE_LAST = SND_HWDEP_IFACE_ICS2115 /**< last know hwdep interface */ + SND_HWDEP_IFACE_SSCAPE, /**< Ensoniq SoundScape ISA card (MC68EC000) */ + SND_HWDEP_IFACE_VX, /**< Digigram VX cards */ + SND_HWDEP_IFACE_LAST = SND_HWDEP_IFACE_VX /**< last know hwdep interface */ } snd_hwdep_iface_t; /** open for reading */ @@ -84,6 +92,8 @@ int snd_hwdep_poll_descriptors(snd_hwdep_t *hwdep, struct pollfd *pfds, unsigned int snd_hwdep_poll_descriptors_revents(snd_hwdep_t *hwdep, struct pollfd *pfds, unsigned int nfds, unsigned short *revents); int snd_hwdep_nonblock(snd_hwdep_t *hwdep, int nonblock); int snd_hwdep_info(snd_hwdep_t *hwdep, snd_hwdep_info_t * info); +int snd_hwdep_dsp_status(snd_hwdep_t *hwdep, snd_hwdep_dsp_status_t *status); +int snd_hwdep_dsp_load(snd_hwdep_t *hwdep, snd_hwdep_dsp_image_t *block); int snd_hwdep_ioctl(snd_hwdep_t *hwdep, unsigned int request, void * arg); ssize_t snd_hwdep_write(snd_hwdep_t *hwdep, const void *buffer, size_t size); ssize_t snd_hwdep_read(snd_hwdep_t *hwdep, void *buffer, size_t size); @@ -102,6 +112,36 @@ const char *snd_hwdep_info_get_name(const snd_hwdep_info_t *obj); snd_hwdep_iface_t snd_hwdep_info_get_iface(const snd_hwdep_info_t *obj); void snd_hwdep_info_set_device(snd_hwdep_info_t *obj, unsigned int val); +size_t snd_hwdep_dsp_status_sizeof(void); +/** allocate #snd_hwdep_dsp_status_t container on stack */ +#define snd_hwdep_dsp_status_alloca(ptr) do { assert(ptr); *ptr = (snd_hwdep_dsp_status_t *) alloca(snd_hwdep_dsp_status_sizeof()); memset(*ptr, 0, snd_hwdep_dsp_status_sizeof()); } while (0) +int snd_hwdep_dsp_status_malloc(snd_hwdep_dsp_status_t **ptr); +void snd_hwdep_dsp_status_free(snd_hwdep_dsp_status_t *obj); +void snd_hwdep_dsp_status_copy(snd_hwdep_dsp_status_t *dst, const snd_hwdep_dsp_status_t *src); + +unsigned int snd_hwdep_dsp_status_get_version(const snd_hwdep_dsp_status_t *obj); +const char *snd_hwdep_dsp_status_get_id(const snd_hwdep_dsp_status_t *obj); +unsigned int snd_hwdep_dsp_status_get_num_dsps(const snd_hwdep_dsp_status_t *obj); +unsigned int snd_hwdep_dsp_status_get_dsp_loaded(const snd_hwdep_dsp_status_t *obj); +unsigned int snd_hwdep_dsp_status_get_chip_ready(const snd_hwdep_dsp_status_t *obj); + +size_t snd_hwdep_dsp_image_sizeof(void); +/** allocate #snd_hwdep_dsp_image_t container on stack */ +#define snd_hwdep_dsp_image_alloca(ptr) do { assert(ptr); *ptr = (snd_hwdep_dsp_image_t *) alloca(snd_hwdep_dsp_image_sizeof()); memset(*ptr, 0, snd_hwdep_dsp_image_sizeof()); } while (0) +int snd_hwdep_dsp_image_malloc(snd_hwdep_dsp_image_t **ptr); +void snd_hwdep_dsp_image_free(snd_hwdep_dsp_image_t *obj); +void snd_hwdep_dsp_image_copy(snd_hwdep_dsp_image_t *dst, const snd_hwdep_dsp_image_t *src); + +unsigned int snd_hwdep_dsp_image_get_index(const snd_hwdep_dsp_image_t *obj); +const char *snd_hwdep_dsp_image_get_name(const snd_hwdep_dsp_image_t *obj); +const void *snd_hwdep_dsp_image_get_image(const snd_hwdep_dsp_image_t *obj); +size_t snd_hwdep_dsp_image_get_length(const snd_hwdep_dsp_image_t *obj); + +void snd_hwdep_dsp_image_set_index(snd_hwdep_dsp_image_t *obj, unsigned int index); +void snd_hwdep_dsp_image_set_name(snd_hwdep_dsp_image_t *obj, const char *name); +void snd_hwdep_dsp_image_set_image(snd_hwdep_dsp_image_t *obj, void *buffer); +void snd_hwdep_dsp_image_set_length(snd_hwdep_dsp_image_t *obj, size_t length); + /** \} */ #ifdef __cplusplus diff --git a/include/local.h b/include/local.h index 59dde5fa..fc7bee69 100644 --- a/include/local.h +++ b/include/local.h @@ -53,6 +53,8 @@ #define _snd_rawmidi_status sndrv_rawmidi_status #define _snd_hwdep_info sndrv_hwdep_info +#define _snd_hwdep_dsp_status sndrv_hwdep_dsp_status +#define _snd_hwdep_dsp_image sndrv_hwdep_dsp_image #define _snd_seq_queue_tempo sndrv_seq_queue_tempo #define _snd_seq_client_info sndrv_seq_client_info diff --git a/include/sound/asound.h b/include/sound/asound.h index d749d968..f4883cc4 100644 --- a/include/sound/asound.h +++ b/include/sound/asound.h @@ -104,9 +104,10 @@ enum sndrv_hwdep_iface { SNDRV_HWDEP_IFACE_YSS225, /* Yamaha FX processor */ SNDRV_HWDEP_IFACE_ICS2115, /* Wavetable synth */ SNDRV_HWDEP_IFACE_SSCAPE, /* Ensoniq SoundScape ISA card (MC68EC000) */ + SNDRV_HWDEP_IFACE_VX, /* Digigram VX cards */ /* Don't forget to change the following: */ - SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_SSCAPE, + SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_VX, }; struct sndrv_hwdep_info { @@ -118,9 +119,27 @@ struct sndrv_hwdep_info { unsigned char reserved[64]; /* reserved for future */ }; +/* generic DSP loader */ +struct sndrv_hwdep_dsp_status { + unsigned int version; /* R: driver-specific version */ + unsigned char id[32]; /* R: driver-specific ID string */ + unsigned int num_dsps; /* R: number of DSP images to transfer */ + unsigned int dsp_loaded; /* R: bit flags indicating the loaded DSPs */ + unsigned int chip_ready; /* R: 1 = initialization finished */ +}; + +struct sndrv_hwdep_dsp_image { + unsigned int index; /* W: DSP index */ + unsigned char name[64]; /* W: ID (e.g. file name) */ + unsigned char *image; /* W: binary image */ + size_t length; /* W: size of image in bytes */ +}; + enum { SNDRV_HWDEP_IOCTL_PVERSION = _IOR ('H', 0x00, int), SNDRV_HWDEP_IOCTL_INFO = _IOR ('H', 0x01, struct sndrv_hwdep_info), + SNDRV_HWDEP_IOCTL_DSP_STATUS = _IOR('H', 0x02, struct sndrv_hwdep_dsp_status), + SNDRV_HWDEP_IOCTL_DSP_LOAD = _IOW('H', 0x03, struct sndrv_hwdep_dsp_image) }; /***************************************************************************** @@ -129,7 +148,7 @@ enum { * * *****************************************************************************/ -#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 2) +#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 3) typedef unsigned long sndrv_pcm_uframes_t; typedef long sndrv_pcm_sframes_t; @@ -423,6 +442,7 @@ enum { SNDRV_PCM_IOCTL_SW_PARAMS = _IOWR('A', 0x13, struct sndrv_pcm_sw_params), SNDRV_PCM_IOCTL_STATUS = _IOR('A', 0x20, struct sndrv_pcm_status), SNDRV_PCM_IOCTL_DELAY = _IOR('A', 0x21, sndrv_pcm_sframes_t), + SNDRV_PCM_IOCTL_HWSYNC = _IO('A', 0x22), SNDRV_PCM_IOCTL_CHANNEL_INFO = _IOR('A', 0x32, struct sndrv_pcm_channel_info), SNDRV_PCM_IOCTL_PREPARE = _IO('A', 0x40), SNDRV_PCM_IOCTL_RESET = _IO('A', 0x41), diff --git a/src/hwdep/hwdep.c b/src/hwdep/hwdep.c index c47939ea..5f16c9f6 100644 --- a/src/hwdep/hwdep.c +++ b/src/hwdep/hwdep.c @@ -487,3 +487,274 @@ ssize_t snd_hwdep_read(snd_hwdep_t *hwdep, void *buffer, size_t size) assert(buffer || size == 0); return hwdep->ops->read(hwdep, buffer, size); } + +/** + * \brief get the DSP status information + * \param hwdep HwDep handle + * \param info pointer to a snd_hwdep_dsp_status_t structure to be filled + * \return 0 on success otherwise a negative error code + */ +int snd_hwdep_dsp_status(snd_hwdep_t *hwdep, snd_hwdep_dsp_status_t *info) +{ + assert(hwdep); + assert(info); + return hwdep->ops->ioctl(hwdep, SNDRV_HWDEP_IOCTL_DSP_STATUS, (void*)info); +} + +/** + * \brief load the DSP block + * \param hwdep HwDep handle + * \param block pointer to a snd_hwdep_dsp_image_t structure to transfer + * \return 0 on success otherwise a negative error code + */ +int snd_hwdep_dsp_load(snd_hwdep_t *hwdep, snd_hwdep_dsp_image_t *block) +{ + assert(hwdep); + assert(block); + return hwdep->ops->ioctl(hwdep, SNDRV_HWDEP_IOCTL_DSP_LOAD, (void*)block); +} + +/** + * \brief get size of the snd_hwdep_dsp_status_t structure in bytes + * \return size of the snd_hwdep_dsp_status_t structure in bytes + */ +size_t snd_hwdep_dsp_status_sizeof() +{ + return sizeof(snd_hwdep_dsp_status_t); +} + +/** + * \brief allocate a new snd_hwdep_dsp_status_t structure + * \param ptr returned pointer + * \return 0 on success otherwise a negative error code if fails + * + * Allocates a new snd_hwdep_dsp_status_t structure using the standard + * malloc C library function. + */ +int snd_hwdep_dsp_status_malloc(snd_hwdep_dsp_status_t **info) +{ + assert(info); + *info = calloc(1, sizeof(snd_hwdep_dsp_status_t)); + if (!*info) + return -ENOMEM; + return 0; +} + +/** + * \brief frees the snd_hwdep_dsp_status_t structure + * \param info pointer to the snd_hwdep_dsp_status_t structure to free + * + * Frees the given snd_hwdep_dsp_status_t structure using the standard + * free C library function. + */ +void snd_hwdep_dsp_status_free(snd_hwdep_dsp_status_t *info) +{ + assert(info); + free(info); +} + +/** + * \brief copy one snd_hwdep_dsp_status_t structure to another + * \param dst destination snd_hwdep_dsp_status_t structure + * \param src source snd_hwdep_dsp_status_t structure + */ +void snd_hwdep_dsp_status_copy(snd_hwdep_dsp_status_t *dst, const snd_hwdep_dsp_status_t *src) +{ + assert(dst && src); + *dst = *src; +} + +/** + * \brief get the driver version of dsp loader + * \param info pointer to a snd_hwdep_dsp_status_t structure + * \return the driver version + */ +unsigned int snd_hwdep_dsp_status_get_version(const snd_hwdep_dsp_status_t *obj) +{ + assert(obj); + return obj->version; +} + +/** + * \brief get the driver id of dsp loader + * \param info pointer to a snd_hwdep_dsp_status_t structure + * \return the driver id string + */ +const char *snd_hwdep_dsp_status_get_id(const snd_hwdep_dsp_status_t *obj) +{ + assert(obj); + return obj->id; +} + +/** + * \brief get number of dsp blocks + * \param info pointer to a snd_hwdep_dsp_status_t structure + * \return number of dsp blocks + */ +unsigned int snd_hwdep_dsp_status_get_num_dsps(const snd_hwdep_dsp_status_t *obj) +{ + assert(obj); + return obj->num_dsps; +} + +/** + * \brief get the bit flags of the loaded dsp blocks + * \param info pointer to a snd_hwdep_dsp_status_t structure + * \return the big flags of the loaded dsp blocks + */ +unsigned int snd_hwdep_dsp_status_get_dsp_loaded(const snd_hwdep_dsp_status_t *info) +{ + assert(info); + return info->dsp_loaded; +} + +/** + * \brief get the chip status of dsp loader + * \param info pointer to a snd_hwdep_dsp_status_t structure + * \return non-zero if all DSP blocks are loaded and the chip is ready + */ +unsigned int snd_hwdep_dsp_status_get_chip_ready(const snd_hwdep_dsp_status_t *obj) +{ + assert(obj); + return obj->chip_ready; +} + +/** + * \brief get size of the snd_hwdep_dsp_image_t structure in bytes + * \return size of the snd_hwdep_dsp_image_t structure in bytes + */ +size_t snd_hwdep_dsp_image_sizeof() +{ + return sizeof(snd_hwdep_dsp_image_t); +} + +/** + * \brief allocate a new snd_hwdep_dsp_image_t structure + * \param ptr returned pointer + * \return 0 on success otherwise a negative error code if fails + * + * Allocates a new snd_hwdep_dsp_image_t structure using the standard + * malloc C library function. + */ +int snd_hwdep_dsp_image_malloc(snd_hwdep_dsp_image_t **info) +{ + assert(info); + *info = calloc(1, sizeof(snd_hwdep_dsp_image_t)); + if (!*info) + return -ENOMEM; + return 0; +} + +/** + * \brief frees the snd_hwdep_dsp_image_t structure + * \param info pointer to the snd_hwdep_dsp_image_t structure to free + * + * Frees the given snd_hwdep_dsp_image_t structure using the standard + * free C library function. + */ +void snd_hwdep_dsp_image_free(snd_hwdep_dsp_image_t *info) +{ + assert(info); + free(info); +} + +/** + * \brief copy one snd_hwdep_dsp_image_t structure to another + * \param dst destination snd_hwdep_dsp_image_t structure + * \param src source snd_hwdep_dsp_image_t structure + */ +void snd_hwdep_dsp_image_copy(snd_hwdep_dsp_image_t *dst, const snd_hwdep_dsp_image_t *src) +{ + assert(dst && src); + *dst = *src; +} + +/** + * \brief get the DSP block index + * \param info pointer to a snd_hwdep_dsp_image_t structure + * \return the index of the DSP block + */ +unsigned int snd_hwdep_dsp_image_get_index(const snd_hwdep_dsp_image_t *obj) +{ + assert(obj); + return obj->index; +} + +/** + * \brief get the name of the DSP block + * \param info pointer to a snd_hwdep_dsp_image_t structure + * \return the name string of the DSP block + */ +const char *snd_hwdep_dsp_image_get_name(const snd_hwdep_dsp_image_t *obj) +{ + assert(obj); + return obj->name; +} + +/** + * \brief get the length of the DSP block + * \param info pointer to a snd_hwdep_dsp_image_t structure + * \return the length of the DSP block in bytes + */ +size_t snd_hwdep_dsp_image_get_length(const snd_hwdep_dsp_image_t *obj) +{ + assert(obj); + return obj->length; +} + +/** + * \brief get the image pointer of the DSP block + * \param info pointer to a snd_hwdep_dsp_image_t structure + * \return the image pointer of the DSP block + */ +const void *snd_hwdep_dsp_image_get_image(const snd_hwdep_dsp_image_t *obj) +{ + assert(obj); + return obj->image; +} + +/** + * \brief set the DSP block index + * \param info pointer to a snd_hwdep_dsp_image_t structure + * \param index the index value to set + */ +void snd_hwdep_dsp_image_set_index(snd_hwdep_dsp_image_t *obj, unsigned int index) +{ + assert(obj); + obj->index = index; +} + +/** + * \brief set the name of the DSP block + * \param info pointer to a snd_hwdep_dsp_image_t structure + * \param name the name string + */ +void snd_hwdep_dsp_image_set_name(snd_hwdep_dsp_image_t *obj, const char *name) +{ + assert(obj && name); + strncpy(obj->name, name, sizeof(obj->name)); + obj->name[sizeof(obj->name)-1] = 0; +} + +/** + * \brief set the DSP block length + * \param info pointer to a snd_hwdep_dsp_image_t structure + * \param length the length of the DSP block + */ +void snd_hwdep_dsp_image_set_length(snd_hwdep_dsp_image_t *obj, size_t length) +{ + assert(obj); + obj->length = length; +} + +/** + * \brief set the DSP block image pointer + * \param info pointer to a snd_hwdep_dsp_image_t structure + * \param image the DSP image pointer + */ +void snd_hwdep_dsp_image_set_image(snd_hwdep_dsp_image_t *obj, void *image) +{ + assert(obj); + obj->image = image; +} +