Merge branch 'topic/hda-reconfig' into topic/hda-next
This commit is contained in:
@@ -36,7 +36,6 @@
|
||||
#include "hda_patch.h"
|
||||
#include "hda_beep.h"
|
||||
|
||||
#define NUM_CONTROL_ALLOC 32
|
||||
#define STAC_PWR_EVENT 0x20
|
||||
#define STAC_HP_EVENT 0x30
|
||||
#define STAC_VREF_EVENT 0x40
|
||||
@@ -222,8 +221,7 @@ struct sigmatel_spec {
|
||||
|
||||
/* dynamic controls and input_mux */
|
||||
struct auto_pin_cfg autocfg;
|
||||
unsigned int num_kctl_alloc, num_kctl_used;
|
||||
struct snd_kcontrol_new *kctl_alloc;
|
||||
struct snd_array kctls;
|
||||
struct hda_input_mux private_dimux;
|
||||
struct hda_input_mux private_imux;
|
||||
struct hda_input_mux private_smux;
|
||||
@@ -1237,6 +1235,8 @@ static const char *slave_sws[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static void stac92xx_free_kctls(struct hda_codec *codec);
|
||||
|
||||
static int stac92xx_build_controls(struct hda_codec *codec)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
@@ -1254,7 +1254,7 @@ static int stac92xx_build_controls(struct hda_codec *codec)
|
||||
}
|
||||
if (spec->num_dmuxes > 0) {
|
||||
stac_dmux_mixer.count = spec->num_dmuxes;
|
||||
err = snd_ctl_add(codec->bus->card,
|
||||
err = snd_hda_ctl_add(codec,
|
||||
snd_ctl_new1(&stac_dmux_mixer, codec));
|
||||
if (err < 0)
|
||||
return err;
|
||||
@@ -1309,6 +1309,7 @@ static int stac92xx_build_controls(struct hda_codec *codec)
|
||||
return err;
|
||||
}
|
||||
|
||||
stac92xx_free_kctls(codec); /* no longer needed */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2596,28 +2597,16 @@ static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
|
||||
{
|
||||
struct snd_kcontrol_new *knew;
|
||||
|
||||
if (spec->num_kctl_used >= spec->num_kctl_alloc) {
|
||||
int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
|
||||
|
||||
knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
|
||||
if (! knew)
|
||||
return -ENOMEM;
|
||||
if (spec->kctl_alloc) {
|
||||
memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
|
||||
kfree(spec->kctl_alloc);
|
||||
}
|
||||
spec->kctl_alloc = knew;
|
||||
spec->num_kctl_alloc = num;
|
||||
}
|
||||
|
||||
knew = &spec->kctl_alloc[spec->num_kctl_used];
|
||||
snd_array_init(&spec->kctls, sizeof(*knew), 32);
|
||||
knew = snd_array_new(&spec->kctls);
|
||||
if (!knew)
|
||||
return -ENOMEM;
|
||||
*knew = stac92xx_control_templates[type];
|
||||
knew->index = idx;
|
||||
knew->name = kstrdup(name, GFP_KERNEL);
|
||||
if (! knew->name)
|
||||
return -ENOMEM;
|
||||
knew->private_value = val;
|
||||
spec->num_kctl_used++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3438,8 +3427,8 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
|
||||
if (dig_in && spec->autocfg.dig_in_pin)
|
||||
spec->dig_in_nid = dig_in;
|
||||
|
||||
if (spec->kctl_alloc)
|
||||
spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
|
||||
if (spec->kctls.list)
|
||||
spec->mixers[spec->num_mixers++] = spec->kctls.list;
|
||||
|
||||
spec->input_mux = &spec->private_imux;
|
||||
spec->dinput_mux = &spec->private_dimux;
|
||||
@@ -3540,8 +3529,8 @@ static int stac9200_parse_auto_config(struct hda_codec *codec)
|
||||
if (spec->autocfg.dig_in_pin)
|
||||
spec->dig_in_nid = 0x04;
|
||||
|
||||
if (spec->kctl_alloc)
|
||||
spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
|
||||
if (spec->kctls.list)
|
||||
spec->mixers[spec->num_mixers++] = spec->kctls.list;
|
||||
|
||||
spec->input_mux = &spec->private_imux;
|
||||
spec->dinput_mux = &spec->private_dimux;
|
||||
@@ -3708,20 +3697,26 @@ static int stac92xx_init(struct hda_codec *codec)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void stac92xx_free_kctls(struct hda_codec *codec)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
|
||||
if (spec->kctls.list) {
|
||||
struct snd_kcontrol_new *kctl = spec->kctls.list;
|
||||
int i;
|
||||
for (i = 0; i < spec->kctls.used; i++)
|
||||
kfree(kctl[i].name);
|
||||
}
|
||||
snd_array_free(&spec->kctls);
|
||||
}
|
||||
|
||||
static void stac92xx_free(struct hda_codec *codec)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
int i;
|
||||
|
||||
if (! spec)
|
||||
return;
|
||||
|
||||
if (spec->kctl_alloc) {
|
||||
for (i = 0; i < spec->num_kctl_used; i++)
|
||||
kfree(spec->kctl_alloc[i].name);
|
||||
kfree(spec->kctl_alloc);
|
||||
}
|
||||
|
||||
if (spec->bios_pin_configs)
|
||||
kfree(spec->bios_pin_configs);
|
||||
|
||||
|
Reference in New Issue
Block a user