Linux 4.19.133
[linux/fpc-iii.git] / drivers / media / usb / pvrusb2 / pvrusb2-cs53l32a.c
blob679f3ff3b0a5c073ff8ab589d59331ffdd92653d
1 /*
4 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
5 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License
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.
20 This source file is specifically designed to interface with the
21 v4l-dvb cs53l32a module.
25 #include "pvrusb2-cs53l32a.h"
28 #include "pvrusb2-hdw-internal.h"
29 #include "pvrusb2-debug.h"
30 #include <linux/videodev2.h>
31 #include <media/v4l2-common.h>
32 #include <linux/errno.h>
34 struct routing_scheme {
35 const int *def;
36 unsigned int cnt;
40 static const int routing_scheme1[] = {
41 [PVR2_CVAL_INPUT_TV] = 2, /* 1 or 2 seems to work here */
42 [PVR2_CVAL_INPUT_RADIO] = 2,
43 [PVR2_CVAL_INPUT_COMPOSITE] = 0,
44 [PVR2_CVAL_INPUT_SVIDEO] = 0,
47 static const struct routing_scheme routing_def1 = {
48 .def = routing_scheme1,
49 .cnt = ARRAY_SIZE(routing_scheme1),
52 static const struct routing_scheme *routing_schemes[] = {
53 [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1,
57 void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
59 if (hdw->input_dirty || hdw->force_dirty) {
60 const struct routing_scheme *sp;
61 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
62 u32 input;
63 pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
64 hdw->input_val);
65 sp = (sid < ARRAY_SIZE(routing_schemes)) ?
66 routing_schemes[sid] : NULL;
67 if ((sp == NULL) ||
68 (hdw->input_val < 0) ||
69 (hdw->input_val >= sp->cnt)) {
70 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
71 "*** WARNING *** subdev v4l2 set_input: Invalid routing scheme (%u) and/or input (%d)",
72 sid, hdw->input_val);
73 return;
75 input = sp->def[hdw->input_val];
76 sd->ops->audio->s_routing(sd, input, 0, 0);