[alsa-devel] [PATCH v2] ASoC: Add support for cs42l73 codec

Austin, Brian Brian.Austin at cirrus.com
Tue Oct 4 21:17:16 CEST 2011


>> 
>> 
>> 
>>> +	if (spc & xSPDIF_PCM) {
>>> +		spc &= (31 << 3);	/* Clear PCM mode, set MSB->LSB */
>>> +		if (format == SND_SOC_DAIFMT_DSP_B
>>> +		    && inv == SND_SOC_DAIFMT_IB_IF)
>>> +			spc |= (xPCM_MODE0 << 4);
>>> +		else
>>> +
>>> +		    if (format == SND_SOC_DAIFMT_DSP_B
>>> +				&& inv == SND_SOC_DAIFMT_IB_NF)
>>> +			spc |= (xPCM_MODE1 << 4);
>>> +		else
>>> +
>>> +		    if (format == SND_SOC_DAIFMT_DSP_A
>>> +				&& inv == SND_SOC_DAIFMT_IB_IF)
>>> +			spc |= (xPCM_MODE1 << 4);
>>> +		else
>>> +			return -EINVAL;
>> 
>> I can't help but feel this would be clearer with a switch statement.
> 
> I'm trying to make this look better...
> 

        if (spc & xSPDIF_PCM) {
                spc &= (31 << 3);       /* Clear PCM mode, set MSB->LSB */
                switch(format){
                        case SND_SOC_DAIFMT_DSP_B:
                                if (inv == SND_SOC_DAIFMT_IB_IF)
                                        spc |= (xPCM_MODE0 << 4);
                                
                                if (inv == SND_SOC_DAIFMT_IB_NF)
                                        spc |= (xPCM_MODE1 << 4);
                                break;
                        case SND_SOC_DAIFMT_DSP_A:
                                if (inv == SND_SOC_DAIFMT_IB_IF)
                                        spc |= (xPCM_MODE1 << 4);
                                break;
                        default:
                                return -EINVAL;
                }
        }

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3917 bytes
Desc: not available
Url : http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20111004/eb0ee494/attachment-0001.p7s 


More information about the Alsa-devel mailing list