2 Audio-related ivtv functions.
3 Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>
4 Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "ivtv-driver.h"
22 #include "ivtv-mailbox.h"
24 #include "ivtv-gpio.h"
25 #include "ivtv-cards.h"
26 #include "ivtv-audio.h"
27 #include <media/msp3400.h>
28 #include <linux/videodev.h>
30 /* Selects the audio input and output according to the current
32 int ivtv_audio_set_io(struct ivtv *itv)
34 struct v4l2_routing route;
38 /* Determine which input to use */
39 if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) {
40 audio_input = itv->card->radio_input.audio_input;
41 mux_input = itv->card->radio_input.muxer_input;
43 audio_input = itv->card->audio_inputs[itv->audio_input].audio_input;
44 mux_input = itv->card->audio_inputs[itv->audio_input].muxer_input;
47 /* handle muxer chips */
48 route.input = mux_input;
50 ivtv_i2c_hw(itv, itv->card->hw_muxer, VIDIOC_INT_S_AUDIO_ROUTING, &route);
52 route.input = audio_input;
53 if (itv->card->hw_audio & IVTV_HW_MSP34XX) {
54 route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
56 return ivtv_i2c_hw(itv, itv->card->hw_audio, VIDIOC_INT_S_AUDIO_ROUTING, &route);
59 void ivtv_audio_set_route(struct ivtv *itv, struct v4l2_routing *route)
61 ivtv_i2c_hw(itv, itv->card->hw_audio, VIDIOC_INT_S_AUDIO_ROUTING, route);
64 void ivtv_audio_set_audio_clock_freq(struct ivtv *itv, u8 freq)
66 static u32 freqs[3] = { 44100, 48000, 32000 };
68 /* The audio clock of the digitizer must match the codec sample
69 rate otherwise you get some very strange effects. */
72 ivtv_call_i2c_clients(itv, VIDIOC_INT_AUDIO_CLOCK_FREQ, &freqs[freq]);