Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 133130
b: refs/heads/master
c: 97b71c9
h: refs/heads/master
v: v3
  • Loading branch information
Takashi Iwai committed Mar 19, 2009
1 parent 2505599 commit 9337348
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 66 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: 2d864c499a77129dc6aa4f7552ddf2885e4a9c47
refs/heads/master: 97b71c94d691728b82052e9c4d6286fbc9965d7f
46 changes: 32 additions & 14 deletions trunk/sound/pci/hda/hda_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1076,8 +1076,7 @@ static int azx_setup_periods(struct azx *chip,
azx_sd_writel(azx_dev, SD_BDLPL, 0);
azx_sd_writel(azx_dev, SD_BDLPU, 0);

period_bytes = snd_pcm_lib_period_bytes(substream);
azx_dev->period_bytes = period_bytes;
period_bytes = azx_dev->period_bytes;
periods = azx_dev->bufsize / period_bytes;

/* program the initial BDL entries */
Expand Down Expand Up @@ -1124,9 +1123,6 @@ static int azx_setup_periods(struct azx *chip,
error:
snd_printk(KERN_ERR "Too many BDL entries: buffer=%d, period=%d\n",
azx_dev->bufsize, period_bytes);
/* reset */
azx_sd_writel(azx_dev, SD_BDLPL, 0);
azx_sd_writel(azx_dev, SD_BDLPU, 0);
return -EINVAL;
}

Expand Down Expand Up @@ -1429,6 +1425,11 @@ static int azx_pcm_close(struct snd_pcm_substream *substream)
static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params)
{
struct azx_dev *azx_dev = get_azx_dev(substream);

azx_dev->bufsize = 0;
azx_dev->period_bytes = 0;
azx_dev->format_val = 0;
return snd_pcm_lib_malloc_pages(substream,
params_buffer_bytes(hw_params));
}
Expand All @@ -1443,6 +1444,9 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
azx_sd_writel(azx_dev, SD_BDLPL, 0);
azx_sd_writel(azx_dev, SD_BDLPU, 0);
azx_sd_writel(azx_dev, SD_CTL, 0);
azx_dev->bufsize = 0;
azx_dev->period_bytes = 0;
azx_dev->format_val = 0;

hinfo->ops.cleanup(hinfo, apcm->codec, substream);

Expand All @@ -1456,23 +1460,37 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
struct azx_dev *azx_dev = get_azx_dev(substream);
struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
struct snd_pcm_runtime *runtime = substream->runtime;
unsigned int bufsize, period_bytes, format_val;
int err;

azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream);
azx_dev->format_val = snd_hda_calc_stream_format(runtime->rate,
runtime->channels,
runtime->format,
hinfo->maxbps);
if (!azx_dev->format_val) {
format_val = snd_hda_calc_stream_format(runtime->rate,
runtime->channels,
runtime->format,
hinfo->maxbps);
if (!format_val) {
snd_printk(KERN_ERR SFX
"invalid format_val, rate=%d, ch=%d, format=%d\n",
runtime->rate, runtime->channels, runtime->format);
return -EINVAL;
}

bufsize = snd_pcm_lib_buffer_bytes(substream);
period_bytes = snd_pcm_lib_period_bytes(substream);

snd_printdd("azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
azx_dev->bufsize, azx_dev->format_val);
if (azx_setup_periods(chip, substream, azx_dev) < 0)
return -EINVAL;
bufsize, format_val);

if (bufsize != azx_dev->bufsize ||
period_bytes != azx_dev->period_bytes ||
format_val != azx_dev->format_val) {
azx_dev->bufsize = bufsize;
azx_dev->period_bytes = period_bytes;
azx_dev->format_val = format_val;
err = azx_setup_periods(chip, substream, azx_dev);
if (err < 0)
return err;
}

azx_setup_controller(chip, azx_dev);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1;
Expand Down
6 changes: 2 additions & 4 deletions trunk/sound/pci/hda/hda_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,8 @@ static void print_conn_list(struct snd_info_buffer *buffer,
{
int c, curr = -1;

if (conn_len > 1 &&
wid_type != AC_WID_AUD_MIX &&
wid_type != AC_WID_VOL_KNB &&
wid_type != AC_WID_POWER)
if (conn_len > 1 && wid_type != AC_WID_AUD_MIX &&
wid_type != AC_WID_VOL_KNB)
curr = snd_hda_codec_read(codec, nid, 0,
AC_VERB_GET_CONNECT_SEL, 0);
snd_iprintf(buffer, " Connection: %d\n", conn_len);
Expand Down
63 changes: 16 additions & 47 deletions trunk/sound/pci/hda/patch_realtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -16725,58 +16725,26 @@ static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
return 0;
}

/* return the index of the src widget from the connection list of the nid.
* return -1 if not found
*/
static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
hda_nid_t src)
{
hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
int i, conns;

conns = snd_hda_get_connections(codec, nid, conn_list,
ARRAY_SIZE(conn_list));
if (conns < 0)
return -1;
for (i = 0; i < conns; i++)
if (conn_list[i] == src)
return i;
return -1;
}

static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
{
unsigned int pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
return (pincap & AC_PINCAP_IN) != 0;
}

/* create playback/capture controls for input pins */
static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
const struct auto_pin_cfg *cfg)
{
struct alc_spec *spec = codec->spec;
struct hda_input_mux *imux = &spec->private_imux[0];
int i, err, idx;

for (i = 0; i < AUTO_PIN_LAST; i++) {
if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
idx = alc662_input_pin_idx(codec, 0x0b,
cfg->input_pins[i]);
if (idx >= 0) {
err = new_analog_input(spec, cfg->input_pins[i],
auto_pin_cfg_labels[i],
idx, 0x0b);
if (err < 0)
return err;
}
idx = alc662_input_pin_idx(codec, 0x22,
cfg->input_pins[i]);
if (idx >= 0) {
imux->items[imux->num_items].label =
auto_pin_cfg_labels[i];
imux->items[imux->num_items].index = idx;
imux->num_items++;
}
if (alc880_is_input_pin(cfg->input_pins[i])) {
idx = alc880_input_pin_idx(cfg->input_pins[i]);
err = new_analog_input(spec, cfg->input_pins[i],
auto_pin_cfg_labels[i],
idx, 0x0b);
if (err < 0)
return err;
imux->items[imux->num_items].label =
auto_pin_cfg_labels[i];
imux->items[imux->num_items].index =
alc880_input_pin_idx(cfg->input_pins[i]);
imux->num_items++;
}
}
return 0;
Expand Down Expand Up @@ -16826,6 +16794,7 @@ static void alc662_auto_init_hp_out(struct hda_codec *codec)
alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
}

#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID

static void alc662_auto_init_analog_input(struct hda_codec *codec)
Expand All @@ -16835,7 +16804,7 @@ static void alc662_auto_init_analog_input(struct hda_codec *codec)

for (i = 0; i < AUTO_PIN_LAST; i++) {
hda_nid_t nid = spec->autocfg.input_pins[i];
if (alc662_is_input_pin(codec, nid)) {
if (alc662_is_input_pin(nid)) {
alc_set_input_pin(codec, nid, i);
if (nid != ALC662_PIN_CD_NID)
snd_hda_codec_write(codec, nid, 0,
Expand Down Expand Up @@ -16875,7 +16844,7 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
"Headphone");
if (err < 0)
return err;
err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
if (err < 0)
return err;

Expand Down

0 comments on commit 9337348

Please sign in to comment.