Commit 2d35c1ff authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

media: staging: media: imx: imx7-media-csi: Drop YUV/RGB/BAYER format selectors

All the format lookup functions are called with a ANY selector, drop
selector support.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
Tested-by: default avatarAlexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 539a9859
...@@ -809,17 +809,6 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data) ...@@ -809,17 +809,6 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data)
#define IMX_BUS_FMTS(fmt...) (const u32[]) {fmt, 0} #define IMX_BUS_FMTS(fmt...) (const u32[]) {fmt, 0}
enum imx7_csi_pixfmt_sel {
IMX7_CSI_PIXFMT_SEL_YUV = BIT(0), /* select YUV formats */
IMX7_CSI_PIXFMT_SEL_RGB = BIT(1), /* select RGB formats */
IMX7_CSI_PIXFMT_SEL_BAYER = BIT(2), /* select BAYER formats */
IMX7_CSI_PIXFMT_SEL_YUV_RGB = IMX7_CSI_PIXFMT_SEL_YUV
| IMX7_CSI_PIXFMT_SEL_RGB,
IMX7_CSI_PIXFMT_SEL_ANY = IMX7_CSI_PIXFMT_SEL_YUV
| IMX7_CSI_PIXFMT_SEL_RGB
| IMX7_CSI_PIXFMT_SEL_BAYER,
};
/* /*
* List of supported pixel formats for the subdevs. Keep MEDIA_BUS_FMT_UYVY8_2X8 * List of supported pixel formats for the subdevs. Keep MEDIA_BUS_FMT_UYVY8_2X8
* first to match IMX7_CSI_DEF_MBUS_CODE. * first to match IMX7_CSI_DEF_MBUS_CODE.
...@@ -928,25 +917,16 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { ...@@ -928,25 +917,16 @@ static const struct imx7_csi_pixfmt pixel_formats[] = {
/* /*
* Search in the pixel_formats[] array for an entry with the given fourcc * Search in the pixel_formats[] array for an entry with the given fourcc
* that matches the requested selection criteria and return it. * return it.
*
* @fourcc: Search for an entry with the given fourcc pixel format.
* @fmt_sel: Allow entries only with the given selection criteria.
*/ */
static const struct imx7_csi_pixfmt * static const struct imx7_csi_pixfmt *imx7_csi_find_pixel_format(u32 fourcc)
imx7_csi_find_pixel_format(u32 fourcc, enum imx7_csi_pixfmt_sel fmt_sel)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) {
const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; const struct imx7_csi_pixfmt *fmt = &pixel_formats[i];
enum imx7_csi_pixfmt_sel sel;
sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER
: (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV :
IMX7_CSI_PIXFMT_SEL_RGB);
if ((fmt_sel & sel) && fmt->fourcc == fourcc) if (fmt->fourcc == fourcc)
return fmt; return fmt;
} }
...@@ -955,26 +935,17 @@ imx7_csi_find_pixel_format(u32 fourcc, enum imx7_csi_pixfmt_sel fmt_sel) ...@@ -955,26 +935,17 @@ imx7_csi_find_pixel_format(u32 fourcc, enum imx7_csi_pixfmt_sel fmt_sel)
/* /*
* Search in the pixel_formats[] array for an entry with the given media * Search in the pixel_formats[] array for an entry with the given media
* bus code that matches the requested selection criteria and return it. * bus code and return it.
*
* @code: Search for an entry with the given media-bus code.
* @fmt_sel: Allow entries only with the given selection criteria.
*/ */
static const struct imx7_csi_pixfmt * static const struct imx7_csi_pixfmt *imx7_csi_find_mbus_format(u32 code)
imx7_csi_find_mbus_format(u32 code, enum imx7_csi_pixfmt_sel fmt_sel)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) {
const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; const struct imx7_csi_pixfmt *fmt = &pixel_formats[i];
enum imx7_csi_pixfmt_sel sel;
unsigned int j; unsigned int j;
sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER if (!fmt->codes)
: (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV :
IMX7_CSI_PIXFMT_SEL_RGB);
if (!(fmt_sel & sel) || !fmt->codes)
continue; continue;
for (j = 0; fmt->codes[j]; j++) { for (j = 0; fmt->codes[j]; j++) {
...@@ -994,27 +965,15 @@ imx7_csi_find_mbus_format(u32 code, enum imx7_csi_pixfmt_sel fmt_sel) ...@@ -994,27 +965,15 @@ imx7_csi_find_mbus_format(u32 code, enum imx7_csi_pixfmt_sel fmt_sel)
* @fourcc: The returned fourcc that matches the search criteria at * @fourcc: The returned fourcc that matches the search criteria at
* the requested match index. * the requested match index.
* @index: The requested match index. * @index: The requested match index.
* @fmt_sel: Include in the enumeration entries with the given selection
* criteria.
* @code: If non-zero, only include in the enumeration entries matching this * @code: If non-zero, only include in the enumeration entries matching this
* media bus code. * media bus code.
*/ */
static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index, static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index, u32 code)
enum imx7_csi_pixfmt_sel fmt_sel,
u32 code)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) {
const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; const struct imx7_csi_pixfmt *fmt = &pixel_formats[i];
enum imx7_csi_pixfmt_sel sel;
sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER
: (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV :
IMX7_CSI_PIXFMT_SEL_RGB);
if (!(fmt_sel & sel))
continue;
/* /*
* If a media bus code is specified, only consider formats that * If a media bus code is specified, only consider formats that
...@@ -1054,24 +1013,16 @@ static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index, ...@@ -1054,24 +1013,16 @@ static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index,
* @code: The returned media-bus code that matches the search criteria at * @code: The returned media-bus code that matches the search criteria at
* the requested match index. * the requested match index.
* @index: The requested match index. * @index: The requested match index.
* @fmt_sel: Include in the enumeration entries with the given selection
* criteria.
*/ */
static int imx7_csi_enum_mbus_formats(u32 *code, u32 index, static int imx7_csi_enum_mbus_formats(u32 *code, u32 index)
enum imx7_csi_pixfmt_sel fmt_sel)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) {
const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; const struct imx7_csi_pixfmt *fmt = &pixel_formats[i];
enum imx7_csi_pixfmt_sel sel;
unsigned int j; unsigned int j;
sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER if (!fmt->codes)
: (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV :
IMX7_CSI_PIXFMT_SEL_RGB);
if (!(fmt_sel & sel) || !fmt->codes)
continue; continue;
for (j = 0; fmt->codes[j]; j++) { for (j = 0; fmt->codes[j]; j++) {
...@@ -1100,7 +1051,7 @@ static int imx7_csi_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus, ...@@ -1100,7 +1051,7 @@ static int imx7_csi_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus,
if (code == 0) if (code == 0)
code = IMX7_CSI_DEF_MBUS_CODE; code = IMX7_CSI_DEF_MBUS_CODE;
lcc = imx7_csi_find_mbus_format(code, IMX7_CSI_PIXFMT_SEL_ANY); lcc = imx7_csi_find_mbus_format(code);
if (!lcc) if (!lcc)
return -EINVAL; return -EINVAL;
...@@ -1128,8 +1079,7 @@ static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, ...@@ -1128,8 +1079,7 @@ static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
u32 stride; u32 stride;
if (!cc) { if (!cc) {
cc = imx7_csi_find_mbus_format(mbus->code, cc = imx7_csi_find_mbus_format(mbus->code);
IMX7_CSI_PIXFMT_SEL_ANY);
if (!cc) if (!cc)
return -EINVAL; return -EINVAL;
} }
...@@ -1179,7 +1129,6 @@ static int imx7_csi_video_enum_fmt_vid_cap(struct file *file, void *fh, ...@@ -1179,7 +1129,6 @@ static int imx7_csi_video_enum_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_fmtdesc *f) struct v4l2_fmtdesc *f)
{ {
return imx7_csi_enum_pixel_formats(&f->pixelformat, f->index, return imx7_csi_enum_pixel_formats(&f->pixelformat, f->index,
IMX7_CSI_PIXFMT_SEL_ANY,
f->mbus_code); f->mbus_code);
} }
...@@ -1191,8 +1140,7 @@ static int imx7_csi_video_enum_framesizes(struct file *file, void *fh, ...@@ -1191,8 +1140,7 @@ static int imx7_csi_video_enum_framesizes(struct file *file, void *fh,
if (fsize->index > 0) if (fsize->index > 0)
return -EINVAL; return -EINVAL;
cc = imx7_csi_find_pixel_format(fsize->pixel_format, cc = imx7_csi_find_pixel_format(fsize->pixel_format);
IMX7_CSI_PIXFMT_SEL_ANY);
if (!cc) if (!cc)
return -EINVAL; return -EINVAL;
...@@ -1233,13 +1181,10 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, ...@@ -1233,13 +1181,10 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
* Find the pixel format, default to the first supported format if not * Find the pixel format, default to the first supported format if not
* found. * found.
*/ */
cc = imx7_csi_find_pixel_format(pixfmt->pixelformat, cc = imx7_csi_find_pixel_format(pixfmt->pixelformat);
IMX7_CSI_PIXFMT_SEL_ANY);
if (!cc) { if (!cc) {
imx7_csi_enum_pixel_formats(&pixfmt->pixelformat, 0, imx7_csi_enum_pixel_formats(&pixfmt->pixelformat, 0, 0);
IMX7_CSI_PIXFMT_SEL_ANY, 0); cc = imx7_csi_find_pixel_format(pixfmt->pixelformat);
cc = imx7_csi_find_pixel_format(pixfmt->pixelformat,
IMX7_CSI_PIXFMT_SEL_ANY);
} }
/* Allow IDMAC interweave but enforce field order from source. */ /* Allow IDMAC interweave but enforce field order from source. */
...@@ -1464,8 +1409,7 @@ static int imx7_csi_video_validate_fmt(struct imx7_csi *csi) ...@@ -1464,8 +1409,7 @@ static int imx7_csi_video_validate_fmt(struct imx7_csi *csi)
* Verify that the media bus code is compatible with the pixel format * Verify that the media bus code is compatible with the pixel format
* set on the video node. * set on the video node.
*/ */
cc = imx7_csi_find_mbus_format(fmt_src.format.code, cc = imx7_csi_find_mbus_format(fmt_src.format.code);
IMX7_CSI_PIXFMT_SEL_ANY);
if (!cc || csi->vdev_cc->yuv != cc->yuv) if (!cc || csi->vdev_cc->yuv != cc->yuv)
return -EPIPE; return -EPIPE;
...@@ -1639,8 +1583,7 @@ static int imx7_csi_video_init_format(struct imx7_csi *csi) ...@@ -1639,8 +1583,7 @@ static int imx7_csi_video_init_format(struct imx7_csi *csi)
csi->vdev_compose.width = fmt_src.format.width; csi->vdev_compose.width = fmt_src.format.width;
csi->vdev_compose.height = fmt_src.format.height; csi->vdev_compose.height = fmt_src.format.height;
csi->vdev_cc = imx7_csi_find_pixel_format(csi->vdev_fmt.pixelformat, csi->vdev_cc = imx7_csi_find_pixel_format(csi->vdev_fmt.pixelformat);
IMX7_CSI_PIXFMT_SEL_ANY);
return 0; return 0;
} }
...@@ -1847,8 +1790,7 @@ static int imx7_csi_enum_mbus_code(struct v4l2_subdev *sd, ...@@ -1847,8 +1790,7 @@ static int imx7_csi_enum_mbus_code(struct v4l2_subdev *sd,
switch (code->pad) { switch (code->pad) {
case IMX7_CSI_PAD_SINK: case IMX7_CSI_PAD_SINK:
ret = imx7_csi_enum_mbus_formats(&code->code, code->index, ret = imx7_csi_enum_mbus_formats(&code->code, code->index);
IMX7_CSI_PIXFMT_SEL_ANY);
break; break;
case IMX7_CSI_PAD_SRC: case IMX7_CSI_PAD_SRC:
if (code->index != 0) { if (code->index != 0) {
...@@ -1905,7 +1847,7 @@ static void imx7_csi_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt) ...@@ -1905,7 +1847,7 @@ static void imx7_csi_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt)
const struct imx7_csi_pixfmt *cc; const struct imx7_csi_pixfmt *cc;
bool is_rgb = false; bool is_rgb = false;
cc = imx7_csi_find_mbus_format(tryfmt->code, IMX7_CSI_PIXFMT_SEL_ANY); cc = imx7_csi_find_mbus_format(tryfmt->code);
if (cc && !cc->yuv) if (cc && !cc->yuv)
is_rgb = true; is_rgb = true;
...@@ -1955,8 +1897,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, ...@@ -1955,8 +1897,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi,
switch (sdformat->pad) { switch (sdformat->pad) {
case IMX7_CSI_PAD_SRC: case IMX7_CSI_PAD_SRC:
in_cc = imx7_csi_find_mbus_format(in_fmt->code, in_cc = imx7_csi_find_mbus_format(in_fmt->code);
IMX7_CSI_PIXFMT_SEL_ANY);
sdformat->format.width = in_fmt->width; sdformat->format.width = in_fmt->width;
sdformat->format.height = in_fmt->height; sdformat->format.height = in_fmt->height;
...@@ -1970,12 +1911,10 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, ...@@ -1970,12 +1911,10 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi,
sdformat->format.ycbcr_enc = in_fmt->ycbcr_enc; sdformat->format.ycbcr_enc = in_fmt->ycbcr_enc;
break; break;
case IMX7_CSI_PAD_SINK: case IMX7_CSI_PAD_SINK:
*cc = imx7_csi_find_mbus_format(sdformat->format.code, *cc = imx7_csi_find_mbus_format(sdformat->format.code);
IMX7_CSI_PIXFMT_SEL_ANY);
if (!*cc) { if (!*cc) {
code = IMX7_CSI_DEF_MBUS_CODE; code = IMX7_CSI_DEF_MBUS_CODE;
*cc = imx7_csi_find_mbus_format(code, *cc = imx7_csi_find_mbus_format(code);
IMX7_CSI_PIXFMT_SEL_ANY);
sdformat->format.code = code; sdformat->format.code = code;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment