[alsa-devel] [PATCH v2] ASoC: hdac_hdmi: Program pin-port-mux during jack report event

Takashi Iwai tiwai at suse.de
Wed Jul 11 08:45:05 CEST 2018


On Wed, 11 Jul 2018 08:30:43 +0200,
Sriram Periyasamy wrote:
> 
> @@ -167,6 +171,30 @@ static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm,
>  
>  	if (is_connect) {
>  		/*
> +		 * Increment the usage count to ensure that the device
> +		 * is runtime active to send verb across.
> +		 */
> +		pm_runtime_get_sync(&edev->hdev.dev);

This looks more reasonable now, but...

> +		/* set the device if pin is mst_capable */
> +		if (hdac_hdmi_port_select_set(edev, port) < 0) {
> +			dev_err(&edev->hdev.dev,
> +				"port %d device select fail\n", port->id);
> +			return;

It appears like an unbalanced pm refcount here in the error path.

> +		}
> +
> +		/*
> +		 * Restore the connection selection index of the
> +		 * respective pin.
> +		 */
> +		if (port->pin->conn_index > 0)
> +			snd_hdac_codec_write(&edev->hdev, port->pin->nid,
> +						0, AC_VERB_SET_CONNECT_SEL,
> +						port->pin->conn_index - 1);

And, here checks conn_index > 0 while...

> @@ -903,6 +931,9 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol,
>  		}
>  	}
>  
> +	if (ucontrol->value.enumerated.item[0] > 0)
> +		port->pin->conn_index =	ucontrol->value.enumerated.item[0];

... conn_index is set only non-zero here.

That is, once after a non-zero is passed, conn_index can't any longer
back to zero.  I guess it's not intentional?


thanks,

Takashi


More information about the Alsa-devel mailing list