Skip to content

Commit

Permalink
media: imx: utils: Rename pixel format selection enumeration
Browse files Browse the repository at this point in the history
After the introduction of the CS_SEL_BAYER flag, the "codespace"
pixel format selection enumeration wording no longer makes sense
(and even before, when selecting between YUV or RGB formats,
"codespace" was a misuse of the term).

Rename

- 'enum codespace_sel' to 'enum imx_pixfmt_sel'
- CS_SEL_* to PIXFMT_SEL_*
- local vars named cs_sel to fmt_sel or just sel

No functional changes.

Signed-off-by: Steve Longerbeam <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
slongerbeam authored and mchehab committed Apr 21, 2020
1 parent 3130c45 commit a7d5003
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 107 deletions.
12 changes: 7 additions & 5 deletions drivers/staging/media/imx/imx-ic-prp.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static int prp_enum_mbus_code(struct v4l2_subdev *sd,
switch (code->pad) {
case PRP_SINK_PAD:
ret = imx_media_enum_ipu_format(&code->code, code->index,
CS_SEL_YUV_RGB);
PIXFMT_SEL_YUV_RGB);
break;
case PRP_SRC_PAD_PRPENC:
case PRP_SRC_PAD_PRPVF:
Expand Down Expand Up @@ -180,10 +180,12 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
MIN_H, MAX_H, H_ALIGN, S_ALIGN);

cc = imx_media_find_ipu_format(sdformat->format.code,
CS_SEL_YUV_RGB);
PIXFMT_SEL_YUV_RGB);
if (!cc) {
imx_media_enum_ipu_format(&code, 0, CS_SEL_YUV_RGB);
cc = imx_media_find_ipu_format(code, CS_SEL_YUV_RGB);
imx_media_enum_ipu_format(&code, 0,
PIXFMT_SEL_YUV_RGB);
cc = imx_media_find_ipu_format(code,
PIXFMT_SEL_YUV_RGB);
sdformat->format.code = cc->codes[0];
}

Expand Down Expand Up @@ -438,7 +440,7 @@ static int prp_registered(struct v4l2_subdev *sd)
priv->frame_interval.denominator = 30;

/* set a default mbus format */
imx_media_enum_ipu_format(&code, 0, CS_SEL_YUV);
imx_media_enum_ipu_format(&code, 0, PIXFMT_SEL_YUV);
return imx_media_init_mbus_fmt(&priv->format_mbus, 640, 480, code,
V4L2_FIELD_NONE, NULL);
}
Expand Down
12 changes: 7 additions & 5 deletions drivers/staging/media/imx/imx-ic-prpencvf.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ static int prp_enum_mbus_code(struct v4l2_subdev *sd,
return -EINVAL;

return imx_media_enum_ipu_format(&code->code, code->index,
CS_SEL_YUV_RGB);
PIXFMT_SEL_YUV_RGB);
}

static int prp_get_fmt(struct v4l2_subdev *sd,
Expand Down Expand Up @@ -886,12 +886,14 @@ static void prp_try_fmt(struct prp_priv *priv,
{
struct v4l2_mbus_framefmt *infmt;

*cc = imx_media_find_ipu_format(sdformat->format.code, CS_SEL_YUV_RGB);
*cc = imx_media_find_ipu_format(sdformat->format.code,
PIXFMT_SEL_YUV_RGB);
if (!*cc) {
u32 code;

imx_media_enum_ipu_format(&code, 0, CS_SEL_YUV_RGB);
*cc = imx_media_find_ipu_format(code, CS_SEL_YUV_RGB);
imx_media_enum_ipu_format(&code, 0, PIXFMT_SEL_YUV_RGB);
*cc = imx_media_find_ipu_format(code, PIXFMT_SEL_YUV_RGB);

sdformat->format.code = (*cc)->codes[0];
}

Expand Down Expand Up @@ -1249,7 +1251,7 @@ static int prp_registered(struct v4l2_subdev *sd)
u32 code;

/* set a default mbus format */
imx_media_enum_ipu_format(&code, 0, CS_SEL_YUV);
imx_media_enum_ipu_format(&code, 0, PIXFMT_SEL_YUV);
for (i = 0; i < PRPENCVF_NUM_PADS; i++) {
ret = imx_media_init_mbus_fmt(&priv->format_mbus[i],
640, 480, code, V4L2_FIELD_NONE,
Expand Down
34 changes: 18 additions & 16 deletions drivers/staging/media/imx/imx-media-capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static int capture_enum_framesizes(struct file *file, void *fh,
};
int ret;

cc = imx_media_find_format(fsize->pixel_format, CS_SEL_ANY);
cc = imx_media_find_format(fsize->pixel_format, PIXFMT_SEL_ANY);
if (!cc)
return -EINVAL;

Expand Down Expand Up @@ -133,7 +133,7 @@ static int capture_enum_frameintervals(struct file *file, void *fh,
};
int ret;

cc = imx_media_find_format(fival->pixel_format, CS_SEL_ANY);
cc = imx_media_find_format(fival->pixel_format, PIXFMT_SEL_ANY);
if (!cc)
return -EINVAL;

Expand Down Expand Up @@ -168,17 +168,18 @@ static int capture_enum_fmt_vid_cap(struct file *file, void *fh,
}

cc_src = imx_media_find_ipu_format(fmt_src.format.code,
CS_SEL_YUV_RGB);
PIXFMT_SEL_YUV_RGB);
if (cc_src) {
u32 cs_sel = (cc_src->cs == IPUV3_COLORSPACE_YUV) ?
CS_SEL_YUV : CS_SEL_RGB;
enum imx_pixfmt_sel fmt_sel =
(cc_src->cs == IPUV3_COLORSPACE_YUV) ?
PIXFMT_SEL_YUV : PIXFMT_SEL_RGB;

ret = imx_media_enum_format(&fourcc, f->index, cs_sel);
ret = imx_media_enum_format(&fourcc, f->index, fmt_sel);
if (ret)
return ret;
} else {
cc_src = imx_media_find_mbus_format(fmt_src.format.code,
CS_SEL_ANY);
PIXFMT_SEL_ANY);
if (WARN_ON(!cc_src))
return -EINVAL;

Expand Down Expand Up @@ -211,22 +212,23 @@ static int __capture_try_fmt_vid_cap(struct capture_priv *priv,
const struct imx_media_pixfmt *cc, *cc_src;

cc_src = imx_media_find_ipu_format(fmt_src->format.code,
CS_SEL_YUV_RGB);
PIXFMT_SEL_YUV_RGB);
if (cc_src) {
u32 fourcc, cs_sel;
enum imx_pixfmt_sel fmt_sel;
u32 fourcc;

cs_sel = (cc_src->cs == IPUV3_COLORSPACE_YUV) ?
CS_SEL_YUV : CS_SEL_RGB;
fmt_sel = (cc_src->cs == IPUV3_COLORSPACE_YUV) ?
PIXFMT_SEL_YUV : PIXFMT_SEL_RGB;
fourcc = f->fmt.pix.pixelformat;

cc = imx_media_find_format(fourcc, cs_sel);
cc = imx_media_find_format(fourcc, fmt_sel);
if (!cc) {
imx_media_enum_format(&fourcc, 0, cs_sel);
cc = imx_media_find_format(fourcc, cs_sel);
imx_media_enum_format(&fourcc, 0, fmt_sel);
cc = imx_media_find_format(fourcc, fmt_sel);
}
} else {
cc_src = imx_media_find_mbus_format(fmt_src->format.code,
CS_SEL_ANY);
PIXFMT_SEL_ANY);
if (WARN_ON(!cc_src))
return -EINVAL;

Expand Down Expand Up @@ -792,7 +794,7 @@ int imx_media_capture_device_register(struct imx_media_video_dev *vdev)
vdev->compose.width = fmt_src.format.width;
vdev->compose.height = fmt_src.format.height;
vdev->cc = imx_media_find_format(vdev->fmt.fmt.pix.pixelformat,
CS_SEL_ANY);
PIXFMT_SEL_ANY);

v4l2_info(sd, "Registered %s as /dev/%s\n", vfd->name,
video_device_node_name(vfd));
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/media/imx/imx-media-csc-scaler.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static int ipu_csc_scaler_enum_fmt(struct file *file, void *fh,
u32 fourcc;
int ret;

ret = imx_media_enum_format(&fourcc, f->index, CS_SEL_YUV_RGB);
ret = imx_media_enum_format(&fourcc, f->index, PIXFMT_SEL_YUV_RGB);
if (ret)
return ret;

Expand Down
35 changes: 20 additions & 15 deletions drivers/staging/media/imx/imx-media-csi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,12 +1234,12 @@ static int csi_enum_mbus_code(struct v4l2_subdev *sd,
mutex_lock(&priv->lock);

infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, code->which);
incc = imx_media_find_mbus_format(infmt->code, CS_SEL_ANY);
incc = imx_media_find_mbus_format(infmt->code, PIXFMT_SEL_ANY);

switch (code->pad) {
case CSI_SINK_PAD:
ret = imx_media_enum_mbus_format(&code->code, code->index,
CS_SEL_ANY);
PIXFMT_SEL_ANY);
break;
case CSI_SRC_PAD_DIRECT:
case CSI_SRC_PAD_IDMAC:
Expand All @@ -1256,11 +1256,13 @@ static int csi_enum_mbus_code(struct v4l2_subdev *sd,
}
code->code = infmt->code;
} else {
u32 cs_sel = (incc->cs == IPUV3_COLORSPACE_YUV) ?
CS_SEL_YUV : CS_SEL_RGB;
enum imx_pixfmt_sel fmt_sel =
(incc->cs == IPUV3_COLORSPACE_YUV) ?
PIXFMT_SEL_YUV : PIXFMT_SEL_RGB;

ret = imx_media_enum_ipu_format(&code->code,
code->index,
cs_sel);
fmt_sel);
}
break;
default:
Expand Down Expand Up @@ -1433,7 +1435,7 @@ static void csi_try_fmt(struct csi_priv *priv,
switch (sdformat->pad) {
case CSI_SRC_PAD_DIRECT:
case CSI_SRC_PAD_IDMAC:
incc = imx_media_find_mbus_format(infmt->code, CS_SEL_ANY);
incc = imx_media_find_mbus_format(infmt->code, PIXFMT_SEL_ANY);

sdformat->format.width = compose->width;
sdformat->format.height = compose->height;
Expand All @@ -1442,14 +1444,15 @@ static void csi_try_fmt(struct csi_priv *priv,
sdformat->format.code = infmt->code;
*cc = incc;
} else {
u32 cs_sel = (incc->cs == IPUV3_COLORSPACE_YUV) ?
CS_SEL_YUV : CS_SEL_RGB;
enum imx_pixfmt_sel fmt_sel =
(incc->cs == IPUV3_COLORSPACE_YUV) ?
PIXFMT_SEL_YUV : PIXFMT_SEL_RGB;

*cc = imx_media_find_ipu_format(sdformat->format.code,
cs_sel);
fmt_sel);
if (!*cc) {
imx_media_enum_ipu_format(&code, 0, cs_sel);
*cc = imx_media_find_ipu_format(code, cs_sel);
imx_media_enum_ipu_format(&code, 0, fmt_sel);
*cc = imx_media_find_ipu_format(code, fmt_sel);
sdformat->format.code = (*cc)->codes[0];
}
}
Expand All @@ -1469,10 +1472,12 @@ static void csi_try_fmt(struct csi_priv *priv,
MIN_H, MAX_H, H_ALIGN, S_ALIGN);

*cc = imx_media_find_mbus_format(sdformat->format.code,
CS_SEL_ANY);
PIXFMT_SEL_ANY);
if (!*cc) {
imx_media_enum_mbus_format(&code, 0, CS_SEL_YUV_RGB);
*cc = imx_media_find_mbus_format(code, CS_SEL_YUV_RGB);
imx_media_enum_mbus_format(&code, 0,
PIXFMT_SEL_YUV_RGB);
*cc = imx_media_find_mbus_format(code,
PIXFMT_SEL_YUV_RGB);
sdformat->format.code = (*cc)->codes[0];
}

Expand Down Expand Up @@ -1758,7 +1763,7 @@ static int csi_registered(struct v4l2_subdev *sd)
for (i = 0; i < CSI_NUM_PADS; i++) {
code = 0;
if (i != CSI_SINK_PAD)
imx_media_enum_ipu_format(&code, 0, CS_SEL_YUV);
imx_media_enum_ipu_format(&code, 0, PIXFMT_SEL_YUV);

/* set a default mbus format */
ret = imx_media_init_mbus_fmt(&priv->format_mbus[i],
Expand Down
Loading

0 comments on commit a7d5003

Please sign in to comment.