1205859Sjoel/*-
2162874Snetchild * Copyright (c) 2006 Konstantin Dimitrov <kosio.dimitrov@gmail.com>
3159687Snetchild * Copyright (c) 2001 Katsurajima Naoto <raven@katsurajima.seya.yokohama.jp>
4159687Snetchild * All rights reserved.
5159687Snetchild *
6159687Snetchild * Redistribution and use in source and binary forms, with or without
7159687Snetchild * modification, are permitted provided that the following conditions
8159687Snetchild * are met:
9159687Snetchild * 1. Redistributions of source code must retain the above copyright
10159687Snetchild *    notice, this list of conditions and the following disclaimer.
11159687Snetchild * 2. Redistributions in binary form must reproduce the above copyright
12159687Snetchild *    notice, this list of conditions and the following disclaimer in the
13159687Snetchild *    documentation and/or other materials provided with the distribution.
14159687Snetchild *
15159687Snetchild * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16159687Snetchild * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17159687Snetchild * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18159687Snetchild * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19159687Snetchild * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20159687Snetchild * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21159687Snetchild * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22159687Snetchild * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT
23159687Snetchild * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24159687Snetchild * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
25159687Snetchild * SUCH DAMAGE.
26159687Snetchild *
27159687Snetchild * $FreeBSD$
28159687Snetchild */
29159687Snetchild
30159687Snetchild/* supported CODECs */
31162874Snetchild#define SPICDS_TYPE_AK4524 0
32162874Snetchild#define SPICDS_TYPE_AK4528 1
33162874Snetchild#define SPICDS_TYPE_WM8770 2
34162874Snetchild#define SPICDS_TYPE_AK4358 3
35162874Snetchild#define SPICDS_TYPE_AK4381 4
36170031Sjoel#define SPICDS_TYPE_AK4396 5
37159687Snetchild
38159687Snetchild/* AK4524/AK4528 control registers */
39159687Snetchild#define AK4524_POWER 0x00
40159687Snetchild#define AK4528_POWER 0x00
41159687Snetchild#define   AK452X_POWER_PWDA 0x01
42159687Snetchild#define   AK452X_POWER_PWAD 0x02
43159687Snetchild#define   AK452X_POWER_PWVR 0x04
44159687Snetchild#define AK4524_RESET 0x01
45159687Snetchild#define AK4528_RESET 0x01
46159687Snetchild#define   AK452X_RESET_RSDA 0x01
47159687Snetchild#define   AK452X_RESET_RSAD 0x02
48159687Snetchild#define AK4524_FORMAT 0x02
49159687Snetchild#define AK4528_FORMAT 0x02
50159687Snetchild#define   AK452X_FORMAT_1X       0x00
51159687Snetchild#define   AK452X_FORMAT_2X       0x01
52159687Snetchild#define   AK452X_FORMAT_4X1      0x02
53159687Snetchild#define   AK452X_FORMAT_4X2      0x03
54159687Snetchild#define   AK452X_FORMAT_256FSN   0x00
55159687Snetchild#define   AK452X_FORMAT_512FSN   0x04
56159687Snetchild#define   AK452X_FORMAT_1024FSN  0x08
57159687Snetchild#define   AK452X_FORMAT_384FSN   0x10
58159687Snetchild#define   AK452X_FORMAT_768FSN   0x14
59159687Snetchild#define   AK452X_FORMAT_OM24IL16 0x00
60159687Snetchild#define   AK452X_FORMAT_OM24IL20 0x20
61159687Snetchild#define   AK452X_FORMAT_OM24IM24 0x40
62159687Snetchild#define   AK452X_FORMAT_I2S      0x60
63159687Snetchild#define   AK452X_FORMAT_OM24IL24 0x80
64159687Snetchild#define AK4524_DVC 0x03
65159687Snetchild#define   AK452X_DVC_DEM441  0x00
66159687Snetchild#define   AK452X_DVC_DEMOFF  0x01
67159687Snetchild#define   AK452X_DVC_DEM48   0x02
68159687Snetchild#define   AK452X_DVC_DEM32   0x03
69159687Snetchild#define   AK452X_DVC_ZTM256  0x00
70159687Snetchild#define   AK452X_DVC_ZTM512  0x04
71159687Snetchild#define   AK452X_DVC_ZTM1024 0x08
72159687Snetchild#define   AK452X_DVC_ZTM2048 0x0c
73159687Snetchild#define   AK452X_DVC_ZCE     0x10
74159687Snetchild#define   AK452X_DVC_HPFL    0x04
75159687Snetchild#define   AK452X_DVC_HPFR    0x08
76159687Snetchild#define   AK452X_DVC_SMUTE   0x80
77159687Snetchild#define AK4524_LIPGA 0x04
78159687Snetchild#define AK4524_RIPGA 0x05
79159687Snetchild#define AK4524_LOATT 0x06
80159687Snetchild#define AK4524_ROATT 0x07
81159687Snetchild#define AK4528_LOATT 0x04
82159687Snetchild#define AK4528_ROATT 0x05
83159687Snetchild
84162874Snetchild/* WM8770 control registers */
85162874Snetchild#define WM8770_AOATT_L1 0x00
86162874Snetchild#define WM8770_AOATT_R1 0x01
87162874Snetchild#define WM8770_AOATT_L2 0x02
88162874Snetchild#define WM8770_AOATT_R2 0x03
89162874Snetchild#define WM8770_AOATT_L3 0x04
90162874Snetchild#define WM8770_AOATT_R3 0x05
91162874Snetchild#define WM8770_AOATT_L4 0x06
92162874Snetchild#define WM8770_AOATT_R4 0x07
93162874Snetchild#define WM8770_AOATT_MAST 0x08
94162874Snetchild#define WM8770_AOATT_UPDATE 0x100
95159687Snetchild
96162874Snetchild/* AK4358 control registers */
97162874Snetchild#define AK4358_LO1ATT 0x04
98162874Snetchild#define AK4358_RO1ATT 0x05
99162874Snetchild#define AK4358_OATT_ENABLE 0x80
100159687Snetchild
101162874Snetchild/* AK4381 control registers */
102162874Snetchild#define AK4381_LOATT 0x03
103162874Snetchild#define AK4381_ROATT 0x04
104162874Snetchild
105170031Sjoel/* AK4396 control registers */
106170031Sjoel#define AK4396_LOATT 0x03
107170031Sjoel#define AK4396_ROATT 0x04
108170031Sjoel
109162874Snetchildstruct spicds_info;
110162874Snetchild
111162874Snetchildtypedef void (*spicds_ctrl)(void *, unsigned int, unsigned int, unsigned int);
112162874Snetchild
113162874Snetchildstruct spicds_info *spicds_create(device_t dev, void *devinfo, int num, spicds_ctrl);
114162874Snetchildvoid spicds_destroy(struct spicds_info *codec);
115162874Snetchildvoid spicds_settype(struct spicds_info *codec, unsigned int type);
116162874Snetchildvoid spicds_setcif(struct spicds_info *codec, unsigned int cif);
117162874Snetchildvoid spicds_setformat(struct spicds_info *codec, unsigned int format);
118162874Snetchildvoid spicds_setdvc(struct spicds_info *codec, unsigned int dvc);
119162874Snetchildvoid spicds_init(struct spicds_info *codec);
120162874Snetchildvoid spicds_reinit(struct spicds_info *codec);
121162874Snetchildvoid spicds_set(struct spicds_info *codec, int dir, unsigned int left, unsigned int right);
122