Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19b50063 authored by Giuliano Pochini's avatar Giuliano Pochini Committed by Takashi Iwai
Browse files

ALSA: Echoaudio - Add firmware cache #1



Changes the way the firmware is passed through functions.

When CONFIG_PM is enabled the firmware cannot be released because the
driver will need it again to resume the card. 
With this patch the firmware is passed as an index of the struct
firmware card_fw[] in place of a pointer. That same index is then used
to locate the firmware in the firmware cache.

Signed-off-by: default avatarGiuliano Pochini <pochini@shiny.it>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent a540e133
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
	chip->device_id = device_id;
	chip->subdevice_id = subdevice_id;
	chip->bad_board = TRUE;
	chip->dsp_code_to_load = &card_fw[FW_DARLA20_DSP];
	chip->dsp_code_to_load = FW_DARLA20_DSP;
	chip->spdif_status = GD_SPDIF_STATUS_UNDEF;
	chip->clock_state = GD_CLOCK_UNDEF;
	/* Since this card has no ASIC, mark it as loaded so everything
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
	chip->device_id = device_id;
	chip->subdevice_id = subdevice_id;
	chip->bad_board = TRUE;
	chip->dsp_code_to_load = &card_fw[FW_DARLA24_DSP];
	chip->dsp_code_to_load = FW_DARLA24_DSP;
	/* Since this card has no ASIC, mark it as loaded so everything
	   works OK */
	chip->asic_loaded = TRUE;
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
	chip->subdevice_id = subdevice_id;
	chip->bad_board = TRUE;
	chip->has_midi = TRUE;
	chip->dsp_code_to_load = &card_fw[FW_ECHO3G_DSP];
	chip->dsp_code_to_load = FW_ECHO3G_DSP;

	/* Load the DSP code and the ASIC on the PCI card and get
	what type of external box is attached */
+7 −1
Original line number Diff line number Diff line
@@ -36,11 +36,15 @@ MODULE_PARM_DESC(enable, "Enable " ECHOCARD_NAME " soundcard.");
static unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999};
static const DECLARE_TLV_DB_SCALE(db_scale_output_gain, -12800, 100, 1);



static int get_firmware(const struct firmware **fw_entry,
			const struct firmware *frm, struct echoaudio *chip)
			struct echoaudio *chip, const short fw_index)
{
	int err;
	char name[30];
	const struct firmware *frm = &card_fw[fw_index];

	DE_ACT(("firmware requested: %s\n", frm->data));
	snprintf(name, sizeof(name), "ea/%s", frm->data);
	if ((err = request_firmware(fw_entry, name, pci_device(chip))) < 0)
@@ -48,6 +52,8 @@ static int get_firmware(const struct firmware **fw_entry,
	return err;
}



static void free_firmware(const struct firmware *fw_entry)
{
	release_firmware(fw_entry);
+3 −3
Original line number Diff line number Diff line
@@ -442,8 +442,8 @@ struct echoaudio {
	u16 device_id, subdevice_id;
	u16 *dsp_code;			/* Current DSP code loaded,
					 * NULL if nothing loaded */
	const struct firmware *dsp_code_to_load;/* DSP code to load */
	const struct firmware *asic_code;	/* Current ASIC code */
	short dsp_code_to_load;		/* DSP code to load */
	short asic_code;		/* Current ASIC code */
	u32 comm_page_phys;			/* Physical address of the
						 * memory seen by DSP */
	volatile u32 __iomem *dsp_registers;	/* DSP's register base */
@@ -464,7 +464,7 @@ static int load_firmware(struct echoaudio *chip);
static int wait_handshake(struct echoaudio *chip);
static int send_vector(struct echoaudio *chip, u32 command);
static int get_firmware(const struct firmware **fw_entry,
			const struct firmware *frm, struct echoaudio *chip);
			struct echoaudio *chip, const short fw_index);
static void free_firmware(const struct firmware *fw_entry);

#ifdef ECHOCARD_HAS_MIDI
Loading