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/* 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci This source file is specifically designed to interface with the 118c2ecf20Sopenharmony_ci v4l-dvb cs53l32a module. 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci*/ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "pvrusb2-cs53l32a.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include "pvrusb2-hdw-internal.h" 198c2ecf20Sopenharmony_ci#include "pvrusb2-debug.h" 208c2ecf20Sopenharmony_ci#include <linux/videodev2.h> 218c2ecf20Sopenharmony_ci#include <media/v4l2-common.h> 228c2ecf20Sopenharmony_ci#include <linux/errno.h> 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistruct routing_scheme { 258c2ecf20Sopenharmony_ci const int *def; 268c2ecf20Sopenharmony_ci unsigned int cnt; 278c2ecf20Sopenharmony_ci}; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistatic const int routing_scheme1[] = { 318c2ecf20Sopenharmony_ci [PVR2_CVAL_INPUT_TV] = 2, /* 1 or 2 seems to work here */ 328c2ecf20Sopenharmony_ci [PVR2_CVAL_INPUT_RADIO] = 2, 338c2ecf20Sopenharmony_ci [PVR2_CVAL_INPUT_COMPOSITE] = 0, 348c2ecf20Sopenharmony_ci [PVR2_CVAL_INPUT_SVIDEO] = 0, 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cistatic const struct routing_scheme routing_def1 = { 388c2ecf20Sopenharmony_ci .def = routing_scheme1, 398c2ecf20Sopenharmony_ci .cnt = ARRAY_SIZE(routing_scheme1), 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistatic const struct routing_scheme *routing_schemes[] = { 438c2ecf20Sopenharmony_ci [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1, 448c2ecf20Sopenharmony_ci}; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_civoid pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) 488c2ecf20Sopenharmony_ci{ 498c2ecf20Sopenharmony_ci if (hdw->input_dirty || hdw->force_dirty) { 508c2ecf20Sopenharmony_ci const struct routing_scheme *sp; 518c2ecf20Sopenharmony_ci unsigned int sid = hdw->hdw_desc->signal_routing_scheme; 528c2ecf20Sopenharmony_ci u32 input; 538c2ecf20Sopenharmony_ci pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", 548c2ecf20Sopenharmony_ci hdw->input_val); 558c2ecf20Sopenharmony_ci sp = (sid < ARRAY_SIZE(routing_schemes)) ? 568c2ecf20Sopenharmony_ci routing_schemes[sid] : NULL; 578c2ecf20Sopenharmony_ci if ((sp == NULL) || 588c2ecf20Sopenharmony_ci (hdw->input_val < 0) || 598c2ecf20Sopenharmony_ci (hdw->input_val >= sp->cnt)) { 608c2ecf20Sopenharmony_ci pvr2_trace(PVR2_TRACE_ERROR_LEGS, 618c2ecf20Sopenharmony_ci "*** WARNING *** subdev v4l2 set_input: Invalid routing scheme (%u) and/or input (%d)", 628c2ecf20Sopenharmony_ci sid, hdw->input_val); 638c2ecf20Sopenharmony_ci return; 648c2ecf20Sopenharmony_ci } 658c2ecf20Sopenharmony_ci input = sp->def[hdw->input_val]; 668c2ecf20Sopenharmony_ci sd->ops->audio->s_routing(sd, input, 0, 0); 678c2ecf20Sopenharmony_ci } 688c2ecf20Sopenharmony_ci} 69