diff options
author | Andy Walls <awalls@radix.net> | 2009-01-30 22:33:02 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:38 -0400 |
commit | 302df9702192a68578916ef922c33370cbba350d (patch) | |
tree | eab3173a4b82ec26c89b82c50e9bfb0fe2477953 /drivers/media/video/cx18/cx18-ioctl.c | |
parent | 4325dff220918c2ced82d16c3475d9a5afb1cab3 (diff) |
V4L/DVB (10439): cx18: Clean-up and enable sliced VBI handling
Removed legacy ivtv state variables, added comments, and cleaned
up sliced VBI related code. Enabled sliced VBI.
Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx18/cx18-ioctl.c')
-rw-r--r-- | drivers/media/video/cx18/cx18-ioctl.c | 77 |
1 files changed, 72 insertions, 5 deletions
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c index 20467fce5251..1adb97220920 100644 --- a/drivers/media/video/cx18/cx18-ioctl.c +++ b/drivers/media/video/cx18/cx18-ioctl.c | |||
@@ -102,6 +102,19 @@ void cx18_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal) | |||
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | static int check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal) | ||
106 | { | ||
107 | int f, l; | ||
108 | u16 set = 0; | ||
109 | |||
110 | for (f = 0; f < 2; f++) { | ||
111 | for (l = 0; l < 24; l++) { | ||
112 | fmt->service_lines[f][l] = select_service_from_set(f, l, fmt->service_lines[f][l], is_pal); | ||
113 | set |= fmt->service_lines[f][l]; | ||
114 | } | ||
115 | } | ||
116 | return set != 0; | ||
117 | } | ||
105 | 118 | ||
106 | u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt) | 119 | u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt) |
107 | { | 120 | { |
@@ -150,7 +163,7 @@ static int cx18_g_fmt_vbi_cap(struct file *file, void *fh, | |||
150 | 163 | ||
151 | vbifmt->sampling_rate = 27000000; | 164 | vbifmt->sampling_rate = 27000000; |
152 | vbifmt->offset = 248; | 165 | vbifmt->offset = 248; |
153 | vbifmt->samples_per_line = cx->vbi.raw_decoder_line_size - 4; | 166 | vbifmt->samples_per_line = vbi_active_samples - 4; |
154 | vbifmt->sample_format = V4L2_PIX_FMT_GREY; | 167 | vbifmt->sample_format = V4L2_PIX_FMT_GREY; |
155 | vbifmt->start[0] = cx->vbi.start[0]; | 168 | vbifmt->start[0] = cx->vbi.start[0]; |
156 | vbifmt->start[1] = cx->vbi.start[1]; | 169 | vbifmt->start[1] = cx->vbi.start[1]; |
@@ -164,7 +177,17 @@ static int cx18_g_fmt_vbi_cap(struct file *file, void *fh, | |||
164 | static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh, | 177 | static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh, |
165 | struct v4l2_format *fmt) | 178 | struct v4l2_format *fmt) |
166 | { | 179 | { |
167 | return -EINVAL; | 180 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; |
181 | struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; | ||
182 | |||
183 | vbifmt->reserved[0] = 0; | ||
184 | vbifmt->reserved[1] = 0; | ||
185 | vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; | ||
186 | memset(vbifmt->service_lines, 0, sizeof(vbifmt->service_lines)); | ||
187 | |||
188 | cx18_av_cmd(cx, VIDIOC_G_FMT, fmt); | ||
189 | vbifmt->service_set = cx18_get_service_set(vbifmt); | ||
190 | return 0; | ||
168 | } | 191 | } |
169 | 192 | ||
170 | static int cx18_try_fmt_vid_cap(struct file *file, void *fh, | 193 | static int cx18_try_fmt_vid_cap(struct file *file, void *fh, |
@@ -194,7 +217,18 @@ static int cx18_try_fmt_vbi_cap(struct file *file, void *fh, | |||
194 | static int cx18_try_fmt_sliced_vbi_cap(struct file *file, void *fh, | 217 | static int cx18_try_fmt_sliced_vbi_cap(struct file *file, void *fh, |
195 | struct v4l2_format *fmt) | 218 | struct v4l2_format *fmt) |
196 | { | 219 | { |
197 | return -EINVAL; | 220 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; |
221 | struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; | ||
222 | |||
223 | vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; | ||
224 | vbifmt->reserved[0] = 0; | ||
225 | vbifmt->reserved[1] = 0; | ||
226 | |||
227 | if (vbifmt->service_set) | ||
228 | cx18_expand_service_set(vbifmt, cx->is_50hz); | ||
229 | check_service_set(vbifmt, cx->is_50hz); | ||
230 | vbifmt->service_set = cx18_get_service_set(vbifmt); | ||
231 | return 0; | ||
198 | } | 232 | } |
199 | 233 | ||
200 | static int cx18_s_fmt_vid_cap(struct file *file, void *fh, | 234 | static int cx18_s_fmt_vid_cap(struct file *file, void *fh, |
@@ -250,7 +284,28 @@ static int cx18_s_fmt_vbi_cap(struct file *file, void *fh, | |||
250 | static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh, | 284 | static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh, |
251 | struct v4l2_format *fmt) | 285 | struct v4l2_format *fmt) |
252 | { | 286 | { |
253 | return -EINVAL; | 287 | struct cx18_open_id *id = fh; |
288 | struct cx18 *cx = id->cx; | ||
289 | int ret; | ||
290 | struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; | ||
291 | |||
292 | ret = v4l2_prio_check(&cx->prio, &id->prio); | ||
293 | if (ret) | ||
294 | return ret; | ||
295 | |||
296 | ret = cx18_try_fmt_sliced_vbi_cap(file, fh, fmt); | ||
297 | if (ret) | ||
298 | return ret; | ||
299 | |||
300 | if (check_service_set(vbifmt, cx->is_50hz) == 0) | ||
301 | return -EINVAL; | ||
302 | |||
303 | if (cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0) | ||
304 | return -EBUSY; | ||
305 | cx->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; | ||
306 | cx18_av_cmd(cx, VIDIOC_S_FMT, fmt); | ||
307 | memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in)); | ||
308 | return 0; | ||
254 | } | 309 | } |
255 | 310 | ||
256 | static int cx18_g_chip_ident(struct file *file, void *fh, | 311 | static int cx18_g_chip_ident(struct file *file, void *fh, |
@@ -548,7 +603,6 @@ int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std) | |||
548 | cx->vbi.count = cx->is_50hz ? 18 : 12; | 603 | cx->vbi.count = cx->is_50hz ? 18 : 12; |
549 | cx->vbi.start[0] = cx->is_50hz ? 6 : 10; | 604 | cx->vbi.start[0] = cx->is_50hz ? 6 : 10; |
550 | cx->vbi.start[1] = cx->is_50hz ? 318 : 273; | 605 | cx->vbi.start[1] = cx->is_50hz ? 318 : 273; |
551 | cx->vbi.sliced_decoder_line_size = cx->is_60hz ? 272 : 284; | ||
552 | CX18_DEBUG_INFO("Switching standard to %llx.\n", | 606 | CX18_DEBUG_INFO("Switching standard to %llx.\n", |
553 | (unsigned long long) cx->std); | 607 | (unsigned long long) cx->std); |
554 | 608 | ||
@@ -599,6 +653,19 @@ static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) | |||
599 | static int cx18_g_sliced_vbi_cap(struct file *file, void *fh, | 653 | static int cx18_g_sliced_vbi_cap(struct file *file, void *fh, |
600 | struct v4l2_sliced_vbi_cap *cap) | 654 | struct v4l2_sliced_vbi_cap *cap) |
601 | { | 655 | { |
656 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; | ||
657 | int set = cx->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525; | ||
658 | int f, l; | ||
659 | |||
660 | if (cap->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) { | ||
661 | for (f = 0; f < 2; f++) { | ||
662 | for (l = 0; l < 24; l++) { | ||
663 | if (valid_service_line(f, l, cx->is_50hz)) | ||
664 | cap->service_lines[f][l] = set; | ||
665 | } | ||
666 | } | ||
667 | return 0; | ||
668 | } | ||
602 | return -EINVAL; | 669 | return -EINVAL; |
603 | } | 670 | } |
604 | 671 | ||