Path: blob/master/drivers/media/video/cx18/cx18-audio.c
17722 views
/*1* cx18 audio-related functions2*3* Derived from ivtv-audio.c4*5* Copyright (C) 2007 Hans Verkuil <[email protected]>6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2 of the License, or10* (at your option) any later version.11*12* This program is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA20* 02111-1307 USA21*/2223#include "cx18-driver.h"24#include "cx18-io.h"25#include "cx18-cards.h"26#include "cx18-audio.h"2728#define CX18_AUDIO_ENABLE 0xc7201429#define CX18_AI1_MUX_MASK 0x3030#define CX18_AI1_MUX_I2S1 0x0031#define CX18_AI1_MUX_I2S2 0x1032#define CX18_AI1_MUX_843_I2S 0x203334/* Selects the audio input and output according to the current35settings. */36int cx18_audio_set_io(struct cx18 *cx)37{38const struct cx18_card_audio_input *in;39u32 u, v;40int err;4142/* Determine which input to use */43if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags))44in = &cx->card->radio_input;45else46in = &cx->card->audio_inputs[cx->audio_input];4748/* handle muxer chips */49v4l2_subdev_call(cx->sd_extmux, audio, s_routing,50(u32) in->muxer_input, 0, 0);5152err = cx18_call_hw_err(cx, cx->card->hw_audio_ctrl,53audio, s_routing, in->audio_input, 0, 0);54if (err)55return err;5657/* FIXME - this internal mux should be abstracted to a subdev */58u = cx18_read_reg(cx, CX18_AUDIO_ENABLE);59v = u & ~CX18_AI1_MUX_MASK;60switch (in->audio_input) {61case CX18_AV_AUDIO_SERIAL1:62v |= CX18_AI1_MUX_I2S1;63break;64case CX18_AV_AUDIO_SERIAL2:65v |= CX18_AI1_MUX_I2S2;66break;67default:68v |= CX18_AI1_MUX_843_I2S;69break;70}71if (v == u) {72/* force a toggle of some AI1 MUX control bits */73u &= ~CX18_AI1_MUX_MASK;74switch (in->audio_input) {75case CX18_AV_AUDIO_SERIAL1:76u |= CX18_AI1_MUX_843_I2S;77break;78case CX18_AV_AUDIO_SERIAL2:79u |= CX18_AI1_MUX_843_I2S;80break;81default:82u |= CX18_AI1_MUX_I2S1;83break;84}85cx18_write_reg_expect(cx, u | 0xb00, CX18_AUDIO_ENABLE,86u, CX18_AI1_MUX_MASK);87}88cx18_write_reg_expect(cx, v | 0xb00, CX18_AUDIO_ENABLE,89v, CX18_AI1_MUX_MASK);90return 0;91}929394