I2S redirect on VS1005

Writing software that inputs and/or outputs audio and performs DSP algorithms such as filters, new codecs or audio effects.
art
User
Posts: 2
Joined: Fri 2015-02-20 15:05

I2S redirect on VS1005

Post by art »

Hi support,


I have trouble redirecting audio output on my VS1005 breakout board.

I have tried this code from programmer's guide:

Code: Select all

ior = ioctl(fp, IOCTL_AUDIO_SET_OUTPUTS,(void *)(AOR_DAC | AOR_I2S ));
but the result of this function is not S_OK so I assume I2s is not activated..

I have had this in the Kernel, clock and frame are ok when I check with an oscilloscope but there is no data.

Code: Select all

GpioSetAsPeripheral(0x1b);
GpioSetAsPeripheral(0x1c);
GpioSetAsPeripheral(0x1d);
GpioSetAsPeripheral(0x1e);
PERIP(I2S_CF) = I2S_CF_ENA | I2S_CF_MASTER | I2S_CF_ENAMCK | I2S_CF_32B | I2S_CF_FS;


In a same way, for redirecting audio input

Code: Select all

  // Switch stdaudioin to I2S input. Default format is 48 kHz, 32 bits
ioctl(stdaudioin,IOCTL_AUDIO_SELECT_INPUT,(void *)(AID_I2S ) );
the result of this function is OK this time, but I cannot retrieve data with fread function. It seems to wait for correct data and it prevents my further code to execute,but that probably another problem.


Have you got any clue for my problem?


Regards,

Art
User avatar
Panu
VSDSP Expert
Posts: 2829
Joined: Tue 2010-06-22 13:43

Re: I2S redirect on VS1005

Post by Panu »

1) Henrik is away, but hmm..., did you load the AUDIO driver at startup?


2) The GpioSetAsPeripheral... code should work, but perhaps someone is switching the I2S DATA pin back to GPIO mode. You can also write this code into your application to activate the I2S output (automatically generated copy of DAC main port audio)

-Panu
User avatar
Henrik
VLSI Staff
Posts: 1294
Joined: Tue 2010-06-22 14:10

Re: I2S redirect on VS1005

Post by Henrik »

Hello Art,

have you had success or do you still have this problem?

Kind regards,
- Henrik
Good signatures never die. They just fade away.
valece
User
Posts: 14
Joined: Thu 2015-01-22 20:30

Re: I2S redirect on VS1005

Post by valece »

Hello,

Thank you very much for your answers.
Unfortunately, we still can't make it work, we have no more idea why...
I attached to this message our very simple C file that is built and loaded as INIT.ap3 on the board. Are we doing something wrong?
As mentionned by Panu , we made sure to load the AUDIO driver at the startup of the board by writing: audio on the config.txt (it should however be loaded without that if we understood well?)

For information: we are using a VS1205g breakout board, and we loaded the kernel on the internal flash. We use the kernel v.3.20 for VS1005G developper board.

Sincerely yours,

Valece
Attachments
main.c
Here is our very simple C file that is built and loaded as INIT.ap3 on the board.
(4.76 KiB) Downloaded 324 times
User avatar
Henrik
VLSI Staff
Posts: 1294
Joined: Tue 2010-06-22 14:10

Re: I2S redirect on VS1005

Post by Henrik »

Hello Valece,

without the "audio" line in config.txt only a rudimentary DAC-only very simple audio driver is used.

If you have the audio driver already loaded by writing "audio" in config.txt, then you should be set, and I2S and SPDIF outputs should automatically be set on. Still, check that you have the audio driver SYS/AUDIO.DL3 in your VSOS system drive. Please have a look at that you don't get errors from the serial port debug output when you start the board.

To make absolutely sure, you could add the following code to the beginning of your main() function:

Code: Select all

  u_int16 *audioLib = NULL;
[...]
  if (!(audioLib = LoadLibrary("audio"))) {
    printf("Couldn't open AUDIO library\n");
    result = S_ERROR;
    goto finally;
  }
[... add this to finally ...]
 finally:
  if (audioLib) {
    DropLibrary(audioLib);
    audioLib = NULL;
  }
After this, you should remove the following code, because the audio driver automatically activates both I2S and SPDIF outputs.

Code: Select all

/* You can remove code beginning here */
  GpioSetAsPeripheral(0x1b);
  GpioSetAsPeripheral(0x1c);
  GpioSetAsPeripheral(0x1d);
  GpioSetAsPeripheral(0x1e);
  PERIP(I2S_CF) = I2S_CF_ENA | I2S_CF_MASTER | I2S_CF_ENAMCK | I2S_CF_32B | I2S_CF_FS;
	
  ior = ioctl(fp, IOCTL_AUDIO_SET_OUTPUTS,(void *)(AOR_DAC | AOR_I2S | AOR_SPDIF ));
/* You can remove code ending here */
We don't yet support I2S input, so that is why your ioctl() for IOCTL_AUDIO_SELECT_INPUT fails. If that is a necessity for your project, let us know, and we'll move it up our audio driver implementation queue.

For a list of what is already supported and what isn't, have a look at http://www.vlsi.fi/en/support/software/ ... tatus.html

Kind regards,
- Henrik
Good signatures never die. They just fade away.
valece
User
Posts: 14
Joined: Thu 2015-01-22 20:30

Re: I2S redirect on VS1005

Post by valece »

Hello,
Thank you for your answer.

I have removed the code as you said.
I dont seem to have any errors from the serial port debug output when I start the board.

The audio driver seems to be correctly loaded according to your code.
Here's what I get when plugging the board:

Code: Select all

Hello.
VSOS 3.20 build Feb 20 2015 17:18:13
VLSI Solution Oy 2012-2014 - www.vlsi.fi

Starting the kernel.. Starting Devices...  Internal Flash 
Installed system devices:
S: SPI Flash c213, handled by FAT.
Load drivers, config 0...
Driver: audio... 

1 driver(s) loaded.

VSOS running with 5 tasks:
Task   I/O Stack:0010-020f (512w), free:210
Task   Int Stack:0210-024f ( 64w), free:29
Task   Net Stack:0250-0251 (  2w), free:1
Task    UI Stack:0252-0253 (  2w), free:1
Task DECOD Stack:0254-03cf (380w), free:379

Interrupts: INT0_DAC:2->37765 INT6_MAC0:2->14031 INT13_RX:1->32923 INT16_TI2:2->10657 INT18_SRC:2->13948 INT23_SPDIFT:2->13965 

Load S:INIT.AP3...
open AUDIO library OK
i2s failed to activate
sample rate failed to be set
Opening S:TEST.MP3...
Starting the decoder...
Decoding audio...
Decoder returns 0, "header was expected"
Starting the decoder...
Decoding audio...
Decoder returns 1, "ok"
Starting the decoder...
Decoding audio...
Decoder returns 1, "ok"
Starting the decoder...
Couldn't create decoder
Clean-up.

App exit, result: -1.
Restart.
I2S input is necessary for our project, what alternative could we use to receive audio, which is currently supported by the board?

Sincerely yours,

Valentin
User avatar
Henrik
VLSI Staff
Posts: 1294
Joined: Tue 2010-06-22 14:10

Re: I2S redirect on VS1005

Post by Henrik »

Hello Valece!

Do you now get I2S output?

For the I2S input, can VS1005 be the clock master? If so, I could have a look if I could help you next week. The I2S master driver shouldn't be too difficult to implement.

Kind regards,
- Henrik
Good signatures never die. They just fade away.
valece
User
Posts: 14
Joined: Thu 2015-01-22 20:30

Re: I2S redirect on VS1005

Post by valece »

Hello Sir,

Thank you very much for your answers.

Yes , the data, is sent properly, but we still have an issue, this code :

Code: Select all

ior = ioctl(fp, IOCTL_AUDIO_GET_ORATE, (void *)(&sampleRate));
sill sends NOT(S_OK), is that normal?

The VS1005 sends a 20KHz frame and a 1mHz I2S clock. How can we decrease that clock rate?

For the I2S input, in our project,the VS1005 is indeed the clock master. Thank you again.

Sincerely yours,

Valece
Last edited by valece on Thu 2015-03-05 16:44, edited 1 time in total.
User avatar
Henrik
VLSI Staff
Posts: 1294
Joined: Tue 2010-06-22 14:10

Re: I2S redirect on VS1005

Post by Henrik »

Hello Valece,
valece wrote:

Code: Select all

ior = ioctl(fp, IOCTL_AUDIO_GET_ORATE, (void *)(&sampleRate));
sill sends NOT(S_OK), is that normal?
Hmm... It should return S_OK.

Are you sure you are using the current version of the audio driver? It's available in the VSOS 3.22 Root and Libraries Source Code.zip package at viewtopic.php?f=13&t=680&start=40#p7061

If the proglem persists after updating to the audio driver, please attach your current main.c to your next message, and I'll test it.
valece wrote:For the I2S input, in our project,the VS1005 is indeed the clock master. Thank you again.
All right, I'll have a look at it next week. Do you have a preference for sample rate and amount of bits? The best options are 192 kHz at 16 bits, 96 kHz at 16 or 32 bits, and 48 kHz at 16 or 32 bits. Would 48 kHz or 96 kHz at 32 bits be ok?

Kind regards,
- Henrik
Good signatures never die. They just fade away.
valece
User
Posts: 14
Joined: Thu 2015-01-22 20:30

Re: I2S redirect on VS1005

Post by valece »

Hello sir,

Yes we've updated the kernel to V.3.22 and put the latest drivers aviable.

I attached the main file.

Again, I want to mention that we are working on a breakout board, not on a developper board.

For the I2S, 96 kHz at 32 bits would be perfect.

Thank you again for your support.

Kind regards,
- Valece
Attachments
main.c
Here's our main file.
(5.08 KiB) Downloaded 300 times
Post Reply