Skip to content

Commit fd62bd4

Browse files
Rahi374pinchartl
authored andcommitted
media: rkisp1: Add YC swap capability
The ISP version in the i.MX8MP has an MI_OUTPUT_ALIGN_FORMAT register that the rk3399 does not have. This register allows swapping bytes, which can be used to implement UYVY from YUYV. Add a flag to the format info in the list of formats supported by the capture v4l2 devices, and update enum_fmt and s_fmt to take it into account. To signify the presence of this feature, reuse the MAIN_STRIDE feature flag, as it is very likely that any ISP version that supports one of these two features will also support the other. Signed-off-by: Paul Elder <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Laurent Pinchart <[email protected]> Tested-by: Alexander Stein <[email protected]> Tested-by: Adam Ford <[email protected]>
1 parent da1484c commit fd62bd4

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ enum rkisp1_plane {
4747
* @fourcc: pixel format
4848
* @fmt_type: helper filed for pixel format
4949
* @uv_swap: if cb cr swapped, for yuv
50+
* @yc_swap: if y and cb/cr swapped, for yuv
5051
* @write_format: defines how YCbCr self picture data is written to memory
5152
* @output_format: defines sp output format
5253
* @mbus: the mbus code on the src resizer pad that matches the pixel format
5354
*/
5455
struct rkisp1_capture_fmt_cfg {
5556
u32 fourcc;
56-
u8 uv_swap;
57+
u32 uv_swap : 1;
58+
u32 yc_swap : 1;
5759
u32 write_format;
5860
u32 output_format;
5961
u32 mbus;
@@ -1159,10 +1161,14 @@ rkisp1_fill_pixfmt(const struct rkisp1_capture *cap,
11591161
static const struct rkisp1_capture_fmt_cfg *
11601162
rkisp1_find_fmt_cfg(const struct rkisp1_capture *cap, const u32 pixelfmt)
11611163
{
1164+
bool yc_swap_support = rkisp1_has_feature(cap->rkisp1, MAIN_STRIDE);
11621165
unsigned int i;
11631166

11641167
for (i = 0; i < cap->config->fmt_size; i++) {
1165-
if (cap->config->fmts[i].fourcc == pixelfmt)
1168+
const struct rkisp1_capture_fmt_cfg *fmt = &cap->config->fmts[i];
1169+
1170+
if (fmt->fourcc == pixelfmt &&
1171+
(!fmt->yc_swap || yc_swap_support))
11661172
return &cap->config->fmts[i];
11671173
}
11681174
return NULL;
@@ -1231,23 +1237,29 @@ static int rkisp1_enum_fmt_vid_cap_mplane(struct file *file, void *priv,
12311237
{
12321238
struct rkisp1_capture *cap = video_drvdata(file);
12331239
const struct rkisp1_capture_fmt_cfg *fmt = NULL;
1240+
bool yc_swap_support = rkisp1_has_feature(cap->rkisp1, MAIN_STRIDE);
12341241
unsigned int i, n = 0;
12351242

1236-
if (!f->mbus_code) {
1237-
if (f->index >= cap->config->fmt_size)
1238-
return -EINVAL;
1243+
if (f->index >= cap->config->fmt_size)
1244+
return -EINVAL;
12391245

1246+
if (!f->mbus_code && yc_swap_support) {
12401247
fmt = &cap->config->fmts[f->index];
12411248
f->pixelformat = fmt->fourcc;
12421249
return 0;
12431250
}
12441251

12451252
for (i = 0; i < cap->config->fmt_size; i++) {
1246-
if (cap->config->fmts[i].mbus != f->mbus_code)
1253+
fmt = &cap->config->fmts[i];
1254+
1255+
if (f->mbus_code && fmt->mbus != f->mbus_code)
1256+
continue;
1257+
1258+
if (!yc_swap_support && fmt->yc_swap)
12471259
continue;
12481260

12491261
if (n++ == f->index) {
1250-
f->pixelformat = cap->config->fmts[i].fourcc;
1262+
f->pixelformat = fmt->fourcc;
12511263
return 0;
12521264
}
12531265
}

0 commit comments

Comments
 (0)