Lines Matching +full:data +full:- +full:lines

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"
17 struct v4l2_sliced_vbi_data data; in ivtv_set_vps() local
19 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_set_vps()
21 data.id = V4L2_SLICED_VPS; in ivtv_set_vps()
22 data.field = 0; 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()
29 ivtv_call_hw(itv, IVTV_HW_SAA7127, vbi, s_vbi_data, &data); in ivtv_set_vps()
34 struct v4l2_sliced_vbi_data data; in ivtv_set_cc() local
36 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_set_cc()
38 data.id = V4L2_SLICED_CAPTION_525; in ivtv_set_cc()
39 data.field = 0; 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()
43 ivtv_call_hw(itv, IVTV_HW_SAA7127, vbi, s_vbi_data, &data); in ivtv_set_cc()
44 data.field = 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()
48 ivtv_call_hw(itv, IVTV_HW_SAA7127, vbi, s_vbi_data, &data); in ivtv_set_cc()
53 struct v4l2_sliced_vbi_data data; in ivtv_set_wss() local
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()
66 data.id = V4L2_SLICED_WSS_625; in ivtv_set_wss()
67 data.field = 0; in ivtv_set_wss()
68 data.line = enabled ? 23 : 0; in ivtv_set_wss()
69 data.data[0] = mode & 0xff; in ivtv_set_wss()
70 data.data[1] = (mode >> 8) & 0xff; in ivtv_set_wss()
71 ivtv_call_hw(itv, IVTV_HW_SAA7127, vbi, s_vbi_data, &data); 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()
174 static void copy_vbi_data(struct ivtv *itv, int lines, u32 pts_stamp) in copy_vbi_data() argument
186 const int sd = sizeof(mpeg_hdr_data); /* start of vbi data */ in copy_vbi_data()
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()
190 for (i = 0; i < lines; i++) { 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()
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()
211 /* All lines are used, so there is no space for the linemask in copy_vbi_data()
212 (the max size of the VBI data is 36 * 43 + 4 bytes). in copy_vbi_data()
231 itv->vbi.sliced_mpeg_size[idx] = sd + size; in copy_vbi_data()
248 /* unknown VBI data, convert to empty VBI frame */ in ivtv_convert_ivtv_vbi()
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()
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()
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() local
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()
309 for (i = 0; i < lines; i++) { 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()
327 u32 line_size = itv->vbi.sliced_decoder_line_size; in compress_sliced_buf()
330 unsigned lines = 0; in compress_sliced_buf() local
338 size -= i; 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()
366 u8 *p = (u8 *) buf->buf; in ivtv_process_vbi_data()
367 u32 size = buf->bytesused; in ivtv_process_vbi_data()
370 /* Raw VBI data */ 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()
391 /* Sliced VBI data with data insertion */ in ivtv_process_vbi_data()
393 int lines; in ivtv_process_vbi_data() local
398 lines = compress_sliced_buf(itv, 0, p, size / 2, 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()
406 if (lines == 0) { 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()
410 lines = 1; 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()
416 copy_vbi_data(itv, lines, pts_stamp); 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()
425 for the swapping is also shifted. After swapping the data the in ivtv_process_vbi_data()
426 real start address of the VBI data is exactly 4 bytes after the 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()
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()
465 struct v4l2_sliced_vbi_data data; in ivtv_vbi_work_handler() local
469 if (itv->output_mode == OUT_PASSTHROUGH) { in ivtv_vbi_work_handler()
470 if (itv->is_50hz) { in ivtv_vbi_work_handler()
471 data.id = V4L2_SLICED_WSS_625; in ivtv_vbi_work_handler()
472 data.field = 0; in ivtv_vbi_work_handler()
474 if (v4l2_subdev_call(itv->sd_video, vbi, g_vbi_data, &data) == 0) { in ivtv_vbi_work_handler()
475 ivtv_set_wss(itv, 1, data.data[0] & 0xf); 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()
486 data.id = V4L2_SLICED_CAPTION_525; in ivtv_vbi_work_handler()
487 data.field = 0; in ivtv_vbi_work_handler()
488 if (v4l2_subdev_call(itv->sd_video, vbi, g_vbi_data, &data) == 0) { in ivtv_vbi_work_handler()
490 cc.odd[0] = data.data[0]; in ivtv_vbi_work_handler()
491 cc.odd[1] = data.data[1]; in ivtv_vbi_work_handler()
493 data.field = 1; in ivtv_vbi_work_handler()
494 if (v4l2_subdev_call(itv->sd_video, vbi, g_vbi_data, &data) == 0) { in ivtv_vbi_work_handler()
496 cc.even[0] = data.data[0]; in ivtv_vbi_work_handler()
497 cc.even[1] = data.data[1]; 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()
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()
534 if (test_and_clear_bit(IVTV_F_I_UPDATE_VPS, &itv->i_flags)) { in ivtv_vbi_work_handler()