hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/media/pci/saa7134/saa7134-video.c
....@@ -1,19 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 *
34 * device driver for philips saa7134 based TV cards
45 * video4linux video interface
56 *
67 * (c) 2001-03 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
178 */
189
1910 #include "saa7134.h"
....@@ -99,70 +90,58 @@
9990
10091 static struct saa7134_format formats[] = {
10192 {
102
- .name = "8 bpp gray",
10393 .fourcc = V4L2_PIX_FMT_GREY,
10494 .depth = 8,
10595 .pm = 0x06,
10696 },{
107
- .name = "15 bpp RGB, le",
10897 .fourcc = V4L2_PIX_FMT_RGB555,
10998 .depth = 16,
11099 .pm = 0x13 | 0x80,
111100 },{
112
- .name = "15 bpp RGB, be",
113101 .fourcc = V4L2_PIX_FMT_RGB555X,
114102 .depth = 16,
115103 .pm = 0x13 | 0x80,
116104 .bswap = 1,
117105 },{
118
- .name = "16 bpp RGB, le",
119106 .fourcc = V4L2_PIX_FMT_RGB565,
120107 .depth = 16,
121108 .pm = 0x10 | 0x80,
122109 },{
123
- .name = "16 bpp RGB, be",
124110 .fourcc = V4L2_PIX_FMT_RGB565X,
125111 .depth = 16,
126112 .pm = 0x10 | 0x80,
127113 .bswap = 1,
128114 },{
129
- .name = "24 bpp RGB, le",
130115 .fourcc = V4L2_PIX_FMT_BGR24,
131116 .depth = 24,
132117 .pm = 0x11,
133118 },{
134
- .name = "24 bpp RGB, be",
135119 .fourcc = V4L2_PIX_FMT_RGB24,
136120 .depth = 24,
137121 .pm = 0x11,
138122 .bswap = 1,
139123 },{
140
- .name = "32 bpp RGB, le",
141124 .fourcc = V4L2_PIX_FMT_BGR32,
142125 .depth = 32,
143126 .pm = 0x12,
144127 },{
145
- .name = "32 bpp RGB, be",
146128 .fourcc = V4L2_PIX_FMT_RGB32,
147129 .depth = 32,
148130 .pm = 0x12,
149131 .bswap = 1,
150132 .wswap = 1,
151133 },{
152
- .name = "4:2:2 packed, YUYV",
153134 .fourcc = V4L2_PIX_FMT_YUYV,
154135 .depth = 16,
155136 .pm = 0x00,
156137 .bswap = 1,
157138 .yuv = 1,
158139 },{
159
- .name = "4:2:2 packed, UYVY",
160140 .fourcc = V4L2_PIX_FMT_UYVY,
161141 .depth = 16,
162142 .pm = 0x00,
163143 .yuv = 1,
164144 },{
165
- .name = "4:2:2 planar, Y-Cb-Cr",
166145 .fourcc = V4L2_PIX_FMT_YUV422P,
167146 .depth = 16,
168147 .pm = 0x09,
....@@ -171,7 +150,6 @@
171150 .hshift = 1,
172151 .vshift = 0,
173152 },{
174
- .name = "4:2:0 planar, Y-Cb-Cr",
175153 .fourcc = V4L2_PIX_FMT_YUV420,
176154 .depth = 12,
177155 .pm = 0x0a,
....@@ -180,7 +158,6 @@
180158 .hshift = 1,
181159 .vshift = 1,
182160 },{
183
- .name = "4:2:0 planar, Y-Cb-Cr",
184161 .fourcc = V4L2_PIX_FMT_YVU420,
185162 .depth = 12,
186163 .pm = 0x0a,
....@@ -729,10 +706,10 @@
729706 return err;
730707
731708 dev->ovfield = dev->win.field;
732
- video_dbg("start_preview %dx%d+%d+%d %s field=%s\n",
733
- dev->win.w.width, dev->win.w.height,
734
- dev->win.w.left, dev->win.w.top,
735
- dev->ovfmt->name, v4l2_field_names[dev->ovfield]);
709
+ video_dbg("%s %dx%d+%d+%d 0x%08x field=%s\n", __func__,
710
+ dev->win.w.width, dev->win.w.height,
711
+ dev->win.w.left, dev->win.w.top,
712
+ dev->ovfmt->fourcc, v4l2_field_names[dev->ovfield]);
736713
737714 /* setup window + clipping */
738715 set_size(dev, TASK_B, dev->win.w.width, dev->win.w.height,
....@@ -1031,8 +1008,7 @@
10311008 */
10321009 if ((dmaq == &dev->video_q && !vb2_is_streaming(&dev->vbi_vbq)) ||
10331010 (dmaq == &dev->vbi_q && !vb2_is_streaming(&dev->video_vbq)))
1034
- pm_qos_add_request(&dev->qos_request,
1035
- PM_QOS_CPU_DMA_LATENCY, 20);
1011
+ cpu_latency_qos_add_request(&dev->qos_request, 20);
10361012 dmaq->seq_nr = 0;
10371013
10381014 return 0;
....@@ -1047,7 +1023,7 @@
10471023
10481024 if ((dmaq == &dev->video_q && !vb2_is_streaming(&dev->vbi_vbq)) ||
10491025 (dmaq == &dev->vbi_q && !vb2_is_streaming(&dev->video_vbq)))
1050
- pm_qos_remove_request(&dev->qos_request);
1026
+ cpu_latency_qos_remove_request(&dev->qos_request);
10511027 }
10521028
10531029 static const struct vb2_ops vb2_qops = {
....@@ -1445,7 +1421,8 @@
14451421 if (card_in(dev, i->index).type == SAA7134_NO_INPUT)
14461422 return -EINVAL;
14471423 i->index = n;
1448
- strcpy(i->name, saa7134_input_name[card_in(dev, n).type]);
1424
+ strscpy(i->name, saa7134_input_name[card_in(dev, n).type],
1425
+ sizeof(i->name));
14491426 switch (card_in(dev, n).type) {
14501427 case SAA7134_INPUT_TV:
14511428 case SAA7134_INPUT_TV_MONO:
....@@ -1497,50 +1474,20 @@
14971474 struct v4l2_capability *cap)
14981475 {
14991476 struct saa7134_dev *dev = video_drvdata(file);
1500
- struct video_device *vdev = video_devdata(file);
1501
- u32 radio_caps, video_caps, vbi_caps;
15021477
1503
- unsigned int tuner_type = dev->tuner_type;
1504
-
1505
- strcpy(cap->driver, "saa7134");
1506
- strlcpy(cap->card, saa7134_boards[dev->board].name,
1478
+ strscpy(cap->driver, "saa7134", sizeof(cap->driver));
1479
+ strscpy(cap->card, saa7134_boards[dev->board].name,
15071480 sizeof(cap->card));
15081481 sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
1509
-
1510
- cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
1511
- if ((tuner_type != TUNER_ABSENT) && (tuner_type != UNSET))
1512
- cap->device_caps |= V4L2_CAP_TUNER;
1513
-
1514
- radio_caps = V4L2_CAP_RADIO;
1482
+ cap->capabilities = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
1483
+ V4L2_CAP_RADIO | V4L2_CAP_VIDEO_CAPTURE |
1484
+ V4L2_CAP_VBI_CAPTURE | V4L2_CAP_DEVICE_CAPS;
1485
+ if (dev->tuner_type != TUNER_ABSENT && dev->tuner_type != UNSET)
1486
+ cap->capabilities |= V4L2_CAP_TUNER;
15151487 if (dev->has_rds)
1516
- radio_caps |= V4L2_CAP_RDS_CAPTURE;
1517
-
1518
- video_caps = V4L2_CAP_VIDEO_CAPTURE;
1519
- if (saa7134_no_overlay <= 0 && !is_empress(file))
1520
- video_caps |= V4L2_CAP_VIDEO_OVERLAY;
1521
-
1522
- vbi_caps = V4L2_CAP_VBI_CAPTURE;
1523
-
1524
- switch (vdev->vfl_type) {
1525
- case VFL_TYPE_RADIO:
1526
- cap->device_caps |= radio_caps;
1527
- break;
1528
- case VFL_TYPE_GRABBER:
1529
- cap->device_caps |= video_caps;
1530
- break;
1531
- case VFL_TYPE_VBI:
1532
- cap->device_caps |= vbi_caps;
1533
- break;
1534
- default:
1535
- return -EINVAL;
1536
- }
1537
- cap->capabilities = radio_caps | video_caps | vbi_caps |
1538
- cap->device_caps | V4L2_CAP_DEVICE_CAPS;
1539
- if (vdev->vfl_type == VFL_TYPE_RADIO) {
1540
- cap->device_caps &= ~V4L2_CAP_STREAMING;
1541
- if (!dev->has_rds)
1542
- cap->device_caps &= ~V4L2_CAP_READWRITE;
1543
- }
1488
+ cap->capabilities |= V4L2_CAP_RDS_CAPTURE;
1489
+ if (saa7134_no_overlay <= 0)
1490
+ cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY;
15441491
15451492 return 0;
15461493 }
....@@ -1649,23 +1596,22 @@
16491596 }
16501597 EXPORT_SYMBOL_GPL(saa7134_querystd);
16511598
1652
-static int saa7134_cropcap(struct file *file, void *priv,
1653
- struct v4l2_cropcap *cap)
1599
+static int saa7134_g_pixelaspect(struct file *file, void *priv,
1600
+ int type, struct v4l2_fract *f)
16541601 {
16551602 struct saa7134_dev *dev = video_drvdata(file);
16561603
1657
- if (cap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
1658
- cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
1604
+ if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
1605
+ type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
16591606 return -EINVAL;
1660
- cap->pixelaspect.numerator = 1;
1661
- cap->pixelaspect.denominator = 1;
1607
+
16621608 if (dev->tvnorm->id & V4L2_STD_525_60) {
1663
- cap->pixelaspect.numerator = 11;
1664
- cap->pixelaspect.denominator = 10;
1609
+ f->numerator = 11;
1610
+ f->denominator = 10;
16651611 }
16661612 if (dev->tvnorm->id & V4L2_STD_625_50) {
1667
- cap->pixelaspect.numerator = 54;
1668
- cap->pixelaspect.denominator = 59;
1613
+ f->numerator = 54;
1614
+ f->denominator = 59;
16691615 }
16701616 return 0;
16711617 }
....@@ -1747,7 +1693,7 @@
17471693 if (n == SAA7134_INPUT_MAX)
17481694 return -EINVAL;
17491695 if (card_in(dev, n).type != SAA7134_NO_INPUT) {
1750
- strcpy(t->name, "Television");
1696
+ strscpy(t->name, "Television", sizeof(t->name));
17511697 t->type = V4L2_TUNER_ANALOG_TV;
17521698 saa_call_all(dev, tuner, g_tuner, t);
17531699 t->capability = V4L2_TUNER_CAP_NORM |
....@@ -1819,9 +1765,6 @@
18191765 if (f->index >= FORMATS)
18201766 return -EINVAL;
18211767
1822
- strlcpy(f->description, formats[f->index].name,
1823
- sizeof(f->description));
1824
-
18251768 f->pixelformat = formats[f->index].fourcc;
18261769
18271770 return 0;
....@@ -1837,9 +1780,6 @@
18371780
18381781 if ((f->index >= FORMATS) || formats[f->index].planar)
18391782 return -EINVAL;
1840
-
1841
- strlcpy(f->description, formats[f->index].name,
1842
- sizeof(f->description));
18431783
18441784 f->pixelformat = formats[f->index].fourcc;
18451785
....@@ -1939,7 +1879,7 @@
19391879 if (0 != t->index)
19401880 return -EINVAL;
19411881
1942
- strcpy(t->name, "Radio");
1882
+ strscpy(t->name, "Radio", sizeof(t->name));
19431883
19441884 saa_call_all(dev, tuner, g_tuner, t);
19451885 t->audmode &= V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO;
....@@ -1986,7 +1926,7 @@
19861926 .vidioc_g_fmt_vbi_cap = saa7134_try_get_set_fmt_vbi_cap,
19871927 .vidioc_try_fmt_vbi_cap = saa7134_try_get_set_fmt_vbi_cap,
19881928 .vidioc_s_fmt_vbi_cap = saa7134_try_get_set_fmt_vbi_cap,
1989
- .vidioc_cropcap = saa7134_cropcap,
1929
+ .vidioc_g_pixelaspect = saa7134_g_pixelaspect,
19901930 .vidioc_reqbufs = vb2_ioctl_reqbufs,
19911931 .vidioc_querybuf = vb2_ioctl_querybuf,
19921932 .vidioc_qbuf = vb2_ioctl_qbuf,
....@@ -2136,7 +2076,7 @@
21362076 hdl = &dev->radio_ctrl_handler;
21372077 v4l2_ctrl_handler_init(hdl, 2);
21382078 v4l2_ctrl_add_handler(hdl, &dev->ctrl_handler,
2139
- v4l2_ctrl_radio_filter);
2079
+ v4l2_ctrl_radio_filter, false);
21402080 if (hdl->error)
21412081 return hdl->error;
21422082 }
....@@ -2213,10 +2153,9 @@
22132153
22142154 void saa7134_video_fini(struct saa7134_dev *dev)
22152155 {
2156
+ del_timer_sync(&dev->video_q.timeout);
22162157 /* free stuff */
2217
- vb2_queue_release(&dev->video_vbq);
22182158 saa7134_pgtable_free(dev->pci, &dev->video_q.pt);
2219
- vb2_queue_release(&dev->vbi_vbq);
22202159 saa7134_pgtable_free(dev->pci, &dev->vbi_q.pt);
22212160 v4l2_ctrl_handler_free(&dev->ctrl_handler);
22222161 if (card_has_radio(dev))