Path: blob/master/drivers/media/video/ivtv/ivtv-routing.c
17880 views
/*1Audio/video-routing-related ivtv functions.2Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>3Copyright (C) 2005-2007 Hans Verkuil <[email protected]>45This program is free software; you can redistribute it and/or modify6it under the terms of the GNU General Public License as published by7the Free Software Foundation; either version 2 of the License, or8(at your option) any later version.910This program is distributed in the hope that it will be useful,11but WITHOUT ANY WARRANTY; without even the implied warranty of12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13GNU General Public License for more details.1415You should have received a copy of the GNU General Public License16along with this program; if not, write to the Free Software17Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*/1920#include "ivtv-driver.h"21#include "ivtv-i2c.h"22#include "ivtv-cards.h"23#include "ivtv-gpio.h"24#include "ivtv-routing.h"2526#include <media/msp3400.h>27#include <media/m52790.h>28#include <media/upd64031a.h>29#include <media/upd64083.h>3031/* Selects the audio input and output according to the current32settings. */33void ivtv_audio_set_io(struct ivtv *itv)34{35const struct ivtv_card_audio_input *in;36u32 input, output = 0;3738/* Determine which input to use */39if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags))40in = &itv->card->radio_input;41else42in = &itv->card->audio_inputs[itv->audio_input];4344/* handle muxer chips */45input = in->muxer_input;46if (itv->card->hw_muxer & IVTV_HW_M52790)47output = M52790_OUT_STEREO;48v4l2_subdev_call(itv->sd_muxer, audio, s_routing,49input, output, 0);5051input = in->audio_input;52output = 0;53if (itv->card->hw_audio & IVTV_HW_MSP34XX)54output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);55ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing,56input, output, 0);57}5859/* Selects the video input and output according to the current60settings. */61void ivtv_video_set_io(struct ivtv *itv)62{63int inp = itv->active_input;64u32 input;65u32 type;6667v4l2_subdev_call(itv->sd_video, video, s_routing,68itv->card->video_inputs[inp].video_input, 0, 0);6970type = itv->card->video_inputs[inp].video_type;7172if (type == IVTV_CARD_INPUT_VID_TUNER) {73input = 0; /* Tuner */74} else if (type < IVTV_CARD_INPUT_COMPOSITE1) {75input = 2; /* S-Video */76} else {77input = 1; /* Composite */78}7980if (itv->card->hw_video & IVTV_HW_GPIO)81ivtv_call_hw(itv, IVTV_HW_GPIO, video, s_routing,82input, 0, 0);8384if (itv->card->hw_video & IVTV_HW_UPD64031A) {85if (type == IVTV_CARD_INPUT_VID_TUNER ||86type >= IVTV_CARD_INPUT_COMPOSITE1) {87/* Composite: GR on, connect to 3DYCS */88input = UPD64031A_GR_ON | UPD64031A_3DYCS_COMPOSITE;89} else {90/* S-Video: GR bypassed, turn it off */91input = UPD64031A_GR_OFF | UPD64031A_3DYCS_DISABLE;92}93input |= itv->card->gr_config;9495ivtv_call_hw(itv, IVTV_HW_UPD64031A, video, s_routing,96input, 0, 0);97}9899if (itv->card->hw_video & IVTV_HW_UPD6408X) {100input = UPD64083_YCS_MODE;101if (type > IVTV_CARD_INPUT_VID_TUNER &&102type < IVTV_CARD_INPUT_COMPOSITE1) {103/* S-Video uses YCNR mode and internal Y-ADC, the104upd64031a is not used. */105input |= UPD64083_YCNR_MODE;106}107else if (itv->card->hw_video & IVTV_HW_UPD64031A) {108/* Use upd64031a output for tuner and109composite(CX23416GYC only) inputs */110if (type == IVTV_CARD_INPUT_VID_TUNER ||111itv->card->type == IVTV_CARD_CX23416GYC) {112input |= UPD64083_EXT_Y_ADC;113}114}115ivtv_call_hw(itv, IVTV_HW_UPD6408X, video, s_routing,116input, 0, 0);117}118}119120121