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#include "pvrusb2-video-v4l.h"
27
28
29
30#include "pvrusb2-hdw-internal.h"
31#include "pvrusb2-debug.h"
32#include <linux/videodev2.h>
33#include <media/v4l2-common.h>
34#include <media/i2c/saa7115.h>
35#include <linux/errno.h>
36
37struct routing_scheme {
38 const int *def;
39 unsigned int cnt;
40};
41
42
43static const int routing_scheme0[] = {
44 [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4,
45
46
47 [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5,
48 [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE5,
49 [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2,
50};
51
52static const struct routing_scheme routing_def0 = {
53 .def = routing_scheme0,
54 .cnt = ARRAY_SIZE(routing_scheme0),
55};
56
57static const int routing_scheme1[] = {
58 [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4,
59 [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5,
60 [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE3,
61 [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2,
62};
63
64static const struct routing_scheme routing_def1 = {
65 .def = routing_scheme1,
66 .cnt = ARRAY_SIZE(routing_scheme1),
67};
68
69static const struct routing_scheme *routing_schemes[] = {
70 [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0,
71 [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1,
72};
73
74void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
75{
76 if (hdw->input_dirty || hdw->force_dirty) {
77 const struct routing_scheme *sp;
78 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
79 u32 input;
80
81 pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
82 hdw->input_val);
83
84 sp = (sid < ARRAY_SIZE(routing_schemes)) ?
85 routing_schemes[sid] : NULL;
86 if ((sp == NULL) ||
87 (hdw->input_val < 0) ||
88 (hdw->input_val >= sp->cnt)) {
89 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
90 "*** WARNING *** subdev v4l2 set_input: Invalid routing scheme (%u) and/or input (%d)",
91 sid, hdw->input_val);
92 return;
93 }
94 input = sp->def[hdw->input_val];
95 sd->ops->video->s_routing(sd, input, 0, 0);
96 }
97}
98