1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2006 Konstantin Dimitrov <kosio.dimitrov@gmail.com> 5 * Copyright (c) 2001 Katsurajima Naoto <raven@katsurajima.seya.yokohama.jp> 6 * All rights reserved. 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 AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $FreeBSD$ 30 */ 31 32 /* supported CODECs */ 33 #define SPICDS_TYPE_AK4524 0 34 #define SPICDS_TYPE_AK4528 1 35 #define SPICDS_TYPE_WM8770 2 36 #define SPICDS_TYPE_AK4358 3 37 #define SPICDS_TYPE_AK4381 4 38 #define SPICDS_TYPE_AK4396 5 39 40 /* AK4524/AK4528 control registers */ 41 #define AK4524_POWER 0x00 42 #define AK4528_POWER 0x00 43 #define AK452X_POWER_PWDA 0x01 44 #define AK452X_POWER_PWAD 0x02 45 #define AK452X_POWER_PWVR 0x04 46 #define AK4524_RESET 0x01 47 #define AK4528_RESET 0x01 48 #define AK452X_RESET_RSDA 0x01 49 #define AK452X_RESET_RSAD 0x02 50 #define AK4524_FORMAT 0x02 51 #define AK4528_FORMAT 0x02 52 #define AK452X_FORMAT_1X 0x00 53 #define AK452X_FORMAT_2X 0x01 54 #define AK452X_FORMAT_4X1 0x02 55 #define AK452X_FORMAT_4X2 0x03 56 #define AK452X_FORMAT_256FSN 0x00 57 #define AK452X_FORMAT_512FSN 0x04 58 #define AK452X_FORMAT_1024FSN 0x08 59 #define AK452X_FORMAT_384FSN 0x10 60 #define AK452X_FORMAT_768FSN 0x14 61 #define AK452X_FORMAT_OM24IL16 0x00 62 #define AK452X_FORMAT_OM24IL20 0x20 63 #define AK452X_FORMAT_OM24IM24 0x40 64 #define AK452X_FORMAT_I2S 0x60 65 #define AK452X_FORMAT_OM24IL24 0x80 66 #define AK4524_DVC 0x03 67 #define AK452X_DVC_DEM441 0x00 68 #define AK452X_DVC_DEMOFF 0x01 69 #define AK452X_DVC_DEM48 0x02 70 #define AK452X_DVC_DEM32 0x03 71 #define AK452X_DVC_ZTM256 0x00 72 #define AK452X_DVC_ZTM512 0x04 73 #define AK452X_DVC_ZTM1024 0x08 74 #define AK452X_DVC_ZTM2048 0x0c 75 #define AK452X_DVC_ZCE 0x10 76 #define AK452X_DVC_HPFL 0x04 77 #define AK452X_DVC_HPFR 0x08 78 #define AK452X_DVC_SMUTE 0x80 79 #define AK4524_LIPGA 0x04 80 #define AK4524_RIPGA 0x05 81 #define AK4524_LOATT 0x06 82 #define AK4524_ROATT 0x07 83 #define AK4528_LOATT 0x04 84 #define AK4528_ROATT 0x05 85 86 /* WM8770 control registers */ 87 #define WM8770_AOATT_L1 0x00 88 #define WM8770_AOATT_R1 0x01 89 #define WM8770_AOATT_L2 0x02 90 #define WM8770_AOATT_R2 0x03 91 #define WM8770_AOATT_L3 0x04 92 #define WM8770_AOATT_R3 0x05 93 #define WM8770_AOATT_L4 0x06 94 #define WM8770_AOATT_R4 0x07 95 #define WM8770_AOATT_MAST 0x08 96 #define WM8770_AOATT_UPDATE 0x100 97 98 /* AK4358 control registers */ 99 #define AK4358_LO1ATT 0x04 100 #define AK4358_RO1ATT 0x05 101 #define AK4358_OATT_ENABLE 0x80 102 103 /* AK4381 control registers */ 104 #define AK4381_LOATT 0x03 105 #define AK4381_ROATT 0x04 106 107 /* AK4396 control registers */ 108 #define AK4396_LOATT 0x03 109 #define AK4396_ROATT 0x04 110 111 struct spicds_info; 112 113 typedef void (*spicds_ctrl)(void *, unsigned int, unsigned int, unsigned int); 114 115 struct spicds_info *spicds_create(device_t dev, void *devinfo, int num, spicds_ctrl); 116 void spicds_destroy(struct spicds_info *codec); 117 void spicds_settype(struct spicds_info *codec, unsigned int type); 118 void spicds_setcif(struct spicds_info *codec, unsigned int cif); 119 void spicds_setformat(struct spicds_info *codec, unsigned int format); 120 void spicds_setdvc(struct spicds_info *codec, unsigned int dvc); 121 void spicds_init(struct spicds_info *codec); 122 void spicds_reinit(struct spicds_info *codec); 123 void spicds_set(struct spicds_info *codec, int dir, unsigned int left, unsigned int right); 124