Commit 8e3d8c6f authored by lamikr's avatar lamikr Committed by Tony Lindgren

[PATCH] ARM: OMAP: Alsa modularisations and support for tsc2101 3/3 (round 2)

This 3/3 patch adds the tsc2101 alsa driver support for the omap-h2.

Just like the aic23 alsa driver, the codec specific functionality is
separated from the common alsa driver functionality that is in the omap-alsa.c.
tsc2101 mixer supports currently the playback selection between
loudspeaker and headset/handset.
Addon of others input and targets should be possible to do afterwards.

In addition it should be possible to add later the support for the
dynamic clocks on top of this series of patches, as discussed
in the omap-linux mailing list.
Signed-off-by: default avatarMika Laitio <lamikr@cc.jyu.fi>
Signed-off-by: default avatarDaniel Petrini <d.pensator@gmail.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent c8af20c5
......@@ -40,8 +40,9 @@
#include <asm/arch/irda.h>
#include <asm/arch/usb.h>
#include <asm/arch/keypad.h>
#include <asm/arch/dma.h>
#include <asm/arch/common.h>
#include <asm/arch/mcbsp.h>
#include <asm/arch/omap-alsa.h>
extern int omap_gpio_init(void);
......@@ -285,6 +286,41 @@ static struct platform_device h2_lcd_device = {
.id = -1,
};
static struct omap_mcbsp_reg_cfg mcbsp_regs = {
.spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
.spcr1 = RINTM(3) | RRST,
.rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(1),
.rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
.xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(1) | XFIG,
.xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
.srgr1 = FWID(15),
.srgr2 = GSYNC | CLKSP | FSGM | FPER(31),
.pcr0 = CLKXM | CLKRM | FSXP | FSRP | CLKXP | CLKRP,
//.pcr0 = CLKXP | CLKRP, /* mcbsp: slave */
};
static struct omap_alsa_codec_config alsa_config = {
.name = "H2 TSC2101",
.mcbsp_regs_alsa = &mcbsp_regs,
.codec_configure_dev = NULL, // tsc2101_configure,
.codec_set_samplerate = NULL, // tsc2101_set_samplerate,
.codec_clock_setup = NULL, // tsc2101_clock_setup,
.codec_clock_on = NULL, // tsc2101_clock_on,
.codec_clock_off = NULL, // tsc2101_clock_off,
.get_default_samplerate = NULL, // tsc2101_get_default_samplerate,
};
static struct platform_device h2_mcbsp1_device = {
.name = "omap_alsa_mcbsp",
.id = 1,
.dev = {
.platform_data = &alsa_config,
},
};
static struct platform_device *h2_devices[] __initdata = {
&h2_nor_device,
&h2_nand_device,
......@@ -292,6 +328,7 @@ static struct platform_device *h2_devices[] __initdata = {
&h2_irda_device,
&h2_kp_device,
&h2_lcd_device,
&h2_mcbsp1_device,
};
static void __init h2_init_smc91x(void)
......
......@@ -45,4 +45,18 @@ config SND_OMAP_AIC23
To compile this driver as a module, choose M here: the module
will be called snd-omap-aic23.
config SND_OMAP_TSC2101
tristate "OMAP TSC2101 alsa driver"
depends on ARCH_OMAP && SND
select SND_PCM
select OMAP_TSC2101
select OMAP_UWIRE if ARCH_OMAP
help
Say Y here if you have a OMAP platform board
and want to use its TSC2101 audio chip. Driver has
been tested with H2 and iPAQ h6300.
To compile this driver as a module, choose M here: the module
will be called snd-omap-tsc2101.
endmenu
......@@ -4,3 +4,6 @@
#
obj-$(CONFIG_SND_OMAP_AIC23) += snd-omap-alsa-aic23.o
snd-omap-alsa-aic23-objs := omap-alsa.o omap-alsa-dma.o omap-alsa-aic23.o omap-alsa-aic23-mixer.o
obj-$(CONFIG_SND_OMAP_TSC2101) += snd-omap-alsa-tsc2101.o
snd-omap-alsa-tsc2101-objs := omap-alsa.o omap-alsa-dma.o omap-alsa-tsc2101.o omap-alsa-tsc2101-mixer.o
This diff is collapsed.
/*
* sound/arm/omap/omap-alsa-tsc2101-mixer.c
*
* Alsa Driver for TSC2101 codec for OMAP platform boards.
*
* Copyright (C) 2005 Mika Laitio <lamikr@cc.jyu.fi> and
* Everett Coleman II <gcc80x86@fuzzyneural.net>
*
* Based on the ideas in omap-aic23.c and sa11xx-uda1341.c
* Copyright (C) 2005 Instituto Nokia de Tecnologia - INdT - Manaus Brazil
* Copyright (C) 2002 Tomas Kasparek <tomas.kasparek@seznam.cz>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*
* History:
*
* 2006-03-01 Mika Laitio - Mixer for the tsc2101 driver used in omap boards.
* Can switch between headset and loudspeaker playback,
* mute and unmute dgc, set dgc volume. Record source switch,
* keyclick, buzzer and headset volume and handset volume control
* are still missing.
*/
#ifndef OMAPALSATSC2101MIXER_H_
#define OMAPALSATSC2101MIXER_H_
#include <asm/hardware/tsc2101.h>
#include <../drivers/ssi/omap-tsc2101.h>
#include "omap-alsa-dma.h"
/* tsc2101 DAC gain control volume specific */
#define OUTPUT_VOLUME_MIN 0x7F // 1111111 = -63.5 DB
#define OUTPUT_VOLUME_MAX 0x32 // 110010
#define OUTPUT_VOLUME_RANGE (OUTPUT_VOLUME_MIN - OUTPUT_VOLUME_MAX)
/* use input vol of 75 for 0dB gain */
#define INPUT_VOLUME_MIN 0x0
#define INPUT_VOLUME_MAX 0x7D
#define INPUT_VOLUME_RANGE (INPUT_VOLUME_MAX - INPUT_VOLUME_MIN)
#define PLAYBACK_TARGET_COUNT 0x02
#define PLAYBACK_TARGET_LOUDSPEAKER 0x00
#define PLAYBACK_TARGET_HEADPHONE 0x01
/* following are used for register 03h Mixer PGA control bits D7-D5 for selecting record source */
#define REC_SRC_TARGET_COUNT 0x08
#define REC_SRC_SINGLE_ENDED_MICIN_HED MPC_MICSEL(0) // oss code referred to MIXER_LINE
#define REC_SRC_SINGLE_ENDED_MICIN_HND MPC_MICSEL(1) // oss code referred to MIXER_MIC
#define REC_SRC_SINGLE_ENDED_AUX1 MPC_MICSEL(2)
#define REC_SRC_SINGLE_ENDED_AUX2 MPC_MICSEL(3)
#define REC_SRC_MICIN_HED_AND_AUX1 MPC_MICSEL(4)
#define REC_SRC_MICIN_HED_AND_AUX2 MPC_MICSEL(5)
#define REC_SRC_MICIN_HND_AND_AUX1 MPC_MICSEL(6)
#define REC_SRC_MICIN_HND_AND_AUX2 MPC_MICSEL(7)
#define DEFAULT_OUTPUT_VOLUME 90 // default output volume to dac dgc
#define DEFAULT_INPUT_VOLUME 20 // default record volume
#define TSC2101_AUDIO_CODEC_REGISTERS_PAGE2 (2)
#endif /*OMAPALSATSC2101MIXER_H_*/
This diff is collapsed.
/*
* arch/arc/mach-omap1/omap-alsa-tsc2101.h
*
* Alsa Driver for TSC2101 codec for OMAP platform boards.
*
* Based on former omap-aic23.h and tsc2101 OSS drivers.
* Copyright (C) 2004 Texas Instruments, Inc.
* Written by Nishanth Menon and Sriram Kannan
*
* Copyright (C) 2006 Instituto Nokia de Tecnologia - INdT - Manaus Brazil
* Alsa modularization by Daniel Petrini (d.pensator@gmail.com)
*
* Copyright (C) 2006 Mika Laitio <lamikr@cc.jyu.fi>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
#ifndef OMAP_ALSA_TSC2101_H_
#define OMAP_ALSA_TSC2101_H_
#include <linux/types.h>
/* Define to set the tsc as the master w.r.t McBSP */
#define TSC_MASTER
#define NUMBER_SAMPLE_RATES_SUPPORTED 16
/*
* AUDIO related MACROS
*/
#ifndef DEFAULT_BITPERSAMPLE
#define DEFAULT_BITPERSAMPLE 16
#endif
#define DEFAULT_SAMPLE_RATE 44100
#define CODEC_CLOCK 12000000
#define AUDIO_MCBSP OMAP_MCBSP1
#define PAGE2_AUDIO_CODEC_REGISTERS (2)
struct tsc2101_samplerate_reg_info {
u16 sample_rate;
u8 divisor;
u8 fs_44kHz; /* if 0 48 khz, if 1 44.1 khz fsref */
};
/*
* Defines codec specific functions pointers that can be used from the
* common omap-alse base driver for all omap codecs. (tsc2101 and aic23)
*/
inline void tsc2101_configure(void);
void tsc2101_set_samplerate(long rate);
void tsc2101_clock_setup(void);
int tsc2101_clock_on(void);
int tsc2101_clock_off(void);
int tsc2101_get_default_samplerate(void);
#endif /*OMAP_ALSA_TSC2101_H_*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment