forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * linux/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
34 *
....@@ -6,11 +7,6 @@
67 *
78 * Jeongtae Park <jtp.park@samsung.com>
89 * Kamil Debski <k.debski@samsung.com>
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version.
1410 */
1511
1612 #include <linux/clk.h>
....@@ -36,7 +32,6 @@
3632
3733 static struct s5p_mfc_fmt formats[] = {
3834 {
39
- .name = "4:2:0 2 Planes 16x16 Tiles",
4035 .fourcc = V4L2_PIX_FMT_NV12MT_16X16,
4136 .codec_mode = S5P_MFC_CODEC_NONE,
4237 .type = MFC_FMT_RAW,
....@@ -44,7 +39,6 @@
4439 .versions = MFC_V6_BIT | MFC_V7_BIT,
4540 },
4641 {
47
- .name = "4:2:0 2 Planes 64x32 Tiles",
4842 .fourcc = V4L2_PIX_FMT_NV12MT,
4943 .codec_mode = S5P_MFC_CODEC_NONE,
5044 .type = MFC_FMT_RAW,
....@@ -52,7 +46,6 @@
5246 .versions = MFC_V5_BIT,
5347 },
5448 {
55
- .name = "4:2:0 2 Planes Y/CbCr",
5649 .fourcc = V4L2_PIX_FMT_NV12M,
5750 .codec_mode = S5P_MFC_CODEC_NONE,
5851 .type = MFC_FMT_RAW,
....@@ -60,7 +53,6 @@
6053 .versions = MFC_V5PLUS_BITS,
6154 },
6255 {
63
- .name = "4:2:0 2 Planes Y/CrCb",
6456 .fourcc = V4L2_PIX_FMT_NV21M,
6557 .codec_mode = S5P_MFC_CODEC_NONE,
6658 .type = MFC_FMT_RAW,
....@@ -68,7 +60,6 @@
6860 .versions = MFC_V6PLUS_BITS,
6961 },
7062 {
71
- .name = "H264 Encoded Stream",
7263 .fourcc = V4L2_PIX_FMT_H264,
7364 .codec_mode = S5P_MFC_CODEC_H264_ENC,
7465 .type = MFC_FMT_ENC,
....@@ -76,7 +67,6 @@
7667 .versions = MFC_V5PLUS_BITS,
7768 },
7869 {
79
- .name = "MPEG4 Encoded Stream",
8070 .fourcc = V4L2_PIX_FMT_MPEG4,
8171 .codec_mode = S5P_MFC_CODEC_MPEG4_ENC,
8272 .type = MFC_FMT_ENC,
....@@ -84,7 +74,6 @@
8474 .versions = MFC_V5PLUS_BITS,
8575 },
8676 {
87
- .name = "H263 Encoded Stream",
8877 .fourcc = V4L2_PIX_FMT_H263,
8978 .codec_mode = S5P_MFC_CODEC_H263_ENC,
9079 .type = MFC_FMT_ENC,
....@@ -92,7 +81,6 @@
9281 .versions = MFC_V5PLUS_BITS,
9382 },
9483 {
95
- .name = "VP8 Encoded Stream",
9684 .fourcc = V4L2_PIX_FMT_VP8,
9785 .codec_mode = S5P_MFC_CODEC_VP8_ENC,
9886 .type = MFC_FMT_ENC,
....@@ -134,7 +122,7 @@
134122 .id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE,
135123 .type = V4L2_CTRL_TYPE_MENU,
136124 .minimum = V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE,
137
- .maximum = V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES,
125
+ .maximum = V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_BYTES,
138126 .default_value = V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE,
139127 .menu_skip_mask = 0,
140128 },
....@@ -272,6 +260,12 @@
272260 .maximum = V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT,
273261 .menu_skip_mask = 0,
274262 .default_value = V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_DISABLED,
263
+ },
264
+ {
265
+ .id = V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE,
266
+ .type = V4L2_CTRL_TYPE_MENU,
267
+ .maximum = V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT,
268
+ .default_value = V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED,
275269 },
276270 {
277271 .id = V4L2_CID_MPEG_MFC51_VIDEO_RC_FIXED_TARGET_BIT,
....@@ -1313,17 +1307,10 @@
13131307 {
13141308 struct s5p_mfc_dev *dev = video_drvdata(file);
13151309
1316
- strlcpy(cap->driver, S5P_MFC_NAME, sizeof(cap->driver));
1317
- strlcpy(cap->card, dev->vfd_enc->name, sizeof(cap->card));
1310
+ strscpy(cap->driver, S5P_MFC_NAME, sizeof(cap->driver));
1311
+ strscpy(cap->card, dev->vfd_enc->name, sizeof(cap->card));
13181312 snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
13191313 dev_name(&dev->plat_dev->dev));
1320
- /*
1321
- * This is only a mem-to-mem video device. The capture and output
1322
- * device capability flags are left only for backward compatibility
1323
- * and are scheduled for removal.
1324
- */
1325
- cap->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
1326
- cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
13271314 return 0;
13281315 }
13291316
....@@ -1331,7 +1318,6 @@
13311318 bool out)
13321319 {
13331320 struct s5p_mfc_dev *dev = video_drvdata(file);
1334
- struct s5p_mfc_fmt *fmt;
13351321 int i, j = 0;
13361322
13371323 for (i = 0; i < ARRAY_SIZE(formats); ++i) {
....@@ -1343,10 +1329,7 @@
13431329 continue;
13441330
13451331 if (j == f->index) {
1346
- fmt = &formats[i];
1347
- strlcpy(f->description, fmt->name,
1348
- sizeof(f->description));
1349
- f->pixelformat = fmt->fourcc;
1332
+ f->pixelformat = formats[i].fourcc;
13501333 return 0;
13511334 }
13521335 ++j;
....@@ -1354,14 +1337,14 @@
13541337 return -EINVAL;
13551338 }
13561339
1357
-static int vidioc_enum_fmt_vid_cap_mplane(struct file *file, void *pirv,
1358
- struct v4l2_fmtdesc *f)
1340
+static int vidioc_enum_fmt_vid_cap(struct file *file, void *pirv,
1341
+ struct v4l2_fmtdesc *f)
13591342 {
13601343 return vidioc_enum_fmt(file, f, false);
13611344 }
13621345
1363
-static int vidioc_enum_fmt_vid_out_mplane(struct file *file, void *prov,
1364
- struct v4l2_fmtdesc *f)
1346
+static int vidioc_enum_fmt_vid_out(struct file *file, void *priv,
1347
+ struct v4l2_fmtdesc *f)
13651348 {
13661349 return vidioc_enum_fmt(file, f, true);
13671350 }
....@@ -1621,9 +1604,9 @@
16211604 mfc_err("Call on QBUF after EOS command\n");
16221605 return -EIO;
16231606 }
1624
- return vb2_qbuf(&ctx->vq_src, buf);
1607
+ return vb2_qbuf(&ctx->vq_src, NULL, buf);
16251608 } else if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
1626
- return vb2_qbuf(&ctx->vq_dst, buf);
1609
+ return vb2_qbuf(&ctx->vq_dst, NULL, buf);
16271610 }
16281611 return -EINVAL;
16291612 }
....@@ -1872,6 +1855,7 @@
18721855 p->seq_hdr_mode = ctrl->val;
18731856 break;
18741857 case V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE:
1858
+ case V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE:
18751859 p->frame_skip_mode = ctrl->val;
18761860 break;
18771861 case V4L2_CID_MPEG_MFC51_VIDEO_RC_FIXED_TARGET_BIT:
....@@ -2343,8 +2327,8 @@
23432327
23442328 static const struct v4l2_ioctl_ops s5p_mfc_enc_ioctl_ops = {
23452329 .vidioc_querycap = vidioc_querycap,
2346
- .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane,
2347
- .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane,
2330
+ .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
2331
+ .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out,
23482332 .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt,
23492333 .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt,
23502334 .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt,