Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/zaurus Apply WM8731 support patch from TOYOKURA Ats...



details:   https://anonhg.NetBSD.org/src/rev/7ba7545be9a4
branches:  trunk
changeset: 332479:7ba7545be9a4
user:      nonaka <nonaka%NetBSD.org@localhost>
date:      Tue Sep 23 14:49:46 2014 +0000

description:
Apply WM8731 support patch from TOYOKURA Atsushi, arranged by me.

- SL-C700: work fine
- SL-C750: attach failed
- SL-C860: not tested

diffstat:

 sys/arch/zaurus/conf/files.zaurus   |     4 +-
 sys/arch/zaurus/dev/scoop.c         |    35 +-
 sys/arch/zaurus/dev/scoopreg.h      |     4 +-
 sys/arch/zaurus/dev/scoopvar.h      |     3 +-
 sys/arch/zaurus/dev/wm8731_zaudio.c |  1054 ++++++++++++++++++++++++++++++
 sys/arch/zaurus/dev/wm8731reg.h     |   125 +++
 sys/arch/zaurus/dev/wm8731var.h     |    35 +
 sys/arch/zaurus/dev/wm8750_zaudio.c |  1202 +++++++++++++++++++++++++++++++++++
 sys/arch/zaurus/dev/wm8750var.h     |    34 +
 sys/arch/zaurus/dev/zaudio.c        |  1195 +---------------------------------
 sys/arch/zaurus/dev/zaudiovar.h     |    94 ++
 11 files changed, 2623 insertions(+), 1162 deletions(-)

diffs (truncated from 4008 to 300 lines):

diff -r 1eb51466dbd8 -r 7ba7545be9a4 sys/arch/zaurus/conf/files.zaurus
--- a/sys/arch/zaurus/conf/files.zaurus Tue Sep 23 13:48:04 2014 +0000
+++ b/sys/arch/zaurus/conf/files.zaurus Tue Sep 23 14:49:46 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.zaurus,v 1.11 2012/01/29 10:12:41 tsutsui Exp $
+#      $NetBSD: files.zaurus,v 1.12 2014/09/23 14:49:46 nonaka Exp $
 #
 # Sharp Zaurus specific configuration info
 #
@@ -100,6 +100,8 @@
 device zaudio: audiobus, auconv, mulaw, aurateconv, pxaiis
 attach zaudio at iic
 file arch/zaurus/dev/zaudio.c          zaudio
+file arch/zaurus/dev/wm8731_zaudio.c   zaudio & cpu_xscale_pxa250
+file arch/zaurus/dev/wm8750_zaudio.c   zaudio & cpu_xscale_pxa270
 defparam opt_zaudio.h                  ZAUDIO_VOLUME_STRIDE
 
 # Zaurus remote control
diff -r 1eb51466dbd8 -r 7ba7545be9a4 sys/arch/zaurus/dev/scoop.c
--- a/sys/arch/zaurus/dev/scoop.c       Tue Sep 23 13:48:04 2014 +0000
+++ b/sys/arch/zaurus/dev/scoop.c       Tue Sep 23 14:49:46 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scoop.c,v 1.12 2012/10/27 17:18:14 chs Exp $   */
+/*     $NetBSD: scoop.c,v 1.13 2014/09/23 14:49:46 nonaka Exp $        */
 /*     $OpenBSD: zaurus_scoop.c,v 1.12 2005/11/17 05:26:31 uwe Exp $   */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scoop.c,v 1.12 2012/10/27 17:18:14 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scoop.c,v 1.13 2014/09/23 14:49:46 nonaka Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -245,16 +245,45 @@
 }
 
 /*
+ * Enable or disable the speaker output connection.
+ */
+void
+scoop_set_speaker(int onoff)
+{
+       struct scoop_softc *sc;
+
+       if (!ZAURUS_ISC860)
+               return;
+
+       sc = device_lookup_private(&scoop_cd, 0);
+       if (sc == NULL)
+               return;
+
+       scoop_gpio_pin_ctl(sc, SCOOP0_AMP_ON, GPIO_PIN_OUTPUT);
+       if (onoff) {
+               scoop_gpio_pin_write(sc, SCOOP0_AMP_ON, GPIO_PIN_HIGH);
+       } else {
+               scoop_gpio_pin_write(sc, SCOOP0_AMP_ON, GPIO_PIN_LOW);
+       }
+}
+
+/*
  * Enable or disable the mic bias
  */
 void
 scoop_set_mic_bias(int onoff)
 {
+       struct scoop_softc *sc0;
        struct scoop_softc *sc1;
 
+       sc0 = device_lookup_private(&scoop_cd, 0);
        sc1 = device_lookup_private(&scoop_cd, 1);
-       if (sc1 != NULL)
+
+       if (sc1 != NULL) {
                scoop_gpio_pin_write(sc1, SCOOP1_MIC_BIAS, onoff);
+       } else if (sc0 != NULL) {
+               scoop_gpio_pin_write(sc0, SCOOP0_MIC_BIAS, onoff);
+       }
 }
 
 /*
diff -r 1eb51466dbd8 -r 7ba7545be9a4 sys/arch/zaurus/dev/scoopreg.h
--- a/sys/arch/zaurus/dev/scoopreg.h    Tue Sep 23 13:48:04 2014 +0000
+++ b/sys/arch/zaurus/dev/scoopreg.h    Tue Sep 23 14:49:46 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scoopreg.h,v 1.5 2012/01/29 10:12:41 tsutsui Exp $     */
+/*     $NetBSD: scoopreg.h,v 1.6 2014/09/23 14:49:46 nonaka Exp $      */
 /*     $OpenBSD: zaurus_scoopreg.h,v 1.7 2005/07/01 23:51:55 uwe Exp $ */
 
 /*
@@ -68,7 +68,7 @@
 #define SCOOP0_MUTE_R                  5
 #define SCOOP0_AKIN_PULLUP             6
 #define SCOOP0_CF_POWER_C3000          6
-#define SCOOP0_APM_ON                  7
+#define SCOOP0_AMP_ON                  7
 #define SCOOP0_LED_ORANGE_C3000                7
 #define SCOOP0_BACKLIGHT_CONT          8
 #define SCOOP0_JK_A_C3000              8
diff -r 1eb51466dbd8 -r 7ba7545be9a4 sys/arch/zaurus/dev/scoopvar.h
--- a/sys/arch/zaurus/dev/scoopvar.h    Tue Sep 23 13:48:04 2014 +0000
+++ b/sys/arch/zaurus/dev/scoopvar.h    Tue Sep 23 14:49:46 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scoopvar.h,v 1.5 2009/04/18 05:20:21 nonaka Exp $      */
+/*     $NetBSD: scoopvar.h,v 1.6 2014/09/23 14:49:46 nonaka Exp $      */
 /*     $OpenBSD: zaurus_scoopvar.h,v 1.10 2005/11/17 05:26:31 uwe Exp $        */
 
 /*
@@ -32,6 +32,7 @@
 void   scoop_set_sdmmc_power(int);
 void   scoop_check_mcr(void);
 void   scoop_set_headphone(int);
+void   scoop_set_speaker(int);
 void   scoop_set_mic_bias(int);
 void   scoop_akin_pullup(int);
 void   scoop_suspend(void);
diff -r 1eb51466dbd8 -r 7ba7545be9a4 sys/arch/zaurus/dev/wm8731_zaudio.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/zaurus/dev/wm8731_zaudio.c       Tue Sep 23 14:49:46 2014 +0000
@@ -0,0 +1,1054 @@
+/*     $NetBSD: wm8731_zaudio.c,v 1.1 2014/09/23 14:49:46 nonaka Exp $ */
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by TOYOKURA Atsushi.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TODO:
+ *     - powerhooks (currently only works until first suspend)
+ */
+
+#include "opt_cputypes.h"
+#include "opt_zaudio.h"
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: wm8731_zaudio.c,v 1.1 2014/09/23 14:49:46 nonaka Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/callout.h>
+#include <sys/device.h>
+#include <sys/kmem.h>
+#include <sys/kernel.h>
+#include <sys/audioio.h>
+#include <sys/mutex.h>
+#include <sys/intr.h>
+#include <sys/bus.h>
+
+#include <dev/audio_if.h>
+#include <dev/mulaw.h>
+#include <dev/auconv.h>
+
+#include <dev/i2c/i2cvar.h>
+
+#include <arm/xscale/pxa2x0reg.h>
+#include <arm/xscale/pxa2x0var.h>
+#include <arm/xscale/pxa2x0_i2c.h>
+#include <arm/xscale/pxa2x0_i2s.h>
+#include <arm/xscale/pxa2x0_dmac.h>
+#include <arm/xscale/pxa2x0_gpio.h>
+
+#include <zaurus/zaurus/zaurus_var.h>
+#include <zaurus/dev/zaudiovar.h>
+#include <zaurus/dev/wm8731reg.h>
+#include <zaurus/dev/wm8731var.h>
+#include <zaurus/dev/scoopvar.h>
+
+#define WM8731_ADDRESS  0x1B
+
+/* GPIO pins */
+#define GPIO_HP_IN_C860        4
+
+#define WM8731_OP_SPKR 0
+#define WM8731_OP_MIC  1
+#define WM8731_OP_NUM  2
+
+static int     wm8731_finalize(device_t);
+static bool    wm8731_suspend(device_t, const pmf_qual_t *);
+static bool    wm8731_resume(device_t, const pmf_qual_t *);
+static void    wm8731_volume_up(device_t);
+static void    wm8731_volume_down(device_t);
+static void    wm8731_volume_toggle(device_t);
+
+static struct audio_device wm8731_device = {
+       "WM8731",
+       "1.0",
+       "wm"
+};
+
+static const struct audio_format wm8731_formats[] = {
+       {
+               .driver_data    = NULL,
+               .mode           = AUMODE_PLAY | AUMODE_RECORD,
+               .encoding       = AUDIO_ENCODING_SLINEAR_LE,
+               .validbits      = 16,
+               .precision      = 16,
+               .channels       = 2,
+               .channel_mask   = AUFMT_STEREO,
+               .frequency_type = 0,
+               .frequency      = { 4000, 48000 }
+       }
+};
+static const int wm8731_nformats = (int)__arraycount(wm8731_formats);
+
+static void wm8731_init(struct zaudio_softc *);
+static int wm8731_jack_intr(void *);
+static void wm8731_jack(void *);
+static void wm8731_standby(struct zaudio_softc *);
+static void wm8731_update_volume(struct zaudio_softc *, int);
+static void wm8731_update_mutes(struct zaudio_softc *, int);
+static void wm8731_play_setup(struct zaudio_softc *);
+/*static*/ void wm8731_record_setup(struct zaudio_softc *);
+static int wm8731_query_encoding(void *, struct audio_encoding *);
+static int wm8731_set_params(void *, int, int, audio_params_t *,
+    audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
+static int wm8731_start_output(void *, void *, int, void (*)(void *), void *);
+static int wm8731_start_input(void *, void *, int, void (*)(void *), void *);
+static int wm8731_halt_output(void *);
+static int wm8731_halt_input(void *);
+static int wm8731_getdev(void *, struct audio_device *);
+static int wm8731_set_port(void *, struct mixer_ctrl *);
+static int wm8731_get_port(void *, struct mixer_ctrl *);
+static int wm8731_query_devinfo(void *, struct mixer_devinfo *);
+
+static struct audio_hw_if wm8731_hw_if = {
+       .open                   = zaudio_open,
+       .close                  = zaudio_close,
+       .drain                  = NULL,
+       .query_encoding         = wm8731_query_encoding,
+       .set_params             = wm8731_set_params,
+       .round_blocksize        = zaudio_round_blocksize,
+       .commit_settings        = NULL,
+       .init_output            = NULL,
+       .init_input             = NULL,
+       .start_output           = wm8731_start_output,
+       .start_input            = wm8731_start_input,
+       .halt_output            = wm8731_halt_output,
+       .halt_input             = wm8731_halt_input,
+       .speaker_ctl            = NULL,
+       .getdev                 = wm8731_getdev,
+       .setfd                  = NULL,
+       .set_port               = wm8731_set_port,
+       .get_port               = wm8731_get_port,
+       .query_devinfo          = wm8731_query_devinfo,
+       .allocm                 = zaudio_allocm,
+       .freem                  = zaudio_freem,
+       .round_buffersize       = zaudio_round_buffersize,
+       .mappage                = zaudio_mappage,
+       .get_props              = zaudio_get_props,
+       .trigger_output         = NULL,
+       .trigger_input          = NULL,
+       .dev_ioctl              = NULL,
+       .get_locks              = zaudio_get_locks,
+};
+
+static const uint16_t playback_regs[][2] = {
+       /* Power Down Control */
+       { WM8731_PD_REG, WM8731_CLKOUTPD | WM8731_OSCPD | WM8731_OUTPD
+           | WM8731_ADCPD | WM8731_MICPD | WM8731_LINEINPD },
+
+       /* Digital Audio Path Control */
+       { WM8731_DAP_REG, 0 },
+
+       /* Analogue Audio Path Control */
+       { WM8731_AAP_REG, WM8731_DACSEL | WM8731_MUTEMIC },
+
+       /* Activating DSP and DAI */
+       { WM8731_AC_REG, WM8731_ACTIVE },
+       
+       /* End of list */
+       { 0xffff, 0xffff }
+};
+



Home | Main Index | Thread Index | Old Index