1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
5 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
10 This source file is specifically designed to interface with the
11 saa711x support that is available in the v4l available starting
16 #include "pvrusb2-video-v4l.h"
20 #include "pvrusb2-hdw-internal.h"
21 #include "pvrusb2-debug.h"
22 #include <linux/videodev2.h>
23 #include <media/v4l2-common.h>
24 #include <media/i2c/saa7115.h>
25 #include <linux/errno.h>
27 struct routing_scheme
{
33 static const int routing_scheme0
[] = {
34 [PVR2_CVAL_INPUT_TV
] = SAA7115_COMPOSITE4
,
35 /* In radio mode, we mute the video, but point at one
36 spot just to stay consistent */
37 [PVR2_CVAL_INPUT_RADIO
] = SAA7115_COMPOSITE5
,
38 [PVR2_CVAL_INPUT_COMPOSITE
] = SAA7115_COMPOSITE5
,
39 [PVR2_CVAL_INPUT_SVIDEO
] = SAA7115_SVIDEO2
,
42 static const struct routing_scheme routing_def0
= {
43 .def
= routing_scheme0
,
44 .cnt
= ARRAY_SIZE(routing_scheme0
),
47 static const int routing_scheme1
[] = {
48 [PVR2_CVAL_INPUT_TV
] = SAA7115_COMPOSITE4
,
49 [PVR2_CVAL_INPUT_RADIO
] = SAA7115_COMPOSITE5
,
50 [PVR2_CVAL_INPUT_COMPOSITE
] = SAA7115_COMPOSITE3
,
51 [PVR2_CVAL_INPUT_SVIDEO
] = SAA7115_SVIDEO2
, /* or SVIDEO0, it seems */
54 static const struct routing_scheme routing_def1
= {
55 .def
= routing_scheme1
,
56 .cnt
= ARRAY_SIZE(routing_scheme1
),
59 static const struct routing_scheme
*routing_schemes
[] = {
60 [PVR2_ROUTING_SCHEME_HAUPPAUGE
] = &routing_def0
,
61 [PVR2_ROUTING_SCHEME_ONAIR
] = &routing_def1
,
64 void pvr2_saa7115_subdev_update(struct pvr2_hdw
*hdw
, struct v4l2_subdev
*sd
)
66 if (hdw
->input_dirty
|| hdw
->force_dirty
) {
67 const struct routing_scheme
*sp
;
68 unsigned int sid
= hdw
->hdw_desc
->signal_routing_scheme
;
71 pvr2_trace(PVR2_TRACE_CHIPS
, "subdev v4l2 set_input(%d)",
74 sp
= (sid
< ARRAY_SIZE(routing_schemes
)) ?
75 routing_schemes
[sid
] : NULL
;
77 (hdw
->input_val
< 0) ||
78 (hdw
->input_val
>= sp
->cnt
)) {
79 pvr2_trace(PVR2_TRACE_ERROR_LEGS
,
80 "*** WARNING *** subdev v4l2 set_input: Invalid routing scheme (%u) and/or input (%d)",
84 input
= sp
->def
[hdw
->input_val
];
85 sd
->ops
->video
->s_routing(sd
, input
, 0, 0);