hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/platform/davinci/vpfe_capture.c
....@@ -1,15 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2008-2009 Texas Instruments Inc
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License as published by
6
- * the Free Software Foundation; either version 2 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
134 *
145 * Driver name : VPFE Capture driver
156 * VPFE Capture driver allows applications to capture and stream video
....@@ -23,7 +14,6 @@
2314 * YUV data through an in-built analog encoder or Digital LCD port. This
2415 * driver is for capture through VPFE. A typical EVM using these SoCs have
2516 * following high level configuration.
26
- *
2717 *
2818 * decoder(TVP5146/ YUV/
2919 * MT9T001) --> Raw Bayer RGB ---> MUX -> VPFE (CCDC/ISIF)
....@@ -129,57 +119,27 @@
129119 /* Used when raw Bayer image from ccdc is directly captured to SDRAM */
130120 static const struct vpfe_pixel_format vpfe_pix_fmts[] = {
131121 {
132
- .fmtdesc = {
133
- .index = 0,
134
- .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
135
- .description = "Bayer GrRBGb 8bit A-Law compr.",
136
- .pixelformat = V4L2_PIX_FMT_SBGGR8,
137
- },
122
+ .pixelformat = V4L2_PIX_FMT_SBGGR8,
138123 .bpp = 1,
139124 },
140125 {
141
- .fmtdesc = {
142
- .index = 1,
143
- .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
144
- .description = "Bayer GrRBGb - 16bit",
145
- .pixelformat = V4L2_PIX_FMT_SBGGR16,
146
- },
126
+ .pixelformat = V4L2_PIX_FMT_SBGGR16,
147127 .bpp = 2,
148128 },
149129 {
150
- .fmtdesc = {
151
- .index = 2,
152
- .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
153
- .description = "Bayer GrRBGb 8bit DPCM compr.",
154
- .pixelformat = V4L2_PIX_FMT_SGRBG10DPCM8,
155
- },
130
+ .pixelformat = V4L2_PIX_FMT_SGRBG10DPCM8,
156131 .bpp = 1,
157132 },
158133 {
159
- .fmtdesc = {
160
- .index = 3,
161
- .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
162
- .description = "YCbCr 4:2:2 Interleaved UYVY",
163
- .pixelformat = V4L2_PIX_FMT_UYVY,
164
- },
134
+ .pixelformat = V4L2_PIX_FMT_UYVY,
165135 .bpp = 2,
166136 },
167137 {
168
- .fmtdesc = {
169
- .index = 4,
170
- .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
171
- .description = "YCbCr 4:2:2 Interleaved YUYV",
172
- .pixelformat = V4L2_PIX_FMT_YUYV,
173
- },
138
+ .pixelformat = V4L2_PIX_FMT_YUYV,
174139 .bpp = 2,
175140 },
176141 {
177
- .fmtdesc = {
178
- .index = 5,
179
- .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
180
- .description = "Y/CbCr 4:2:0 - Semi planar",
181
- .pixelformat = V4L2_PIX_FMT_NV12,
182
- },
142
+ .pixelformat = V4L2_PIX_FMT_NV12,
183143 .bpp = 1,
184144 },
185145 };
....@@ -193,7 +153,7 @@
193153 int i;
194154
195155 for (i = 0; i < ARRAY_SIZE(vpfe_pix_fmts); i++) {
196
- if (pix_format == vpfe_pix_fmts[i].fmtdesc.pixelformat)
156
+ if (pix_format == vpfe_pix_fmts[i].pixelformat)
197157 return &vpfe_pix_fmts[i];
198158 }
199159 return NULL;
....@@ -208,21 +168,22 @@
208168 int ret = 0;
209169 printk(KERN_NOTICE "vpfe_register_ccdc_device: %s\n", dev->name);
210170
211
- BUG_ON(!dev->hw_ops.open);
212
- BUG_ON(!dev->hw_ops.enable);
213
- BUG_ON(!dev->hw_ops.set_hw_if_params);
214
- BUG_ON(!dev->hw_ops.configure);
215
- BUG_ON(!dev->hw_ops.set_buftype);
216
- BUG_ON(!dev->hw_ops.get_buftype);
217
- BUG_ON(!dev->hw_ops.enum_pix);
218
- BUG_ON(!dev->hw_ops.set_frame_format);
219
- BUG_ON(!dev->hw_ops.get_frame_format);
220
- BUG_ON(!dev->hw_ops.get_pixel_format);
221
- BUG_ON(!dev->hw_ops.set_pixel_format);
222
- BUG_ON(!dev->hw_ops.set_image_window);
223
- BUG_ON(!dev->hw_ops.get_image_window);
224
- BUG_ON(!dev->hw_ops.get_line_length);
225
- BUG_ON(!dev->hw_ops.getfid);
171
+ if (!dev->hw_ops.open ||
172
+ !dev->hw_ops.enable ||
173
+ !dev->hw_ops.set_hw_if_params ||
174
+ !dev->hw_ops.configure ||
175
+ !dev->hw_ops.set_buftype ||
176
+ !dev->hw_ops.get_buftype ||
177
+ !dev->hw_ops.enum_pix ||
178
+ !dev->hw_ops.set_frame_format ||
179
+ !dev->hw_ops.get_frame_format ||
180
+ !dev->hw_ops.get_pixel_format ||
181
+ !dev->hw_ops.set_pixel_format ||
182
+ !dev->hw_ops.set_image_window ||
183
+ !dev->hw_ops.get_image_window ||
184
+ !dev->hw_ops.get_line_length ||
185
+ !dev->hw_ops.getfid)
186
+ return -EINVAL;
226187
227188 mutex_lock(&ccdc_lock);
228189 if (!ccdc_cfg) {
....@@ -518,7 +479,7 @@
518479
519480 static void vpfe_process_buffer_complete(struct vpfe_device *vpfe_dev)
520481 {
521
- v4l2_get_timestamp(&vpfe_dev->cur_frm->ts);
482
+ vpfe_dev->cur_frm->ts = ktime_get_ns();
522483 vpfe_dev->cur_frm->state = VIDEOBUF_DONE;
523484 vpfe_dev->cur_frm->size = vpfe_dev->fmt.fmt.pix.sizeimage;
524485 wake_up_interruptible(&vpfe_dev->cur_frm->done);
....@@ -792,7 +753,7 @@
792753 temp = 0;
793754 found = 0;
794755 while (ccdc_dev->hw_ops.enum_pix(&pix, temp) >= 0) {
795
- if (vpfe_pix_fmt->fmtdesc.pixelformat == pix) {
756
+ if (vpfe_pix_fmt->pixelformat == pix) {
796757 found = 1;
797758 break;
798759 }
....@@ -887,11 +848,9 @@
887848
888849 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querycap\n");
889850
890
- cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
891
- cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
892
- strlcpy(cap->driver, CAPTURE_DRV_NAME, sizeof(cap->driver));
893
- strlcpy(cap->bus_info, "VPFE", sizeof(cap->bus_info));
894
- strlcpy(cap->card, vpfe_dev->cfg->card_name, sizeof(cap->card));
851
+ strscpy(cap->driver, CAPTURE_DRV_NAME, sizeof(cap->driver));
852
+ strscpy(cap->bus_info, "VPFE", sizeof(cap->bus_info));
853
+ strscpy(cap->card, vpfe_dev->cfg->card_name, sizeof(cap->card));
895854 return 0;
896855 }
897856
....@@ -911,7 +870,6 @@
911870 {
912871 struct vpfe_device *vpfe_dev = video_drvdata(file);
913872 const struct vpfe_pixel_format *pix_fmt;
914
- int temp_index;
915873 u32 pix;
916874
917875 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_enum_fmt_vid_cap\n");
....@@ -922,9 +880,7 @@
922880 /* Fill in the information about format */
923881 pix_fmt = vpfe_lookup_pix_format(pix);
924882 if (pix_fmt) {
925
- temp_index = fmt->index;
926
- *fmt = pix_fmt->fmtdesc;
927
- fmt->index = temp_index;
883
+ fmt->pixelformat = pix_fmt->pixelformat;
928884 return 0;
929885 }
930886 return -EINVAL;
....@@ -1558,20 +1514,20 @@
15581514 return ret;
15591515 }
15601516
1561
-static int vpfe_cropcap(struct file *file, void *priv,
1562
- struct v4l2_cropcap *crop)
1517
+static int vpfe_g_pixelaspect(struct file *file, void *priv,
1518
+ int type, struct v4l2_fract *f)
15631519 {
15641520 struct vpfe_device *vpfe_dev = video_drvdata(file);
15651521
1566
- v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_cropcap\n");
1522
+ v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_pixelaspect\n");
15671523
1568
- if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1524
+ if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
15691525 return -EINVAL;
15701526 /* If std_index is invalid, then just return (== 1:1 aspect) */
15711527 if (vpfe_dev->std_index >= ARRAY_SIZE(vpfe_standards))
15721528 return 0;
15731529
1574
- crop->pixelaspect = vpfe_standards[vpfe_dev->std_index].pixelaspect;
1530
+ *f = vpfe_standards[vpfe_dev->std_index].pixelaspect;
15751531 return 0;
15761532 }
15771533
....@@ -1677,7 +1633,7 @@
16771633 .vidioc_dqbuf = vpfe_dqbuf,
16781634 .vidioc_streamon = vpfe_streamon,
16791635 .vidioc_streamoff = vpfe_streamoff,
1680
- .vidioc_cropcap = vpfe_cropcap,
1636
+ .vidioc_g_pixelaspect = vpfe_g_pixelaspect,
16811637 .vidioc_g_selection = vpfe_g_selection,
16821638 .vidioc_s_selection = vpfe_s_selection,
16831639 };
....@@ -1759,7 +1715,7 @@
17591715
17601716 mutex_lock(&ccdc_lock);
17611717
1762
- strncpy(ccdc_cfg->name, vpfe_cfg->ccdc, 32);
1718
+ strscpy(ccdc_cfg->name, vpfe_cfg->ccdc, sizeof(ccdc_cfg->name));
17631719 /* Get VINT0 irq resource */
17641720 res1 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
17651721 if (!res1) {
....@@ -1795,6 +1751,7 @@
17951751 vfd->ioctl_ops = &vpfe_ioctl_ops;
17961752 vfd->tvnorms = 0;
17971753 vfd->v4l2_dev = &vpfe_dev->v4l2_dev;
1754
+ vfd->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
17981755 snprintf(vfd->name, sizeof(vfd->name),
17991756 "%s_V%d.%d.%d",
18001757 CAPTURE_DRV_NAME,
....@@ -1823,7 +1780,7 @@
18231780 "video_dev=%p\n", &vpfe_dev->video_dev);
18241781 vpfe_dev->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
18251782 ret = video_register_device(&vpfe_dev->video_dev,
1826
- VFL_TYPE_GRABBER, -1);
1783
+ VFL_TYPE_VIDEO, -1);
18271784
18281785 if (ret) {
18291786 v4l2_err(pdev->dev.driver,