Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 1 | /* |
| 2 | * |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 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 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | |
| 24 | This source file is specifically designed to interface with the |
| 25 | saa711x support that is available in the v4l available starting |
| 26 | with linux 2.6.15. |
| 27 | |
| 28 | */ |
| 29 | |
| 30 | #include "pvrusb2-video-v4l.h" |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 31 | |
| 32 | |
Mike Isely | 6f95651 | 2009-03-07 00:43:26 -0300 | [diff] [blame] | 33 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 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> |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 40 | |
Mike Isely | f5174af | 2007-11-26 02:07:26 -0300 | [diff] [blame] | 41 | struct routing_scheme { |
| 42 | const int *def; |
| 43 | unsigned int cnt; |
| 44 | }; |
| 45 | |
| 46 | |
| 47 | static const int routing_scheme0[] = { |
| 48 | [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4, |
| 49 | /* In radio mode, we mute the video, but point at one |
| 50 | spot just to stay consistent */ |
| 51 | [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5, |
| 52 | [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE5, |
| 53 | [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2, |
| 54 | }; |
| 55 | |
Mike Isely | 81e804c | 2009-06-20 14:55:31 -0300 | [diff] [blame] | 56 | static const struct routing_scheme routing_def0 = { |
| 57 | .def = routing_scheme0, |
| 58 | .cnt = ARRAY_SIZE(routing_scheme0), |
| 59 | }; |
| 60 | |
Mike Isely | 2a6b627 | 2009-03-15 17:53:29 -0300 | [diff] [blame] | 61 | static const int routing_scheme1[] = { |
| 62 | [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4, |
| 63 | [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5, |
| 64 | [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE3, |
| 65 | [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2, /* or SVIDEO0, it seems */ |
| 66 | }; |
| 67 | |
Mike Isely | 81e804c | 2009-06-20 14:55:31 -0300 | [diff] [blame] | 68 | static const struct routing_scheme routing_def1 = { |
| 69 | .def = routing_scheme1, |
| 70 | .cnt = ARRAY_SIZE(routing_scheme1), |
| 71 | }; |
| 72 | |
| 73 | static const struct routing_scheme *routing_schemes[] = { |
| 74 | [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0, |
| 75 | [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1, |
Mike Isely | f5174af | 2007-11-26 02:07:26 -0300 | [diff] [blame] | 76 | }; |
| 77 | |
Mike Isely | 6f95651 | 2009-03-07 00:43:26 -0300 | [diff] [blame] | 78 | void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) |
| 79 | { |
Mike Isely | 2776472 | 2009-03-07 01:57:25 -0300 | [diff] [blame] | 80 | if (hdw->input_dirty || hdw->force_dirty) { |
Mike Isely | 6f95651 | 2009-03-07 00:43:26 -0300 | [diff] [blame] | 81 | const struct routing_scheme *sp; |
| 82 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; |
Hans Verkuil | 5325b42 | 2009-04-02 11:26:22 -0300 | [diff] [blame] | 83 | u32 input; |
| 84 | |
Mike Isely | 6f95651 | 2009-03-07 00:43:26 -0300 | [diff] [blame] | 85 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", |
| 86 | hdw->input_val); |
Mike Isely | 90135c9 | 2009-06-20 14:57:24 -0300 | [diff] [blame] | 87 | |
| 88 | sp = (sid < ARRAY_SIZE(routing_schemes)) ? |
| 89 | routing_schemes[sid] : NULL; |
| 90 | if ((sp == NULL) || |
| 91 | (hdw->input_val < 0) || |
| 92 | (hdw->input_val >= sp->cnt)) { |
Mike Isely | 6f95651 | 2009-03-07 00:43:26 -0300 | [diff] [blame] | 93 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 94 | "*** WARNING *** subdev v4l2 set_input:" |
Mike Isely | 1e481cc | 2009-03-07 00:52:42 -0300 | [diff] [blame] | 95 | " Invalid routing scheme (%u)" |
| 96 | " and/or input (%d)", |
Mike Isely | 6f95651 | 2009-03-07 00:43:26 -0300 | [diff] [blame] | 97 | sid, hdw->input_val); |
| 98 | return; |
| 99 | } |
Mike Isely | 90135c9 | 2009-06-20 14:57:24 -0300 | [diff] [blame] | 100 | input = sp->def[hdw->input_val]; |
Hans Verkuil | 5325b42 | 2009-04-02 11:26:22 -0300 | [diff] [blame] | 101 | sd->ops->video->s_routing(sd, input, 0, 0); |
Mike Isely | 6f95651 | 2009-03-07 00:43:26 -0300 | [diff] [blame] | 102 | } |
| 103 | } |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 104 | |
| 105 | |
| 106 | /* |
| 107 | Stuff for Emacs to see, in order to encourage consistent editing style: |
| 108 | *** Local Variables: *** |
| 109 | *** mode: c *** |
| 110 | *** fill-column: 70 *** |
| 111 | *** tab-width: 8 *** |
| 112 | *** c-basic-offset: 8 *** |
| 113 | *** End: *** |
| 114 | */ |