1 /*-
2  * Copyright (c) 2012 The NetBSD Foundation, Inc.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to The NetBSD Foundation
6  * by Paul Fleischer <paul@xpg.dk>
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 #ifndef _DEV_IC_UDA1341VAR_H_
30 #define _DEV_IC_UDA1341VAR_H_
31 
32 #include <sys/device.h>
33 #include <sys/audioio.h>
34 
35 struct uda1341_softc {
36           /* Pointer to the driver that holds this sc */
37           void                *parent;
38 
39           /* Pointer to L3 write function */
40           void                (*sc_l3_write)(void *,int,int);
41 
42           /* Approximate sample rate at which the codec is currently running */
43           int                 sc_sample_rate_approx;
44 
45           int                 sc_system_clock;
46 #define UDA1341_CLOCK_NA  3
47 #define UDA1341_CLOCK_256 2
48 #define UDA1341_CLOCK_384 1
49 #define UDA1341_CLOCK_512 0
50 
51           int                 sc_bus_format;
52 #define UDA1341_BUS_I2S                 0
53 #define UDA1341_BUS_LSB16     1
54 #define UDA1341_BUS_LSB18     2
55 #define UDA1341_BUS_LSB20     3
56 #define UDA1341_BUS_MSB                 4
57 #define UDA1341_BUS_LSB16_MSB 5
58 #define UDA1341_BUS_LSB18_MSB 6
59 #define UDA1341_BUS_LSB20_MSB 7
60 
61           uint8_t             sc_volume;
62           uint8_t             sc_bass;
63           uint8_t             sc_treble;
64           uint8_t             sc_mode;
65           uint8_t             sc_mute;
66           uint8_t             sc_ogain;
67           uint8_t             sc_dac_power;
68           uint8_t             sc_adc_power;
69           uint8_t             sc_inmix1;
70           uint8_t             sc_inmix2;
71           uint8_t             sc_micvol;
72           uint8_t             sc_inmode;
73           uint8_t             sc_agc;
74           uint8_t             sc_agc_lvl;
75           uint8_t             sc_ch2_gain;
76 
77 #define UDA1341_DEEMPHASIS_AUTO         4
78           uint8_t             sc_deemphasis;
79 
80 };
81 
82 int uda1341_attach(struct uda1341_softc *);
83 int uda1341_open(void *, int );
84 void uda1341_close(void *);
85 int uda1341_set_format(void *, int,
86     const audio_params_t *, const audio_params_t *,
87     audio_filter_reg_t *, audio_filter_reg_t *);
88 int uda1341_query_devinfo(void *, mixer_devinfo_t *);
89 int uda1341_get_port(void *, mixer_ctrl_t *);
90 int uda1341_set_port(void *, mixer_ctrl_t *);
91 #endif
92