All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>, Benoit Parrot <bparrot@ti.com>
Subject: [PATCH v3 09/24] media: ti-vpe: cal: Don't pass format to cal_ctx_wr_dma_config()
Date: Mon,  7 Dec 2020 01:53:38 +0200	[thread overview]
Message-ID: <20201206235353.26968-10-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20201206235353.26968-1-laurent.pinchart@ideasonboard.com>

The cal_ctx_wr_dma_config() function has access to the context, there's
no need to give it format-related values retrieved from the context.
Access the values internally, and reword internal comments. The comment
regarding the CAL_WR_DMA_OFST register not being well understood is
dropped, as the datasheet explicitly documents it as "Offset between two
consecutive line starts".

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
---
 drivers/media/platform/ti-vpe/cal-video.c |  3 +--
 drivers/media/platform/ti-vpe/cal.c       | 25 +++++++++--------------
 drivers/media/platform/ti-vpe/cal.h       |  3 +--
 3 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/ti-vpe/cal-video.c b/drivers/media/platform/ti-vpe/cal-video.c
index 1ada27d42da1..083389635269 100644
--- a/drivers/media/platform/ti-vpe/cal-video.c
+++ b/drivers/media/platform/ti-vpe/cal-video.c
@@ -516,8 +516,7 @@ static int cal_start_streaming(struct vb2_queue *vq, unsigned int count)
 
 	cal_ctx_csi2_config(ctx);
 	cal_ctx_pix_proc_config(ctx);
-	cal_ctx_wr_dma_config(ctx, ctx->v_fmt.fmt.pix.bytesperline,
-			      ctx->v_fmt.fmt.pix.height);
+	cal_ctx_wr_dma_config(ctx);
 
 	cal_camerarx_enable_irqs(ctx->phy);
 
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 5d073d9cd8b5..4c938ca1f1a9 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -356,14 +356,15 @@ void cal_ctx_pix_proc_config(struct cal_ctx *ctx)
 		cal_read(ctx->cal, CAL_PIX_PROC(ctx->index)));
 }
 
-void cal_ctx_wr_dma_config(struct cal_ctx *ctx, unsigned int width,
-			    unsigned int height)
+void cal_ctx_wr_dma_config(struct cal_ctx *ctx)
 {
+	unsigned int stride = ctx->v_fmt.fmt.pix.bytesperline;
 	u32 val;
 
 	val = cal_read(ctx->cal, CAL_WR_DMA_CTRL(ctx->index));
 	cal_set_field(&val, ctx->cport, CAL_WR_DMA_CTRL_CPORT_MASK);
-	cal_set_field(&val, height, CAL_WR_DMA_CTRL_YSIZE_MASK);
+	cal_set_field(&val, ctx->v_fmt.fmt.pix.height,
+		      CAL_WR_DMA_CTRL_YSIZE_MASK);
 	cal_set_field(&val, CAL_WR_DMA_CTRL_DTAG_PIX_DAT,
 		      CAL_WR_DMA_CTRL_DTAG_MASK);
 	cal_set_field(&val, CAL_WR_DMA_CTRL_MODE_CONST,
@@ -375,14 +376,8 @@ void cal_ctx_wr_dma_config(struct cal_ctx *ctx, unsigned int width,
 	ctx_dbg(3, ctx, "CAL_WR_DMA_CTRL(%d) = 0x%08x\n", ctx->index,
 		cal_read(ctx->cal, CAL_WR_DMA_CTRL(ctx->index)));
 
-	/*
-	 * width/16 not sure but giving it a whirl.
-	 * zero does not work right
-	 */
-	cal_write_field(ctx->cal,
-			CAL_WR_DMA_OFST(ctx->index),
-			(width / 16),
-			CAL_WR_DMA_OFST_MASK);
+	cal_write_field(ctx->cal, CAL_WR_DMA_OFST(ctx->index),
+			stride / 16, CAL_WR_DMA_OFST_MASK);
 	ctx_dbg(3, ctx, "CAL_WR_DMA_OFST(%d) = 0x%08x\n", ctx->index,
 		cal_read(ctx->cal, CAL_WR_DMA_OFST(ctx->index)));
 
@@ -390,11 +385,11 @@ void cal_ctx_wr_dma_config(struct cal_ctx *ctx, unsigned int width,
 	/* 64 bit word means no skipping */
 	cal_set_field(&val, 0, CAL_WR_DMA_XSIZE_XSKIP_MASK);
 	/*
-	 * (width*8)/64 this should be size of an entire line
-	 * in 64bit word but 0 means all data until the end
-	 * is detected automagically
+	 * The XSIZE field is expressed in 64-bit units and prevents overflows
+	 * in case of synchronization issues by limiting the number of bytes
+	 * written per line.
 	 */
-	cal_set_field(&val, (width / 8), CAL_WR_DMA_XSIZE_MASK);
+	cal_set_field(&val, stride / 8, CAL_WR_DMA_XSIZE_MASK);
 	cal_write(ctx->cal, CAL_WR_DMA_XSIZE(ctx->index), val);
 	ctx_dbg(3, ctx, "CAL_WR_DMA_XSIZE(%d) = 0x%08x\n", ctx->index,
 		cal_read(ctx->cal, CAL_WR_DMA_XSIZE(ctx->index)));
diff --git a/drivers/media/platform/ti-vpe/cal.h b/drivers/media/platform/ti-vpe/cal.h
index 45f65ebf7aa9..d8e7f0c586f6 100644
--- a/drivers/media/platform/ti-vpe/cal.h
+++ b/drivers/media/platform/ti-vpe/cal.h
@@ -273,8 +273,7 @@ void cal_camerarx_destroy(struct cal_camerarx *phy);
 
 void cal_ctx_csi2_config(struct cal_ctx *ctx);
 void cal_ctx_pix_proc_config(struct cal_ctx *ctx);
-void cal_ctx_wr_dma_config(struct cal_ctx *ctx, unsigned int width,
-			   unsigned int height);
+void cal_ctx_wr_dma_config(struct cal_ctx *ctx);
 void cal_ctx_wr_dma_addr(struct cal_ctx *ctx, unsigned int dmaaddr);
 
 int cal_ctx_v4l2_register(struct cal_ctx *ctx);
-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2020-12-06 23:56 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-06 23:53 [PATCH v3 00/24] media: ti-vpe: cal: Add media controller support Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 01/24] media: ti-vpe: cal: Create subdev for CAMERARX Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 02/24] media: ti-vpe: cal: Drop cal_ctx m_fmt field Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 03/24] media: ti-vpe: cal: Move format handling to cal.c and expose helpers Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 04/24] media: ti-vpe: cal: Rename MAX_(WIDTH|HEIGHT)_* macros with CAL_ prefix Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 05/24] media: ti-vpe: cal: Replace hardcoded BIT() value with macro Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 06/24] media: ti-vpe: cal: Iterate over correct number of CAMERARX instances Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 07/24] media: ti-vpe: cal: Implement subdev ops for CAMERARX Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 08/24] media: ti-vpe: cal: Use CAMERARX subdev s_stream op in video device code Laurent Pinchart
2020-12-06 23:53 ` Laurent Pinchart [this message]
2020-12-06 23:53 ` [PATCH v3 10/24] media: ti-vpe: cal: Rename struct cal_fmt to cal_format_info Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 11/24] media: ti-vpe: cal: Refactor interrupt enable/disable Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 12/24] media: ti-vpe: cal: Fold PPI enable in CAMERARX .s_stream() Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 13/24] media: ti-vpe: cal: Stop write DMA without disabling PPI Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 14/24] media: ti-vpe: cal: Use spin_lock_irq() when starting or stopping stream Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 15/24] media: ti-vpe: cal: Share buffer release code between start and stop Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 16/24] media: ti-vpe: cal: Drop V4L2_CAP_READWRITE Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 17/24] media: ti-vpe: cal: Drop unneeded check in cal_calc_format_size() Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 18/24] media: ti-vpe: cal: Remove DMA queue empty check at start streaming time Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 19/24] media: ti-vpe: cal: Use list_first_entry() Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 20/24] media: ti-vpe: cal: Group all DMA queue fields in struct cal_dmaqueue Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 21/24] media: ti-vpe: cal: Set cal_dmaqueue.pending to NULL when no pending buffer Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 22/24] media: ti-vpe: cal: Store buffer DMA address in dma_addr_t Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 23/24] media: ti-vpe: cal: Simplify the context API Laurent Pinchart
2020-12-06 23:53 ` [PATCH v3 24/24] media: ti-vpe: cal: Implement media controller centric API Laurent Pinchart
2020-12-07 10:11   ` Hans Verkuil
2020-12-07 23:51     ` Laurent Pinchart
2020-12-08  8:58       ` Hans Verkuil
2020-12-08 16:15         ` Laurent Pinchart
2021-02-15 15:23           ` Tomi Valkeinen
2021-03-03 15:15             ` Hans Verkuil
2021-03-03 15:22               ` Laurent Pinchart
2021-03-03 15:51                 ` Hans Verkuil

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=20201206235353.26968-10-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=bparrot@ti.com \
    --cc=linux-media@vger.kernel.org \
    --cc=tomi.valkeinen@ti.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.