18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2005 Mike Isely <isely@pobox.com> 58c2ecf20Sopenharmony_ci * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include "pvrusb2-audio.h" 98c2ecf20Sopenharmony_ci#include "pvrusb2-hdw-internal.h" 108c2ecf20Sopenharmony_ci#include "pvrusb2-debug.h" 118c2ecf20Sopenharmony_ci#include <linux/videodev2.h> 128c2ecf20Sopenharmony_ci#include <media/drv-intf/msp3400.h> 138c2ecf20Sopenharmony_ci#include <media/v4l2-common.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_cistruct routing_scheme { 178c2ecf20Sopenharmony_ci const int *def; 188c2ecf20Sopenharmony_ci unsigned int cnt; 198c2ecf20Sopenharmony_ci}; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistatic const int routing_scheme0[] = { 228c2ecf20Sopenharmony_ci [PVR2_CVAL_INPUT_TV] = MSP_INPUT_DEFAULT, 238c2ecf20Sopenharmony_ci [PVR2_CVAL_INPUT_RADIO] = MSP_INPUT(MSP_IN_SCART2, 248c2ecf20Sopenharmony_ci MSP_IN_TUNER1, 258c2ecf20Sopenharmony_ci MSP_DSP_IN_SCART, 268c2ecf20Sopenharmony_ci MSP_DSP_IN_SCART), 278c2ecf20Sopenharmony_ci [PVR2_CVAL_INPUT_COMPOSITE] = MSP_INPUT(MSP_IN_SCART1, 288c2ecf20Sopenharmony_ci MSP_IN_TUNER1, 298c2ecf20Sopenharmony_ci MSP_DSP_IN_SCART, 308c2ecf20Sopenharmony_ci MSP_DSP_IN_SCART), 318c2ecf20Sopenharmony_ci [PVR2_CVAL_INPUT_SVIDEO] = MSP_INPUT(MSP_IN_SCART1, 328c2ecf20Sopenharmony_ci MSP_IN_TUNER1, 338c2ecf20Sopenharmony_ci MSP_DSP_IN_SCART, 348c2ecf20Sopenharmony_ci MSP_DSP_IN_SCART), 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cistatic const struct routing_scheme routing_def0 = { 388c2ecf20Sopenharmony_ci .def = routing_scheme0, 398c2ecf20Sopenharmony_ci .cnt = ARRAY_SIZE(routing_scheme0), 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistatic const struct routing_scheme *routing_schemes[] = { 438c2ecf20Sopenharmony_ci [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0, 448c2ecf20Sopenharmony_ci}; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_civoid pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) 478c2ecf20Sopenharmony_ci{ 488c2ecf20Sopenharmony_ci if (hdw->input_dirty || hdw->force_dirty) { 498c2ecf20Sopenharmony_ci const struct routing_scheme *sp; 508c2ecf20Sopenharmony_ci unsigned int sid = hdw->hdw_desc->signal_routing_scheme; 518c2ecf20Sopenharmony_ci u32 input; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo"); 548c2ecf20Sopenharmony_ci sp = (sid < ARRAY_SIZE(routing_schemes)) ? 558c2ecf20Sopenharmony_ci routing_schemes[sid] : NULL; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci if ((sp != NULL) && 588c2ecf20Sopenharmony_ci (hdw->input_val >= 0) && 598c2ecf20Sopenharmony_ci (hdw->input_val < sp->cnt)) { 608c2ecf20Sopenharmony_ci input = sp->def[hdw->input_val]; 618c2ecf20Sopenharmony_ci } else { 628c2ecf20Sopenharmony_ci pvr2_trace(PVR2_TRACE_ERROR_LEGS, 638c2ecf20Sopenharmony_ci "*** WARNING *** subdev msp3400 set_input: Invalid routing scheme (%u) and/or input (%d)", 648c2ecf20Sopenharmony_ci sid, hdw->input_val); 658c2ecf20Sopenharmony_ci return; 668c2ecf20Sopenharmony_ci } 678c2ecf20Sopenharmony_ci sd->ops->audio->s_routing(sd, input, 688c2ecf20Sopenharmony_ci MSP_OUTPUT(MSP_SC_IN_DSP_SCART1), 0); 698c2ecf20Sopenharmony_ci } 708c2ecf20Sopenharmony_ci} 71