[alsa-devel] [PATCH v4 5/5] ALSA: hda - hdmi: Notify userspace when ELD control changes

Takashi Iwai tiwai at suse.de
Tue Feb 19 15:12:12 CET 2013


At Tue, 19 Feb 2013 13:23:05 +0100,
David Henningsson wrote:
> 
> ELD validity can change during the lifetime of a presence detect,
> so we need to be able to listen for changes on the ELD control.
> 
> Signed-off-by: David Henningsson <david.henningsson at canonical.com>
> ---
>  sound/pci/hda/patch_hdmi.c |   14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
> index ec3ff3f..a6b5ad0 100644
> --- a/sound/pci/hda/patch_hdmi.c
> +++ b/sound/pci/hda/patch_hdmi.c
> @@ -75,6 +75,7 @@ struct hdmi_spec_per_pin {
>  	struct hda_codec *codec;
>  	struct hdmi_eld sink_eld;
>  	struct delayed_work work;
> +	struct snd_kcontrol *eld_ctl;
>  	int repoll_count;
>  	bool non_pcm;
>  	bool chmap_set;		/* channel-map override by ALSA API? */
> @@ -411,6 +412,7 @@ static int hdmi_create_eld_ctl(struct hda_codec *codec, int pin_idx,
>  	if (err < 0)
>  		return err;
>  
> +	spec->pins[pin_idx].eld_ctl = kctl;
>  	return 0;
>  }
>  
> @@ -1217,19 +1219,27 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
>  	}
>  
>  	mutex_lock(&pin_eld->lock);
> -	if (pin_eld->eld_valid && !eld->eld_valid)
> +	if (pin_eld->eld_valid && !eld->eld_valid) {
>  		update_eld = true;
> +		eld_changed = true;
> +	}
>  	if (update_eld) {
>  		pin_eld->eld_valid = eld->eld_valid;
> -		eld_changed = memcmp(pin_eld->eld_buffer, eld->eld_buffer,
> +		eld_changed |= memcmp(pin_eld->eld_buffer, eld->eld_buffer,
>  				     eld->eld_size) != 0;
>  		if (eld_changed)
>  			memcpy(pin_eld->eld_buffer, eld->eld_buffer,
>  			       eld->eld_size);
> +		eld_changed |= pin_eld->eld_size != eld->eld_size;

The size check should be done before memcmp().  memcmp() can be
skipped if it's already set true.

 	if (update_eld) {
 		pin_eld->eld_valid = eld->eld_valid;
		eld_changed |= pin_eld->eld_size != eld->eld_size;
		if (!eld_changed)
			eld_changed = memcmp(pin_eld->eld_buffer, eld->eld_buffer,
 				     eld->eld_size) != 0;
		if (eld_changed)
			memcpy(pin_eld->eld_buffer, eld->eld_buffer,
			       eld->eld_size);

 		pin_eld->eld_size = eld->eld_size;
 		pin_eld->info = eld->info;
 	}


Takashi


More information about the Alsa-devel mailing list