hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/media/platform/exynos-gsc/gsc-core.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd.
34 * http://www.samsung.com
45 *
56 * Samsung EXYNOS5 SoC series G-Scaler driver
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published
9
- * by the Free Software Foundation, either version 2 of the License,
10
- * or (at your option) any later version.
117 */
128
139 #include <linux/module.h>
....@@ -31,21 +27,18 @@
3127
3228 static const struct gsc_fmt gsc_formats[] = {
3329 {
34
- .name = "RGB565",
3530 .pixelformat = V4L2_PIX_FMT_RGB565X,
3631 .depth = { 16 },
3732 .color = GSC_RGB,
3833 .num_planes = 1,
3934 .num_comp = 1,
4035 }, {
41
- .name = "BGRX-8-8-8-8, 32 bpp",
4236 .pixelformat = V4L2_PIX_FMT_BGR32,
4337 .depth = { 32 },
4438 .color = GSC_RGB,
4539 .num_planes = 1,
4640 .num_comp = 1,
4741 }, {
48
- .name = "YUV 4:2:2 packed, YCbYCr",
4942 .pixelformat = V4L2_PIX_FMT_YUYV,
5043 .depth = { 16 },
5144 .color = GSC_YUV422,
....@@ -55,7 +48,6 @@
5548 .num_comp = 1,
5649 .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8,
5750 }, {
58
- .name = "YUV 4:2:2 packed, CbYCrY",
5951 .pixelformat = V4L2_PIX_FMT_UYVY,
6052 .depth = { 16 },
6153 .color = GSC_YUV422,
....@@ -65,7 +57,6 @@
6557 .num_comp = 1,
6658 .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8,
6759 }, {
68
- .name = "YUV 4:2:2 packed, CrYCbY",
6960 .pixelformat = V4L2_PIX_FMT_VYUY,
7061 .depth = { 16 },
7162 .color = GSC_YUV422,
....@@ -75,7 +66,6 @@
7566 .num_comp = 1,
7667 .mbus_code = MEDIA_BUS_FMT_VYUY8_2X8,
7768 }, {
78
- .name = "YUV 4:2:2 packed, YCrYCb",
7969 .pixelformat = V4L2_PIX_FMT_YVYU,
8070 .depth = { 16 },
8171 .color = GSC_YUV422,
....@@ -85,7 +75,6 @@
8575 .num_comp = 1,
8676 .mbus_code = MEDIA_BUS_FMT_YVYU8_2X8,
8777 }, {
88
- .name = "YUV 4:4:4 planar, YCbYCr",
8978 .pixelformat = V4L2_PIX_FMT_YUV32,
9079 .depth = { 32 },
9180 .color = GSC_YUV444,
....@@ -94,7 +83,6 @@
9483 .num_planes = 1,
9584 .num_comp = 1,
9685 }, {
97
- .name = "YUV 4:2:2 planar, Y/Cb/Cr",
9886 .pixelformat = V4L2_PIX_FMT_YUV422P,
9987 .depth = { 16 },
10088 .color = GSC_YUV422,
....@@ -103,7 +91,6 @@
10391 .num_planes = 1,
10492 .num_comp = 3,
10593 }, {
106
- .name = "YUV 4:2:2 planar, Y/CbCr",
10794 .pixelformat = V4L2_PIX_FMT_NV16,
10895 .depth = { 16 },
10996 .color = GSC_YUV422,
....@@ -112,7 +99,6 @@
11299 .num_planes = 1,
113100 .num_comp = 2,
114101 }, {
115
- .name = "YUV 4:2:2 non-contig, Y/CbCr",
116102 .pixelformat = V4L2_PIX_FMT_NV16M,
117103 .depth = { 8, 8 },
118104 .color = GSC_YUV422,
....@@ -121,7 +107,6 @@
121107 .num_planes = 2,
122108 .num_comp = 2,
123109 }, {
124
- .name = "YUV 4:2:2 planar, Y/CrCb",
125110 .pixelformat = V4L2_PIX_FMT_NV61,
126111 .depth = { 16 },
127112 .color = GSC_YUV422,
....@@ -130,7 +115,6 @@
130115 .num_planes = 1,
131116 .num_comp = 2,
132117 }, {
133
- .name = "YUV 4:2:2 non-contig, Y/CrCb",
134118 .pixelformat = V4L2_PIX_FMT_NV61M,
135119 .depth = { 8, 8 },
136120 .color = GSC_YUV422,
....@@ -139,7 +123,6 @@
139123 .num_planes = 2,
140124 .num_comp = 2,
141125 }, {
142
- .name = "YUV 4:2:0 planar, YCbCr",
143126 .pixelformat = V4L2_PIX_FMT_YUV420,
144127 .depth = { 12 },
145128 .color = GSC_YUV420,
....@@ -148,7 +131,6 @@
148131 .num_planes = 1,
149132 .num_comp = 3,
150133 }, {
151
- .name = "YUV 4:2:0 planar, YCrCb",
152134 .pixelformat = V4L2_PIX_FMT_YVU420,
153135 .depth = { 12 },
154136 .color = GSC_YUV420,
....@@ -158,7 +140,6 @@
158140 .num_comp = 3,
159141
160142 }, {
161
- .name = "YUV 4:2:0 planar, Y/CbCr",
162143 .pixelformat = V4L2_PIX_FMT_NV12,
163144 .depth = { 12 },
164145 .color = GSC_YUV420,
....@@ -167,7 +148,6 @@
167148 .num_planes = 1,
168149 .num_comp = 2,
169150 }, {
170
- .name = "YUV 4:2:0 planar, Y/CrCb",
171151 .pixelformat = V4L2_PIX_FMT_NV21,
172152 .depth = { 12 },
173153 .color = GSC_YUV420,
....@@ -176,7 +156,6 @@
176156 .num_planes = 1,
177157 .num_comp = 2,
178158 }, {
179
- .name = "YUV 4:2:0 non-contig. 2p, Y/CrCb",
180159 .pixelformat = V4L2_PIX_FMT_NV21M,
181160 .depth = { 8, 4 },
182161 .color = GSC_YUV420,
....@@ -185,7 +164,6 @@
185164 .num_planes = 2,
186165 .num_comp = 2,
187166 }, {
188
- .name = "YUV 4:2:0 non-contig. 2p, Y/CbCr",
189167 .pixelformat = V4L2_PIX_FMT_NV12M,
190168 .depth = { 8, 4 },
191169 .color = GSC_YUV420,
....@@ -194,7 +172,6 @@
194172 .num_planes = 2,
195173 .num_comp = 2,
196174 }, {
197
- .name = "YUV 4:2:0 non-contig. 3p, Y/Cb/Cr",
198175 .pixelformat = V4L2_PIX_FMT_YUV420M,
199176 .depth = { 8, 2, 2 },
200177 .color = GSC_YUV420,
....@@ -203,7 +180,6 @@
203180 .num_planes = 3,
204181 .num_comp = 3,
205182 }, {
206
- .name = "YUV 4:2:0 non-contig. 3p, Y/Cr/Cb",
207183 .pixelformat = V4L2_PIX_FMT_YVU420M,
208184 .depth = { 8, 2, 2 },
209185 .color = GSC_YUV420,
....@@ -212,7 +188,6 @@
212188 .num_planes = 3,
213189 .num_comp = 3,
214190 }, {
215
- .name = "YUV 4:2:0 n.c. 2p, Y/CbCr tiled",
216191 .pixelformat = V4L2_PIX_FMT_NV12MT_16X16,
217192 .depth = { 8, 4 },
218193 .color = GSC_YUV420,
....@@ -331,7 +306,7 @@
331306 }
332307 }
333308
334
-int gsc_enum_fmt_mplane(struct v4l2_fmtdesc *f)
309
+int gsc_enum_fmt(struct v4l2_fmtdesc *f)
335310 {
336311 const struct gsc_fmt *fmt;
337312
....@@ -339,7 +314,6 @@
339314 if (!fmt)
340315 return -EINVAL;
341316
342
- strlcpy(f->description, fmt->name, sizeof(f->description));
343317 f->pixelformat = fmt->pixelformat;
344318
345319 return 0;
....@@ -541,20 +515,7 @@
541515 }
542516 }
543517
544
-int gsc_g_crop(struct gsc_ctx *ctx, struct v4l2_crop *cr)
545
-{
546
- struct gsc_frame *frame;
547
-
548
- frame = ctx_get_frame(ctx, cr->type);
549
- if (IS_ERR(frame))
550
- return PTR_ERR(frame);
551
-
552
- cr->c = frame->crop;
553
-
554
- return 0;
555
-}
556
-
557
-int gsc_try_crop(struct gsc_ctx *ctx, struct v4l2_crop *cr)
518
+int gsc_try_selection(struct gsc_ctx *ctx, struct v4l2_selection *s)
558519 {
559520 struct gsc_frame *f;
560521 struct gsc_dev *gsc = ctx->gsc_dev;
....@@ -562,25 +523,25 @@
562523 u32 mod_x = 0, mod_y = 0, tmp_w, tmp_h;
563524 u32 min_w, min_h, max_w, max_h;
564525
565
- if (cr->c.top < 0 || cr->c.left < 0) {
526
+ if (s->r.top < 0 || s->r.left < 0) {
566527 pr_err("doesn't support negative values for top & left\n");
567528 return -EINVAL;
568529 }
569
- pr_debug("user put w: %d, h: %d", cr->c.width, cr->c.height);
530
+ pr_debug("user put w: %d, h: %d", s->r.width, s->r.height);
570531
571
- if (cr->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
532
+ if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
572533 f = &ctx->d_frame;
573
- else if (cr->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
534
+ else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
574535 f = &ctx->s_frame;
575536 else
576537 return -EINVAL;
577538
578539 max_w = f->f_width;
579540 max_h = f->f_height;
580
- tmp_w = cr->c.width;
581
- tmp_h = cr->c.height;
541
+ tmp_w = s->r.width;
542
+ tmp_h = s->r.height;
582543
583
- if (V4L2_TYPE_IS_OUTPUT(cr->type)) {
544
+ if (V4L2_TYPE_IS_OUTPUT(s->type)) {
584545 if ((is_yuv422(f->fmt->color) && f->fmt->num_comp == 1) ||
585546 is_rgb(f->fmt->color))
586547 min_w = 32;
....@@ -602,8 +563,8 @@
602563 max_h = f->f_width;
603564 min_w = variant->pix_min->target_rot_en_w;
604565 min_h = variant->pix_min->target_rot_en_h;
605
- tmp_w = cr->c.height;
606
- tmp_h = cr->c.width;
566
+ tmp_w = s->r.height;
567
+ tmp_h = s->r.width;
607568 } else {
608569 min_w = variant->pix_min->target_rot_dis_w;
609570 min_h = variant->pix_min->target_rot_dis_h;
....@@ -616,29 +577,29 @@
616577 v4l_bound_align_image(&tmp_w, min_w, max_w, mod_x,
617578 &tmp_h, min_h, max_h, mod_y, 0);
618579
619
- if (!V4L2_TYPE_IS_OUTPUT(cr->type) &&
620
- (ctx->gsc_ctrls.rotate->val == 90 ||
621
- ctx->gsc_ctrls.rotate->val == 270))
580
+ if (V4L2_TYPE_IS_CAPTURE(s->type) &&
581
+ (ctx->gsc_ctrls.rotate->val == 90 ||
582
+ ctx->gsc_ctrls.rotate->val == 270))
622583 gsc_check_crop_change(tmp_h, tmp_w,
623
- &cr->c.width, &cr->c.height);
584
+ &s->r.width, &s->r.height);
624585 else
625586 gsc_check_crop_change(tmp_w, tmp_h,
626
- &cr->c.width, &cr->c.height);
587
+ &s->r.width, &s->r.height);
627588
628589
629590 /* adjust left/top if cropping rectangle is out of bounds */
630591 /* Need to add code to algin left value with 2's multiple */
631
- if (cr->c.left + tmp_w > max_w)
632
- cr->c.left = max_w - tmp_w;
633
- if (cr->c.top + tmp_h > max_h)
634
- cr->c.top = max_h - tmp_h;
592
+ if (s->r.left + tmp_w > max_w)
593
+ s->r.left = max_w - tmp_w;
594
+ if (s->r.top + tmp_h > max_h)
595
+ s->r.top = max_h - tmp_h;
635596
636597 if ((is_yuv420(f->fmt->color) || is_yuv422(f->fmt->color)) &&
637
- cr->c.left & 1)
638
- cr->c.left -= 1;
598
+ s->r.left & 1)
599
+ s->r.left -= 1;
639600
640601 pr_debug("Aligned l:%d, t:%d, w:%d, h:%d, f_w: %d, f_h: %d",
641
- cr->c.left, cr->c.top, cr->c.width, cr->c.height, max_w, max_h);
602
+ s->r.left, s->r.top, s->r.width, s->r.height, max_w, max_h);
642603
643604 return 0;
644605 }