Lines Matching +full:p +full:- +full:384

1 // SPDX-License-Identifier: GPL-2.0-only
4 #include <media/drv-intf/saa7146_vv.h>
12 struct saa7146_vv *vv = dev->vv_data; in saa7146_res_get()
14 if (vv->resources & bit) { in saa7146_res_get()
16 bit, vv->resources); in saa7146_res_get()
22 if (vv->resources & bit) { in saa7146_res_get()
23 DEB_D("locked! vv->resources:0x%02x, we want:0x%02x\n", in saa7146_res_get()
24 vv->resources, bit); in saa7146_res_get()
29 vv->resources |= bit; in saa7146_res_get()
30 DEB_D("res: get 0x%02x, cur:0x%02x\n", bit, vv->resources); in saa7146_res_get()
36 struct saa7146_vv *vv = dev->vv_data; in saa7146_res_free()
38 WARN_ON((vv->resources & bits) != bits); in saa7146_res_free()
40 vv->resources &= ~bits; in saa7146_res_free()
41 DEB_D("res: put 0x%02x, cur:0x%02x\n", bits, vv->resources); in saa7146_res_free()
52 assert_spin_locked(&dev->slock); in saa7146_buffer_queue()
53 DEB_EE("dev:%p, dmaq:%p, buf:%p\n", dev, q, buf); in saa7146_buffer_queue()
56 return -EIO; in saa7146_buffer_queue()
58 if (NULL == q->curr) { in saa7146_buffer_queue()
59 q->curr = buf; in saa7146_buffer_queue()
60 DEB_D("immediately activating buffer %p\n", buf); in saa7146_buffer_queue()
61 buf->activate(dev,buf,NULL); in saa7146_buffer_queue()
63 list_add_tail(&buf->list, &q->queue); in saa7146_buffer_queue()
64 DEB_D("adding buffer %p to queue. (active buffer present)\n", in saa7146_buffer_queue()
74 struct saa7146_vv *vv = dev->vv_data; in saa7146_buffer_finish()
75 struct saa7146_buf *buf = q->curr; in saa7146_buffer_finish()
77 assert_spin_locked(&dev->slock); in saa7146_buffer_finish()
78 DEB_EE("dev:%p, dmaq:%p, state:%d\n", dev, q, state); in saa7146_buffer_finish()
79 DEB_EE("q->curr:%p\n", q->curr); in saa7146_buffer_finish()
87 q->curr = NULL; in saa7146_buffer_finish()
88 buf->vb.vb2_buf.timestamp = ktime_get_ns(); in saa7146_buffer_finish()
89 if (vv->video_fmt.field == V4L2_FIELD_ALTERNATE) in saa7146_buffer_finish()
90 buf->vb.field = vv->last_field; in saa7146_buffer_finish()
91 else if (vv->video_fmt.field == V4L2_FIELD_ANY) in saa7146_buffer_finish()
92 buf->vb.field = (vv->video_fmt.height > vv->standard->v_max_out / 2) in saa7146_buffer_finish()
96 buf->vb.field = vv->video_fmt.field; in saa7146_buffer_finish()
97 buf->vb.sequence = vv->seqnr++; in saa7146_buffer_finish()
98 vb2_buffer_done(&buf->vb.vb2_buf, state); in saa7146_buffer_finish()
109 DEB_INT("dev:%p, dmaq:%p, vbi:%d\n", dev, q, vbi); in saa7146_buffer_next()
111 assert_spin_locked(&dev->slock); in saa7146_buffer_next()
112 if (!list_empty(&q->queue)) { in saa7146_buffer_next()
114 buf = list_entry(q->queue.next, struct saa7146_buf, list); in saa7146_buffer_next()
115 list_del(&buf->list); in saa7146_buffer_next()
116 if (!list_empty(&q->queue)) in saa7146_buffer_next()
117 next = list_entry(q->queue.next, struct saa7146_buf, list); in saa7146_buffer_next()
118 q->curr = buf; in saa7146_buffer_next()
119 DEB_INT("next buffer: buf:%p, prev:%p, next:%p\n", in saa7146_buffer_next()
120 buf, q->queue.prev, q->queue.next); in saa7146_buffer_next()
121 buf->activate(dev,buf,next); in saa7146_buffer_next()
125 /* turn off video-dma3 */ in saa7146_buffer_next()
128 /* nothing to do -- just prevent next video-dma1 transfer in saa7146_buffer_next()
136 /* write the address of the rps-program */ in saa7146_buffer_next()
137 saa7146_write(dev, RPS_ADDR0, dev->d_rps0.dma_handle); in saa7146_buffer_next()
150 del_timer(&q->timeout); in saa7146_buffer_next()
157 struct saa7146_dev *dev = q->dev; in saa7146_buffer_timeout()
160 DEB_EE("dev:%p, dmaq:%p\n", dev, q); in saa7146_buffer_timeout()
162 spin_lock_irqsave(&dev->slock,flags); in saa7146_buffer_timeout()
163 if (q->curr) { in saa7146_buffer_timeout()
164 DEB_D("timeout on %p\n", q->curr); in saa7146_buffer_timeout()
177 spin_unlock_irqrestore(&dev->slock,flags); in saa7146_buffer_timeout()
189 if (vdev->vfl_type != VFL_TYPE_VBI || !dev->ext_vv_data->vbi_fops.write) in fops_write()
190 return -EINVAL; in fops_write()
191 if (mutex_lock_interruptible(vdev->lock)) in fops_write()
192 return -ERESTARTSYS; in fops_write()
193 ret = dev->ext_vv_data->vbi_fops.write(file, data, count, ppos); in fops_write()
194 mutex_unlock(vdev->lock); in fops_write()
214 DEB_INT("dev:%p, isr:0x%08x\n", dev, (u32)status); in vv_callback()
225 wake_up(&dev->vv_data->vbi_wq); in vv_callback()
240 struct v4l2_ctrl_handler *hdl = &dev->ctrl_handler; in saa7146_vv_init()
246 err = v4l2_device_register(&dev->pci->dev, &dev->v4l2_dev); in saa7146_vv_init()
261 if (hdl->error) { in saa7146_vv_init()
262 err = hdl->error; in saa7146_vv_init()
264 v4l2_device_unregister(&dev->v4l2_dev); in saa7146_vv_init()
267 dev->v4l2_dev.ctrl_handler = hdl; in saa7146_vv_init()
273 v4l2_device_unregister(&dev->v4l2_dev); in saa7146_vv_init()
274 return -ENOMEM; in saa7146_vv_init()
276 ext_vv->vid_ops = saa7146_video_ioctl_ops; in saa7146_vv_init()
277 ext_vv->vbi_ops = saa7146_vbi_ioctl_ops; in saa7146_vv_init()
278 ext_vv->core_ops = &saa7146_video_ioctl_ops; in saa7146_vv_init()
280 DEB_EE("dev:%p\n", dev); in saa7146_vv_init()
285 /* enable video-port pins */ in saa7146_vv_init()
288 /* save per-device extension data (one extension can in saa7146_vv_init()
291 dev->ext_vv_data = ext_vv; in saa7146_vv_init()
294 if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) in saa7146_vv_init()
297 fmt = &vv->video_fmt; in saa7146_vv_init()
298 fmt->width = 384; in saa7146_vv_init()
299 fmt->height = 288; in saa7146_vv_init()
300 fmt->pixelformat = V4L2_PIX_FMT_BGR24; in saa7146_vv_init()
301 fmt->field = V4L2_FIELD_INTERLACED; in saa7146_vv_init()
302 fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; in saa7146_vv_init()
303 fmt->bytesperline = 3 * fmt->width; in saa7146_vv_init()
304 fmt->sizeimage = fmt->bytesperline * fmt->height; in saa7146_vv_init()
306 vbi = &vv->vbi_fmt; in saa7146_vv_init()
307 vbi->sampling_rate = 27000000; in saa7146_vv_init()
308 vbi->offset = 248; /* todo */ in saa7146_vv_init()
309 vbi->samples_per_line = 720 * 2; in saa7146_vv_init()
310 vbi->sample_format = V4L2_PIX_FMT_GREY; in saa7146_vv_init()
313 vbi->start[0] = 5; in saa7146_vv_init()
314 vbi->count[0] = 16; in saa7146_vv_init()
315 vbi->start[1] = 312; in saa7146_vv_init()
316 vbi->count[1] = 16; in saa7146_vv_init()
318 timer_setup(&vv->vbi_read_timeout, NULL, 0); in saa7146_vv_init()
320 dev->vv_data = vv; in saa7146_vv_init()
321 dev->vv_callback = &vv_callback; in saa7146_vv_init()
329 struct saa7146_vv *vv = dev->vv_data; in saa7146_vv_release()
331 DEB_EE("dev:%p\n", dev); in saa7146_vv_release()
333 v4l2_device_unregister(&dev->v4l2_dev); in saa7146_vv_release()
334 v4l2_ctrl_handler_free(&dev->ctrl_handler); in saa7146_vv_release()
336 dev->vv_data = NULL; in saa7146_vv_release()
337 dev->vv_callback = NULL; in saa7146_vv_release()
350 DEB_EE("dev:%p, name:'%s', type:%d\n", dev, name, type); in saa7146_register_device()
352 vfd->fops = &video_fops; in saa7146_register_device()
354 vfd->ioctl_ops = &dev->ext_vv_data->vid_ops; in saa7146_register_device()
355 q = &dev->vv_data->video_dmaq.q; in saa7146_register_device()
357 vfd->ioctl_ops = &dev->ext_vv_data->vbi_ops; in saa7146_register_device()
358 q = &dev->vv_data->vbi_dmaq.q; in saa7146_register_device()
360 vfd->release = video_device_release_empty; in saa7146_register_device()
361 vfd->lock = &dev->v4l2_lock; in saa7146_register_device()
362 vfd->v4l2_dev = &dev->v4l2_dev; in saa7146_register_device()
363 vfd->tvnorms = 0; in saa7146_register_device()
364 for (i = 0; i < dev->ext_vv_data->num_stds; i++) in saa7146_register_device()
365 vfd->tvnorms |= dev->ext_vv_data->stds[i].id; in saa7146_register_device()
366 strscpy(vfd->name, name, sizeof(vfd->name)); in saa7146_register_device()
367 vfd->device_caps = V4L2_CAP_VIDEO_CAPTURE | in saa7146_register_device()
369 vfd->device_caps |= dev->ext_vv_data->capabilities; in saa7146_register_device()
371 vfd->device_caps &= in saa7146_register_device()
373 } else if (vfd->device_caps & V4L2_CAP_SLICED_VBI_OUTPUT) { in saa7146_register_device()
374 vfd->vfl_dir = VFL_DIR_TX; in saa7146_register_device()
375 vfd->device_caps &= ~(V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | in saa7146_register_device()
378 vfd->device_caps &= ~V4L2_CAP_VIDEO_CAPTURE; in saa7146_register_device()
381 q->type = type == VFL_TYPE_VIDEO ? V4L2_BUF_TYPE_VIDEO_CAPTURE : V4L2_BUF_TYPE_VBI_CAPTURE; in saa7146_register_device()
382 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in saa7146_register_device()
383 q->io_modes = VB2_MMAP | VB2_READ | VB2_DMABUF; in saa7146_register_device()
384 q->ops = type == VFL_TYPE_VIDEO ? &video_qops : &vbi_qops; in saa7146_register_device()
385 q->mem_ops = &vb2_dma_sg_memops; in saa7146_register_device()
386 q->drv_priv = dev; in saa7146_register_device()
387 q->gfp_flags = __GFP_DMA32; in saa7146_register_device()
388 q->buf_struct_size = sizeof(struct saa7146_buf); in saa7146_register_device()
389 q->lock = &dev->v4l2_lock; in saa7146_register_device()
390 q->min_buffers_needed = 2; in saa7146_register_device()
391 q->dev = &dev->pci->dev; in saa7146_register_device()
395 vfd->queue = q; in saa7146_register_device()
399 err = video_register_device(vfd, type, -1); in saa7146_register_device()
406 dev->name, video_device_node_name(vfd)); in saa7146_register_device()
413 DEB_EE("dev:%p\n", dev); in saa7146_unregister_device()
434 MODULE_DESCRIPTION("video4linux driver for saa7146-based hardware");