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>
89 * and clear the passed in fmt->service_set
93 u16 set = fmt->service_set; in cx18_expand_service_set()
96 fmt->service_set = 0; in cx18_expand_service_set()
99 fmt->service_lines[f][l] = select_service_from_set(f, l, set, is_pal); in cx18_expand_service_set()
114 fmt->service_lines[f][l] = select_service_from_set(f, l, fmt->service_lines[f][l], is_pal); in check_service_set()
115 set |= fmt->service_lines[f][l]; in check_service_set()
129 set |= fmt->service_lines[f][l]; in cx18_get_service_set()
138 struct cx18 *cx = id->cx; in cx18_g_fmt_vid_cap()
139 struct cx18_stream *s = &cx->streams[id->type]; in cx18_g_fmt_vid_cap()
140 struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; in cx18_g_fmt_vid_cap()
142 pixfmt->width = cx->cxhdl.width; in cx18_g_fmt_vid_cap()
143 pixfmt->height = cx->cxhdl.height; in cx18_g_fmt_vid_cap()
144 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; in cx18_g_fmt_vid_cap()
145 pixfmt->field = V4L2_FIELD_INTERLACED; in cx18_g_fmt_vid_cap()
146 if (id->type == CX18_ENC_STREAM_TYPE_YUV) { in cx18_g_fmt_vid_cap()
147 pixfmt->pixelformat = s->pixelformat; in cx18_g_fmt_vid_cap()
148 pixfmt->sizeimage = s->vb_bytes_per_frame; in cx18_g_fmt_vid_cap()
149 pixfmt->bytesperline = s->vb_bytes_per_line; in cx18_g_fmt_vid_cap()
151 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; in cx18_g_fmt_vid_cap()
152 pixfmt->sizeimage = 128 * 1024; in cx18_g_fmt_vid_cap()
153 pixfmt->bytesperline = 0; in cx18_g_fmt_vid_cap()
161 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_fmt_vbi_cap()
162 struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi; in cx18_g_fmt_vbi_cap()
164 vbifmt->sampling_rate = 27000000; in cx18_g_fmt_vbi_cap()
165 vbifmt->offset = 248; /* FIXME - slightly wrong for both 50 & 60 Hz */ in cx18_g_fmt_vbi_cap()
166 vbifmt->samples_per_line = VBI_ACTIVE_SAMPLES - 4; in cx18_g_fmt_vbi_cap()
167 vbifmt->sample_format = V4L2_PIX_FMT_GREY; in cx18_g_fmt_vbi_cap()
168 vbifmt->start[0] = cx->vbi.start[0]; in cx18_g_fmt_vbi_cap()
169 vbifmt->start[1] = cx->vbi.start[1]; in cx18_g_fmt_vbi_cap()
170 vbifmt->count[0] = vbifmt->count[1] = cx->vbi.count; in cx18_g_fmt_vbi_cap()
171 vbifmt->flags = 0; in cx18_g_fmt_vbi_cap()
172 vbifmt->reserved[0] = 0; in cx18_g_fmt_vbi_cap()
173 vbifmt->reserved[1] = 0; in cx18_g_fmt_vbi_cap()
180 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_fmt_sliced_vbi_cap()
181 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in cx18_g_fmt_sliced_vbi_cap()
184 vbifmt->reserved[0] = 0; in cx18_g_fmt_sliced_vbi_cap()
185 vbifmt->reserved[1] = 0; in cx18_g_fmt_sliced_vbi_cap()
186 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; in cx18_g_fmt_sliced_vbi_cap()
187 memset(vbifmt->service_lines, 0, sizeof(vbifmt->service_lines)); in cx18_g_fmt_sliced_vbi_cap()
188 vbifmt->service_set = 0; in cx18_g_fmt_sliced_vbi_cap()
193 * fmt->fmt.sliced under valid calling conditions in cx18_g_fmt_sliced_vbi_cap()
195 if (v4l2_subdev_call(cx->sd_av, vbi, g_sliced_fmt, &fmt->fmt.sliced)) in cx18_g_fmt_sliced_vbi_cap()
196 return -EINVAL; in cx18_g_fmt_sliced_vbi_cap()
198 vbifmt->service_set = cx18_get_service_set(vbifmt); in cx18_g_fmt_sliced_vbi_cap()
206 struct cx18 *cx = id->cx; in cx18_try_fmt_vid_cap()
207 int w = fmt->fmt.pix.width; in cx18_try_fmt_vid_cap()
208 int h = fmt->fmt.pix.height; in cx18_try_fmt_vid_cap()
213 if (id->type == CX18_ENC_STREAM_TYPE_YUV) { in cx18_try_fmt_vid_cap()
218 h = min(h, cx->is_50hz ? 576 : 480); in cx18_try_fmt_vid_cap()
221 fmt->fmt.pix.width = w; in cx18_try_fmt_vid_cap()
222 fmt->fmt.pix.height = h; in cx18_try_fmt_vid_cap()
235 struct cx18 *cx = fh2id(fh)->cx; in cx18_try_fmt_sliced_vbi_cap()
236 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in cx18_try_fmt_sliced_vbi_cap()
238 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; in cx18_try_fmt_sliced_vbi_cap()
239 vbifmt->reserved[0] = 0; in cx18_try_fmt_sliced_vbi_cap()
240 vbifmt->reserved[1] = 0; in cx18_try_fmt_sliced_vbi_cap()
243 if (vbifmt->service_set) in cx18_try_fmt_sliced_vbi_cap()
244 cx18_expand_service_set(vbifmt, cx->is_50hz); in cx18_try_fmt_sliced_vbi_cap()
246 if (check_service_set(vbifmt, cx->is_50hz)) in cx18_try_fmt_sliced_vbi_cap()
247 vbifmt->service_set = cx18_get_service_set(vbifmt); in cx18_try_fmt_sliced_vbi_cap()
255 struct cx18 *cx = id->cx; in cx18_s_fmt_vid_cap()
259 struct cx18_stream *s = &cx->streams[id->type]; in cx18_s_fmt_vid_cap()
266 w = fmt->fmt.pix.width; in cx18_s_fmt_vid_cap()
267 h = fmt->fmt.pix.height; in cx18_s_fmt_vid_cap()
269 if (cx->cxhdl.width == w && cx->cxhdl.height == h && in cx18_s_fmt_vid_cap()
270 s->pixelformat == fmt->fmt.pix.pixelformat) in cx18_s_fmt_vid_cap()
273 if (atomic_read(&cx->ana_capturing) > 0) in cx18_s_fmt_vid_cap()
274 return -EBUSY; in cx18_s_fmt_vid_cap()
276 s->pixelformat = fmt->fmt.pix.pixelformat; in cx18_s_fmt_vid_cap()
279 if (s->pixelformat == V4L2_PIX_FMT_HM12) { in cx18_s_fmt_vid_cap()
280 s->vb_bytes_per_frame = h * 720 * 3 / 2; in cx18_s_fmt_vid_cap()
281 s->vb_bytes_per_line = 720; /* First plane */ in cx18_s_fmt_vid_cap()
283 s->vb_bytes_per_frame = h * 720 * 2; in cx18_s_fmt_vid_cap()
284 s->vb_bytes_per_line = 1440; /* Packed */ in cx18_s_fmt_vid_cap()
287 format.format.width = cx->cxhdl.width = w; in cx18_s_fmt_vid_cap()
288 format.format.height = cx->cxhdl.height = h; in cx18_s_fmt_vid_cap()
290 v4l2_subdev_call(cx->sd_av, pad, set_fmt, NULL, &format); in cx18_s_fmt_vid_cap()
298 struct cx18 *cx = id->cx; in cx18_s_fmt_vbi_cap()
305 if (!cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0) in cx18_s_fmt_vbi_cap()
306 return -EBUSY; in cx18_s_fmt_vbi_cap()
313 ret = v4l2_subdev_call(cx->sd_av, vbi, s_raw_fmt, &fmt->fmt.vbi); in cx18_s_fmt_vbi_cap()
317 /* Store our new v4l2 (non-)sliced VBI state */ in cx18_s_fmt_vbi_cap()
318 cx->vbi.sliced_in->service_set = 0; in cx18_s_fmt_vbi_cap()
319 cx->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE; in cx18_s_fmt_vbi_cap()
328 struct cx18 *cx = id->cx; in cx18_s_fmt_sliced_vbi_cap()
330 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in cx18_s_fmt_sliced_vbi_cap()
338 if (cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0) in cx18_s_fmt_sliced_vbi_cap()
339 return -EBUSY; in cx18_s_fmt_sliced_vbi_cap()
344 * passed in fmt->fmt.sliced under valid calling conditions in cx18_s_fmt_sliced_vbi_cap()
346 ret = v4l2_subdev_call(cx->sd_av, vbi, s_sliced_fmt, &fmt->fmt.sliced); in cx18_s_fmt_sliced_vbi_cap()
350 cx->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; in cx18_s_fmt_sliced_vbi_cap()
351 memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in)); in cx18_s_fmt_sliced_vbi_cap()
359 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_register()
361 if (reg->reg & 0x3) in cx18_g_register()
362 return -EINVAL; in cx18_g_register()
363 if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE) in cx18_g_register()
364 return -EINVAL; in cx18_g_register()
365 reg->size = 4; in cx18_g_register()
366 reg->val = cx18_read_enc(cx, reg->reg); in cx18_g_register()
373 struct cx18 *cx = fh2id(fh)->cx; in cx18_s_register()
375 if (reg->reg & 0x3) in cx18_s_register()
376 return -EINVAL; in cx18_s_register()
377 if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE) in cx18_s_register()
378 return -EINVAL; in cx18_s_register()
379 cx18_write_enc(cx, reg->val, reg->reg); in cx18_s_register()
388 struct cx18 *cx = id->cx; in cx18_querycap()
390 strscpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver)); in cx18_querycap()
391 strscpy(vcap->card, cx->card_name, sizeof(vcap->card)); in cx18_querycap()
392 snprintf(vcap->bus_info, sizeof(vcap->bus_info), in cx18_querycap()
393 "PCI:%s", pci_name(cx->pci_dev)); in cx18_querycap()
394 vcap->capabilities = cx->v4l2_cap | V4L2_CAP_DEVICE_CAPS; in cx18_querycap()
400 struct cx18 *cx = fh2id(fh)->cx; in cx18_enumaudio()
402 return cx18_get_audio_input(cx, vin->index, vin); in cx18_enumaudio()
407 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_audio()
409 vin->index = cx->audio_input; in cx18_g_audio()
410 return cx18_get_audio_input(cx, vin->index, vin); in cx18_g_audio()
415 struct cx18 *cx = fh2id(fh)->cx; in cx18_s_audio()
417 if (vout->index >= cx->nof_audio_inputs) in cx18_s_audio()
418 return -EINVAL; in cx18_s_audio()
419 cx->audio_input = vout->index; in cx18_s_audio()
426 struct cx18 *cx = fh2id(fh)->cx; in cx18_enum_input()
429 return cx18_get_input(cx, vin->index, vin); in cx18_enum_input()
435 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_pixelaspect()
438 return -EINVAL; in cx18_g_pixelaspect()
440 f->numerator = cx->is_50hz ? 54 : 11; in cx18_g_pixelaspect()
441 f->denominator = cx->is_50hz ? 59 : 10; in cx18_g_pixelaspect()
448 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_selection()
450 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in cx18_g_selection()
451 return -EINVAL; in cx18_g_selection()
452 switch (sel->target) { in cx18_g_selection()
455 sel->r.top = sel->r.left = 0; in cx18_g_selection()
456 sel->r.width = 720; in cx18_g_selection()
457 sel->r.height = cx->is_50hz ? 576 : 480; in cx18_g_selection()
460 return -EINVAL; in cx18_g_selection()
490 if (fmt->index > ARRAY_SIZE(formats) - 1) in cx18_enum_fmt_vid_cap()
491 return -EINVAL; in cx18_enum_fmt_vid_cap()
492 *fmt = formats[fmt->index]; in cx18_enum_fmt_vid_cap()
498 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_input()
500 *i = cx->active_input; in cx18_g_input()
507 struct cx18 *cx = id->cx; in cx18_s_input()
510 cx->card->video_inputs + inp; in cx18_s_input()
512 if (inp >= cx->nof_inputs) in cx18_s_input()
513 return -EINVAL; in cx18_s_input()
515 if (inp == cx->active_input) { in cx18_s_input()
521 cx->active_input, inp); in cx18_s_input()
523 cx->active_input = inp; in cx18_s_input()
525 cx->audio_input = cx->card->video_inputs[inp].audio_index; in cx18_s_input()
526 if (card_input->video_type == V4L2_INPUT_TYPE_TUNER) in cx18_s_input()
527 std = cx->tuner_std; in cx18_s_input()
528 cx->streams[CX18_ENC_STREAM_TYPE_MPG].video_dev.tvnorms = std; in cx18_s_input()
529 cx->streams[CX18_ENC_STREAM_TYPE_YUV].video_dev.tvnorms = std; in cx18_s_input()
530 cx->streams[CX18_ENC_STREAM_TYPE_VBI].video_dev.tvnorms = std; in cx18_s_input()
544 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_frequency()
546 if (vf->tuner != 0) in cx18_g_frequency()
547 return -EINVAL; in cx18_g_frequency()
556 struct cx18 *cx = id->cx; in cx18_s_frequency()
558 if (vf->tuner != 0) in cx18_s_frequency()
559 return -EINVAL; in cx18_s_frequency()
562 CX18_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf->frequency); in cx18_s_frequency()
570 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_std()
572 *std = cx->std; in cx18_g_std()
579 struct cx18 *cx = id->cx; in cx18_s_std()
582 return -EINVAL; in cx18_s_std()
584 if (std == cx->std) in cx18_s_std()
587 if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) || in cx18_s_std()
588 atomic_read(&cx->ana_capturing) > 0) { in cx18_s_std()
589 /* Switching standard would turn off the radio or mess in cx18_s_std()
592 return -EBUSY; in cx18_s_std()
595 cx->std = std; in cx18_s_std()
596 cx->is_60hz = (std & V4L2_STD_525_60) ? 1 : 0; in cx18_s_std()
597 cx->is_50hz = !cx->is_60hz; in cx18_s_std()
598 cx2341x_handler_set_50hz(&cx->cxhdl, cx->is_50hz); in cx18_s_std()
599 cx->cxhdl.width = 720; in cx18_s_std()
600 cx->cxhdl.height = cx->is_50hz ? 576 : 480; in cx18_s_std()
601 cx->vbi.count = cx->is_50hz ? 18 : 12; in cx18_s_std()
602 cx->vbi.start[0] = cx->is_50hz ? 6 : 10; in cx18_s_std()
603 cx->vbi.start[1] = cx->is_50hz ? 318 : 273; in cx18_s_std()
604 CX18_DEBUG_INFO("Switching standard to %llx.\n", in cx18_s_std()
605 (unsigned long long) cx->std); in cx18_s_std()
608 cx18_call_all(cx, video, s_std, cx->std); in cx18_s_std()
612 static int cx18_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *vt) in cx18_s_tuner() argument
615 struct cx18 *cx = id->cx; in cx18_s_tuner()
617 if (vt->index != 0) in cx18_s_tuner()
618 return -EINVAL; in cx18_s_tuner()
620 cx18_call_all(cx, tuner, s_tuner, vt); in cx18_s_tuner()
624 static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) in cx18_g_tuner() argument
626 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_tuner()
628 if (vt->index != 0) in cx18_g_tuner()
629 return -EINVAL; in cx18_g_tuner()
631 cx18_call_all(cx, tuner, g_tuner, vt); in cx18_g_tuner()
633 if (vt->type == V4L2_TUNER_RADIO) in cx18_g_tuner()
634 strscpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name)); in cx18_g_tuner()
636 strscpy(vt->name, "cx18 TV Tuner", sizeof(vt->name)); in cx18_g_tuner()
643 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_sliced_vbi_cap()
644 int set = cx->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525; in cx18_g_sliced_vbi_cap()
647 if (cap->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) in cx18_g_sliced_vbi_cap()
648 return -EINVAL; in cx18_g_sliced_vbi_cap()
650 cap->service_set = 0; in cx18_g_sliced_vbi_cap()
653 if (valid_service_line(f, l, cx->is_50hz)) { in cx18_g_sliced_vbi_cap()
656 * for the standard, on a valid line for the std in cx18_g_sliced_vbi_cap()
658 cap->service_lines[f][l] = set; in cx18_g_sliced_vbi_cap()
659 cap->service_set |= set; in cx18_g_sliced_vbi_cap()
661 cap->service_lines[f][l] = 0; in cx18_g_sliced_vbi_cap()
665 cap->reserved[f] = 0; in cx18_g_sliced_vbi_cap()
678 -1, V4L2_ENC_IDX_FRAME_I, V4L2_ENC_IDX_FRAME_P, in _cx18_process_idx_data()
679 -1, V4L2_ENC_IDX_FRAME_B, -1, -1, -1 in _cx18_process_idx_data()
687 remaining = buf->bytesused - buf->readpos; in _cx18_process_idx_data()
689 e_idx = &idx->entry[idx->entries]; in _cx18_process_idx_data()
690 e_buf = (struct cx18_enc_idx_entry *) &buf->buf[buf->readpos]; in _cx18_process_idx_data()
693 idx->entries < V4L2_ENC_IDX_ENTRIES) { in _cx18_process_idx_data()
695 e_idx->offset = (((u64) le32_to_cpu(e_buf->offset_high)) << 32) in _cx18_process_idx_data()
696 | le32_to_cpu(e_buf->offset_low); in _cx18_process_idx_data()
698 e_idx->pts = (((u64) (le32_to_cpu(e_buf->pts_high) & 1)) << 32) in _cx18_process_idx_data()
699 | le32_to_cpu(e_buf->pts_low); in _cx18_process_idx_data()
701 e_idx->length = le32_to_cpu(e_buf->length); in _cx18_process_idx_data()
703 e_idx->flags = mapping[le32_to_cpu(e_buf->flags) & 0x7]; in _cx18_process_idx_data()
705 e_idx->reserved[0] = 0; in _cx18_process_idx_data()
706 e_idx->reserved[1] = 0; in _cx18_process_idx_data()
708 idx->entries++; in _cx18_process_idx_data()
709 e_idx = &idx->entry[idx->entries]; in _cx18_process_idx_data()
712 remaining -= sizeof(struct cx18_enc_idx_entry); in _cx18_process_idx_data()
720 buf->readpos += consumed; in _cx18_process_idx_data()
727 if (s->type != CX18_ENC_STREAM_TYPE_IDX) in cx18_process_idx_data()
728 return -EINVAL; in cx18_process_idx_data()
730 if (mdl->curr_buf == NULL) in cx18_process_idx_data()
731 mdl->curr_buf = list_first_entry(&mdl->buf_list, in cx18_process_idx_data()
734 if (list_entry_is_past_end(mdl->curr_buf, &mdl->buf_list, list)) { in cx18_process_idx_data()
740 mdl->readpos = mdl->bytesused; in cx18_process_idx_data()
744 list_for_each_entry_from(mdl->curr_buf, &mdl->buf_list, list) { in cx18_process_idx_data()
747 if (mdl->curr_buf->readpos >= mdl->curr_buf->bytesused) in cx18_process_idx_data()
750 mdl->readpos += _cx18_process_idx_data(mdl->curr_buf, idx); in cx18_process_idx_data()
753 if (idx->entries >= V4L2_ENC_IDX_ENTRIES || in cx18_process_idx_data()
754 mdl->curr_buf->readpos < mdl->curr_buf->bytesused || in cx18_process_idx_data()
755 mdl->readpos >= mdl->bytesused) in cx18_process_idx_data()
764 struct cx18 *cx = fh2id(fh)->cx; in cx18_g_enc_index()
765 struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_IDX]; in cx18_g_enc_index()
770 return -EINVAL; in cx18_g_enc_index()
773 tmp = s->buffers - in cx18_g_enc_index()
774 s->bufs_per_mdl * CX18_ENC_STREAM_TYPE_IDX_FW_MDL_MIN; in cx18_g_enc_index()
777 tmp = tmp * s->buf_size / sizeof(struct cx18_enc_idx_entry); in cx18_g_enc_index()
780 idx->entries = 0; in cx18_g_enc_index()
781 idx->entries_cap = tmp; in cx18_g_enc_index()
782 memset(idx->reserved, 0, sizeof(idx->reserved)); in cx18_g_enc_index()
786 mdl = cx18_dequeue(s, &s->q_full); in cx18_g_enc_index()
792 if (mdl->readpos < mdl->bytesused) { in cx18_g_enc_index()
794 cx18_push(s, mdl, &s->q_full); in cx18_g_enc_index()
799 cx18_enqueue(s, mdl, &s->q_free); in cx18_g_enc_index()
801 } while (idx->entries < V4L2_ENC_IDX_ENTRIES); in cx18_g_enc_index()
811 struct cx18 *cx = id->cx; in cx18_vb_queue()
812 struct cx18_stream *s = &cx->streams[id->type]; in cx18_vb_queue()
814 switch (s->vb_type) { in cx18_vb_queue()
816 q = &s->vbuf_q; in cx18_vb_queue()
829 struct cx18_open_id *id = file->private_data; in cx18_streamon()
830 struct cx18 *cx = id->cx; in cx18_streamon()
831 struct cx18_stream *s = &cx->streams[id->type]; in cx18_streamon()
834 if ((s->vb_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && in cx18_streamon()
835 (s->vb_type != V4L2_BUF_TYPE_VBI_CAPTURE)) in cx18_streamon()
836 return -EINVAL; in cx18_streamon()
838 if (id->type != CX18_ENC_STREAM_TYPE_YUV) in cx18_streamon()
839 return -EINVAL; in cx18_streamon()
842 mod_timer(&s->vb_timeout, msecs_to_jiffies(2000) + jiffies); in cx18_streamon()
850 struct cx18_open_id *id = file->private_data; in cx18_streamoff()
851 struct cx18 *cx = id->cx; in cx18_streamoff()
852 struct cx18_stream *s = &cx->streams[id->type]; in cx18_streamoff()
855 if ((s->vb_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && in cx18_streamoff()
856 (s->vb_type != V4L2_BUF_TYPE_VBI_CAPTURE)) in cx18_streamoff()
857 return -EINVAL; in cx18_streamoff()
859 if (id->type != CX18_ENC_STREAM_TYPE_YUV) in cx18_streamoff()
860 return -EINVAL; in cx18_streamoff()
868 struct cx18_open_id *id = file->private_data; in cx18_reqbufs()
869 struct cx18 *cx = id->cx; in cx18_reqbufs()
870 struct cx18_stream *s = &cx->streams[id->type]; in cx18_reqbufs()
872 if ((s->vb_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && in cx18_reqbufs()
873 (s->vb_type != V4L2_BUF_TYPE_VBI_CAPTURE)) in cx18_reqbufs()
874 return -EINVAL; in cx18_reqbufs()
882 struct cx18_open_id *id = file->private_data; in cx18_querybuf()
883 struct cx18 *cx = id->cx; in cx18_querybuf()
884 struct cx18_stream *s = &cx->streams[id->type]; in cx18_querybuf()
886 if ((s->vb_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && in cx18_querybuf()
887 (s->vb_type != V4L2_BUF_TYPE_VBI_CAPTURE)) in cx18_querybuf()
888 return -EINVAL; in cx18_querybuf()
895 struct cx18_open_id *id = file->private_data; in cx18_qbuf()
896 struct cx18 *cx = id->cx; in cx18_qbuf()
897 struct cx18_stream *s = &cx->streams[id->type]; in cx18_qbuf()
899 if ((s->vb_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && in cx18_qbuf()
900 (s->vb_type != V4L2_BUF_TYPE_VBI_CAPTURE)) in cx18_qbuf()
901 return -EINVAL; in cx18_qbuf()
908 struct cx18_open_id *id = file->private_data; in cx18_dqbuf()
909 struct cx18 *cx = id->cx; in cx18_dqbuf()
910 struct cx18_stream *s = &cx->streams[id->type]; in cx18_dqbuf()
912 if ((s->vb_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && in cx18_dqbuf()
913 (s->vb_type != V4L2_BUF_TYPE_VBI_CAPTURE)) in cx18_dqbuf()
914 return -EINVAL; in cx18_dqbuf()
916 return videobuf_dqbuf(cx18_vb_queue(id), b, file->f_flags & O_NONBLOCK); in cx18_dqbuf()
923 struct cx18 *cx = id->cx; in cx18_encoder_cmd()
926 switch (enc->cmd) { in cx18_encoder_cmd()
929 enc->flags = 0; in cx18_encoder_cmd()
934 enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END; in cx18_encoder_cmd()
936 enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END); in cx18_encoder_cmd()
941 enc->flags = 0; in cx18_encoder_cmd()
942 if (!atomic_read(&cx->ana_capturing)) in cx18_encoder_cmd()
943 return -EPERM; in cx18_encoder_cmd()
944 if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) in cx18_encoder_cmd()
949 return -EBADFD; in cx18_encoder_cmd()
957 enc->flags = 0; in cx18_encoder_cmd()
958 if (!atomic_read(&cx->ana_capturing)) in cx18_encoder_cmd()
959 return -EPERM; in cx18_encoder_cmd()
960 if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) in cx18_encoder_cmd()
965 return -EBADFD; in cx18_encoder_cmd()
972 CX18_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd); in cx18_encoder_cmd()
973 return -EINVAL; in cx18_encoder_cmd()
981 struct cx18 *cx = fh2id(fh)->cx; in cx18_try_encoder_cmd()
983 switch (enc->cmd) { in cx18_try_encoder_cmd()
986 enc->flags = 0; in cx18_try_encoder_cmd()
991 enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END; in cx18_try_encoder_cmd()
996 enc->flags = 0; in cx18_try_encoder_cmd()
1001 enc->flags = 0; in cx18_try_encoder_cmd()
1005 CX18_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd); in cx18_try_encoder_cmd()
1006 return -EINVAL; in cx18_try_encoder_cmd()
1013 struct cx18 *cx = fh2id(fh)->cx; in cx18_log_status()
1018 CX18_INFO("Version: %s Card: %s\n", CX18_VERSION, cx->card_name); in cx18_log_status()
1019 if (cx->hw_flags & CX18_HW_TVEEPROM) { in cx18_log_status()
1025 cx18_get_input(cx, cx->active_input, &vidin); in cx18_log_status()
1026 cx18_get_audio_input(cx, cx->audio_input, &audin); in cx18_log_status()
1029 mutex_lock(&cx->gpio_lock); in cx18_log_status()
1031 cx->gpio_dir, cx->gpio_val); in cx18_log_status()
1032 mutex_unlock(&cx->gpio_lock); in cx18_log_status()
1034 test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) ? "Radio" : "TV"); in cx18_log_status()
1035 v4l2_ctrl_handler_log_status(&cx->cxhdl.hdl, cx->v4l2_dev.name); in cx18_log_status()
1036 CX18_INFO("Status flags: 0x%08lx\n", cx->i_flags); in cx18_log_status()
1038 struct cx18_stream *s = &cx->streams[i]; in cx18_log_status()
1040 if (s->video_dev.v4l2_dev == NULL || s->buffers == 0) in cx18_log_status()
1043 s->name, s->s_flags, in cx18_log_status()
1044 atomic_read(&s->q_full.depth) * s->bufs_per_mdl * 100 in cx18_log_status()
1045 / s->buffers, in cx18_log_status()
1046 (s->buffers * s->buf_size) / 1024, s->buffers); in cx18_log_status()
1049 (long long)cx->mpg_data_received, in cx18_log_status()
1050 (long long)cx->vbi_data_inserted); in cx18_log_status()
1057 struct cx18 *cx = fh2id(fh)->cx; in cx18_default()
1070 return -ENOTTY; in cx18_default()
1123 vdev->ioctl_ops = &cx18_ioctl_ops; in cx18_set_funcs()