2 * Driver for the NXP SAA7164 PCIe bridge
4 * Copyright (c) 2010-2015 Steven Toth <stoth@kernellabs.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
20 /* Take the encoder configuration from the port struct and
21 * flush it to the hardware.
23 static void saa7164_vbi_configure(struct saa7164_port
*port
)
25 struct saa7164_dev
*dev
= port
->dev
;
26 dprintk(DBGLVL_VBI
, "%s()\n", __func__
);
28 port
->vbi_params
.width
= port
->enc_port
->width
;
29 port
->vbi_params
.height
= port
->enc_port
->height
;
30 port
->vbi_params
.is_50hz
=
31 (port
->enc_port
->encodernorm
.id
& V4L2_STD_625_50
) != 0;
33 /* Set up the DIF (enable it) for analog mode by default */
34 saa7164_api_initialize_dif(port
);
35 dprintk(DBGLVL_VBI
, "%s() ends\n", __func__
);
38 static int saa7164_vbi_buffers_dealloc(struct saa7164_port
*port
)
40 struct list_head
*c
, *n
, *p
, *q
, *l
, *v
;
41 struct saa7164_dev
*dev
= port
->dev
;
42 struct saa7164_buffer
*buf
;
43 struct saa7164_user_buffer
*ubuf
;
45 /* Remove any allocated buffers */
46 mutex_lock(&port
->dmaqueue_lock
);
48 dprintk(DBGLVL_VBI
, "%s(port=%d) dmaqueue\n", __func__
, port
->nr
);
49 list_for_each_safe(c
, n
, &port
->dmaqueue
.list
) {
50 buf
= list_entry(c
, struct saa7164_buffer
, list
);
52 saa7164_buffer_dealloc(buf
);
55 dprintk(DBGLVL_VBI
, "%s(port=%d) used\n", __func__
, port
->nr
);
56 list_for_each_safe(p
, q
, &port
->list_buf_used
.list
) {
57 ubuf
= list_entry(p
, struct saa7164_user_buffer
, list
);
59 saa7164_buffer_dealloc_user(ubuf
);
62 dprintk(DBGLVL_VBI
, "%s(port=%d) free\n", __func__
, port
->nr
);
63 list_for_each_safe(l
, v
, &port
->list_buf_free
.list
) {
64 ubuf
= list_entry(l
, struct saa7164_user_buffer
, list
);
66 saa7164_buffer_dealloc_user(ubuf
);
69 mutex_unlock(&port
->dmaqueue_lock
);
70 dprintk(DBGLVL_VBI
, "%s(port=%d) done\n", __func__
, port
->nr
);
75 /* Dynamic buffer switch at vbi start time */
76 static int saa7164_vbi_buffers_alloc(struct saa7164_port
*port
)
78 struct saa7164_dev
*dev
= port
->dev
;
79 struct saa7164_buffer
*buf
;
80 struct saa7164_user_buffer
*ubuf
;
81 struct tmHWStreamParameters
*params
= &port
->hw_streamingparams
;
82 int result
= -ENODEV
, i
;
85 dprintk(DBGLVL_VBI
, "%s()\n", __func__
);
87 /* TODO: NTSC SPECIFIC */
88 /* Init and establish defaults */
89 params
->samplesperline
= 1440;
90 params
->numberoflines
= 12;
91 params
->numberoflines
= 18;
94 params
->numpagetables
= 2 +
95 ((params
->numberoflines
* params
->pitch
) / PAGE_SIZE
);
96 params
->bitspersample
= 8;
97 params
->linethreshold
= 0;
98 params
->pagetablelistvirt
= NULL
;
99 params
->pagetablelistphys
= NULL
;
100 params
->numpagetableentries
= port
->hwcfg
.buffercount
;
102 /* Allocate the PCI resources, buffers (hard) */
103 for (i
= 0; i
< port
->hwcfg
.buffercount
; i
++) {
104 buf
= saa7164_buffer_alloc(port
,
105 params
->numberoflines
*
109 printk(KERN_ERR
"%s() failed (errno = %d), unable to allocate buffer\n",
115 mutex_lock(&port
->dmaqueue_lock
);
116 list_add_tail(&buf
->list
, &port
->dmaqueue
.list
);
117 mutex_unlock(&port
->dmaqueue_lock
);
122 /* Allocate some kernel buffers for copying
125 len
= params
->numberoflines
* params
->pitch
;
127 if (vbi_buffers
< 16)
129 if (vbi_buffers
> 512)
132 for (i
= 0; i
< vbi_buffers
; i
++) {
134 ubuf
= saa7164_buffer_alloc_user(dev
, len
);
136 mutex_lock(&port
->dmaqueue_lock
);
137 list_add_tail(&ubuf
->list
, &port
->list_buf_free
.list
);
138 mutex_unlock(&port
->dmaqueue_lock
);
150 static int saa7164_vbi_initialize(struct saa7164_port
*port
)
152 saa7164_vbi_configure(port
);
156 /* -- V4L2 --------------------------------------------------------- */
157 static int vidioc_s_std(struct file
*file
, void *priv
, v4l2_std_id id
)
159 struct saa7164_vbi_fh
*fh
= file
->private_data
;
161 return saa7164_s_std(fh
->port
->enc_port
, id
);
164 static int vidioc_g_std(struct file
*file
, void *priv
, v4l2_std_id
*id
)
166 struct saa7164_encoder_fh
*fh
= file
->private_data
;
168 return saa7164_g_std(fh
->port
->enc_port
, id
);
171 static int vidioc_g_input(struct file
*file
, void *priv
, unsigned int *i
)
173 struct saa7164_vbi_fh
*fh
= file
->private_data
;
175 return saa7164_g_input(fh
->port
->enc_port
, i
);
178 static int vidioc_s_input(struct file
*file
, void *priv
, unsigned int i
)
180 struct saa7164_vbi_fh
*fh
= file
->private_data
;
182 return saa7164_s_input(fh
->port
->enc_port
, i
);
185 static int vidioc_g_frequency(struct file
*file
, void *priv
,
186 struct v4l2_frequency
*f
)
188 struct saa7164_vbi_fh
*fh
= file
->private_data
;
190 return saa7164_g_frequency(fh
->port
->enc_port
, f
);
193 static int vidioc_s_frequency(struct file
*file
, void *priv
,
194 const struct v4l2_frequency
*f
)
196 struct saa7164_vbi_fh
*fh
= file
->private_data
;
197 int ret
= saa7164_s_frequency(fh
->port
->enc_port
, f
);
200 saa7164_vbi_initialize(fh
->port
);
204 static int vidioc_querycap(struct file
*file
, void *priv
,
205 struct v4l2_capability
*cap
)
207 struct saa7164_vbi_fh
*fh
= file
->private_data
;
208 struct saa7164_port
*port
= fh
->port
;
209 struct saa7164_dev
*dev
= port
->dev
;
211 strcpy(cap
->driver
, dev
->name
);
212 strlcpy(cap
->card
, saa7164_boards
[dev
->board
].name
,
214 sprintf(cap
->bus_info
, "PCI:%s", pci_name(dev
->pci
));
217 V4L2_CAP_VBI_CAPTURE
|
221 cap
->capabilities
= cap
->device_caps
|
222 V4L2_CAP_VIDEO_CAPTURE
|
223 V4L2_CAP_DEVICE_CAPS
;
228 static int saa7164_vbi_stop_port(struct saa7164_port
*port
)
230 struct saa7164_dev
*dev
= port
->dev
;
233 ret
= saa7164_api_transition_port(port
, SAA_DMASTATE_STOP
);
234 if ((ret
!= SAA_OK
) && (ret
!= SAA_ERR_ALREADY_STOPPED
)) {
235 printk(KERN_ERR
"%s() stop transition failed, ret = 0x%x\n",
239 dprintk(DBGLVL_VBI
, "%s() Stopped\n", __func__
);
246 static int saa7164_vbi_acquire_port(struct saa7164_port
*port
)
248 struct saa7164_dev
*dev
= port
->dev
;
251 ret
= saa7164_api_transition_port(port
, SAA_DMASTATE_ACQUIRE
);
252 if ((ret
!= SAA_OK
) && (ret
!= SAA_ERR_ALREADY_STOPPED
)) {
253 printk(KERN_ERR
"%s() acquire transition failed, ret = 0x%x\n",
257 dprintk(DBGLVL_VBI
, "%s() Acquired\n", __func__
);
264 static int saa7164_vbi_pause_port(struct saa7164_port
*port
)
266 struct saa7164_dev
*dev
= port
->dev
;
269 ret
= saa7164_api_transition_port(port
, SAA_DMASTATE_PAUSE
);
270 if ((ret
!= SAA_OK
) && (ret
!= SAA_ERR_ALREADY_STOPPED
)) {
271 printk(KERN_ERR
"%s() pause transition failed, ret = 0x%x\n",
275 dprintk(DBGLVL_VBI
, "%s() Paused\n", __func__
);
282 /* Firmware is very windows centric, meaning you have to transition
283 * the part through AVStream / KS Windows stages, forwards or backwards.
284 * States are: stopped, acquired (h/w), paused, started.
285 * We have to leave here will all of the soft buffers on the free list,
286 * else the cfg_post() func won't have soft buffers to correctly configure.
288 static int saa7164_vbi_stop_streaming(struct saa7164_port
*port
)
290 struct saa7164_dev
*dev
= port
->dev
;
291 struct saa7164_buffer
*buf
;
292 struct saa7164_user_buffer
*ubuf
;
293 struct list_head
*c
, *n
;
296 dprintk(DBGLVL_VBI
, "%s(port=%d)\n", __func__
, port
->nr
);
298 ret
= saa7164_vbi_pause_port(port
);
299 ret
= saa7164_vbi_acquire_port(port
);
300 ret
= saa7164_vbi_stop_port(port
);
302 dprintk(DBGLVL_VBI
, "%s(port=%d) Hardware stopped\n", __func__
,
305 /* Reset the state of any allocated buffer resources */
306 mutex_lock(&port
->dmaqueue_lock
);
308 /* Reset the hard and soft buffer state */
309 list_for_each_safe(c
, n
, &port
->dmaqueue
.list
) {
310 buf
= list_entry(c
, struct saa7164_buffer
, list
);
311 buf
->flags
= SAA7164_BUFFER_FREE
;
315 list_for_each_safe(c
, n
, &port
->list_buf_used
.list
) {
316 ubuf
= list_entry(c
, struct saa7164_user_buffer
, list
);
318 list_move_tail(&ubuf
->list
, &port
->list_buf_free
.list
);
321 mutex_unlock(&port
->dmaqueue_lock
);
323 /* Free any allocated resources */
324 saa7164_vbi_buffers_dealloc(port
);
326 dprintk(DBGLVL_VBI
, "%s(port=%d) Released\n", __func__
, port
->nr
);
331 static int saa7164_vbi_start_streaming(struct saa7164_port
*port
)
333 struct saa7164_dev
*dev
= port
->dev
;
336 dprintk(DBGLVL_VBI
, "%s(port=%d)\n", __func__
, port
->nr
);
338 port
->done_first_interrupt
= 0;
340 /* allocate all of the PCIe DMA buffer resources on the fly,
341 * allowing switching between TS and PS payloads without
342 * requiring a complete driver reload.
344 saa7164_vbi_buffers_alloc(port
);
346 /* Configure the encoder with any cache values */
348 saa7164_api_set_encoder(port
);
349 saa7164_api_get_encoder(port
);
352 /* Place the empty buffers on the hardware */
353 saa7164_buffer_cfg_port(port
);
355 /* Negotiate format */
356 if (saa7164_api_set_vbi_format(port
) != SAA_OK
) {
357 printk(KERN_ERR
"%s() No supported VBI format\n", __func__
);
362 /* Acquire the hardware */
363 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_ACQUIRE
);
364 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
365 printk(KERN_ERR
"%s() acquire transition failed, res = 0x%x\n",
371 dprintk(DBGLVL_VBI
, "%s() Acquired\n", __func__
);
373 /* Pause the hardware */
374 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_PAUSE
);
375 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
376 printk(KERN_ERR
"%s() pause transition failed, res = 0x%x\n",
379 /* Stop the hardware, regardless */
380 result
= saa7164_vbi_stop_port(port
);
381 if (result
!= SAA_OK
) {
382 printk(KERN_ERR
"%s() pause/forced stop transition failed, res = 0x%x\n",
389 dprintk(DBGLVL_VBI
, "%s() Paused\n", __func__
);
391 /* Start the hardware */
392 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_RUN
);
393 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
394 printk(KERN_ERR
"%s() run transition failed, result = 0x%x\n",
397 /* Stop the hardware, regardless */
398 result
= saa7164_vbi_acquire_port(port
);
399 result
= saa7164_vbi_stop_port(port
);
400 if (result
!= SAA_OK
) {
401 printk(KERN_ERR
"%s() run/forced stop transition failed, res = 0x%x\n",
407 dprintk(DBGLVL_VBI
, "%s() Running\n", __func__
);
413 static int saa7164_vbi_fmt(struct file
*file
, void *priv
,
414 struct v4l2_format
*f
)
417 f
->fmt
.vbi
.samples_per_line
= 1440;
418 f
->fmt
.vbi
.sampling_rate
= 27000000;
419 f
->fmt
.vbi
.sample_format
= V4L2_PIX_FMT_GREY
;
420 f
->fmt
.vbi
.offset
= 0;
421 f
->fmt
.vbi
.flags
= 0;
422 f
->fmt
.vbi
.start
[0] = 10;
423 f
->fmt
.vbi
.count
[0] = 18;
424 f
->fmt
.vbi
.start
[1] = 263 + 10 + 1;
425 f
->fmt
.vbi
.count
[1] = 18;
426 memset(f
->fmt
.vbi
.reserved
, 0, sizeof(f
->fmt
.vbi
.reserved
));
430 static int fops_open(struct file
*file
)
432 struct saa7164_dev
*dev
;
433 struct saa7164_port
*port
;
434 struct saa7164_vbi_fh
*fh
;
436 port
= (struct saa7164_port
*)video_get_drvdata(video_devdata(file
));
442 dprintk(DBGLVL_VBI
, "%s()\n", __func__
);
444 /* allocate + initialize per filehandle data */
445 fh
= kzalloc(sizeof(*fh
), GFP_KERNEL
);
450 v4l2_fh_init(&fh
->fh
, video_devdata(file
));
451 v4l2_fh_add(&fh
->fh
);
452 file
->private_data
= fh
;
457 static int fops_release(struct file
*file
)
459 struct saa7164_vbi_fh
*fh
= file
->private_data
;
460 struct saa7164_port
*port
= fh
->port
;
461 struct saa7164_dev
*dev
= port
->dev
;
463 dprintk(DBGLVL_VBI
, "%s()\n", __func__
);
465 /* Shut device down on last close */
466 if (atomic_cmpxchg(&fh
->v4l_reading
, 1, 0) == 1) {
467 if (atomic_dec_return(&port
->v4l_reader_count
) == 0) {
468 /* stop vbi capture then cancel buffers */
469 saa7164_vbi_stop_streaming(port
);
473 v4l2_fh_del(&fh
->fh
);
474 v4l2_fh_exit(&fh
->fh
);
481 saa7164_user_buffer
*saa7164_vbi_next_buf(struct saa7164_port
*port
)
483 struct saa7164_user_buffer
*ubuf
= NULL
;
484 struct saa7164_dev
*dev
= port
->dev
;
487 mutex_lock(&port
->dmaqueue_lock
);
488 if (!list_empty(&port
->list_buf_used
.list
)) {
489 ubuf
= list_first_entry(&port
->list_buf_used
.list
,
490 struct saa7164_user_buffer
, list
);
493 crc
= crc32(0, ubuf
->data
, ubuf
->actual_size
);
494 if (crc
!= ubuf
->crc
) {
495 printk(KERN_ERR
"%s() ubuf %p crc became invalid, was 0x%x became 0x%x\n",
497 ubuf
, ubuf
->crc
, crc
);
502 mutex_unlock(&port
->dmaqueue_lock
);
504 dprintk(DBGLVL_VBI
, "%s() returns %p\n", __func__
, ubuf
);
509 static ssize_t
fops_read(struct file
*file
, char __user
*buffer
,
510 size_t count
, loff_t
*pos
)
512 struct saa7164_vbi_fh
*fh
= file
->private_data
;
513 struct saa7164_port
*port
= fh
->port
;
514 struct saa7164_user_buffer
*ubuf
= NULL
;
515 struct saa7164_dev
*dev
= port
->dev
;
520 port
->last_read_msecs_diff
= port
->last_read_msecs
;
521 port
->last_read_msecs
= jiffies_to_msecs(jiffies
);
522 port
->last_read_msecs_diff
= port
->last_read_msecs
-
523 port
->last_read_msecs_diff
;
525 saa7164_histogram_update(&port
->read_interval
,
526 port
->last_read_msecs_diff
);
529 printk(KERN_ERR
"%s() ESPIPE\n", __func__
);
533 if (atomic_cmpxchg(&fh
->v4l_reading
, 0, 1) == 0) {
534 if (atomic_inc_return(&port
->v4l_reader_count
) == 1) {
536 if (saa7164_vbi_initialize(port
) < 0) {
537 printk(KERN_ERR
"%s() EINVAL\n", __func__
);
541 saa7164_vbi_start_streaming(port
);
546 /* blocking wait for buffer */
547 if ((file
->f_flags
& O_NONBLOCK
) == 0) {
548 if (wait_event_interruptible(port
->wait_read
,
549 saa7164_vbi_next_buf(port
))) {
550 printk(KERN_ERR
"%s() ERESTARTSYS\n", __func__
);
555 /* Pull the first buffer from the used list */
556 ubuf
= saa7164_vbi_next_buf(port
);
558 while ((count
> 0) && ubuf
) {
560 /* set remaining bytes to copy */
561 rem
= ubuf
->actual_size
- ubuf
->pos
;
562 cnt
= rem
> count
? count
: rem
;
564 p
= ubuf
->data
+ ubuf
->pos
;
567 "%s() count=%d cnt=%d rem=%d buf=%p buf->pos=%d\n",
568 __func__
, (int)count
, cnt
, rem
, ubuf
, ubuf
->pos
);
570 if (copy_to_user(buffer
, p
, cnt
)) {
571 printk(KERN_ERR
"%s() copy_to_user failed\n", __func__
);
573 printk(KERN_ERR
"%s() EFAULT\n", __func__
);
584 if (ubuf
->pos
> ubuf
->actual_size
)
585 printk(KERN_ERR
"read() pos > actual, huh?\n");
587 if (ubuf
->pos
== ubuf
->actual_size
) {
589 /* finished with current buffer, take next buffer */
591 /* Requeue the buffer on the free list */
594 mutex_lock(&port
->dmaqueue_lock
);
595 list_move_tail(&ubuf
->list
, &port
->list_buf_free
.list
);
596 mutex_unlock(&port
->dmaqueue_lock
);
599 if ((file
->f_flags
& O_NONBLOCK
) == 0) {
600 if (wait_event_interruptible(port
->wait_read
,
601 saa7164_vbi_next_buf(port
))) {
605 ubuf
= saa7164_vbi_next_buf(port
);
610 printk(KERN_ERR
"%s() EAGAIN\n", __func__
);
617 static __poll_t
fops_poll(struct file
*file
, poll_table
*wait
)
619 struct saa7164_vbi_fh
*fh
= (struct saa7164_vbi_fh
*)file
->private_data
;
620 struct saa7164_port
*port
= fh
->port
;
623 port
->last_poll_msecs_diff
= port
->last_poll_msecs
;
624 port
->last_poll_msecs
= jiffies_to_msecs(jiffies
);
625 port
->last_poll_msecs_diff
= port
->last_poll_msecs
-
626 port
->last_poll_msecs_diff
;
628 saa7164_histogram_update(&port
->poll_interval
,
629 port
->last_poll_msecs_diff
);
631 if (!video_is_registered(port
->v4l_device
))
634 if (atomic_cmpxchg(&fh
->v4l_reading
, 0, 1) == 0) {
635 if (atomic_inc_return(&port
->v4l_reader_count
) == 1) {
636 if (saa7164_vbi_initialize(port
) < 0)
638 saa7164_vbi_start_streaming(port
);
643 /* blocking wait for buffer */
644 if ((file
->f_flags
& O_NONBLOCK
) == 0) {
645 if (wait_event_interruptible(port
->wait_read
,
646 saa7164_vbi_next_buf(port
))) {
651 /* Pull the first buffer from the used list */
652 if (!list_empty(&port
->list_buf_used
.list
))
653 mask
|= EPOLLIN
| EPOLLRDNORM
;
657 static const struct v4l2_file_operations vbi_fops
= {
658 .owner
= THIS_MODULE
,
660 .release
= fops_release
,
663 .unlocked_ioctl
= video_ioctl2
,
666 static const struct v4l2_ioctl_ops vbi_ioctl_ops
= {
667 .vidioc_s_std
= vidioc_s_std
,
668 .vidioc_g_std
= vidioc_g_std
,
669 .vidioc_enum_input
= saa7164_enum_input
,
670 .vidioc_g_input
= vidioc_g_input
,
671 .vidioc_s_input
= vidioc_s_input
,
672 .vidioc_g_tuner
= saa7164_g_tuner
,
673 .vidioc_s_tuner
= saa7164_s_tuner
,
674 .vidioc_g_frequency
= vidioc_g_frequency
,
675 .vidioc_s_frequency
= vidioc_s_frequency
,
676 .vidioc_querycap
= vidioc_querycap
,
677 .vidioc_g_fmt_vbi_cap
= saa7164_vbi_fmt
,
678 .vidioc_try_fmt_vbi_cap
= saa7164_vbi_fmt
,
679 .vidioc_s_fmt_vbi_cap
= saa7164_vbi_fmt
,
682 static struct video_device saa7164_vbi_template
= {
685 .ioctl_ops
= &vbi_ioctl_ops
,
687 .tvnorms
= SAA7164_NORMS
,
690 static struct video_device
*saa7164_vbi_alloc(
691 struct saa7164_port
*port
,
693 struct video_device
*template,
696 struct video_device
*vfd
;
697 struct saa7164_dev
*dev
= port
->dev
;
699 dprintk(DBGLVL_VBI
, "%s()\n", __func__
);
701 vfd
= video_device_alloc();
706 snprintf(vfd
->name
, sizeof(vfd
->name
), "%s %s (%s)", dev
->name
,
707 type
, saa7164_boards
[dev
->board
].name
);
709 vfd
->v4l2_dev
= &dev
->v4l2_dev
;
710 vfd
->release
= video_device_release
;
714 int saa7164_vbi_register(struct saa7164_port
*port
)
716 struct saa7164_dev
*dev
= port
->dev
;
717 int result
= -ENODEV
;
719 dprintk(DBGLVL_VBI
, "%s()\n", __func__
);
721 if (port
->type
!= SAA7164_MPEG_VBI
)
724 /* Sanity check that the PCI configuration space is active */
725 if (port
->hwcfg
.BARLocation
== 0) {
726 printk(KERN_ERR
"%s() failed (errno = %d), NO PCI configuration\n",
732 /* Establish VBI defaults here */
734 /* Allocate and register the video device node */
735 port
->v4l_device
= saa7164_vbi_alloc(port
,
736 dev
->pci
, &saa7164_vbi_template
, "vbi");
738 if (!port
->v4l_device
) {
739 printk(KERN_INFO
"%s: can't allocate vbi device\n",
745 port
->enc_port
= &dev
->ports
[port
->nr
- 2];
746 video_set_drvdata(port
->v4l_device
, port
);
747 result
= video_register_device(port
->v4l_device
,
750 printk(KERN_INFO
"%s: can't register vbi device\n",
752 /* TODO: We're going to leak here if we don't dealloc
753 The buffers above. The unreg function can't deal wit it.
758 printk(KERN_INFO
"%s: registered device vbi%d [vbi]\n",
759 dev
->name
, port
->v4l_device
->num
);
761 /* Configure the hardware defaults */
768 void saa7164_vbi_unregister(struct saa7164_port
*port
)
770 struct saa7164_dev
*dev
= port
->dev
;
772 dprintk(DBGLVL_VBI
, "%s(port=%d)\n", __func__
, port
->nr
);
774 if (port
->type
!= SAA7164_MPEG_VBI
)
777 if (port
->v4l_device
) {
778 if (port
->v4l_device
->minor
!= -1)
779 video_unregister_device(port
->v4l_device
);
781 video_device_release(port
->v4l_device
);
783 port
->v4l_device
= NULL
;