blob: 6cb65d69c98697353bc8d2c9c7e9f0db23cf719d [file] [log] [blame]
Hans Verkuil1a0adaf2007-04-27 12:31:25 -03001/*
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>
5
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.
10
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.
15
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
19 */
20
21#include "ivtv-driver.h"
Hans Verkuil1a0adaf2007-04-27 12:31:25 -030022#include "ivtv-i2c.h"
Hans Verkuil1a0adaf2007-04-27 12:31:25 -030023#include "ivtv-cards.h"
24#include "ivtv-audio.h"
25#include <media/msp3400.h>
Hans Verkuil1a0adaf2007-04-27 12:31:25 -030026
27/* Selects the audio input and output according to the current
28 settings. */
29int ivtv_audio_set_io(struct ivtv *itv)
30{
31 struct v4l2_routing route;
32 u32 audio_input;
33 int mux_input;
34
35 /* Determine which input to use */
36 if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) {
37 audio_input = itv->card->radio_input.audio_input;
38 mux_input = itv->card->radio_input.muxer_input;
39 } else {
40 audio_input = itv->card->audio_inputs[itv->audio_input].audio_input;
41 mux_input = itv->card->audio_inputs[itv->audio_input].muxer_input;
42 }
43
44 /* handle muxer chips */
45 route.input = mux_input;
46 route.output = 0;
47 ivtv_i2c_hw(itv, itv->card->hw_muxer, VIDIOC_INT_S_AUDIO_ROUTING, &route);
48
49 route.input = audio_input;
50 if (itv->card->hw_audio & IVTV_HW_MSP34XX) {
51 route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
52 }
53 return ivtv_i2c_hw(itv, itv->card->hw_audio, VIDIOC_INT_S_AUDIO_ROUTING, &route);
54}
55
56void ivtv_audio_set_route(struct ivtv *itv, struct v4l2_routing *route)
57{
58 ivtv_i2c_hw(itv, itv->card->hw_audio, VIDIOC_INT_S_AUDIO_ROUTING, route);
59}
60
61void ivtv_audio_set_audio_clock_freq(struct ivtv *itv, u8 freq)
62{
63 static u32 freqs[3] = { 44100, 48000, 32000 };
64
65 /* The audio clock of the digitizer must match the codec sample
66 rate otherwise you get some very strange effects. */
67 if (freq > 2)
68 return;
69 ivtv_call_i2c_clients(itv, VIDIOC_INT_AUDIO_CLOCK_FREQ, &freqs[freq]);
70}
71