Testers needed: HDSP with hotplug firmware loader
Hi,
can any HDSP owner with 2.6 kernel test the attached patches?
The patch changes the firmware loading of hdsp. When the hotplug firmware loader on kernel is available, it uses automatically via hotplug. So, hdsploader is no longer needed.
The patches are for alsa-kernel, alsa-driver and alsa-firmware, respectively. After applying them, rebuild alsa-driver, and reinstall alsa-firmware, too.
Please let me know if it works, then I'll commit these patches to CVS before 1.0.8-rc2.
thanks,
Takashi
Index: alsa-kernel/pci/rme9652/hdsp.c
===================================================================
RCS file: /home/tiwai/cvs/alsa/alsa-kernel/pci/rme9652/hdsp.c,v retrieving revision 1.78
pci/rme9652/hdsp.c +102 -5
@@ -27,6 +27,7 @@#include <linux/interrupt.h> #include <linux/slab.h> #include <linux/pci.h> +#include <linux/firmware.h> #include <linux/moduleparam.h> #include <sound/core.h>
@@ -399,6 +400,13 @@#define HDSP_DMA_AREA_BYTES ((HDSP_MAX_CHANNELS+1) * HDSP_CHANNEL_BUFFER_BYTES)#define HDSP_DMA_AREA_KILOBYTES (HDSP_DMA_AREA_BYTES/1024) +/* use hotplug firmeare loader? */ +#if defined(CONFIG_FW_LOADER ) || defined(CONFIG_FW_LOADER_MODULE ) +#ifndef HDSP_USE_HWDEP_LOADER +#define HDSP_FW_LOADER +#endif +#endif +typedef struct _hdsp hdsp_t ;typedef struct _hdsp_midi hdsp_midi_t ;typedef struct _hdsp_9632_meters hdsp_9632_meters_t ;
@@ -585,8 +593,8 @@MODULE_DEVICE_TABLE (pci, snd_hdsp_ids);/* prototypes */ -static int __devinit snd_hdsp_create_alsa_devices (snd_card_t *card,hdsp_t *hdsp); -static int __devinit snd_hdsp_create_pcm (snd_card_t *card,hdsp_t *hdsp); +static int snd_hdsp_create_alsa_devices (snd_card_t *card,hdsp_t *hdsp); +static int snd_hdsp_create_pcm (snd_card_t *card,hdsp_t *hdsp);static int snd_hdsp_enable_io (hdsp_t *hdsp);static void snd_hdsp_initialize_midi_flush (hdsp_t *hdsp);static void snd_hdsp_initialize_channels (hdsp_t *hdsp);
@@ -4653,6 +4661,7 @@ }break ; } +#ifndef HDSP_FW_LOADER case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE : {hdsp_firmware_t __user *firmware;u32 __user *firmware_data;
@@ -4662,6 +4671,9 @@/* SNDRV_HDSP_IOCTL_GET_VERSION must have been called */ if (hdsp->io_type == Undefined)return -EINVAL ; +if (hdsp->state & (HDSP_FirmwareCached | HDSP_FirmwareLoaded)) +return -EBUSY ; +snd_printk ("initializing firmware upload\n" ); firmware = (hdsp_firmware_t __user *)argp;
@@ -4695,6 +4707,7 @@ }break ; } +#endif case SNDRV_HDSP_IOCTL_GET_MIXER : {hdsp_mixer_t __user *mixer = (hdsp_mixer_t __user *)argp;if (copy_to_user (mixer->matrix, hdsp->mixer_matrix,sizeof (unsigned short )*HDSP_MATRIX_MIXER_SIZE ))
@@ -4750,8 +4763,7 @@return 0 ; } -static int __devinit snd_hdsp_create_pcm (snd_card_t *card, -hdsp_t *hdsp) +static int snd_hdsp_create_pcm (snd_card_t *card,hdsp_t *hdsp) {snd_pcm_t *pcm;int err;
@@ -4842,7 +4854,7 @@snd_hdsp_flush_midi_input (hdsp,1 ); } -static int __devinit snd_hdsp_create_alsa_devices (snd_card_t *card,hdsp_t *hdsp) +static int snd_hdsp_create_alsa_devices (snd_card_t *card,hdsp_t *hdsp) {int err;
@@ -4895,6 +4907,86 @@return 0 ; } +#ifdef HDSP_FW_LOADER +/* load firmware via hotplug fw loader */ +static int __devinit hdsp_request_fw_loader (hdsp_t *hdsp) +{ +const char *fwfile; +const struct firmware *fw; +int err; + +if (hdsp->io_type ==H9652 || hdsp->io_type ==H9632 ) +return 0 ; +if (hdsp->io_type == Undefined) { +if ((err =hdsp_get_iobox_version (hdsp)) <0 ) +return err; +if (hdsp->io_type ==H9652 || hdsp->io_type ==H9632 ) +return 0 ; + } +if (hdsp_check_for_iobox (hdsp)) +return -EIO ; + +/* caution: max length of firmware filename is 30! */ +switch (hdsp->io_type) { +case Multiface: +if (hdsp->firmware_rev ==0xa ) + fwfile ="multiface_firmware.bin" ; +else + fwfile ="multiface_firmware_rev11.bin" ; +break ; +case Digiface: +if (hdsp->firmware_rev ==0xa ) + fwfile ="digiface_firmware.bin" ; +else + fwfile ="digiface_firmware_rev11.bin" ; +break ; +default : +snd_printk (KERN_ERR "hdsp: invalid io_type %d\n" , hdsp->io_type); +return -EINVAL ; + } + +if (request_firmware (&fw, fwfile, &hdsp->pci->dev)) { +snd_printk (KERN_ERR "hdsp: cannot load firmware %s\n" , fwfile); +return -ENOENT ; + } +if (fw->size <sizeof (hdsp->firmware_cache)) { +snd_printk (KERN_ERR "hdsp: too short firmware size %d (expected %d)\n" , + (int )fw->size, (int )sizeof (hdsp->firmware_cache)); +release_firmware (fw); +return -EINVAL ; + } +#ifdef SNDRV_BIG_ENDIAN + { +int i; +u32 *src = hdsp->data; +for (i =0 ; i <ARRAY_SIZE (hdsp->firmware_cache); i++, src++) + hdsp->firmware_cache[i] = ((*src &0x000000ff ) <<16 ) | + ((*src &0x0000ff00 ) <<8 ) | + ((*src &0x00ff0000 ) >>8 ) | + ((*src &0xff000000 ) >>16 ); + } +#else +memcpy (hdsp->firmware_cache, fw->data,sizeof (hdsp->firmware_cache)); +#endif +release_firmware (fw); + + hdsp->state |= HDSP_FirmwareCached; + +if ((err =snd_hdsp_load_firmware_from_cache (hdsp)) <0 ) +return err; + +if (!(hdsp->state & HDSP_InitializationComplete)) { +snd_hdsp_initialize_channels (hdsp); +snd_hdsp_initialize_midi_flush (hdsp); +if ((err =snd_hdsp_create_alsa_devices (hdsp->card, hdsp)) <0 ) { +snd_printk ("error creating alsa devices\n" ); +return err; + } + } +return 0 ; +} +#endif +static int __devinit snd_hdsp_create (snd_card_t *card,hdsp_t *hdsp,int precise_ptr)
@@ -5003,11 +5095,16 @@ }if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) !=0 ) { +#ifdef HDSP_FW_LOADER +if ((err =hdsp_request_fw_loader (hdsp)) <0 ) +return err; +#else snd_printk ("card initialization pending : waiting for firmware\n" );if ((err =snd_hdsp_create_hwdep (card, hdsp)) <0 ) {return err; }return 0 ; +#endif }snd_printk ("Firmware already loaded, initializing card.\n" );
Index: alsa-driver/pci/rme9652/hdsp.c
===================================================================
RCS file: /home/tiwai/cvs/alsa/alsa-driver/pci/rme9652/hdsp.c,v retrieving revision 1.2
pci/rme9652/hdsp.c +5 -0
@@ -1,2 +1,7 @@ +#include <linux/config.h> +#include <linux/version.h> +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,0 ) +#define HDSP_USE_HWDEP_LOADER +#endif #include "../../alsa-kernel/pci/rme9652/hdsp.c" EXPORT_NO_SYMBOLS ;
Index: alsa-firmware/hdsploader/Makefile.am
===================================================================
RCS file: /home/tiwai/cvs/alsa/alsa-firmware/hdsploader/Makefile.am,v retrieving revision 1.4
hdsploader/Makefile.am +20 -5
@@ -1,18 +1,33 @@ # # Process this file with automake to produce Makefile.in. MYNAME = hdsploader -firmwaredir = $(datadir)/alsa/firmware/$(MYNAME) -firmware_DATA = digiface_firmware.bin \ +dsp_files = digiface_firmware.bin \ digiface_firmware_rev11.bin \ multiface_firmware.bin \ multiface_firmware_rev11.bin +if USE_LOADER +firmwaredir = $(datadir)/alsa/firmware/$(MYNAME) +firmware_DATA = $(dsp_files) +else +firmwaredir = +firmware_DATA = +endif + +if USE_HOTPLUG +hotplugfwdir = @HOTPLUGFWDIR@ +hotplugfw_DATA = $(dsp_files) +else +hotplugfwdir = +hotplugfw_DATA = +endif + noinst_PROGRAMS = tobin tobin_SOURCES = tobin.c -EXTRA_DIST = $(firmware_DATA:%.bin=%.dat) \ +EXTRA_DIST = $(dsp_files:%.bin=%.dat) \ tobin.c -CLEANFILES = $(firmware_DATA) +CLEANFILES = $(dsp_files) -$(firmware_DATA): tobin +$(dsp_files): tobin ./tobin