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#include "pvrusb2-cx2584x-v4l.h"
26#include "pvrusb2-video-v4l.h"
27
28
29#include "pvrusb2-hdw-internal.h"
30#include "pvrusb2-debug.h"
31#include <media/drv-intf/cx25840.h>
32#include <linux/videodev2.h>
33#include <media/v4l2-common.h>
34#include <linux/errno.h>
35
36
37struct routing_scheme_item {
38 int vid;
39 int aud;
40};
41
42struct routing_scheme {
43 const struct routing_scheme_item *def;
44 unsigned int cnt;
45};
46
47static const struct routing_scheme_item routing_scheme0[] = {
48 [PVR2_CVAL_INPUT_TV] = {
49 .vid = CX25840_COMPOSITE7,
50 .aud = CX25840_AUDIO8,
51 },
52 [PVR2_CVAL_INPUT_RADIO] = {
53 .vid = CX25840_COMPOSITE3,
54 .aud = CX25840_AUDIO_SERIAL,
55 },
56 [PVR2_CVAL_INPUT_COMPOSITE] = {
57 .vid = CX25840_COMPOSITE3,
58 .aud = CX25840_AUDIO_SERIAL,
59 },
60 [PVR2_CVAL_INPUT_SVIDEO] = {
61 .vid = CX25840_SVIDEO1,
62 .aud = CX25840_AUDIO_SERIAL,
63 },
64};
65
66static const struct routing_scheme routing_def0 = {
67 .def = routing_scheme0,
68 .cnt = ARRAY_SIZE(routing_scheme0),
69};
70
71
72static const struct routing_scheme_item routing_schemegv[] = {
73 [PVR2_CVAL_INPUT_TV] = {
74 .vid = CX25840_COMPOSITE2,
75 .aud = CX25840_AUDIO5,
76 },
77 [PVR2_CVAL_INPUT_RADIO] = {
78
79
80 .vid = CX25840_COMPOSITE1,
81 .aud = CX25840_AUDIO_SERIAL,
82 },
83 [PVR2_CVAL_INPUT_COMPOSITE] = {
84 .vid = CX25840_COMPOSITE1,
85 .aud = CX25840_AUDIO_SERIAL,
86 },
87 [PVR2_CVAL_INPUT_SVIDEO] = {
88 .vid = (CX25840_SVIDEO_LUMA3|CX25840_SVIDEO_CHROMA4),
89 .aud = CX25840_AUDIO_SERIAL,
90 },
91};
92
93static const struct routing_scheme routing_defgv = {
94 .def = routing_schemegv,
95 .cnt = ARRAY_SIZE(routing_schemegv),
96};
97
98
99static const struct routing_scheme_item routing_schemeav400[] = {
100 [PVR2_CVAL_INPUT_COMPOSITE] = {
101 .vid = CX25840_COMPOSITE1,
102 .aud = CX25840_AUDIO_SERIAL,
103 },
104 [PVR2_CVAL_INPUT_SVIDEO] = {
105 .vid = (CX25840_SVIDEO_LUMA2|CX25840_SVIDEO_CHROMA4),
106 .aud = CX25840_AUDIO_SERIAL,
107 },
108};
109
110static const struct routing_scheme routing_defav400 = {
111 .def = routing_schemeav400,
112 .cnt = ARRAY_SIZE(routing_schemeav400),
113};
114
115static const struct routing_scheme *routing_schemes[] = {
116 [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0,
117 [PVR2_ROUTING_SCHEME_GOTVIEW] = &routing_defgv,
118 [PVR2_ROUTING_SCHEME_AV400] = &routing_defav400,
119};
120
121void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
122{
123 pvr2_trace(PVR2_TRACE_CHIPS, "subdev cx2584x update...");
124 if (hdw->input_dirty || hdw->force_dirty) {
125 enum cx25840_video_input vid_input;
126 enum cx25840_audio_input aud_input;
127 const struct routing_scheme *sp;
128 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
129
130 sp = (sid < ARRAY_SIZE(routing_schemes)) ?
131 routing_schemes[sid] : NULL;
132 if ((sp == NULL) ||
133 (hdw->input_val < 0) ||
134 (hdw->input_val >= sp->cnt)) {
135 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
136 "*** WARNING *** subdev cx2584x set_input: Invalid routing scheme (%u) and/or input (%d)",
137 sid, hdw->input_val);
138 return;
139 }
140 vid_input = sp->def[hdw->input_val].vid;
141 aud_input = sp->def[hdw->input_val].aud;
142 pvr2_trace(PVR2_TRACE_CHIPS,
143 "subdev cx2584x set_input vid=0x%x aud=0x%x",
144 vid_input, aud_input);
145 sd->ops->video->s_routing(sd, (u32)vid_input, 0, 0);
146 sd->ops->audio->s_routing(sd, (u32)aud_input, 0, 0);
147 }
148}
149