* [PATCH v3 02/14] gpu: ipu-csi: Check for field type alternate
[not found] <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com>
@ 2018-08-01 19:12 ` Steve Longerbeam
2018-08-02 9:42 ` Philipp Zabel
2018-08-01 19:12 ` [PATCH v3 03/14] gpu: ipu-csi: Swap fields according to input/output field types Steve Longerbeam
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Steve Longerbeam @ 2018-08-01 19:12 UTC (permalink / raw)
To: linux-media
Cc: Steve Longerbeam, Philipp Zabel,
open list:DRM DRIVERS FOR FREESCALE IMX, open list
When the CSI is receiving from a bt.656 bus, include a check for
field type 'alternate' when determining whether to set CSI clock
mode to CCIR656_INTERLACED or CCIR656_PROGRESSIVE.
Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
---
drivers/gpu/ipu-v3/ipu-csi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index caa05b0..5450a2d 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -339,7 +339,8 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
break;
case V4L2_MBUS_BT656:
csicfg->ext_vsync = 0;
- if (V4L2_FIELD_HAS_BOTH(mbus_fmt->field))
+ if (V4L2_FIELD_HAS_BOTH(mbus_fmt->field) ||
+ mbus_fmt->field == V4L2_FIELD_ALTERNATE)
csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_INTERLACED;
else
csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE;
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 03/14] gpu: ipu-csi: Swap fields according to input/output field types
[not found] <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com>
2018-08-01 19:12 ` [PATCH v3 02/14] gpu: ipu-csi: Check for field type alternate Steve Longerbeam
@ 2018-08-01 19:12 ` Steve Longerbeam
2018-08-01 19:12 ` [PATCH v3 04/14] gpu: ipu-v3: Fix U/V offset macros for planar 4:2:0 Steve Longerbeam
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Steve Longerbeam @ 2018-08-01 19:12 UTC (permalink / raw)
To: linux-media
Cc: open list:STAGING SUBSYSTEM, open list:FRAMEBUFFER LAYER,
Steve Longerbeam, Bartlomiej Zolnierkiewicz, Greg Kroah-Hartman,
open list, open list:DRM DRIVERS FOR FREESCALE IMX, Philipp Zabel,
Steve Longerbeam, Mauro Carvalho Chehab
The function ipu_csi_init_interface() was inverting the F-bit for
NTSC case, in the CCIR_CODE_1/2 registers. The result being that
for NTSC bottom-top field order, the CSI would swap fields and
capture in top-bottom order.
Instead, base field swap on the field order of the input to the CSI,
and the field order of the requested output. If the input/output
fields are sequential but different, swap fields, otherwise do
not swap. This requires passing both the input and output mbus
frame formats to ipu_csi_init_interface().
Move this code to a new private function ipu_csi_set_bt_interlaced_codes()
that programs the CCIR_CODE_1/2 registers for interlaced BT.656 (and
possibly interlaced BT.1120 in the future).
When detecting input video standard from the input frame width/height,
make sure to double height if input field type is alternate, since
in that case input height only includes lines for one field.
Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
---
drivers/gpu/ipu-v3/ipu-csi.c | 133 +++++++++++++++++++++---------
drivers/staging/media/imx/imx-media-csi.c | 13 +--
include/video/imx-ipu-v3.h | 3 +-
3 files changed, 98 insertions(+), 51 deletions(-)
diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index 5450a2d..7a845c9 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -315,6 +315,15 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code)
return 0;
}
+/* translate alternate field mode based on given standard */
+static inline enum v4l2_field
+ipu_csi_translate_field(enum v4l2_field field, v4l2_std_id std)
+{
+ return (field != V4L2_FIELD_ALTERNATE) ? field :
+ ((std & V4L2_STD_525_60) ?
+ V4L2_FIELD_SEQ_BT : V4L2_FIELD_SEQ_TB);
+}
+
/*
* Fill a CSI bus config struct from mbus_config and mbus_framefmt.
*/
@@ -358,19 +367,73 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
}
}
+static int ipu_csi_set_bt_interlaced_codes(struct ipu_csi *csi,
+ struct v4l2_mbus_framefmt *infmt,
+ struct v4l2_mbus_framefmt *outfmt,
+ v4l2_std_id std)
+{
+ enum v4l2_field infield, outfield;
+ bool swap_fields;
+
+ /* get translated field type of input and output */
+ infield = ipu_csi_translate_field(infmt->field, std);
+ outfield = ipu_csi_translate_field(outfmt->field, std);
+
+ /*
+ * Write the H-V-F codes the CSI will match against the
+ * incoming data for start/end of active and blanking
+ * field intervals. If input and output field types are
+ * sequential but not the same (one is SEQ_BT and the other
+ * is SEQ_TB), swap the F-bit so that the CSI will capture
+ * field 1 lines before field 0 lines.
+ */
+ swap_fields = (V4L2_FIELD_IS_SEQUENTIAL(infield) &&
+ V4L2_FIELD_IS_SEQUENTIAL(outfield) &&
+ infield != outfield);
+
+ if (!swap_fields) {
+ /*
+ * Field0BlankEnd = 110, Field0BlankStart = 010
+ * Field0ActiveEnd = 100, Field0ActiveStart = 000
+ * Field1BlankEnd = 111, Field1BlankStart = 011
+ * Field1ActiveEnd = 101, Field1ActiveStart = 001
+ */
+ ipu_csi_write(csi, 0x40596 | CSI_CCIR_ERR_DET_EN,
+ CSI_CCIR_CODE_1);
+ ipu_csi_write(csi, 0xD07DF, CSI_CCIR_CODE_2);
+ } else {
+ dev_dbg(csi->ipu->dev, "capture field swap\n");
+
+ /* same as above but with F-bit inverted */
+ ipu_csi_write(csi, 0xD07DF | CSI_CCIR_ERR_DET_EN,
+ CSI_CCIR_CODE_1);
+ ipu_csi_write(csi, 0x40596, CSI_CCIR_CODE_2);
+ }
+
+ ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3);
+
+ return 0;
+}
+
+
int ipu_csi_init_interface(struct ipu_csi *csi,
struct v4l2_mbus_config *mbus_cfg,
- struct v4l2_mbus_framefmt *mbus_fmt)
+ struct v4l2_mbus_framefmt *infmt,
+ struct v4l2_mbus_framefmt *outfmt)
{
struct ipu_csi_bus_config cfg;
unsigned long flags;
u32 width, height, data = 0;
+ v4l2_std_id std;
+ int ret = 0;
- fill_csi_bus_cfg(&cfg, mbus_cfg, mbus_fmt);
+ fill_csi_bus_cfg(&cfg, mbus_cfg, infmt);
/* set default sensor frame width and height */
- width = mbus_fmt->width;
- height = mbus_fmt->height;
+ width = infmt->width;
+ height = infmt->height;
+ if (infmt->field == V4L2_FIELD_ALTERNATE)
+ height *= 2;
/* Set the CSI_SENS_CONF register remaining fields */
data |= cfg.data_width << CSI_SENS_CONF_DATA_WIDTH_SHIFT |
@@ -397,42 +460,33 @@ int ipu_csi_init_interface(struct ipu_csi *csi,
ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3);
break;
case IPU_CSI_CLK_MODE_CCIR656_INTERLACED:
- if (mbus_fmt->width == 720 && mbus_fmt->height == 576) {
- /*
- * PAL case
- *
- * Field0BlankEnd = 0x6, Field0BlankStart = 0x2,
- * Field0ActiveEnd = 0x4, Field0ActiveStart = 0
- * Field1BlankEnd = 0x7, Field1BlankStart = 0x3,
- * Field1ActiveEnd = 0x5, Field1ActiveStart = 0x1
- */
- height = 625; /* framelines for PAL */
-
- ipu_csi_write(csi, 0x40596 | CSI_CCIR_ERR_DET_EN,
- CSI_CCIR_CODE_1);
- ipu_csi_write(csi, 0xD07DF, CSI_CCIR_CODE_2);
- ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3);
- } else if (mbus_fmt->width == 720 && mbus_fmt->height == 480) {
- /*
- * NTSC case
- *
- * Field0BlankEnd = 0x7, Field0BlankStart = 0x3,
- * Field0ActiveEnd = 0x5, Field0ActiveStart = 0x1
- * Field1BlankEnd = 0x6, Field1BlankStart = 0x2,
- * Field1ActiveEnd = 0x4, Field1ActiveStart = 0
- */
- height = 525; /* framelines for NTSC */
-
- ipu_csi_write(csi, 0xD07DF | CSI_CCIR_ERR_DET_EN,
- CSI_CCIR_CODE_1);
- ipu_csi_write(csi, 0x40596, CSI_CCIR_CODE_2);
- ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3);
- } else {
+ std = V4L2_STD_UNKNOWN;
+ if (width == 720) {
+ switch (height) {
+ case 480:
+ std = V4L2_STD_NTSC;
+ break;
+ case 576:
+ std = V4L2_STD_PAL;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (std == V4L2_STD_UNKNOWN) {
dev_err(csi->ipu->dev,
- "Unsupported CCIR656 interlaced video mode\n");
- spin_unlock_irqrestore(&csi->lock, flags);
- return -EINVAL;
+ "Unsupported interlaced video mode\n");
+ ret = -EINVAL;
+ goto out_unlock;
}
+
+ ret = ipu_csi_set_bt_interlaced_codes(csi, infmt, outfmt, std);
+ if (ret)
+ goto out_unlock;
+
+ /* framelines for NTSC / PAL */
+ height = (std & V4L2_STD_525_60) ? 525 : 625;
break;
case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_DDR:
case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_SDR:
@@ -457,9 +511,10 @@ int ipu_csi_init_interface(struct ipu_csi *csi,
dev_dbg(csi->ipu->dev, "CSI_ACT_FRM_SIZE = 0x%08X\n",
ipu_csi_read(csi, CSI_ACT_FRM_SIZE));
+out_unlock:
spin_unlock_irqrestore(&csi->lock, flags);
- return 0;
+ return ret;
}
EXPORT_SYMBOL_GPL(ipu_csi_init_interface);
diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
index 4647206..2fdd21d 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -663,7 +663,6 @@ static int csi_setup(struct csi_priv *priv)
struct v4l2_mbus_framefmt *infmt, *outfmt;
const struct imx_media_pixfmt *incc;
struct v4l2_mbus_config mbus_cfg;
- struct v4l2_mbus_framefmt if_fmt;
struct v4l2_rect crop;
infmt = &priv->format_mbus[CSI_SINK_PAD];
@@ -676,22 +675,14 @@ static int csi_setup(struct csi_priv *priv)
priv->upstream_ep.bus.parallel.flags :
priv->upstream_ep.bus.mipi_csi2.flags;
- /*
- * we need to pass input frame to CSI interface, but
- * with translated field type from output format
- */
- if_fmt = *infmt;
- if_fmt.field = outfmt->field;
crop = priv->crop;
/*
* if cycles is set, we need to handle this over multiple cycles as
* generic/bayer data
*/
- if (is_parallel_bus(&priv->upstream_ep) && incc->cycles) {
- if_fmt.width *= incc->cycles;
+ if (is_parallel_bus(&priv->upstream_ep) && incc->cycles)
crop.width *= incc->cycles;
- }
ipu_csi_set_window(priv->csi, &crop);
@@ -699,7 +690,7 @@ static int csi_setup(struct csi_priv *priv)
priv->crop.width == 2 * priv->compose.width,
priv->crop.height == 2 * priv->compose.height);
- ipu_csi_init_interface(priv->csi, &mbus_cfg, &if_fmt);
+ ipu_csi_init_interface(priv->csi, &mbus_cfg, infmt, outfmt);
ipu_csi_set_dest(priv->csi, priv->dest);
diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
index abbad94..f44a351 100644
--- a/include/video/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -352,7 +352,8 @@ int ipu_prg_channel_configure(struct ipuv3_channel *ipu_chan,
struct ipu_csi;
int ipu_csi_init_interface(struct ipu_csi *csi,
struct v4l2_mbus_config *mbus_cfg,
- struct v4l2_mbus_framefmt *mbus_fmt);
+ struct v4l2_mbus_framefmt *infmt,
+ struct v4l2_mbus_framefmt *outfmt);
bool ipu_csi_is_interlaced(struct ipu_csi *csi);
void ipu_csi_get_window(struct ipu_csi *csi, struct v4l2_rect *w);
void ipu_csi_set_window(struct ipu_csi *csi, struct v4l2_rect *w);
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 04/14] gpu: ipu-v3: Fix U/V offset macros for planar 4:2:0
[not found] <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com>
2018-08-01 19:12 ` [PATCH v3 02/14] gpu: ipu-csi: Check for field type alternate Steve Longerbeam
2018-08-01 19:12 ` [PATCH v3 03/14] gpu: ipu-csi: Swap fields according to input/output field types Steve Longerbeam
@ 2018-08-01 19:12 ` Steve Longerbeam
2018-08-02 9:51 ` Philipp Zabel
2018-08-01 19:12 ` [PATCH v3 05/14] gpu: ipu-v3: Allow negative offsets for interlaced scanning Steve Longerbeam
2018-08-01 19:12 ` [PATCH v3 06/14] gpu: ipu-v3: Add planar support to interlaced scan Steve Longerbeam
4 siblings, 1 reply; 10+ messages in thread
From: Steve Longerbeam @ 2018-08-01 19:12 UTC (permalink / raw)
To: linux-media
Cc: Steve Longerbeam, Philipp Zabel,
open list:DRM DRIVERS FOR FREESCALE IMX, open list
The U and V offset macros for planar 4:2:0 (U_OFFSET, V_OFFSET, and
UV_OFFSET), are not correct. The height component to the offset was
calculated as:
(pix->width * y / 4)
But this does not produce correct offsets for odd values of y (luma
line #). The luma line # must be decimated by two to produce the
correct U/V line #, so the correct formula is:
(pix->width * (y / 2) / 2)
Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
---
drivers/gpu/ipu-v3/ipu-cpmem.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c
index 9f2d9ec..e68e473 100644
--- a/drivers/gpu/ipu-v3/ipu-cpmem.c
+++ b/drivers/gpu/ipu-v3/ipu-cpmem.c
@@ -530,17 +530,17 @@ static const struct ipu_rgb def_bgra_16 = {
#define Y_OFFSET(pix, x, y) ((x) + pix->width * (y))
#define U_OFFSET(pix, x, y) ((pix->width * pix->height) + \
- (pix->width * (y) / 4) + (x) / 2)
+ (pix->width * ((y) / 2) / 2) + (x) / 2)
#define V_OFFSET(pix, x, y) ((pix->width * pix->height) + \
(pix->width * pix->height / 4) + \
- (pix->width * (y) / 4) + (x) / 2)
+ (pix->width * ((y) / 2) / 2) + (x) / 2)
#define U2_OFFSET(pix, x, y) ((pix->width * pix->height) + \
(pix->width * (y) / 2) + (x) / 2)
#define V2_OFFSET(pix, x, y) ((pix->width * pix->height) + \
(pix->width * pix->height / 2) + \
(pix->width * (y) / 2) + (x) / 2)
#define UV_OFFSET(pix, x, y) ((pix->width * pix->height) + \
- (pix->width * (y) / 2) + (x))
+ (pix->width * ((y) / 2)) + (x))
#define UV2_OFFSET(pix, x, y) ((pix->width * pix->height) + \
(pix->width * y) + (x))
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 05/14] gpu: ipu-v3: Allow negative offsets for interlaced scanning
[not found] <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com>
` (2 preceding siblings ...)
2018-08-01 19:12 ` [PATCH v3 04/14] gpu: ipu-v3: Fix U/V offset macros for planar 4:2:0 Steve Longerbeam
@ 2018-08-01 19:12 ` Steve Longerbeam
2018-08-02 9:46 ` Philipp Zabel
2018-08-01 19:12 ` [PATCH v3 06/14] gpu: ipu-v3: Add planar support to interlaced scan Steve Longerbeam
4 siblings, 1 reply; 10+ messages in thread
From: Steve Longerbeam @ 2018-08-01 19:12 UTC (permalink / raw)
To: linux-media
Cc: Philipp Zabel, Steve Longerbeam,
open list:DRM DRIVERS FOR FREESCALE IMX, open list
From: Philipp Zabel <p.zabel@pengutronix.de>
The IPU also supports interlaced buffers that start with the bottom field.
To achieve this, the the base address EBA has to be increased by a stride
length and the interlace offset ILO has to be set to the negative stride.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
---
drivers/gpu/ipu-v3/ipu-cpmem.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c
index e68e473..8cd9e37 100644
--- a/drivers/gpu/ipu-v3/ipu-cpmem.c
+++ b/drivers/gpu/ipu-v3/ipu-cpmem.c
@@ -269,9 +269,20 @@ EXPORT_SYMBOL_GPL(ipu_cpmem_set_uv_offset);
void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride)
{
+ u32 ilo, sly;
+
+ if (stride < 0) {
+ stride = -stride;
+ ilo = 0x100000 - (stride / 8);
+ } else {
+ ilo = stride / 8;
+ }
+
+ sly = (stride * 2) - 1;
+
ipu_ch_param_write_field(ch, IPU_FIELD_SO, 1);
- ipu_ch_param_write_field(ch, IPU_FIELD_ILO, stride / 8);
- ipu_ch_param_write_field(ch, IPU_FIELD_SLY, (stride * 2) - 1);
+ ipu_ch_param_write_field(ch, IPU_FIELD_ILO, ilo);
+ ipu_ch_param_write_field(ch, IPU_FIELD_SLY, sly);
};
EXPORT_SYMBOL_GPL(ipu_cpmem_interlaced_scan);
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 06/14] gpu: ipu-v3: Add planar support to interlaced scan
[not found] <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com>
` (3 preceding siblings ...)
2018-08-01 19:12 ` [PATCH v3 05/14] gpu: ipu-v3: Allow negative offsets for interlaced scanning Steve Longerbeam
@ 2018-08-01 19:12 ` Steve Longerbeam
4 siblings, 0 replies; 10+ messages in thread
From: Steve Longerbeam @ 2018-08-01 19:12 UTC (permalink / raw)
To: linux-media
Cc: open list:STAGING SUBSYSTEM, open list:FRAMEBUFFER LAYER,
Steve Longerbeam, Bartlomiej Zolnierkiewicz, Greg Kroah-Hartman,
open list, open list:DRM DRIVERS FOR FREESCALE IMX, Philipp Zabel,
Steve Longerbeam, Mauro Carvalho Chehab
To support interlaced scan with planar formats, cpmem SLUV must
be programmed with the correct chroma line stride. For full and
partial planar 4:2:2 (YUV422P, NV16), chroma line stride must
be doubled. For full and partial planar 4:2:0 (YUV420, YVU420, NV12),
chroma line stride must _not_ be doubled, since a single chroma line
is shared by two luma lines.
Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
---
drivers/gpu/ipu-v3/ipu-cpmem.c | 26 ++++++++++++++++++++++++--
drivers/staging/media/imx/imx-ic-prpencvf.c | 3 ++-
drivers/staging/media/imx/imx-media-csi.c | 3 ++-
include/video/imx-ipu-v3.h | 3 ++-
4 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c
index 8cd9e37..eae0f63 100644
--- a/drivers/gpu/ipu-v3/ipu-cpmem.c
+++ b/drivers/gpu/ipu-v3/ipu-cpmem.c
@@ -267,9 +267,10 @@ void ipu_cpmem_set_uv_offset(struct ipuv3_channel *ch, u32 u_off, u32 v_off)
}
EXPORT_SYMBOL_GPL(ipu_cpmem_set_uv_offset);
-void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride)
+void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride,
+ u32 pixelformat)
{
- u32 ilo, sly;
+ u32 ilo, sly, sluv;
if (stride < 0) {
stride = -stride;
@@ -280,9 +281,30 @@ void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride)
sly = (stride * 2) - 1;
+ switch (pixelformat) {
+ case V4L2_PIX_FMT_YUV420:
+ case V4L2_PIX_FMT_YVU420:
+ sluv = stride / 2 - 1;
+ break;
+ case V4L2_PIX_FMT_NV12:
+ sluv = stride - 1;
+ break;
+ case V4L2_PIX_FMT_YUV422P:
+ sluv = stride - 1;
+ break;
+ case V4L2_PIX_FMT_NV16:
+ sluv = stride * 2 - 1;
+ break;
+ default:
+ sluv = 0;
+ break;
+ }
+
ipu_ch_param_write_field(ch, IPU_FIELD_SO, 1);
ipu_ch_param_write_field(ch, IPU_FIELD_ILO, ilo);
ipu_ch_param_write_field(ch, IPU_FIELD_SLY, sly);
+ if (sluv)
+ ipu_ch_param_write_field(ch, IPU_FIELD_SLUV, sluv);
};
EXPORT_SYMBOL_GPL(ipu_cpmem_interlaced_scan);
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c
index 28f41ca..af72248 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -412,7 +412,8 @@ static int prp_setup_channel(struct prp_priv *priv,
if (image.pix.field == V4L2_FIELD_NONE &&
V4L2_FIELD_HAS_BOTH(infmt->field) &&
channel == priv->out_ch)
- ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline);
+ ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline,
+ image.pix.pixelformat);
ret = ipu_ic_task_idma_init(priv->ic, channel,
image.pix.width, image.pix.height,
diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
index 2fdd21d..1c468ec 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -509,7 +509,8 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
if (image.pix.field == V4L2_FIELD_NONE &&
V4L2_FIELD_HAS_BOTH(infmt->field))
ipu_cpmem_interlaced_scan(priv->idmac_ch,
- image.pix.bytesperline);
+ image.pix.bytesperline,
+ image.pix.pixelformat);
ipu_idmac_set_double_buffer(priv->idmac_ch, true);
diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
index f44a351..e888c66 100644
--- a/include/video/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -255,7 +255,8 @@ void ipu_cpmem_set_stride(struct ipuv3_channel *ch, int stride);
void ipu_cpmem_set_high_priority(struct ipuv3_channel *ch);
void ipu_cpmem_set_buffer(struct ipuv3_channel *ch, int bufnum, dma_addr_t buf);
void ipu_cpmem_set_uv_offset(struct ipuv3_channel *ch, u32 u_off, u32 v_off);
-void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride);
+void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride,
+ u32 pixelformat);
void ipu_cpmem_set_axi_id(struct ipuv3_channel *ch, u32 id);
int ipu_cpmem_get_burstsize(struct ipuv3_channel *ch);
void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize);
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 02/14] gpu: ipu-csi: Check for field type alternate
2018-08-01 19:12 ` [PATCH v3 02/14] gpu: ipu-csi: Check for field type alternate Steve Longerbeam
@ 2018-08-02 9:42 ` Philipp Zabel
2018-08-04 19:08 ` Steve Longerbeam
0 siblings, 1 reply; 10+ messages in thread
From: Philipp Zabel @ 2018-08-02 9:42 UTC (permalink / raw)
To: Steve Longerbeam, linux-media
Cc: Steve Longerbeam, open list,
open list:DRM DRIVERS FOR FREESCALE IMX
Hi Steve,
On Wed, 2018-08-01 at 12:12 -0700, Steve Longerbeam wrote:
> When the CSI is receiving from a bt.656 bus, include a check for
> field type 'alternate' when determining whether to set CSI clock
> mode to CCIR656_INTERLACED or CCIR656_PROGRESSIVE.
>
> Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
> ---
> drivers/gpu/ipu-v3/ipu-csi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
> index caa05b0..5450a2d 100644
> --- a/drivers/gpu/ipu-v3/ipu-csi.c
> +++ b/drivers/gpu/ipu-v3/ipu-csi.c
> @@ -339,7 +339,8 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
> break;
> case V4L2_MBUS_BT656:
> csicfg->ext_vsync = 0;
> - if (V4L2_FIELD_HAS_BOTH(mbus_fmt->field))
> + if (V4L2_FIELD_HAS_BOTH(mbus_fmt->field) ||
> + mbus_fmt->field == V4L2_FIELD_ALTERNATE)
> csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_INTERLACED;
> else
> csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE;
this patch is already merged in v4.18-rc7.
regards
Philipp
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 05/14] gpu: ipu-v3: Allow negative offsets for interlaced scanning
2018-08-01 19:12 ` [PATCH v3 05/14] gpu: ipu-v3: Allow negative offsets for interlaced scanning Steve Longerbeam
@ 2018-08-02 9:46 ` Philipp Zabel
2018-08-04 19:25 ` Steve Longerbeam
0 siblings, 1 reply; 10+ messages in thread
From: Philipp Zabel @ 2018-08-02 9:46 UTC (permalink / raw)
To: Steve Longerbeam, linux-media
Cc: Steve Longerbeam, open list,
open list:DRM DRIVERS FOR FREESCALE IMX
On Wed, 2018-08-01 at 12:12 -0700, Steve Longerbeam wrote:
> From: Philipp Zabel <p.zabel@pengutronix.de>
>
> The IPU also supports interlaced buffers that start with the bottom field.
> To achieve this, the the base address EBA has to be increased by a stride
> length and the interlace offset ILO has to be set to the negative stride.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
> ---
> drivers/gpu/ipu-v3/ipu-cpmem.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c
> index e68e473..8cd9e37 100644
> --- a/drivers/gpu/ipu-v3/ipu-cpmem.c
> +++ b/drivers/gpu/ipu-v3/ipu-cpmem.c
> @@ -269,9 +269,20 @@ EXPORT_SYMBOL_GPL(ipu_cpmem_set_uv_offset);
>
> void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride)
> {
> + u32 ilo, sly;
> +
> + if (stride < 0) {
> + stride = -stride;
> + ilo = 0x100000 - (stride / 8);
> + } else {
> + ilo = stride / 8;
> + }
> +
> + sly = (stride * 2) - 1;
> +
> ipu_ch_param_write_field(ch, IPU_FIELD_SO, 1);
> - ipu_ch_param_write_field(ch, IPU_FIELD_ILO, stride / 8);
> - ipu_ch_param_write_field(ch, IPU_FIELD_SLY, (stride * 2) - 1);
> + ipu_ch_param_write_field(ch, IPU_FIELD_ILO, ilo);
> + ipu_ch_param_write_field(ch, IPU_FIELD_SLY, sly);
> };
> EXPORT_SYMBOL_GPL(ipu_cpmem_interlaced_scan);
This patch is merged in drm-next: 4e3c5d7e05be ("gpu: ipu-v3: Allow
negative offsets for interlaced scanning")
regards
Philipp
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 04/14] gpu: ipu-v3: Fix U/V offset macros for planar 4:2:0
2018-08-01 19:12 ` [PATCH v3 04/14] gpu: ipu-v3: Fix U/V offset macros for planar 4:2:0 Steve Longerbeam
@ 2018-08-02 9:51 ` Philipp Zabel
0 siblings, 0 replies; 10+ messages in thread
From: Philipp Zabel @ 2018-08-02 9:51 UTC (permalink / raw)
To: Steve Longerbeam, linux-media
Cc: Steve Longerbeam, open list,
open list:DRM DRIVERS FOR FREESCALE IMX
On Wed, 2018-08-01 at 12:12 -0700, Steve Longerbeam wrote:
> The U and V offset macros for planar 4:2:0 (U_OFFSET, V_OFFSET, and
> UV_OFFSET), are not correct. The height component to the offset was
> calculated as:
>
> (pix->width * y / 4)
>
> But this does not produce correct offsets for odd values of y (luma
> line #). The luma line # must be decimated by two to produce the
> correct U/V line #, so the correct formula is:
>
> (pix->width * (y / 2) / 2)
>
> Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Thank you this patch is applied to imx-drm/fixes now.
regards
Philipp
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 02/14] gpu: ipu-csi: Check for field type alternate
2018-08-02 9:42 ` Philipp Zabel
@ 2018-08-04 19:08 ` Steve Longerbeam
0 siblings, 0 replies; 10+ messages in thread
From: Steve Longerbeam @ 2018-08-04 19:08 UTC (permalink / raw)
To: Philipp Zabel, linux-media
Cc: Steve Longerbeam, open list:DRM DRIVERS FOR FREESCALE IMX,
open list
Hi Philipp,
On 08/02/2018 02:42 AM, Philipp Zabel wrote:
> Hi Steve,
>
> On Wed, 2018-08-01 at 12:12 -0700, Steve Longerbeam wrote:
>> When the CSI is receiving from a bt.656 bus, include a check for
>> field type 'alternate' when determining whether to set CSI clock
>> mode to CCIR656_INTERLACED or CCIR656_PROGRESSIVE.
>>
>> Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
>> ---
>> drivers/gpu/ipu-v3/ipu-csi.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
>> index caa05b0..5450a2d 100644
>> --- a/drivers/gpu/ipu-v3/ipu-csi.c
>> +++ b/drivers/gpu/ipu-v3/ipu-csi.c
>> @@ -339,7 +339,8 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
>> break;
>> case V4L2_MBUS_BT656:
>> csicfg->ext_vsync = 0;
>> - if (V4L2_FIELD_HAS_BOTH(mbus_fmt->field))
>> + if (V4L2_FIELD_HAS_BOTH(mbus_fmt->field) ||
>> + mbus_fmt->field == V4L2_FIELD_ALTERNATE)
>> csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_INTERLACED;
>> else
>> csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE;
> this patch is already merged in v4.18-rc7.
Ah, I just noticed that after a fetch from kernel.org, thanks.
Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 05/14] gpu: ipu-v3: Allow negative offsets for interlaced scanning
2018-08-02 9:46 ` Philipp Zabel
@ 2018-08-04 19:25 ` Steve Longerbeam
0 siblings, 0 replies; 10+ messages in thread
From: Steve Longerbeam @ 2018-08-04 19:25 UTC (permalink / raw)
To: Philipp Zabel, linux-media
Cc: Steve Longerbeam, open list:DRM DRIVERS FOR FREESCALE IMX,
open list
Hi Philipp,
On 08/02/2018 02:46 AM, Philipp Zabel wrote:
> On Wed, 2018-08-01 at 12:12 -0700, Steve Longerbeam wrote:
>> From: Philipp Zabel <p.zabel@pengutronix.de>
>>
>> The IPU also supports interlaced buffers that start with the bottom field.
>> To achieve this, the the base address EBA has to be increased by a stride
>> length and the interlace offset ILO has to be set to the negative stride.
>>
>> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
>> Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
>> ---
>> drivers/gpu/ipu-v3/ipu-cpmem.c | 15 +++++++++++++--
>> 1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c
>> index e68e473..8cd9e37 100644
>> --- a/drivers/gpu/ipu-v3/ipu-cpmem.c
>> +++ b/drivers/gpu/ipu-v3/ipu-cpmem.c
>> @@ -269,9 +269,20 @@ EXPORT_SYMBOL_GPL(ipu_cpmem_set_uv_offset);
>>
>> void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride)
>> {
>> + u32 ilo, sly;
>> +
>> + if (stride < 0) {
>> + stride = -stride;
>> + ilo = 0x100000 - (stride / 8);
>> + } else {
>> + ilo = stride / 8;
>> + }
>> +
>> + sly = (stride * 2) - 1;
>> +
>> ipu_ch_param_write_field(ch, IPU_FIELD_SO, 1);
>> - ipu_ch_param_write_field(ch, IPU_FIELD_ILO, stride / 8);
>> - ipu_ch_param_write_field(ch, IPU_FIELD_SLY, (stride * 2) - 1);
>> + ipu_ch_param_write_field(ch, IPU_FIELD_ILO, ilo);
>> + ipu_ch_param_write_field(ch, IPU_FIELD_SLY, sly);
>> };
>> EXPORT_SYMBOL_GPL(ipu_cpmem_interlaced_scan);
> This patch is merged in drm-next: 4e3c5d7e05be ("gpu: ipu-v3: Allow
> negative offsets for interlaced scanning")
I don't see it in drm-next, but I see it in linux-next/master. Thanks.
Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-08-04 19:25 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1533150747-30677-1-git-send-email-steve_longerbeam@mentor.com>
2018-08-01 19:12 ` [PATCH v3 02/14] gpu: ipu-csi: Check for field type alternate Steve Longerbeam
2018-08-02 9:42 ` Philipp Zabel
2018-08-04 19:08 ` Steve Longerbeam
2018-08-01 19:12 ` [PATCH v3 03/14] gpu: ipu-csi: Swap fields according to input/output field types Steve Longerbeam
2018-08-01 19:12 ` [PATCH v3 04/14] gpu: ipu-v3: Fix U/V offset macros for planar 4:2:0 Steve Longerbeam
2018-08-02 9:51 ` Philipp Zabel
2018-08-01 19:12 ` [PATCH v3 05/14] gpu: ipu-v3: Allow negative offsets for interlaced scanning Steve Longerbeam
2018-08-02 9:46 ` Philipp Zabel
2018-08-04 19:25 ` Steve Longerbeam
2018-08-01 19:12 ` [PATCH v3 06/14] gpu: ipu-v3: Add planar support to interlaced scan Steve Longerbeam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox