Lines Matching +full:656 +full:- +full:4
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"
58 VFL_TYPE_VIDEO, -1,
83 VFL_TYPE_VIDEO, -1,
98 videobuf_waiton(q, &buf->vb, 0, 0); in cx18_dma_free()
99 videobuf_vmalloc_free(&buf->vb); in cx18_dma_free()
100 buf->vb.state = VIDEOBUF_NEEDS_INIT; in cx18_dma_free()
110 struct cx18 *cx = s->cx; in cx18_prepare_buffer()
114 buf->bytes_used = 0; in cx18_prepare_buffer()
117 return -EINVAL; in cx18_prepare_buffer()
119 buf->vb.size = (width * height * 2); in cx18_prepare_buffer()
120 if ((buf->vb.baddr != 0) && (buf->vb.bsize < buf->vb.size)) in cx18_prepare_buffer()
121 return -EINVAL; in cx18_prepare_buffer()
124 if (buf->vb.width != width || buf->vb.height != height || in cx18_prepare_buffer()
125 buf->vb.field != field || s->pixelformat != pixelformat || in cx18_prepare_buffer()
126 buf->tvnorm != cx->std) { in cx18_prepare_buffer()
128 buf->vb.width = width; in cx18_prepare_buffer()
129 buf->vb.height = height; in cx18_prepare_buffer()
130 buf->vb.field = field; in cx18_prepare_buffer()
131 buf->tvnorm = cx->std; in cx18_prepare_buffer()
132 s->pixelformat = pixelformat; in cx18_prepare_buffer()
136 if (s->pixelformat == V4L2_PIX_FMT_NV12_16L16) in cx18_prepare_buffer()
137 s->vb_bytes_per_frame = height * 720 * 3 / 2; in cx18_prepare_buffer()
139 s->vb_bytes_per_frame = height * 720 * 2; in cx18_prepare_buffer()
143 if ((buf->vb.baddr != 0) && (buf->vb.bsize < buf->vb.size)) in cx18_prepare_buffer()
144 return -EINVAL; in cx18_prepare_buffer()
146 if (buf->vb.field == 0) in cx18_prepare_buffer()
147 buf->vb.field = V4L2_FIELD_INTERLACED; in cx18_prepare_buffer()
149 if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { in cx18_prepare_buffer()
150 buf->vb.width = width; in cx18_prepare_buffer()
151 buf->vb.height = height; in cx18_prepare_buffer()
152 buf->vb.field = field; in cx18_prepare_buffer()
153 buf->tvnorm = cx->std; in cx18_prepare_buffer()
154 s->pixelformat = pixelformat; in cx18_prepare_buffer()
158 if (s->pixelformat == V4L2_PIX_FMT_NV12_16L16) in cx18_prepare_buffer()
159 s->vb_bytes_per_frame = height * 720 * 3 / 2; in cx18_prepare_buffer()
161 s->vb_bytes_per_frame = height * 720 * 2; in cx18_prepare_buffer()
162 rc = videobuf_iolock(q, &buf->vb, NULL); in cx18_prepare_buffer()
166 buf->vb.state = VIDEOBUF_PREPARED; in cx18_prepare_buffer()
176 1440 is a single line of 4:2:2 YUV at 720 luma samples wide
184 struct cx18_stream *s = q->priv_data; in buffer_setup()
185 struct cx18 *cx = s->cx; in buffer_setup()
187 *size = 2 * cx->cxhdl.width * cx->cxhdl.height; in buffer_setup()
192 (*count)--; in buffer_setup()
194 q->field = V4L2_FIELD_INTERLACED; in buffer_setup()
195 q->last = V4L2_FIELD_INTERLACED; in buffer_setup()
206 struct cx18_stream *s = q->priv_data; in buffer_prepare()
207 struct cx18 *cx = s->cx; in buffer_prepare()
209 return cx18_prepare_buffer(q, s, buf, s->pixelformat, in buffer_prepare()
210 cx->cxhdl.width, cx->cxhdl.height, field); in buffer_prepare()
218 struct cx18_stream *s = q->priv_data; in buffer_release()
227 struct cx18_stream *s = q->priv_data; in buffer_queue()
229 buf->vb.state = VIDEOBUF_QUEUED; in buffer_queue()
231 list_add_tail(&buf->vb.queue, &s->vb_capture); in buffer_queue()
243 struct cx18_stream *s = &cx->streams[type]; in cx18_stream_init()
248 s->dvb = NULL; in cx18_stream_init()
249 s->cx = cx; in cx18_stream_init()
250 s->type = type; in cx18_stream_init()
251 s->name = cx18_stream_info[type].name; in cx18_stream_init()
252 s->handle = CX18_INVALID_TASK_HANDLE; in cx18_stream_init()
254 s->dma = cx18_stream_info[type].dma; in cx18_stream_init()
255 s->v4l2_dev_caps = cx18_stream_info[type].caps; in cx18_stream_init()
256 s->buffers = cx->stream_buffers[type]; in cx18_stream_init()
257 s->buf_size = cx->stream_buf_size[type]; in cx18_stream_init()
258 INIT_LIST_HEAD(&s->buf_pool); in cx18_stream_init()
259 s->bufs_per_mdl = 1; in cx18_stream_init()
260 s->mdl_size = s->buf_size * s->bufs_per_mdl; in cx18_stream_init()
262 init_waitqueue_head(&s->waitq); in cx18_stream_init()
263 s->id = -1; in cx18_stream_init()
264 spin_lock_init(&s->q_free.lock); in cx18_stream_init()
265 cx18_queue_init(&s->q_free); in cx18_stream_init()
266 spin_lock_init(&s->q_busy.lock); in cx18_stream_init()
267 cx18_queue_init(&s->q_busy); in cx18_stream_init()
268 spin_lock_init(&s->q_full.lock); in cx18_stream_init()
269 cx18_queue_init(&s->q_full); in cx18_stream_init()
270 spin_lock_init(&s->q_idle.lock); in cx18_stream_init()
271 cx18_queue_init(&s->q_idle); in cx18_stream_init()
273 INIT_WORK(&s->out_work_order, cx18_out_work_handler); in cx18_stream_init()
275 INIT_LIST_HEAD(&s->vb_capture); in cx18_stream_init()
276 timer_setup(&s->vb_timeout, cx18_vb_timeout, 0); in cx18_stream_init()
277 spin_lock_init(&s->vb_lock); in cx18_stream_init()
279 spin_lock_init(&s->vbuf_q_lock); in cx18_stream_init()
281 s->vb_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in cx18_stream_init()
282 videobuf_queue_vmalloc_init(&s->vbuf_q, &cx18_videobuf_qops, in cx18_stream_init()
283 &cx->pci_dev->dev, &s->vbuf_q_lock, in cx18_stream_init()
287 s, &cx->serialize_lock); in cx18_stream_init()
290 s->pixelformat = V4L2_PIX_FMT_NV12_16L16; in cx18_stream_init()
291 s->vb_bytes_per_frame = cx->cxhdl.height * 720 * 3 / 2; in cx18_stream_init()
292 s->vb_bytes_per_line = 720; in cx18_stream_init()
298 struct cx18_stream *s = &cx->streams[type]; in cx18_prep_dev()
299 u32 cap = cx->v4l2_cap; in cx18_prep_dev()
301 int num = cx->instance + cx18_first_minor + num_offset; in cx18_prep_dev()
310 s->video_dev.v4l2_dev = NULL; in cx18_prep_dev()
311 s->dvb = NULL; in cx18_prep_dev()
312 s->cx = cx; in cx18_prep_dev()
313 s->type = type; in cx18_prep_dev()
314 s->name = cx18_stream_info[type].name; in cx18_prep_dev()
328 cx->stream_buffers[type] == 0) { in cx18_prep_dev()
337 if (cx->card->hw_all & CX18_HW_DVB) { in cx18_prep_dev()
338 s->dvb = kzalloc(sizeof(struct cx18_dvb), GFP_KERNEL); in cx18_prep_dev()
339 if (s->dvb == NULL) { in cx18_prep_dev()
341 s->name); in cx18_prep_dev()
342 return -ENOMEM; in cx18_prep_dev()
346 s->buffers = 0; in cx18_prep_dev()
350 if (num_offset == -1) in cx18_prep_dev()
354 snprintf(s->video_dev.name, sizeof(s->video_dev.name), "%s %s", in cx18_prep_dev()
355 cx->v4l2_dev.name, s->name); in cx18_prep_dev()
357 s->video_dev.num = num; in cx18_prep_dev()
358 s->video_dev.v4l2_dev = &cx->v4l2_dev; in cx18_prep_dev()
359 s->video_dev.fops = &cx18_v4l2_enc_fops; in cx18_prep_dev()
360 s->video_dev.release = video_device_release_empty; in cx18_prep_dev()
361 if (cx->card->video_inputs->video_type == CX18_CARD_INPUT_VID_TUNER) in cx18_prep_dev()
362 s->video_dev.tvnorms = cx->tuner_std; in cx18_prep_dev()
364 s->video_dev.tvnorms = V4L2_STD_ALL; in cx18_prep_dev()
365 s->video_dev.lock = &cx->serialize_lock; in cx18_prep_dev()
366 cx18_set_funcs(&s->video_dev); in cx18_prep_dev()
383 ret = cx18_stream_alloc(&cx->streams[type]); in cx18_streams_setup()
397 struct cx18_stream *s = &cx->streams[type]; in cx18_reg_dev()
402 if (type == CX18_ENC_STREAM_TYPE_TS && s->dvb != NULL) { in cx18_reg_dev()
410 if (s->video_dev.v4l2_dev == NULL) in cx18_reg_dev()
413 num = s->video_dev.num; in cx18_reg_dev()
414 s->video_dev.device_caps = s->v4l2_dev_caps; /* device capabilities */ in cx18_reg_dev()
417 struct cx18_stream *s_mpg = &cx->streams[CX18_ENC_STREAM_TYPE_MPG]; in cx18_reg_dev()
419 if (s_mpg->video_dev.v4l2_dev) in cx18_reg_dev()
420 num = s_mpg->video_dev.num in cx18_reg_dev()
423 video_set_drvdata(&s->video_dev, s); in cx18_reg_dev()
426 ret = video_register_device_no_warn(&s->video_dev, vfl_type, num); in cx18_reg_dev()
429 s->name, num); in cx18_reg_dev()
430 s->video_dev.v4l2_dev = NULL; in cx18_reg_dev()
434 name = video_device_node_name(&s->video_dev); in cx18_reg_dev()
439 name, s->name, cx->stream_buffers[type], in cx18_reg_dev()
440 cx->stream_buf_size[type] / 1024, in cx18_reg_dev()
441 (cx->stream_buf_size[type] * 100 / 1024) % 100); in cx18_reg_dev()
445 CX18_INFO("Registered device %s for %s\n", name, s->name); in cx18_reg_dev()
449 if (cx->stream_buffers[type]) in cx18_reg_dev()
451 name, s->name, cx->stream_buffers[type], in cx18_reg_dev()
452 cx->stream_buf_size[type]); in cx18_reg_dev()
455 name, s->name); in cx18_reg_dev()
495 if (cx->streams[type].dvb != NULL) { in cx18_streams_cleanup()
497 cx18_dvb_unregister(&cx->streams[type]); in cx18_streams_cleanup()
498 kfree(cx->streams[type].dvb); in cx18_streams_cleanup()
499 cx->streams[type].dvb = NULL; in cx18_streams_cleanup()
500 cx18_stream_free(&cx->streams[type]); in cx18_streams_cleanup()
508 if (cx->stream_buffers[type] != 0) { in cx18_streams_cleanup()
509 cx->stream_buffers[type] = 0; in cx18_streams_cleanup()
516 if (cx->streams[type].buffers != 0) in cx18_streams_cleanup()
517 cx18_stream_free(&cx->streams[type]); in cx18_streams_cleanup()
523 vdev = &cx->streams[type].video_dev; in cx18_streams_cleanup()
525 if (vdev->v4l2_dev == NULL) in cx18_streams_cleanup()
529 videobuf_mmap_free(&cx->streams[type].vbuf_q); in cx18_streams_cleanup()
531 cx18_stream_free(&cx->streams[type]); in cx18_streams_cleanup()
539 struct cx18 *cx = s->cx; in cx18_vbi_setup()
544 if (cx->is_60hz) { in cx18_vbi_setup()
545 cx->vbi.count = 12; in cx18_vbi_setup()
546 cx->vbi.start[0] = 10; in cx18_vbi_setup()
547 cx->vbi.start[1] = 273; in cx18_vbi_setup()
549 cx->vbi.count = 18; in cx18_vbi_setup()
550 cx->vbi.start[0] = 6; in cx18_vbi_setup()
551 cx->vbi.start[1] = 318; in cx18_vbi_setup()
556 v4l2_subdev_call(cx->sd_av, vbi, s_raw_fmt, &cx->vbi.in.fmt.vbi); in cx18_vbi_setup()
558 v4l2_subdev_call(cx->sd_av, vbi, s_sliced_fmt, &cx->vbi.in.fmt.sliced); in cx18_vbi_setup()
569 lines = cx->vbi.count * 2; in cx18_vbi_setup()
572 * For 525/60 systems, according to the VIP 2 & BT.656 std: in cx18_vbi_setup()
573 * The EAV RP code's Field bit toggles on line 4, a few lines in cx18_vbi_setup()
575 * Tell the encoder to capture 21-4+1=18 lines per field, in cx18_vbi_setup()
578 * For 625/50 systems, according to the VIP 2 & BT.656 std: in cx18_vbi_setup()
582 * toggles on line 2.) Tell the encoder to capture 23-2+1=22 in cx18_vbi_setup()
585 lines = cx->is_60hz ? (21 - 4 + 1) * 2 : (23 - 2 + 1) * 2; in cx18_vbi_setup()
588 data[0] = s->handle; in cx18_vbi_setup()
593 : (cx->is_60hz ? VBI_HBLANK_SAMPLES_60HZ in cx18_vbi_setup()
600 * when in VIP-1.1 mode in cx18_vbi_setup()
608 data[4] = 0x20602060; in cx18_vbi_setup()
632 data[4] = 0xB0F0B0F0; in cx18_vbi_setup()
642 data[0], data[1], data[2], data[3], data[4], data[5]); in cx18_vbi_setup()
649 struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_IDX]; in cx18_stream_rotate_idx_mdls()
656 if ((atomic_read(&s->q_free.depth) + atomic_read(&s->q_busy.depth)) >= in cx18_stream_rotate_idx_mdls()
661 if (atomic_read(&s->q_full.depth) < 2) in cx18_stream_rotate_idx_mdls()
668 mdl = cx18_dequeue(s, &s->q_full); in cx18_stream_rotate_idx_mdls()
670 cx18_enqueue(s, mdl, &s->q_free); in cx18_stream_rotate_idx_mdls()
677 struct cx18 *cx = s->cx; in _cx18_stream_put_mdl_fw()
681 if (s->handle == CX18_INVALID_TASK_HANDLE || in _cx18_stream_put_mdl_fw()
682 test_bit(CX18_F_S_STOPPING, &s->s_flags) || in _cx18_stream_put_mdl_fw()
683 !test_bit(CX18_F_S_STREAMING, &s->s_flags)) in _cx18_stream_put_mdl_fw()
684 return cx18_enqueue(s, mdl, &s->q_free); in _cx18_stream_put_mdl_fw()
686 q = cx18_enqueue(s, mdl, &s->q_busy); in _cx18_stream_put_mdl_fw()
687 if (q != &s->q_busy) in _cx18_stream_put_mdl_fw()
691 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, in _cx18_stream_put_mdl_fw()
692 (void __iomem *) &cx->scb->cpu_mdl[mdl->id] - cx->enc_mem, in _cx18_stream_put_mdl_fw()
693 s->bufs_per_mdl, mdl->id, s->mdl_size); in _cx18_stream_put_mdl_fw()
703 if (atomic_read(&s->q_free.depth) == 0 || in _cx18_stream_load_fw_queue()
704 atomic_read(&s->q_busy.depth) >= CX18_MAX_FW_MDLS_PER_STREAM) in _cx18_stream_load_fw_queue()
709 mdl = cx18_dequeue(s, &s->q_free); in _cx18_stream_load_fw_queue()
713 } while (atomic_read(&s->q_busy.depth) < CX18_MAX_FW_MDLS_PER_STREAM in _cx18_stream_load_fw_queue()
714 && q == &s->q_busy); in _cx18_stream_load_fw_queue()
729 switch (s->type) { in cx18_stream_configure_mdls()
736 if (s->pixelformat == V4L2_PIX_FMT_NV12_16L16) in cx18_stream_configure_mdls()
737 s->mdl_size = 720 * s->cx->cxhdl.height * 3 / 2; in cx18_stream_configure_mdls()
739 s->mdl_size = 720 * s->cx->cxhdl.height * 2; in cx18_stream_configure_mdls()
740 s->bufs_per_mdl = s->mdl_size / s->buf_size; in cx18_stream_configure_mdls()
741 if (s->mdl_size % s->buf_size) in cx18_stream_configure_mdls()
742 s->bufs_per_mdl++; in cx18_stream_configure_mdls()
745 s->bufs_per_mdl = 1; in cx18_stream_configure_mdls()
746 if (cx18_raw_vbi(s->cx)) { in cx18_stream_configure_mdls()
747 s->mdl_size = (s->cx->is_60hz ? 12 : 18) in cx18_stream_configure_mdls()
755 s->mdl_size = s->cx->is_60hz in cx18_stream_configure_mdls()
756 ? (21 - 4 + 1) * 2 * VBI_HBLANK_SAMPLES_60HZ in cx18_stream_configure_mdls()
757 : (23 - 2 + 1) * 2 * VBI_HBLANK_SAMPLES_50HZ; in cx18_stream_configure_mdls()
761 s->bufs_per_mdl = 1; in cx18_stream_configure_mdls()
762 s->mdl_size = s->buf_size * s->bufs_per_mdl; in cx18_stream_configure_mdls()
772 struct cx18 *cx = s->cx; in cx18_start_v4l2_encode_stream()
777 return -EINVAL; in cx18_start_v4l2_encode_stream()
779 CX18_DEBUG_INFO("Start encoder stream %s\n", s->name); in cx18_start_v4l2_encode_stream()
781 switch (s->type) { in cx18_start_v4l2_encode_stream()
784 cx->mpg_data_received = cx->vbi_data_inserted = 0; in cx18_start_v4l2_encode_stream()
785 cx->dualwatch_jiffies = jiffies; in cx18_start_v4l2_encode_stream()
786 cx->dualwatch_stereo_mode = v4l2_ctrl_g_ctrl(cx->cxhdl.audio_mode); in cx18_start_v4l2_encode_stream()
787 cx->search_pack_header = 0; in cx18_start_v4l2_encode_stream()
813 cx->vbi.frame = 0; in cx18_start_v4l2_encode_stream()
814 cx->vbi.inserted_frame = 0; in cx18_start_v4l2_encode_stream()
815 memset(cx->vbi.sliced_mpeg_size, in cx18_start_v4l2_encode_stream()
816 0, sizeof(cx->vbi.sliced_mpeg_size)); in cx18_start_v4l2_encode_stream()
819 return -EINVAL; in cx18_start_v4l2_encode_stream()
823 clear_bit(CX18_F_S_STREAMOFF, &s->s_flags); in cx18_start_v4l2_encode_stream()
826 s->handle = data[0]; in cx18_start_v4l2_encode_stream()
827 cx18_vapi(cx, CX18_CPU_SET_CHANNEL_TYPE, 2, s->handle, captype); in cx18_start_v4l2_encode_stream()
841 cx18_vapi(cx, CX18_CPU_SET_VER_CROP_LINE, 2, s->handle, 0); in cx18_start_v4l2_encode_stream()
842 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 3, 1); in cx18_start_v4l2_encode_stream()
843 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 8, 0); in cx18_start_v4l2_encode_stream()
844 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 4, 1); in cx18_start_v4l2_encode_stream()
848 * Documentation/driver-api/media/drivers/cx2341x-devel.rst in cx18_start_v4l2_encode_stream()
850 if (atomic_read(&cx->ana_capturing) == 0) in cx18_start_v4l2_encode_stream()
852 s->handle, 12); in cx18_start_v4l2_encode_stream()
856 * Documentation/driver-api/media/drivers/cx2341x-devel.rst in cx18_start_v4l2_encode_stream()
857 * Field 1 is 312 for 625 line systems in BT.656 in cx18_start_v4l2_encode_stream()
858 * Field 2 is 313 for 625 line systems in BT.656 in cx18_start_v4l2_encode_stream()
861 s->handle, 312, 313); in cx18_start_v4l2_encode_stream()
863 if (cx->v4l2_cap & V4L2_CAP_VBI_CAPTURE) in cx18_start_v4l2_encode_stream()
871 s_idx = &cx->streams[CX18_ENC_STREAM_TYPE_IDX]; in cx18_start_v4l2_encode_stream()
873 s->handle, cx18_stream_enabled(s_idx) ? 7 : 0); in cx18_start_v4l2_encode_stream()
876 cx->cxhdl.priv = s; in cx18_start_v4l2_encode_stream()
877 cx2341x_handler_setup(&cx->cxhdl); in cx18_start_v4l2_encode_stream()
883 if (!cx->cxhdl.video_mute && in cx18_start_v4l2_encode_stream()
884 test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) in cx18_start_v4l2_encode_stream()
885 cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, s->handle, in cx18_start_v4l2_encode_stream()
886 (v4l2_ctrl_g_ctrl(cx->cxhdl.video_mute_yuv) << 8) | 1); in cx18_start_v4l2_encode_stream()
888 /* Enable the Video Format Converter for UYVY 4:2:2 support, in cx18_start_v4l2_encode_stream()
889 * rather than the default HM12 Macroblovk 4:2:0 support. in cx18_start_v4l2_encode_stream()
892 if (s->pixelformat == V4L2_PIX_FMT_UYVY) in cx18_start_v4l2_encode_stream()
894 s->handle, 1); in cx18_start_v4l2_encode_stream()
898 s->handle, 0); in cx18_start_v4l2_encode_stream()
902 if (atomic_read(&cx->tot_capturing) == 0) { in cx18_start_v4l2_encode_stream()
903 cx2341x_handler_set_busy(&cx->cxhdl, 1); in cx18_start_v4l2_encode_stream()
904 clear_bit(CX18_F_I_EOS, &cx->i_flags); in cx18_start_v4l2_encode_stream()
908 cx18_vapi(cx, CX18_CPU_DE_SET_MDL_ACK, 3, s->handle, in cx18_start_v4l2_encode_stream()
909 (void __iomem *)&cx->scb->cpu_mdl_ack[s->type][0] - cx->enc_mem, in cx18_start_v4l2_encode_stream()
910 (void __iomem *)&cx->scb->cpu_mdl_ack[s->type][1] - cx->enc_mem); in cx18_start_v4l2_encode_stream()
917 if (cx18_vapi(cx, CX18_CPU_CAPTURE_START, 1, s->handle)) { in cx18_start_v4l2_encode_stream()
920 set_bit(CX18_F_S_STOPPING, &s->s_flags); in cx18_start_v4l2_encode_stream()
921 if (s->type == CX18_ENC_STREAM_TYPE_MPG) in cx18_start_v4l2_encode_stream()
922 cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 2, s->handle, 1); in cx18_start_v4l2_encode_stream()
924 cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 1, s->handle); in cx18_start_v4l2_encode_stream()
925 clear_bit(CX18_F_S_STREAMING, &s->s_flags); in cx18_start_v4l2_encode_stream()
926 /* FIXME - CX18_F_S_STREAMOFF as well? */ in cx18_start_v4l2_encode_stream()
927 cx18_vapi(cx, CX18_CPU_DE_RELEASE_MDL, 1, s->handle); in cx18_start_v4l2_encode_stream()
928 cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle); in cx18_start_v4l2_encode_stream()
929 s->handle = CX18_INVALID_TASK_HANDLE; in cx18_start_v4l2_encode_stream()
930 clear_bit(CX18_F_S_STOPPING, &s->s_flags); in cx18_start_v4l2_encode_stream()
931 if (atomic_read(&cx->tot_capturing) == 0) { in cx18_start_v4l2_encode_stream()
932 set_bit(CX18_F_I_EOS, &cx->i_flags); in cx18_start_v4l2_encode_stream()
935 return -EINVAL; in cx18_start_v4l2_encode_stream()
940 atomic_inc(&cx->ana_capturing); in cx18_start_v4l2_encode_stream()
941 atomic_inc(&cx->tot_capturing); in cx18_start_v4l2_encode_stream()
950 for (i = CX18_MAX_STREAMS - 1; i >= 0; i--) { in cx18_stop_all_captures()
951 struct cx18_stream *s = &cx->streams[i]; in cx18_stop_all_captures()
955 if (test_bit(CX18_F_S_STREAMING, &s->s_flags)) in cx18_stop_all_captures()
962 struct cx18 *cx = s->cx; in cx18_stop_v4l2_encode_stream()
965 return -EINVAL; in cx18_stop_v4l2_encode_stream()
972 if (atomic_read(&cx->tot_capturing) == 0) in cx18_stop_v4l2_encode_stream()
975 set_bit(CX18_F_S_STOPPING, &s->s_flags); in cx18_stop_v4l2_encode_stream()
976 if (s->type == CX18_ENC_STREAM_TYPE_MPG) in cx18_stop_v4l2_encode_stream()
977 cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 2, s->handle, !gop_end); in cx18_stop_v4l2_encode_stream()
979 cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 1, s->handle); in cx18_stop_v4l2_encode_stream()
981 if (s->type == CX18_ENC_STREAM_TYPE_MPG && gop_end) { in cx18_stop_v4l2_encode_stream()
985 if (s->type != CX18_ENC_STREAM_TYPE_TS) in cx18_stop_v4l2_encode_stream()
986 atomic_dec(&cx->ana_capturing); in cx18_stop_v4l2_encode_stream()
987 atomic_dec(&cx->tot_capturing); in cx18_stop_v4l2_encode_stream()
989 /* Clear capture and no-read bits */ in cx18_stop_v4l2_encode_stream()
990 clear_bit(CX18_F_S_STREAMING, &s->s_flags); in cx18_stop_v4l2_encode_stream()
993 cx18_vapi(cx, CX18_CPU_DE_RELEASE_MDL, 1, s->handle); in cx18_stop_v4l2_encode_stream()
995 cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle); in cx18_stop_v4l2_encode_stream()
996 s->handle = CX18_INVALID_TASK_HANDLE; in cx18_stop_v4l2_encode_stream()
997 clear_bit(CX18_F_S_STOPPING, &s->s_flags); in cx18_stop_v4l2_encode_stream()
999 if (atomic_read(&cx->tot_capturing) > 0) in cx18_stop_v4l2_encode_stream()
1002 cx2341x_handler_set_busy(&cx->cxhdl, 0); in cx18_stop_v4l2_encode_stream()
1004 wake_up(&s->waitq); in cx18_stop_v4l2_encode_stream()
1016 struct cx18_stream *s = &cx->streams[i]; in cx18_find_handle()
1018 if (s->video_dev.v4l2_dev && (s->handle != CX18_INVALID_TASK_HANDLE)) in cx18_find_handle()
1019 return s->handle; in cx18_find_handle()
1033 s = &cx->streams[i]; in cx18_handle_to_stream()
1034 if (s->handle != handle) in cx18_handle_to_stream()