1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30#include "pvrusb2-video-v4l.h"
31
32
33
34#include "pvrusb2-hdw-internal.h"
35#include "pvrusb2-debug.h"
36#include <linux/videodev2.h>
37#include <media/v4l2-common.h>
38#include <media/saa7115.h>
39#include <linux/errno.h>
40#include <linux/slab.h>
41
42struct routing_scheme {
43 const int *def;
44 unsigned int cnt;
45};
46
47
48static const int routing_scheme0[] = {
49 [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4,
50
51
52 [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5,
53 [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE5,
54 [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2,
55};
56
57static const struct routing_scheme routing_def0 = {
58 .def = routing_scheme0,
59 .cnt = ARRAY_SIZE(routing_scheme0),
60};
61
62static const int routing_scheme1[] = {
63 [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4,
64 [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5,
65 [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE3,
66 [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2,
67};
68
69static const struct routing_scheme routing_def1 = {
70 .def = routing_scheme1,
71 .cnt = ARRAY_SIZE(routing_scheme1),
72};
73
74static const struct routing_scheme *routing_schemes[] = {
75 [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0,
76 [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1,
77};
78
79void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
80{
81 if (hdw->input_dirty || hdw->force_dirty) {
82 const struct routing_scheme *sp;
83 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
84 u32 input;
85
86 pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
87 hdw->input_val);
88
89 sp = (sid < ARRAY_SIZE(routing_schemes)) ?
90 routing_schemes[sid] : NULL;
91 if ((sp == NULL) ||
92 (hdw->input_val < 0) ||
93 (hdw->input_val >= sp->cnt)) {
94 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
95 "*** WARNING *** subdev v4l2 set_input:"
96 " Invalid routing scheme (%u)"
97 " and/or input (%d)",
98 sid, hdw->input_val);
99 return;
100 }
101 input = sp->def[hdw->input_val];
102 sd->ops->video->s_routing(sd, input, 0, 0);
103 }
104}
105
106
107
108
109
110
111
112
113
114
115
116