2014-07-23 18:12:32 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/audio/audio_null.c
|
|
|
|
*
|
2021-03-04 07:10:42 +01: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
|
2014-07-23 18:12:32 +02:00
|
|
|
*
|
2021-03-04 07:10:42 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-07-23 18:12:32 +02:00
|
|
|
*
|
2021-03-04 07:10:42 +01: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.
|
2014-07-23 18:12:32 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
2020-11-13 06:23:11 +01:00
|
|
|
#include <inttypes.h>
|
2014-07-23 18:12:32 +02:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
2021-05-18 08:59:14 +02:00
|
|
|
#include <assert.h>
|
2014-07-23 18:12:32 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include <nuttx/kmalloc.h>
|
2017-10-10 16:43:10 +02:00
|
|
|
#include <nuttx/mqueue.h>
|
2014-07-23 18:12:32 +02:00
|
|
|
#include <nuttx/fs/fs.h>
|
|
|
|
#include <nuttx/fs/ioctl.h>
|
|
|
|
#include <nuttx/audio/audio.h>
|
|
|
|
#include <nuttx/audio/audio_null.h>
|
2023-10-25 05:08:56 +02:00
|
|
|
#include <nuttx/signal.h>
|
2014-07-23 18:12:32 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2015-04-08 15:15:32 +02:00
|
|
|
* Pre-processor Definitions
|
2014-07-23 18:12:32 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct null_dev_s
|
|
|
|
{
|
|
|
|
struct audio_lowerhalf_s dev; /* Audio lower half (this device) */
|
2020-11-26 13:15:28 +01:00
|
|
|
uint32_t scaler; /* Data bytes to sec scaler (bytes per sec) */
|
2020-12-24 13:53:17 +01:00
|
|
|
struct file mq; /* Message queue for receiving messages */
|
2014-07-23 18:12:32 +02:00
|
|
|
char mqname[16]; /* Our message queue name */
|
|
|
|
pthread_t threadid; /* ID of our thread */
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_STOP
|
|
|
|
volatile bool terminate; /* True: request to terminate */
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|
|
|
FAR struct audio_caps_s *caps);
|
2014-07-23 18:12:32 +02:00
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_configure(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session,
|
|
|
|
FAR const struct audio_caps_s *caps);
|
2014-07-23 18:12:32 +02:00
|
|
|
#else
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_configure(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR const struct audio_caps_s *caps);
|
2014-07-23 18:12:32 +02:00
|
|
|
#endif
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_shutdown(FAR struct audio_lowerhalf_s *dev);
|
|
|
|
static void *null_workerthread(pthread_addr_t pvarg);
|
2014-07-23 18:12:32 +02:00
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_start(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session);
|
2014-07-23 18:12:32 +02:00
|
|
|
#else
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_start(FAR struct audio_lowerhalf_s *dev);
|
2014-07-23 18:12:32 +02:00
|
|
|
#endif
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_STOP
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_stop(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session);
|
2014-07-23 18:12:32 +02:00
|
|
|
#else
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_stop(FAR struct audio_lowerhalf_s *dev);
|
2014-07-23 18:12:32 +02:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_pause(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session);
|
|
|
|
static int null_resume(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session);
|
2014-07-23 18:12:32 +02:00
|
|
|
#else
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_pause(FAR struct audio_lowerhalf_s *dev);
|
|
|
|
static int null_resume(FAR struct audio_lowerhalf_s *dev);
|
2014-07-23 18:12:32 +02:00
|
|
|
#endif
|
|
|
|
#endif
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR struct ap_buffer_s *apb);
|
|
|
|
static int null_cancelbuffer(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR struct ap_buffer_s *apb);
|
|
|
|
static int null_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd,
|
|
|
|
unsigned long arg);
|
2014-07-23 18:12:32 +02:00
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_reserve(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void **session);
|
2014-07-23 18:12:32 +02:00
|
|
|
#else
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_reserve(FAR struct audio_lowerhalf_s *dev);
|
2014-07-23 18:12:32 +02:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_release(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR void *session);
|
2014-07-23 18:12:32 +02:00
|
|
|
#else
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_release(FAR struct audio_lowerhalf_s *dev);
|
2014-07-23 18:12:32 +02:00
|
|
|
#endif
|
2022-03-26 21:51:22 +01:00
|
|
|
static int null_sleep(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR struct ap_buffer_s *apb);
|
2014-07-23 18:12:32 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static const struct audio_ops_s g_audioops =
|
|
|
|
{
|
|
|
|
null_getcaps, /* getcaps */
|
|
|
|
null_configure, /* configure */
|
|
|
|
null_shutdown, /* shutdown */
|
|
|
|
null_start, /* start */
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_STOP
|
|
|
|
null_stop, /* stop */
|
|
|
|
#endif
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
|
|
|
|
null_pause, /* pause */
|
|
|
|
null_resume, /* resume */
|
|
|
|
#endif
|
|
|
|
NULL, /* allocbuffer */
|
|
|
|
NULL, /* freebuffer */
|
|
|
|
null_enqueuebuffer, /* enqueue_buffer */
|
|
|
|
null_cancelbuffer, /* cancel_buffer */
|
|
|
|
null_ioctl, /* ioctl */
|
|
|
|
NULL, /* read */
|
|
|
|
NULL, /* write */
|
|
|
|
null_reserve, /* reserve */
|
|
|
|
null_release /* release */
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-11-26 13:15:28 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_sleep
|
|
|
|
*
|
|
|
|
* Description: Consume audio buffer in queue
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int null_sleep(FAR struct audio_lowerhalf_s *dev,
|
|
|
|
FAR struct ap_buffer_s *apb)
|
|
|
|
{
|
|
|
|
FAR struct null_dev_s *priv = (struct null_dev_s *)dev;
|
|
|
|
uint64_t sleep_time;
|
|
|
|
|
|
|
|
sleep_time = USEC_PER_SEC * (uint64_t)apb->nbytes / priv->scaler;
|
2023-10-25 05:08:56 +02:00
|
|
|
nxsig_usleep(sleep_time);
|
2020-11-26 13:15:28 +01:00
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_DEQUEUE,
|
|
|
|
apb, OK, NULL);
|
|
|
|
#else
|
|
|
|
priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_DEQUEUE,
|
|
|
|
apb, OK);
|
|
|
|
#endif
|
|
|
|
if ((apb->flags & AUDIO_APB_FINAL) != 0)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
priv->dev.upper(priv->dev.priv,
|
|
|
|
AUDIO_CALLBACK_COMPLETE,
|
|
|
|
NULL,
|
|
|
|
OK,
|
|
|
|
NULL);
|
|
|
|
#else
|
|
|
|
priv->dev.upper(priv->dev.priv,
|
|
|
|
AUDIO_CALLBACK_COMPLETE,
|
|
|
|
NULL,
|
|
|
|
OK);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2014-07-23 18:12:32 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_getcaps
|
|
|
|
*
|
|
|
|
* Description: Get the audio device capabilities
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
2022-03-26 21:51:22 +01:00
|
|
|
FAR struct audio_caps_s *caps)
|
2014-07-23 18:12:32 +02:00
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("type=%d\n", type);
|
2014-07-23 18:12:32 +02:00
|
|
|
|
|
|
|
/* Validate the structure */
|
|
|
|
|
|
|
|
DEBUGASSERT(caps->ac_len >= sizeof(struct audio_caps_s));
|
|
|
|
|
|
|
|
/* Fill in the caller's structure based on requested info */
|
|
|
|
|
2014-07-24 18:21:04 +02:00
|
|
|
caps->ac_format.hw = 0;
|
|
|
|
caps->ac_controls.w = 0;
|
2014-07-23 18:12:32 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
caps->ac_channels = 2; /* Stereo output */
|
|
|
|
|
|
|
|
switch (caps->ac_subtype)
|
|
|
|
{
|
|
|
|
case AUDIO_TYPE_QUERY:
|
|
|
|
/* 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 */
|
|
|
|
|
2020-04-21 09:45:24 +02:00
|
|
|
caps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT |
|
|
|
|
AUDIO_TYPE_FEATURE |
|
2014-07-24 18:21:04 +02:00
|
|
|
AUDIO_TYPE_PROCESSING;
|
2014-07-23 18:12:32 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AUDIO_FMT_MIDI:
|
2020-04-21 09:45:24 +02:00
|
|
|
|
2014-07-23 18:12:32 +02:00
|
|
|
/* We only support Format 0 */
|
|
|
|
|
2014-07-24 18:21:04 +02:00
|
|
|
caps->ac_controls.b[0] = AUDIO_SUBFMT_END;
|
2014-07-23 18:12:32 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-07-24 18:21:04 +02:00
|
|
|
caps->ac_controls.b[0] = AUDIO_SUBFMT_END;
|
2014-07-23 18:12:32 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Provide capabilities of our OUTPUT unit */
|
|
|
|
|
|
|
|
case AUDIO_TYPE_OUTPUT:
|
|
|
|
|
|
|
|
caps->ac_channels = 2;
|
|
|
|
|
|
|
|
switch (caps->ac_subtype)
|
|
|
|
{
|
|
|
|
case AUDIO_TYPE_QUERY:
|
|
|
|
|
|
|
|
/* Report the Sample rates we support */
|
|
|
|
|
2024-08-22 15:20:52 +02:00
|
|
|
caps->ac_controls.hw[0] = AUDIO_SAMP_RATE_8K |
|
|
|
|
AUDIO_SAMP_RATE_11K |
|
|
|
|
AUDIO_SAMP_RATE_16K |
|
|
|
|
AUDIO_SAMP_RATE_22K |
|
|
|
|
AUDIO_SAMP_RATE_32K |
|
|
|
|
AUDIO_SAMP_RATE_44K |
|
|
|
|
AUDIO_SAMP_RATE_48K;
|
2014-07-23 18:12:32 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AUDIO_FMT_MP3:
|
|
|
|
case AUDIO_FMT_WMA:
|
|
|
|
case AUDIO_FMT_PCM:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Provide capabilities of our FEATURE units */
|
|
|
|
|
|
|
|
case AUDIO_TYPE_FEATURE:
|
|
|
|
|
2020-04-21 09:45:24 +02:00
|
|
|
/* If the sub-type is UNDEF,
|
|
|
|
* then report the Feature Units we support
|
|
|
|
*/
|
2014-07-23 18:12:32 +02:00
|
|
|
|
|
|
|
if (caps->ac_subtype == AUDIO_FU_UNDEF)
|
|
|
|
{
|
2020-04-21 09:45:24 +02:00
|
|
|
/* Fill in the ac_controls section with
|
|
|
|
* the Feature Units we have
|
|
|
|
*/
|
2014-07-23 18:12:32 +02:00
|
|
|
|
2020-04-21 09:45:24 +02:00
|
|
|
caps->ac_controls.b[0] = AUDIO_FU_VOLUME |
|
|
|
|
AUDIO_FU_BASS |
|
|
|
|
AUDIO_FU_TREBLE;
|
2014-07-24 18:21:04 +02:00
|
|
|
caps->ac_controls.b[1] = AUDIO_FU_BALANCE >> 8;
|
2014-07-23 18:12:32 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-21 09:45:24 +02:00
|
|
|
/* TODO: Do we need to provide specific info for the
|
|
|
|
* Feature Units, such as volume setting ranges, etc.?
|
2014-07-23 18:12:32 +02:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Provide capabilities of our PROCESSING unit */
|
|
|
|
|
|
|
|
case AUDIO_TYPE_PROCESSING:
|
|
|
|
|
|
|
|
switch (caps->ac_subtype)
|
|
|
|
{
|
|
|
|
case AUDIO_PU_UNDEF:
|
|
|
|
|
|
|
|
/* Provide the type of Processing Units we support */
|
|
|
|
|
2014-07-24 18:21:04 +02:00
|
|
|
caps->ac_controls.b[0] = AUDIO_PU_STEREO_EXTENDER;
|
2014-07-23 18:12:32 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AUDIO_PU_STEREO_EXTENDER:
|
|
|
|
|
|
|
|
/* Provide capabilities of our Stereo Extender */
|
|
|
|
|
2020-04-21 09:45:24 +02:00
|
|
|
caps->ac_controls.b[0] = AUDIO_STEXT_ENABLE |
|
|
|
|
AUDIO_STEXT_WIDTH;
|
2014-07-23 18:12:32 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
/* Other types of processing uint we don't support */
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* All others we don't support */
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
/* Zero out the fields to indicate no support */
|
|
|
|
|
|
|
|
caps->ac_subtype = 0;
|
|
|
|
caps->ac_channels = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the length of the audio_caps_s struct for validation of
|
|
|
|
* proper Audio device type.
|
|
|
|
*/
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Return %d\n", caps->ac_len);
|
2014-07-23 18:12:32 +02:00
|
|
|
return caps->ac_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_configure
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Configure the audio device for the specified mode of operation.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
static int null_configure(FAR struct audio_lowerhalf_s *dev,
|
2014-07-23 19:58:43 +02:00
|
|
|
FAR void *session,
|
|
|
|
FAR const struct audio_caps_s *caps)
|
2014-07-23 18:12:32 +02:00
|
|
|
#else
|
|
|
|
static int null_configure(FAR struct audio_lowerhalf_s *dev,
|
2014-07-23 19:58:43 +02:00
|
|
|
FAR const struct audio_caps_s *caps)
|
2014-07-23 18:12:32 +02:00
|
|
|
#endif
|
|
|
|
{
|
2020-11-26 13:15:28 +01:00
|
|
|
FAR struct null_dev_s *priv = (FAR struct null_dev_s *)dev;
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("ac_type: %d\n", caps->ac_type);
|
2014-07-24 17:56:39 +02:00
|
|
|
|
|
|
|
/* Process the configure operation */
|
|
|
|
|
|
|
|
switch (caps->ac_type)
|
|
|
|
{
|
|
|
|
case AUDIO_TYPE_FEATURE:
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo(" AUDIO_TYPE_FEATURE\n");
|
2014-07-24 17:56:39 +02:00
|
|
|
|
|
|
|
/* Process based on Feature Unit */
|
|
|
|
|
2014-07-24 18:21:04 +02:00
|
|
|
switch (caps->ac_format.hw)
|
2014-07-24 17:56:39 +02:00
|
|
|
{
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
|
|
|
case AUDIO_FU_VOLUME:
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo(" Volume: %d\n", caps->ac_controls.hw[0]);
|
2014-07-24 17:56:39 +02:00
|
|
|
break;
|
2020-01-31 19:07:39 +01:00
|
|
|
#endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */
|
2014-07-24 17:56:39 +02:00
|
|
|
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_TONE
|
|
|
|
case AUDIO_FU_BASS:
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo(" Bass: %d\n", caps->ac_controls.b[0]);
|
2014-07-24 17:56:39 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AUDIO_FU_TREBLE:
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo(" Treble: %d\n", caps->ac_controls.b[0]);
|
2014-07-24 17:56:39 +02:00
|
|
|
break;
|
2020-01-31 19:07:39 +01:00
|
|
|
#endif /* CONFIG_AUDIO_EXCLUDE_TONE */
|
2014-07-24 17:56:39 +02:00
|
|
|
|
|
|
|
default:
|
2016-06-12 17:26:00 +02:00
|
|
|
auderr(" ERROR: Unrecognized feature unit\n");
|
2014-07-24 17:56:39 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AUDIO_TYPE_OUTPUT:
|
2020-11-26 13:15:28 +01:00
|
|
|
priv->scaler = caps->ac_channels
|
|
|
|
* caps->ac_controls.hw[0]
|
|
|
|
* caps->ac_controls.b[2] / 8;
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo(" AUDIO_TYPE_OUTPUT:\n");
|
|
|
|
audinfo(" Number of channels: %u\n", caps->ac_channels);
|
|
|
|
audinfo(" Sample rate: %u\n", caps->ac_controls.hw[0]);
|
|
|
|
audinfo(" Sample width: %u\n", caps->ac_controls.b[2]);
|
2014-07-24 17:56:39 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AUDIO_TYPE_PROCESSING:
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo(" AUDIO_TYPE_PROCESSING:\n");
|
2014-07-24 17:56:39 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Return OK\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_shutdown
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Shutdown the driver and put it in the lowest power state possible.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int null_shutdown(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Return OK\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_workerthread
|
|
|
|
*
|
|
|
|
* This is the thread that feeds data to the chip and keeps the audio
|
|
|
|
* stream going.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static void *null_workerthread(pthread_addr_t pvarg)
|
|
|
|
{
|
2020-11-26 13:15:28 +01:00
|
|
|
FAR struct null_dev_s *priv = (FAR struct null_dev_s *) pvarg;
|
2014-07-23 18:12:32 +02:00
|
|
|
struct audio_msg_s msg;
|
|
|
|
int msglen;
|
2019-02-16 02:18:55 +01:00
|
|
|
unsigned int prio;
|
2014-07-23 18:12:32 +02:00
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Entry\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
|
|
|
|
/* Loop as long as we are supposed to be running */
|
|
|
|
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_STOP
|
|
|
|
while (!priv->terminate)
|
|
|
|
#else
|
2015-10-10 18:41:00 +02:00
|
|
|
for (; ; )
|
2014-07-23 18:12:32 +02:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
/* Wait for messages from our message queue */
|
|
|
|
|
2020-12-24 13:53:17 +01:00
|
|
|
msglen = file_mq_receive(&priv->mq, (FAR char *)&msg,
|
|
|
|
sizeof(msg), &prio);
|
2014-07-23 18:12:32 +02:00
|
|
|
|
|
|
|
/* Handle the case when we return with no message */
|
|
|
|
|
|
|
|
if (msglen < sizeof(struct audio_msg_s))
|
|
|
|
{
|
2016-06-11 23:50:49 +02:00
|
|
|
auderr("ERROR: Message too small: %d\n", msglen);
|
2014-07-23 18:12:32 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Process the message */
|
|
|
|
|
2020-04-21 09:45:24 +02:00
|
|
|
switch (msg.msg_id)
|
2014-07-23 18:12:32 +02:00
|
|
|
{
|
|
|
|
case AUDIO_MSG_DATA_REQUEST:
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_STOP
|
|
|
|
case AUDIO_MSG_STOP:
|
|
|
|
priv->terminate = true;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case AUDIO_MSG_ENQUEUE:
|
2020-11-26 13:15:28 +01:00
|
|
|
null_sleep(&priv->dev, (FAR struct ap_buffer_s *)msg.u.ptr);
|
2014-07-23 18:12:32 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AUDIO_MSG_COMPLETE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2020-04-21 09:45:24 +02:00
|
|
|
auderr("ERROR: Ignoring message ID %d\n", msg.msg_id);
|
2014-07-23 18:12:32 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the message queue */
|
|
|
|
|
2020-12-24 13:53:17 +01:00
|
|
|
file_mq_close(&priv->mq);
|
|
|
|
file_mq_unlink(priv->mqname);
|
2020-11-26 13:15:28 +01:00
|
|
|
priv->terminate = false;
|
2014-07-23 18:12:32 +02:00
|
|
|
|
|
|
|
/* Send an AUDIO_MSG_COMPLETE message to the client */
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_COMPLETE, NULL, OK, NULL);
|
|
|
|
#else
|
|
|
|
priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_COMPLETE, NULL, OK);
|
|
|
|
#endif
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Exit\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_start
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Start the configured operation (audio streaming, volume enabled, etc.).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
static int null_start(FAR struct audio_lowerhalf_s *dev, FAR void *session)
|
|
|
|
#else
|
|
|
|
static int null_start(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
FAR struct null_dev_s *priv = (FAR struct null_dev_s *)dev;
|
|
|
|
struct sched_param sparam;
|
|
|
|
struct mq_attr attr;
|
|
|
|
pthread_attr_t tattr;
|
|
|
|
FAR void *value;
|
|
|
|
int ret;
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Entry\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
|
|
|
|
/* Create a message queue for the worker thread */
|
|
|
|
|
2020-11-13 06:23:11 +01:00
|
|
|
snprintf(priv->mqname, sizeof(priv->mqname), "/tmp/%" PRIXPTR,
|
|
|
|
(uintptr_t)priv);
|
2014-07-23 18:12:32 +02:00
|
|
|
|
|
|
|
attr.mq_maxmsg = 16;
|
|
|
|
attr.mq_msgsize = sizeof(struct audio_msg_s);
|
|
|
|
attr.mq_curmsgs = 0;
|
|
|
|
attr.mq_flags = 0;
|
|
|
|
|
2020-12-24 13:53:17 +01:00
|
|
|
ret = file_mq_open(&priv->mq, priv->mqname,
|
|
|
|
O_RDWR | O_CREAT, 0644, &attr);
|
|
|
|
if (ret < 0)
|
2014-07-23 18:12:32 +02:00
|
|
|
{
|
|
|
|
/* Error creating message queue! */
|
|
|
|
|
2016-06-11 23:50:49 +02:00
|
|
|
auderr("ERROR: Couldn't allocate message queue\n");
|
2020-12-24 13:53:17 +01:00
|
|
|
return ret;
|
2014-07-23 18:12:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Join any old worker thread we had created to prevent a memory leak */
|
|
|
|
|
|
|
|
if (priv->threadid != 0)
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Joining old thread\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
pthread_join(priv->threadid, &value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start our thread for sending data to the device */
|
|
|
|
|
|
|
|
pthread_attr_init(&tattr);
|
|
|
|
sparam.sched_priority = sched_get_priority_max(SCHED_FIFO) - 3;
|
2020-01-02 17:49:34 +01:00
|
|
|
pthread_attr_setschedparam(&tattr, &sparam);
|
|
|
|
pthread_attr_setstacksize(&tattr, CONFIG_AUDIO_NULL_WORKER_STACKSIZE);
|
2014-07-23 18:12:32 +02:00
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Starting worker thread\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
ret = pthread_create(&priv->threadid, &tattr, null_workerthread,
|
|
|
|
(pthread_addr_t)priv);
|
|
|
|
if (ret != OK)
|
|
|
|
{
|
2016-06-11 23:50:49 +02:00
|
|
|
auderr("ERROR: pthread_create failed: %d\n", ret);
|
2014-07-23 18:12:32 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pthread_setname_np(priv->threadid, "null audio");
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Created worker thread\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
}
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Return %d\n", ret);
|
2014-07-23 18:12:32 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_stop
|
|
|
|
*
|
|
|
|
* Description: Stop the configured operation (audio streaming, volume
|
|
|
|
* disabled, etc.).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_STOP
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
2015-10-10 18:41:00 +02:00
|
|
|
static int null_stop(FAR struct audio_lowerhalf_s *dev, FAR void *session)
|
2014-07-23 18:12:32 +02:00
|
|
|
#else
|
|
|
|
static int null_stop(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
FAR struct null_dev_s *priv = (FAR struct null_dev_s *)dev;
|
|
|
|
struct audio_msg_s term_msg;
|
|
|
|
FAR void *value;
|
|
|
|
|
|
|
|
/* Send a message to stop all audio streaming */
|
2020-04-21 09:45:24 +02:00
|
|
|
|
|
|
|
/* REVISIT:
|
|
|
|
* There should be a check to see if the worker thread is still running.
|
2014-07-25 19:27:29 +02:00
|
|
|
*/
|
2014-07-23 18:12:32 +02:00
|
|
|
|
2020-04-21 09:45:24 +02:00
|
|
|
term_msg.msg_id = AUDIO_MSG_STOP;
|
2014-07-23 18:12:32 +02:00
|
|
|
term_msg.u.data = 0;
|
2020-12-24 13:53:17 +01:00
|
|
|
file_mq_send(&priv->mq, (FAR const char *)&term_msg, sizeof(term_msg),
|
|
|
|
CONFIG_AUDIO_NULL_MSG_PRIO);
|
2014-07-23 18:12:32 +02:00
|
|
|
|
|
|
|
/* Join the worker thread */
|
|
|
|
|
|
|
|
pthread_join(priv->threadid, &value);
|
|
|
|
priv->threadid = 0;
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Return OK\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_pause
|
|
|
|
*
|
|
|
|
* Description: Pauses the playback.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
2015-10-10 18:41:00 +02:00
|
|
|
static int null_pause(FAR struct audio_lowerhalf_s *dev, FAR void *session)
|
2014-07-23 18:12:32 +02:00
|
|
|
#else
|
|
|
|
static int null_pause(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
#endif
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Return OK\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME */
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_resume
|
|
|
|
*
|
|
|
|
* Description: Resumes the playback.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
2015-10-10 18:41:00 +02:00
|
|
|
static int null_resume(FAR struct audio_lowerhalf_s *dev, FAR void *session)
|
2014-07-23 18:12:32 +02:00
|
|
|
#else
|
|
|
|
static int null_resume(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
#endif
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Return OK\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME */
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_enqueuebuffer
|
|
|
|
*
|
|
|
|
* Description: Enqueue an Audio Pipeline Buffer for playback/ processing.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int null_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
|
2022-03-26 21:51:22 +01:00
|
|
|
FAR struct ap_buffer_s *apb)
|
2014-07-23 18:12:32 +02:00
|
|
|
{
|
2014-07-28 02:33:17 +02:00
|
|
|
FAR struct null_dev_s *priv = (FAR struct null_dev_s *)dev;
|
2020-11-26 13:15:28 +01:00
|
|
|
struct audio_msg_s msg;
|
|
|
|
int ret;
|
2014-07-23 18:12:32 +02:00
|
|
|
|
2017-05-15 15:20:32 +02:00
|
|
|
DEBUGASSERT(priv && apb && priv->dev.upper);
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("apb=%p curbyte=%d nbytes=%d\n", apb, apb->curbyte, apb->nbytes);
|
2014-07-23 18:12:32 +02:00
|
|
|
|
2020-11-26 13:15:28 +01:00
|
|
|
msg.msg_id = AUDIO_MSG_ENQUEUE;
|
|
|
|
msg.u.ptr = apb;
|
2014-07-23 18:12:32 +02:00
|
|
|
|
2020-12-24 13:53:17 +01:00
|
|
|
ret = file_mq_send(&priv->mq, (FAR const char *)&msg,
|
|
|
|
sizeof(msg), CONFIG_AUDIO_NULL_MSG_PRIO);
|
2020-11-26 13:15:28 +01:00
|
|
|
if (ret < 0)
|
2014-08-01 00:36:09 +02:00
|
|
|
{
|
2020-12-24 13:53:17 +01:00
|
|
|
auderr("ERROR: file_mq_send failed: %d\n", ret);
|
2014-08-01 00:36:09 +02:00
|
|
|
}
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Return OK\n");
|
2020-11-26 13:15:28 +01:00
|
|
|
return ret;
|
2014-07-23 18:12:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_cancelbuffer
|
|
|
|
*
|
|
|
|
* Description: Called when an enqueued buffer is being cancelled.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int null_cancelbuffer(FAR struct audio_lowerhalf_s *dev,
|
2014-07-23 19:58:43 +02:00
|
|
|
FAR struct ap_buffer_s *apb)
|
2014-07-23 18:12:32 +02:00
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("apb=%p curbyte=%d nbytes=%d, return OK\n",
|
2014-07-23 19:58:43 +02:00
|
|
|
apb, apb->curbyte, apb->nbytes);
|
|
|
|
|
2014-07-23 18:12:32 +02:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_ioctl
|
|
|
|
*
|
|
|
|
* Description: Perform a device ioctl
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int null_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd,
|
2022-03-26 21:51:22 +01:00
|
|
|
unsigned long arg)
|
2014-07-23 18:12:32 +02:00
|
|
|
{
|
2020-06-05 03:34:01 +02:00
|
|
|
int ret = OK;
|
2014-07-23 18:12:32 +02:00
|
|
|
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
|
|
|
|
FAR struct ap_buffer_info_s *bufinfo;
|
|
|
|
#endif
|
|
|
|
|
2020-12-05 14:31:08 +01:00
|
|
|
audinfo("cmd=%d arg=%ld\n", cmd, arg);
|
2014-07-23 19:58:43 +02:00
|
|
|
|
2014-07-23 18:12:32 +02:00
|
|
|
/* Deal with ioctls passed from the upper-half driver */
|
|
|
|
|
|
|
|
switch (cmd)
|
|
|
|
{
|
|
|
|
/* Check for AUDIOIOC_HWRESET ioctl. This ioctl is passed straight
|
|
|
|
* through from the upper-half audio driver.
|
|
|
|
*/
|
|
|
|
|
|
|
|
case AUDIOIOC_HWRESET:
|
2014-07-23 20:21:04 +02:00
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("AUDIOIOC_HWRESET:\n");
|
2014-07-23 20:21:04 +02:00
|
|
|
}
|
2014-07-23 18:12:32 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Report our preferred buffer size and quantity */
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
|
|
|
|
case AUDIOIOC_GETBUFFERINFO:
|
2014-07-23 20:21:04 +02:00
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("AUDIOIOC_GETBUFFERINFO:\n");
|
2014-07-23 20:21:04 +02:00
|
|
|
bufinfo = (FAR struct ap_buffer_info_s *) arg;
|
|
|
|
bufinfo->buffer_size = CONFIG_AUDIO_NULL_BUFFER_SIZE;
|
|
|
|
bufinfo->nbuffers = CONFIG_AUDIO_NULL_NUM_BUFFERS;
|
|
|
|
}
|
2014-07-23 18:12:32 +02:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
default:
|
2020-06-05 03:34:01 +02:00
|
|
|
ret = -ENOTTY;
|
2014-07-23 18:12:32 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Return OK\n");
|
2020-06-05 03:34:01 +02:00
|
|
|
return ret;
|
2014-07-23 18:12:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_reserve
|
|
|
|
*
|
|
|
|
* Description: Reserves a session (the only one we have).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
static int null_reserve(FAR struct audio_lowerhalf_s *dev,
|
2022-03-26 21:51:22 +01:00
|
|
|
FAR void **session)
|
2014-07-23 18:12:32 +02:00
|
|
|
#else
|
|
|
|
static int null_reserve(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
#endif
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
audinfo("Return OK\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: null_release
|
|
|
|
*
|
|
|
|
* Description: Releases the session (the only one we have).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
|
|
|
static int null_release(FAR struct audio_lowerhalf_s *dev,
|
2022-03-26 21:51:22 +01:00
|
|
|
FAR void *session)
|
2014-07-23 18:12:32 +02:00
|
|
|
#else
|
|
|
|
static int null_release(FAR struct audio_lowerhalf_s *dev)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
FAR struct null_dev_s *priv = (FAR struct null_dev_s *)dev;
|
|
|
|
void *value;
|
|
|
|
|
|
|
|
/* Join any old worker thread we had created to prevent a memory leak */
|
|
|
|
|
|
|
|
if (priv->threadid != 0)
|
|
|
|
{
|
|
|
|
pthread_join(priv->threadid, &value);
|
|
|
|
priv->threadid = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: audio_null_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize the null audio device.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* i2c - An I2C driver instance
|
|
|
|
* i2s - An I2S driver instance
|
|
|
|
* lower - Persistent board configuration data
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* A new lower half audio interface for the NULL audio device is returned
|
|
|
|
* on success; NULL is returned on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
FAR struct audio_lowerhalf_s *audio_null_initialize(void)
|
|
|
|
{
|
|
|
|
FAR struct null_dev_s *priv;
|
|
|
|
|
|
|
|
/* Allocate the null audio device structure */
|
|
|
|
|
2023-08-28 09:39:47 +02:00
|
|
|
priv = kmm_zalloc(sizeof(struct null_dev_s));
|
2014-07-23 18:12:32 +02:00
|
|
|
if (priv)
|
|
|
|
{
|
2020-04-21 09:45:24 +02:00
|
|
|
/* Initialize the null audio device structure.
|
|
|
|
* Since we used kmm_zalloc, only the non-zero elements
|
|
|
|
* of the structure need to be initialized.
|
2014-07-23 18:12:32 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
priv->dev.ops = &g_audioops;
|
|
|
|
return &priv->dev;
|
|
|
|
}
|
|
|
|
|
2016-06-11 23:50:49 +02:00
|
|
|
auderr("ERROR: Failed to allocate null audio device\n");
|
2014-07-23 18:12:32 +02:00
|
|
|
return NULL;
|
|
|
|
}
|