Commit 6ef0e91e authored by Connor McAdams's avatar Connor McAdams Committed by Takashi Iwai

ALSA: hda/ca0132 - Merge post-dsp functions + cleanup

This patch cleans up some of the formatting of the post-dsp load setup
functions, and also merges some of the sub functions into individual
ones.
Signed-off-by: default avatarConnor McAdams <conmanx360@gmail.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 7a928186
...@@ -6335,69 +6335,48 @@ static void ca0132_refresh_widget_caps(struct hda_codec *codec) ...@@ -6335,69 +6335,48 @@ static void ca0132_refresh_widget_caps(struct hda_codec *codec)
} }
/* /*
* Recon3D r3d_setup_defaults sub functions. * Creates a dummy stream to bind the output to. This seems to have to be done
* after changing the main outputs source and destination streams.
*/ */
static void ca0132_alt_create_dummy_stream(struct hda_codec *codec)
static void r3d_dsp_scp_startup(struct hda_codec *codec)
{ {
unsigned int tmp; struct ca0132_spec *spec = codec->spec;
unsigned int stream_format;
tmp = 0x00000000;
dspio_set_uint_param_no_source(codec, 0x80, 0x0A, tmp);
tmp = 0x00000001;
dspio_set_uint_param_no_source(codec, 0x80, 0x0B, tmp);
tmp = 0x00000004;
dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
tmp = 0x00000005;
dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
tmp = 0x00000000;
dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
}
static void r3d_dsp_initial_mic_setup(struct hda_codec *codec) stream_format = snd_hdac_calc_stream_format(48000, 2,
{ SNDRV_PCM_FORMAT_S32_LE, 32, 0);
unsigned int tmp;
/* Mic 1 Setup */ snd_hda_codec_setup_stream(codec, spec->dacs[0], spec->dsp_stream_id,
chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); 0, stream_format);
chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000);
/* This ConnPointID is unique to Recon3Di. Haven't seen it elsewhere */
chipio_set_conn_rate(codec, 0x0F, SR_96_000);
tmp = FLOAT_ONE;
dspio_set_uint_param(codec, 0x80, 0x00, tmp);
/* Mic 2 Setup, even though it isn't connected on SBZ */ snd_hda_codec_cleanup_stream(codec, spec->dacs[0]);
chipio_set_conn_rate(codec, MEM_CONNID_MICIN2, SR_96_000);
chipio_set_conn_rate(codec, MEM_CONNID_MICOUT2, SR_96_000);
chipio_set_conn_rate(codec, 0x0F, SR_96_000);
tmp = FLOAT_ZERO;
dspio_set_uint_param(codec, 0x80, 0x01, tmp);
} }
/* /*
* Initialize Sound Blaster Z analog microphones. * Initialize mic for non-chromebook ca0132 implementations.
*/ */
static void sbz_init_analog_mics(struct hda_codec *codec) static void ca0132_alt_init_analog_mics(struct hda_codec *codec)
{ {
struct ca0132_spec *spec = codec->spec;
unsigned int tmp; unsigned int tmp;
/* Mic 1 Setup */ /* Mic 1 Setup */
chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000);
chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000);
tmp = FLOAT_THREE; if (spec->quirk == QUIRK_R3DI) {
chipio_set_conn_rate(codec, 0x0F, SR_96_000);
tmp = FLOAT_ONE;
} else
tmp = FLOAT_THREE;
dspio_set_uint_param(codec, 0x80, 0x00, tmp); dspio_set_uint_param(codec, 0x80, 0x00, tmp);
/* Mic 2 Setup, even though it isn't connected on SBZ */ /* Mic 2 setup (not present on desktop cards) */
chipio_set_conn_rate(codec, MEM_CONNID_MICIN2, SR_96_000); chipio_set_conn_rate(codec, MEM_CONNID_MICIN2, SR_96_000);
chipio_set_conn_rate(codec, MEM_CONNID_MICOUT2, SR_96_000); chipio_set_conn_rate(codec, MEM_CONNID_MICOUT2, SR_96_000);
if (spec->quirk == QUIRK_R3DI)
chipio_set_conn_rate(codec, 0x0F, SR_96_000);
tmp = FLOAT_ZERO; tmp = FLOAT_ZERO;
dspio_set_uint_param(codec, 0x80, 0x01, tmp); dspio_set_uint_param(codec, 0x80, 0x01, tmp);
} }
/* /*
...@@ -6430,7 +6409,6 @@ static void sbz_connect_streams(struct hda_codec *codec) ...@@ -6430,7 +6409,6 @@ static void sbz_connect_streams(struct hda_codec *codec)
codec_dbg(codec, "Connect Streams exited, mutex released.\n"); codec_dbg(codec, "Connect Streams exited, mutex released.\n");
mutex_unlock(&spec->chipio_mutex); mutex_unlock(&spec->chipio_mutex);
} }
/* /*
...@@ -6477,35 +6455,49 @@ static void sbz_chipio_startup_data(struct hda_codec *codec) ...@@ -6477,35 +6455,49 @@ static void sbz_chipio_startup_data(struct hda_codec *codec)
} }
/* /*
* Sound Blaster Z uses these after DSP is loaded. Weird SCP commands * Custom DSP SCP commands where the src value is 0x00 instead of 0x20. This is
* without a 0x20 source like normal. * done after the DSP is loaded.
*/ */
static void sbz_dsp_scp_startup(struct hda_codec *codec) static void ca0132_alt_dsp_scp_startup(struct hda_codec *codec)
{ {
struct ca0132_spec *spec = codec->spec;
unsigned int tmp; unsigned int tmp;
tmp = 0x00000003; switch (spec->quirk) {
dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp); case QUIRK_SBZ:
case QUIRK_AE5:
tmp = 0x00000000; tmp = 0x00000003;
dspio_set_uint_param_no_source(codec, 0x80, 0x0A, tmp); dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
tmp = 0x00000000;
tmp = 0x00000001; dspio_set_uint_param_no_source(codec, 0x80, 0x0A, tmp);
dspio_set_uint_param_no_source(codec, 0x80, 0x0B, tmp); tmp = 0x00000001;
dspio_set_uint_param_no_source(codec, 0x80, 0x0B, tmp);
tmp = 0x00000004; tmp = 0x00000004;
dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp); dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
tmp = 0x00000005;
tmp = 0x00000005; dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp); tmp = 0x00000000;
dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
tmp = 0x00000000; break;
dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp); case QUIRK_R3D:
case QUIRK_R3DI:
tmp = 0x00000000;
dspio_set_uint_param_no_source(codec, 0x80, 0x0A, tmp);
tmp = 0x00000001;
dspio_set_uint_param_no_source(codec, 0x80, 0x0B, tmp);
tmp = 0x00000004;
dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
tmp = 0x00000005;
dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
tmp = 0x00000000;
dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
break;
}
} }
static void sbz_dsp_initial_mic_setup(struct hda_codec *codec) static void ca0132_alt_dsp_initial_mic_setup(struct hda_codec *codec)
{ {
struct ca0132_spec *spec = codec->spec;
unsigned int tmp; unsigned int tmp;
chipio_set_stream_control(codec, 0x03, 0); chipio_set_stream_control(codec, 0x03, 0);
...@@ -6520,8 +6512,16 @@ static void sbz_dsp_initial_mic_setup(struct hda_codec *codec) ...@@ -6520,8 +6512,16 @@ static void sbz_dsp_initial_mic_setup(struct hda_codec *codec)
chipio_set_stream_control(codec, 0x03, 1); chipio_set_stream_control(codec, 0x03, 1);
chipio_set_stream_control(codec, 0x04, 1); chipio_set_stream_control(codec, 0x04, 1);
chipio_write(codec, 0x18b098, 0x0000000c); switch (spec->quirk) {
chipio_write(codec, 0x18b09C, 0x0000000c); case QUIRK_SBZ:
chipio_write(codec, 0x18b098, 0x0000000c);
chipio_write(codec, 0x18b09C, 0x0000000c);
break;
case QUIRK_AE5:
chipio_write(codec, 0x18b098, 0x0000000c);
chipio_write(codec, 0x18b09c, 0x0000004c);
break;
}
} }
/* /*
...@@ -6582,9 +6582,8 @@ static void r3d_setup_defaults(struct hda_codec *codec) ...@@ -6582,9 +6582,8 @@ static void r3d_setup_defaults(struct hda_codec *codec)
if (spec->dsp_state != DSP_DOWNLOADED) if (spec->dsp_state != DSP_DOWNLOADED)
return; return;
r3d_dsp_scp_startup(codec); ca0132_alt_dsp_scp_startup(codec);
ca0132_alt_init_analog_mics(codec);
r3d_dsp_initial_mic_setup(codec);
/*remove DSP headroom*/ /*remove DSP headroom*/
tmp = FLOAT_ZERO; tmp = FLOAT_ZERO;
...@@ -6620,19 +6619,16 @@ static void r3d_setup_defaults(struct hda_codec *codec) ...@@ -6620,19 +6619,16 @@ static void r3d_setup_defaults(struct hda_codec *codec)
static void sbz_setup_defaults(struct hda_codec *codec) static void sbz_setup_defaults(struct hda_codec *codec)
{ {
struct ca0132_spec *spec = codec->spec; struct ca0132_spec *spec = codec->spec;
unsigned int tmp, stream_format; unsigned int tmp;
int num_fx; int num_fx;
int idx, i; int idx, i;
if (spec->dsp_state != DSP_DOWNLOADED) if (spec->dsp_state != DSP_DOWNLOADED)
return; return;
sbz_dsp_scp_startup(codec); ca0132_alt_dsp_scp_startup(codec);
ca0132_alt_init_analog_mics(codec);
sbz_init_analog_mics(codec);
sbz_connect_streams(codec); sbz_connect_streams(codec);
sbz_chipio_startup_data(codec); sbz_chipio_startup_data(codec);
chipio_set_stream_control(codec, 0x03, 1); chipio_set_stream_control(codec, 0x03, 1);
...@@ -6658,8 +6654,7 @@ static void sbz_setup_defaults(struct hda_codec *codec) ...@@ -6658,8 +6654,7 @@ static void sbz_setup_defaults(struct hda_codec *codec)
/* Set speaker source? */ /* Set speaker source? */
dspio_set_uint_param(codec, 0x32, 0x00, tmp); dspio_set_uint_param(codec, 0x32, 0x00, tmp);
sbz_dsp_initial_mic_setup(codec); ca0132_alt_dsp_initial_mic_setup(codec);
/* out, in effects + voicefx */ /* out, in effects + voicefx */
num_fx = OUT_EFFECTS_COUNT + IN_EFFECTS_COUNT + 1; num_fx = OUT_EFFECTS_COUNT + IN_EFFECTS_COUNT + 1;
...@@ -6672,23 +6667,7 @@ static void sbz_setup_defaults(struct hda_codec *codec) ...@@ -6672,23 +6667,7 @@ static void sbz_setup_defaults(struct hda_codec *codec)
} }
} }
/* ca0132_alt_create_dummy_stream(codec);
* Have to make a stream to bind the sound output to, otherwise
* you'll get dead audio. Before I did this, it would bind to an
* audio input, and would never work
*/
stream_format = snd_hdac_calc_stream_format(48000, 2,
SNDRV_PCM_FORMAT_S32_LE, 32, 0);
snd_hda_codec_setup_stream(codec, spec->dacs[0], spec->dsp_stream_id,
0, stream_format);
snd_hda_codec_cleanup_stream(codec, spec->dacs[0]);
snd_hda_codec_setup_stream(codec, spec->dacs[0], spec->dsp_stream_id,
0, stream_format);
snd_hda_codec_cleanup_stream(codec, spec->dacs[0]);
} }
/* /*
...@@ -6774,7 +6753,7 @@ static bool ca0132_download_dsp_images(struct hda_codec *codec) ...@@ -6774,7 +6753,7 @@ static bool ca0132_download_dsp_images(struct hda_codec *codec)
case QUIRK_AE5: case QUIRK_AE5:
if (request_firmware(&fw_entry, DESKTOP_EFX_FILE, if (request_firmware(&fw_entry, DESKTOP_EFX_FILE,
codec->card->dev) != 0) { codec->card->dev) != 0) {
codec_dbg(codec, "Desktop firmware not found. "); codec_dbg(codec, "Desktop firmware not found.");
spec->alt_firmware_present = false; spec->alt_firmware_present = false;
} else { } else {
codec_dbg(codec, "Desktop firmware selected."); codec_dbg(codec, "Desktop firmware selected.");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment