From patchwork Mon Feb 10 17:56:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13968315 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D5732566C8; Mon, 10 Feb 2025 17:56:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739210208; cv=none; b=mI7bHA2WEz9+J6drV4FqO1k1OO2txE8A8h+9ClclO8BRX1NBGwbR+iyHNldN2jebZBPaEje4PPDF+4rdsPnTUZwxAC1lLAH9s/xUnnOr/poeLdyGOAGsmI5WaQ2MXjERvJZ/i5XQr4yQUzpeNWUtJUioCyu3oDakVeuuYyQ/AwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739210208; c=relaxed/simple; bh=RF3miZ49pe0vcIdpcavO9YqSEAMJxrSv5R1Ncv7F6Jg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K7aBqIXyIN4Vc8OOVpd6ojfUU9cXTie/21oRBqFwQ7bC50cnibXVUJ8DCZBWGohbxKF66PYV2lnQzOCLvGBRATLRmzqIaYq4akD6LBv+OGFU/ZCUeNBEmDfNqM/zM3WdITfFdAFj9vXN5fRzX9aFAwfldRxx98cSIQM8z55WoW4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=SmkszRat; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=KQ1+PLqz; arc=none smtp.client-ip=103.168.172.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="SmkszRat"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="KQ1+PLqz" Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id 5BF53138097E; Mon, 10 Feb 2025 12:56:45 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Mon, 10 Feb 2025 12:56:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1739210205; x=1739296605; bh=qUnZh0YAnsGSR1WSxEryTHZVAxOVNWRSgPqukKSsZL8=; b= SmkszRatIpOnXKoUExuZrxHVs0Q+a86lHpS3p2V/XM/kmx/ZOaZUCZO/TGSoN/je AzOCGyABpm9hEbUol3VKYARzoIjCgWIsLtzS/mqjeESWY2DNyvtPLCZ0f/D15Skw KNDRyI7WE0xGyDckiNYStz95FmLwLsTzBY7hIXpQ83FVXObnxW0/zxHKRiXF1FTG g/17OtlpTWJfimG7n3A/zaaUarUcIz4GrUIQvvy9dQpI5HiqRNSYy5VLOoQ5eY2J K8H1eM0VrQnVvXI2gNdCkGhHI4qd5SPy63cC+Hno1JS9k99cOWArxTEiJxTW0NJA btQH3u+AGgcMUzXnoQr2LA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1739210205; x= 1739296605; bh=qUnZh0YAnsGSR1WSxEryTHZVAxOVNWRSgPqukKSsZL8=; b=K Q1+PLqzj68vsxgS4YJLmmiwdeQeWmc5nZrvnsN/MV9t23hb+BBXhzdzYfmLGeL9z 3xrJxyo/3Vrcf9zmYLXnCopP+HCMXzr5Ap/MCHPQQHi8gQLjvGOvWKTOUcK6Lh2b KUtvLLAaGx7oTIjO6oWCcrtIUCLQpJRbNlFFmIU4BzLKl8rjfY26TtzBIVoK/lFa IofYdiLm6cYQ0uBuj6XwoCbEaHMrK5Mn408s01HnKGo37aY2dbDBUh9Gq0EwlV4J cQQxO2QeetHeOmRsP42ujEPsnnP9rLjZhpiNuUpBwN1QZt6DfEV4UNAn7ZWZCUdf LSlUH90nRM1av4hPJ5XPA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdefkeejvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfgggtgfesthekredtredt jeenucfhrhhomheppfhikhhlrghsucfunpguvghrlhhunhguuceonhhikhhlrghsrdhsoh guvghrlhhunhguodhrvghnvghsrghssehrrghgnhgrthgvtghhrdhsvgeqnecuggftrfgr thhtvghrnhepheeigfeuveeutdefhfehgeekvedtleeuueekveefudehhffhjeffgfegff elfeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep nhhikhhlrghsrdhsohguvghrlhhunhgusehrrghgnhgrthgvtghhrdhsvgdpnhgspghrtg hpthhtohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepshgrkhgrrhhirdgr ihhluhhssehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepmhgthhgvhhgrsg eskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhomhhirdhvrghlkhgvihhnvghnodhr vghnvghsrghssehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthhopehlihhnuh igqdhmvgguihgrsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhu gidqrhgvnhgvshgrshdqshhotgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtth hopehnihhklhgrshdrshhouggvrhhluhhnugdorhgvnhgvshgrshesrhgrghhnrghtvggt hhdrshgv X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Feb 2025 12:56:44 -0500 (EST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Sakari Ailus , Mauro Carvalho Chehab , Tomi Valkeinen , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Cc: =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH v3 1/5] media: rcar-vin: Remove emulated SEQ_{TB,BT} Date: Mon, 10 Feb 2025 18:56:11 +0100 Message-ID: <20250210175615.1686529-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250210175615.1686529-1-niklas.soderlund+renesas@ragnatech.se> References: <20250210175615.1686529-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When the driver was converted from soc_camera software support for V4L2_FIELD_SEQ_TB and V4L2_FIELD_SEQ_BT were added. This was done by capturing twice to the same VB2 buffer, but at different offsets. This turned out to be a bad idea and it never really worked properly in all situations. As the hardware can't support this mode natively remove trying to emulate it in software. It's still possible to capture TOP or BOTTOM fields separately or both ALTERNATING. If user-space wants the same fields in the same buffer the same hack to capture twice to the same buffer can be done. Removing this error prone emulated support pave ways in future work to simplify the internal buffer handling and making it less fragile, while enabling adding support for other features the hardware actually supports. Signed-off-by: Niklas Söderlund Reviewed-by: Tomi Valkeinen Tested-by: Tomi Valkeinen --- * Changes since v2 - Fix commit message. * Changes since v1 - Remove 'prev' variable in rvin_fill_hw_slot() which is no longer used, but set. --- .../platform/renesas/rcar-vin/rcar-dma.c | 58 +++---------------- .../platform/renesas/rcar-vin/rcar-v4l2.c | 7 --- .../platform/renesas/rcar-vin/rcar-vin.h | 18 ------ 3 files changed, 7 insertions(+), 76 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c index 8773998101ff..a16adc6fd4dc 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c @@ -642,8 +642,6 @@ void rvin_scaler_gen3(struct rvin_dev *vin) case V4L2_FIELD_INTERLACED_TB: case V4L2_FIELD_INTERLACED_BT: case V4L2_FIELD_INTERLACED: - case V4L2_FIELD_SEQ_TB: - case V4L2_FIELD_SEQ_BT: clip_size |= vin->compose.height / 2; break; default: @@ -727,8 +725,6 @@ static int rvin_setup(struct rvin_dev *vin) case V4L2_FIELD_INTERLACED_BT: vnmc = VNMC_IM_FULL | VNMC_FOC; break; - case V4L2_FIELD_SEQ_TB: - case V4L2_FIELD_SEQ_BT: case V4L2_FIELD_NONE: case V4L2_FIELD_ALTERNATE: vnmc = VNMC_IM_ODD_EVEN; @@ -1021,33 +1017,14 @@ static void rvin_fill_hw_slot(struct rvin_dev *vin, int slot) struct rvin_buffer *buf; struct vb2_v4l2_buffer *vbuf; dma_addr_t phys_addr; - int prev; /* A already populated slot shall never be overwritten. */ if (WARN_ON(vin->buf_hw[slot].buffer)) return; - prev = (slot == 0 ? HW_BUFFER_NUM : slot) - 1; - - if (vin->buf_hw[prev].type == HALF_TOP) { - vbuf = vin->buf_hw[prev].buffer; - vin->buf_hw[slot].buffer = vbuf; - vin->buf_hw[slot].type = HALF_BOTTOM; - switch (vin->format.pixelformat) { - case V4L2_PIX_FMT_NV12: - case V4L2_PIX_FMT_NV16: - phys_addr = vin->buf_hw[prev].phys + - vin->format.sizeimage / 4; - break; - default: - phys_addr = vin->buf_hw[prev].phys + - vin->format.sizeimage / 2; - break; - } - } else if ((vin->state != STOPPED && vin->state != RUNNING) || - list_empty(&vin->buf_list)) { + if ((vin->state != STOPPED && vin->state != RUNNING) || + list_empty(&vin->buf_list)) { vin->buf_hw[slot].buffer = NULL; - vin->buf_hw[slot].type = FULL; phys_addr = vin->scratch_phys; } else { /* Keep track of buffer we give to HW */ @@ -1056,16 +1033,12 @@ static void rvin_fill_hw_slot(struct rvin_dev *vin, int slot) list_del_init(to_buf_list(vbuf)); vin->buf_hw[slot].buffer = vbuf; - vin->buf_hw[slot].type = - V4L2_FIELD_IS_SEQUENTIAL(vin->format.field) ? - HALF_TOP : FULL; - /* Setup DMA */ phys_addr = vb2_dma_contig_plane_dma_addr(&vbuf->vb2_buf, 0); } - vin_dbg(vin, "Filling HW slot: %d type: %d buffer: %p\n", - slot, vin->buf_hw[slot].type, vin->buf_hw[slot].buffer); + vin_dbg(vin, "Filling HW slot: %d buffer: %p\n", + slot, vin->buf_hw[slot].buffer); vin->buf_hw[slot].phys = phys_addr; rvin_set_slot_addr(vin, slot, phys_addr); @@ -1073,15 +1046,12 @@ static void rvin_fill_hw_slot(struct rvin_dev *vin, int slot) static int rvin_capture_start(struct rvin_dev *vin) { - int slot, ret; + int ret; - for (slot = 0; slot < HW_BUFFER_NUM; slot++) { + for (unsigned int slot = 0; slot < HW_BUFFER_NUM; slot++) { vin->buf_hw[slot].buffer = NULL; - vin->buf_hw[slot].type = FULL; - } - - for (slot = 0; slot < HW_BUFFER_NUM; slot++) rvin_fill_hw_slot(vin, slot); + } ret = rvin_setup(vin); if (ret) @@ -1162,16 +1132,6 @@ static irqreturn_t rvin_irq(int irq, void *data) /* Capture frame */ if (vin->buf_hw[slot].buffer) { - /* - * Nothing to do but refill the hardware slot if - * capture only filled first half of vb2 buffer. - */ - if (vin->buf_hw[slot].type == HALF_TOP) { - vin->buf_hw[slot].buffer = NULL; - rvin_fill_hw_slot(vin, slot); - goto done; - } - vin->buf_hw[slot].buffer->field = rvin_get_active_field(vin, vnms); vin->buf_hw[slot].buffer->sequence = vin->sequence; @@ -1322,8 +1282,6 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd, case V4L2_FIELD_INTERLACED_TB: case V4L2_FIELD_INTERLACED_BT: case V4L2_FIELD_INTERLACED: - case V4L2_FIELD_SEQ_TB: - case V4L2_FIELD_SEQ_BT: /* Supported natively */ break; case V4L2_FIELD_ALTERNATE: @@ -1336,8 +1294,6 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd, case V4L2_FIELD_INTERLACED_TB: case V4L2_FIELD_INTERLACED_BT: case V4L2_FIELD_INTERLACED: - case V4L2_FIELD_SEQ_TB: - case V4L2_FIELD_SEQ_BT: /* Use VIN hardware to combine the two fields */ fmt.format.height *= 2; break; diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c index 756fdfdbce61..a5763f1c5784 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c @@ -161,9 +161,6 @@ static u32 rvin_format_bytesperline(struct rvin_dev *vin, break; } - if (V4L2_FIELD_IS_SEQUENTIAL(pix->field)) - align = 0x80; - return ALIGN(pix->width, align) * fmt->bpp; } @@ -194,8 +191,6 @@ static void rvin_format_align(struct rvin_dev *vin, struct v4l2_pix_format *pix) case V4L2_FIELD_INTERLACED_BT: case V4L2_FIELD_INTERLACED: case V4L2_FIELD_ALTERNATE: - case V4L2_FIELD_SEQ_TB: - case V4L2_FIELD_SEQ_BT: break; default: pix->field = RVIN_DEFAULT_FIELD; @@ -504,8 +499,6 @@ static int rvin_remote_rectangle(struct rvin_dev *vin, struct v4l2_rect *rect) case V4L2_FIELD_INTERLACED_TB: case V4L2_FIELD_INTERLACED_BT: case V4L2_FIELD_INTERLACED: - case V4L2_FIELD_SEQ_TB: - case V4L2_FIELD_SEQ_BT: rect->height *= 2; break; } diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-vin.h b/drivers/media/platform/renesas/rcar-vin/rcar-vin.h index f87d4bc9e53e..d5763462809a 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-vin.h +++ b/drivers/media/platform/renesas/rcar-vin/rcar-vin.h @@ -77,23 +77,6 @@ enum rvin_dma_state { SUSPENDED, }; -/** - * enum rvin_buffer_type - * - * Describes how a buffer is given to the hardware. To be able - * to capture SEQ_TB/BT it's needed to capture to the same vb2 - * buffer twice so the type of buffer needs to be kept. - * - * @FULL: One capture fills the whole vb2 buffer - * @HALF_TOP: One capture fills the top half of the vb2 buffer - * @HALF_BOTTOM: One capture fills the bottom half of the vb2 buffer - */ -enum rvin_buffer_type { - FULL, - HALF_TOP, - HALF_BOTTOM, -}; - /** * struct rvin_video_format - Data format stored in memory * @fourcc: Pixelformat @@ -237,7 +220,6 @@ struct rvin_dev { spinlock_t qlock; struct { struct vb2_v4l2_buffer *buffer; - enum rvin_buffer_type type; dma_addr_t phys; } buf_hw[HW_BUFFER_NUM]; struct list_head buf_list; From patchwork Mon Feb 10 17:56:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13968316 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A38AC25B67D; Mon, 10 Feb 2025 17:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739210210; cv=none; b=YmeAbfDwajGeiGMRgDT566zt5aXtXKyxyCDgEkL93uXia7KU22gni3oTdZm+aT9jUq//oENvSWvV3qUDe+VEO7kLOpDOAI6KOSsod0S3//faqs6tpKDgFUZcLHFl7id7dZOcYMLmVTB6od/KjqM0fmn+Q6UzdrUYAwGYBC9SNm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739210210; c=relaxed/simple; bh=2zZuFSg/JcxyXGwQl3ZYPvYFSaljIbxPocAJ/rF6rVM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Nos4hOmoKJN+p2b0YYcHD40yxM9GpIl6mOWM5U7QUI0GC59dcA4Z35OPMjFRqzsru+koUdtfepwoqwTxUt8zUap1VgOTI3GNd5gqhi7H4E3rKspILa8MCxa+bGJvvdME3Dm4Y7aVbUPykagFgBZ3sf0a15GF7DNk4/ejUwQKTJw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=QuBAG0EG; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QGb1uRij; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="QuBAG0EG"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QGb1uRij" Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id BCEB811400E2; Mon, 10 Feb 2025 12:56:47 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Mon, 10 Feb 2025 12:56:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1739210207; x=1739296607; bh=aL5vU4AQTAt1GuJKWFcWB/1PAooHMP+SRXFny0kf0zw=; b= QuBAG0EG0u7bfDV53xlMRnIDV2fPb8W4woEEa7k4XFzU+MRDIWTwSeZypL1ZWgGD tCZES5WjsTLtyf/62YZ2wcGwwhei0iBmv3/bhVlC7Mqav7n989Z0LBKZaktjg4HP E22g6q/PlMgG4sCtEvMhXaANdnCWxMpIpbSHHQzPPT+CP02/sntgpR+vQpunpPiX GyvazOQb6Eaz+SGIjGJ9uSTfNzuoLsSJuX38tSQ0qKfVlIhlEcTeWQ/HR8tuFumk bKjfmx+rjo01qqvQ+UqNGAFFezOwrY3rzmuSnLxuEWDNFH4CUlUUq5li7o7xP0c0 nx+YjF/6/ZnNG43ow6QOHw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1739210207; x= 1739296607; bh=aL5vU4AQTAt1GuJKWFcWB/1PAooHMP+SRXFny0kf0zw=; b=Q Gb1uRijz60MD6XO56aKcykzKHMbICaV9ZDRYomEMhTpaD82Xecjr/yvG3VerqoEY q8m3NerjYwHNx873JV7O0RkYwbHxab/zyqYiVjbrclQdPjN6edz9OSFQh3ONuU07 ZRgzvkJdwAfLmFEQDLaHcbJwg6VJIANt7x+KSjBxDptAZ2gFVSFeZu3ruo2VICUF nKsw8YvcSf6MZnT8R2OgQOusscNA8nUvkIAdejDySHvI7Qbo8ESB426cXnEPfRTv FwN6oICJPd214ge2mfdj/jhn5CZnfLTyxTLC6aHyDmydT9bykywCyW94OqtD7xD0 Ps13uu9GcUktfKSCwDn6Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdefkeejfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfgggtgfesthekredtredt jeenucfhrhhomheppfhikhhlrghsucfunpguvghrlhhunhguuceonhhikhhlrghsrdhsoh guvghrlhhunhguodhrvghnvghsrghssehrrghgnhgrthgvtghhrdhsvgeqnecuggftrfgr thhtvghrnhepheeigfeuveeutdefhfehgeekvedtleeuueekveefudehhffhjeffgfegff elfeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep nhhikhhlrghsrdhsohguvghrlhhunhgusehrrghgnhgrthgvtghhrdhsvgdpnhgspghrtg hpthhtohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepshgrkhgrrhhirdgr ihhluhhssehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepmhgthhgvhhgrsg eskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhomhhirdhvrghlkhgvihhnvghnodhr vghnvghsrghssehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthhopehlihhnuh igqdhmvgguihgrsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhu gidqrhgvnhgvshgrshdqshhotgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtth hopehnihhklhgrshdrshhouggvrhhluhhnugdorhgvnhgvshgrshesrhgrghhnrghtvggt hhdrshgv X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Feb 2025 12:56:47 -0500 (EST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Sakari Ailus , Mauro Carvalho Chehab , Tomi Valkeinen , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Cc: =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH v3 2/5] media: rcar-vin: Remove superfluous suspended state Date: Mon, 10 Feb 2025 18:56:12 +0100 Message-ID: <20250210175615.1686529-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250210175615.1686529-1-niklas.soderlund+renesas@ragnatech.se> References: <20250210175615.1686529-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The VIN state of suspended is superfluous. The logic was that when the device were suspended and in a RUNNING state the state was set to SUSPENDED. And when resuming it checked if the state is SUSPENDED and if so started the device and changed it to RUNNING. This can be avoided by simply checking if the device is in a RUNNING state at both suspend and resume callbacks. Remove the unneeded complexity. Signed-off-by: Niklas Söderlund Reviewed-by: Tomi Valkeinen Tested-by: Tomi Valkeinen --- * Changes since v2 - Update commit message. --- drivers/media/platform/renesas/rcar-vin/rcar-core.c | 4 +--- drivers/media/platform/renesas/rcar-vin/rcar-vin.h | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/media/platform/renesas/rcar-vin/rcar-core.c index ddfb18e6e7a4..b8e35ef4d9d8 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c @@ -1085,8 +1085,6 @@ static int __maybe_unused rvin_suspend(struct device *dev) rvin_stop_streaming(vin); - vin->state = SUSPENDED; - return 0; } @@ -1094,7 +1092,7 @@ static int __maybe_unused rvin_resume(struct device *dev) { struct rvin_dev *vin = dev_get_drvdata(dev); - if (vin->state != SUSPENDED) + if (vin->state != RUNNING) return 0; /* diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-vin.h b/drivers/media/platform/renesas/rcar-vin/rcar-vin.h index d5763462809a..4cb25d8bbf32 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-vin.h +++ b/drivers/media/platform/renesas/rcar-vin/rcar-vin.h @@ -67,14 +67,12 @@ enum rvin_isp_id { * @STARTING: Capture starting up * @RUNNING: Operation in progress have buffers * @STOPPING: Stopping operation - * @SUSPENDED: Capture is suspended */ enum rvin_dma_state { STOPPED = 0, STARTING, RUNNING, STOPPING, - SUSPENDED, }; /** From patchwork Mon Feb 10 17:56:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13968317 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7EDC2566D6; Mon, 10 Feb 2025 17:56:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739210212; cv=none; b=dV4Pa/ouw6rz7KDgayLRezYk3zIJ4lGf4em4dPkybXvtmyGHzdAlaMsqxCOYzmGHzwlYY8eUgpGjMMAaYnnCXizWwgUEUAjZI9qaMOgpLi/s1mfW6cxigvQGi49ag8/SMkhYGPFuCBqFe4KshZ9nzGJphOrpcKCHpX0d/k3zkRQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739210212; c=relaxed/simple; bh=WX8duDp9UY2AK1yL1NPEKAQIbrBRfcGMd8Mq0Ut4dAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tf+2CuqPAHghtmvzy8ISp/x7Oi2oQ06JPNDJPoAYQX/LLRk6tqW07vnFdMh6DWShcBlAqweTDdlf85WRaALSyPbqUKW05bO2nLtS1rUe7xFWcxh+wXx/jSnLzKckQYFlzzgBoFTZdfS7lWDI9tcSBlmweDt+ZbcLDT/LGPeASwY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=LzJg81ZH; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=X+00LhNy; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="LzJg81ZH"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="X+00LhNy" Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id AF8B31140225; Mon, 10 Feb 2025 12:56:49 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Mon, 10 Feb 2025 12:56:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1739210209; x=1739296609; bh=mArqwrKsYh/Zl4yEqXMR1NzP9ZxW1whG54O8bnLGmyM=; b= LzJg81ZHYqUH6FAeR+hW42RSa76DVwQyy2tuNxQ7eDNzku38+j2QiC/a5y/a8BKQ o8jHwVkR2BUbSgBHxDBpsww4QldoDP7mIWSzrv8YWMKqsm4CiItZ6gGSYfp922TG gm7fMVmTpkXPkONHZqjoDadmjk0i7ssvAahhEHXDFoxtOhJAfKqB6CjIgFsFcNMo NNsb/k8bRenQ+n2UuS2Qky+yXlxvnpb1zeYpUjGruzr+No97zkl9B6hSMr8xLD+w FMmlDtSu9jj/E+jK/KA2sv+hsdArli3tnRU3SUtFwx9ZbeaXf2xAcXgh/HrXGGbp lwnpHuwO7N+Ea2pLKxs1Jg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1739210209; x= 1739296609; bh=mArqwrKsYh/Zl4yEqXMR1NzP9ZxW1whG54O8bnLGmyM=; b=X +00LhNyuZ74K1dHOa91CpiHJ6JwyZcyPtd7SnUtSi7qSK5/00TYoinVEaeOa2ySZ mlBsbzMazCgwvMmIiydd/uXboQ7i6ptvp4DgnLqGPoqkUshwT/JMkqQSRdeaIijr Hjpls7b1tow2TuT2ChgbDCUwHWH4e+4np0Szv0o9NmppzkaztHjmOKzcaeIo3ko7 QlE+hGSyVjXs3L2K7Z011V/7ws1jnpX4MIFzeRn9/PD3aSunknbBuLOqstQ4OeO+ /2ZyqNbg0dDoB2tXnAkvMOoAhLP44ajJGF37SfkOb0NjgtNYVpffcrp58jd6dSvQ wjflk6q9qXxTTQXs6tEyQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdefkeejvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfgggtgfesthekredtredt jeenucfhrhhomheppfhikhhlrghsucfunpguvghrlhhunhguuceonhhikhhlrghsrdhsoh guvghrlhhunhguodhrvghnvghsrghssehrrghgnhgrthgvtghhrdhsvgeqnecuggftrfgr thhtvghrnhepheeigfeuveeutdefhfehgeekvedtleeuueekveefudehhffhjeffgfegff elfeegnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhep nhhikhhlrghsrdhsohguvghrlhhunhgusehrrghgnhgrthgvtghhrdhsvgdpnhgspghrtg hpthhtohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepshgrkhgrrhhirdgr ihhluhhssehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepmhgthhgvhhgrsg eskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhomhhirdhvrghlkhgvihhnvghnodhr vghnvghsrghssehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthhopehlihhnuh igqdhmvgguihgrsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhu gidqrhgvnhgvshgrshdqshhotgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtth hopehnihhklhgrshdrshhouggvrhhluhhnugdorhgvnhgvshgrshesrhgrghhnrghtvggt hhdrshgv X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Feb 2025 12:56:49 -0500 (EST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Sakari Ailus , Mauro Carvalho Chehab , Tomi Valkeinen , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Cc: =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH v3 3/5] media: rcar-vin: Remove superfluous starting state Date: Mon, 10 Feb 2025 18:56:13 +0100 Message-ID: <20250210175615.1686529-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250210175615.1686529-1-niklas.soderlund+renesas@ragnatech.se> References: <20250210175615.1686529-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The STARTING state is superfluous and can be replaced with a check of the sequence counter. The design idea is that the first buffer returned from the driver have to come from the first hardware buffer slot. Failing this the first 3 buffers queued to the device can be returned out-of-order. But it's much clearer to check the sequence counter to only return the first buffer if it comes from hardware slot 0 then it is to carry around an extra state just for this. Remove the unneeded state and replace it with a simpler check. Signed-off-by: Niklas Söderlund Reviewed-by: Tomi Valkeinen Tested-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 5 ++--- drivers/media/platform/renesas/rcar-vin/rcar-vin.h | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c index a16adc6fd4dc..ba55ccf648de 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c @@ -1064,7 +1064,7 @@ static int rvin_capture_start(struct rvin_dev *vin) /* Continuous Frame Capture Mode */ rvin_write(vin, VNFC_C_FRAME, VNFC_REG); - vin->state = STARTING; + vin->state = RUNNING; return 0; } @@ -1120,14 +1120,13 @@ static irqreturn_t rvin_irq(int irq, void *data) * To hand buffers back in a known order to userspace start * to capture first from slot 0. */ - if (vin->state == STARTING) { + if (!vin->sequence) { if (slot != 0) { vin_dbg(vin, "Starting sync slot: %d\n", slot); goto done; } vin_dbg(vin, "Capture start synced!\n"); - vin->state = RUNNING; } /* Capture frame */ diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-vin.h b/drivers/media/platform/renesas/rcar-vin/rcar-vin.h index 4cb25d8bbf32..f13ef379d095 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-vin.h +++ b/drivers/media/platform/renesas/rcar-vin/rcar-vin.h @@ -64,13 +64,11 @@ enum rvin_isp_id { /** * enum rvin_dma_state - DMA states * @STOPPED: No operation in progress - * @STARTING: Capture starting up * @RUNNING: Operation in progress have buffers * @STOPPING: Stopping operation */ enum rvin_dma_state { STOPPED = 0, - STARTING, RUNNING, STOPPING, }; From patchwork Mon Feb 10 17:56:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13968318 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD0E52566E2; Mon, 10 Feb 2025 17:56:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739210214; cv=none; b=aX1xwp54cSnBscN2kW8SKM30OmuH335CmyliY0nk4zcEUUktFYJgwso0Av7vfdhcX9KLDT0LLoCrKDjJtQvSaOV0/xi6Op1Yu4VgFKf1gnAsE8HMYzAUoPSJrNFeLZye2xz0c+f2W37P/77sH05foJ6B538SKOsTeOPcP2oxJ6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739210214; c=relaxed/simple; bh=43csYOVOJq5a1sK5zONrF7t6naHregr/2lfLrGBWw6A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JU93MSQNHw1hVWj3VLLPaNg+ZFLtVXefL8Wj7kVWZ4MDFTiwH4oMJShhu/3p+yXy1RuMy9SAIXwD8aBIeIBW5virJBN64w5oK0+W9gGUEE4n+saA+kzkJ1xHAygXE/s7HM/m6n+3QQ7h/nj50UQGyrS1NzwLfEHn26sJiWPcQOU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=VtF8KSgm; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=l+ErpjX8; arc=none smtp.client-ip=103.168.172.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="VtF8KSgm"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="l+ErpjX8" Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id B399E13809AF; Mon, 10 Feb 2025 12:56:51 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Mon, 10 Feb 2025 12:56:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1739210211; x=1739296611; bh=HsdG9KkcdTzgBNoNWGlPU+eXaZWfTVKwtTMyGjfU0d4=; b= VtF8KSgm+diRaI6qsNFFVwRumyfut4rSiI3Gsg/A6Dw1H7tIt3KpWUQ9Te3dw+qj MlhNzFZJheLh7FF7sS612Kn+j3PBPZu0XlH7OWYW2QdF0u6U3Byn++05ZFfMmQde ZvmrVauuvzvnvJJn9sZsDXAfGzlEtdfBPOeJUXtU5ymIorrRrzI9myEpjzOD9hH1 P1yvhWKBUhI9pTX4RDsoc9jgfY7SBHXF6UN/4fML51mCyLDiOSD4a9dZI70d2eIJ m9aq50Ldx7cX59ZiFzg56o/HklFjrp0qaecFexNITDFyx0w9hCHTZ+w5QZ8xJhwk NLXzm1WslZNbAa+FRgEbvQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1739210211; x= 1739296611; bh=HsdG9KkcdTzgBNoNWGlPU+eXaZWfTVKwtTMyGjfU0d4=; b=l +ErpjX8DZHbSVCzV0Fgwqh475N15L9cy8uhmRmonqZz6wIS5YNT9kllU3fi8DyoU 8t+BIYC3fxwI/R20KBZwftg8DfEmt9VE6AUCTbN0s6kJFqo92efZGJfHz3sU6V7T K8ZFFDUPKReaIxznP7W8+dekH5EzwYCGg9IPqYbGov7KZTsYJnppKgQ1qtjjrc0I 6/UIhYy2+oVNOWlMKBLg2RJADNPA8zIlInl3wywMymYn3fcVs9rFDq09EyLqbx0V DIHjLQZ/7wkx15I1AtGn0ShlyAtn1JLxqNnyi+RW1dq4+FmBJESZY204+WHGMX6g 09Ajrb+TEDVtXK/zdpLdw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdefkeejvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfgggtgfesthekredtredt jeenucfhrhhomheppfhikhhlrghsucfunpguvghrlhhunhguuceonhhikhhlrghsrdhsoh guvghrlhhunhguodhrvghnvghsrghssehrrghgnhgrthgvtghhrdhsvgeqnecuggftrfgr thhtvghrnhepheeigfeuveeutdefhfehgeekvedtleeuueekveefudehhffhjeffgfegff elfeegnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhep nhhikhhlrghsrdhsohguvghrlhhunhgusehrrghgnhgrthgvtghhrdhsvgdpnhgspghrtg hpthhtohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepshgrkhgrrhhirdgr ihhluhhssehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepmhgthhgvhhgrsg eskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhomhhirdhvrghlkhgvihhnvghnodhr vghnvghsrghssehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthhopehlihhnuh igqdhmvgguihgrsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhu gidqrhgvnhgvshgrshdqshhotgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtth hopehnihhklhgrshdrshhouggvrhhluhhnugdorhgvnhgvshgrshesrhgrghhnrghtvggt hhdrshgv X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Feb 2025 12:56:50 -0500 (EST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Sakari Ailus , Mauro Carvalho Chehab , Tomi Valkeinen , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Cc: =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH v3 4/5] media: rcar-vin: Simplify the shutdown process Date: Mon, 10 Feb 2025 18:56:14 +0100 Message-ID: <20250210175615.1686529-5-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250210175615.1686529-1-niklas.soderlund+renesas@ragnatech.se> References: <20250210175615.1686529-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When shutting down capture extra care was needed to try and complete a buffer that was involved in the emulated support for SEQ_{TB,BT}. This was needed as a buffer might be queued once to the driver, but two times to the hardware using different offsets. As support for SEQ_{TB,BT} is now removed this shutdown process can be greatly simplified. And in addition the state keeping of the VIN device can be reduced to a single boolean value instead of keeping track of this SEQ_{TB,BT} stopping dance. Signed-off-by: Niklas Söderlund Reviewed-by: Tomi Valkeinen Tested-by: Tomi Valkeinen --- .../platform/renesas/rcar-vin/rcar-core.c | 4 +- .../platform/renesas/rcar-vin/rcar-dma.c | 75 ++++++------------- .../platform/renesas/rcar-vin/rcar-vin.h | 18 +---- 3 files changed, 26 insertions(+), 71 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/media/platform/renesas/rcar-vin/rcar-core.c index b8e35ef4d9d8..cfbc9ec27706 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c @@ -1080,7 +1080,7 @@ static int __maybe_unused rvin_suspend(struct device *dev) { struct rvin_dev *vin = dev_get_drvdata(dev); - if (vin->state != RUNNING) + if (!vin->running) return 0; rvin_stop_streaming(vin); @@ -1092,7 +1092,7 @@ static int __maybe_unused rvin_resume(struct device *dev) { struct rvin_dev *vin = dev_get_drvdata(dev); - if (vin->state != RUNNING) + if (!vin->running) return 0; /* diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c index ba55ccf648de..3eb6b5fcac89 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c @@ -1022,8 +1022,7 @@ static void rvin_fill_hw_slot(struct rvin_dev *vin, int slot) if (WARN_ON(vin->buf_hw[slot].buffer)) return; - if ((vin->state != STOPPED && vin->state != RUNNING) || - list_empty(&vin->buf_list)) { + if (list_empty(&vin->buf_list)) { vin->buf_hw[slot].buffer = NULL; phys_addr = vin->scratch_phys; } else { @@ -1064,8 +1063,6 @@ static int rvin_capture_start(struct rvin_dev *vin) /* Continuous Frame Capture Mode */ rvin_write(vin, VNFC_C_FRAME, VNFC_REG); - vin->state = RUNNING; - return 0; } @@ -1106,9 +1103,9 @@ static irqreturn_t rvin_irq(int irq, void *data) if (!(int_status & VNINTS_FIS)) goto done; - /* Nothing to do if capture status is 'STOPPED' */ - if (vin->state == STOPPED) { - vin_dbg(vin, "IRQ while state stopped\n"); + /* Nothing to do if not running. */ + if (!vin->running) { + vin_dbg(vin, "IRQ while not running, ignoring\n"); goto done; } @@ -1389,6 +1386,8 @@ int rvin_start_streaming(struct rvin_dev *vin) if (ret) rvin_set_stream(vin, 0); + vin->running = true; + spin_unlock_irqrestore(&vin->qlock, flags); return ret; @@ -1421,44 +1420,21 @@ static int rvin_start_streaming_vq(struct vb2_queue *vq, unsigned int count) void rvin_stop_streaming(struct rvin_dev *vin) { - unsigned int i, retries; unsigned long flags; - bool buffersFreed; spin_lock_irqsave(&vin->qlock, flags); - if (vin->state == STOPPED) { + if (!vin->running) { spin_unlock_irqrestore(&vin->qlock, flags); return; } - vin->state = STOPPING; - - /* Wait until only scratch buffer is used, max 3 interrupts. */ - retries = 0; - while (retries++ < RVIN_RETRIES) { - buffersFreed = true; - for (i = 0; i < HW_BUFFER_NUM; i++) - if (vin->buf_hw[i].buffer) - buffersFreed = false; - - if (buffersFreed) - break; - - spin_unlock_irqrestore(&vin->qlock, flags); - msleep(RVIN_TIMEOUT_MS); - spin_lock_irqsave(&vin->qlock, flags); - } - /* Wait for streaming to stop */ - retries = 0; - while (retries++ < RVIN_RETRIES) { - + for (unsigned int i = 0; i < RVIN_RETRIES; i++) { rvin_capture_stop(vin); /* Check if HW is stopped */ if (!rvin_capture_active(vin)) { - vin->state = STOPPED; break; } @@ -1467,32 +1443,25 @@ void rvin_stop_streaming(struct rvin_dev *vin) spin_lock_irqsave(&vin->qlock, flags); } - if (!buffersFreed || vin->state != STOPPED) { - /* - * If this happens something have gone horribly wrong. - * Set state to stopped to prevent the interrupt handler - * to make things worse... - */ - vin_err(vin, "Failed stop HW, something is seriously broken\n"); - vin->state = STOPPED; - } + if (rvin_capture_active(vin)) + vin_err(vin, "Hardware did not stop\n"); + + vin->running = false; spin_unlock_irqrestore(&vin->qlock, flags); - /* If something went wrong, free buffers with an error. */ - if (!buffersFreed) { - return_unused_buffers(vin, VB2_BUF_STATE_ERROR); - for (i = 0; i < HW_BUFFER_NUM; i++) { - if (vin->buf_hw[i].buffer) - vb2_buffer_done(&vin->buf_hw[i].buffer->vb2_buf, - VB2_BUF_STATE_ERROR); - } - } - rvin_set_stream(vin, 0); /* disable interrupts */ rvin_disable_interrupts(vin); + + /* Return unprocessed buffers from hardware. */ + for (unsigned int i = 0; i < HW_BUFFER_NUM; i++) { + if (vin->buf_hw[i].buffer) + vb2_buffer_done(&vin->buf_hw[i].buffer->vb2_buf, + VB2_BUF_STATE_ERROR); + } + } static void rvin_stop_streaming_vq(struct vb2_queue *vq) @@ -1538,8 +1507,6 @@ int rvin_dma_register(struct rvin_dev *vin, int irq) spin_lock_init(&vin->qlock); - vin->state = STOPPED; - for (i = 0; i < HW_BUFFER_NUM; i++) vin->buf_hw[i].buffer = NULL; @@ -1642,7 +1609,7 @@ void rvin_set_alpha(struct rvin_dev *vin, unsigned int alpha) vin->alpha = alpha; - if (vin->state == STOPPED) + if (!vin->running) goto out; switch (vin->format.pixelformat) { diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-vin.h b/drivers/media/platform/renesas/rcar-vin/rcar-vin.h index f13ef379d095..934474d2334a 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-vin.h +++ b/drivers/media/platform/renesas/rcar-vin/rcar-vin.h @@ -61,18 +61,6 @@ enum rvin_isp_id { (((unsigned int)RVIN_CSI_MAX) > ((unsigned int)RVIN_ISP_MAX) ? \ (unsigned int)RVIN_CSI_MAX : (unsigned int)RVIN_ISP_MAX) -/** - * enum rvin_dma_state - DMA states - * @STOPPED: No operation in progress - * @RUNNING: Operation in progress have buffers - * @STOPPING: Stopping operation - */ -enum rvin_dma_state { - STOPPED = 0, - RUNNING, - STOPPING, -}; - /** * struct rvin_video_format - Data format stored in memory * @fourcc: Pixelformat @@ -173,11 +161,11 @@ struct rvin_info { * @scratch: cpu address for scratch buffer * @scratch_phys: physical address of the scratch buffer * - * @qlock: protects @buf_hw, @buf_list, @sequence and @state + * @qlock: Protects @buf_hw, @buf_list, @sequence and @running * @buf_hw: Keeps track of buffers given to HW slot * @buf_list: list of queued buffers * @sequence: V4L2 buffers sequence number - * @state: keeps track of operation state + * @running: Keeps track of if the VIN is running * * @is_csi: flag to mark the VIN as using a CSI-2 subdevice * @chsel: Cached value of the current CSI-2 channel selection @@ -220,7 +208,7 @@ struct rvin_dev { } buf_hw[HW_BUFFER_NUM]; struct list_head buf_list; unsigned int sequence; - enum rvin_dma_state state; + bool running; bool is_csi; unsigned int chsel; From patchwork Mon Feb 10 17:56:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13968319 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3BEC25B66E; Mon, 10 Feb 2025 17:56:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739210216; cv=none; b=lbpMUjug94q0M4ySPk0bxhqOrKoNW+0Y/bye1CPOt72F0aAr97k2MmgimY/fEH+XVxQBHb9xnlFaFBCNgQugjxg1mYIhE0g1IqLp7o8hyMKoweGVCRytMcXYqKOVtZ3xStb1Jezj9FR2Pn0i3w2CalM6ayxR/cnKdRgB5oJvS5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739210216; c=relaxed/simple; bh=H4IDeRAmX7Y4WnQ+uVNW07kZp2AdoCg6R147e9SL34c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BrZBePAYTS+Q0QbY0wA2H1LiSBrAFZT+0xqMmo95YFoAeOvwaTEEJp+/VN36DIGXqURpgggx2qDlBIc0rHpAA+T9xcIfYVx48ybbOwtVa/+ZtWywjfJGsyuM5Kex/mwSI+BbOy4xdrA8BR3kXs6KVyrQd42bBaTnqEfrKILmgng= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=O6WtvWV7; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=FZHz04bQ; arc=none smtp.client-ip=103.168.172.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="O6WtvWV7"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="FZHz04bQ" Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id A55E213809B5; Mon, 10 Feb 2025 12:56:53 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Mon, 10 Feb 2025 12:56:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1739210213; x=1739296613; bh=OS5OapSvaFpjT9JRLG5DYp9nzVMqDiBRyUF9duh/Pbs=; b= O6WtvWV7MRT7WxItCGJtME1Sd7Vldo6hqF5hzHGl9vcgjINuOu41Gu4A0YV22+FX TjHFUTCpL5hAXsIIdJamq001vbnMzK1PhTAoVX/xiH3uznx+Uo/RtUw4KoXc33S9 iG5MzCRY89KzNd2z/GcuV+A3cd+UAGgWf61cPnRVBPSgp747aVzlnT/XJQvgY7p3 F4Za9ysoN2G6oyAgbUHv8cb84Ke5xPbgSPt3OMgP3uSFABpfup/iLf9dk/Dup9yT hVluVR36wwUMou7sEUCY1f24rVzuxRONq/p8yvHbRdjI6HiNkCfryaTnhvTdiVkT wRL9Mjc+zpH6DdIqBaIfQQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1739210213; x= 1739296613; bh=OS5OapSvaFpjT9JRLG5DYp9nzVMqDiBRyUF9duh/Pbs=; b=F ZHz04bQst5qFZlBfWLr5ZevqYVsxl/ipwfUNQiXAQww23TjG71uPROGGzpiRrJps XcMBCWmpqjQDFtNwMrNJA1xacAZ3ZJw3sZHzyaqng5SvxLlLxBTWj0GTI5fLJ7VK 7EN+8px77VMGEL3Gxe1+zRDPGHzXP/O4Bh+zaFqpaQbUf7yLTXLEKlG7zO3FKkOw VuFuRoWV/VKJM8eDwHinuEQvothVK6XcLdgBe8IJ/6uyoInkLSnpjwx1V4bF6jde 1d6CYFcrnFifqhs3XPUAxHCURuNDDLA8ZZVnXorLpFKd10p388aDfiLnrSQD2eYs ousW62MI6tjLGkj38ZmnA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdefkeejfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfgggtgfesthekredtredt jeenucfhrhhomheppfhikhhlrghsucfunpguvghrlhhunhguuceonhhikhhlrghsrdhsoh guvghrlhhunhguodhrvghnvghsrghssehrrghgnhgrthgvtghhrdhsvgeqnecuggftrfgr thhtvghrnhepheeigfeuveeutdefhfehgeekvedtleeuueekveefudehhffhjeffgfegff elfeegnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhep nhhikhhlrghsrdhsohguvghrlhhunhgusehrrghgnhgrthgvtghhrdhsvgdpnhgspghrtg hpthhtohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepshgrkhgrrhhirdgr ihhluhhssehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepmhgthhgvhhgrsg eskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhomhhirdhvrghlkhgvihhnvghnodhr vghnvghsrghssehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthhopehlihhnuh igqdhmvgguihgrsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhu gidqrhgvnhgvshgrshdqshhotgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtth hopehnihhklhgrshdrshhouggvrhhluhhnugdorhgvnhgvshgrshesrhgrghhnrghtvggt hhdrshgv X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Feb 2025 12:56:53 -0500 (EST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Sakari Ailus , Mauro Carvalho Chehab , Tomi Valkeinen , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Cc: =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH v3 5/5] media: rcar-csi2: Remove hack to detect NTSC content Date: Mon, 10 Feb 2025 18:56:15 +0100 Message-ID: <20250210175615.1686529-6-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250210175615.1686529-1-niklas.soderlund+renesas@ragnatech.se> References: <20250210175615.1686529-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In an effort to emulate support for SEQ_{TB,BT} in the R-Car VIN driver on data captured from a CVBS input a hack was added to detect NTSC vs PAL. This is ugly and as support for emulated SEQ_{TB,BT} have been removed from the VIN driver remove the ugly hack. Signed-off-by: Niklas Söderlund Reviewed-by: Tomi Valkeinen Tested-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c index 0a53dd47d7bf..7dfa2729209d 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -1045,16 +1045,10 @@ static int rcsi2_start_receiver_gen3(struct rcar_csi2 *priv, vcdt2 |= vcdt_part << ((i % 2) * 16); } - if (fmt->field == V4L2_FIELD_ALTERNATE) { + if (fmt->field == V4L2_FIELD_ALTERNATE) fld = FLD_DET_SEL(1) | FLD_FLD_EN4 | FLD_FLD_EN3 | FLD_FLD_EN2 | FLD_FLD_EN; - if (fmt->height == 240) - fld |= FLD_FLD_NUM(0); - else - fld |= FLD_FLD_NUM(1); - } - /* * Get the number of active data lanes inspecting the remote mbus * configuration.