From: Shivam Garg Date: Thu, 7 Sep 2017 09:04:38 +0000 (+0900) Subject: Added support for separate device registeration for play and capture. X-Git-Tag: 1.1_Public_Release~188^2~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d37cb83820e639c32ab90fe7defb521122678ea1;p=rtos%2Ftinyara.git Added support for separate device registeration for play and capture. alc5658 audio device can be registered as two seperate devices. The device naming format is "/dev/audio/pcmC%dD%d%c",card,device,(playback or capture flag). Changed the device opening format in tinyalsa to open the device registered as a single device for both playback and capture. --- diff --git a/framework/src/tinyalsa/tinyalsa.c b/framework/src/tinyalsa/tinyalsa.c index 5fb839d..26f6c47 100644 --- a/framework/src/tinyalsa/tinyalsa.c +++ b/framework/src/tinyalsa/tinyalsa.c @@ -755,7 +755,12 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, unsigned int flags, return &bad_pcm; } +#ifdef CONFIG_AUDIO_MULTI_CARD snprintf(fn, sizeof(fn), "/dev/audio/pcmC%uD%u%c", card, device, flags & PCM_IN ? 'c' : 'p'); +#else + snprintf(fn, sizeof(fn), "/dev/audio/pcmC%u", card); +#endif + pcm->flags = flags; pcm->fd = open(fn, O_RDWR); diff --git a/os/arch/arm/src/artik053/src/artik053_alc5658.c b/os/arch/arm/src/artik053/src/artik053_alc5658.c index 2ed7b47..b468265 100644 --- a/os/arch/arm/src/artik053/src/artik053_alc5658.c +++ b/os/arch/arm/src/artik053/src/artik053_alc5658.c @@ -285,6 +285,41 @@ int s5j_alc5658_initialize(int minor) /* Now we can use these I2C and I2S interfaces to initialize the * ALC5658 which will return an audio interface. */ + /* Create a device name */ +#ifdef CONFIG_AUDIO_MULTI_CARD + snprintf(devname, 12, "pcmC%uD%u%c", minor, 0, 'c'); + + alc5658 = alc5658_initialize(i2c, i2s, &g_alc5658info.lower); + if (!alc5658) { + auddbg("ERROR: Failed to initialize the ALC5658\n"); + ret = -ENODEV; + goto errout_with_irq; + } + + /* No we can embed the ALC5658/I2C/I2S conglomerate into a PCM decoder + * instance so that we will have a PCM front end for the the ALC5658 + * driver. + */ + + pcm = pcm_decode_initialize(alc5658); + if (!pcm) { + auddbg("ERROR: Failed create the PCM decoder\n"); + ret = -ENODEV; + goto errout_with_alc5658; + } + + ret = audio_register(devname, pcm); + if (ret < 0) { + auddbg("ERROR: Failed to register /dev/%s device: %d\n", devname, ret); + goto errout_with_pcm; + } + + snprintf(devname, 12, "pcmC%uD%u%c", minor, 0, 'p'); + +#else + snprintf(devname, 12, "pcmC%u", minor); +#endif + alc5658 = alc5658_initialize(i2c, i2s, &g_alc5658info.lower); if (!alc5658) { auddbg("ERROR: Failed to initialize the ALC5658\n"); @@ -304,9 +339,7 @@ int s5j_alc5658_initialize(int minor) goto errout_with_alc5658; } - /* Create a device name */ - snprintf(devname, 12, "pcm%d", minor); /* Finally, we can register the PCM/ALC5658/I2C/I2S audio device. * diff --git a/os/audio/Kconfig b/os/audio/Kconfig index f0ef29d..92b9f26 100644 --- a/os/audio/Kconfig +++ b/os/audio/Kconfig @@ -60,6 +60,11 @@ config AUDIO_DRIVER_SPECIFIC_BUFFERS endmenu # Audio Buffer Configuration +config AUDIO_MULTI_CARD + bool "Registering audio device as different devices for capture and playback" + default n + + config DEBUG_AUDIO_ERROR bool "Output AUDIO Error Debug Messages" default n