Lines Matching +full:3 +full:- +full:line

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 Copyright (C) 2004-2007 Hans Verkuil <hverkuil@xs4all.nl>
8 #include "ivtv-driver.h"
9 #include "ivtv-i2c.h"
10 #include "ivtv-ioctl.h"
11 #include "ivtv-queue.h"
12 #include "ivtv-cards.h"
13 #include "ivtv-vbi.h"
19 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_set_vps()
23 data.line = enabled ? 16 : 0; in ivtv_set_vps()
24 data.data[2] = itv->vbi.vps_payload.data[0]; in ivtv_set_vps()
25 data.data[8] = itv->vbi.vps_payload.data[1]; in ivtv_set_vps()
26 data.data[9] = itv->vbi.vps_payload.data[2]; in ivtv_set_vps()
27 data.data[10] = itv->vbi.vps_payload.data[3]; in ivtv_set_vps()
28 data.data[11] = itv->vbi.vps_payload.data[4]; in ivtv_set_vps()
36 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_set_cc()
40 data.line = (mode & 1) ? 21 : 0; in ivtv_set_cc()
41 data.data[0] = cc->odd[0]; in ivtv_set_cc()
42 data.data[1] = cc->odd[1]; in ivtv_set_cc()
45 data.line = (mode & 2) ? 21 : 0; in ivtv_set_cc()
46 data.data[0] = cc->even[0]; in ivtv_set_cc()
47 data.data[1] = cc->even[1]; in ivtv_set_cc()
55 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_set_wss()
62 if ((itv->std_out & V4L2_STD_625_50) && !enabled) { in ivtv_set_wss()
68 data.line = enabled ? 23 : 0; in ivtv_set_wss()
87 struct vbi_info *vi = &itv->vbi; in ivtv_write_vbi_line()
89 if (d->id == V4L2_SLICED_CAPTION_525 && d->line == 21) { in ivtv_write_vbi_line()
90 if (d->field) { in ivtv_write_vbi_line()
91 cc->even[0] = d->data[0]; in ivtv_write_vbi_line()
92 cc->even[1] = d->data[1]; in ivtv_write_vbi_line()
94 cc->odd[0] = d->data[0]; in ivtv_write_vbi_line()
95 cc->odd[1] = d->data[1]; in ivtv_write_vbi_line()
98 } else if (d->id == V4L2_SLICED_VPS && d->line == 16 && d->field == 0) { in ivtv_write_vbi_line()
101 vps.data[0] = d->data[2]; in ivtv_write_vbi_line()
102 vps.data[1] = d->data[8]; in ivtv_write_vbi_line()
103 vps.data[2] = d->data[9]; in ivtv_write_vbi_line()
104 vps.data[3] = d->data[10]; in ivtv_write_vbi_line()
105 vps.data[4] = d->data[11]; in ivtv_write_vbi_line()
106 if (memcmp(&vps, &vi->vps_payload, sizeof(vps))) { in ivtv_write_vbi_line()
107 vi->vps_payload = vps; in ivtv_write_vbi_line()
108 set_bit(IVTV_F_I_UPDATE_VPS, &itv->i_flags); in ivtv_write_vbi_line()
110 } else if (d->id == V4L2_SLICED_WSS_625 && in ivtv_write_vbi_line()
111 d->line == 23 && d->field == 0) { in ivtv_write_vbi_line()
112 int wss = d->data[0] | d->data[1] << 8; in ivtv_write_vbi_line()
114 if (vi->wss_payload != wss) { in ivtv_write_vbi_line()
115 vi->wss_payload = wss; in ivtv_write_vbi_line()
116 set_bit(IVTV_F_I_UPDATE_WSS, &itv->i_flags); in ivtv_write_vbi_line()
123 struct vbi_info *vi = &itv->vbi; in ivtv_write_vbi_cc_lines()
125 if (vi->cc_payload_idx < ARRAY_SIZE(vi->cc_payload)) { in ivtv_write_vbi_cc_lines()
126 memcpy(&vi->cc_payload[vi->cc_payload_idx], cc, in ivtv_write_vbi_cc_lines()
128 vi->cc_payload_idx++; in ivtv_write_vbi_cc_lines()
129 set_bit(IVTV_F_I_UPDATE_CC, &itv->i_flags); in ivtv_write_vbi_cc_lines()
162 ret = -EFAULT; in ivtv_write_vbi_from_user()
176 int line = 0; in copy_vbi_data() local
187 int idx = itv->vbi.frame % IVTV_VBI_FRAMES; in copy_vbi_data()
188 u8 *dst = &itv->vbi.sliced_mpeg_data[idx][0]; in copy_vbi_data()
193 if (itv->vbi.sliced_data[i].id == 0) in copy_vbi_data()
196 l = itv->vbi.sliced_data[i].line - 6; in copy_vbi_data()
197 f = itv->vbi.sliced_data[i].field; in copy_vbi_data()
203 linemask[1] |= (1 << (l - 32)); in copy_vbi_data()
204 dst[sd + 12 + line * 43] = in copy_vbi_data()
205 ivtv_service2vbi(itv->vbi.sliced_data[i].id); in copy_vbi_data()
206 memcpy(dst + sd + 12 + line * 43 + 1, itv->vbi.sliced_data[i].data, 42); in copy_vbi_data()
207 line++; in copy_vbi_data()
210 if (line == 36) { in copy_vbi_data()
215 memmove(dst + sd + 4, dst + sd + 12, line * 43); in copy_vbi_data()
216 size = 4 + ((43 * line + 3) & ~3); in copy_vbi_data()
222 size = 12 + ((43 * line + 3) & ~3); in copy_vbi_data()
231 itv->vbi.sliced_mpeg_size[idx] = sd + size; in copy_vbi_data()
238 int line = 0; in ivtv_convert_ivtv_vbi() local
256 if (i >= 32 && !(linemask[1] & (1 << (i - 32)))) in ivtv_convert_ivtv_vbi()
278 l = (i < 18) ? i + 6 : i - 18 + 6; in ivtv_convert_ivtv_vbi()
279 itv->vbi.sliced_dec_data[line].line = l; in ivtv_convert_ivtv_vbi()
280 itv->vbi.sliced_dec_data[line].field = i >= 18; in ivtv_convert_ivtv_vbi()
281 itv->vbi.sliced_dec_data[line].id = id2; in ivtv_convert_ivtv_vbi()
282 memcpy(itv->vbi.sliced_dec_data[line].data, p + 1, 42); in ivtv_convert_ivtv_vbi()
283 line++; in ivtv_convert_ivtv_vbi()
287 while (line < 36) { in ivtv_convert_ivtv_vbi()
288 itv->vbi.sliced_dec_data[line].id = 0; in ivtv_convert_ivtv_vbi()
289 itv->vbi.sliced_dec_data[line].line = 0; in ivtv_convert_ivtv_vbi()
290 itv->vbi.sliced_dec_data[line].field = 0; in ivtv_convert_ivtv_vbi()
291 line++; in ivtv_convert_ivtv_vbi()
293 return line * sizeof(itv->vbi.sliced_dec_data[0]); in ivtv_convert_ivtv_vbi()
301 u32 line_size = itv->vbi.raw_decoder_line_size; in compress_raw_buf()
302 u32 lines = itv->vbi.count; in compress_raw_buf()
303 u8 sav1 = itv->vbi.raw_decoder_sav_odd_field; in compress_raw_buf()
304 u8 sav2 = itv->vbi.raw_decoder_sav_even_field; in compress_raw_buf()
313 if (p[0] != 0xff || p[1] || p[2] || (p[3] != sav1 && p[3] != sav2)) { in compress_raw_buf()
316 memcpy(q, p + 4, line_size - 4); in compress_raw_buf()
317 q += line_size - 4; in compress_raw_buf()
319 return lines * (line_size - 4); in compress_raw_buf()
325 static u32 compress_sliced_buf(struct ivtv *itv, u32 line, u8 *buf, u32 size, u8 sav) in compress_sliced_buf() argument
327 u32 line_size = itv->vbi.sliced_decoder_line_size; in compress_sliced_buf()
332 /* find the first valid line */ in compress_sliced_buf()
334 if (buf[0] == 0xff && !buf[1] && !buf[2] && buf[3] == sav) in compress_sliced_buf()
338 size -= i; in compress_sliced_buf()
340 return line; in compress_sliced_buf()
346 if (p[0] != 0xff || p[1] || p[2] || p[3] != sav) { in compress_sliced_buf()
350 v4l2_subdev_call(itv->sd_video, vbi, decode_vbi_line, &vbi); in compress_sliced_buf()
351 if (vbi.type && !(lines & (1 << vbi.line))) { in compress_sliced_buf()
352 lines |= 1 << vbi.line; in compress_sliced_buf()
353 itv->vbi.sliced_data[line].id = vbi.type; in compress_sliced_buf()
354 itv->vbi.sliced_data[line].field = vbi.is_second_field; in compress_sliced_buf()
355 itv->vbi.sliced_data[line].line = vbi.line; in compress_sliced_buf()
356 memcpy(itv->vbi.sliced_data[line].data, vbi.p, 42); in compress_sliced_buf()
357 line++; in compress_sliced_buf()
360 return line; in compress_sliced_buf()
366 u8 *p = (u8 *) buf->buf; in ivtv_process_vbi_data()
367 u32 size = buf->bytesused; in ivtv_process_vbi_data()
376 type = p[3]; in ivtv_process_vbi_data()
378 size = buf->bytesused = compress_raw_buf(itv, p, size); in ivtv_process_vbi_data()
381 if (type == itv->vbi.raw_decoder_sav_even_field) { in ivtv_process_vbi_data()
384 p += size - 4; in ivtv_process_vbi_data()
385 memcpy(p, &itv->vbi.frame, 4); in ivtv_process_vbi_data()
386 itv->vbi.frame++; in ivtv_process_vbi_data()
399 itv->vbi.sliced_decoder_sav_odd_field); in ivtv_process_vbi_data()
403 lines = compress_sliced_buf(itv, lines, p + size / 2 - 32, size / 2 + 32, in ivtv_process_vbi_data()
404 itv->vbi.sliced_decoder_sav_even_field); in ivtv_process_vbi_data()
405 /* always return at least one empty line */ in ivtv_process_vbi_data()
407 itv->vbi.sliced_data[0].id = 0; in ivtv_process_vbi_data()
408 itv->vbi.sliced_data[0].line = 0; in ivtv_process_vbi_data()
409 itv->vbi.sliced_data[0].field = 0; in ivtv_process_vbi_data()
412 buf->bytesused = size = lines * sizeof(itv->vbi.sliced_data[0]); in ivtv_process_vbi_data()
413 memcpy(p, &itv->vbi.sliced_data[0], size); in ivtv_process_vbi_data()
415 if (itv->vbi.insert_mpeg) { in ivtv_process_vbi_data()
418 itv->vbi.frame++; in ivtv_process_vbi_data()
422 /* Sliced VBI re-inserted from an MPEG stream */ in ivtv_process_vbi_data()
424 /* If the size is not 4-byte aligned, then the starting address in ivtv_process_vbi_data()
428 Non-4-byte alignment happens when an lseek is done on the input in ivtv_process_vbi_data()
429 mpeg file to a non-4-byte aligned position. So on arrival here in ivtv_process_vbi_data()
430 the VBI data is also non-4-byte aligned. */ in ivtv_process_vbi_data()
431 int offset = size & 3; in ivtv_process_vbi_data()
435 p += 4 - offset; in ivtv_process_vbi_data()
443 memcpy(buf->buf, itv->vbi.sliced_dec_data, cnt); in ivtv_process_vbi_data()
444 buf->bytesused = cnt; in ivtv_process_vbi_data()
446 ivtv_write_vbi(itv, itv->vbi.sliced_dec_data, in ivtv_process_vbi_data()
447 cnt / sizeof(itv->vbi.sliced_dec_data[0])); in ivtv_process_vbi_data()
456 clear_bit(IVTV_F_I_UPDATE_CC, &itv->i_flags); in ivtv_disable_cc()
458 itv->vbi.cc_payload_idx = 0; in ivtv_disable_cc()
464 struct vbi_info *vi = &itv->vbi; in ivtv_vbi_work_handler()
469 if (itv->output_mode == OUT_PASSTHROUGH) { in ivtv_vbi_work_handler()
470 if (itv->is_50hz) { in ivtv_vbi_work_handler()
474 if (v4l2_subdev_call(itv->sd_video, vbi, g_vbi_data, &data) == 0) { in ivtv_vbi_work_handler()
476 vi->wss_missing_cnt = 0; in ivtv_vbi_work_handler()
477 } else if (vi->wss_missing_cnt == 4) { in ivtv_vbi_work_handler()
480 vi->wss_missing_cnt++; in ivtv_vbi_work_handler()
488 if (v4l2_subdev_call(itv->sd_video, vbi, g_vbi_data, &data) == 0) { in ivtv_vbi_work_handler()
494 if (v4l2_subdev_call(itv->sd_video, vbi, g_vbi_data, &data) == 0) { in ivtv_vbi_work_handler()
500 vi->cc_missing_cnt = 0; in ivtv_vbi_work_handler()
502 } else if (vi->cc_missing_cnt == 4) { in ivtv_vbi_work_handler()
505 vi->cc_missing_cnt++; in ivtv_vbi_work_handler()
511 if (test_and_clear_bit(IVTV_F_I_UPDATE_WSS, &itv->i_flags)) { in ivtv_vbi_work_handler()
512 ivtv_set_wss(itv, 1, vi->wss_payload & 0xf); in ivtv_vbi_work_handler()
515 if (test_bit(IVTV_F_I_UPDATE_CC, &itv->i_flags)) { in ivtv_vbi_work_handler()
516 if (vi->cc_payload_idx == 0) { in ivtv_vbi_work_handler()
517 clear_bit(IVTV_F_I_UPDATE_CC, &itv->i_flags); in ivtv_vbi_work_handler()
518 ivtv_set_cc(itv, 3, &cc); in ivtv_vbi_work_handler()
520 while (vi->cc_payload_idx) { in ivtv_vbi_work_handler()
521 cc = vi->cc_payload[0]; in ivtv_vbi_work_handler()
523 memmove(vi->cc_payload, vi->cc_payload + 1, in ivtv_vbi_work_handler()
524 sizeof(vi->cc_payload) - sizeof(vi->cc_payload[0])); in ivtv_vbi_work_handler()
525 vi->cc_payload_idx--; in ivtv_vbi_work_handler()
526 if (vi->cc_payload_idx && cc.odd[0] == 0x80 && cc.odd[1] == 0x80) in ivtv_vbi_work_handler()
529 ivtv_set_cc(itv, 3, &cc); in ivtv_vbi_work_handler()
534 if (test_and_clear_bit(IVTV_F_I_UPDATE_VPS, &itv->i_flags)) { in ivtv_vbi_work_handler()