diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-05 10:53:54 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-05 10:53:54 -0200 |
commit | 8b702294eb6b500645e914552b2f5077d3251ae7 (patch) | |
tree | 683407291bf8a9dc9226e09b6d235c2f422dd764 /linux/drivers/media/video/em28xx/em28xx-core.c | |
parent | 51549372cf89b75379465e885cb3b2b178be53ad (diff) | |
download | mediapointer-dvb-s2-8b702294eb6b500645e914552b2f5077d3251ae7.tar.gz mediapointer-dvb-s2-8b702294eb6b500645e914552b2f5077d3251ae7.tar.bz2 |
Improve audio setup handling
From: Mauro Carvalho Chehab <mchehab@infradead.org>
It is possible to select audio inputs via em28xx or via ac97 functions.
This patch allows configuring a board to use either one way.
It also do some cleanups at audio setup configurations.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video/em28xx/em28xx-core.c')
-rw-r--r-- | linux/drivers/media/video/em28xx/em28xx-core.c | 87 |
1 files changed, 77 insertions, 10 deletions
diff --git a/linux/drivers/media/video/em28xx/em28xx-core.c b/linux/drivers/media/video/em28xx/em28xx-core.c index f229a83da..98153d70d 100644 --- a/linux/drivers/media/video/em28xx/em28xx-core.c +++ b/linux/drivers/media/video/em28xx/em28xx-core.c @@ -303,7 +303,7 @@ int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, * em28xx_write_ac97() * write a 16 bit value to the specified AC97 address (LSB first!) */ -int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 * val) +static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 *val) { int ret; u8 addr = reg & 0x7f; @@ -319,24 +319,91 @@ int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 * val) return 0; } +int em28xx_set_audio_source(struct em28xx *dev) +{ + static char *enable = "\x08\x08"; + static char *disable = "\x08\x88"; + char *video = enable, *line = disable; + int ret, no_ac97; + u8 input; + + if (dev->is_em2800) { + if (dev->ctl_ainput) + input = EM2800_AUDIO_SRC_LINE; + else + input = EM2800_AUDIO_SRC_TUNER; + + ret = em28xx_write_regs(dev, EM2800_AUDIOSRC_REG, &input, 1); + if (ret < 0) + return ret; + } + + if (dev->has_msp34xx) + input = EM28XX_AUDIO_SRC_TUNER; + else { + switch (dev->ctl_ainput) { + case EM28XX_AMUX_VIDEO: + input = EM28XX_AUDIO_SRC_TUNER; + no_ac97 = 1; + break; + case EM28XX_AMUX_LINE_IN: + input = EM28XX_AUDIO_SRC_LINE; + no_ac97 = 1; + break; + case EM28XX_AMUX_AC97_VIDEO: + input = EM28XX_AUDIO_SRC_LINE; + break; + case EM28XX_AMUX_AC97_LINE_IN: + input = EM28XX_AUDIO_SRC_LINE; + video = disable; + line = enable; + break; + } + } + + ret = em28xx_write_reg_bits(dev, AUDIOSRC_REG, input, 0xc0); + if (ret < 0) + return ret; + + if (no_ac97) + return 0; + + /* Sets AC97 mixer registers */ + + ret = em28xx_write_ac97(dev, VIDEO_AC97, video); + if (ret < 0) + return ret; + + ret = em28xx_write_ac97(dev, LINE_IN_AC97, line); + + return ret; +} + int em28xx_audio_analog_set(struct em28xx *dev) { + int ret; char s[2] = { 0x00, 0x00 }; + s[0] |= 0x1f - dev->volume; s[1] |= 0x1f - dev->volume; + if (dev->mute) s[1] |= 0x80; - return em28xx_write_ac97(dev, MASTER_AC97, s); -} + ret = em28xx_write_ac97(dev, MASTER_AC97, s); + if (ret < 0) + return ret; -#if 0 -int em28xx_audio_analog_mute(struct em28xx *dev, int mute) -{ - /* (un)mute master mixer with maximum volume level */ - return em28xx_write_ac97(dev, MASTER_AC97, - mute ? "\x00\x80" : "\x00\x00"); + ret = em28xx_write_reg_bits(dev, XCLK_REG, + dev->mute ? 0x00 : 0x80, 0x80); + if (ret < 0) + return ret; + + /* Selects the proper audio input */ + ret = em28xx_set_audio_source(dev); + + return ret; } -#endif +EXPORT_SYMBOL_GPL(em28xx_audio_analog_set); int em28xx_colorlevels_set_default(struct em28xx *dev) { |