* [PATCHv3 2/4] media: imx: Store the type of hardware implementation
2021-10-19 12:13 [PATCHv3 1/4] media: imx: Remove unused functions Dorota Czaplejewicz
@ 2021-10-19 12:13 ` Dorota Czaplejewicz
2021-10-19 12:14 ` [PATCHv3 3/4] media: imx: Forward " Dorota Czaplejewicz
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Dorota Czaplejewicz @ 2021-10-19 12:13 UTC (permalink / raw)
To: Steve Longerbeam, Philipp Zabel, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
linux-media, linux-staging, linux-arm-kernel, linux-kernel,
kernel, phone-devel
[-- Attachment #1: Type: text/plain, Size: 4623 bytes --]
The driver covers i.MX5/6, as well as i.MX7/8 hardware.
Those implementations differ, e.g. in the sizes of buffers they accept.
Some functionality should be abstracted, and storing type achieves that.
Signed-off-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>
---
drivers/staging/media/imx/imx-ic-prpencvf.c | 3 ++-
drivers/staging/media/imx/imx-media-capture.c | 5 ++++-
drivers/staging/media/imx/imx-media-csi.c | 3 ++-
drivers/staging/media/imx/imx-media.h | 8 +++++++-
drivers/staging/media/imx/imx7-media-csi.c | 3 ++-
5 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c
index d990553de87b..e06f5fbe5174 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -1265,7 +1265,8 @@ static int prp_registered(struct v4l2_subdev *sd)
priv->vdev = imx_media_capture_device_init(ic_priv->ipu_dev,
&ic_priv->sd,
- PRPENCVF_SRC_PAD, true);
+ PRPENCVF_SRC_PAD, true,
+ DEVICE_TYPE_IMX56);
if (IS_ERR(priv->vdev))
return PTR_ERR(priv->vdev);
diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
index 93ba09236010..65dc95a48ecc 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -34,6 +34,7 @@ struct capture_priv {
struct imx_media_video_dev vdev; /* Video device */
struct media_pad vdev_pad; /* Video device pad */
+ enum imx_media_device_type type; /* Type of hardware implementation */
struct v4l2_subdev *src_sd; /* Source subdev */
int src_sd_pad; /* Source subdev pad */
@@ -957,7 +958,8 @@ EXPORT_SYMBOL_GPL(imx_media_capture_device_unregister);
struct imx_media_video_dev *
imx_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd,
- int pad, bool legacy_api)
+ int pad, bool legacy_api,
+ enum imx_media_device_type type)
{
struct capture_priv *priv;
struct video_device *vfd;
@@ -972,6 +974,7 @@ imx_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd,
priv->src_sd_pad = pad;
priv->dev = dev;
priv->legacy_api = legacy_api;
+ priv->type = type;
mutex_init(&priv->mutex);
INIT_LIST_HEAD(&priv->ready_q);
diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
index 6a94fff49bf6..b6758c3787c7 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1794,7 +1794,8 @@ static int csi_registered(struct v4l2_subdev *sd)
}
priv->vdev = imx_media_capture_device_init(priv->sd.dev, &priv->sd,
- CSI_SRC_PAD_IDMAC, true);
+ CSI_SRC_PAD_IDMAC, true,
+ DEVICE_TYPE_IMX56);
if (IS_ERR(priv->vdev)) {
ret = PTR_ERR(priv->vdev);
goto free_fim;
diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h
index d2a150aac6cd..08e0c94e2de1 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -96,6 +96,11 @@ enum imx_pixfmt_sel {
PIXFMT_SEL_ANY = PIXFMT_SEL_YUV | PIXFMT_SEL_RGB | PIXFMT_SEL_BAYER,
};
+enum imx_media_device_type {
+ DEVICE_TYPE_IMX56,
+ DEVICE_TYPE_IMX78,
+};
+
struct imx_media_buffer {
struct vb2_v4l2_buffer vbuf; /* v4l buffer must be first */
struct list_head list;
@@ -282,7 +287,8 @@ int imx_media_ic_unregister(struct v4l2_subdev *sd);
/* imx-media-capture.c */
struct imx_media_video_dev *
imx_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd,
- int pad, bool legacy_api);
+ int pad, bool legacy_api,
+ enum imx_media_device_type type);
void imx_media_capture_device_remove(struct imx_media_video_dev *vdev);
int imx_media_capture_device_register(struct imx_media_video_dev *vdev,
u32 link_flags);
diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c
index d7dc0d8edf50..1a11f07620e9 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -1012,7 +1012,8 @@ static int imx7_csi_registered(struct v4l2_subdev *sd)
}
csi->vdev = imx_media_capture_device_init(csi->sd.dev, &csi->sd,
- IMX7_CSI_PAD_SRC, false);
+ IMX7_CSI_PAD_SRC, false,
+ DEVICE_TYPE_IMX78);
if (IS_ERR(csi->vdev))
return PTR_ERR(csi->vdev);
--
2.31.1
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCHv3 3/4] media: imx: Forward type of hardware implementation
2021-10-19 12:13 [PATCHv3 1/4] media: imx: Remove unused functions Dorota Czaplejewicz
2021-10-19 12:13 ` [PATCHv3 2/4] media: imx: Store the type of hardware implementation Dorota Czaplejewicz
@ 2021-10-19 12:14 ` Dorota Czaplejewicz
2021-10-19 12:14 ` [PATCHv3 4/4] media: imx: Use dedicated format handler for i.MX7/8 Dorota Czaplejewicz
2021-11-03 12:32 ` [PATCHv3 1/4] media: imx: Remove unused functions Philipp Zabel
3 siblings, 0 replies; 8+ messages in thread
From: Dorota Czaplejewicz @ 2021-10-19 12:14 UTC (permalink / raw)
To: Steve Longerbeam, Philipp Zabel, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
linux-media, linux-staging, linux-arm-kernel, linux-kernel,
kernel, phone-devel
[-- Attachment #1: Type: text/plain, Size: 3904 bytes --]
Signed-off-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>
---
drivers/staging/media/imx/imx-media-capture.c | 15 +++++++++------
drivers/staging/media/imx/imx-media-utils.c | 3 ++-
drivers/staging/media/imx/imx-media.h | 3 ++-
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
index 65dc95a48ecc..7a6384b3e5e6 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -139,7 +139,8 @@ static int capture_g_fmt_vid_cap(struct file *file, void *fh,
}
static const struct imx_media_pixfmt *
-__capture_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose)
+__capture_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose,
+ enum imx_media_device_type type)
{
struct v4l2_mbus_framefmt fmt_src;
const struct imx_media_pixfmt *cc;
@@ -171,7 +172,7 @@ __capture_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose)
}
v4l2_fill_mbus_format(&fmt_src, pixfmt, 0);
- imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc);
+ imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc, type);
if (compose) {
compose->width = fmt_src.width;
@@ -184,7 +185,9 @@ __capture_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose)
static int capture_try_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_format *f)
{
- __capture_try_fmt(&f->fmt.pix, NULL);
+ struct capture_priv *priv = video_drvdata(file);
+
+ __capture_try_fmt(&f->fmt.pix, NULL, priv->type);
return 0;
}
@@ -199,7 +202,7 @@ static int capture_s_fmt_vid_cap(struct file *file, void *fh,
return -EBUSY;
}
- cc = __capture_try_fmt(&f->fmt.pix, &priv->vdev.compose);
+ cc = __capture_try_fmt(&f->fmt.pix, &priv->vdev.compose, priv->type);
priv->vdev.cc = cc;
priv->vdev.fmt = f->fmt.pix;
@@ -418,7 +421,7 @@ __capture_legacy_try_fmt(struct capture_priv *priv,
}
}
- imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src->format, cc);
+ imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src->format, cc, priv->type);
return cc;
}
@@ -889,7 +892,7 @@ static int capture_init_format(struct capture_priv *priv)
fmt_src.format.height = IMX_MEDIA_DEF_PIX_HEIGHT;
}
- imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt, &fmt_src.format, NULL);
+ imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt, &fmt_src.format, NULL, priv->type);
vdev->compose.width = fmt_src.format.width;
vdev->compose.height = fmt_src.format.height;
diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c
index afa96e05ea7f..8b5c6bcfd4fa 100644
--- a/drivers/staging/media/imx/imx-media-utils.c
+++ b/drivers/staging/media/imx/imx-media-utils.c
@@ -518,7 +518,8 @@ EXPORT_SYMBOL_GPL(imx_media_try_colorimetry);
int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
const struct v4l2_mbus_framefmt *mbus,
- const struct imx_media_pixfmt *cc)
+ const struct imx_media_pixfmt *cc,
+ enum imx_media_device_type type)
{
u32 width;
u32 stride;
diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h
index 08e0c94e2de1..79adab775739 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -203,7 +203,8 @@ void imx_media_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt,
bool ic_route);
int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
const struct v4l2_mbus_framefmt *mbus,
- const struct imx_media_pixfmt *cc);
+ const struct imx_media_pixfmt *cc,
+ enum imx_media_device_type type);
void imx_media_grp_id_to_sd_name(char *sd_name, int sz,
u32 grp_id, int ipu_id);
struct v4l2_subdev *
--
2.31.1
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCHv3 4/4] media: imx: Use dedicated format handler for i.MX7/8
2021-10-19 12:13 [PATCHv3 1/4] media: imx: Remove unused functions Dorota Czaplejewicz
2021-10-19 12:13 ` [PATCHv3 2/4] media: imx: Store the type of hardware implementation Dorota Czaplejewicz
2021-10-19 12:14 ` [PATCHv3 3/4] media: imx: Forward " Dorota Czaplejewicz
@ 2021-10-19 12:14 ` Dorota Czaplejewicz
2021-11-03 12:32 ` Philipp Zabel
2022-01-28 10:57 ` Hans Verkuil
2021-11-03 12:32 ` [PATCHv3 1/4] media: imx: Remove unused functions Philipp Zabel
3 siblings, 2 replies; 8+ messages in thread
From: Dorota Czaplejewicz @ 2021-10-19 12:14 UTC (permalink / raw)
To: Steve Longerbeam, Philipp Zabel, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
linux-media, linux-staging, linux-arm-kernel, linux-kernel,
kernel, phone-devel
[-- Attachment #1: Type: text/plain, Size: 2971 bytes --]
This splits out a format handler which takes into account
the capabilities of the i.MX7/8 video device,
as opposed to the default handler compatible with both i.MX5/6 and i.MX7/8.
Signed-off-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>
---
drivers/staging/media/imx/imx-media-utils.c | 56 +++++++++++++++++++--
1 file changed, 52 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c
index 8b5c6bcfd4fa..1ff7ec4c877a 100644
--- a/drivers/staging/media/imx/imx-media-utils.c
+++ b/drivers/staging/media/imx/imx-media-utils.c
@@ -516,10 +516,9 @@ void imx_media_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt,
}
EXPORT_SYMBOL_GPL(imx_media_try_colorimetry);
-int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
- const struct v4l2_mbus_framefmt *mbus,
- const struct imx_media_pixfmt *cc,
- enum imx_media_device_type type)
+static int imx56_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
+ const struct v4l2_mbus_framefmt *mbus,
+ const struct imx_media_pixfmt *cc)
{
u32 width;
u32 stride;
@@ -568,6 +567,55 @@ int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
return 0;
}
+
+static int imx78_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
+ const struct v4l2_mbus_framefmt *mbus,
+ const struct imx_media_pixfmt *cc)
+{
+ int ret;
+
+ if (!cc)
+ cc = imx_media_find_mbus_format(mbus->code, PIXFMT_SEL_ANY);
+
+ /*
+ * The hardware can handle line lengths divisible by 4 pixels
+ * as long as the whole buffer size ends up divisible by 8 bytes.
+ * If not, use the value of 8 pixels recommended in the datasheet.
+ */
+ ret = v4l2_fill_pixfmt(pix, cc->fourcc,
+ round_up(mbus->width, 4), mbus->height);
+ if (ret)
+ return ret;
+
+ /* Only 8bits-per-pixel formats may need to get aligned to 8 pixels,
+ * because both 10-bit and 16-bit pixels occupy 2 bytes.
+ * In those, 4-pixel aligmnent is equal to 8-byte alignment.
+ */
+ if (pix->sizeimage % 8 != 0)
+ ret = v4l2_fill_pixfmt(pix, cc->fourcc,
+ round_up(mbus->width, 8), mbus->height);
+
+ pix->colorspace = mbus->colorspace;
+ pix->xfer_func = mbus->xfer_func;
+ pix->ycbcr_enc = mbus->ycbcr_enc;
+ pix->quantization = mbus->quantization;
+ pix->field = mbus->field;
+
+ return ret;
+}
+
+int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
+ const struct v4l2_mbus_framefmt *mbus,
+ const struct imx_media_pixfmt *cc,
+ enum imx_media_device_type type) {
+ switch (type) {
+ case DEVICE_TYPE_IMX56:
+ return imx56_media_mbus_fmt_to_pix_fmt(pix, mbus, cc);
+ case DEVICE_TYPE_IMX78:
+ return imx78_media_mbus_fmt_to_pix_fmt(pix, mbus, cc);
+ }
+ return -EINVAL;
+}
EXPORT_SYMBOL_GPL(imx_media_mbus_fmt_to_pix_fmt);
void imx_media_free_dma_buf(struct device *dev,
--
2.31.1
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCHv3 4/4] media: imx: Use dedicated format handler for i.MX7/8
2021-10-19 12:14 ` [PATCHv3 4/4] media: imx: Use dedicated format handler for i.MX7/8 Dorota Czaplejewicz
@ 2021-11-03 12:32 ` Philipp Zabel
2021-11-04 9:54 ` Rui Miguel Silva
2022-01-28 10:57 ` Hans Verkuil
1 sibling, 1 reply; 8+ messages in thread
From: Philipp Zabel @ 2021-11-03 12:32 UTC (permalink / raw)
To: Dorota Czaplejewicz, Steve Longerbeam, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
linux-media, linux-staging, linux-arm-kernel, linux-kernel,
kernel, phone-devel
Cc: Rui Miguel Silva, Laurent Pinchart
On Tue, 2021-10-19 at 14:14 +0200, Dorota Czaplejewicz wrote:
> This splits out a format handler which takes into account
> the capabilities of the i.MX7/8 video device,
> as opposed to the default handler compatible with both i.MX5/6 and i.MX7/8.
>
> Signed-off-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>
Cc: Rui & Laurent
Looks sane to me, but I'd like someone with i.MX7/8 media experience to
have a look at this.
Thread at
https://lore.kernel.org/linux-media/20211019120047.827915-1-dorota.czaplejewicz@puri.sm/
regards
Philipp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCHv3 4/4] media: imx: Use dedicated format handler for i.MX7/8
2021-11-03 12:32 ` Philipp Zabel
@ 2021-11-04 9:54 ` Rui Miguel Silva
0 siblings, 0 replies; 8+ messages in thread
From: Rui Miguel Silva @ 2021-11-04 9:54 UTC (permalink / raw)
To: Philipp Zabel, Dorota Czaplejewicz, Steve Longerbeam,
Mauro Carvalho Chehab, Greg Kroah-Hartman, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
NXP Linux Team, linux-media, linux-staging, linux-arm-kernel,
linux-kernel, kernel, phone-devel
Cc: Laurent Pinchart
Hi Philipp,
On Wed Nov 3, 2021 at 12:32 PM WET, Philipp Zabel wrote:
> On Tue, 2021-10-19 at 14:14 +0200, Dorota Czaplejewicz wrote:
> > This splits out a format handler which takes into account
> > the capabilities of the i.MX7/8 video device,
> > as opposed to the default handler compatible with both i.MX5/6 and i.MX7/8.
> >
> > Signed-off-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>
>
> Cc: Rui & Laurent
>
> Looks sane to me, but I'd like someone with i.MX7/8 media experience to
> have a look at this.
Thanks for the CC, this really went off of my radar. I will try to
take a look at it, but one of the comments on the first patch:
"The use of `v4l2_fill_pixfmt` comes with the downside of breaking
10-bit Bayer formats, or at least until my other series gets accepted
(Subject: "media: Add 16-bit Bayer formats". Sorry, I don't have the
message id.)."
made me wonder if that series was already accepted? without it this
will break the warp7 setup.
------
Cheers,
Rui
>
> Thread at
> https://lore.kernel.org/linux-media/20211019120047.827915-1-dorota.czaplejewicz@puri.sm/
>
> regards
> Philipp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCHv3 4/4] media: imx: Use dedicated format handler for i.MX7/8
2021-10-19 12:14 ` [PATCHv3 4/4] media: imx: Use dedicated format handler for i.MX7/8 Dorota Czaplejewicz
2021-11-03 12:32 ` Philipp Zabel
@ 2022-01-28 10:57 ` Hans Verkuil
1 sibling, 0 replies; 8+ messages in thread
From: Hans Verkuil @ 2022-01-28 10:57 UTC (permalink / raw)
To: Dorota Czaplejewicz, Steve Longerbeam, Philipp Zabel,
Mauro Carvalho Chehab, Greg Kroah-Hartman, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
NXP Linux Team, linux-media, linux-staging, linux-arm-kernel,
linux-kernel, kernel, phone-devel
Hi Dorota,
Since I marked "media: Add 16-bit Bayer formats" as 'Changes Requested', and since
this patch appears to depend on that patch based on a comment in the first patch,
I decided to mark this series as 'Changes Requested' (except for patch 1 which has
already been accepted).
Please post a v4 if you want this in, and add the "media: Add 16-bit Bayer formats"
patch as well to that v4 series.
Thanks!
Hans
On 19/10/2021 14:14, Dorota Czaplejewicz wrote:
> This splits out a format handler which takes into account
> the capabilities of the i.MX7/8 video device,
> as opposed to the default handler compatible with both i.MX5/6 and i.MX7/8.
>
> Signed-off-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>
> ---
> drivers/staging/media/imx/imx-media-utils.c | 56 +++++++++++++++++++--
> 1 file changed, 52 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c
> index 8b5c6bcfd4fa..1ff7ec4c877a 100644
> --- a/drivers/staging/media/imx/imx-media-utils.c
> +++ b/drivers/staging/media/imx/imx-media-utils.c
> @@ -516,10 +516,9 @@ void imx_media_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt,
> }
> EXPORT_SYMBOL_GPL(imx_media_try_colorimetry);
>
> -int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
> - const struct v4l2_mbus_framefmt *mbus,
> - const struct imx_media_pixfmt *cc,
> - enum imx_media_device_type type)
> +static int imx56_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
> + const struct v4l2_mbus_framefmt *mbus,
> + const struct imx_media_pixfmt *cc)
> {
> u32 width;
> u32 stride;
> @@ -568,6 +567,55 @@ int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
>
> return 0;
> }
> +
> +static int imx78_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
> + const struct v4l2_mbus_framefmt *mbus,
> + const struct imx_media_pixfmt *cc)
> +{
> + int ret;
> +
> + if (!cc)
> + cc = imx_media_find_mbus_format(mbus->code, PIXFMT_SEL_ANY);
> +
> + /*
> + * The hardware can handle line lengths divisible by 4 pixels
> + * as long as the whole buffer size ends up divisible by 8 bytes.
> + * If not, use the value of 8 pixels recommended in the datasheet.
> + */
> + ret = v4l2_fill_pixfmt(pix, cc->fourcc,
> + round_up(mbus->width, 4), mbus->height);
> + if (ret)
> + return ret;
> +
> + /* Only 8bits-per-pixel formats may need to get aligned to 8 pixels,
> + * because both 10-bit and 16-bit pixels occupy 2 bytes.
> + * In those, 4-pixel aligmnent is equal to 8-byte alignment.
> + */
> + if (pix->sizeimage % 8 != 0)
> + ret = v4l2_fill_pixfmt(pix, cc->fourcc,
> + round_up(mbus->width, 8), mbus->height);
> +
> + pix->colorspace = mbus->colorspace;
> + pix->xfer_func = mbus->xfer_func;
> + pix->ycbcr_enc = mbus->ycbcr_enc;
> + pix->quantization = mbus->quantization;
> + pix->field = mbus->field;
> +
> + return ret;
> +}
> +
> +int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
> + const struct v4l2_mbus_framefmt *mbus,
> + const struct imx_media_pixfmt *cc,
> + enum imx_media_device_type type) {
> + switch (type) {
> + case DEVICE_TYPE_IMX56:
> + return imx56_media_mbus_fmt_to_pix_fmt(pix, mbus, cc);
> + case DEVICE_TYPE_IMX78:
> + return imx78_media_mbus_fmt_to_pix_fmt(pix, mbus, cc);
> + }
> + return -EINVAL;
> +}
> EXPORT_SYMBOL_GPL(imx_media_mbus_fmt_to_pix_fmt);
>
> void imx_media_free_dma_buf(struct device *dev,
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCHv3 1/4] media: imx: Remove unused functions
2021-10-19 12:13 [PATCHv3 1/4] media: imx: Remove unused functions Dorota Czaplejewicz
` (2 preceding siblings ...)
2021-10-19 12:14 ` [PATCHv3 4/4] media: imx: Use dedicated format handler for i.MX7/8 Dorota Czaplejewicz
@ 2021-11-03 12:32 ` Philipp Zabel
3 siblings, 0 replies; 8+ messages in thread
From: Philipp Zabel @ 2021-11-03 12:32 UTC (permalink / raw)
To: Dorota Czaplejewicz, Steve Longerbeam, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
linux-media, linux-staging, linux-arm-kernel, linux-kernel,
kernel, phone-devel
On Tue, 2021-10-19 at 14:13 +0200, Dorota Czaplejewicz wrote:
> Neither imx_media_mbus_fmt_to_ipu_image nor imx_media_ipu_image_to_mbus_fmt
> were used anywhere.
>
> Signed-off-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
regards
Philipp
^ permalink raw reply [flat|nested] 8+ messages in thread