Sound on New Kernel

a1ien.n3t
For some reason, in a new kernels sound does not work!
Tried to understand, but something does not work.

static struct platform_driver s3c24xx_uda134x_driver = {
  .probe  = s3c24xx_uda134x_probe,
  .remove = s3c24xx_uda134x_remove,
  .driver = {
    .name = "s3c24xx_uda134x",
    .owner = THIS_MODULE,
  },
};
static int __init s3c24xx_uda134x_init(void)
{
  return platform_driver_register(&s3c24xx_uda134x_driver);
}
Everything is Ok here. s3c24xx_uda134x_probe been called. Comes to
snd_soc_instantiate_card (which in linux-2.6 \ sound \ sos \ soc-core.c) 
There is a problem in this code:
...
for (i = 0; i < card->num_links; i++)
    soc_bind_dai_link(card, i);

//soc_bind_dai_link
....
find_platform:
  /* do we already have the CODEC DAI for this link ? */
  if (rtd->platform) {
    goto out;
  }
  /* no, then find CPU DAI from registered DAIs*/
  list_for_each_entry(platform, &platform_list, list) {
    if (!strcmp(platform->name, dai_link->platform_name)) {
      rtd->platform = platform;
      goto out;
    }
  }
....
platform_list is empty. I check that filling this structure and found this
in linux-2.6 \ sound \ soc \ samsung \ dma.c file:
.....
static int __devinit samsung_asoc_platform_probe (struct platform_device *
pdev)
{
/ / This function is no longer executes.
  return snd_soc_register_platform(&pdev->dev, &samsung_asoc_platform);
}
static int __devexit samsung_asoc_platform_remove(struct platform_device
*pdev)
{
  snd_soc_unregister_platform(&pdev->dev);
  return 0;
}
static struct platform_driver asoc_dma_driver = {
  .driver = {
    .name = "samsung-audio",
    .owner = THIS_MODULE,
  },
  .probe = samsung_asoc_platform_probe,
  .remove = __devexit_p(samsung_asoc_platform_remove),
};
static int __init samsung_asoc_init(void)
{
//But this is performed
  return platform_driver_register(&asoc_dma_driver);
}
module_init(samsung_asoc_init);
....
What problems in this code?

davef
Which new kernel?

a1ien.n3t
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary
But 2.6.37.y have same problem

davef
Did 2.6.32.2 work for you?  Maybe, the patches people have been trying to
push to mainstream still haven't gotten there or are broken.

Maybe trying:
http://www.friendlyarm.net/forum/topic/1094
a kernel posted by Jay or find the one open-nandra posted recently might
help narrow the problem down.

There was quite a lot of "sound" activity months ago, but thought the
issues had been resolved.

Can't help with the code.

Good luck.

a1ien.n3t
2.6.32.2 work fine.
I looked kernel a kernel posted by Jay but it probably will not help me

davef
As 2.6.32.2 works would comparing the relevant source files help?

davef
http://www.friendlyarm.net/forum/topic/1949
towards the end probably tells the story.

a1ien.n3t
I found the first problem. Need add to static struct platform_device
*mini2440_devices[] __initdata = {
line 
&samsung_asoc_dma, to \arch\arm\mach-s3c2440\mach-mini2440.c
But now the problem with codec.....

open-nandra
Same on my side. I found &samsung_asoc_dma is missing now codec part ;).
Keep us both informed ;).

marek

Andy
While you are in there can you make the codec work duplex as it never has
done!

You can open it for either read only or write only but not both.

Swap O_RDWR for O_RDONLY or O_WRONLY you will see what I mean!

Test code :-

// testdev.c
#include <sys/ioctl.h>
#include <sys/time.h>
#include <fcntl.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int fd;

  fd=open(argv[1], O_RDWR|O_NONBLOCK);

  if (fd<0)
    { 
      perror("error opening opening AUDIO device");
      exit(1);
    }
  printf("open ok\n");
  exit(0);
}


./testdev /dev/dsp

open-nandra
Says everything ;) :

soc-audio soc-audio: Registered card 'S3C24XX_UDA134X'
ALSA device list:
  #0: S3C24XX_UDA134X

2.6.38-rc8+ kernel. Will do tests if it make some sound ;).

marek

open-nandra
If anyone could try. Patch in attachment.

a1ien.n3t
I try Patch. 
ALSA device list:
  #0: S3C24XX_UDA134X
Present. But in Qtopia no sound

a1ien.n3t
Problem SOLVED.

Add #define POWER_OFF_ON_STANDBY 1 to /sound/soc/codecs/uda134x.c

open-nandra
Nice, how did you find that this is missing? Do you have patch for it? I
post my previous patch upstream for comments (not sure if all things done
correctly). Thanks for testing and working on this issue.

marek

a1ien.n3t
I just compared the file 2.6.32 and 2.6.38. On 2.6.32 kernel have define

#define POWER_OFF_ON_STANDBY 1
/*
  ALSA SOC usually puts the device in standby mode when it's not used
  for sometime. If you define POWER_OFF_ON_STANDBY the driver will
  turn off the ADC/DAC when this callback is invoked and turn it back
  on when needed. Unfortunately this will result in a very light bump
  (it can be audible only with good earphones). If this bothers you
  just comment this line, you will have slightly higher power
  consumption . Please note that sending the L3 command for ADC is
  enough to make the bump, so it doesn't make difference if you
  completely take off power from the codec.
 */
>Do you have patch for it?
I post full patch tomorrow because in the current version I have a lot of
rubbish added debug messages

open-nandra
OK nice. Will the send new patch with this change upstream when first patch
will be accepted. Original patch is here
(https://lkml.org/lkml/2011/3/9/338). Thanks,

marek

a1ien.n3t
https://gist.github.com/863650 Patch.
And my 2.6.38 kernel https://github.com/a1ien/mini2440-linux-kernel )

open-nandra
Today got info my patch was accepted mainstream. Also will send your second
patch mainstream hopefully will be accepted too.

marek

Andrew
Hi a1ien.n3t,

Does the audio interface works full duplex?

I mean, can you open /dev/dsp in O_RDWR mode?

I'm downloads the kernel and the patch wright now.

Thanks,

Andrew.

Andrew
Anyone??