From: Steve Longerbeam <slongerbeam@gmail.com>
To: linux-media@vger.kernel.org
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Rui Miguel Silva <rmfrfs@gmail.com>,
Steve Longerbeam <slongerbeam@gmail.com>
Subject: [PATCH v7 07/11] media: imx: utils: Introduce PIXFMT_SEL_IPU
Date: Mon, 6 Apr 2020 09:39:01 -0700 [thread overview]
Message-ID: <20200406163905.24475-8-slongerbeam@gmail.com> (raw)
In-Reply-To: <20200406163905.24475-1-slongerbeam@gmail.com>
Add a PIXFMT_SEL_IPU selection flag, to select only the IPU-internal
pixel formats, and move the single-entry IPU-internal pixel format
arrays into pixel_formats[]. imx_media_find_ipu_format() and
imx_media_enum_ipu_format() can now simply call find_format() and
enum_format().
The RGB32 format is both an IPU-internal format, and an in-memory format
via idmac channels that is supported by the IPUv3 driver, so it appears
twice in pixel_formats[], one with ipufmt=false for the in-memory format,
and again with ipufmt=true for the IPU-internal format.
Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
drivers/staging/media/imx/imx-media-utils.c | 116 +++++---------------
drivers/staging/media/imx/imx-media.h | 1 +
2 files changed, 26 insertions(+), 91 deletions(-)
diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c
index 32acece14a6f..7566e0ae5e81 100644
--- a/drivers/staging/media/imx/imx-media-utils.c
+++ b/drivers/staging/media/imx/imx-media-utils.c
@@ -53,6 +53,12 @@ static const struct imx_media_pixfmt pixel_formats[] = {
.cs = IPUV3_COLORSPACE_YUV,
.bpp = 16,
.planar = true,
+ }, {
+ .fourcc = V4L2_PIX_FMT_YUV32,
+ .codes = {MEDIA_BUS_FMT_AYUV8_1X32},
+ .cs = IPUV3_COLORSPACE_YUV,
+ .bpp = 32,
+ .ipufmt = true,
},
/*** RGB formats start here ***/
{
@@ -73,6 +79,11 @@ static const struct imx_media_pixfmt pixel_formats[] = {
.fourcc = V4L2_PIX_FMT_BGR24,
.cs = IPUV3_COLORSPACE_RGB,
.bpp = 24,
+ }, {
+ .fourcc = V4L2_PIX_FMT_XRGB32,
+ .codes = {MEDIA_BUS_FMT_ARGB8888_1X32},
+ .cs = IPUV3_COLORSPACE_RGB,
+ .bpp = 32,
}, {
.fourcc = V4L2_PIX_FMT_XRGB32,
.codes = {MEDIA_BUS_FMT_ARGB8888_1X32},
@@ -186,42 +197,24 @@ static const struct imx_media_pixfmt pixel_formats[] = {
},
};
-static const struct imx_media_pixfmt ipu_yuv_formats[] = {
- {
- .fourcc = V4L2_PIX_FMT_YUV32,
- .codes = {MEDIA_BUS_FMT_AYUV8_1X32},
- .cs = IPUV3_COLORSPACE_YUV,
- .bpp = 32,
- .ipufmt = true,
- },
-};
-
-#define NUM_IPU_YUV_FORMATS ARRAY_SIZE(ipu_yuv_formats)
-
-static const struct imx_media_pixfmt ipu_rgb_formats[] = {
- {
- .fourcc = V4L2_PIX_FMT_XRGB32,
- .codes = {MEDIA_BUS_FMT_ARGB8888_1X32},
- .cs = IPUV3_COLORSPACE_RGB,
- .bpp = 32,
- .ipufmt = true,
- },
-};
-
-#define NUM_IPU_RGB_FORMATS ARRAY_SIZE(ipu_rgb_formats)
-
static const struct imx_media_pixfmt *find_format(u32 fourcc,
u32 code,
enum imx_pixfmt_sel fmt_sel,
bool allow_non_mbus)
{
+ bool sel_ipu = fmt_sel & PIXFMT_SEL_IPU;
unsigned int i;
+ fmt_sel &= ~PIXFMT_SEL_IPU;
+
for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) {
const struct imx_media_pixfmt *fmt = &pixel_formats[i];
enum imx_pixfmt_sel sel;
unsigned int j;
+ if (sel_ipu != fmt->ipufmt)
+ continue;
+
sel = fmt->bayer ? PIXFMT_SEL_BAYER :
((fmt->cs == IPUV3_COLORSPACE_YUV) ?
PIXFMT_SEL_YUV : PIXFMT_SEL_RGB);
@@ -249,13 +242,19 @@ static int enum_format(u32 *fourcc, u32 *code, u32 index,
enum imx_pixfmt_sel fmt_sel,
bool allow_non_mbus)
{
+ bool sel_ipu = fmt_sel & PIXFMT_SEL_IPU;
unsigned int i;
+ fmt_sel &= ~PIXFMT_SEL_IPU;
+
for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) {
const struct imx_media_pixfmt *fmt = &pixel_formats[i];
enum imx_pixfmt_sel sel;
unsigned int j;
+ if (sel_ipu != fmt->ipufmt)
+ continue;
+
sel = fmt->bayer ? PIXFMT_SEL_BAYER :
((fmt->cs == IPUV3_COLORSPACE_YUV) ?
PIXFMT_SEL_YUV : PIXFMT_SEL_RGB);
@@ -317,79 +316,14 @@ EXPORT_SYMBOL_GPL(imx_media_enum_mbus_format);
const struct imx_media_pixfmt *
imx_media_find_ipu_format(u32 code, enum imx_pixfmt_sel fmt_sel)
{
- const struct imx_media_pixfmt *array, *fmt, *ret = NULL;
- u32 array_size;
- int i, j;
-
- fmt_sel &= ~PIXFMT_SEL_BAYER;
-
- switch (fmt_sel) {
- case PIXFMT_SEL_YUV:
- array_size = NUM_IPU_YUV_FORMATS;
- array = ipu_yuv_formats;
- break;
- case PIXFMT_SEL_RGB:
- array_size = NUM_IPU_RGB_FORMATS;
- array = ipu_rgb_formats;
- break;
- case PIXFMT_SEL_YUV_RGB:
- array_size = NUM_IPU_YUV_FORMATS + NUM_IPU_RGB_FORMATS;
- array = ipu_yuv_formats;
- break;
- default:
- return NULL;
- }
-
- for (i = 0; i < array_size; i++) {
- if (fmt_sel == PIXFMT_SEL_YUV_RGB && i >= NUM_IPU_YUV_FORMATS)
- fmt = &ipu_rgb_formats[i - NUM_IPU_YUV_FORMATS];
- else
- fmt = &array[i];
-
- for (j = 0; code && fmt->codes[j]; j++) {
- if (code == fmt->codes[j]) {
- ret = fmt;
- goto out;
- }
- }
- }
-
-out:
- return ret;
+ return find_format(0, code, fmt_sel | PIXFMT_SEL_IPU, false);
}
EXPORT_SYMBOL_GPL(imx_media_find_ipu_format);
int imx_media_enum_ipu_format(u32 *code, u32 index,
enum imx_pixfmt_sel fmt_sel)
{
- fmt_sel &= ~PIXFMT_SEL_BAYER;
-
- switch (fmt_sel) {
- case PIXFMT_SEL_YUV:
- if (index >= NUM_IPU_YUV_FORMATS)
- return -EINVAL;
- *code = ipu_yuv_formats[index].codes[0];
- break;
- case PIXFMT_SEL_RGB:
- if (index >= NUM_IPU_RGB_FORMATS)
- return -EINVAL;
- *code = ipu_rgb_formats[index].codes[0];
- break;
- case PIXFMT_SEL_YUV_RGB:
- if (index >= NUM_IPU_YUV_FORMATS + NUM_IPU_RGB_FORMATS)
- return -EINVAL;
- if (index >= NUM_IPU_YUV_FORMATS) {
- index -= NUM_IPU_YUV_FORMATS;
- *code = ipu_rgb_formats[index].codes[0];
- } else {
- *code = ipu_yuv_formats[index].codes[0];
- }
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
+ return enum_format(NULL, code, index, fmt_sel | PIXFMT_SEL_IPU, false);
}
EXPORT_SYMBOL_GPL(imx_media_enum_ipu_format);
diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h
index ac7c521d8148..c61592750729 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -83,6 +83,7 @@ enum imx_pixfmt_sel {
PIXFMT_SEL_YUV = BIT(0), /* select YUV formats */
PIXFMT_SEL_RGB = BIT(1), /* select RGB formats */
PIXFMT_SEL_BAYER = BIT(2), /* select BAYER formats */
+ PIXFMT_SEL_IPU = BIT(3), /* select IPU-internal formats */
PIXFMT_SEL_YUV_RGB = PIXFMT_SEL_YUV | PIXFMT_SEL_RGB,
PIXFMT_SEL_ANY = PIXFMT_SEL_YUV | PIXFMT_SEL_RGB | PIXFMT_SEL_BAYER,
};
--
2.17.1
next prev parent reply other threads:[~2020-04-06 16:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-06 16:38 [PATCH v7 00/11] media: imx: Miscellaneous format-related cleanups Steve Longerbeam
2020-04-06 16:38 ` [PATCH v7 01/11] media: imx: utils: fix and simplify pixel format enumeration Steve Longerbeam
2020-04-09 15:38 ` Fabio Estevam
2020-04-14 21:00 ` Steve Longerbeam
2020-04-14 21:20 ` [PATCH v7.1 " Steve Longerbeam
2020-04-06 16:38 ` [PATCH v7 02/11] media: imx: utils: fix media bus " Steve Longerbeam
2020-04-14 21:23 ` [PATCH v7.1 " Steve Longerbeam
2020-04-06 16:38 ` [PATCH v7 03/11] media: imx: utils: Inline init_mbus_colorimetry() in its caller Steve Longerbeam
2020-04-06 16:38 ` [PATCH v7 04/11] media: imx: utils: Handle Bayer format lookup through a selection flag Steve Longerbeam
2020-04-21 11:12 ` Mauro Carvalho Chehab
2020-04-06 16:38 ` [PATCH v7 05/11] media: imx: Fix some pixel format selections Steve Longerbeam
2020-04-06 17:13 ` Laurent Pinchart
2020-04-06 16:39 ` [PATCH v7 06/11] media: imx: utils: Rename pixel format selection enumeration Steve Longerbeam
2020-04-06 16:39 ` Steve Longerbeam [this message]
2020-04-06 16:39 ` [PATCH v7 08/11] media: imx: utils: Make imx_media_pixfmt handle variable number of codes Steve Longerbeam
2020-04-06 16:39 ` [PATCH v7 09/11] media: imx: utils: Split find|enum_format into fourcc and mbus functions Steve Longerbeam
2020-04-06 16:39 ` [PATCH v7 10/11] media: imx: utils: Rename format lookup and enumeration functions Steve Longerbeam
2020-04-06 16:39 ` [PATCH v7 11/11] media: imx: utils: Constify some mbus and ipu_image arguments Steve Longerbeam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200406163905.24475-8-slongerbeam@gmail.com \
--to=slongerbeam@gmail.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=rmfrfs@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.