This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

read error: Input/output error

I'm porting the wm8960 codec to a am335x board with the kernel (ti-sdk-am335x-evm-07.00.00.00 -> linux-3.12.10-ti2013.12.01)

I have modified the davicin-evm.c, wm8960.c and dts file.

Then I can see these logs:

[    1.975425] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
[    1.983944] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 100 kHz
[    1.990694] edma-dma-engine edma-dma-engine.0: allocated channel for 0:25
[    1.997961] edma-dma-engine edma-dma-engine.0: allocated channel for 0:24
[    2.037707] wm8960 0-001a: No platform data supplied
[    2.042946] wm8960 0-001a: Failed to create debugfs directory
[    2.125253] mmc1: host does not support reading read-only switch. assuming write-enable.
[    2.136520] mmc1: new high speed SDHC card at address aaaa
[    2.142984] mmcblk0: mmc1:aaaa SL16G 14.8 GiB 
[    2.149158]  mmcblk0: p1 p2
[    2.160190] +tq335x_wm8960_init()
[    2.163724] *tq335x_wm8960_init(): dapm sync start
[    2.168776] *tq335x_wm8960_init(): dapm sync end
[    2.173615] -tq335x_wm8960_init()
[    2.177977] davinci_evm sound.3:  wm8960-hifi <-> 4803c000.mcasp mapping ok
[    2.247106] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6
[    2.253514] davinci_mdio 4a101000.mdio: detected phy mask ffffffde
[    2.261198] libphy: 4a101000.mdio: probed
[    2.265421] davinci_mdio 4a101000.mdio: phy[0]: device 4a101000.mdio:00, driver unknown
[    2.273841] davinci_mdio 4a101000.mdio: phy[5]: device 4a101000.mdio:05, driver unknown
[    2.282944] Detected MACID = c4:ed:ba:88:b5:e4
[    2.289708] input: volume_keys.8 as /devices/volume_keys.8/input/input2
[    2.297467] omap_rtc 44e3e000.rtc: setting system clock to 2000-01-01 00:00:00 UTC (946684800)
[    2.309129] ALSA device list:
[    2.312267]   #0: AM335x-EVM

But, when record with arecord I get the error message:

arecord: pcm_read:2031: read error: Input/output error

When play a wav file with aplay, I get the error message:

aplay: pcm_write:1939: write error: Input/output error

What should I do?

Because I can not upload any file here, I put the source code and schematic on my net disk.

The following is the link:

http://pan.baidu.com/s/1sjPoRcp

  • The link:
    http://pan.baidu.com/s/1dDzoUbf
  • Hi,

    Have you configured your pinmux correctly?

  • I keep the default pinmux configuration in am335x-evm.dts.

    The following is my hw_params function:

    static int tq335x_wm8960_hw_params(struct snd_pcm_substream *substream,
            struct snd_pcm_hw_params *params)
    {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
        unsigned int rate = params_rate(params);
        snd_pcm_format_t fmt = params_format(params);
        unsigned sysclk;
        int ret = 0;
        struct snd_soc_card_drvdata_davinci *drvdata =
    		(struct snd_soc_card_drvdata_davinci *)snd_soc_card_get_drvdata(codec_dai->card);
    
        int bclk_div;
        int dacdiv;
    
        dprintk("+%s()\n", __func__ );
    
        switch (fmt) {
        case SNDRV_PCM_FORMAT_S16:
            bclk_div = 32;
            break;
        case SNDRV_PCM_FORMAT_S20_3LE:
        case SNDRV_PCM_FORMAT_S24:
            bclk_div = 48;
            break;
        default:
            dprintk("-%s(): PCM FMT ERROR\n", __func__ );
            return -EINVAL;
        }
    
        switch (rate) {
        case 8018:
            dacdiv = WM8960_DAC_DIV_5_5;
            sysclk = 11289600;
            break;
        case 11025:
            dacdiv = WM8960_DAC_DIV_4;
            sysclk = 11289600;
            break;
        case 22050:
            dacdiv = WM8960_DAC_DIV_2;
            sysclk = 11289600;
            break;
        case 44100:
            dacdiv = WM8960_DAC_DIV_1;
            sysclk = 11289600;
            break;
        case 8000:
            dacdiv = WM8960_DAC_DIV_6;
            sysclk = 12288000;
            break;
        case 12000:
            dacdiv = WM8960_DAC_DIV_4;
            sysclk = 12288000;
            break;
        case 16000:
            dacdiv = WM8960_DAC_DIV_3;
            sysclk = 12288000;
            break;
        case 24000:
            dacdiv = WM8960_DAC_DIV_2;
            sysclk = 12288000;
            break;
        case 32000:
            dacdiv = WM8960_DAC_DIV_1_5;
            sysclk = 12288000;
            break;
        case 48000:
            dacdiv = WM8960_DAC_DIV_1;
            sysclk = 12288000;
            break;
        default:
            dprintk("-%s(): SND RATE ERROR (%d)\n", __func__,rate );
            return -EINVAL;
        }
        dprintk("-%s(): rate is %d\n", __func__,rate );
    
        /**
         * Source clock is 24.576M, devide into 12.288M.
         */
        ret = snd_soc_dai_set_clkdiv(codec_dai, WM8960_SYSCLKDIV, WM8960_SYSCLK_DIV_2);
        if( ret < 0 ){
            dprintk("-%s(): Codec SYSCLKDIV setting error, %d\n", __func__, ret);
            return ret;
        }
    
        ret = snd_soc_dai_set_clkdiv(codec_dai, WM8960_DACDIV, dacdiv);
        if( ret < 0 ){
            dprintk("-%s(): Codec WM8960_DACDIV setting error, %d\n", __func__, ret);
            return ret;
        }
    
        ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT);
        if( ret < 0 ){
            dprintk("-%s(): Codec DAI configuration error, %d\n", __func__, ret);
            return ret;
        }
    
        ret = snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT);
        if( ret < 0 ){
            dprintk("-%s(): AP DAI configuration error, %d\n", __func__, ret);
            return ret;
        }
    
        ret = snd_soc_dai_set_pll(codec_dai, 0, 0, drvdata->sysclk, sysclk);
        if (ret < 0) {
        	dprintk("-%s(): Codec DAI set pll failed.");
        }
        dprintk("-%s()\n", __func__ );
    
        return 0;
    }

    Is it enough for McASP?

  • You need to configure the pins so as to fit the connections on your board: pin function, direction, pullup/pulldown if necessary.

  • I'm checking the configuration of the pinmux, thank you for your help.

    Best Regards