From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 429EFC87FCA for ; Fri, 1 Aug 2025 09:38:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CE0yUTi8vaWBOP+ptSGUlpWi9dFsFhf4ychTYVoaqcU=; b=YHxjAUaUFjUU92KszHiin0TpAN o8MoEGvquPsi2HVlypZ7QEm0Y1bxaGMxsdsUuJZmToag2twY2rbyd0dHIUFtjN0oLFWCQvqVBkZg2 vULGCh19TVHOpU/vuQ+MBZT+BI1DmzWF8Mx8aOWA8wszugkyRXPdjuC//fl/MlrjIjCHTdQ+VSpqJ 1Q8iMiuSmP5OHBsFYbJjf7qudZr/XpAA4xGUyCxxiHKrk24zevmWqZAi17eG21OoYx6pb8WNrBrSD AV+vPTjH28TFAZ8CfLvY/8Ag7/u6dgJxLCemabZ79QKES7tDoBIlGdSuWr0ngfXbJQfpOIw83a/tJ N3Xbkb7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uhmDS-00000005O1A-4B0p; Fri, 01 Aug 2025 09:38:18 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uhm3h-00000005Mhi-1lCG for linux-arm-kernel@lists.infradead.org; Fri, 01 Aug 2025 09:28:15 +0000 Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-3a54a8a0122so685223f8f.2 for ; Fri, 01 Aug 2025 02:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1754040491; x=1754645291; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=CE0yUTi8vaWBOP+ptSGUlpWi9dFsFhf4ychTYVoaqcU=; b=KqZRQtSRLhy37+xgCkwVw3C4tOiGU7YYuOYwKPlrii8Vj6/MDO6sm7fdqi2+mJcrsL wimTMcCvdPlHnwxgZUevixpSiyeKPeNxSvGfxLIwKiXsaFeph/QWoII1QesBCJnHoDsn FG9dakf1ZqceMs+FcjoshEm8OhF84omN4lw1vzTFavrzAO03bHx+sWgJknKeabaxBlCZ MvqiU+tmyJHS5PCyllTOCT9CEotfAgH2VEU9x9HwSfnNsaxg2Pm9CgppHTIddzU08WHQ A6/F8eFsoD2z6iKIiEeQ+XNQn/5CItjzTPl6IjWs8Wrx0Aem99DIPbypIaH+aF9Pmsbe 6FfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754040491; x=1754645291; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CE0yUTi8vaWBOP+ptSGUlpWi9dFsFhf4ychTYVoaqcU=; b=QzP5De/E37+4GAKmUfA9trGhcGu8604I+2wiwoZY8Rg5ITCigtywg15+blKLE37HuN UpNPH1pQ7lENAgAQWuj5yfdiiDfNRJ3eE9rnXpJbvMKQJBV7b+xZwrf+UIT8jSEeQs0G 3RVQL+HvQO7F6ufozt8EM3SpqfDhCwylI7yq+sw/y7GH1Y5ItXI7gWo0n3GQ73f/haS2 fLhJ01vXPwBtcAVtSz5MgMiu2To6QKEyJvp+hF4dGc8yynFz35o205rrlYWEd42xtqzF xKWGP6pQ+LG1A4M4L89Zqm1xrkgMOcnWW8XnhOoBhY/1a0iv8eUILE33XnxARzV/EN4L x3NQ== X-Forwarded-Encrypted: i=1; AJvYcCW98PYaMs+aws3iB36ljOs3WSNPqIYDM65343SzieVHgxxSPKRCnjlXwq0KjtZcbnQYgFqyvv79XX+FtNRm7dk/@lists.infradead.org X-Gm-Message-State: AOJu0YxqhO9FMC5lR+kcNzURwPrxMNAcggoI1/aJzN1L0NdUTjmpLyY5 nxpK/sRwTfQmjitkoarQK1cVNk/uluzizwMVn0V+1xsqGyJuS/MWe4MGa/WIbRG5YxAaZ5UNuAU cJovPdtipimb2FazU/g== X-Google-Smtp-Source: AGHT+IGclLlFV2GkuMwBDGhI/am9e4aUyiArGDfT6eX1AfmQulH6DcrQSI5ElTu2oPPFAXeEXjf99dWLtJ2pyZY= X-Received: from wrpa8.prod.google.com ([2002:adf:eec8:0:b0:3b7:8342:dc50]) (user=verhaegen job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:2311:b0:3b4:9b82:d44c with SMTP id ffacd0b85a97d-3b794fc3115mr8167881f8f.22.1754040490843; Fri, 01 Aug 2025 02:28:10 -0700 (PDT) Date: Fri, 1 Aug 2025 10:27:15 +0100 In-Reply-To: <20250801092720.1845282-1-verhaegen@google.com> Mime-Version: 1.0 References: <20250801092720.1845282-1-verhaegen@google.com> X-Mailer: git-send-email 2.50.1.565.gc32cd1483b-goog Message-ID: <20250801092720.1845282-3-verhaegen@google.com> Subject: [PATCH v4 2/3] ALSA: compress_offload: Add SNDRV_COMPRESS_TSTAMP64 ioctl From: Joris Verhaegen To: Vinod Koul , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Cezary Rojewski , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Kai Vehmanen , Pierre-Louis Bossart , Srinivas Kandagatla , Daniel Baluta , Orson Zhai , Baolin Wang , Chunyan Zhang , Kunihiko Hayashi , Masami Hiramatsu Cc: Joris Verhaegen , kernel-team@android.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com, linux-arm-msm@vger.kernel.org, sound-open-firmware@alsa-project.org, linux-arm-kernel@lists.infradead.org, Miller Liang Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250801_022813_476324_812DD0C2 X-CRM114-Status: GOOD ( 17.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The previous patch introduced the internal infrastructure for handling 64-bit timestamps. This patch exposes this capability to user-space. Define the new ioctl command SNDRV_COMPRESS_TSTAMP64, which allows applications to fetch the overflow-safe struct snd_compr_tstamp64. The ioctl dispatch table is updated to handle the new command by calling a new snd_compr_tstamp64 handler, while the legacy path is renamed to snd_compr_tstamp32 for clarity. This patch bumps the SNDRV_COMPRESS_VERSION to 0.4.0. Reviewed-by: Miller Liang Tested-by: Joris Verhaegen Signed-off-by: Joris Verhaegen --- include/uapi/sound/compress_offload.h | 5 +++-- sound/core/compress_offload.c | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h index abd0ea3f86ee..70b8921601f9 100644 --- a/include/uapi/sound/compress_offload.h +++ b/include/uapi/sound/compress_offload.h @@ -13,8 +13,7 @@ #include #include - -#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 3, 0) +#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 4, 0) /** * struct snd_compressed_buffer - compressed buffer * @fragment_size: size of buffer fragment in bytes @@ -208,6 +207,7 @@ struct snd_compr_task_status { * Note: only codec params can be changed runtime and stream params cant be * SNDRV_COMPRESS_GET_PARAMS: Query codec params * SNDRV_COMPRESS_TSTAMP: get the current timestamp value + * SNDRV_COMPRESS_TSTAMP64: get the current timestamp value in 64 bit format * SNDRV_COMPRESS_AVAIL: get the current buffer avail value. * This also queries the tstamp properties * SNDRV_COMPRESS_PAUSE: Pause the running stream @@ -230,6 +230,7 @@ struct snd_compr_task_status { struct snd_compr_metadata) #define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x20, struct snd_compr_tstamp) #define SNDRV_COMPRESS_AVAIL _IOR('C', 0x21, struct snd_compr_avail) +#define SNDRV_COMPRESS_TSTAMP64 _IOR('C', 0x22, struct snd_compr_tstamp64) #define SNDRV_COMPRESS_PAUSE _IO('C', 0x30) #define SNDRV_COMPRESS_RESUME _IO('C', 0x31) #define SNDRV_COMPRESS_START _IO('C', 0x32) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index d3164aa07158..445220fdb6a0 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -736,18 +736,23 @@ snd_compr_set_metadata(struct snd_compr_stream *stream, unsigned long arg) return retval; } -static inline int -snd_compr_tstamp(struct snd_compr_stream *stream, unsigned long arg) +static inline int snd_compr_tstamp(struct snd_compr_stream *stream, + unsigned long arg, bool is_32bit) { struct snd_compr_tstamp64 tstamp64 = { 0 }; struct snd_compr_tstamp tstamp32 = { 0 }; + const void *copy_from = &tstamp64; + size_t copy_size = sizeof(tstamp64); int ret; ret = snd_compr_update_tstamp(stream, &tstamp64); if (ret == 0) { - snd_compr_tstamp32_from_64(&tstamp32, &tstamp64); - ret = copy_to_user((struct snd_compr_tstamp __user *)arg, - &tstamp32, sizeof(tstamp32)) ? + if (is_32bit) { + snd_compr_tstamp32_from_64(&tstamp32, &tstamp64); + copy_from = &tstamp32; + copy_size = sizeof(tstamp32); + } + ret = copy_to_user((void __user *)arg, copy_from, copy_size) ? -EFAULT : 0; } @@ -1327,7 +1332,9 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) switch (cmd) { case SNDRV_COMPRESS_TSTAMP: - return snd_compr_tstamp(stream, arg); + return snd_compr_tstamp(stream, arg, true); + case SNDRV_COMPRESS_TSTAMP64: + return snd_compr_tstamp(stream, arg, false); case SNDRV_COMPRESS_AVAIL: return snd_compr_ioctl_avail(stream, arg); case SNDRV_COMPRESS_PAUSE: -- 2.50.1.565.gc32cd1483b-goog