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 | cx2584x, in kernels 2.6.16 or newer. |
| 26 | |
| 27 | */ |
| 28 | |
| 29 | #include "pvrusb2-cx2584x-v4l.h" |
| 30 | #include "pvrusb2-video-v4l.h" |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 31 | |
| 32 | |
| 33 | #include "pvrusb2-hdw-internal.h" |
| 34 | #include "pvrusb2-debug.h" |
| 35 | #include <media/cx25840.h> |
| 36 | #include <linux/videodev2.h> |
| 37 | #include <media/v4l2-common.h> |
| 38 | #include <linux/errno.h> |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 39 | |
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_item { |
| 42 | int vid; |
| 43 | int aud; |
| 44 | }; |
| 45 | |
| 46 | struct routing_scheme { |
| 47 | const struct routing_scheme_item *def; |
| 48 | unsigned int cnt; |
| 49 | }; |
| 50 | |
| 51 | static const struct routing_scheme_item routing_scheme0[] = { |
| 52 | [PVR2_CVAL_INPUT_TV] = { |
| 53 | .vid = CX25840_COMPOSITE7, |
| 54 | .aud = CX25840_AUDIO8, |
| 55 | }, |
| 56 | [PVR2_CVAL_INPUT_RADIO] = { /* Treat the same as composite */ |
| 57 | .vid = CX25840_COMPOSITE3, |
| 58 | .aud = CX25840_AUDIO_SERIAL, |
| 59 | }, |
| 60 | [PVR2_CVAL_INPUT_COMPOSITE] = { |
| 61 | .vid = CX25840_COMPOSITE3, |
| 62 | .aud = CX25840_AUDIO_SERIAL, |
| 63 | }, |
| 64 | [PVR2_CVAL_INPUT_SVIDEO] = { |
| 65 | .vid = CX25840_SVIDEO1, |
| 66 | .aud = CX25840_AUDIO_SERIAL, |
| 67 | }, |
| 68 | }; |
| 69 | |
Mike Isely | 81e804c | 2009-06-20 14:55:31 -0300 | [diff] [blame] | 70 | static const struct routing_scheme routing_def0 = { |
| 71 | .def = routing_scheme0, |
| 72 | .cnt = ARRAY_SIZE(routing_scheme0), |
| 73 | }; |
| 74 | |
Mike Isely | 9e2e3ae | 2007-11-26 02:14:23 -0300 | [diff] [blame] | 75 | /* Specific to gotview device */ |
| 76 | static const struct routing_scheme_item routing_schemegv[] = { |
| 77 | [PVR2_CVAL_INPUT_TV] = { |
| 78 | .vid = CX25840_COMPOSITE2, |
| 79 | .aud = CX25840_AUDIO5, |
| 80 | }, |
Mike Isely | 1df59f0 | 2008-04-21 03:50:39 -0300 | [diff] [blame] | 81 | [PVR2_CVAL_INPUT_RADIO] = { |
| 82 | /* line-in is used for radio and composite. A GPIO is |
| 83 | used to switch between the two choices. */ |
Mike Isely | 9e2e3ae | 2007-11-26 02:14:23 -0300 | [diff] [blame] | 84 | .vid = CX25840_COMPOSITE1, |
| 85 | .aud = CX25840_AUDIO_SERIAL, |
| 86 | }, |
| 87 | [PVR2_CVAL_INPUT_COMPOSITE] = { |
| 88 | .vid = CX25840_COMPOSITE1, |
| 89 | .aud = CX25840_AUDIO_SERIAL, |
| 90 | }, |
| 91 | [PVR2_CVAL_INPUT_SVIDEO] = { |
| 92 | .vid = (CX25840_SVIDEO_LUMA3|CX25840_SVIDEO_CHROMA4), |
| 93 | .aud = CX25840_AUDIO_SERIAL, |
| 94 | }, |
| 95 | }; |
| 96 | |
Mike Isely | 81e804c | 2009-06-20 14:55:31 -0300 | [diff] [blame] | 97 | static const struct routing_scheme routing_defgv = { |
| 98 | .def = routing_schemegv, |
| 99 | .cnt = ARRAY_SIZE(routing_schemegv), |
| 100 | }; |
| 101 | |
Mike Isely | 43823c0 | 2011-03-13 20:37:11 -0300 | [diff] [blame] | 102 | /* Specific to grabster av400 device */ |
| 103 | static const struct routing_scheme_item routing_schemeav400[] = { |
| 104 | [PVR2_CVAL_INPUT_COMPOSITE] = { |
| 105 | .vid = CX25840_COMPOSITE1, |
| 106 | .aud = CX25840_AUDIO_SERIAL, |
| 107 | }, |
| 108 | [PVR2_CVAL_INPUT_SVIDEO] = { |
| 109 | .vid = (CX25840_SVIDEO_LUMA2|CX25840_SVIDEO_CHROMA4), |
| 110 | .aud = CX25840_AUDIO_SERIAL, |
| 111 | }, |
| 112 | }; |
| 113 | |
| 114 | static const struct routing_scheme routing_defav400 = { |
| 115 | .def = routing_schemeav400, |
| 116 | .cnt = ARRAY_SIZE(routing_schemeav400), |
| 117 | }; |
| 118 | |
Mike Isely | 81e804c | 2009-06-20 14:55:31 -0300 | [diff] [blame] | 119 | static const struct routing_scheme *routing_schemes[] = { |
| 120 | [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0, |
| 121 | [PVR2_ROUTING_SCHEME_GOTVIEW] = &routing_defgv, |
Mike Isely | 43823c0 | 2011-03-13 20:37:11 -0300 | [diff] [blame] | 122 | [PVR2_ROUTING_SCHEME_AV400] = &routing_defav400, |
Mike Isely | f5174af | 2007-11-26 02:07:26 -0300 | [diff] [blame] | 123 | }; |
| 124 | |
Mike Isely | 634ba26 | 2009-03-07 00:54:02 -0300 | [diff] [blame] | 125 | void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) |
| 126 | { |
Mike Isely | 5e430ca | 2009-03-07 01:51:54 -0300 | [diff] [blame] | 127 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev cx2584x update..."); |
Mike Isely | 2776472 | 2009-03-07 01:57:25 -0300 | [diff] [blame] | 128 | if (hdw->input_dirty || hdw->force_dirty) { |
Mike Isely | 634ba26 | 2009-03-07 00:54:02 -0300 | [diff] [blame] | 129 | enum cx25840_video_input vid_input; |
| 130 | enum cx25840_audio_input aud_input; |
| 131 | const struct routing_scheme *sp; |
| 132 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; |
| 133 | |
Mike Isely | 90135c9 | 2009-06-20 14:57:24 -0300 | [diff] [blame] | 134 | sp = (sid < ARRAY_SIZE(routing_schemes)) ? |
| 135 | routing_schemes[sid] : NULL; |
| 136 | if ((sp == NULL) || |
| 137 | (hdw->input_val < 0) || |
| 138 | (hdw->input_val >= sp->cnt)) { |
Mike Isely | 634ba26 | 2009-03-07 00:54:02 -0300 | [diff] [blame] | 139 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 140 | "*** WARNING *** subdev cx2584x set_input:" |
| 141 | " Invalid routing scheme (%u)" |
| 142 | " and/or input (%d)", |
| 143 | sid, hdw->input_val); |
| 144 | return; |
| 145 | } |
Mike Isely | 90135c9 | 2009-06-20 14:57:24 -0300 | [diff] [blame] | 146 | vid_input = sp->def[hdw->input_val].vid; |
| 147 | aud_input = sp->def[hdw->input_val].aud; |
Mike Isely | 634ba26 | 2009-03-07 00:54:02 -0300 | [diff] [blame] | 148 | pvr2_trace(PVR2_TRACE_CHIPS, |
Mike Isely | 5e430ca | 2009-03-07 01:51:54 -0300 | [diff] [blame] | 149 | "subdev cx2584x set_input vid=0x%x aud=0x%x", |
Mike Isely | 634ba26 | 2009-03-07 00:54:02 -0300 | [diff] [blame] | 150 | vid_input, aud_input); |
Hans Verkuil | 5325b42 | 2009-04-02 11:26:22 -0300 | [diff] [blame] | 151 | sd->ops->video->s_routing(sd, (u32)vid_input, 0, 0); |
| 152 | sd->ops->audio->s_routing(sd, (u32)aud_input, 0, 0); |
Mike Isely | 634ba26 | 2009-03-07 00:54:02 -0300 | [diff] [blame] | 153 | } |
| 154 | } |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 155 | |
| 156 | |
Mike Isely | acd92d4 | 2009-03-06 23:32:02 -0300 | [diff] [blame] | 157 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 158 | /* |
| 159 | Stuff for Emacs to see, in order to encourage consistent editing style: |
| 160 | *** Local Variables: *** |
| 161 | *** mode: c *** |
| 162 | *** fill-column: 70 *** |
| 163 | *** tab-width: 8 *** |
| 164 | *** c-basic-offset: 8 *** |
| 165 | *** End: *** |
| 166 | */ |