Re: [PATCH 1/2] enable capture from line-in and CD on Revolution 5.1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At Wed, 4 Oct 2006 00:27:57 +0100,
Jochen Voss wrote:
> 
> Enable capture from line-in and CD on the Revolution 5.1 card.
> 
> This patch adds support for switching between the 5 input channels of
> the AK5365 ADC and modifies the Revolution 5.1 driver to make use of
> this facility.  Previously the capture channel was fixed to channel 0
> (microphone on the Revolution 5.1 card).
> 
> Signed-off-by: Jochen Voss <voss@xxxxxxxxxx>

Thanks, the patch is almost good but needs small fixes as follows:


> diff -ur -x sound alsa-driver-hg20060929.orig/alsa-kernel/i2c/other/ak4xxx-adda.c alsa-driver-hg20060929/alsa-kernel/i2c/other/ak4xxx-adda.c
> --- alsa-driver-hg20060929.orig/alsa-kernel/i2c/other/ak4xxx-adda.c	2006-09-09 01:00:11.000000000 +0100
> +++ alsa-driver-hg20060929/alsa-kernel/i2c/other/ak4xxx-adda.c	2006-10-03 20:47:35.677261631 +0100
> @@ -513,6 +513,61 @@
>  	return change;
>  }
>  
> +static int ak4xxx_capture_source_info(struct snd_kcontrol *kcontrol,
> +				      struct snd_ctl_elem_info *uinfo)
> +{
> +	struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
> +	int mixer_ch = AK_GET_SHIFT(kcontrol->private_value);
> +	const char **input_names;
> +	int  num_names, idx;
> +
> +	input_names = ak->adc_info[mixer_ch].input_names;
> +
> +	num_names = 0;
> +	while (num_names<5 && input_names[num_names])

White space around '<', and define a constant for 5, please.

> +		++num_names;
> +	
> +	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
> +	uinfo->count = 1;
> +	uinfo->value.enumerated.items = num_names;
> +	idx = uinfo->value.enumerated.item;
> +	if (idx >= num_names) return -1;

Break a line, and return a meaningful error code, e.g. -EINVAL.

> +	strncpy(uinfo->value.enumerated.name, input_names[idx],
> +		sizeof(uinfo->value.enumerated.name));
> +	return 0;
> +}
> +
> +static int ak4xxx_capture_source_get(struct snd_kcontrol *kcontrol,
> +				     struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
> +	int chip = AK_GET_CHIP(kcontrol->private_value);
> +	int addr = AK_GET_ADDR(kcontrol->private_value);
> +	int mask = AK_GET_MASK(kcontrol->private_value);
> +	unsigned char val;
> +
> +	val = snd_akm4xxx_get(ak, chip, addr)&mask;

Put spaces around '&'.

> +        ucontrol->value.enumerated.item[0] = val;

Indentation?

> +	return 0;
> +}
> +
> +static int ak4xxx_capture_source_put(struct snd_kcontrol *kcontrol,
> +				     struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
> +	int chip = AK_GET_CHIP(kcontrol->private_value);
> +	int addr = AK_GET_ADDR(kcontrol->private_value);
> +	int mask = AK_GET_MASK(kcontrol->private_value);
> +	unsigned char oval, val;
> +
> +	oval = snd_akm4xxx_get(ak, chip, addr);
> +	val = oval & ~mask;
> +	val |= ucontrol->value.enumerated.item[0]&mask;
> +	if (val != oval)
> +		snd_akm4xxx_write(ak, chip, addr, val);
> +	return 0;

The put callback should return 1 if the value is changed and 0 if the
value is unchanged.  That is, such as:

	if (val != oval) {
		snd_akm4xxx_write(ak, chip, addr, val);
		return 1;
	}
	return 0;


> +}
> +
>  /*
>   * build AK4xxx controls
>   */
> @@ -647,10 +702,12 @@
>  
>  		if (ak->type == SND_AK5365 && (idx % 2) == 0) {
>  			if (! ak->adc_info || 
> -			    ! ak->adc_info[mixer_ch].switch_name)
> +			    ! ak->adc_info[mixer_ch].switch_name) {
>  				knew.name = "Capture Switch";
> -			else
> +				knew.index = mixer_ch + ak->idx_offset * 2;
> +			} else {
>  				knew.name = ak->adc_info[mixer_ch].switch_name;
> +			}

Don't put braces around a single-line if.


Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux