diff options
-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; |