2018-08-27 16:52:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/audio/audio_i2s.c
|
|
|
|
*
|
2020-08-22 18:36:57 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2018-08-27 16:52:08 +02:00
|
|
|
*
|
2020-08-22 18:36:57 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-08-27 16:52:08 +02:00
|
|
|
*
|
2020-08-22 18:36:57 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2018-08-27 16:52:08 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2021-05-14 04:45:57 +02:00
|
|
|
|
2021-05-18 08:59:14 +02:00
|
|
|
#include <assert.h>
|
2021-05-14 04:45:57 +02:00
|
|
|
#include <debug.h>
|
|
|
|
|
2018-08-27 16:52:08 +02:00
|
|
|
#include <nuttx/audio/audio.h>
|
|
|
|
#include <nuttx/audio/i2s.h>
|
|
|
|
#include <nuttx/kmalloc.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct audio_i2s_s
|
|
|
|
{
|
|
|
|
struct audio_lowerhalf_s dev;
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct i2s_dev_s *i2s;
|
2018-08-27 16:52:08 +02:00
|
|
|
bool playback;
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int audio_i2s_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|
|
|
FAR struct audio_caps_s *caps);
|
|
|
|
static int audio_i2s_shutdown(FAR struct audio_lowerhalf_s *dev);
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
static int audio_i2s_configure(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session,
|
|
|
|
FAR const struct audio_caps_s *caps);
|
|
|
|
static int audio_i2s_start(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session);
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_STOP
|
|
|
|
static int audio_i2s_stop(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session);
|
|
|
|
#endif
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
|
|
|
|
static int audio_i2s_pause(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session);
|
|
|
|
static int audio_i2s_resume(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session);
|
|
|
|
#endif
|
|
|
|
static int audio_i2s_reserve(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void **session);
|
|
|
|
static int audio_i2s_release(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session);
|
|
|
|
#else
|
|
|
|
static int audio_i2s_configure(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR const struct audio_caps_s *caps);
|
|
|
|
static int audio_i2s_start(FAR struct audio_lowerhalf_s *dev);
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_STOP
|
|
|
|
static int audio_i2s_stop(FAR struct audio_lowerhalf_s *dev);
|
|
|
|
#endif
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
|
|
|
|
static int audio_i2s_pause(FAR struct audio_lowerhalf_s *dev);
|
|
|
|
static int audio_i2s_resume(FAR struct audio_lowerhalf_s *dev);
|
|
|
|
#endif
|
|
|
|
static int audio_i2s_reserve(FAR struct audio_lowerhalf_s *dev);
|
|
|
|
static int audio_i2s_release(FAR struct audio_lowerhalf_s *dev);
|
|
|
|
#endif
|
|
|
|
static int audio_i2s_allocbuffer(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR struct audio_buf_desc_s *bufdesc);
|
|
|
|
static int audio_i2s_freebuffer(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR struct audio_buf_desc_s *bufdesc);
|
|
|
|
static int audio_i2s_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR struct ap_buffer_s *apb);
|
|
|
|
static int audio_i2s_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd,
|
|
|
|
unsigned long arg);
|
2024-08-25 01:21:12 +02:00
|
|
|
static void audio_i2s_callback(FAR struct i2s_dev_s *dev,
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR struct ap_buffer_s *apb, FAR void *arg,
|
|
|
|
int result);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static const struct audio_ops_s g_audio_i2s_ops =
|
|
|
|
{
|
2022-03-26 21:51:22 +01:00
|
|
|
audio_i2s_getcaps, /* getcaps */
|
|
|
|
audio_i2s_configure, /* configure */
|
|
|
|
audio_i2s_shutdown, /* shutdown */
|
|
|
|
audio_i2s_start, /* start */
|
2018-08-27 16:52:08 +02:00
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_STOP
|
2022-03-26 21:51:22 +01:00
|
|
|
audio_i2s_stop, /* stop */
|
2018-08-27 16:52:08 +02:00
|
|
|
#endif
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
|
2022-03-26 21:51:22 +01:00
|
|
|
audio_i2s_pause, /* pause */
|
|
|
|
audio_i2s_resume, /* resume */
|
2018-08-27 16:52:08 +02:00
|
|
|
#endif
|
2022-03-26 21:51:22 +01:00
|
|
|
audio_i2s_allocbuffer, /* allocbuffer */
|
|
|
|
audio_i2s_freebuffer, /* freebuffer */
|
|
|
|
audio_i2s_enqueuebuffer, /* enqueue_buffer */
|
|
|
|
NULL, /* cancel_buffer */
|
|
|
|
audio_i2s_ioctl, /* ioctl */
|
|
|
|
NULL, /* read */
|
|
|
|
NULL, /* write */
|
|
|
|
audio_i2s_reserve, /* reserve */
|
|
|
|
audio_i2s_release /* release */
|
2018-08-27 16:52:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int audio_i2s_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|
|
|
FAR struct audio_caps_s *caps)
|
|
|
|
{
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct audio_i2s_s *audio_i2s = (FAR struct audio_i2s_s *)dev;
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR struct i2s_dev_s *i2s = audio_i2s->i2s;
|
|
|
|
|
|
|
|
/* Validate the structure */
|
|
|
|
|
|
|
|
DEBUGASSERT(caps && caps->ac_len >= sizeof(struct audio_caps_s));
|
|
|
|
audinfo("type=%d ac_type=%d\n", type, caps->ac_type);
|
|
|
|
|
|
|
|
caps->ac_format.hw = 0;
|
|
|
|
caps->ac_controls.w = 0;
|
|
|
|
|
|
|
|
switch (caps->ac_type)
|
|
|
|
{
|
|
|
|
/* Caller is querying for the types of units we support */
|
|
|
|
|
|
|
|
case AUDIO_TYPE_QUERY:
|
|
|
|
|
|
|
|
/* Provide our overall capabilities. The interfacing software
|
|
|
|
* must then call us back for specific info for each capability.
|
|
|
|
*/
|
|
|
|
|
2023-07-15 21:14:32 +02:00
|
|
|
if (caps->ac_subtype == AUDIO_TYPE_QUERY)
|
2018-08-27 16:52:08 +02:00
|
|
|
{
|
|
|
|
/* We don't decode any formats! Only something above us in
|
|
|
|
* the audio stream can perform decoding on our behalf.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The types of audio units we implement */
|
|
|
|
|
|
|
|
if (audio_i2s->playback)
|
|
|
|
{
|
|
|
|
caps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
caps->ac_controls.b[0] = AUDIO_TYPE_INPUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
caps->ac_format.hw = 1 << (AUDIO_FMT_PCM - 1);
|
|
|
|
break;
|
|
|
|
}
|
2023-07-15 21:14:32 +02:00
|
|
|
|
|
|
|
caps->ac_controls.b[0] = AUDIO_SUBFMT_END;
|
|
|
|
break;
|
2018-08-27 16:52:08 +02:00
|
|
|
|
|
|
|
/* Provide capabilities of our OUTPUT unit */
|
|
|
|
|
|
|
|
case AUDIO_TYPE_OUTPUT:
|
|
|
|
case AUDIO_TYPE_INPUT:
|
|
|
|
|
2023-07-15 21:14:32 +02:00
|
|
|
if (caps->ac_subtype == AUDIO_TYPE_QUERY)
|
2018-08-27 16:52:08 +02:00
|
|
|
{
|
|
|
|
/* Report the Sample rates we support */
|
|
|
|
|
2023-07-15 21:14:32 +02:00
|
|
|
caps->ac_controls.hw[0] = AUDIO_SAMP_RATE_DEF_ALL;
|
2024-02-19 08:58:10 +01:00
|
|
|
|
|
|
|
caps->ac_channels = 2;
|
|
|
|
|
2018-08-27 16:52:08 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
I2S_IOCTL(i2s, AUDIOIOC_GETCAPS, (unsigned long)caps);
|
|
|
|
break;
|
2023-07-15 21:14:32 +02:00
|
|
|
}
|
2018-08-27 16:52:08 +02:00
|
|
|
|
|
|
|
return caps->ac_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
static int audio_i2s_configure(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session,
|
|
|
|
FAR const struct audio_caps_s *caps)
|
|
|
|
#else
|
|
|
|
static int audio_i2s_configure(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR const struct audio_caps_s *caps)
|
|
|
|
#endif
|
|
|
|
{
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct audio_i2s_s *audio_i2s = (FAR struct audio_i2s_s *)dev;
|
2018-08-29 14:19:19 +02:00
|
|
|
FAR struct i2s_dev_s *i2s;
|
2020-04-21 09:45:24 +02:00
|
|
|
int samprate;
|
|
|
|
int nchannels;
|
|
|
|
int bpsamp;
|
2018-08-27 16:52:08 +02:00
|
|
|
int ret = OK;
|
|
|
|
|
2018-08-29 14:19:19 +02:00
|
|
|
DEBUGASSERT(audio_i2s != NULL && caps != NULL);
|
|
|
|
i2s = audio_i2s->i2s;
|
2018-08-27 16:52:08 +02:00
|
|
|
audinfo("ac_type: %d\n", caps->ac_type);
|
|
|
|
|
|
|
|
/* Process the configure operation */
|
|
|
|
|
|
|
|
switch (caps->ac_type)
|
|
|
|
{
|
|
|
|
case AUDIO_TYPE_OUTPUT:
|
|
|
|
case AUDIO_TYPE_INPUT:
|
|
|
|
|
|
|
|
/* Save the current stream configuration */
|
|
|
|
|
|
|
|
samprate = caps->ac_controls.hw[0] |
|
|
|
|
(caps->ac_controls.b[3] << 16);
|
|
|
|
nchannels = caps->ac_channels;
|
|
|
|
bpsamp = caps->ac_controls.b[2];
|
|
|
|
|
|
|
|
if (audio_i2s->playback)
|
|
|
|
{
|
|
|
|
I2S_TXCHANNELS(i2s, nchannels);
|
|
|
|
I2S_TXDATAWIDTH(i2s, bpsamp);
|
|
|
|
I2S_TXSAMPLERATE(i2s, samprate);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
I2S_RXCHANNELS(i2s, nchannels);
|
|
|
|
I2S_RXDATAWIDTH(i2s, bpsamp);
|
|
|
|
I2S_RXSAMPLERATE(i2s, samprate);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ret = I2S_IOCTL(i2s, AUDIOIOC_CONFIGURE, (unsigned long)caps);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int audio_i2s_shutdown(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
{
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct audio_i2s_s *audio_i2s = (FAR struct audio_i2s_s *)dev;
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR struct i2s_dev_s *i2s = audio_i2s->i2s;
|
|
|
|
|
|
|
|
return I2S_IOCTL(i2s, AUDIOIOC_SHUTDOWN, audio_i2s->playback);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
static int audio_i2s_start(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session)
|
|
|
|
#else
|
|
|
|
static int audio_i2s_start(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
#endif
|
|
|
|
{
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct audio_i2s_s *audio_i2s = (FAR struct audio_i2s_s *)dev;
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR struct i2s_dev_s *i2s = audio_i2s->i2s;
|
|
|
|
|
|
|
|
return I2S_IOCTL(i2s, AUDIOIOC_START, audio_i2s->playback);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_STOP
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
static int audio_i2s_stop(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session)
|
|
|
|
#else
|
|
|
|
static int audio_i2s_stop(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
#endif
|
|
|
|
{
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct audio_i2s_s *audio_i2s = (FAR struct audio_i2s_s *)dev;
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR struct i2s_dev_s *i2s = audio_i2s->i2s;
|
|
|
|
|
|
|
|
return I2S_IOCTL(i2s, AUDIOIOC_STOP, audio_i2s->playback);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
2020-01-31 16:15:01 +01:00
|
|
|
static int audio_i2s_pause(FAR struct audio_lowerhalf_s *dev,
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR void *session)
|
|
|
|
#else
|
|
|
|
static int audio_i2s_pause(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
#endif
|
|
|
|
{
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct audio_i2s_s *audio_i2s = (FAR struct audio_i2s_s *)dev;
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR struct i2s_dev_s *i2s = audio_i2s->i2s;
|
|
|
|
|
|
|
|
return I2S_IOCTL(i2s, AUDIOIOC_PAUSE, audio_i2s->playback);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
static int audio_i2s_resume(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session)
|
|
|
|
#else
|
|
|
|
static int audio_i2s_resume(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
#endif
|
|
|
|
{
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct audio_i2s_s *audio_i2s = (FAR struct audio_i2s_s *)dev;
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR struct i2s_dev_s *i2s = audio_i2s->i2s;
|
|
|
|
|
|
|
|
return I2S_IOCTL(i2s, AUDIOIOC_RESUME, audio_i2s->playback);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int audio_i2s_allocbuffer(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR struct audio_buf_desc_s *bufdesc)
|
|
|
|
{
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct audio_i2s_s *audio_i2s = (FAR struct audio_i2s_s *)dev;
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR struct i2s_dev_s *i2s = audio_i2s->i2s;
|
|
|
|
|
|
|
|
return I2S_IOCTL(i2s, AUDIOIOC_ALLOCBUFFER, (unsigned long)bufdesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int audio_i2s_freebuffer(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR struct audio_buf_desc_s *bufdesc)
|
|
|
|
{
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct audio_i2s_s *audio_i2s = (FAR struct audio_i2s_s *)dev;
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR struct i2s_dev_s *i2s = audio_i2s->i2s;
|
|
|
|
|
|
|
|
return I2S_IOCTL(i2s, AUDIOIOC_FREEBUFFER, (unsigned long)bufdesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int audio_i2s_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR struct ap_buffer_s *apb)
|
|
|
|
{
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct audio_i2s_s *audio_i2s = (FAR struct audio_i2s_s *)dev;
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR struct i2s_dev_s *i2s = audio_i2s->i2s;
|
|
|
|
|
|
|
|
if (audio_i2s->playback)
|
|
|
|
{
|
|
|
|
return I2S_SEND(i2s, apb, audio_i2s_callback, audio_i2s, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return I2S_RECEIVE(i2s, apb, audio_i2s_callback, audio_i2s, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int audio_i2s_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd,
|
|
|
|
unsigned long arg)
|
|
|
|
{
|
2024-08-25 01:21:12 +02:00
|
|
|
FAR struct audio_i2s_s *audio_i2s = (FAR struct audio_i2s_s *)dev;
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR struct i2s_dev_s *i2s = audio_i2s->i2s;
|
|
|
|
|
|
|
|
return I2S_IOCTL(i2s, cmd, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
static int audio_i2s_reserve(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void **session)
|
|
|
|
#else
|
|
|
|
static int audio_i2s_reserve(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
2024-08-25 01:21:12 +02:00
|
|
|
*session = (FAR void *)audio_i2s->playback;
|
2018-08-27 16:52:08 +02:00
|
|
|
#endif
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
static int audio_i2s_release(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session)
|
|
|
|
#else
|
|
|
|
static int audio_i2s_release(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2024-08-25 01:21:12 +02:00
|
|
|
static void audio_i2s_callback(FAR struct i2s_dev_s *dev,
|
2018-08-27 16:52:08 +02:00
|
|
|
FAR struct ap_buffer_s *apb,
|
|
|
|
FAR void *arg, int result)
|
|
|
|
{
|
|
|
|
FAR struct audio_i2s_s *audio_i2s = arg;
|
|
|
|
bool final = false;
|
|
|
|
|
|
|
|
if ((apb->flags & AUDIO_APB_FINAL) != 0)
|
|
|
|
{
|
|
|
|
final = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
audio_i2s->dev.upper(audio_i2s->dev.priv, AUDIO_CALLBACK_DEQUEUE, apb,
|
|
|
|
OK, NULL);
|
|
|
|
#else
|
|
|
|
audio_i2s->dev.upper(audio_i2s->dev.priv, AUDIO_CALLBACK_DEQUEUE, apb,
|
|
|
|
OK);
|
|
|
|
#endif
|
|
|
|
if (final)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
audio_i2s->dev.upper(audio_i2s->dev.priv, AUDIO_CALLBACK_COMPLETE,
|
|
|
|
NULL, OK, NULL);
|
|
|
|
#else
|
|
|
|
audio_i2s->dev.upper(audio_i2s->dev.priv, AUDIO_CALLBACK_COMPLETE,
|
|
|
|
NULL, OK);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
FAR struct audio_lowerhalf_s *audio_i2s_initialize(FAR struct i2s_dev_s *i2s,
|
|
|
|
bool playback)
|
|
|
|
{
|
|
|
|
FAR struct audio_i2s_s *audio_i2s;
|
|
|
|
|
|
|
|
if (i2s == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
audio_i2s = kmm_zalloc(sizeof(struct audio_i2s_s));
|
|
|
|
if (audio_i2s == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
audio_i2s->playback = playback;
|
|
|
|
audio_i2s->i2s = i2s;
|
|
|
|
audio_i2s->dev.ops = &g_audio_i2s_ops;
|
|
|
|
|
|
|
|
return &audio_i2s->dev;
|
|
|
|
}
|