Lines Matching +full:bt +full:- +full:pcm +full:- +full:int +full:- +full:params

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Derived from ivtv-streams.c
11 #include "cx18-driver.h"
12 #include "cx18-io.h"
13 #include "cx18-fileops.h"
14 #include "cx18-mailbox.h"
15 #include "cx18-i2c.h"
16 #include "cx18-queue.h"
17 #include "cx18-ioctl.h"
18 #include "cx18-streams.h"
19 #include "cx18-cards.h"
20 #include "cx18-scb.h"
21 #include "cx18-dvb.h"
46 /* offset from 0 to register pcm v4l2 minors on */
53 int vfl_type;
54 int num_offset;
55 int dma;
67 VFL_TYPE_VIDEO, -1,
85 "encoder PCM audio",
92 VFL_TYPE_VIDEO, -1,
103 static int cx18_queue_setup(struct vb2_queue *vq, in cx18_queue_setup()
104 unsigned int *nbuffers, unsigned int *nplanes, in cx18_queue_setup()
105 unsigned int sizes[], struct device *alloc_devs[]) in cx18_queue_setup()
107 unsigned int q_num_bufs = vb2_get_num_buffers(vq); in cx18_queue_setup()
109 struct cx18 *cx = s->cx; in cx18_queue_setup()
110 unsigned int szimage; in cx18_queue_setup()
116 if (s->pixelformat == V4L2_PIX_FMT_NV12_16L16) in cx18_queue_setup()
117 szimage = cx->cxhdl.height * 720 * 3 / 2; in cx18_queue_setup()
119 szimage = cx->cxhdl.height * 720 * 2; in cx18_queue_setup()
126 *nbuffers = 3 - q_num_bufs; in cx18_queue_setup()
130 return -EINVAL; in cx18_queue_setup()
141 struct cx18_stream *s = vb2_get_drv_priv(vb->vb2_queue); in cx18_buf_queue()
147 spin_lock_irqsave(&s->vb_lock, flags); in cx18_buf_queue()
148 list_add_tail(&buf->list, &s->vb_capture); in cx18_buf_queue()
149 spin_unlock_irqrestore(&s->vb_lock, flags); in cx18_buf_queue()
152 static int cx18_buf_prepare(struct vb2_buffer *vb) in cx18_buf_prepare()
155 struct cx18_stream *s = vb2_get_drv_priv(vb->vb2_queue); in cx18_buf_prepare()
156 struct cx18 *cx = s->cx; in cx18_buf_prepare()
157 unsigned int size; in cx18_buf_prepare()
163 if (s->pixelformat == V4L2_PIX_FMT_NV12_16L16) in cx18_buf_prepare()
164 size = cx->cxhdl.height * 720 * 3 / 2; in cx18_buf_prepare()
166 size = cx->cxhdl.height * 720 * 2; in cx18_buf_prepare()
169 return -EINVAL; in cx18_buf_prepare()
171 vbuf->field = V4L2_FIELD_INTERLACED; in cx18_buf_prepare()
177 while (!list_empty(&s->vb_capture)) { in cx18_clear_queue()
180 buf = list_first_entry(&s->vb_capture, in cx18_clear_queue()
182 list_del(&buf->list); in cx18_clear_queue()
183 vb2_buffer_done(&buf->vb.vb2_buf, state); in cx18_clear_queue()
187 static int cx18_start_streaming(struct vb2_queue *vq, unsigned int count) in cx18_start_streaming()
189 struct v4l2_fh *owner = vq->owner; in cx18_start_streaming()
192 int rc; in cx18_start_streaming()
195 rc = -EIO; in cx18_start_streaming()
199 s->sequence = 0; in cx18_start_streaming()
203 mod_timer(&s->vb_timeout, msecs_to_jiffies(2000) + jiffies); in cx18_start_streaming()
208 spin_lock_irqsave(&s->vb_lock, flags); in cx18_start_streaming()
210 spin_unlock_irqrestore(&s->vb_lock, flags); in cx18_start_streaming()
220 timer_delete_sync(&s->vb_timeout); in cx18_stop_streaming()
221 spin_lock_irqsave(&s->vb_lock, flags); in cx18_stop_streaming()
223 spin_unlock_irqrestore(&s->vb_lock, flags); in cx18_stop_streaming()
234 static int cx18_stream_init(struct cx18 *cx, int type) in cx18_stream_init()
236 struct cx18_stream *s = &cx->streams[type]; in cx18_stream_init()
237 int err = 0; in cx18_stream_init()
242 s->dvb = NULL; in cx18_stream_init()
243 s->cx = cx; in cx18_stream_init()
244 s->type = type; in cx18_stream_init()
245 s->name = cx18_stream_info[type].name; in cx18_stream_init()
246 s->handle = CX18_INVALID_TASK_HANDLE; in cx18_stream_init()
248 s->dma = cx18_stream_info[type].dma; in cx18_stream_init()
249 s->v4l2_dev_caps = cx18_stream_info[type].caps; in cx18_stream_init()
250 s->buffers = cx->stream_buffers[type]; in cx18_stream_init()
251 s->buf_size = cx->stream_buf_size[type]; in cx18_stream_init()
252 INIT_LIST_HEAD(&s->buf_pool); in cx18_stream_init()
253 s->bufs_per_mdl = 1; in cx18_stream_init()
254 s->mdl_size = s->buf_size * s->bufs_per_mdl; in cx18_stream_init()
256 init_waitqueue_head(&s->waitq); in cx18_stream_init()
257 s->id = -1; in cx18_stream_init()
258 spin_lock_init(&s->q_free.lock); in cx18_stream_init()
259 cx18_queue_init(&s->q_free); in cx18_stream_init()
260 spin_lock_init(&s->q_busy.lock); in cx18_stream_init()
261 cx18_queue_init(&s->q_busy); in cx18_stream_init()
262 spin_lock_init(&s->q_full.lock); in cx18_stream_init()
263 cx18_queue_init(&s->q_full); in cx18_stream_init()
264 spin_lock_init(&s->q_idle.lock); in cx18_stream_init()
265 cx18_queue_init(&s->q_idle); in cx18_stream_init()
267 INIT_WORK(&s->out_work_order, cx18_out_work_handler); in cx18_stream_init()
269 INIT_LIST_HEAD(&s->vb_capture); in cx18_stream_init()
270 timer_setup(&s->vb_timeout, cx18_vb_timeout, 0); in cx18_stream_init()
271 spin_lock_init(&s->vb_lock); in cx18_stream_init()
274 s->vb_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in cx18_stream_init()
277 s->pixelformat = V4L2_PIX_FMT_NV12_16L16; in cx18_stream_init()
278 s->vb_bytes_per_frame = cx->cxhdl.height * 720 * 3 / 2; in cx18_stream_init()
279 s->vb_bytes_per_line = 720; in cx18_stream_init()
281 s->vidq.io_modes = VB2_READ | VB2_MMAP | VB2_DMABUF; in cx18_stream_init()
282 s->vidq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in cx18_stream_init()
283 s->vidq.drv_priv = s; in cx18_stream_init()
284 s->vidq.buf_struct_size = sizeof(struct cx18_vb2_buffer); in cx18_stream_init()
285 s->vidq.ops = &cx18_vb2_qops; in cx18_stream_init()
286 s->vidq.mem_ops = &vb2_vmalloc_memops; in cx18_stream_init()
287 s->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in cx18_stream_init()
288 s->vidq.min_queued_buffers = 2; in cx18_stream_init()
289 s->vidq.gfp_flags = GFP_DMA32; in cx18_stream_init()
290 s->vidq.dev = &cx->pci_dev->dev; in cx18_stream_init()
291 s->vidq.lock = &cx->serialize_lock; in cx18_stream_init()
293 err = vb2_queue_init(&s->vidq); in cx18_stream_init()
295 v4l2_err(&cx->v4l2_dev, "cannot init vb2 queue\n"); in cx18_stream_init()
296 s->video_dev.queue = &s->vidq; in cx18_stream_init()
301 static int cx18_prep_dev(struct cx18 *cx, int type) in cx18_prep_dev()
303 struct cx18_stream *s = &cx->streams[type]; in cx18_prep_dev()
304 u32 cap = cx->v4l2_cap; in cx18_prep_dev()
305 int num_offset = cx18_stream_info[type].num_offset; in cx18_prep_dev()
306 int num = cx->instance + cx18_first_minor + num_offset; in cx18_prep_dev()
307 int err; in cx18_prep_dev()
316 s->video_dev.v4l2_dev = NULL; in cx18_prep_dev()
317 s->dvb = NULL; in cx18_prep_dev()
318 s->cx = cx; in cx18_prep_dev()
319 s->type = type; in cx18_prep_dev()
320 s->name = cx18_stream_info[type].name; in cx18_prep_dev()
334 cx->stream_buffers[type] == 0) { in cx18_prep_dev()
345 if (cx->card->hw_all & CX18_HW_DVB) { in cx18_prep_dev()
346 s->dvb = kzalloc(sizeof(struct cx18_dvb), GFP_KERNEL); in cx18_prep_dev()
347 if (s->dvb == NULL) { in cx18_prep_dev()
349 s->name); in cx18_prep_dev()
350 return -ENOMEM; in cx18_prep_dev()
354 s->buffers = 0; in cx18_prep_dev()
358 if (num_offset == -1) in cx18_prep_dev()
362 snprintf(s->video_dev.name, sizeof(s->video_dev.name), "%s %s", in cx18_prep_dev()
363 cx->v4l2_dev.name, s->name); in cx18_prep_dev()
365 s->video_dev.num = num; in cx18_prep_dev()
366 s->video_dev.v4l2_dev = &cx->v4l2_dev; in cx18_prep_dev()
368 s->video_dev.fops = &cx18_v4l2_enc_yuv_fops; in cx18_prep_dev()
370 s->video_dev.fops = &cx18_v4l2_enc_fops; in cx18_prep_dev()
371 s->video_dev.release = video_device_release_empty; in cx18_prep_dev()
372 if (cx->card->video_inputs->video_type == CX18_CARD_INPUT_VID_TUNER) in cx18_prep_dev()
373 s->video_dev.tvnorms = cx->tuner_std; in cx18_prep_dev()
375 s->video_dev.tvnorms = V4L2_STD_ALL; in cx18_prep_dev()
376 s->video_dev.lock = &cx->serialize_lock; in cx18_prep_dev()
377 cx18_set_funcs(&s->video_dev); in cx18_prep_dev()
382 int cx18_streams_setup(struct cx18 *cx) in cx18_streams_setup()
384 int type, ret; in cx18_streams_setup()
394 ret = cx18_stream_alloc(&cx->streams[type]); in cx18_streams_setup()
406 static int cx18_reg_dev(struct cx18 *cx, int type) in cx18_reg_dev()
408 struct cx18_stream *s = &cx->streams[type]; in cx18_reg_dev()
409 int vfl_type = cx18_stream_info[type].vfl_type; in cx18_reg_dev()
411 int num, ret; in cx18_reg_dev()
413 if (type == CX18_ENC_STREAM_TYPE_TS && s->dvb != NULL) { in cx18_reg_dev()
421 if (s->video_dev.v4l2_dev == NULL) in cx18_reg_dev()
424 num = s->video_dev.num; in cx18_reg_dev()
425 s->video_dev.device_caps = s->v4l2_dev_caps; /* device capabilities */ in cx18_reg_dev()
428 struct cx18_stream *s_mpg = &cx->streams[CX18_ENC_STREAM_TYPE_MPG]; in cx18_reg_dev()
430 if (s_mpg->video_dev.v4l2_dev) in cx18_reg_dev()
431 num = s_mpg->video_dev.num in cx18_reg_dev()
434 video_set_drvdata(&s->video_dev, s); in cx18_reg_dev()
437 ret = video_register_device_no_warn(&s->video_dev, vfl_type, num); in cx18_reg_dev()
440 s->name, num); in cx18_reg_dev()
441 s->video_dev.v4l2_dev = NULL; in cx18_reg_dev()
445 name = video_device_node_name(&s->video_dev); in cx18_reg_dev()
450 name, s->name, cx->stream_buffers[type], in cx18_reg_dev()
451 cx->stream_buf_size[type] / 1024, in cx18_reg_dev()
452 (cx->stream_buf_size[type] * 100 / 1024) % 100); in cx18_reg_dev()
456 CX18_INFO("Registered device %s for %s\n", name, s->name); in cx18_reg_dev()
460 if (cx->stream_buffers[type]) in cx18_reg_dev()
462 name, s->name, cx->stream_buffers[type], in cx18_reg_dev()
463 cx->stream_buf_size[type]); in cx18_reg_dev()
466 name, s->name); in cx18_reg_dev()
474 int cx18_streams_register(struct cx18 *cx) in cx18_streams_register()
476 int type; in cx18_streams_register()
477 int err; in cx18_streams_register()
478 int ret = 0; in cx18_streams_register()
496 void cx18_streams_cleanup(struct cx18 *cx, int unregister) in cx18_streams_cleanup()
499 int type; in cx18_streams_cleanup()
506 if (cx->streams[type].dvb != NULL) { in cx18_streams_cleanup()
508 cx18_dvb_unregister(&cx->streams[type]); in cx18_streams_cleanup()
509 kfree(cx->streams[type].dvb); in cx18_streams_cleanup()
510 cx->streams[type].dvb = NULL; in cx18_streams_cleanup()
511 cx18_stream_free(&cx->streams[type]); in cx18_streams_cleanup()
518 /* If the module params didn't inhibit IDX ... */ in cx18_streams_cleanup()
519 if (cx->stream_buffers[type] != 0) { in cx18_streams_cleanup()
520 cx->stream_buffers[type] = 0; in cx18_streams_cleanup()
527 if (cx->streams[type].buffers != 0) in cx18_streams_cleanup()
528 cx18_stream_free(&cx->streams[type]); in cx18_streams_cleanup()
534 vdev = &cx->streams[type].video_dev; in cx18_streams_cleanup()
536 if (vdev->v4l2_dev == NULL) in cx18_streams_cleanup()
539 cx18_stream_free(&cx->streams[type]); in cx18_streams_cleanup()
550 struct cx18 *cx = s->cx; in cx18_vbi_setup()
551 int raw = cx18_raw_vbi(cx); in cx18_vbi_setup()
553 int lines; in cx18_vbi_setup()
555 if (cx->is_60hz) { in cx18_vbi_setup()
556 cx->vbi.count = 12; in cx18_vbi_setup()
557 cx->vbi.start[0] = 10; in cx18_vbi_setup()
558 cx->vbi.start[1] = 273; in cx18_vbi_setup()
560 cx->vbi.count = 18; in cx18_vbi_setup()
561 cx->vbi.start[0] = 6; in cx18_vbi_setup()
562 cx->vbi.start[1] = 318; in cx18_vbi_setup()
567 v4l2_subdev_call(cx->sd_av, vbi, s_raw_fmt, &cx->vbi.in.fmt.vbi); in cx18_vbi_setup()
569 v4l2_subdev_call(cx->sd_av, vbi, s_sliced_fmt, &cx->vbi.in.fmt.sliced); in cx18_vbi_setup()
580 lines = cx->vbi.count * 2; in cx18_vbi_setup()
583 * For 525/60 systems, according to the VIP 2 & BT.656 std: in cx18_vbi_setup()
586 * Tell the encoder to capture 21-4+1=18 lines per field, in cx18_vbi_setup()
589 * For 625/50 systems, according to the VIP 2 & BT.656 std: in cx18_vbi_setup()
593 * toggles on line 2.) Tell the encoder to capture 23-2+1=22 in cx18_vbi_setup()
596 lines = cx->is_60hz ? (21 - 4 + 1) * 2 : (23 - 2 + 1) * 2; in cx18_vbi_setup()
599 data[0] = s->handle; in cx18_vbi_setup()
604 : (cx->is_60hz ? VBI_HBLANK_SAMPLES_60HZ in cx18_vbi_setup()
611 * when in VIP-1.1 mode in cx18_vbi_setup()
660 struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_IDX]; in cx18_stream_rotate_idx_mdls()
667 if ((atomic_read(&s->q_free.depth) + atomic_read(&s->q_busy.depth)) >= in cx18_stream_rotate_idx_mdls()
672 if (atomic_read(&s->q_full.depth) < 2) in cx18_stream_rotate_idx_mdls()
679 mdl = cx18_dequeue(s, &s->q_full); in cx18_stream_rotate_idx_mdls()
681 cx18_enqueue(s, mdl, &s->q_free); in cx18_stream_rotate_idx_mdls()
688 struct cx18 *cx = s->cx; in _cx18_stream_put_mdl_fw()
692 if (s->handle == CX18_INVALID_TASK_HANDLE || in _cx18_stream_put_mdl_fw()
693 test_bit(CX18_F_S_STOPPING, &s->s_flags) || in _cx18_stream_put_mdl_fw()
694 !test_bit(CX18_F_S_STREAMING, &s->s_flags)) in _cx18_stream_put_mdl_fw()
695 return cx18_enqueue(s, mdl, &s->q_free); in _cx18_stream_put_mdl_fw()
697 q = cx18_enqueue(s, mdl, &s->q_busy); in _cx18_stream_put_mdl_fw()
698 if (q != &s->q_busy) in _cx18_stream_put_mdl_fw()
702 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, in _cx18_stream_put_mdl_fw()
703 (void __iomem *) &cx->scb->cpu_mdl[mdl->id] - cx->enc_mem, in _cx18_stream_put_mdl_fw()
704 s->bufs_per_mdl, mdl->id, s->mdl_size); in _cx18_stream_put_mdl_fw()
714 if (atomic_read(&s->q_free.depth) == 0 || in _cx18_stream_load_fw_queue()
715 atomic_read(&s->q_busy.depth) >= CX18_MAX_FW_MDLS_PER_STREAM) in _cx18_stream_load_fw_queue()
720 mdl = cx18_dequeue(s, &s->q_free); in _cx18_stream_load_fw_queue()
724 } while (atomic_read(&s->q_busy.depth) < CX18_MAX_FW_MDLS_PER_STREAM in _cx18_stream_load_fw_queue()
725 && q == &s->q_busy); in _cx18_stream_load_fw_queue()
740 switch (s->type) { in cx18_stream_configure_mdls()
747 if (s->pixelformat == V4L2_PIX_FMT_NV12_16L16) in cx18_stream_configure_mdls()
748 s->mdl_size = 720 * s->cx->cxhdl.height * 3 / 2; in cx18_stream_configure_mdls()
750 s->mdl_size = 720 * s->cx->cxhdl.height * 2; in cx18_stream_configure_mdls()
751 s->bufs_per_mdl = s->mdl_size / s->buf_size; in cx18_stream_configure_mdls()
752 if (s->mdl_size % s->buf_size) in cx18_stream_configure_mdls()
753 s->bufs_per_mdl++; in cx18_stream_configure_mdls()
756 s->bufs_per_mdl = 1; in cx18_stream_configure_mdls()
757 if (cx18_raw_vbi(s->cx)) { in cx18_stream_configure_mdls()
758 s->mdl_size = (s->cx->is_60hz ? 12 : 18) in cx18_stream_configure_mdls()
766 s->mdl_size = s->cx->is_60hz in cx18_stream_configure_mdls()
767 ? (21 - 4 + 1) * 2 * VBI_HBLANK_SAMPLES_60HZ in cx18_stream_configure_mdls()
768 : (23 - 2 + 1) * 2 * VBI_HBLANK_SAMPLES_50HZ; in cx18_stream_configure_mdls()
772 s->bufs_per_mdl = 1; in cx18_stream_configure_mdls()
773 s->mdl_size = s->buf_size * s->bufs_per_mdl; in cx18_stream_configure_mdls()
780 int cx18_start_v4l2_encode_stream(struct cx18_stream *s) in cx18_start_v4l2_encode_stream()
783 struct cx18 *cx = s->cx; in cx18_start_v4l2_encode_stream()
784 int captype = 0; in cx18_start_v4l2_encode_stream()
788 return -EINVAL; in cx18_start_v4l2_encode_stream()
790 CX18_DEBUG_INFO("Start encoder stream %s\n", s->name); in cx18_start_v4l2_encode_stream()
792 switch (s->type) { in cx18_start_v4l2_encode_stream()
795 cx->mpg_data_received = cx->vbi_data_inserted = 0; in cx18_start_v4l2_encode_stream()
796 cx->dualwatch_jiffies = jiffies; in cx18_start_v4l2_encode_stream()
797 cx->dualwatch_stereo_mode = v4l2_ctrl_g_ctrl(cx->cxhdl.audio_mode); in cx18_start_v4l2_encode_stream()
798 cx->search_pack_header = 0; in cx18_start_v4l2_encode_stream()
824 cx->vbi.frame = 0; in cx18_start_v4l2_encode_stream()
825 cx->vbi.inserted_frame = 0; in cx18_start_v4l2_encode_stream()
826 memset(cx->vbi.sliced_mpeg_size, in cx18_start_v4l2_encode_stream()
827 0, sizeof(cx->vbi.sliced_mpeg_size)); in cx18_start_v4l2_encode_stream()
830 return -EINVAL; in cx18_start_v4l2_encode_stream()
834 clear_bit(CX18_F_S_STREAMOFF, &s->s_flags); in cx18_start_v4l2_encode_stream()
837 s->handle = data[0]; in cx18_start_v4l2_encode_stream()
838 cx18_vapi(cx, CX18_CPU_SET_CHANNEL_TYPE, 2, s->handle, captype); in cx18_start_v4l2_encode_stream()
852 cx18_vapi(cx, CX18_CPU_SET_VER_CROP_LINE, 2, s->handle, 0); in cx18_start_v4l2_encode_stream()
853 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 3, 1); in cx18_start_v4l2_encode_stream()
854 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 8, 0); in cx18_start_v4l2_encode_stream()
855 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 4, 1); in cx18_start_v4l2_encode_stream()
859 * Documentation/driver-api/media/drivers/cx2341x-devel.rst in cx18_start_v4l2_encode_stream()
861 if (atomic_read(&cx->ana_capturing) == 0) in cx18_start_v4l2_encode_stream()
863 s->handle, 12); in cx18_start_v4l2_encode_stream()
867 * Documentation/driver-api/media/drivers/cx2341x-devel.rst in cx18_start_v4l2_encode_stream()
868 * Field 1 is 312 for 625 line systems in BT.656 in cx18_start_v4l2_encode_stream()
869 * Field 2 is 313 for 625 line systems in BT.656 in cx18_start_v4l2_encode_stream()
872 s->handle, 312, 313); in cx18_start_v4l2_encode_stream()
874 if (cx->v4l2_cap & V4L2_CAP_VBI_CAPTURE) in cx18_start_v4l2_encode_stream()
882 s_idx = &cx->streams[CX18_ENC_STREAM_TYPE_IDX]; in cx18_start_v4l2_encode_stream()
884 s->handle, cx18_stream_enabled(s_idx) ? 7 : 0); in cx18_start_v4l2_encode_stream()
887 cx->cxhdl.priv = s; in cx18_start_v4l2_encode_stream()
888 cx2341x_handler_setup(&cx->cxhdl); in cx18_start_v4l2_encode_stream()
894 if (!cx->cxhdl.video_mute && in cx18_start_v4l2_encode_stream()
895 test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) in cx18_start_v4l2_encode_stream()
896 cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, s->handle, in cx18_start_v4l2_encode_stream()
897 (v4l2_ctrl_g_ctrl(cx->cxhdl.video_mute_yuv) << 8) | 1); in cx18_start_v4l2_encode_stream()
903 if (s->pixelformat == V4L2_PIX_FMT_UYVY) in cx18_start_v4l2_encode_stream()
905 s->handle, 1); in cx18_start_v4l2_encode_stream()
909 s->handle, 0); in cx18_start_v4l2_encode_stream()
913 if (atomic_read(&cx->tot_capturing) == 0) { in cx18_start_v4l2_encode_stream()
914 cx2341x_handler_set_busy(&cx->cxhdl, 1); in cx18_start_v4l2_encode_stream()
915 clear_bit(CX18_F_I_EOS, &cx->i_flags); in cx18_start_v4l2_encode_stream()
919 cx18_vapi(cx, CX18_CPU_DE_SET_MDL_ACK, 3, s->handle, in cx18_start_v4l2_encode_stream()
920 (void __iomem *)&cx->scb->cpu_mdl_ack[s->type][0] - cx->enc_mem, in cx18_start_v4l2_encode_stream()
921 (void __iomem *)&cx->scb->cpu_mdl_ack[s->type][1] - cx->enc_mem); in cx18_start_v4l2_encode_stream()
928 if (cx18_vapi(cx, CX18_CPU_CAPTURE_START, 1, s->handle)) { in cx18_start_v4l2_encode_stream()
931 set_bit(CX18_F_S_STOPPING, &s->s_flags); in cx18_start_v4l2_encode_stream()
932 if (s->type == CX18_ENC_STREAM_TYPE_MPG) in cx18_start_v4l2_encode_stream()
933 cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 2, s->handle, 1); in cx18_start_v4l2_encode_stream()
935 cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 1, s->handle); in cx18_start_v4l2_encode_stream()
936 clear_bit(CX18_F_S_STREAMING, &s->s_flags); in cx18_start_v4l2_encode_stream()
937 /* FIXME - CX18_F_S_STREAMOFF as well? */ in cx18_start_v4l2_encode_stream()
938 cx18_vapi(cx, CX18_CPU_DE_RELEASE_MDL, 1, s->handle); in cx18_start_v4l2_encode_stream()
939 cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle); in cx18_start_v4l2_encode_stream()
940 s->handle = CX18_INVALID_TASK_HANDLE; in cx18_start_v4l2_encode_stream()
941 clear_bit(CX18_F_S_STOPPING, &s->s_flags); in cx18_start_v4l2_encode_stream()
942 if (atomic_read(&cx->tot_capturing) == 0) { in cx18_start_v4l2_encode_stream()
943 set_bit(CX18_F_I_EOS, &cx->i_flags); in cx18_start_v4l2_encode_stream()
946 return -EINVAL; in cx18_start_v4l2_encode_stream()
951 atomic_inc(&cx->ana_capturing); in cx18_start_v4l2_encode_stream()
952 atomic_inc(&cx->tot_capturing); in cx18_start_v4l2_encode_stream()
959 int i; in cx18_stop_all_captures()
961 for (i = CX18_MAX_STREAMS - 1; i >= 0; i--) { in cx18_stop_all_captures()
962 struct cx18_stream *s = &cx->streams[i]; in cx18_stop_all_captures()
966 if (test_bit(CX18_F_S_STREAMING, &s->s_flags)) in cx18_stop_all_captures()
971 int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end) in cx18_stop_v4l2_encode_stream()
973 struct cx18 *cx = s->cx; in cx18_stop_v4l2_encode_stream()
976 return -EINVAL; in cx18_stop_v4l2_encode_stream()
983 if (atomic_read(&cx->tot_capturing) == 0) in cx18_stop_v4l2_encode_stream()
986 set_bit(CX18_F_S_STOPPING, &s->s_flags); in cx18_stop_v4l2_encode_stream()
987 if (s->type == CX18_ENC_STREAM_TYPE_MPG) in cx18_stop_v4l2_encode_stream()
988 cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 2, s->handle, !gop_end); in cx18_stop_v4l2_encode_stream()
990 cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 1, s->handle); in cx18_stop_v4l2_encode_stream()
992 if (s->type == CX18_ENC_STREAM_TYPE_MPG && gop_end) { in cx18_stop_v4l2_encode_stream()
996 if (s->type != CX18_ENC_STREAM_TYPE_TS) in cx18_stop_v4l2_encode_stream()
997 atomic_dec(&cx->ana_capturing); in cx18_stop_v4l2_encode_stream()
998 atomic_dec(&cx->tot_capturing); in cx18_stop_v4l2_encode_stream()
1000 /* Clear capture and no-read bits */ in cx18_stop_v4l2_encode_stream()
1001 clear_bit(CX18_F_S_STREAMING, &s->s_flags); in cx18_stop_v4l2_encode_stream()
1004 cx18_vapi(cx, CX18_CPU_DE_RELEASE_MDL, 1, s->handle); in cx18_stop_v4l2_encode_stream()
1006 cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle); in cx18_stop_v4l2_encode_stream()
1007 s->handle = CX18_INVALID_TASK_HANDLE; in cx18_stop_v4l2_encode_stream()
1008 clear_bit(CX18_F_S_STOPPING, &s->s_flags); in cx18_stop_v4l2_encode_stream()
1010 if (atomic_read(&cx->tot_capturing) > 0) in cx18_stop_v4l2_encode_stream()
1013 cx2341x_handler_set_busy(&cx->cxhdl, 0); in cx18_stop_v4l2_encode_stream()
1015 wake_up(&s->waitq); in cx18_stop_v4l2_encode_stream()
1023 int i; in cx18_find_handle()
1027 struct cx18_stream *s = &cx->streams[i]; in cx18_find_handle()
1029 if (s->video_dev.v4l2_dev && (s->handle != CX18_INVALID_TASK_HANDLE)) in cx18_find_handle()
1030 return s->handle; in cx18_find_handle()
1037 int i; in cx18_handle_to_stream()
1044 s = &cx->streams[i]; in cx18_handle_to_stream()
1045 if (s->handle != handle) in cx18_handle_to_stream()