Linux Audio

Check our new training course

Loading...
v6.2
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3    Audio/video-routing-related ivtv functions.
  4    Copyright (C) 2003-2004  Kevin Thayer <nufan_wfk at yahoo.com>
  5    Copyright (C) 2005-2007  Hans Verkuil <hverkuil@xs4all.nl>
  6
 
 
 
 
 
 
 
 
 
 
 
 
 
  7 */
  8
  9#include "ivtv-driver.h"
 10#include "ivtv-i2c.h"
 11#include "ivtv-cards.h"
 12#include "ivtv-gpio.h"
 13#include "ivtv-routing.h"
 14
 15#include <media/drv-intf/msp3400.h>
 16#include <media/i2c/m52790.h>
 17#include <media/i2c/upd64031a.h>
 18#include <media/i2c/upd64083.h>
 19
 20/* Selects the audio input and output according to the current
 21   settings. */
 22void ivtv_audio_set_io(struct ivtv *itv)
 23{
 24	const struct ivtv_card_audio_input *in;
 25	u32 input, output = 0;
 26
 27	/* Determine which input to use */
 28	if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags))
 29		in = &itv->card->radio_input;
 30	else
 31		in = &itv->card->audio_inputs[itv->audio_input];
 32
 33	/* handle muxer chips */
 34	input = in->muxer_input;
 35	if (itv->card->hw_muxer & IVTV_HW_M52790)
 36		output = M52790_OUT_STEREO;
 37	v4l2_subdev_call(itv->sd_muxer, audio, s_routing,
 38			input, output, 0);
 39
 40	input = in->audio_input;
 41	output = 0;
 42	if (itv->card->hw_audio & IVTV_HW_MSP34XX)
 43		output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
 44	ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing,
 45			input, output, 0);
 46}
 47
 48/* Selects the video input and output according to the current
 49   settings. */
 50void ivtv_video_set_io(struct ivtv *itv)
 51{
 52	int inp = itv->active_input;
 53	u32 input;
 54	u32 type;
 55
 56	v4l2_subdev_call(itv->sd_video, video, s_routing,
 57		itv->card->video_inputs[inp].video_input, 0, 0);
 58
 59	type = itv->card->video_inputs[inp].video_type;
 60
 61	if (type == IVTV_CARD_INPUT_VID_TUNER) {
 62		input = 0;  /* Tuner */
 63	} else if (type < IVTV_CARD_INPUT_COMPOSITE1) {
 64		input = 2;  /* S-Video */
 65	} else {
 66		input = 1;  /* Composite */
 67	}
 68
 69	if (itv->card->hw_video & IVTV_HW_GPIO)
 70		ivtv_call_hw(itv, IVTV_HW_GPIO, video, s_routing,
 71				input, 0, 0);
 72
 73	if (itv->card->hw_video & IVTV_HW_UPD64031A) {
 74		if (type == IVTV_CARD_INPUT_VID_TUNER ||
 75		    type >= IVTV_CARD_INPUT_COMPOSITE1) {
 76			/* Composite: GR on, connect to 3DYCS */
 77			input = UPD64031A_GR_ON | UPD64031A_3DYCS_COMPOSITE;
 78		} else {
 79			/* S-Video: GR bypassed, turn it off */
 80			input = UPD64031A_GR_OFF | UPD64031A_3DYCS_DISABLE;
 81		}
 82		input |= itv->card->gr_config;
 83
 84		ivtv_call_hw(itv, IVTV_HW_UPD64031A, video, s_routing,
 85				input, 0, 0);
 86	}
 87
 88	if (itv->card->hw_video & IVTV_HW_UPD6408X) {
 89		input = UPD64083_YCS_MODE;
 90		if (type > IVTV_CARD_INPUT_VID_TUNER &&
 91		    type < IVTV_CARD_INPUT_COMPOSITE1) {
 92			/* S-Video uses YCNR mode and internal Y-ADC, the
 93			   upd64031a is not used. */
 94			input |= UPD64083_YCNR_MODE;
 95		}
 96		else if (itv->card->hw_video & IVTV_HW_UPD64031A) {
 97			/* Use upd64031a output for tuner and
 98			   composite(CX23416GYC only) inputs */
 99			if (type == IVTV_CARD_INPUT_VID_TUNER ||
100			    itv->card->type == IVTV_CARD_CX23416GYC) {
101				input |= UPD64083_EXT_Y_ADC;
102			}
103		}
104		ivtv_call_hw(itv, IVTV_HW_UPD6408X, video, s_routing,
105				input, 0, 0);
106	}
107}
v4.10.11
 
  1/*
  2    Audio/video-routing-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"
 22#include "ivtv-i2c.h"
 23#include "ivtv-cards.h"
 24#include "ivtv-gpio.h"
 25#include "ivtv-routing.h"
 26
 27#include <media/drv-intf/msp3400.h>
 28#include <media/i2c/m52790.h>
 29#include <media/i2c/upd64031a.h>
 30#include <media/i2c/upd64083.h>
 31
 32/* Selects the audio input and output according to the current
 33   settings. */
 34void ivtv_audio_set_io(struct ivtv *itv)
 35{
 36	const struct ivtv_card_audio_input *in;
 37	u32 input, output = 0;
 38
 39	/* Determine which input to use */
 40	if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags))
 41		in = &itv->card->radio_input;
 42	else
 43		in = &itv->card->audio_inputs[itv->audio_input];
 44
 45	/* handle muxer chips */
 46	input = in->muxer_input;
 47	if (itv->card->hw_muxer & IVTV_HW_M52790)
 48		output = M52790_OUT_STEREO;
 49	v4l2_subdev_call(itv->sd_muxer, audio, s_routing,
 50			input, output, 0);
 51
 52	input = in->audio_input;
 53	output = 0;
 54	if (itv->card->hw_audio & IVTV_HW_MSP34XX)
 55		output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
 56	ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing,
 57			input, output, 0);
 58}
 59
 60/* Selects the video input and output according to the current
 61   settings. */
 62void ivtv_video_set_io(struct ivtv *itv)
 63{
 64	int inp = itv->active_input;
 65	u32 input;
 66	u32 type;
 67
 68	v4l2_subdev_call(itv->sd_video, video, s_routing,
 69		itv->card->video_inputs[inp].video_input, 0, 0);
 70
 71	type = itv->card->video_inputs[inp].video_type;
 72
 73	if (type == IVTV_CARD_INPUT_VID_TUNER) {
 74		input = 0;  /* Tuner */
 75	} else if (type < IVTV_CARD_INPUT_COMPOSITE1) {
 76		input = 2;  /* S-Video */
 77	} else {
 78		input = 1;  /* Composite */
 79	}
 80
 81	if (itv->card->hw_video & IVTV_HW_GPIO)
 82		ivtv_call_hw(itv, IVTV_HW_GPIO, video, s_routing,
 83				input, 0, 0);
 84
 85	if (itv->card->hw_video & IVTV_HW_UPD64031A) {
 86		if (type == IVTV_CARD_INPUT_VID_TUNER ||
 87		    type >= IVTV_CARD_INPUT_COMPOSITE1) {
 88			/* Composite: GR on, connect to 3DYCS */
 89			input = UPD64031A_GR_ON | UPD64031A_3DYCS_COMPOSITE;
 90		} else {
 91			/* S-Video: GR bypassed, turn it off */
 92			input = UPD64031A_GR_OFF | UPD64031A_3DYCS_DISABLE;
 93		}
 94		input |= itv->card->gr_config;
 95
 96		ivtv_call_hw(itv, IVTV_HW_UPD64031A, video, s_routing,
 97				input, 0, 0);
 98	}
 99
100	if (itv->card->hw_video & IVTV_HW_UPD6408X) {
101		input = UPD64083_YCS_MODE;
102		if (type > IVTV_CARD_INPUT_VID_TUNER &&
103		    type < IVTV_CARD_INPUT_COMPOSITE1) {
104			/* S-Video uses YCNR mode and internal Y-ADC, the
105			   upd64031a is not used. */
106			input |= UPD64083_YCNR_MODE;
107		}
108		else if (itv->card->hw_video & IVTV_HW_UPD64031A) {
109			/* Use upd64031a output for tuner and
110			   composite(CX23416GYC only) inputs */
111			if (type == IVTV_CARD_INPUT_VID_TUNER ||
112			    itv->card->type == IVTV_CARD_CX23416GYC) {
113				input |= UPD64083_EXT_Y_ADC;
114			}
115		}
116		ivtv_call_hw(itv, IVTV_HW_UPD6408X, video, s_routing,
117				input, 0, 0);
118	}
119}