sunxi_codec.h revision 1.2.2.2 1 1.2.2.2 skrll /* $NetBSD: sunxi_codec.h,v 1.2.2.2 2017/08/28 17:51:32 skrll Exp $ */
2 1.2.2.2 skrll
3 1.2.2.2 skrll /*-
4 1.2.2.2 skrll * Copyright (c) 2014-2017 Jared McNeill <jmcneill (at) invisible.ca>
5 1.2.2.2 skrll * All rights reserved.
6 1.2.2.2 skrll *
7 1.2.2.2 skrll * Redistribution and use in source and binary forms, with or without
8 1.2.2.2 skrll * modification, are permitted provided that the following conditions
9 1.2.2.2 skrll * are met:
10 1.2.2.2 skrll * 1. Redistributions of source code must retain the above copyright
11 1.2.2.2 skrll * notice, this list of conditions and the following disclaimer.
12 1.2.2.2 skrll * 2. Redistributions in binary form must reproduce the above copyright
13 1.2.2.2 skrll * notice, this list of conditions and the following disclaimer in the
14 1.2.2.2 skrll * documentation and/or other materials provided with the distribution.
15 1.2.2.2 skrll *
16 1.2.2.2 skrll * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.2.2.2 skrll * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.2.2.2 skrll * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.2.2.2 skrll * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.2.2.2 skrll * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 1.2.2.2 skrll * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 1.2.2.2 skrll * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 1.2.2.2 skrll * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 1.2.2.2 skrll * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.2.2.2 skrll * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.2.2.2 skrll * SUCH DAMAGE.
27 1.2.2.2 skrll */
28 1.2.2.2 skrll
29 1.2.2.2 skrll #ifndef _ARM_SUNXI_CODEC_H
30 1.2.2.2 skrll #define _ARM_SUNXI_CODEC_H
31 1.2.2.2 skrll
32 1.2.2.2 skrll #include <sys/audioio.h>
33 1.2.2.2 skrll #include <dev/audio_if.h>
34 1.2.2.2 skrll #include <dev/auconv.h>
35 1.2.2.2 skrll
36 1.2.2.2 skrll #include <dev/fdt/fdtvar.h>
37 1.2.2.2 skrll
38 1.2.2.2 skrll #include "h3_codec.h"
39 1.2.2.2 skrll
40 1.2.2.2 skrll struct sunxi_codec_softc;
41 1.2.2.2 skrll
42 1.2.2.2 skrll struct sunxi_codec_conf {
43 1.2.2.2 skrll const char *name;
44 1.2.2.2 skrll
45 1.2.2.2 skrll /* initialize codec */
46 1.2.2.2 skrll int (*init)(struct sunxi_codec_softc *);
47 1.2.2.2 skrll /* toggle DAC/ADC mute */
48 1.2.2.2 skrll void (*mute)(struct sunxi_codec_softc *, int, u_int);
49 1.2.2.2 skrll /* mixer controls */
50 1.2.2.2 skrll int (*set_port)(struct sunxi_codec_softc *,
51 1.2.2.2 skrll mixer_ctrl_t *);
52 1.2.2.2 skrll int (*get_port)(struct sunxi_codec_softc *,
53 1.2.2.2 skrll mixer_ctrl_t *);
54 1.2.2.2 skrll int (*query_devinfo)(struct sunxi_codec_softc *,
55 1.2.2.2 skrll mixer_devinfo_t *);
56 1.2.2.2 skrll
57 1.2.2.2 skrll /* register map */
58 1.2.2.2 skrll bus_size_t DPC,
59 1.2.2.2 skrll DAC_FIFOC,
60 1.2.2.2 skrll DAC_FIFOS,
61 1.2.2.2 skrll DAC_TXDATA,
62 1.2.2.2 skrll ADC_FIFOC,
63 1.2.2.2 skrll ADC_FIFOS,
64 1.2.2.2 skrll ADC_RXDATA,
65 1.2.2.2 skrll DAC_CNT,
66 1.2.2.2 skrll ADC_CNT;
67 1.2.2.2 skrll };
68 1.2.2.2 skrll
69 1.2.2.2 skrll struct sunxi_codec_chan {
70 1.2.2.2 skrll struct sunxi_codec_softc *ch_sc;
71 1.2.2.2 skrll u_int ch_mode;
72 1.2.2.2 skrll
73 1.2.2.2 skrll struct fdtbus_dma *ch_dma;
74 1.2.2.2 skrll struct fdtbus_dma_req ch_req;
75 1.2.2.2 skrll
76 1.2.2.2 skrll audio_params_t ch_params;
77 1.2.2.2 skrll
78 1.2.2.2 skrll bus_addr_t ch_start_phys;
79 1.2.2.2 skrll bus_addr_t ch_end_phys;
80 1.2.2.2 skrll bus_addr_t ch_cur_phys;
81 1.2.2.2 skrll int ch_blksize;
82 1.2.2.2 skrll
83 1.2.2.2 skrll void (*ch_intr)(void *);
84 1.2.2.2 skrll void *ch_intrarg;
85 1.2.2.2 skrll };
86 1.2.2.2 skrll
87 1.2.2.2 skrll struct sunxi_codec_dma {
88 1.2.2.2 skrll LIST_ENTRY(sunxi_codec_dma) dma_list;
89 1.2.2.2 skrll bus_dmamap_t dma_map;
90 1.2.2.2 skrll void *dma_addr;
91 1.2.2.2 skrll size_t dma_size;
92 1.2.2.2 skrll bus_dma_segment_t dma_segs[1];
93 1.2.2.2 skrll int dma_nsegs;
94 1.2.2.2 skrll };
95 1.2.2.2 skrll
96 1.2.2.2 skrll struct sunxi_codec_softc {
97 1.2.2.2 skrll device_t sc_dev;
98 1.2.2.2 skrll bus_space_tag_t sc_bst;
99 1.2.2.2 skrll bus_space_handle_t sc_bsh;
100 1.2.2.2 skrll bus_dma_tag_t sc_dmat;
101 1.2.2.2 skrll int sc_phandle;
102 1.2.2.2 skrll bus_addr_t sc_baseaddr;
103 1.2.2.2 skrll
104 1.2.2.2 skrll struct sunxi_codec_conf *sc_cfg;
105 1.2.2.2 skrll void *sc_codec_priv;
106 1.2.2.2 skrll
107 1.2.2.2 skrll struct fdtbus_gpio_pin *sc_pin_pa;
108 1.2.2.2 skrll
109 1.2.2.2 skrll LIST_HEAD(, sunxi_codec_dma) sc_dmalist;
110 1.2.2.2 skrll
111 1.2.2.2 skrll kmutex_t sc_lock;
112 1.2.2.2 skrll kmutex_t sc_intr_lock;
113 1.2.2.2 skrll
114 1.2.2.2 skrll struct audio_format sc_format;
115 1.2.2.2 skrll struct audio_encoding_set *sc_encodings;
116 1.2.2.2 skrll
117 1.2.2.2 skrll struct sunxi_codec_chan sc_pchan;
118 1.2.2.2 skrll struct sunxi_codec_chan sc_rchan;
119 1.2.2.2 skrll };
120 1.2.2.2 skrll
121 1.2.2.2 skrll #if NH3_CODEC > 0
122 1.2.2.2 skrll extern const struct sunxi_codec_conf sun8i_h3_codecconf;
123 1.2.2.2 skrll #define H3_CODEC_COMPATDATA \
124 1.2.2.2 skrll { "allwinner,sun8i-h3-codec", (uintptr_t)&sun8i_h3_codecconf }
125 1.2.2.2 skrll #else
126 1.2.2.2 skrll #define H3_CODEC_COMPATDATA
127 1.2.2.2 skrll #endif
128 1.2.2.2 skrll
129 1.2.2.2 skrll #endif /* !_ARM_SUNXI_CODEC_H */
130