diff options
author | Andy Walls <awalls@radix.net> | 2009-03-01 21:10:07 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:43:09 -0400 |
commit | 49a53750b266899f259b1734a4a2c80d4376ba75 (patch) | |
tree | 24a9bd49fc1119815a52f36513ef267764ab83ce /drivers | |
parent | cb95a40e54b96938c2e81de6a95609e915922962 (diff) |
V4L/DVB (10856): cx18: Add interlock so sliced VBI insertion only happens for an MPEG PS
The cx18 private packet insertion code only expects to operate on an MPEG PS
when inserting private packets of sliced VBI data. This patch keeps the cx18
driver from corrupting the MPEG TS or other non-PS stream types, in case the
user enables sliced VBI insertion for these MPEG stream types.
Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/cx18/cx18-controls.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/drivers/media/video/cx18/cx18-controls.c b/drivers/media/video/cx18/cx18-controls.c index 925e01fdbaa6..82fc2f9d4021 100644 --- a/drivers/media/video/cx18/cx18-controls.c +++ b/drivers/media/video/cx18/cx18-controls.c | |||
@@ -166,15 +166,26 @@ static int cx18_g_ctrl(struct cx18 *cx, struct v4l2_control *vctrl) | |||
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
168 | 168 | ||
169 | static int cx18_setup_vbi_fmt(struct cx18 *cx, enum v4l2_mpeg_stream_vbi_fmt fmt) | 169 | static int cx18_setup_vbi_fmt(struct cx18 *cx, |
170 | enum v4l2_mpeg_stream_vbi_fmt fmt, | ||
171 | enum v4l2_mpeg_stream_type type) | ||
170 | { | 172 | { |
171 | if (!(cx->v4l2_cap & V4L2_CAP_SLICED_VBI_CAPTURE)) | 173 | if (!(cx->v4l2_cap & V4L2_CAP_SLICED_VBI_CAPTURE)) |
172 | return -EINVAL; | 174 | return -EINVAL; |
173 | if (atomic_read(&cx->ana_capturing) > 0) | 175 | if (atomic_read(&cx->ana_capturing) > 0) |
174 | return -EBUSY; | 176 | return -EBUSY; |
175 | 177 | ||
176 | /* First try to allocate sliced VBI buffers if needed. */ | 178 | if (fmt != V4L2_MPEG_STREAM_VBI_FMT_IVTV || |
177 | if (fmt && cx->vbi.sliced_mpeg_data[0] == NULL) { | 179 | type != V4L2_MPEG_STREAM_TYPE_MPEG2_PS) { |
180 | /* We don't do VBI insertion aside from IVTV format in a PS */ | ||
181 | cx->vbi.insert_mpeg = V4L2_MPEG_STREAM_VBI_FMT_NONE; | ||
182 | CX18_DEBUG_INFO("disabled insertion of sliced VBI data into " | ||
183 | "the MPEG stream\n"); | ||
184 | return 0; | ||
185 | } | ||
186 | |||
187 | /* Allocate sliced VBI buffers if needed. */ | ||
188 | if (cx->vbi.sliced_mpeg_data[0] == NULL) { | ||
178 | int i; | 189 | int i; |
179 | 190 | ||
180 | for (i = 0; i < CX18_VBI_FRAMES; i++) { | 191 | for (i = 0; i < CX18_VBI_FRAMES; i++) { |
@@ -185,19 +196,27 @@ static int cx18_setup_vbi_fmt(struct cx18 *cx, enum v4l2_mpeg_stream_vbi_fmt fmt | |||
185 | kfree(cx->vbi.sliced_mpeg_data[i]); | 196 | kfree(cx->vbi.sliced_mpeg_data[i]); |
186 | cx->vbi.sliced_mpeg_data[i] = NULL; | 197 | cx->vbi.sliced_mpeg_data[i] = NULL; |
187 | } | 198 | } |
199 | cx->vbi.insert_mpeg = | ||
200 | V4L2_MPEG_STREAM_VBI_FMT_NONE; | ||
201 | CX18_WARN("Unable to allocate buffers for " | ||
202 | "sliced VBI data insertion\n"); | ||
188 | return -ENOMEM; | 203 | return -ENOMEM; |
189 | } | 204 | } |
190 | } | 205 | } |
191 | } | 206 | } |
192 | 207 | ||
193 | cx->vbi.insert_mpeg = fmt; | 208 | cx->vbi.insert_mpeg = fmt; |
209 | CX18_DEBUG_INFO("enabled insertion of sliced VBI data into the MPEG PS," | ||
210 | "when sliced VBI is enabled\n"); | ||
194 | 211 | ||
195 | if (cx->vbi.insert_mpeg == 0) | 212 | /* |
196 | return 0; | 213 | * If our current settings have no lines set for capture, store a valid, |
197 | /* Need sliced data for mpeg insertion */ | 214 | * default set of service lines to capture, in our current settings. |
215 | */ | ||
198 | if (cx18_get_service_set(cx->vbi.sliced_in) == 0) { | 216 | if (cx18_get_service_set(cx->vbi.sliced_in) == 0) { |
199 | if (cx->is_60hz) | 217 | if (cx->is_60hz) |
200 | cx->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525; | 218 | cx->vbi.sliced_in->service_set = |
219 | V4L2_SLICED_CAPTION_525; | ||
201 | else | 220 | else |
202 | cx->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625; | 221 | cx->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625; |
203 | cx18_expand_service_set(cx->vbi.sliced_in, cx->is_50hz); | 222 | cx18_expand_service_set(cx->vbi.sliced_in, cx->is_50hz); |
@@ -284,8 +303,11 @@ int cx18_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c) | |||
284 | priv.cx = cx; | 303 | priv.cx = cx; |
285 | priv.s = &cx->streams[id->type]; | 304 | priv.s = &cx->streams[id->type]; |
286 | err = cx2341x_update(&priv, cx18_api_func, &cx->params, &p); | 305 | err = cx2341x_update(&priv, cx18_api_func, &cx->params, &p); |
287 | if (!err && cx->params.stream_vbi_fmt != p.stream_vbi_fmt) | 306 | if (!err && |
288 | err = cx18_setup_vbi_fmt(cx, p.stream_vbi_fmt); | 307 | (cx->params.stream_vbi_fmt != p.stream_vbi_fmt || |
308 | cx->params.stream_type != p.stream_type)) | ||
309 | err = cx18_setup_vbi_fmt(cx, p.stream_vbi_fmt, | ||
310 | p.stream_type); | ||
289 | cx->params = p; | 311 | cx->params = p; |
290 | cx->dualwatch_stereo_mode = p.audio_properties & 0x0300; | 312 | cx->dualwatch_stereo_mode = p.audio_properties & 0x0300; |
291 | idx = p.audio_properties & 0x03; | 313 | idx = p.audio_properties & 0x03; |