]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/media/usb/pvrusb2/pvrusb2-cs53l32a.c
Merge branches 'for-4.11/upstream-fixes', 'for-4.12/accutouch', 'for-4.12/cp2112...
[mirror_ubuntu-artful-kernel.git] / drivers / media / usb / pvrusb2 / pvrusb2-cs53l32a.c
1 /*
2 *
3 *
4 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
5 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
6 *
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
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 */
17
18 /*
19
20 This source file is specifically designed to interface with the
21 v4l-dvb cs53l32a module.
22
23 */
24
25 #include "pvrusb2-cs53l32a.h"
26
27
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>
33
34 struct routing_scheme {
35 const int *def;
36 unsigned int cnt;
37 };
38
39
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,
45 };
46
47 static const struct routing_scheme routing_def1 = {
48 .def = routing_scheme1,
49 .cnt = ARRAY_SIZE(routing_scheme1),
50 };
51
52 static const struct routing_scheme *routing_schemes[] = {
53 [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1,
54 };
55
56
57 void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
58 {
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;
74 }
75 input = sp->def[hdw->input_val];
76 sd->ops->audio->s_routing(sd, input, 0, 0);
77 }
78 }