1*2cfe870aSOleksandr Tymoshenko#- 2*2cfe870aSOleksandr Tymoshenko# Copyright (c) 2019 Oleksandr Tymoshenko <gonzo@FreeBSD.org> 3*2cfe870aSOleksandr Tymoshenko# 4*2cfe870aSOleksandr Tymoshenko# Redistribution and use in source and binary forms, with or without 5*2cfe870aSOleksandr Tymoshenko# modification, are permitted provided that the following conditions 6*2cfe870aSOleksandr Tymoshenko# are met: 7*2cfe870aSOleksandr Tymoshenko# 1. Redistributions of source code must retain the above copyright 8*2cfe870aSOleksandr Tymoshenko# notice, this list of conditions and the following disclaimer. 9*2cfe870aSOleksandr Tymoshenko# 2. Redistributions in binary form must reproduce the above copyright 10*2cfe870aSOleksandr Tymoshenko# notice, this list of conditions and the following disclaimer in the 11*2cfe870aSOleksandr Tymoshenko# documentation and/or other materials provided with the distribution. 12*2cfe870aSOleksandr Tymoshenko# 13*2cfe870aSOleksandr Tymoshenko# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14*2cfe870aSOleksandr Tymoshenko# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15*2cfe870aSOleksandr Tymoshenko# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16*2cfe870aSOleksandr Tymoshenko# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17*2cfe870aSOleksandr Tymoshenko# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18*2cfe870aSOleksandr Tymoshenko# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19*2cfe870aSOleksandr Tymoshenko# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20*2cfe870aSOleksandr Tymoshenko# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21*2cfe870aSOleksandr Tymoshenko# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22*2cfe870aSOleksandr Tymoshenko# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23*2cfe870aSOleksandr Tymoshenko# SUCH DAMAGE. 24*2cfe870aSOleksandr Tymoshenko# 25*2cfe870aSOleksandr Tymoshenko# 26*2cfe870aSOleksandr Tymoshenko 27*2cfe870aSOleksandr TymoshenkoCODE { 28*2cfe870aSOleksandr Tymoshenko #include <sys/param.h> 29*2cfe870aSOleksandr Tymoshenko #include <sys/bus.h> 30*2cfe870aSOleksandr Tymoshenko #include <dev/sound/pcm/sound.h> 31*2cfe870aSOleksandr Tymoshenko} 32*2cfe870aSOleksandr Tymoshenko 33*2cfe870aSOleksandr TymoshenkoINTERFACE audio_dai; 34*2cfe870aSOleksandr Tymoshenko 35*2cfe870aSOleksandr Tymoshenko# set DAI format for communications between CPU/codec nodes 36*2cfe870aSOleksandr TymoshenkoMETHOD int init { 37*2cfe870aSOleksandr Tymoshenko device_t dev; 38*2cfe870aSOleksandr Tymoshenko uint32_t format; 39*2cfe870aSOleksandr Tymoshenko} 40*2cfe870aSOleksandr Tymoshenko 41*2cfe870aSOleksandr Tymoshenko# Initialize DAI and set up interrrupt handler 42*2cfe870aSOleksandr TymoshenkoMETHOD int setup_intr { 43*2cfe870aSOleksandr Tymoshenko device_t dev; 44*2cfe870aSOleksandr Tymoshenko driver_intr_t intr_handler; 45*2cfe870aSOleksandr Tymoshenko void *intr_arg; 46*2cfe870aSOleksandr Tymoshenko} 47*2cfe870aSOleksandr Tymoshenko 48*2cfe870aSOleksandr Tymoshenko# Setup mixers for codec node 49*2cfe870aSOleksandr TymoshenkoMETHOD int setup_mixer { 50*2cfe870aSOleksandr Tymoshenko device_t dev; 51*2cfe870aSOleksandr Tymoshenko device_t ausocdev; 52*2cfe870aSOleksandr Tymoshenko} 53*2cfe870aSOleksandr Tymoshenko 54*2cfe870aSOleksandr Tymoshenko# setup clock speed 55*2cfe870aSOleksandr TymoshenkoMETHOD int set_sysclk { 56*2cfe870aSOleksandr Tymoshenko device_t dev; 57*2cfe870aSOleksandr Tymoshenko uint32_t rate; 58*2cfe870aSOleksandr Tymoshenko int dai_dir; 59*2cfe870aSOleksandr Tymoshenko} 60*2cfe870aSOleksandr Tymoshenko 61*2cfe870aSOleksandr TymoshenkoMETHOD int trigger { 62*2cfe870aSOleksandr Tymoshenko device_t dev; 63*2cfe870aSOleksandr Tymoshenko int go; 64*2cfe870aSOleksandr Tymoshenko int pcm_dir; 65*2cfe870aSOleksandr Tymoshenko} 66*2cfe870aSOleksandr Tymoshenko 67*2cfe870aSOleksandr TymoshenkoMETHOD struct pcmchan_caps* get_caps { 68*2cfe870aSOleksandr Tymoshenko device_t dev; 69*2cfe870aSOleksandr Tymoshenko} 70*2cfe870aSOleksandr Tymoshenko 71*2cfe870aSOleksandr TymoshenkoMETHOD uint32_t get_ptr { 72*2cfe870aSOleksandr Tymoshenko device_t dev; 73*2cfe870aSOleksandr Tymoshenko int pcm_dir; 74*2cfe870aSOleksandr Tymoshenko} 75*2cfe870aSOleksandr Tymoshenko 76*2cfe870aSOleksandr Tymoshenko# Set PCM channel format 77*2cfe870aSOleksandr TymoshenkoMETHOD uint32_t set_chanformat { 78*2cfe870aSOleksandr Tymoshenko device_t dev; 79*2cfe870aSOleksandr Tymoshenko uint32_t format; 80*2cfe870aSOleksandr Tymoshenko} 81*2cfe870aSOleksandr Tymoshenko 82*2cfe870aSOleksandr Tymoshenko# Set PCM channel sampling rate 83*2cfe870aSOleksandr TymoshenkoMETHOD uint32_t set_chanspeed { 84*2cfe870aSOleksandr Tymoshenko device_t dev; 85*2cfe870aSOleksandr Tymoshenko uint32_t speed; 86*2cfe870aSOleksandr Tymoshenko} 87*2cfe870aSOleksandr Tymoshenko 88*2cfe870aSOleksandr Tymoshenko# call DAI interrupt handler 89*2cfe870aSOleksandr Tymoshenko# returns 1 if call to chn_intr required, 0 otherwise 90*2cfe870aSOleksandr TymoshenkoMETHOD int intr { 91*2cfe870aSOleksandr Tymoshenko device_t dev; 92*2cfe870aSOleksandr Tymoshenko struct snd_dbuf *play_buf; 93*2cfe870aSOleksandr Tymoshenko struct snd_dbuf *rec_buf; 94*2cfe870aSOleksandr Tymoshenko} 95