Lines Matching +full:standard +full:- +full:vt
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Derived from ivtv-ioctl.c
11 #include "cx18-driver.h"
12 #include "cx18-io.h"
13 #include "cx18-version.h"
14 #include "cx18-mailbox.h"
15 #include "cx18-i2c.h"
16 #include "cx18-queue.h"
17 #include "cx18-fileops.h"
18 #include "cx18-vbi.h"
19 #include "cx18-audio.h"
20 #include "cx18-video.h"
21 #include "cx18-streams.h"
22 #include "cx18-ioctl.h"
23 #include "cx18-gpio.h"
24 #include "cx18-controls.h"
25 #include "cx18-cards.h"
26 #include "cx18-av-core.h"
28 #include <media/v4l2-event.h>
56 struct cx18 *cx = id->cx; in cx18_g_fmt_vid_cap()
57 struct cx18_stream *s = &cx->streams[id->type]; in cx18_g_fmt_vid_cap()
58 struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; in cx18_g_fmt_vid_cap()
60 pixfmt->width = cx->cxhdl.width; in cx18_g_fmt_vid_cap()
61 pixfmt->height = cx->cxhdl.height; in cx18_g_fmt_vid_cap()
62 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; in cx18_g_fmt_vid_cap()
63 pixfmt->field = V4L2_FIELD_INTERLACED; in cx18_g_fmt_vid_cap()
64 if (id->type == CX18_ENC_STREAM_TYPE_YUV) { in cx18_g_fmt_vid_cap()
65 pixfmt->pixelformat = s->pixelformat; in cx18_g_fmt_vid_cap()
66 pixfmt->sizeimage = s->vb_bytes_per_frame; in cx18_g_fmt_vid_cap()
67 pixfmt->bytesperline = s->vb_bytes_per_line; in cx18_g_fmt_vid_cap()
69 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; in cx18_g_fmt_vid_cap()
70 pixfmt->sizeimage = 128 * 1024; in cx18_g_fmt_vid_cap()
71 pixfmt->bytesperline = 0; in cx18_g_fmt_vid_cap()
80 struct cx18 *cx = id->cx; in cx18_try_fmt_vid_cap()
81 struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; in cx18_try_fmt_vid_cap()
82 int w = pixfmt->width; in cx18_try_fmt_vid_cap()
83 int h = pixfmt->height; in cx18_try_fmt_vid_cap()
88 h = min(h, cx->is_50hz ? 576 : 480); in cx18_try_fmt_vid_cap()
89 h = max(h, (cx->is_50hz ? 576 : 480) / 8); in cx18_try_fmt_vid_cap()
91 if (id->type == CX18_ENC_STREAM_TYPE_YUV) { in cx18_try_fmt_vid_cap()
92 if (pixfmt->pixelformat != V4L2_PIX_FMT_NV12_16L16 && in cx18_try_fmt_vid_cap()
93 pixfmt->pixelformat != V4L2_PIX_FMT_UYVY) in cx18_try_fmt_vid_cap()
94 pixfmt->pixelformat = V4L2_PIX_FMT_UYVY; in cx18_try_fmt_vid_cap()
101 if (pixfmt->pixelformat == V4L2_PIX_FMT_NV12_16L16) { in cx18_try_fmt_vid_cap()
102 pixfmt->sizeimage = h * 720 * 3 / 2; in cx18_try_fmt_vid_cap()
103 pixfmt->bytesperline = 720; /* First plane */ in cx18_try_fmt_vid_cap()
105 pixfmt->sizeimage = h * 720 * 2; in cx18_try_fmt_vid_cap()
106 pixfmt->bytesperline = 1440; /* Packed */ in cx18_try_fmt_vid_cap()
109 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; in cx18_try_fmt_vid_cap()
110 pixfmt->sizeimage = 128 * 1024; in cx18_try_fmt_vid_cap()
111 pixfmt->bytesperline = 0; in cx18_try_fmt_vid_cap()
114 pixfmt->width = w; in cx18_try_fmt_vid_cap()
115 pixfmt->height = h; in cx18_try_fmt_vid_cap()
116 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; in cx18_try_fmt_vid_cap()
117 pixfmt->field = V4L2_FIELD_INTERLACED; in cx18_try_fmt_vid_cap()
125 struct cx18 *cx = id->cx; in cx18_s_fmt_vid_cap()
129 struct cx18_stream *s = &cx->streams[id->type]; in cx18_s_fmt_vid_cap()
136 w = fmt->fmt.pix.width; in cx18_s_fmt_vid_cap()
137 h = fmt->fmt.pix.height; in cx18_s_fmt_vid_cap()
139 if (cx->cxhdl.width == w && cx->cxhdl.height == h && in cx18_s_fmt_vid_cap()
140 s->pixelformat == fmt->fmt.pix.pixelformat) in cx18_s_fmt_vid_cap()
143 if (atomic_read(&cx->ana_capturing) > 0) in cx18_s_fmt_vid_cap()
144 return -EBUSY; in cx18_s_fmt_vid_cap()
146 s->pixelformat = fmt->fmt.pix.pixelformat; in cx18_s_fmt_vid_cap()
147 s->vb_bytes_per_frame = fmt->fmt.pix.sizeimage; in cx18_s_fmt_vid_cap()
148 s->vb_bytes_per_line = fmt->fmt.pix.bytesperline; in cx18_s_fmt_vid_cap()
150 format.format.width = cx->cxhdl.width = w; in cx18_s_fmt_vid_cap()
151 format.format.height = cx->cxhdl.height = h; in cx18_s_fmt_vid_cap()
153 v4l2_subdev_call(cx->sd_av, pad, set_fmt, NULL, &format); in cx18_s_fmt_vid_cap()
216 * and clear the passed in fmt->service_set
220 u16 set = fmt->service_set; in cx18_expand_service_set()
223 fmt->service_set = 0; in cx18_expand_service_set()
226 fmt->service_lines[f][l] = select_service_from_set(f, l, set, is_pal); in cx18_expand_service_set()
241 fmt->service_lines[f][l] = select_service_from_set(f, l, fmt->service_lines[f][l], is_pal); in check_service_set()
242 set |= fmt->service_lines[f][l]; in check_service_set()
256 set |= fmt->service_lines[f][l]; in cx18_get_service_set()
264 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_fmt_vbi_cap()
265 struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi; in cx18_g_fmt_vbi_cap()
267 vbifmt->sampling_rate = 27000000; in cx18_g_fmt_vbi_cap()
268 vbifmt->offset = 248; /* FIXME - slightly wrong for both 50 & 60 Hz */ in cx18_g_fmt_vbi_cap()
269 vbifmt->samples_per_line = VBI_ACTIVE_SAMPLES - 4; in cx18_g_fmt_vbi_cap()
270 vbifmt->sample_format = V4L2_PIX_FMT_GREY; in cx18_g_fmt_vbi_cap()
271 vbifmt->start[0] = cx->vbi.start[0]; in cx18_g_fmt_vbi_cap()
272 vbifmt->start[1] = cx->vbi.start[1]; in cx18_g_fmt_vbi_cap()
273 vbifmt->count[0] = vbifmt->count[1] = cx->vbi.count; in cx18_g_fmt_vbi_cap()
274 vbifmt->flags = 0; in cx18_g_fmt_vbi_cap()
275 vbifmt->reserved[0] = 0; in cx18_g_fmt_vbi_cap()
276 vbifmt->reserved[1] = 0; in cx18_g_fmt_vbi_cap()
283 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_fmt_sliced_vbi_cap()
284 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in cx18_g_fmt_sliced_vbi_cap()
287 vbifmt->reserved[0] = 0; in cx18_g_fmt_sliced_vbi_cap()
288 vbifmt->reserved[1] = 0; in cx18_g_fmt_sliced_vbi_cap()
289 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; in cx18_g_fmt_sliced_vbi_cap()
290 memset(vbifmt->service_lines, 0, sizeof(vbifmt->service_lines)); in cx18_g_fmt_sliced_vbi_cap()
291 vbifmt->service_set = 0; in cx18_g_fmt_sliced_vbi_cap()
296 * fmt->fmt.sliced under valid calling conditions in cx18_g_fmt_sliced_vbi_cap()
298 if (v4l2_subdev_call(cx->sd_av, vbi, g_sliced_fmt, &fmt->fmt.sliced)) in cx18_g_fmt_sliced_vbi_cap()
299 return -EINVAL; in cx18_g_fmt_sliced_vbi_cap()
301 vbifmt->service_set = cx18_get_service_set(vbifmt); in cx18_g_fmt_sliced_vbi_cap()
314 struct cx18 *cx = fh2id(fh)->cx; in cx18_try_fmt_sliced_vbi_cap()
315 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in cx18_try_fmt_sliced_vbi_cap()
317 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; in cx18_try_fmt_sliced_vbi_cap()
318 vbifmt->reserved[0] = 0; in cx18_try_fmt_sliced_vbi_cap()
319 vbifmt->reserved[1] = 0; in cx18_try_fmt_sliced_vbi_cap()
322 if (vbifmt->service_set) in cx18_try_fmt_sliced_vbi_cap()
323 cx18_expand_service_set(vbifmt, cx->is_50hz); in cx18_try_fmt_sliced_vbi_cap()
325 if (check_service_set(vbifmt, cx->is_50hz)) in cx18_try_fmt_sliced_vbi_cap()
326 vbifmt->service_set = cx18_get_service_set(vbifmt); in cx18_try_fmt_sliced_vbi_cap()
334 struct cx18 *cx = id->cx; in cx18_s_fmt_vbi_cap()
341 if (!cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0) in cx18_s_fmt_vbi_cap()
342 return -EBUSY; in cx18_s_fmt_vbi_cap()
349 ret = v4l2_subdev_call(cx->sd_av, vbi, s_raw_fmt, &fmt->fmt.vbi); in cx18_s_fmt_vbi_cap()
353 /* Store our new v4l2 (non-)sliced VBI state */ in cx18_s_fmt_vbi_cap()
354 cx->vbi.sliced_in->service_set = 0; in cx18_s_fmt_vbi_cap()
355 cx->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE; in cx18_s_fmt_vbi_cap()
364 struct cx18 *cx = id->cx; in cx18_s_fmt_sliced_vbi_cap()
366 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in cx18_s_fmt_sliced_vbi_cap()
374 if (cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0) in cx18_s_fmt_sliced_vbi_cap()
375 return -EBUSY; in cx18_s_fmt_sliced_vbi_cap()
380 * passed in fmt->fmt.sliced under valid calling conditions in cx18_s_fmt_sliced_vbi_cap()
382 ret = v4l2_subdev_call(cx->sd_av, vbi, s_sliced_fmt, &fmt->fmt.sliced); in cx18_s_fmt_sliced_vbi_cap()
386 cx->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; in cx18_s_fmt_sliced_vbi_cap()
387 memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in)); in cx18_s_fmt_sliced_vbi_cap()
395 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_register()
397 if (reg->reg & 0x3) in cx18_g_register()
398 return -EINVAL; in cx18_g_register()
399 if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE) in cx18_g_register()
400 return -EINVAL; in cx18_g_register()
401 reg->size = 4; in cx18_g_register()
402 reg->val = cx18_read_enc(cx, reg->reg); in cx18_g_register()
409 struct cx18 *cx = fh2id(fh)->cx; in cx18_s_register()
411 if (reg->reg & 0x3) in cx18_s_register()
412 return -EINVAL; in cx18_s_register()
413 if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE) in cx18_s_register()
414 return -EINVAL; in cx18_s_register()
415 cx18_write_enc(cx, reg->val, reg->reg); in cx18_s_register()
424 struct cx18 *cx = id->cx; in cx18_querycap()
426 strscpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver)); in cx18_querycap()
427 strscpy(vcap->card, cx->card_name, sizeof(vcap->card)); in cx18_querycap()
428 vcap->capabilities = cx->v4l2_cap | V4L2_CAP_DEVICE_CAPS; in cx18_querycap()
434 struct cx18 *cx = fh2id(fh)->cx; in cx18_enumaudio()
436 return cx18_get_audio_input(cx, vin->index, vin); in cx18_enumaudio()
441 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_audio()
443 vin->index = cx->audio_input; in cx18_g_audio()
444 return cx18_get_audio_input(cx, vin->index, vin); in cx18_g_audio()
449 struct cx18 *cx = fh2id(fh)->cx; in cx18_s_audio()
451 if (vout->index >= cx->nof_audio_inputs) in cx18_s_audio()
452 return -EINVAL; in cx18_s_audio()
453 cx->audio_input = vout->index; in cx18_s_audio()
460 struct cx18 *cx = fh2id(fh)->cx; in cx18_enum_input()
463 return cx18_get_input(cx, vin->index, vin); in cx18_enum_input()
469 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_pixelaspect()
472 return -EINVAL; in cx18_g_pixelaspect()
474 f->numerator = cx->is_50hz ? 54 : 11; in cx18_g_pixelaspect()
475 f->denominator = cx->is_50hz ? 59 : 10; in cx18_g_pixelaspect()
482 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_selection()
484 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in cx18_g_selection()
485 return -EINVAL; in cx18_g_selection()
486 switch (sel->target) { in cx18_g_selection()
489 sel->r.top = sel->r.left = 0; in cx18_g_selection()
490 sel->r.width = 720; in cx18_g_selection()
491 sel->r.height = cx->is_50hz ? 576 : 480; in cx18_g_selection()
494 return -EINVAL; in cx18_g_selection()
504 if (id->type == CX18_ENC_STREAM_TYPE_YUV) { in cx18_enum_fmt_vid_cap()
505 if (fmt->index >= ARRAY_SIZE(cx18_formats_yuv)) in cx18_enum_fmt_vid_cap()
506 return -EINVAL; in cx18_enum_fmt_vid_cap()
507 *fmt = cx18_formats_yuv[fmt->index]; in cx18_enum_fmt_vid_cap()
510 if (fmt->index) in cx18_enum_fmt_vid_cap()
511 return -EINVAL; in cx18_enum_fmt_vid_cap()
518 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_input()
520 *i = cx->active_input; in cx18_g_input()
527 struct cx18 *cx = id->cx; in cx18_s_input()
530 cx->card->video_inputs + inp; in cx18_s_input()
532 if (inp >= cx->nof_inputs) in cx18_s_input()
533 return -EINVAL; in cx18_s_input()
535 if (inp == cx->active_input) { in cx18_s_input()
541 cx->active_input, inp); in cx18_s_input()
543 cx->active_input = inp; in cx18_s_input()
545 cx->audio_input = cx->card->video_inputs[inp].audio_index; in cx18_s_input()
546 if (card_input->video_type == V4L2_INPUT_TYPE_TUNER) in cx18_s_input()
547 std = cx->tuner_std; in cx18_s_input()
548 cx->streams[CX18_ENC_STREAM_TYPE_MPG].video_dev.tvnorms = std; in cx18_s_input()
549 cx->streams[CX18_ENC_STREAM_TYPE_YUV].video_dev.tvnorms = std; in cx18_s_input()
550 cx->streams[CX18_ENC_STREAM_TYPE_VBI].video_dev.tvnorms = std; in cx18_s_input()
564 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_frequency()
566 if (vf->tuner != 0) in cx18_g_frequency()
567 return -EINVAL; in cx18_g_frequency()
576 struct cx18 *cx = id->cx; in cx18_s_frequency()
578 if (vf->tuner != 0) in cx18_s_frequency()
579 return -EINVAL; in cx18_s_frequency()
582 CX18_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf->frequency); in cx18_s_frequency()
590 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_std()
592 *std = cx->std; in cx18_g_std()
599 struct cx18 *cx = id->cx; in cx18_s_std()
602 return -EINVAL; in cx18_s_std()
604 if (std == cx->std) in cx18_s_std()
607 if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) || in cx18_s_std()
608 atomic_read(&cx->ana_capturing) > 0) { in cx18_s_std()
609 /* Switching standard would turn off the radio or mess in cx18_s_std()
612 return -EBUSY; in cx18_s_std()
615 cx->std = std; in cx18_s_std()
616 cx->is_60hz = (std & V4L2_STD_525_60) ? 1 : 0; in cx18_s_std()
617 cx->is_50hz = !cx->is_60hz; in cx18_s_std()
618 cx2341x_handler_set_50hz(&cx->cxhdl, cx->is_50hz); in cx18_s_std()
619 cx->cxhdl.width = 720; in cx18_s_std()
620 cx->cxhdl.height = cx->is_50hz ? 576 : 480; in cx18_s_std()
625 if (cx->streams[CX18_ENC_STREAM_TYPE_YUV].pixelformat == V4L2_PIX_FMT_NV12_16L16) { in cx18_s_std()
626 cx->streams[CX18_ENC_STREAM_TYPE_YUV].vb_bytes_per_frame = in cx18_s_std()
627 cx->cxhdl.height * 720 * 3 / 2; in cx18_s_std()
628 cx->streams[CX18_ENC_STREAM_TYPE_YUV].vb_bytes_per_line = 720; in cx18_s_std()
630 cx->streams[CX18_ENC_STREAM_TYPE_YUV].vb_bytes_per_frame = in cx18_s_std()
631 cx->cxhdl.height * 720 * 2; in cx18_s_std()
632 cx->streams[CX18_ENC_STREAM_TYPE_YUV].vb_bytes_per_line = 1440; in cx18_s_std()
634 cx->vbi.count = cx->is_50hz ? 18 : 12; in cx18_s_std()
635 cx->vbi.start[0] = cx->is_50hz ? 6 : 10; in cx18_s_std()
636 cx->vbi.start[1] = cx->is_50hz ? 318 : 273; in cx18_s_std()
637 CX18_DEBUG_INFO("Switching standard to %llx.\n", in cx18_s_std()
638 (unsigned long long) cx->std); in cx18_s_std()
641 cx18_call_all(cx, video, s_std, cx->std); in cx18_s_std()
645 static int cx18_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *vt) in cx18_s_tuner() argument
648 struct cx18 *cx = id->cx; in cx18_s_tuner()
650 if (vt->index != 0) in cx18_s_tuner()
651 return -EINVAL; in cx18_s_tuner()
653 cx18_call_all(cx, tuner, s_tuner, vt); in cx18_s_tuner()
657 static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) in cx18_g_tuner() argument
659 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_tuner()
661 if (vt->index != 0) in cx18_g_tuner()
662 return -EINVAL; in cx18_g_tuner()
664 cx18_call_all(cx, tuner, g_tuner, vt); in cx18_g_tuner()
666 if (vt->type == V4L2_TUNER_RADIO) in cx18_g_tuner()
667 strscpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name)); in cx18_g_tuner()
669 strscpy(vt->name, "cx18 TV Tuner", sizeof(vt->name)); in cx18_g_tuner()
676 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_sliced_vbi_cap()
677 int set = cx->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525; in cx18_g_sliced_vbi_cap()
680 if (cap->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) in cx18_g_sliced_vbi_cap()
681 return -EINVAL; in cx18_g_sliced_vbi_cap()
683 cap->service_set = 0; in cx18_g_sliced_vbi_cap()
686 if (valid_service_line(f, l, cx->is_50hz)) { in cx18_g_sliced_vbi_cap()
689 * for the standard, on a valid line for the std in cx18_g_sliced_vbi_cap()
691 cap->service_lines[f][l] = set; in cx18_g_sliced_vbi_cap()
692 cap->service_set |= set; in cx18_g_sliced_vbi_cap()
694 cap->service_lines[f][l] = 0; in cx18_g_sliced_vbi_cap()
698 cap->reserved[f] = 0; in cx18_g_sliced_vbi_cap()
711 -1, V4L2_ENC_IDX_FRAME_I, V4L2_ENC_IDX_FRAME_P, in _cx18_process_idx_data()
712 -1, V4L2_ENC_IDX_FRAME_B, -1, -1, -1 in _cx18_process_idx_data()
720 remaining = buf->bytesused - buf->readpos; in _cx18_process_idx_data()
722 e_idx = &idx->entry[idx->entries]; in _cx18_process_idx_data()
723 e_buf = (struct cx18_enc_idx_entry *) &buf->buf[buf->readpos]; in _cx18_process_idx_data()
726 idx->entries < V4L2_ENC_IDX_ENTRIES) { in _cx18_process_idx_data()
728 e_idx->offset = (((u64) le32_to_cpu(e_buf->offset_high)) << 32) in _cx18_process_idx_data()
729 | le32_to_cpu(e_buf->offset_low); in _cx18_process_idx_data()
731 e_idx->pts = (((u64) (le32_to_cpu(e_buf->pts_high) & 1)) << 32) in _cx18_process_idx_data()
732 | le32_to_cpu(e_buf->pts_low); in _cx18_process_idx_data()
734 e_idx->length = le32_to_cpu(e_buf->length); in _cx18_process_idx_data()
736 e_idx->flags = mapping[le32_to_cpu(e_buf->flags) & 0x7]; in _cx18_process_idx_data()
738 e_idx->reserved[0] = 0; in _cx18_process_idx_data()
739 e_idx->reserved[1] = 0; in _cx18_process_idx_data()
741 idx->entries++; in _cx18_process_idx_data()
742 e_idx = &idx->entry[idx->entries]; in _cx18_process_idx_data()
745 remaining -= sizeof(struct cx18_enc_idx_entry); in _cx18_process_idx_data()
753 buf->readpos += consumed; in _cx18_process_idx_data()
760 if (s->type != CX18_ENC_STREAM_TYPE_IDX) in cx18_process_idx_data()
761 return -EINVAL; in cx18_process_idx_data()
763 if (mdl->curr_buf == NULL) in cx18_process_idx_data()
764 mdl->curr_buf = list_first_entry(&mdl->buf_list, in cx18_process_idx_data()
767 if (list_entry_is_past_end(mdl->curr_buf, &mdl->buf_list, list)) { in cx18_process_idx_data()
773 mdl->readpos = mdl->bytesused; in cx18_process_idx_data()
777 list_for_each_entry_from(mdl->curr_buf, &mdl->buf_list, list) { in cx18_process_idx_data()
780 if (mdl->curr_buf->readpos >= mdl->curr_buf->bytesused) in cx18_process_idx_data()
783 mdl->readpos += _cx18_process_idx_data(mdl->curr_buf, idx); in cx18_process_idx_data()
786 if (idx->entries >= V4L2_ENC_IDX_ENTRIES || in cx18_process_idx_data()
787 mdl->curr_buf->readpos < mdl->curr_buf->bytesused || in cx18_process_idx_data()
788 mdl->readpos >= mdl->bytesused) in cx18_process_idx_data()
797 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_enc_index()
798 struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_IDX]; in cx18_g_enc_index()
803 return -EINVAL; in cx18_g_enc_index()
806 tmp = s->buffers - in cx18_g_enc_index()
807 s->bufs_per_mdl * CX18_ENC_STREAM_TYPE_IDX_FW_MDL_MIN; in cx18_g_enc_index()
810 tmp = tmp * s->buf_size / sizeof(struct cx18_enc_idx_entry); in cx18_g_enc_index()
813 idx->entries = 0; in cx18_g_enc_index()
814 idx->entries_cap = tmp; in cx18_g_enc_index()
815 memset(idx->reserved, 0, sizeof(idx->reserved)); in cx18_g_enc_index()
819 mdl = cx18_dequeue(s, &s->q_full); in cx18_g_enc_index()
825 if (mdl->readpos < mdl->bytesused) { in cx18_g_enc_index()
827 cx18_push(s, mdl, &s->q_full); in cx18_g_enc_index()
832 cx18_enqueue(s, mdl, &s->q_free); in cx18_g_enc_index()
834 } while (idx->entries < V4L2_ENC_IDX_ENTRIES); in cx18_g_enc_index()
845 struct cx18 *cx = id->cx; in cx18_encoder_cmd()
848 switch (enc->cmd) { in cx18_encoder_cmd()
851 enc->flags = 0; in cx18_encoder_cmd()
856 enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END; in cx18_encoder_cmd()
857 cx18_stop_capture(&cx->streams[id->type], in cx18_encoder_cmd()
858 enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END); in cx18_encoder_cmd()
863 enc->flags = 0; in cx18_encoder_cmd()
864 if (!atomic_read(&cx->ana_capturing)) in cx18_encoder_cmd()
865 return -EPERM; in cx18_encoder_cmd()
866 if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) in cx18_encoder_cmd()
871 return -EBADFD; in cx18_encoder_cmd()
879 enc->flags = 0; in cx18_encoder_cmd()
880 if (!atomic_read(&cx->ana_capturing)) in cx18_encoder_cmd()
881 return -EPERM; in cx18_encoder_cmd()
882 if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) in cx18_encoder_cmd()
887 return -EBADFD; in cx18_encoder_cmd()
894 CX18_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd); in cx18_encoder_cmd()
895 return -EINVAL; in cx18_encoder_cmd()
903 struct cx18 *cx = fh2id(fh)->cx; in cx18_try_encoder_cmd()
905 switch (enc->cmd) { in cx18_try_encoder_cmd()
908 enc->flags = 0; in cx18_try_encoder_cmd()
913 enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END; in cx18_try_encoder_cmd()
918 enc->flags = 0; in cx18_try_encoder_cmd()
923 enc->flags = 0; in cx18_try_encoder_cmd()
927 CX18_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd); in cx18_try_encoder_cmd()
928 return -EINVAL; in cx18_try_encoder_cmd()
935 struct cx18 *cx = fh2id(fh)->cx; in cx18_log_status()
940 CX18_INFO("Version: %s Card: %s\n", CX18_VERSION, cx->card_name); in cx18_log_status()
941 if (cx->hw_flags & CX18_HW_TVEEPROM) { in cx18_log_status()
947 cx18_get_input(cx, cx->active_input, &vidin); in cx18_log_status()
948 cx18_get_audio_input(cx, cx->audio_input, &audin); in cx18_log_status()
951 mutex_lock(&cx->gpio_lock); in cx18_log_status()
953 cx->gpio_dir, cx->gpio_val); in cx18_log_status()
954 mutex_unlock(&cx->gpio_lock); in cx18_log_status()
956 test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) ? "Radio" : "TV"); in cx18_log_status()
957 v4l2_ctrl_handler_log_status(&cx->cxhdl.hdl, cx->v4l2_dev.name); in cx18_log_status()
958 CX18_INFO("Status flags: 0x%08lx\n", cx->i_flags); in cx18_log_status()
960 struct cx18_stream *s = &cx->streams[i]; in cx18_log_status()
962 if (s->video_dev.v4l2_dev == NULL || s->buffers == 0) in cx18_log_status()
965 s->name, s->s_flags, in cx18_log_status()
966 atomic_read(&s->q_full.depth) * s->bufs_per_mdl * 100 in cx18_log_status()
967 / s->buffers, in cx18_log_status()
968 (s->buffers * s->buf_size) / 1024, s->buffers); in cx18_log_status()
971 (long long)cx->mpg_data_received, in cx18_log_status()
972 (long long)cx->vbi_data_inserted); in cx18_log_status()
979 struct cx18 *cx = fh2id(fh)->cx; in cx18_default()
992 return -ENOTTY; in cx18_default()
1048 vdev->ioctl_ops = &cx18_ioctl_ops; in cx18_set_funcs()