* drivers/audio/wm8776.h
*
* SPDX-License-Identifier: Apache-2.0
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
****************************************************************************/
#ifndef __DRIVERS_AUDIO_WM8776_H
#define __DRIVERS_AUDIO_WM8776_H
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <pthread.h>
#include <nuttx/mqueue.h>
#include <nuttx/mutex.h>
#include <nuttx/wqueue.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/spinlock_type.h>
#ifdef CONFIG_AUDIO
* Pre-processor Definitions
****************************************************************************/
#define WM8776_MASTER_ATT 0x02
#define WM8776_DAC_CC 0x07
#define WM8776_DAC_IF 0x0a
#define WM8776_MASTER_MODE 0x0c
#define WM8776_PWR_DOWN 0x0d
#define WM8776_SOFT_RESET 0x17
#define WM8776_DEFAULT_SAMPRATE 44100
#define WM8776_DEFAULT_NCHANNELS 2
#define WM8776_DEFAULT_BPSAMP 16
#define WM8776_HPLZCEN (0x1 << 7)
#define WM8776_UPDATE (0x1 << 8)
#define WM8776_HPOUT_VOL_SHIFT (0)
#define WM8776_HPOUT_VOL_MASK (0x7f << WM8776_HPOUT_VOL_SHIFT)
# define WM8776_HPOUT_VOL(n) ((uint16_t)(n) << WM8776_HPOUT_VOL_SHIFT)
* Public Types
****************************************************************************/
struct wm8776_dev_s
{
* the WM8776 driver with respect to the board lower half driver).
*
* Terminology:
* Our "lower" half audio instances will be called dev for the publicly
* visible version and "priv" for the version that only this driver knows
* From the point of view of this driver, it is the board lower "half"
* that is referred to as "lower".
*/
struct audio_lowerhalf_s dev;
FAR const struct wm8776_lower_s *lower;
FAR struct i2c_master_s *i2c;
FAR struct i2s_dev_s *i2s;
struct dq_queue_s pendq;
struct dq_queue_s doneq;
struct file mq;
char mqname[16];
pthread_t threadid;
uint32_t bitrate;
mutex_t pendlock;
uint16_t samprate;
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
#ifndef CONFIG_AUDIO_EXCLUDE_BALANCE
uint16_t balance;
#endif
uint8_t volume;
#endif
uint8_t nchannels;
uint8_t bpsamp;
volatile uint8_t inflight;
bool running;
bool paused;
bool mute;
#ifndef CONFIG_AUDIO_EXCLUDE_STOP
bool terminating;
#endif
bool reserved;
volatile int result;
spinlock_t lock;
};
#endif
#endif