.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. |
---|
3 | 4 | * http://www.samsung.com |
---|
4 | 5 | * |
---|
5 | 6 | * 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. |
---|
11 | 7 | */ |
---|
12 | 8 | |
---|
13 | 9 | #include <linux/module.h> |
---|
.. | .. |
---|
31 | 27 | |
---|
32 | 28 | static const struct gsc_fmt gsc_formats[] = { |
---|
33 | 29 | { |
---|
34 | | - .name = "RGB565", |
---|
35 | 30 | .pixelformat = V4L2_PIX_FMT_RGB565X, |
---|
36 | 31 | .depth = { 16 }, |
---|
37 | 32 | .color = GSC_RGB, |
---|
38 | 33 | .num_planes = 1, |
---|
39 | 34 | .num_comp = 1, |
---|
40 | 35 | }, { |
---|
41 | | - .name = "BGRX-8-8-8-8, 32 bpp", |
---|
42 | 36 | .pixelformat = V4L2_PIX_FMT_BGR32, |
---|
43 | 37 | .depth = { 32 }, |
---|
44 | 38 | .color = GSC_RGB, |
---|
45 | 39 | .num_planes = 1, |
---|
46 | 40 | .num_comp = 1, |
---|
47 | 41 | }, { |
---|
48 | | - .name = "YUV 4:2:2 packed, YCbYCr", |
---|
49 | 42 | .pixelformat = V4L2_PIX_FMT_YUYV, |
---|
50 | 43 | .depth = { 16 }, |
---|
51 | 44 | .color = GSC_YUV422, |
---|
.. | .. |
---|
55 | 48 | .num_comp = 1, |
---|
56 | 49 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
---|
57 | 50 | }, { |
---|
58 | | - .name = "YUV 4:2:2 packed, CbYCrY", |
---|
59 | 51 | .pixelformat = V4L2_PIX_FMT_UYVY, |
---|
60 | 52 | .depth = { 16 }, |
---|
61 | 53 | .color = GSC_YUV422, |
---|
.. | .. |
---|
65 | 57 | .num_comp = 1, |
---|
66 | 58 | .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8, |
---|
67 | 59 | }, { |
---|
68 | | - .name = "YUV 4:2:2 packed, CrYCbY", |
---|
69 | 60 | .pixelformat = V4L2_PIX_FMT_VYUY, |
---|
70 | 61 | .depth = { 16 }, |
---|
71 | 62 | .color = GSC_YUV422, |
---|
.. | .. |
---|
75 | 66 | .num_comp = 1, |
---|
76 | 67 | .mbus_code = MEDIA_BUS_FMT_VYUY8_2X8, |
---|
77 | 68 | }, { |
---|
78 | | - .name = "YUV 4:2:2 packed, YCrYCb", |
---|
79 | 69 | .pixelformat = V4L2_PIX_FMT_YVYU, |
---|
80 | 70 | .depth = { 16 }, |
---|
81 | 71 | .color = GSC_YUV422, |
---|
.. | .. |
---|
85 | 75 | .num_comp = 1, |
---|
86 | 76 | .mbus_code = MEDIA_BUS_FMT_YVYU8_2X8, |
---|
87 | 77 | }, { |
---|
88 | | - .name = "YUV 4:4:4 planar, YCbYCr", |
---|
89 | 78 | .pixelformat = V4L2_PIX_FMT_YUV32, |
---|
90 | 79 | .depth = { 32 }, |
---|
91 | 80 | .color = GSC_YUV444, |
---|
.. | .. |
---|
94 | 83 | .num_planes = 1, |
---|
95 | 84 | .num_comp = 1, |
---|
96 | 85 | }, { |
---|
97 | | - .name = "YUV 4:2:2 planar, Y/Cb/Cr", |
---|
98 | 86 | .pixelformat = V4L2_PIX_FMT_YUV422P, |
---|
99 | 87 | .depth = { 16 }, |
---|
100 | 88 | .color = GSC_YUV422, |
---|
.. | .. |
---|
103 | 91 | .num_planes = 1, |
---|
104 | 92 | .num_comp = 3, |
---|
105 | 93 | }, { |
---|
106 | | - .name = "YUV 4:2:2 planar, Y/CbCr", |
---|
107 | 94 | .pixelformat = V4L2_PIX_FMT_NV16, |
---|
108 | 95 | .depth = { 16 }, |
---|
109 | 96 | .color = GSC_YUV422, |
---|
.. | .. |
---|
112 | 99 | .num_planes = 1, |
---|
113 | 100 | .num_comp = 2, |
---|
114 | 101 | }, { |
---|
115 | | - .name = "YUV 4:2:2 non-contig, Y/CbCr", |
---|
116 | 102 | .pixelformat = V4L2_PIX_FMT_NV16M, |
---|
117 | 103 | .depth = { 8, 8 }, |
---|
118 | 104 | .color = GSC_YUV422, |
---|
.. | .. |
---|
121 | 107 | .num_planes = 2, |
---|
122 | 108 | .num_comp = 2, |
---|
123 | 109 | }, { |
---|
124 | | - .name = "YUV 4:2:2 planar, Y/CrCb", |
---|
125 | 110 | .pixelformat = V4L2_PIX_FMT_NV61, |
---|
126 | 111 | .depth = { 16 }, |
---|
127 | 112 | .color = GSC_YUV422, |
---|
.. | .. |
---|
130 | 115 | .num_planes = 1, |
---|
131 | 116 | .num_comp = 2, |
---|
132 | 117 | }, { |
---|
133 | | - .name = "YUV 4:2:2 non-contig, Y/CrCb", |
---|
134 | 118 | .pixelformat = V4L2_PIX_FMT_NV61M, |
---|
135 | 119 | .depth = { 8, 8 }, |
---|
136 | 120 | .color = GSC_YUV422, |
---|
.. | .. |
---|
139 | 123 | .num_planes = 2, |
---|
140 | 124 | .num_comp = 2, |
---|
141 | 125 | }, { |
---|
142 | | - .name = "YUV 4:2:0 planar, YCbCr", |
---|
143 | 126 | .pixelformat = V4L2_PIX_FMT_YUV420, |
---|
144 | 127 | .depth = { 12 }, |
---|
145 | 128 | .color = GSC_YUV420, |
---|
.. | .. |
---|
148 | 131 | .num_planes = 1, |
---|
149 | 132 | .num_comp = 3, |
---|
150 | 133 | }, { |
---|
151 | | - .name = "YUV 4:2:0 planar, YCrCb", |
---|
152 | 134 | .pixelformat = V4L2_PIX_FMT_YVU420, |
---|
153 | 135 | .depth = { 12 }, |
---|
154 | 136 | .color = GSC_YUV420, |
---|
.. | .. |
---|
158 | 140 | .num_comp = 3, |
---|
159 | 141 | |
---|
160 | 142 | }, { |
---|
161 | | - .name = "YUV 4:2:0 planar, Y/CbCr", |
---|
162 | 143 | .pixelformat = V4L2_PIX_FMT_NV12, |
---|
163 | 144 | .depth = { 12 }, |
---|
164 | 145 | .color = GSC_YUV420, |
---|
.. | .. |
---|
167 | 148 | .num_planes = 1, |
---|
168 | 149 | .num_comp = 2, |
---|
169 | 150 | }, { |
---|
170 | | - .name = "YUV 4:2:0 planar, Y/CrCb", |
---|
171 | 151 | .pixelformat = V4L2_PIX_FMT_NV21, |
---|
172 | 152 | .depth = { 12 }, |
---|
173 | 153 | .color = GSC_YUV420, |
---|
.. | .. |
---|
176 | 156 | .num_planes = 1, |
---|
177 | 157 | .num_comp = 2, |
---|
178 | 158 | }, { |
---|
179 | | - .name = "YUV 4:2:0 non-contig. 2p, Y/CrCb", |
---|
180 | 159 | .pixelformat = V4L2_PIX_FMT_NV21M, |
---|
181 | 160 | .depth = { 8, 4 }, |
---|
182 | 161 | .color = GSC_YUV420, |
---|
.. | .. |
---|
185 | 164 | .num_planes = 2, |
---|
186 | 165 | .num_comp = 2, |
---|
187 | 166 | }, { |
---|
188 | | - .name = "YUV 4:2:0 non-contig. 2p, Y/CbCr", |
---|
189 | 167 | .pixelformat = V4L2_PIX_FMT_NV12M, |
---|
190 | 168 | .depth = { 8, 4 }, |
---|
191 | 169 | .color = GSC_YUV420, |
---|
.. | .. |
---|
194 | 172 | .num_planes = 2, |
---|
195 | 173 | .num_comp = 2, |
---|
196 | 174 | }, { |
---|
197 | | - .name = "YUV 4:2:0 non-contig. 3p, Y/Cb/Cr", |
---|
198 | 175 | .pixelformat = V4L2_PIX_FMT_YUV420M, |
---|
199 | 176 | .depth = { 8, 2, 2 }, |
---|
200 | 177 | .color = GSC_YUV420, |
---|
.. | .. |
---|
203 | 180 | .num_planes = 3, |
---|
204 | 181 | .num_comp = 3, |
---|
205 | 182 | }, { |
---|
206 | | - .name = "YUV 4:2:0 non-contig. 3p, Y/Cr/Cb", |
---|
207 | 183 | .pixelformat = V4L2_PIX_FMT_YVU420M, |
---|
208 | 184 | .depth = { 8, 2, 2 }, |
---|
209 | 185 | .color = GSC_YUV420, |
---|
.. | .. |
---|
212 | 188 | .num_planes = 3, |
---|
213 | 189 | .num_comp = 3, |
---|
214 | 190 | }, { |
---|
215 | | - .name = "YUV 4:2:0 n.c. 2p, Y/CbCr tiled", |
---|
216 | 191 | .pixelformat = V4L2_PIX_FMT_NV12MT_16X16, |
---|
217 | 192 | .depth = { 8, 4 }, |
---|
218 | 193 | .color = GSC_YUV420, |
---|
.. | .. |
---|
331 | 306 | } |
---|
332 | 307 | } |
---|
333 | 308 | |
---|
334 | | -int gsc_enum_fmt_mplane(struct v4l2_fmtdesc *f) |
---|
| 309 | +int gsc_enum_fmt(struct v4l2_fmtdesc *f) |
---|
335 | 310 | { |
---|
336 | 311 | const struct gsc_fmt *fmt; |
---|
337 | 312 | |
---|
.. | .. |
---|
339 | 314 | if (!fmt) |
---|
340 | 315 | return -EINVAL; |
---|
341 | 316 | |
---|
342 | | - strlcpy(f->description, fmt->name, sizeof(f->description)); |
---|
343 | 317 | f->pixelformat = fmt->pixelformat; |
---|
344 | 318 | |
---|
345 | 319 | return 0; |
---|
.. | .. |
---|
541 | 515 | } |
---|
542 | 516 | } |
---|
543 | 517 | |
---|
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) |
---|
558 | 519 | { |
---|
559 | 520 | struct gsc_frame *f; |
---|
560 | 521 | struct gsc_dev *gsc = ctx->gsc_dev; |
---|
.. | .. |
---|
562 | 523 | u32 mod_x = 0, mod_y = 0, tmp_w, tmp_h; |
---|
563 | 524 | u32 min_w, min_h, max_w, max_h; |
---|
564 | 525 | |
---|
565 | | - if (cr->c.top < 0 || cr->c.left < 0) { |
---|
| 526 | + if (s->r.top < 0 || s->r.left < 0) { |
---|
566 | 527 | pr_err("doesn't support negative values for top & left\n"); |
---|
567 | 528 | return -EINVAL; |
---|
568 | 529 | } |
---|
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); |
---|
570 | 531 | |
---|
571 | | - if (cr->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) |
---|
| 532 | + if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) |
---|
572 | 533 | f = &ctx->d_frame; |
---|
573 | | - else if (cr->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) |
---|
| 534 | + else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) |
---|
574 | 535 | f = &ctx->s_frame; |
---|
575 | 536 | else |
---|
576 | 537 | return -EINVAL; |
---|
577 | 538 | |
---|
578 | 539 | max_w = f->f_width; |
---|
579 | 540 | 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; |
---|
582 | 543 | |
---|
583 | | - if (V4L2_TYPE_IS_OUTPUT(cr->type)) { |
---|
| 544 | + if (V4L2_TYPE_IS_OUTPUT(s->type)) { |
---|
584 | 545 | if ((is_yuv422(f->fmt->color) && f->fmt->num_comp == 1) || |
---|
585 | 546 | is_rgb(f->fmt->color)) |
---|
586 | 547 | min_w = 32; |
---|
.. | .. |
---|
602 | 563 | max_h = f->f_width; |
---|
603 | 564 | min_w = variant->pix_min->target_rot_en_w; |
---|
604 | 565 | 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; |
---|
607 | 568 | } else { |
---|
608 | 569 | min_w = variant->pix_min->target_rot_dis_w; |
---|
609 | 570 | min_h = variant->pix_min->target_rot_dis_h; |
---|
.. | .. |
---|
616 | 577 | v4l_bound_align_image(&tmp_w, min_w, max_w, mod_x, |
---|
617 | 578 | &tmp_h, min_h, max_h, mod_y, 0); |
---|
618 | 579 | |
---|
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)) |
---|
622 | 583 | gsc_check_crop_change(tmp_h, tmp_w, |
---|
623 | | - &cr->c.width, &cr->c.height); |
---|
| 584 | + &s->r.width, &s->r.height); |
---|
624 | 585 | else |
---|
625 | 586 | gsc_check_crop_change(tmp_w, tmp_h, |
---|
626 | | - &cr->c.width, &cr->c.height); |
---|
| 587 | + &s->r.width, &s->r.height); |
---|
627 | 588 | |
---|
628 | 589 | |
---|
629 | 590 | /* adjust left/top if cropping rectangle is out of bounds */ |
---|
630 | 591 | /* 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; |
---|
635 | 596 | |
---|
636 | 597 | 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; |
---|
639 | 600 | |
---|
640 | 601 | 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); |
---|
642 | 603 | |
---|
643 | 604 | return 0; |
---|
644 | 605 | } |
---|