From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 0F8DA3BBA04 for ; Mon, 11 May 2026 09:20:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778491236; cv=none; b=PFsoWiJs/4hIrx0e/G6SqYlCLy/PhDmNKX9+OLC1+juqTslpR89gs4ss7+kYscsNs7dZyayBUHkDrXu7pI4RjDDZJ26wIN3iQw3jh3eNeq5VWALKBDp+UuU71hwuV4BqJCiY4T54mK2YUfZ5rHuJK5pR5yoxyqLyD5/7W3nKabE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778491236; c=relaxed/simple; bh=TAhQZw0wpyy7M1R35sWEGKNJTx38Wi1ZyfZZ3XckPRY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X1WStZlA3nkn198XObcMSmrM9Zz7aTZjCUzccCnA3vuP9zg3shf4Sav4mpgxxS3Z76ZMguvMCWf+t4w7QTSHV0OrT0GL0MPR8dAGwh9BIr1wscXGobG/z61Q0bKdZTQJk7XJSoHPq0geZ8OmIcakFFGW/knIUJdREQuTRkdXt3g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=dXdRx0dU; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="dXdRx0dU" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-43fe62837baso2035836f8f.3 for ; Mon, 11 May 2026 02:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778491232; x=1779096032; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=70RRHIcPtjWb3dpDxzH5BIzTRCGXwzXLne5sT6oMZeE=; b=dXdRx0dU0YOGYHlT58R04EqpXKbAjtWGQPfet0IzMExksAs3aruJkMgs36m5kWYSn5 ekFV3Eh4ryK3iF8vwFszlq5CrYfbk7dSDLKehs9TE5k8JVeshiRVqnxJegNP5jsyL/jr bwO1ECz2iMHCkeehnTfOs4FJZNVPE88tcuJ3XxQKjeCw4Kj/kaDH+QHXi4bt/bg6Usq6 01uBYB7QiX4hJQOJijLqdqOBieLPRiSM5Ircl0e1pMSqB8qy/AKUHYL/Uq7NQMlcG9nt 9CaK8m68l2fGkTKY/83OCxJsL1W0isR1WIso5pXs2jCaG8w5GtFe1UuVhEOGux3BYO4W n9HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778491232; x=1779096032; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=70RRHIcPtjWb3dpDxzH5BIzTRCGXwzXLne5sT6oMZeE=; b=JRLrocof01AcLikgNffI+v4QK6Rzoj8ohhBW5elpv4J9+ew8DBm+NNijztVs8t57Qs D9F0eiiHmHrmnf6mLZq50wbsuHe9XpaEns6q8Rdvgql0vFOTZAZ1Ma9U/RLJVawgtbbI p5UuzjZmN3KfytjYcihauII1gldFqmeOobizUqVIMreRmny+BwQL82MuPZ4yzUrUW2hf tbJN6sUNOJMvLdADRh5QZvsqUFn3zkknkKzZGY7GQx+4lDRisqTdhiADC0rSgQmL0OuH iyKHk6hmQaauYyfjyvbdZWDH8LYCafg2WcL/G2VIBhSikHHSmALws6i3kXI27htEVjNo X0+A== X-Forwarded-Encrypted: i=1; AFNElJ/1KYQdQx1ifdZqaahrXsBHxTxcJf5rdJoreZBivPOIccPpEc0E57cLvdE6/laV2RqUxj0RKqwBAf0A8eI=@vger.kernel.org X-Gm-Message-State: AOJu0Yxg2DkXmx8cYOlqYwUbMBRLub25IIayABnclJj3TeBwBmq2HcUs HkEmQllj6mLtkLtnEAxlwCImCuKVMLs+D0L9m0hrVWQNBBSZQv5SDVeOotg736xZe58= X-Gm-Gg: Acq92OHo+XqW3ZtBbXZpcMOupWl2NelsPjueJUGlv+fsSLBFPGfmsAXiigzF2lOLVqU y5kLlerqVYgt9kQeB/Qzt9ZjzVFcV7XtZuajEIQtHIFzNyT5fp3Ep5fQNm1xPcIBc6krYDwAGnL jrDdyimEzDM6bQKPBMHcphlhPGnLvrSDCUlTzpmWjlkdbobf3tuj0fz3uEHwzV0Jq8XRt1N39o4 IRzzO/2wWQa/Aa2w+gQEmZtNzlDBbnTEyDzfaZPRVl9aJgtX+XaY9MeLw8Y3szMV4ajDY3n8sgi ZilG5OqrIHUBQfBdEkeg8+38oNi5rzQqmixBQPchudb5Ha/uTtJCpf0T14zSqzpGZ4dX/OuguRE 1ZmNvXm54ztwySSzM+TgI0/5G5wvlmc4kz4yNaIG41XZE/z7kH0mIp8ZWlq0oc3gtuGQTW2gLeI a0HNFPoSHJPOap/4LkiijUrzycZ9ur0MqVsJDqDoOofwGL X-Received: by 2002:a05:6000:3107:b0:43d:2be:e54 with SMTP id ffacd0b85a97d-4515dc8095fmr32953188f8f.39.1778491232261; Mon, 11 May 2026 02:20:32 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:106d:1080:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4549120ec0asm23743240f8f.17.2026.05.11.02.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 02:20:31 -0700 (PDT) From: Neil Armstrong Date: Mon, 11 May 2026 11:20:27 +0200 Subject: [PATCH v3 2/6] media: qcom: iris: add QC10C & P010 buffer size calculations Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260511-topic-sm8x50-iris-10bit-decoding-v3-2-7fc049b93042@linaro.org> References: <20260511-topic-sm8x50-iris-10bit-decoding-v3-0-7fc049b93042@linaro.org> In-Reply-To: <20260511-topic-sm8x50-iris-10bit-decoding-v3-0-7fc049b93042@linaro.org> To: Vikash Garodia , Dikshita Agarwal , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Armstrong X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=10187; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=TAhQZw0wpyy7M1R35sWEGKNJTx38Wi1ZyfZZ3XckPRY=; b=owEBbAKT/ZANAwAKAXfc29rIyEnRAcsmYgBqAZ9bhS22tB5+HUPMYAcJ2SC4HNr9lw2nFUcUgYKe YqtTvFuJAjIEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCagGfWwAKCRB33NvayMhJ0SDzD/ iQPV5TBPeDhherAbdia567cDu91JKP8PKtYAHmXDEd/XqCRELlvEEJ/NnWPwlgau6K+fBlthiY9p9w 94FD0S+CZvAT/S+Iq8MLBD6XV1tBOL5r7vw/lC2lfVtVAZbe6YYddQ+B+w3ljnOXamYEPhWE4SIhm1 +dBNBE82W5GrtiDewtwIX3/IGnrm/G3/tL/YvTEgJlJCVyNq4m3y3TSLJ3A0FMqG+6cPJvb4T1oq3s LzV6JmodLIW9PQI3slilO1eLRb7CviKxXXc5R5PptcCLyJ1k2MV4l2sJf2Fu65FBOJXennC0/P0wYX C2GbzpQKTBjuqQHBbQLY5khA5FtHOGblSMgaxJJxTeqIWyeVO7xkgjmu2zwxg2nj2D5kCaCfjRPOgC prYxKgNfGpdAur/iTHZsXWPIbgEsqmTkj1TViSpmdiAJlNb+ri1WnSLrAjXaqi1aXxJSVPVx2sEG3d 8A0cQaAU79PSHU4Oj3osWECtVoHcKb7NHLGy8n59XE9P8ewSeofsiaG4j9ACr1/KKAVoSowIb5rHw9 0p7zvgiDse3ffqgeWUFmF3qf5IVykdPos/ZcYunEOTCY62O8TbdcDI9z/ddQkZIK734kO8mjwIxiRH lw5teMsKGhWV/b7kS3wCWpXvZa+GQwC3wuz5N96LV+bW5In59xhAPUuzUY X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE The P010 (YUV format with 16-bits per pixel with interleaved UV) and QC10C (P010 compressed mode similar to QC08C) requires specific buffer calculations to allocate the right buffer size for DPB frames and frames consumed by userspace. Similar to 8bit, the 10bit DPB frames uses QC10C format. Signed-off-by: Neil Armstrong --- drivers/media/platform/qcom/iris/iris_buffer.c | 195 ++++++++++++++++++++++++- 1 file changed, 194 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media/platform/qcom/iris/iris_buffer.c index 1d53c7414b75..713a63d0ca0c 100644 --- a/drivers/media/platform/qcom/iris/iris_buffer.c +++ b/drivers/media/platform/qcom/iris/iris_buffer.c @@ -15,8 +15,11 @@ #define MAX_WIDTH 4096 #define MAX_HEIGHT 2304 #define Y_STRIDE_ALIGN 128 +#define Y_STRIDE_ALIGN_P010 256 #define UV_STRIDE_ALIGN 128 +#define UV_STRIDE_ALIGN_P010 256 #define Y_SCANLINE_ALIGN 32 +#define Y_SCANLINE_ALIGN_QC10C 16 #define UV_SCANLINE_ALIGN 16 #define UV_SCANLINE_ALIGN_QC08C 32 #define META_STRIDE_ALIGNED 64 @@ -80,6 +83,63 @@ static u32 iris_yuv_buffer_size_nv12(struct iris_inst *inst) return ALIGN(y_plane + uv_plane, PIXELS_4K); } +/* + * P010: + * YUV 4:2:0 image with a plane of 10 bit Y samples followed + * by an interleaved U/V plane containing 10 bit 2x2 subsampled + * colour difference samples. + * + * <-Y/UV_Stride (aligned to 256)-> + * <----- Width*2 -------> + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . ^ ^ + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . Height | + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | y_scanlines (aligned to 32) + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . V | + * . . . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . . . V + * U V U V U V U V U V U V . . . . ^ + * U V U V U V U V U V U V . . . . | + * U V U V U V U V U V U V . . . . | + * U V U V U V U V U V U V . . . . uv_scanlines (aligned to 16) + * . . . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . . . V + * . . . . . . . . . . . . . . . . --> Buffer size aligned to 4K + * + * y_stride : Width*2 aligned to 256 + * uv_stride : Width*2 aligned to 256 + * y_scanlines: Height aligned to 32 + * uv_scanlines: Height/2 aligned to 16 + * Total size = align((y_stride * y_scanlines + * + uv_stride * uv_scanlines , 4096) + * + * Note: All the alignments are hardware requirements. + */ +static u32 iris_yuv_buffer_size_p010(struct iris_inst *inst) +{ + u32 y_plane, uv_plane, y_stride, uv_stride, y_scanlines, uv_scanlines; + struct v4l2_format *f; + + if (inst->domain == DECODER) + f = inst->fmt_dst; + else + f = inst->fmt_src; + + y_stride = ALIGN(f->fmt.pix_mp.width * 2, Y_STRIDE_ALIGN_P010); + uv_stride = ALIGN(f->fmt.pix_mp.width * 2, UV_STRIDE_ALIGN_P010); + y_scanlines = ALIGN(f->fmt.pix_mp.height, Y_SCANLINE_ALIGN); + uv_scanlines = ALIGN((f->fmt.pix_mp.height + 1) >> 1, UV_SCANLINE_ALIGN); + y_plane = y_stride * y_scanlines; + uv_plane = uv_stride * uv_scanlines; + + return ALIGN(y_plane + uv_plane, PIXELS_4K); +} + /* * QC08C: * Compressed Macro-tile format for NV12. @@ -204,6 +264,132 @@ static u32 iris_yuv_buffer_size_qc08c(struct iris_inst *inst) return ALIGN(y_meta_plane + y_plane + uv_meta_plane + uv_plane, PIXELS_4K); } +/* + * QC10C: + * UBWC-compressed format for P010. + * Contains 4 planes in the following order - + * (A) Y_Meta_Plane + * (B) Y_UBWC_Plane + * (C) UV_Meta_Plane + * (D) UV_UBWC_Plane + * + * Y_Meta_Plane consists of meta information to decode compressed + * tile data in Y_UBWC_Plane. + * Y_UBWC_Plane consists of Y data in compressed macro-tile format. + * UBWC decoder block will use the Y_Meta_Plane data together with + * Y_UBWC_Plane data to produce loss-less uncompressed 10 bit Y samples. + * + * UV_Meta_Plane consists of meta information to decode compressed + * tile data in UV_UBWC_Plane. + * UV_UBWC_Plane consists of UV data in compressed macro-tile format. + * UBWC decoder block will use UV_Meta_Plane data together with + * UV_UBWC_Plane data to produce loss-less uncompressed 10 bit 2x2 + * subsampled color difference samples. + * + * Each tile in Y_UBWC_Plane/UV_UBWC_Plane is independently decodable + * and randomly accessible. There is no dependency between tiles. + * + * <----- Y Meta stride -----> (aligned to 64) + * <-------- Width ----------> (aligned to 48) + * M M M M M M M M M M M M . . ^ ^ + * M M M M M M M M M M M M . . | | + * M M M M M M M M M M M M . . Height | + * M M M M M M M M M M M M . . | Meta_Y_Scanlines (aligned to 16) + * M M M M M M M M M M M M . . | | + * M M M M M M M M M M M M . . | | + * M M M M M M M M M M M M . . | | + * M M M M M M M M M M M M . . V | + * . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k + * . . . . . . . . . . . . . . V + * <--Compressed tile Y stride --> (aligned to 256) + * <------- Width * 4/3 ---------> (aligned to 48) + * Y* Y* Y* Y* Y* Y* Y* Y* . . . . ^ ^ + * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | | + * Y* Y* Y* Y* Y* Y* Y* Y* . . . . Height | + * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | Macro_tile_Y_Scanlines (aligned to 16) + * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | | + * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | | + * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | | + * Y* Y* Y* Y* Y* Y* Y* Y* . . . . V | + * . . . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k + * . . . . . . . . . . . . . . . . V + * <---- UV Meta stride ----> (aligned to 64) + * <----- Width / 2 --------> (aligned to 24) + * M M M M M M M M M M M M . . ^ ^ + * M M M M M M M M M M M M . . | | + * M M M M M M M M M M M M . . Height/2 | + * M M M M M M M M M M M M . . V M_UV_Scanlines (aligned to 16) + * . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . V + * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k + * <--Compressed tile UV stride--> (aligned to 256) + * <------- Width * 4/3 ---------> (aligned to 48) + * U* V* U* V* U* V* U* V* . . . . ^ + * U* V* U* V* U* V* U* V* . . . . | + * U* V* U* V* U* V* U* V* . . . . | + * U* V* U* V* U* V* U* V* . . . . UV_Scanlines (aligned to 16) + * . . . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . . . V + * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k + * + * y_stride: width aligned to 256 + * uv_stride: width aligned to 256 + * y_scanlines: height aligned to 16 + * uv_scanlines: height aligned to 16 + * y_plane: buffer size aligned to 4096 + * uv_plane: buffer size aligned to 4096 + * y_meta_stride: width aligned to 64 + * y_meta_scanlines: height aligned to 16 + * y_meta_plane: buffer size aligned to 4096 + * uv_meta_stride: width aligned to 64 + * uv_meta_scanlines: height aligned to 16 + * uv_meta_plane: buffer size aligned to 4096 + * + * Total size = align( y_plane + uv_plane + + * y_meta_plane + uv_meta_plane, 4096) + * + * Note: All the alignments are hardware requirements. + */ +static u32 iris_yuv_buffer_size_qc10c(struct iris_inst *inst) +{ + u32 y_plane, uv_plane, y_stride, uv_stride; + u32 uv_meta_stride, uv_meta_plane; + u32 y_meta_stride, y_meta_plane; + struct v4l2_format *f = NULL; + + if (inst->domain == DECODER) + f = inst->fmt_dst; + else + f = inst->fmt_src; + + y_meta_stride = ALIGN(DIV_ROUND_UP(f->fmt.pix_mp.width, 48), + META_STRIDE_ALIGNED); + y_meta_plane = y_meta_stride * ALIGN(DIV_ROUND_UP(f->fmt.pix_mp.height, 4), + META_SCANLINE_ALIGNED); + y_meta_plane = ALIGN(y_meta_plane, PIXELS_4K); + + y_stride = ALIGN(f->fmt.pix_mp.width * 4 / 3, Y_STRIDE_ALIGN_P010); + y_plane = ALIGN(y_stride * ALIGN(f->fmt.pix_mp.height, Y_SCANLINE_ALIGN_QC10C), + PIXELS_4K); + + uv_meta_stride = ALIGN(DIV_ROUND_UP((f->fmt.pix_mp.width + 1) / 2, 24), + META_STRIDE_ALIGNED); + uv_meta_plane = uv_meta_stride * + ALIGN(DIV_ROUND_UP((f->fmt.pix_mp.height + 1) / 2, 4), + META_SCANLINE_ALIGNED); + uv_meta_plane = ALIGN(uv_meta_plane, PIXELS_4K); + + uv_stride = ALIGN(f->fmt.pix_mp.width * 4 / 3, UV_STRIDE_ALIGN_P010); + uv_plane = ALIGN(uv_stride * ALIGN((f->fmt.pix_mp.height + 1) / 2, UV_SCANLINE_ALIGN), + PIXELS_4K); + + return ALIGN(y_meta_plane + y_plane + uv_meta_plane + uv_plane, PIXELS_4K); +} + static u32 iris_dec_bitstream_buffer_size(struct iris_inst *inst) { struct platform_inst_caps *caps = inst->core->iris_platform_data->inst_caps; @@ -268,10 +454,17 @@ int iris_get_buffer_size(struct iris_inst *inst, case BUF_OUTPUT: if (inst->fmt_dst->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_QC08C) return iris_yuv_buffer_size_qc08c(inst); + else if (inst->fmt_dst->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_QC10C) + return iris_yuv_buffer_size_qc10c(inst); + else if (inst->fmt_dst->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_P010) + return iris_yuv_buffer_size_p010(inst); else return iris_yuv_buffer_size_nv12(inst); case BUF_DPB: - return iris_yuv_buffer_size_qc08c(inst); + if (iris_fmt_is_10bit(inst->fmt_dst->fmt.pix_mp.pixelformat)) + return iris_yuv_buffer_size_qc10c(inst); + else + return iris_yuv_buffer_size_qc08c(inst); default: return 0; } -- 2.34.1