2 * cx18 audio-related functions
4 * Derived from ivtv-audio.c
6 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #include "cx18-driver.h"
21 #include "cx18-cards.h"
22 #include "cx18-audio.h"
24 #define CX18_AUDIO_ENABLE 0xc72014
25 #define CX18_AI1_MUX_MASK 0x30
26 #define CX18_AI1_MUX_I2S1 0x00
27 #define CX18_AI1_MUX_I2S2 0x10
28 #define CX18_AI1_MUX_843_I2S 0x20
30 /* Selects the audio input and output according to the current
32 int cx18_audio_set_io(struct cx18
*cx
)
34 const struct cx18_card_audio_input
*in
;
38 /* Determine which input to use */
39 if (test_bit(CX18_F_I_RADIO_USER
, &cx
->i_flags
))
40 in
= &cx
->card
->radio_input
;
42 in
= &cx
->card
->audio_inputs
[cx
->audio_input
];
44 /* handle muxer chips */
45 v4l2_subdev_call(cx
->sd_extmux
, audio
, s_routing
,
46 (u32
) in
->muxer_input
, 0, 0);
48 err
= cx18_call_hw_err(cx
, cx
->card
->hw_audio_ctrl
,
49 audio
, s_routing
, in
->audio_input
, 0, 0);
53 /* FIXME - this internal mux should be abstracted to a subdev */
54 u
= cx18_read_reg(cx
, CX18_AUDIO_ENABLE
);
55 v
= u
& ~CX18_AI1_MUX_MASK
;
56 switch (in
->audio_input
) {
57 case CX18_AV_AUDIO_SERIAL1
:
58 v
|= CX18_AI1_MUX_I2S1
;
60 case CX18_AV_AUDIO_SERIAL2
:
61 v
|= CX18_AI1_MUX_I2S2
;
64 v
|= CX18_AI1_MUX_843_I2S
;
68 /* force a toggle of some AI1 MUX control bits */
69 u
&= ~CX18_AI1_MUX_MASK
;
70 switch (in
->audio_input
) {
71 case CX18_AV_AUDIO_SERIAL1
:
72 u
|= CX18_AI1_MUX_843_I2S
;
74 case CX18_AV_AUDIO_SERIAL2
:
75 u
|= CX18_AI1_MUX_843_I2S
;
78 u
|= CX18_AI1_MUX_I2S1
;
81 cx18_write_reg_expect(cx
, u
| 0xb00, CX18_AUDIO_ENABLE
,
82 u
, CX18_AI1_MUX_MASK
);
84 cx18_write_reg_expect(cx
, v
| 0xb00, CX18_AUDIO_ENABLE
,
85 v
, CX18_AI1_MUX_MASK
);