From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3901449B1F7 for ; Wed, 14 Oct 2026 11:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791976364; cv=none; b=lJArGSUCbCrEn0EzdKLqKI3ZrdKngiPd/oxzSB4uiO+7dU+dHC0ZGHRvC9rMHUbc0q66zmWF4+wZYZVq0CD9Ga4uJpLEY/3LcXEeEX7zawG2Lcv6Fl/PNMOrcB0mYxNjeB0ZN+ztae/h2FrUr20/iDvn0MAkIL87aGaPJ1Uiwj4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791976364; c=relaxed/simple; bh=Ggq3Uy/XaqA2vSX4D20ALhGnBHxCMCe5R5neJ3oJ4ng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V1rTXtNR2XrN41Ar0cYEhNbxCeWoVhHlG6shMzCGW5dTFBcAqk2fRgWOrkZz4Lg1akQx1c4oVUAZPug/xstv4MQgtkolYPLYUHvR4jHsCFx4ccbjJAJdRi/g/b8uLAVRtPehXNktPfjLhKj6MGon+3McVXix2Hnbme1KSd304WU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BZUt52H7; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BZUt52H7" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-48b042c0759so2997336f8f.2 for ; Wed, 14 Oct 2026 04:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791976356; x=1792581156; darn=lists.linux.dev; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Ql/VTrEuXaadEBjKgJVl5o63RIe6hsZ90eJUJtNqjG0=; b=BZUt52H7FWxSz9C0F9aPvcDzpEW3Xpie7+aPr8rQoqby1lmEg3dAzDZtRy0/jJQik8 y2jxuU1WLv9trOOePGPlD5pXyGcTkuiwWQveYu5zILJygQk677oMa+yPOXp7yGTV3KjW 2hdTx4nbvW2JfByvE/WJMyph2UB5bipf0XUvbfX+1yYEdrOnMTGYwye25ECSz4baJXi7 tu69fmK8tzqe8OtCZXZqianK0fmXQu7lfiJuryZx9wv75QOMMTPkVxc9qTj7VvbW+VY2 S1jojUrYu/KeSA1ka2I9wTpG1dPWPc/M5U/g9xtRzHCu34WepKvtV3QatcE7huGKay2S uX4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791976356; x=1792581156; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Ql/VTrEuXaadEBjKgJVl5o63RIe6hsZ90eJUJtNqjG0=; b=QwL+3yY+drht//0mzF/zNNnMQ7FpWwfjuniGMxOiU7RIKqidqbFF2CAEyCL9V3FKJb Dm2DMb0kMhNnN6h2fUSHnjplIJH6RoM/KMyvJFeqh91vs8II0+9tHrHy0jCAEg4EFh7u lE+XKSQbMYTG4UlJbqDBJu3fAjkdUXdeCusecki0KDE6NWNr6YEhX7QXbO/Fh/Zdwv6m djxz3MSvuv4JYT68gAs5f6d674wkao5YcwdwtOKShJhGCfqktzsgRyjHNAaQOxy9BARl t1uoa8bVzwegMnx1qWpOcl5FC5XcazrwTykjLXyBX79WrkslVRHR8lGO2A2anSdttGU9 Mtqg== X-Forwarded-Encrypted: i=1; AKwUvByiqZrhwRZvLs/MQWbVgHxCub+5olv/kXoJiDlh0LZtySNd+cI+cBV+P5nmnGiQd74eMTq3S0nOrnolx4dX@lists.linux.dev X-Gm-Message-State: AFq9FYLBj4TZMmddg8EG4eZIo8EySql1N03ziIuuBZowMNysiV0o1u/P H1JhbdrFxwznb/PtJQuoVENjElBuymROTvbux19SlnQYKDw5cbAsiMMk X-Gm-Gg: AYBFou3oHfQw01CKmTprT23uOUZOuNVzh0c5+2C4mv+pPgD2mXi/x5cUCE3IxBR7BxP kNJ09lJnklXK81URVNwMyMuzQEEcjqWZOnm0Jo6mkCaP/3ChD49Ny2Xfuxlfbyl7AJKnmTHhT6T 1F/05AE0FyfXf4TvJQvowyqCPtpT4hXjeqWKTCBjlPv4NmH3wyuk7AaapVgL8IpNWPRF0ZESeXj hpKzfOgSccGKdn8+nipi9/GGiZMt98rFVFzOouugxiS+bsWfSoinZYDNBbpwSchZ9utLVLDFh7l B01dyYKD/l2DUlapxkf/COx6uO3LMlGuqXBz/r+4H3hwaO/Y0HEOdjZOT/DWkUfQEXCCaDZKDMb hBgO8GpcMnlWl5Mh2JQ4VVitNfRfmosX9n8oT1Yqa/hcMC/QKg/1LqySw0659g+53aP9QbzMN7E eEvBOkeZ7r8HVzE9Ez3oqMssRqYjgdhwh6egjrqiQbl22C4weHlz1bz4SpfNOt2JYc6gzwgN6OT ea01pG+xTZQnD0EbeVoGA== X-Received: by 2002:a05:6000:400e:b0:48d:ea67:79d4 with SMTP id ffacd0b85a97d-48dea677b9amr2949917f8f.53.1791976355895; Wed, 14 Oct 2026 04:12:35 -0700 (PDT) Received: from ubuntu-4gb-nbg1-1.. ([2a01:4f8:1c19:b0ad::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48deeadc0b5sm1846481f8f.6.2026.10.14.04.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2026 04:12:35 -0700 (PDT) From: =?UTF-8?q?Rare=C8=99-Mihai=20Vladu?= To: Hans de Goede , Mauro Carvalho Chehab Cc: Sakari Ailus , Andy Shevchenko , Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, =?UTF-8?q?Rare=C8=99-Mihai=20Vladu?= Subject: [PATCH v2 3/4] media: atomisp: queue: move circbuf types and helpers to queue_comm.h Date: Wed, 14 Oct 2026 11:12:12 +0000 Message-ID: <20261014111213.1967452-4-vladurares@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261014111213.1967452-1-vladurares@gmail.com> References: <20261014111213.1967452-1-vladurares@gmail.com> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The remote queue code only needs the circbuf descriptor and element layouts plus five small descriptor helpers from the circbuf library. Move them into ia_css_queue_comm.h and include that header instead of the circbuf ones. The descriptor and element layouts are shared with the SP firmware and are moved unchanged, including their static_asserts. While at it, drop the OP___assert() NULL checks from the moved helpers, as every caller passes the address of a local variable, and convert the moved code to the kernel u8/u32 types and the usual function declaration style. Signed-off-by: RareČ™-Mihai Vladu --- .../queue/interface/ia_css_queue_comm.h | 130 +++++++++++++++++- .../atomisp/pci/runtime/queue/src/queue.c | 2 - .../pci/runtime/queue/src/queue_access.c | 1 - .../pci/runtime/queue/src/queue_access.h | 1 - .../media/atomisp/pci/sh_css_internal.h | 2 +- 5 files changed, 130 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/runtime/queue/interface/ia_css_queue_comm.h b/drivers/staging/media/atomisp/pci/runtime/queue/interface/ia_css_queue_comm.h index 7cd788e2b16bd..8323347bea6b4 100644 --- a/drivers/staging/media/atomisp/pci/runtime/queue/interface/ia_css_queue_comm.h +++ b/drivers/staging/media/atomisp/pci/runtime/queue/interface/ia_css_queue_comm.h @@ -7,8 +7,136 @@ #ifndef __IA_CSS_QUEUE_COMM_H #define __IA_CSS_QUEUE_COMM_H +#include +#include + #include "type_support.h" -#include "ia_css_circbuf.h" + +/**************************************************************** + * + * Portable Data structures + * + ****************************************************************/ +/* + * @brief Data structure for the circular descriptor. + */ +typedef struct ia_css_circbuf_desc_s ia_css_circbuf_desc_t; +struct ia_css_circbuf_desc_s { + u8 size; /* the maximum number of elements*/ + u8 step; /* number of bytes per element */ + u8 start; /* index of the oldest element */ + u8 end; /* index at which to write the new element */ +}; + +#define SIZE_OF_IA_CSS_CIRCBUF_DESC_S_STRUCT (4 * sizeof(u8)) + +static_assert(sizeof(struct ia_css_circbuf_desc_s) == SIZE_OF_IA_CSS_CIRCBUF_DESC_S_STRUCT); + +/* + * @brief Data structure for the circular buffer element. + */ +typedef struct ia_css_circbuf_elem_s ia_css_circbuf_elem_t; +struct ia_css_circbuf_elem_s { + u32 val; /* the value stored in the element */ +}; + +#define SIZE_OF_IA_CSS_CIRCBUF_ELEM_S_STRUCT (sizeof(u32)) + +static_assert(sizeof(struct ia_css_circbuf_elem_s) == SIZE_OF_IA_CSS_CIRCBUF_ELEM_S_STRUCT); + +/**************************************************************** + * + * Inline functions. + * + ****************************************************************/ +/* + * @brief Test if the circular buffer is empty. + * + * @param cb_desc The pointer to the circular buffer descriptor. + * + * @return + * - true when it is empty. + * - false when it is not empty. + */ +static inline bool ia_css_circbuf_desc_is_empty(ia_css_circbuf_desc_t *cb_desc) +{ + return (cb_desc->end == cb_desc->start); +} + +/* + * @brief Test if the circular buffer descriptor is full. + * + * @param cb_desc The pointer to the circular buffer + * descriptor. + * + * @return + * - true when it is full. + * - false when it is not full. + */ +static inline bool ia_css_circbuf_desc_is_full(ia_css_circbuf_desc_t *cb_desc) +{ + return ((cb_desc->end + 1) % cb_desc->size) == cb_desc->start; +} + +/* + * @brief Get the offset between two positions in the circular buffer + * descriptor. + * Get the offset from the source position to the terminal position, + * along the direction in which the new elements come in. + * + * @param cb_desc The pointer to the circular buffer descriptor. + * @param src_pos The source position. + * @param dest_pos The terminal position. + * + * @return the offset. + */ +static inline int ia_css_circbuf_desc_get_offset(ia_css_circbuf_desc_t *cb_desc, + u32 src_pos, u32 dest_pos) +{ + int offset; + + offset = (int)(dest_pos - src_pos); + offset += (offset < 0) ? cb_desc->size : 0; + + return offset; +} + +/* + * @brief Get the number of available elements. + * + * @param cb_desc The pointer to the circular buffer. + * + * @return The number of available elements. + */ +static inline u32 ia_css_circbuf_desc_get_num_elems(ia_css_circbuf_desc_t *cb_desc) +{ + int num; + + num = ia_css_circbuf_desc_get_offset(cb_desc, + cb_desc->start, + cb_desc->end); + + return (u32)num; +} + +/* + * @brief Get the number of free elements. + * + * @param cb_desc The pointer to the circular buffer descriptor. + * + * @return: The number of free elements. + */ +static inline u32 ia_css_circbuf_desc_get_free_elems(ia_css_circbuf_desc_t *cb_desc) +{ + u32 num; + + num = ia_css_circbuf_desc_get_offset(cb_desc, + cb_desc->start, + cb_desc->end); + + return (cb_desc->size - num); +} + /***************************************************************************** * Queue Public Data Structures *****************************************************************************/ diff --git a/drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c b/drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c index d3818fe8be364..79a67b3c614eb 100644 --- a/drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c +++ b/drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c @@ -6,8 +6,6 @@ #include "ia_css_queue.h" #include -#include -#include #include "queue_access.h" /***************************************************************************** diff --git a/drivers/staging/media/atomisp/pci/runtime/queue/src/queue_access.c b/drivers/staging/media/atomisp/pci/runtime/queue/src/queue_access.c index 2591d157870ce..65835420a13c0 100644 --- a/drivers/staging/media/atomisp/pci/runtime/queue/src/queue_access.c +++ b/drivers/staging/media/atomisp/pci/runtime/queue/src/queue_access.c @@ -8,7 +8,6 @@ #include "type_support.h" #include "queue_access.h" -#include "ia_css_circbuf.h" #include "sp.h" #include "assert_support.h" diff --git a/drivers/staging/media/atomisp/pci/runtime/queue/src/queue_access.h b/drivers/staging/media/atomisp/pci/runtime/queue/src/queue_access.h index 776c6d6cb1fcc..93dae469cff9a 100644 --- a/drivers/staging/media/atomisp/pci/runtime/queue/src/queue_access.h +++ b/drivers/staging/media/atomisp/pci/runtime/queue/src/queue_access.h @@ -11,7 +11,6 @@ #include #include -#include #define QUEUE_IGNORE_START_FLAG 0x0001 #define QUEUE_IGNORE_END_FLAG 0x0002 diff --git a/drivers/staging/media/atomisp/pci/sh_css_internal.h b/drivers/staging/media/atomisp/pci/sh_css_internal.h index ec68c16d42722..f08f918b361c4 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_internal.h +++ b/drivers/staging/media/atomisp/pci/sh_css_internal.h @@ -29,7 +29,7 @@ #include "sh_css_defs.h" #include "sh_css_uds.h" #include "dma.h" /* N_DMA_CHANNEL_ID */ -#include "ia_css_circbuf_comm.h" /* Circular buffer */ +#include "ia_css_queue_comm.h" #include "ia_css_frame_comm.h" #include "ia_css_3a.h" #include "ia_css_dvs.h" -- 2.43.0