Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 15951
b: refs/heads/master
c: d2a6d7d
h: refs/heads/master
i:
  15949: dd5d24a
  15947: c91ab20
  15943: 83b43d6
  15935: fadc8cf
v: v3
  • Loading branch information
Takashi Iwai authored and Jaroslav Kysela committed Jan 3, 2006
1 parent 1eddc19 commit d64cb85
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 98 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 59de641ca37b88dd34d0e1d853800b488f642624
refs/heads/master: d2a6d7dc757da6b57d77bd8b460cf4faa9fd152d
48 changes: 48 additions & 0 deletions trunk/sound/pci/hda/hda_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,54 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, snd_kcontrol_new_t *knew)
}


/*
* Channel mode helper
*/
int snd_hda_ch_mode_info(struct hda_codec *codec, snd_ctl_elem_info_t *uinfo,
const struct hda_channel_mode *chmode, int num_chmodes)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
uinfo->value.enumerated.items = num_chmodes;
if (uinfo->value.enumerated.item >= num_chmodes)
uinfo->value.enumerated.item = num_chmodes - 1;
sprintf(uinfo->value.enumerated.name, "%dch",
chmode[uinfo->value.enumerated.item].channels);
return 0;
}

int snd_hda_ch_mode_get(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol,
const struct hda_channel_mode *chmode, int num_chmodes,
int max_channels)
{
int i;

for (i = 0; i < num_chmodes; i++) {
if (max_channels == chmode[i].channels) {
ucontrol->value.enumerated.item[0] = i;
break;
}
}
return 0;
}

int snd_hda_ch_mode_put(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol,
const struct hda_channel_mode *chmode, int num_chmodes,
int *max_channelsp)
{
unsigned int mode;

mode = ucontrol->value.enumerated.item[0];
snd_assert(mode < num_chmodes, return -EINVAL);
if (*max_channelsp && ! codec->in_resume)
return 0;
/* change the current channel setting */
*max_channelsp = chmode[mode].channels;
if (chmode[mode].sequence)
snd_hda_sequence_write(codec, chmode[mode].sequence);
return 1;
}

/*
* input MUX helper
*/
Expand Down
17 changes: 17 additions & 0 deletions trunk/sound/pci/hda/hda_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *i
snd_ctl_elem_value_t *ucontrol, hda_nid_t nid,
unsigned int *cur_val);

/*
* Channel mode helper
*/
struct hda_channel_mode {
int channels;
const struct hda_verb *sequence;
};

int snd_hda_ch_mode_info(struct hda_codec *codec, snd_ctl_elem_info_t *uinfo,
const struct hda_channel_mode *chmode, int num_chmodes);
int snd_hda_ch_mode_get(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol,
const struct hda_channel_mode *chmode, int num_chmodes,
int max_channels);
int snd_hda_ch_mode_put(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol,
const struct hda_channel_mode *chmode, int num_chmodes,
int *max_channelsp);

/*
* Multi-channel / digital-out PCM helper
*/
Expand Down
2 changes: 1 addition & 1 deletion trunk/sound/pci/hda/patch_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct ad198x_spec {
unsigned int cur_mux[3];

/* channel model */
const struct alc_channel_mode *channel_mode;
const struct hda_channel_mode *channel_mode;
int num_channel_mode;

/* PCM information */
Expand Down
62 changes: 17 additions & 45 deletions trunk/sound/pci/hda/patch_cmedia.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ enum {

struct cmi_spec {
int board_config;
unsigned int surr_switch: 1; /* switchable line,mic */
unsigned int no_line_in: 1; /* no line-in (5-jack) */
unsigned int front_panel: 1; /* has front-panel 2-jack */

Expand All @@ -62,9 +61,8 @@ struct cmi_spec {
unsigned int cur_mux[2];

/* channel mode */
unsigned int num_ch_modes;
unsigned int cur_ch_mode;
const struct cmi_channel_mode *channel_modes;
int num_channel_modes;
const struct hda_channel_mode *channel_modes;

struct hda_pcm pcm_rec[2]; /* PCM information */

Expand Down Expand Up @@ -158,12 +156,7 @@ static struct hda_verb cmi9880_ch8_init[] = {
{}
};

struct cmi_channel_mode {
unsigned int channels;
const struct hda_verb *sequence;
};

static struct cmi_channel_mode cmi9880_channel_modes[3] = {
static struct hda_channel_mode cmi9880_channel_modes[3] = {
{ 2, cmi9880_ch2_init },
{ 6, cmi9880_ch6_init },
{ 8, cmi9880_ch8_init },
Expand All @@ -173,43 +166,24 @@ static int cmi_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct cmi_spec *spec = codec->spec;

snd_assert(spec->channel_modes, return -EINVAL);
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
uinfo->value.enumerated.items = spec->num_ch_modes;
if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
sprintf(uinfo->value.enumerated.name, "%dch",
spec->channel_modes[uinfo->value.enumerated.item].channels);
return 0;
return snd_hda_ch_mode_info(codec, uinfo, spec->channel_modes,
spec->num_channel_modes);
}

static int cmi_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct cmi_spec *spec = codec->spec;

ucontrol->value.enumerated.item[0] = spec->cur_ch_mode;
return 0;
return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_modes,
spec->num_channel_modes, spec->multiout.max_channels);
}

static int cmi_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct cmi_spec *spec = codec->spec;

snd_assert(spec->channel_modes, return -EINVAL);
if (ucontrol->value.enumerated.item[0] >= spec->num_ch_modes)
ucontrol->value.enumerated.item[0] = spec->num_ch_modes;
if (ucontrol->value.enumerated.item[0] == spec->cur_ch_mode &&
! codec->in_resume)
return 0;

spec->cur_ch_mode = ucontrol->value.enumerated.item[0];
snd_hda_sequence_write(codec, spec->channel_modes[spec->cur_ch_mode].sequence);
spec->multiout.max_channels = spec->channel_modes[spec->cur_ch_mode].channels;
return 1;
return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_modes,
spec->num_channel_modes, &spec->multiout.max_channels);
}

/*
Expand Down Expand Up @@ -361,7 +335,7 @@ static int cmi9880_build_controls(struct hda_codec *codec)
err = snd_hda_add_new_ctls(codec, cmi9880_basic_mixer);
if (err < 0)
return err;
if (spec->surr_switch) {
if (spec->channel_modes) {
err = snd_hda_add_new_ctls(codec, cmi9880_ch_mode_mixer);
if (err < 0)
return err;
Expand Down Expand Up @@ -475,7 +449,7 @@ static int cmi9880_resume(struct hda_codec *codec)

cmi9880_init(codec);
snd_hda_resume_ctls(codec, cmi9880_basic_mixer);
if (spec->surr_switch)
if (spec->channel_modes)
snd_hda_resume_ctls(codec, cmi9880_ch_mode_mixer);
if (spec->multiout.dig_out_nid)
snd_hda_resume_spdif_out(codec);
Expand Down Expand Up @@ -685,14 +659,13 @@ static int patch_cmi9880(struct hda_codec *codec)
switch (spec->board_config) {
case CMI_MINIMAL:
case CMI_MIN_FP:
spec->surr_switch = 1;
spec->channel_modes = cmi9880_channel_modes;
if (spec->board_config == CMI_MINIMAL)
spec->num_ch_modes = 2;
spec->num_channel_modes = 2;
else {
spec->front_panel = 1;
spec->num_ch_modes = 3;
spec->num_channel_modes = 3;
}
spec->channel_modes = cmi9880_channel_modes;
spec->multiout.max_channels = cmi9880_channel_modes[0].channels;
spec->input_mux = &cmi9880_basic_mux;
break;
Expand Down Expand Up @@ -727,19 +700,18 @@ static int patch_cmi9880(struct hda_codec *codec)
get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) {
port_g = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
port_h = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
spec->surr_switch = 1;
spec->channel_modes = cmi9880_channel_modes;
/* no front panel */
if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE ||
get_defcfg_connect(port_h) == AC_JACK_PORT_NONE) {
/* no optional rear panel */
spec->board_config = CMI_MINIMAL;
spec->front_panel = 0;
spec->num_ch_modes = 2;
spec->num_channel_modes = 2;
} else {
spec->board_config = CMI_MIN_FP;
spec->num_ch_modes = 3;
spec->num_channel_modes = 3;
}
spec->channel_modes = cmi9880_channel_modes;
spec->input_mux = &cmi9880_basic_mux;
spec->multiout.max_channels = cmi9880_channel_modes[0].channels;
} else {
Expand Down
67 changes: 16 additions & 51 deletions trunk/sound/pci/hda/patch_realtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct alc_spec {
unsigned int cur_mux[3];

/* channel model */
const struct alc_channel_mode *channel_mode;
const struct hda_channel_mode *channel_mode;
int num_channel_mode;

/* PCM information */
Expand Down Expand Up @@ -157,63 +157,28 @@ static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon
/*
* channel mode setting
*/
struct alc_channel_mode {
int channels;
const struct hda_verb *sequence;
};

static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct alc_spec *spec = codec->spec;
int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;

snd_assert(spec->channel_mode, return -ENXIO);
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
uinfo->value.enumerated.items = items;
if (uinfo->value.enumerated.item >= items)
uinfo->value.enumerated.item = items - 1;
sprintf(uinfo->value.enumerated.name, "%dch",
spec->channel_mode[uinfo->value.enumerated.item].channels);
return 0;
return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
spec->num_channel_mode);
}

static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct alc_spec *spec = codec->spec;
int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
int i;

snd_assert(spec->channel_mode, return -ENXIO);
for (i = 0; i < items; i++) {
if (spec->multiout.max_channels == spec->channel_mode[i].channels) {
ucontrol->value.enumerated.item[0] = i;
break;
}
}
return 0;
return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
spec->num_channel_mode, spec->multiout.max_channels);
}

static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct alc_spec *spec = codec->spec;
int mode;

snd_assert(spec->channel_mode, return -ENXIO);
mode = ucontrol->value.enumerated.item[0] ? 1 : 0;
if (spec->multiout.max_channels == spec->channel_mode[mode].channels &&
! codec->in_resume)
return 0;

/* change the current channel setting */
spec->multiout.max_channels = spec->channel_mode[mode].channels;
if (spec->channel_mode[mode].sequence)
snd_hda_sequence_write(codec, spec->channel_mode[mode].sequence);

return 1;
return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
spec->num_channel_mode, &spec->multiout.max_channels);
}


Expand Down Expand Up @@ -328,7 +293,7 @@ static struct hda_verb alc880_threestack_ch6_init[] = {
{ } /* end */
};

static struct alc_channel_mode alc880_threestack_modes[2] = {
static struct hda_channel_mode alc880_threestack_modes[2] = {
{ 2, alc880_threestack_ch2_init },
{ 6, alc880_threestack_ch6_init },
};
Expand Down Expand Up @@ -443,7 +408,7 @@ static struct hda_verb alc880_fivestack_ch8_init[] = {
{ } /* end */
};

static struct alc_channel_mode alc880_fivestack_modes[2] = {
static struct hda_channel_mode alc880_fivestack_modes[2] = {
{ 6, alc880_fivestack_ch6_init },
{ 8, alc880_fivestack_ch8_init },
};
Expand Down Expand Up @@ -473,7 +438,7 @@ static struct hda_input_mux alc880_6stack_capture_source = {
};

/* fixed 8-channels */
static struct alc_channel_mode alc880_sixstack_modes[1] = {
static struct hda_channel_mode alc880_sixstack_modes[1] = {
{ 8, NULL },
};

Expand Down Expand Up @@ -540,7 +505,7 @@ static hda_nid_t alc880_w810_dac_nids[3] = {
};

/* fixed 6 channels */
static struct alc_channel_mode alc880_w810_modes[1] = {
static struct hda_channel_mode alc880_w810_modes[1] = {
{ 6, NULL }
};

Expand Down Expand Up @@ -572,7 +537,7 @@ static hda_nid_t alc880_z71v_dac_nids[1] = {
#define ALC880_Z71V_HP_DAC 0x03

/* fixed 2 channels */
static struct alc_channel_mode alc880_2_jack_modes[1] = {
static struct hda_channel_mode alc880_2_jack_modes[1] = {
{ 2, NULL }
};

Expand Down Expand Up @@ -1227,7 +1192,7 @@ static struct hda_input_mux alc880_test_capture_source = {
},
};

static struct alc_channel_mode alc880_test_modes[4] = {
static struct hda_channel_mode alc880_test_modes[4] = {
{ 2, NULL },
{ 4, NULL },
{ 6, NULL },
Expand Down Expand Up @@ -1585,7 +1550,7 @@ struct alc_config_preset {
unsigned int num_adc_nids;
hda_nid_t *adc_nids;
unsigned int num_channel_mode;
const struct alc_channel_mode *channel_mode;
const struct hda_channel_mode *channel_mode;
const struct hda_input_mux *input_mux;
};

Expand Down Expand Up @@ -2202,7 +2167,7 @@ static struct hda_input_mux alc260_fujitsu_capture_source = {
* element which allows changing the channel mode, so the verb list is
* never used.
*/
static struct alc_channel_mode alc260_modes[1] = {
static struct hda_channel_mode alc260_modes[1] = {
{ 2, NULL },
};

Expand Down Expand Up @@ -2506,7 +2471,7 @@ static int patch_alc260(struct hda_codec *codec)
* driver yet).
*/

static struct alc_channel_mode alc882_ch_modes[1] = {
static struct hda_channel_mode alc882_ch_modes[1] = {
{ 8, NULL }
};

Expand Down

0 comments on commit d64cb85

Please sign in to comment.