Skip to content
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.

Commit

Permalink
HDMI: update `silent_stream' implementation
Browse files Browse the repository at this point in the history
Some struct fiels were missing and the kernel was using an
old failing implementation of `silent_stream_enable'.
  • Loading branch information
Javinator9889 committed Jan 15, 2021
1 parent b85c492 commit b460ef4
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 13 deletions.
63 changes: 51 additions & 12 deletions sound/pci/hda/patch_hdmi.c
Expand Up @@ -78,6 +78,7 @@ struct hdmi_spec_per_pin {
int pcm_idx; /* which pcm is attached. -1 means no pcm is attached */
int repoll_count;
bool setup; /* the stream has been set up by prepare callback */
bool silent_stream;
int channels; /* current number of channels */
bool non_pcm;
bool chmap_set; /* channel-map override by ALSA API? */
Expand Down Expand Up @@ -1642,27 +1643,65 @@ static void hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
snd_hda_power_down_pm(codec);
}

#define I915_SILENT_RATE 48000
#define I915_SILENT_CHANNELS 2
#define I915_SILENT_FORMAT SNDRV_PCM_FORMAT_S16_LE
#define I915_SILENT_FORMAT_BITS 16
#define I915_SILENT_FMT_MASK 0xf

static void silent_stream_enable(struct hda_codec *codec,
struct hdmi_spec_per_pin *per_pin)
struct hdmi_spec_per_pin *per_pin)
{
unsigned int newval, oldval;

codec_dbg(codec, "hdmi: enabling silent stream for NID %d\n",
per_pin->pin_nid);
struct hdmi_spec *spec = codec->spec;
struct hdmi_spec_per_cvt *per_cvt;
int cvt_idx, pin_idx, err;
unsigned int format;

mutex_lock(&per_pin->lock);

if (!per_pin->channels)
per_pin->channels = 2;
if (per_pin->setup) {
codec_dbg(codec, "hdmi: PCM already open, no silent stream\n");
goto unlock_out;
}

oldval = snd_hda_codec_read(codec, per_pin->pin_nid, 0,
AC_VERB_GET_CONV, 0);
newval = (oldval & 0xF0) | 0xF;
snd_hda_codec_write(codec, per_pin->pin_nid, 0,
AC_VERB_SET_CHANNEL_STREAMID, newval);
pin_idx = pin_id_to_pin_index(codec, per_pin->pin_nid, per_pin->dev_id);
err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx);
if (err) {
codec_err(codec, "hdmi: no free converter to enable silent mode\n");
goto unlock_out;
}

per_cvt = get_cvt(spec, cvt_idx);
per_cvt->assigned = 1;
per_pin->cvt_nid = per_cvt->cvt_nid;
per_pin->silent_stream = true;

codec_dbg(codec, "hdmi: enabling silent stream pin-NID=0x%x cvt-NID=0x%x\n",
per_pin->pin_nid, per_cvt->cvt_nid);

snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id);
snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0,
AC_VERB_SET_CONNECT_SEL,
per_pin->mux_idx);

/* configure unused pins to choose other converters */
pin_cvt_fixup(codec, per_pin, 0);

snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid,
per_pin->dev_id, I915_SILENT_RATE);

/* trigger silent stream generation in hw */
format = snd_hdac_calc_stream_format(I915_SILENT_RATE, I915_SILENT_CHANNELS,
I915_SILENT_FORMAT, I915_SILENT_FORMAT_BITS, 0);
snd_hda_codec_setup_stream(codec, per_pin->cvt_nid,
I915_SILENT_FMT_MASK, I915_SILENT_FMT_MASK, format);
usleep_range(100, 200);
snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, I915_SILENT_FMT_MASK, 0, format);

per_pin->channels = I915_SILENT_CHANNELS;
hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm);

unlock_out:
mutex_unlock(&per_pin->lock);
}

Expand Down
Binary file removed tools/laptop/freefall/freefall
Binary file not shown.
1 change: 0 additions & 1 deletion tools/pci/include/linux/pcitest.h

This file was deleted.

Binary file removed tools/pci/pcitest
Binary file not shown.
Binary file not shown.
Binary file removed tools/wmi/dell-smbios-example
Binary file not shown.

0 comments on commit b460ef4

Please sign in to comment.