1 From c667b06f616d5dec68469ac73764abd5bcb1d694 Mon Sep 17 00:00:00 2001
2 From: FERHAT Nicolas <contact@audiophonics.fr>
3 Date: Fri, 5 Apr 2019 13:06:42 +0100
4 Subject: [PATCH 410/806] Audiophonics I-Sabre 9038Q2M DAC driver
6 Signed-off-by: Audiophonics <contact@audiophonics.fr>
8 arch/arm/boot/dts/overlays/Makefile | 1 +
9 arch/arm/boot/dts/overlays/README | 6 +
10 .../boot/dts/overlays/i-sabre-q2m-overlay.dts | 39 ++
11 sound/soc/bcm/Kconfig | 7 +
12 sound/soc/bcm/Makefile | 2 +
13 sound/soc/bcm/i-sabre-q2m.c | 157 +++++++
14 sound/soc/codecs/Kconfig | 5 +
15 sound/soc/codecs/Makefile | 2 +
16 sound/soc/codecs/i-sabre-codec.c | 392 ++++++++++++++++++
17 sound/soc/codecs/i-sabre-codec.h | 42 ++
18 13 files changed, 656 insertions(+)
19 create mode 100644 arch/arm/boot/dts/overlays/i-sabre-q2m-overlay.dts
20 create mode 100644 sound/soc/bcm/i-sabre-q2m.c
21 create mode 100644 sound/soc/codecs/i-sabre-codec.c
22 create mode 100644 sound/soc/codecs/i-sabre-codec.h
24 --- a/arch/arm/boot/dts/overlays/Makefile
25 +++ b/arch/arm/boot/dts/overlays/Makefile
26 @@ -55,6 +55,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
34 --- a/arch/arm/boot/dts/overlays/README
35 +++ b/arch/arm/boot/dts/overlays/README
36 @@ -869,6 +869,12 @@ Params: speed Display
37 ledgpio GPIO used to control backlight
41 +Info: Configures the Audiophonics I-SABRE Q2M DAC
42 +Load: dtoverlay=i-sabre-q2m
47 Info: Fall back to the i2c_bcm2708 driver for the i2c_arm bus.
48 Load: dtoverlay=i2c-bcm2708
50 +++ b/arch/arm/boot/dts/overlays/i-sabre-q2m-overlay.dts
52 +// Definitions for I-Sabre Q2M
57 + compatible = "brcm,bcm2708";
61 + frag0: __overlay__ {
62 + compatible = "audiophonics,i-sabre-q2m";
63 + i2s-controller = <&i2s>;
78 + #address-cells = <1>;
83 + #sound-dai-cells = <0>;
84 + compatible = "audiophonics,i-sabre-codec";
91 --- a/sound/soc/bcm/Kconfig
92 +++ b/sound/soc/bcm/Kconfig
93 @@ -123,6 +123,13 @@ config SND_BCM2708_SOC_IQAUDIO_DIGI
95 Say Y or M if you want to add support for IQAudIO Digital IO board.
97 +config SND_BCM2708_SOC_I_SABRE_Q2M
98 + tristate "Support for Audiophonics I-Sabre Q2M DAC"
99 + depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
100 + select SND_SOC_I_SABRE_CODEC
102 + Say Y or M if you want to add support for Audiophonics I-SABRE Q2M DAC
104 config SND_BCM2708_SOC_ADAU1977_ADC
105 tristate "Support for ADAU1977 ADC"
106 depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
107 --- a/sound/soc/bcm/Makefile
108 +++ b/sound/soc/bcm/Makefile
109 @@ -19,6 +19,7 @@ snd-soc-justboom-dac-objs := justboom-da
110 snd-soc-rpi-cirrus-objs := rpi-cirrus.o
111 snd-soc-rpi-proto-objs := rpi-proto.o
112 snd-soc-iqaudio-dac-objs := iqaudio-dac.o
113 + snd-soc-i-sabre-q2m-objs := i-sabre-q2m.o
114 snd-soc-audioinjector-pi-soundcard-objs := audioinjector-pi-soundcard.o
115 snd-soc-audioinjector-octo-soundcard-objs := audioinjector-octo-soundcard.o
116 snd-soc-audiosense-pi-objs := audiosense-pi.o
117 @@ -42,6 +43,7 @@ obj-$(CONFIG_SND_BCM2708_SOC_JUSTBOOM_DA
118 obj-$(CONFIG_SND_BCM2708_SOC_RPI_CIRRUS) += snd-soc-rpi-cirrus.o
119 obj-$(CONFIG_SND_BCM2708_SOC_RPI_PROTO) += snd-soc-rpi-proto.o
120 obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) += snd-soc-iqaudio-dac.o
121 + obj-$(CONFIG_SND_BCM2708_SOC_I_SABRE_Q2M) += snd-soc-i-sabre-q2m.o
122 obj-$(CONFIG_SND_AUDIOINJECTOR_PI_SOUNDCARD) += snd-soc-audioinjector-pi-soundcard.o
123 obj-$(CONFIG_SND_AUDIOINJECTOR_OCTO_SOUNDCARD) += snd-soc-audioinjector-octo-soundcard.o
124 obj-$(CONFIG_SND_AUDIOSENSE_PI) += snd-soc-audiosense-pi.o
126 +++ b/sound/soc/bcm/i-sabre-q2m.c
129 + * ASoC Driver for I-Sabre Q2M
131 + * Author: Satoru Kawase
132 + * Modified by: Xiao Qingyong
133 + * Update kernel v4.18+ by : Audiophonics
134 + * Copyright 2018 Audiophonics
136 + * This program is free software; you can redistribute it and/or
137 + * modify it under the terms of the GNU General Public License
138 + * version 2 as published by the Free Software Foundation.
140 + * This program is distributed in the hope that it will be useful, but
141 + * WITHOUT ANY WARRANTY; without even the implied warranty of
142 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
143 + * General Public License for more details.
146 +#include <linux/kernel.h>
147 +#include <linux/init.h>
148 +#include <linux/module.h>
149 +#include <linux/delay.h>
150 +#include <linux/fs.h>
151 +#include <asm/uaccess.h>
152 +#include <sound/core.h>
153 +#include <sound/soc.h>
154 +#include <sound/pcm.h>
155 +#include <sound/pcm_params.h>
157 +#include "../codecs/i-sabre-codec.h"
160 +static int snd_rpi_i_sabre_q2m_init(struct snd_soc_pcm_runtime *rtd)
162 + struct snd_soc_component *component = rtd->codec_dai->component;
163 + unsigned int value;
166 + value = snd_soc_component_read32(component, ISABRECODEC_REG_01);
167 + dev_info(component->card->dev, "Audiophonics Device ID : %02X\n", value);
170 + value = snd_soc_component_read32(component, ISABRECODEC_REG_02);
171 + dev_info(component->card->dev, "Audiophonics API revision : %02X\n", value);
176 +static int snd_rpi_i_sabre_q2m_hw_params(
177 + struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
179 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
180 + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
183 + bclk_ratio = snd_pcm_format_physical_width(
184 + params_format(params)) * params_channels(params);
185 + return snd_soc_dai_set_bclk_ratio(cpu_dai, bclk_ratio);
188 +/* machine stream operations */
189 +static struct snd_soc_ops snd_rpi_i_sabre_q2m_ops = {
190 + .hw_params = snd_rpi_i_sabre_q2m_hw_params,
194 +static struct snd_soc_dai_link snd_rpi_i_sabre_q2m_dai[] = {
196 + .name = "I-Sabre Q2M",
197 + .stream_name = "I-Sabre Q2M DAC",
198 + .cpu_dai_name = "bcm2708-i2s.0",
199 + .codec_dai_name = "i-sabre-codec-dai",
200 + .platform_name = "bcm2708-i2s.0",
201 + .codec_name = "i-sabre-codec-i2c.1-0048",
202 + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
203 + | SND_SOC_DAIFMT_CBS_CFS,
204 + .init = snd_rpi_i_sabre_q2m_init,
205 + .ops = &snd_rpi_i_sabre_q2m_ops,
209 +/* audio machine driver */
210 +static struct snd_soc_card snd_rpi_i_sabre_q2m = {
211 + .name = "I-Sabre Q2M DAC",
212 + .owner = THIS_MODULE,
213 + .dai_link = snd_rpi_i_sabre_q2m_dai,
214 + .num_links = ARRAY_SIZE(snd_rpi_i_sabre_q2m_dai)
218 +static int snd_rpi_i_sabre_q2m_probe(struct platform_device *pdev)
222 + snd_rpi_i_sabre_q2m.dev = &pdev->dev;
223 + if (pdev->dev.of_node) {
224 + struct device_node *i2s_node;
225 + struct snd_soc_dai_link *dai;
227 + dai = &snd_rpi_i_sabre_q2m_dai[0];
228 + i2s_node = of_parse_phandle(pdev->dev.of_node,
229 + "i2s-controller", 0);
231 + dai->cpu_dai_name = NULL;
232 + dai->cpu_of_node = i2s_node;
233 + dai->platform_name = NULL;
234 + dai->platform_of_node = i2s_node;
236 + dev_err(&pdev->dev,
237 + "Property 'i2s-controller' missing or invalid\n");
241 + dai->name = "I-Sabre Q2M";
242 + dai->stream_name = "I-Sabre Q2M DAC";
243 + dai->dai_fmt = SND_SOC_DAIFMT_I2S
244 + | SND_SOC_DAIFMT_NB_NF
245 + | SND_SOC_DAIFMT_CBS_CFS;
248 + /* Wait for registering codec driver */
251 + ret = snd_soc_register_card(&snd_rpi_i_sabre_q2m);
253 + dev_err(&pdev->dev,
254 + "snd_soc_register_card() failed: %d\n", ret);
260 +static int snd_rpi_i_sabre_q2m_remove(struct platform_device *pdev)
262 + return snd_soc_unregister_card(&snd_rpi_i_sabre_q2m);
265 +static const struct of_device_id snd_rpi_i_sabre_q2m_of_match[] = {
266 + { .compatible = "audiophonics,i-sabre-q2m", },
269 +MODULE_DEVICE_TABLE(of, snd_rpi_i_sabre_q2m_of_match);
271 +static struct platform_driver snd_rpi_i_sabre_q2m_driver = {
273 + .name = "snd-rpi-i-sabre-q2m",
274 + .owner = THIS_MODULE,
275 + .of_match_table = snd_rpi_i_sabre_q2m_of_match,
277 + .probe = snd_rpi_i_sabre_q2m_probe,
278 + .remove = snd_rpi_i_sabre_q2m_remove,
280 +module_platform_driver(snd_rpi_i_sabre_q2m_driver);
282 +MODULE_DESCRIPTION("ASoC Driver for I-Sabre Q2M");
283 +MODULE_AUTHOR("Audiophonics <http://www.audiophonics.fr>");
284 +MODULE_LICENSE("GPL");
285 --- a/sound/soc/codecs/Kconfig
286 +++ b/sound/soc/codecs/Kconfig
287 @@ -85,6 +85,7 @@ config SND_SOC_ALL_CODECS
288 select SND_SOC_ICS43432
289 select SND_SOC_INNO_RK3036
290 select SND_SOC_ISABELLE if I2C
291 + select SND_SOC_I_SABRE_CODEC if I2C
292 select SND_SOC_JZ4740_CODEC
293 select SND_SOC_LM4857 if I2C
294 select SND_SOC_LM49453 if I2C
295 @@ -1322,4 +1323,8 @@ config SND_SOC_TPA6130A2
296 tristate "Texas Instruments TPA6130A2 headphone amplifier"
299 +config SND_SOC_I_SABRE_CODEC
300 + tristate "Audiophonics I-SABRE Codec"
304 --- a/sound/soc/codecs/Makefile
305 +++ b/sound/soc/codecs/Makefile
306 @@ -81,6 +81,7 @@ snd-soc-hdac-hdmi-objs := hdac_hdmi.o
307 snd-soc-ics43432-objs := ics43432.o
308 snd-soc-inno-rk3036-objs := inno_rk3036.o
309 snd-soc-isabelle-objs := isabelle.o
310 +snd-soc-i-sabre-codec-objs := i-sabre-codec.o
311 snd-soc-jz4740-codec-objs := jz4740.o
312 snd-soc-l3-objs := l3.o
313 snd-soc-lm4857-objs := lm4857.o
314 @@ -343,6 +344,7 @@ obj-$(CONFIG_SND_SOC_HDAC_HDMI) += snd-s
315 obj-$(CONFIG_SND_SOC_ICS43432) += snd-soc-ics43432.o
316 obj-$(CONFIG_SND_SOC_INNO_RK3036) += snd-soc-inno-rk3036.o
317 obj-$(CONFIG_SND_SOC_ISABELLE) += snd-soc-isabelle.o
318 +obj-$(CONFIG_SND_SOC_I_SABRE_CODEC) += snd-soc-i-sabre-codec.o
319 obj-$(CONFIG_SND_SOC_JZ4740_CODEC) += snd-soc-jz4740-codec.o
320 obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o
321 obj-$(CONFIG_SND_SOC_LM4857) += snd-soc-lm4857.o
323 +++ b/sound/soc/codecs/i-sabre-codec.c
326 + * Driver for I-Sabre Q2M
328 + * Author: Satoru Kawase
329 + * Modified by: Xiao Qingyong
330 + * Modified by: JC BARBAUD (Mute)
331 + * Update kernel v4.18+ by : Audiophonics
332 + * Copyright 2018 Audiophonics
334 + * This program is free software; you can redistribute it and/or
335 + * modify it under the terms of the GNU General Public License
336 + * version 2 as published by the Free Software Foundation.
338 + * This program is distributed in the hope that it will be useful, but
339 + * WITHOUT ANY WARRANTY; without even the implied warranty of
340 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
341 + * General Public License for more details.
345 +#include <linux/init.h>
346 +#include <linux/module.h>
347 +#include <linux/regmap.h>
348 +#include <linux/i2c.h>
349 +#include <sound/soc.h>
350 +#include <sound/pcm_params.h>
351 +#include <sound/tlv.h>
353 +#include "i-sabre-codec.h"
356 +/* I-Sabre Q2M Codec Private Data */
357 +struct i_sabre_codec_priv {
358 + struct regmap *regmap;
363 +/* I-Sabre Q2M Codec Default Register Value */
364 +static const struct reg_default i_sabre_codec_reg_defaults[] = {
365 + { ISABRECODEC_REG_10, 0x00 },
366 + { ISABRECODEC_REG_20, 0x00 },
367 + { ISABRECODEC_REG_21, 0x00 },
368 + { ISABRECODEC_REG_22, 0x00 },
369 + { ISABRECODEC_REG_24, 0x00 },
373 +static bool i_sabre_codec_writeable(struct device *dev, unsigned int reg)
376 + case ISABRECODEC_REG_10:
377 + case ISABRECODEC_REG_20:
378 + case ISABRECODEC_REG_21:
379 + case ISABRECODEC_REG_22:
380 + case ISABRECODEC_REG_24:
388 +static bool i_sabre_codec_readable(struct device *dev, unsigned int reg)
391 + case ISABRECODEC_REG_01:
392 + case ISABRECODEC_REG_02:
393 + case ISABRECODEC_REG_10:
394 + case ISABRECODEC_REG_20:
395 + case ISABRECODEC_REG_21:
396 + case ISABRECODEC_REG_22:
397 + case ISABRECODEC_REG_24:
405 +static bool i_sabre_codec_volatile(struct device *dev, unsigned int reg)
408 + case ISABRECODEC_REG_01:
409 + case ISABRECODEC_REG_02:
419 +static const DECLARE_TLV_DB_SCALE(volume_tlv, -10000, 100, 0);
423 +static const char * const fir_filter_type_texts[] = {
425 + "corrected minimum phase fast",
426 + "minimum phase slow",
427 + "minimum phase fast",
428 + "linear phase slow",
429 + "linear phase fast",
433 +static SOC_ENUM_SINGLE_DECL(i_sabre_fir_filter_type_enum,
434 + ISABRECODEC_REG_22, 0, fir_filter_type_texts);
437 +/* I2S / SPDIF Select */
438 +static const char * const iis_spdif_sel_texts[] = {
443 +static SOC_ENUM_SINGLE_DECL(i_sabre_iis_spdif_sel_enum,
444 + ISABRECODEC_REG_24, 0, iis_spdif_sel_texts);
448 +static const struct snd_kcontrol_new i_sabre_codec_controls[] = {
449 +SOC_SINGLE_RANGE_TLV("Digital Playback Volume", ISABRECODEC_REG_20, 0, 0, 100, 1, volume_tlv),
450 +SOC_SINGLE("Digital Playback Switch", ISABRECODEC_REG_21, 0, 1, 1),
451 +SOC_ENUM("FIR Filter Type", i_sabre_fir_filter_type_enum),
452 +SOC_ENUM("I2S/SPDIF Select", i_sabre_iis_spdif_sel_enum),
456 +static const u32 i_sabre_codec_dai_rates_slave[] = {
457 + 8000, 11025, 16000, 22050, 32000,
458 + 44100, 48000, 64000, 88200, 96000,
459 + 176400, 192000, 352800, 384000,
460 + 705600, 768000, 1411200, 1536000
463 +static const struct snd_pcm_hw_constraint_list constraints_slave = {
464 + .list = i_sabre_codec_dai_rates_slave,
465 + .count = ARRAY_SIZE(i_sabre_codec_dai_rates_slave),
468 +static int i_sabre_codec_dai_startup_slave(
469 + struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
471 + struct snd_soc_component *component = dai->component;
474 + ret = snd_pcm_hw_constraint_list(substream->runtime,
475 + 0, SNDRV_PCM_HW_PARAM_RATE, &constraints_slave);
477 + dev_err(component->card->dev, "Failed to setup rates constraints: %d\n", ret);
483 +static int i_sabre_codec_dai_startup(
484 + struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
486 + struct snd_soc_component *component = dai->component;
487 + struct i_sabre_codec_priv *i_sabre_codec
488 + = snd_soc_component_get_drvdata(component);
490 + switch (i_sabre_codec->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
491 + case SND_SOC_DAIFMT_CBS_CFS:
492 + return i_sabre_codec_dai_startup_slave(substream, dai);
499 +static int i_sabre_codec_hw_params(
500 + struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params,
501 + struct snd_soc_dai *dai)
503 + struct snd_soc_component *component = dai->component;
504 + struct i_sabre_codec_priv *i_sabre_codec
505 + = snd_soc_component_get_drvdata(component);
506 + unsigned int daifmt;
509 + dev_dbg(component->card->dev, "hw_params %u Hz, %u channels\n",
510 + params_rate(params), params_channels(params));
512 + /* Check I2S Format (Bit Size) */
513 + format_width = snd_pcm_format_width(params_format(params));
514 + if ((format_width != 32) && (format_width != 16)) {
515 + dev_err(component->card->dev, "Bad frame size: %d\n",
516 + snd_pcm_format_width(params_format(params)));
520 + /* Check Slave Mode */
521 + daifmt = i_sabre_codec->fmt & SND_SOC_DAIFMT_MASTER_MASK;
522 + if (daifmt != SND_SOC_DAIFMT_CBS_CFS) {
526 + /* Notify Sampling Frequency */
527 + switch (params_rate(params))
535 + snd_soc_component_update_bits(component, ISABRECODEC_REG_10, 0x01, 0x00);
544 + snd_soc_component_update_bits(component, ISABRECODEC_REG_10, 0x01, 0x01);
551 +static int i_sabre_codec_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
553 + struct snd_soc_component *component = dai->component;
554 + struct i_sabre_codec_priv *i_sabre_codec
555 + = snd_soc_component_get_drvdata(component);
557 + /* interface format */
558 + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
559 + case SND_SOC_DAIFMT_I2S:
562 + case SND_SOC_DAIFMT_RIGHT_J:
563 + case SND_SOC_DAIFMT_LEFT_J:
568 + /* clock inversion */
569 + if ((fmt & SND_SOC_DAIFMT_INV_MASK) != SND_SOC_DAIFMT_NB_NF) {
573 + /* Set Audio Data Format */
574 + i_sabre_codec->fmt = fmt;
579 +static int i_sabre_codec_dac_mute(struct snd_soc_dai *dai, int mute)
581 + struct snd_soc_component *component = dai->component;
584 + snd_soc_component_update_bits(component, ISABRECODEC_REG_21, 0x01, 0x01);
586 + snd_soc_component_update_bits(component, ISABRECODEC_REG_21, 0x01, 0x00);
593 +static const struct snd_soc_dai_ops i_sabre_codec_dai_ops = {
594 + .startup = i_sabre_codec_dai_startup,
595 + .hw_params = i_sabre_codec_hw_params,
596 + .set_fmt = i_sabre_codec_set_fmt,
597 + .digital_mute = i_sabre_codec_dac_mute,
600 +static struct snd_soc_dai_driver i_sabre_codec_dai = {
601 + .name = "i-sabre-codec-dai",
603 + .stream_name = "Playback",
606 + .rates = SNDRV_PCM_RATE_CONTINUOUS,
608 + .rate_max = 1536000,
609 + .formats = SNDRV_PCM_FMTBIT_S16_LE
610 + | SNDRV_PCM_FMTBIT_S32_LE,
612 + .ops = &i_sabre_codec_dai_ops,
615 +static struct snd_soc_component_driver i_sabre_codec_codec_driver = {
616 + .controls = i_sabre_codec_controls,
617 + .num_controls = ARRAY_SIZE(i_sabre_codec_controls),
621 +static const struct regmap_config i_sabre_codec_regmap = {
624 + .max_register = ISABRECODEC_MAX_REG,
626 + .reg_defaults = i_sabre_codec_reg_defaults,
627 + .num_reg_defaults = ARRAY_SIZE(i_sabre_codec_reg_defaults),
629 + .writeable_reg = i_sabre_codec_writeable,
630 + .readable_reg = i_sabre_codec_readable,
631 + .volatile_reg = i_sabre_codec_volatile,
633 + .cache_type = REGCACHE_RBTREE,
637 +static int i_sabre_codec_probe(struct device *dev, struct regmap *regmap)
639 + struct i_sabre_codec_priv *i_sabre_codec;
642 + i_sabre_codec = devm_kzalloc(dev, sizeof(*i_sabre_codec), GFP_KERNEL);
643 + if (!i_sabre_codec) {
644 + dev_err(dev, "devm_kzalloc");
648 + i_sabre_codec->regmap = regmap;
650 + dev_set_drvdata(dev, i_sabre_codec);
652 + ret = snd_soc_register_component(dev,
653 + &i_sabre_codec_codec_driver, &i_sabre_codec_dai, 1);
655 + dev_err(dev, "Failed to register CODEC: %d\n", ret);
662 +static void i_sabre_codec_remove(struct device *dev)
664 + snd_soc_unregister_component(dev);
668 +static int i_sabre_codec_i2c_probe(
669 + struct i2c_client *i2c, const struct i2c_device_id *id)
671 + struct regmap *regmap;
673 + regmap = devm_regmap_init_i2c(i2c, &i_sabre_codec_regmap);
674 + if (IS_ERR(regmap)) {
675 + return PTR_ERR(regmap);
678 + return i_sabre_codec_probe(&i2c->dev, regmap);
681 +static int i_sabre_codec_i2c_remove(struct i2c_client *i2c)
683 + i_sabre_codec_remove(&i2c->dev);
689 +static const struct i2c_device_id i_sabre_codec_i2c_id[] = {
690 + { "i-sabre-codec", },
693 +MODULE_DEVICE_TABLE(i2c, i_sabre_codec_i2c_id);
695 +static const struct of_device_id i_sabre_codec_of_match[] = {
696 + { .compatible = "audiophonics,i-sabre-codec", },
699 +MODULE_DEVICE_TABLE(of, i_sabre_codec_of_match);
701 +static struct i2c_driver i_sabre_codec_i2c_driver = {
703 + .name = "i-sabre-codec-i2c",
704 + .owner = THIS_MODULE,
705 + .of_match_table = of_match_ptr(i_sabre_codec_of_match),
707 + .probe = i_sabre_codec_i2c_probe,
708 + .remove = i_sabre_codec_i2c_remove,
709 + .id_table = i_sabre_codec_i2c_id,
711 +module_i2c_driver(i_sabre_codec_i2c_driver);
714 +MODULE_DESCRIPTION("ASoC I-Sabre Q2M codec driver");
715 +MODULE_AUTHOR("Audiophonics <http://www.audiophonics.fr>");
716 +MODULE_LICENSE("GPL");
718 +++ b/sound/soc/codecs/i-sabre-codec.h
721 + * Driver for I-Sabre Q2M
723 + * Author: Satoru Kawase
724 + * Modified by: Xiao Qingyong
725 + * Copyright 2018 Audiophonics
727 + * This program is free software; you can redistribute it and/or
728 + * modify it under the terms of the GNU General Public License
729 + * version 2 as published by the Free Software Foundation.
731 + * This program is distributed in the hope that it will be useful, but
732 + * WITHOUT ANY WARRANTY; without even the implied warranty of
733 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
734 + * General Public License for more details.
737 +#ifndef _SND_SOC_ISABRECODEC
738 +#define _SND_SOC_ISABRECODEC
741 +/* ISABRECODEC Register Address */
742 +#define ISABRECODEC_REG_01 0x01 /* Virtual Device ID : 0x01 = es9038q2m */
743 +#define ISABRECODEC_REG_02 0x02 /* API revision : 0x01 = Revision 01 */
744 +#define ISABRECODEC_REG_10 0x10 /* 0x01 = above 192kHz, 0x00 = otherwise */
745 +#define ISABRECODEC_REG_20 0x20 /* 0 - 100 (decimal value, 0 = min., 100 = max.) */
746 +#define ISABRECODEC_REG_21 0x21 /* 0x00 = Mute OFF, 0x01 = Mute ON */
747 +#define ISABRECODEC_REG_22 0x22
750 + 0x01 = corrected minimum phase fast,
751 + 0x02 = minimum phase slow,
752 + 0x03 = minimum phase fast,
753 + 0x04 = linear phase slow,
754 + 0x05 = linear phase fast,
755 + 0x06 = apodizing fast,
757 +//#define ISABRECODEC_REG_23 0x23 /* reserved */
758 +#define ISABRECODEC_REG_24 0x24 /* 0x00 = I2S, 0x01 = SPDIF */
759 +#define ISABRECODEC_MAX_REG 0x24 /* Maximum Register Number */
761 +#endif /* _SND_SOC_ISABRECODEC */