1 | // SPDX-License-Identifier: GPL-2.0-only |
2 | /* |
3 | * |
4 | * Copyright (C) 2005 Mike Isely <isely@pobox.com> |
5 | * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr> |
6 | */ |
7 | |
8 | /* |
9 | |
10 | This source file is specifically designed to interface with the |
11 | v4l-dvb cs53l32a module. |
12 | |
13 | */ |
14 | |
15 | #include "pvrusb2-cs53l32a.h" |
16 | |
17 | |
18 | #include "pvrusb2-hdw-internal.h" |
19 | #include "pvrusb2-debug.h" |
20 | #include <linux/videodev2.h> |
21 | #include <media/v4l2-common.h> |
22 | #include <linux/errno.h> |
23 | |
24 | struct routing_scheme { |
25 | const int *def; |
26 | unsigned int cnt; |
27 | }; |
28 | |
29 | |
30 | static const int routing_scheme1[] = { |
31 | [PVR2_CVAL_INPUT_TV] = 2, /* 1 or 2 seems to work here */ |
32 | [PVR2_CVAL_INPUT_RADIO] = 2, |
33 | [PVR2_CVAL_INPUT_COMPOSITE] = 0, |
34 | [PVR2_CVAL_INPUT_SVIDEO] = 0, |
35 | }; |
36 | |
37 | static const struct routing_scheme routing_def1 = { |
38 | .def = routing_scheme1, |
39 | .cnt = ARRAY_SIZE(routing_scheme1), |
40 | }; |
41 | |
42 | static const struct routing_scheme *routing_schemes[] = { |
43 | [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1, |
44 | }; |
45 | |
46 | |
47 | void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) |
48 | { |
49 | if (hdw->input_dirty || hdw->force_dirty) { |
50 | const struct routing_scheme *sp; |
51 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; |
52 | u32 input; |
53 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)" , |
54 | hdw->input_val); |
55 | sp = (sid < ARRAY_SIZE(routing_schemes)) ? |
56 | routing_schemes[sid] : NULL; |
57 | if ((sp == NULL) || |
58 | (hdw->input_val < 0) || |
59 | (hdw->input_val >= sp->cnt)) { |
60 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
61 | "*** WARNING *** subdev v4l2 set_input: Invalid routing scheme (%u) and/or input (%d)" , |
62 | sid, hdw->input_val); |
63 | return; |
64 | } |
65 | input = sp->def[hdw->input_val]; |
66 | sd->ops->audio->s_routing(sd, input, 0, 0); |
67 | } |
68 | } |
69 | |