From patchwork Fri Nov 6 15:13:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 28795 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1AA78C335E for ; Fri, 6 Nov 2026 15:14:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8B3336A7E9; Fri, 6 Nov 2026 16:14:03 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.b="KPf53pBY"; dkim=pass (2048-bit key; unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="A+KLEp78"; dkim-atps=neutral Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 81CAD6A7D4 for ; Fri, 6 Nov 2026 16:13:58 +0100 (CET) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6A6F03Yn2671664 for ; Fri, 6 Nov 2026 15:13:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= ObPjx0Y03ltx7pI207VTZMS8Hk07tO1wtc5qngRTeF4=; b=KPf53pBYRDMMlkSi VK1welMOzYgbAZ8zyry6AC6tKyO0P+PUD9KmO0k0AWfQufk3t7jmrISBQtAG6eYV wIJWQOopxsy6HKWPqKKkJheUrxmD7AM1wV0MuXdT2OGDKkZd1rwbzFQOn0/GQGh1 zk+pcAC0zO//ICnj2qlcM7073tezOiv+LK04BxZYHuKjLZxUfkmPS85+HNCDoz7N 9vCueYFqNbYZXbfV3jGxy1AhBxrvtYsR5IC6quKWtNLkKAiMpgQD1eIA2fYjptBl g/vTCh/OVAC/1ETE9XnkllfrOztudrx4wmldTxyAPmftAah7KGi0QxrNGrn7UogJ chAOOg== Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4hs3pcbadn-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 06 Nov 2026 15:13:56 +0000 (GMT) Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-93f6f4fe531so138857685a.0 for ; Fri, 06 Nov 2026 07:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1793978036; x=1794582836; darn=lists.libcamera.org; 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=ObPjx0Y03ltx7pI207VTZMS8Hk07tO1wtc5qngRTeF4=; b=A+KLEp78Ea6O1QJs++qGroHnMjPCXsiaOLK64bV2G9+t2QilKC5FpJGSglxeDxd+d2 1cRhXirb8ak7XAKbmwEY9UHL3FL8xTSJOnVWn1a3btqTNNbpldT0TygmdUleCVTY9q+v tUAl6mh7+QRyKkkdAKGQUcLVSXXtuBf+mco5jqpDlsa4bfsZ+t84SlCyfamMLRCS3jg7 6594R0ECrbQdMzoQg90blJKy8L/FiWJVZSDG/rJpiax2J6OFB0WJ0h6ooZS3ikYIrgML dFNfjXOPxgSAHaQs172+gxf8cjhwNEHWhyLD4hgPE2tf9DtzgC8JVfPGyR8O6vFn1xo+ ywPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793978036; x=1794582836; 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=ObPjx0Y03ltx7pI207VTZMS8Hk07tO1wtc5qngRTeF4=; b=O/ertO8a3UGjXKz8c5YufLYLu7hXL6aNJx9aYr+OOTc2GMHveGnMPMWqYNbfU8oyih fWaVQr5+2PkW9HqyE3rnqwx29lZqSienpnr5aO4z5RVEK4eG5YgAmgLzCNpBEcFmhxAf UWq5ha9ojNIkMGlEFwB0KQhJOq8tgS/zTjTcBr9XoBQq4WfqFJqJjaoXxBOK3ydpdtA9 u9YeGw0ZytrAfTowAN8iG+2qzPSgGsR2kBRBk65V5CKbG/HupN55+rSc9FAUSuVX7laN TdfyiK+zhH/HDbzWksDT4ddgKGdkKXlAk8/r45G4kaESJXkWLYswwY4rED3i/9CJlEDI GN8A== X-Gm-Message-State: APuU4Z/Di36f1DfR5lOieQX1E6UAwk/5Iq1XWuiwE08dgi0WINloh2lE p3t697z31cez68hEQXCfx3aZmVw35YgeBXldNmnsZ1q2/HlDWtCAlRYxVV4I1HZopl/kfi/ThXx bJGZ3UKYjsJyHKtpbaFsKeJ3ZBS5e9wZraeqPVrbnrxwrawVMpAoGOmMXjEQjhlyTHWNZtlqCYu WW6uA6vqXj X-Gm-Gg: AYBFou0kIAcXfbPJOmTAJRnMVp/RQKy0aHkmLWTuKE1WYgi+DDI7puyxe7Zh6Ecn6M/ oO2aR2cE7VUY2yZw+h2oNDWe0w7XYSPX5faCFiWZJ9GWm+Be18593NFQKykmy8Xp+S92An3kXgx JccXUn9v6c9wHamrjSqXpH5gmvw9a6ZtJE3Gs4dYxY2lzrzfgnp600cdfY7sHqyT4boqzC3k08L RGeO2XON1i7Q+gLHAFNT7/0/KZosdhcH23lGauxFvWHBJfdg0NG0+Mvy9uodN2WnkD53FhxuxSR bjBekzrnikw4pTYtseyeHzQ6WCcEQYlXb8wpDUU/8yAPG7NY4INElPFn2yLNBGxOV4R8gQ0xbkd arZN+/49McjCc1dnfErpDO4YJ1JSMUgmKfMyQisw0dUfJ6eIvF5YJhOEoTGj/BGhdGi/wRjqjh4 iYMymTfaxGFs8w0He0FJzz9eRP3m5dVSMjU5kgeE0zS0KZKAO9OyKpe1ni8+mbwYYN X-Received: by 2002:a05:620a:1a29:b0:943:f31a:c0a7 with SMTP id af79cd13be357-945f34c9990mr456779985a.31.1793978035399; Fri, 06 Nov 2026 07:13:55 -0800 (PST) X-Received: by 2002:a05:620a:1a29:b0:943:f31a:c0a7 with SMTP id af79cd13be357-945f34c9990mr456772085a.31.1793978034699; Fri, 06 Nov 2026 07:13:54 -0800 (PST) Received: from shalem (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c4d3569b856sm86042466b.46.2026.11.06.07.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2026 07:13:53 -0800 (PST) From: Hans de Goede To: libcamera-devel@lists.libcamera.org Cc: Gjorgji Rosikopulos , Loic Poulain , Hans de Goede Subject: [PATCH v3 5/7] camss: Add include/linux/qcom-camss-config.h Date: Fri, 6 Nov 2026 16:13:39 +0100 Message-ID: <20261106151345.32491-6-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261106151345.32491-1-johannes.goede@oss.qualcomm.com> References: <20261106151345.32491-1-johannes.goede@oss.qualcomm.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: KeUN610vB4fco_MH_L8qB_rsNnymCWFU X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA2MDA1OSBTYWx0ZWRfX2cNq5Zdjy14p wq0fsz7d8QyJrumD+JJarlZqrgZqSl7Rhhf9pLfY+pZZtMMwjl7kKcUitjT6dmhFGeqOQdO1LI+ seGxneG+9o9FT0w2P+mMYonCjLSbtxWESEM5b/A3yvAVm7ANYwQNaLBtJrhNlqT+C7Ee+6+cyuD bJbQ13G8bQHXH81Ng/oafbMBXLkwHS4LUl3zd4Wy7w2YFnjMwwRlUbK9OKrQX/HYlQTBv2azzQA 0MGQsMbnCyqH9zBRpGAIual5dPCh+hFiA8EjCMD602J4pLHKFKkgt08y4hdlotPCHvGFEKOJTWU WdGkmI3nUjbplIz0UKzTDPjglUWVnVCdCHBxlpgsvwUVjh/OtEZxCjMAzCP6F5lrRI+KPmVOKzh eTxqFi4U62tufx76DuHrOAgr9HZ/YJYJm02YZR0FSJFhP9iIix54fAEapRPah7L0hu5xPyZ3oSj LrV+XtpckGMxgk88O/Q== X-Proofpoint-GUID: KeUN610vB4fco_MH_L8qB_rsNnymCWFU X-Authority-Analysis: v=2.4 cv=TI3Q2Fla c=1 sm=1 tr=0 ts=6aedeeb4 cx=c_pps a=HLyN3IcIa5EE8TELMZ618Q==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=cBt3T3tByBXynNCq78MA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=bTQJ7kPSJx9SKPbeHEYW:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTA2MDA1OSBTYWx0ZWRfXx2/8N55Gt56Y A7ZSUahCqBaCRr9/f+u19eCs+JMfNRBWFqXtC4YWo/47vhwpY/e33d0bj/X7d0YNhTqp7mYSU3C WeYk7lCCumYsLYEGnpRbfVA0pVfkyJA= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293, Aquarius:18.0.1176, Hydra:6.1.138, FMLib:17.12.100.49 definitions=2026-11-06_05,2026-11-06_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 phishscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611060059 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add include/linux/qcom-camss-config.h for OPE ISP parameter definitions. Link: https://lore.kernel.org/linux-media/20261103-camss-isp-ope-v13-4-c2cbf15a39b1@oss.qualcomm.com/ Signed-off-by: Hans de Goede --- include/linux/qcom-camss-config.h | 217 ++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 include/linux/qcom-camss-config.h diff --git a/include/linux/qcom-camss-config.h b/include/linux/qcom-camss-config.h new file mode 100644 index 000000000..543c1682f --- /dev/null +++ b/include/linux/qcom-camss-config.h @@ -0,0 +1,217 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* + * Qualcomm CAMSS ISP Driver - Userspace API + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + */ + +#ifndef _UAPI_LINUX_QCOM_CAMSS_CONFIG_H +#define _UAPI_LINUX_QCOM_CAMSS_CONFIG_H + +#include +#include + +/** + * enum camss_params_block_type - CAMSS ISP parameter block identifiers + * + * Each value identifies one ISP processing block. The value is placed in + * the @type field of &struct v4l2_isp_block_header. + * + * @CAMSS_PARAMS_WB_GAIN: white balance gains and offsets (CLC_WB), + * &struct camss_params_wb_gain + * @CAMSS_PARAMS_CHROMA_ENHAN: RGB to YUV colour transfer matrix + * (CLC_CHROMA_ENHAN), &struct camss_params_chroma_enhan + * @CAMSS_PARAMS_COLOR_CORRECT: colour correction matrix (CLC_CC), + * &struct camss_params_color_correct + * @CAMSS_PARAMS_GAMMA: per-channel gamma correction curves (CLC_GLUT), + * &struct camss_params_gamma + */ +enum camss_params_block_type { + CAMSS_PARAMS_WB_GAIN = 1, + CAMSS_PARAMS_CHROMA_ENHAN = 2, + CAMSS_PARAMS_COLOR_CORRECT = 3, + CAMSS_PARAMS_GAMMA = 4, +}; + +/* Number of entries in each gamma channel LUT. */ +#define CAMSS_GAMMA_LUT_SIZE 256 + +/** + * struct camss_params_wb_gain - White Balance gains + * + * Implements the CLC_WB pipeline module. The pipeline applies three + * sequential operations per channel:: + * + * 1. Subtract sub-offset (black-level subtraction) + * 2. Multiply by gain (colour balance) + * 3. Add add-offset (output pedestal) + * + * Gains are 15uQ10 (15-bit unsigned, 10 fractional bits). Offsets + * are 16-bit unsigned, normalised to full input scale (65535 = 1.0) + * + * @header: block header; @header.type = CAMSS_PARAMS_WB_GAIN + * @g_gain: green channel gain (15uQ10, 1024 = 1.0) + * @b_gain: blue channel gain (15uQ10, 1024 = 1.0) + * @r_gain: red channel gain (15uQ10, 1024 = 1.0) + * @g_sub: green sub-offset, subtracted before gain (16u) + * @b_sub: blue sub-offset, subtracted before gain (16u) + * @r_sub: red sub-offset, subtracted before gain (16u) + * @g_add: green add-offset, added after gain (16u) + * @b_add: blue add-offset, added after gain (16u) + * @r_add: red add-offset, added after gain (16u) + * @_pad: padding for 64-bit alignment, must be zero + */ +struct camss_params_wb_gain { + struct v4l2_isp_block_header header; + __u16 g_gain; + __u16 b_gain; + __u16 r_gain; + __u16 g_sub; + __u16 b_sub; + __u16 r_sub; + __u16 g_add; + __u16 b_add; + __u16 r_add; + __u16 _pad[3]; +} __attribute__((aligned(8))); + +/** + * struct camss_params_chroma_enhan - RGB to YUV colour transfer matrix + * + * Implements the CLC_CHROMA_ENHAN pipeline module. All coefficients are + * signed 12-bit fixed-point Q3.8 (range roughly -8.0 to +7.996). + * + * RGB2Y - Luma (Y) coefficients:: + * + * Y = v0 * R + v1 * G + v2 * B + * + * RGB2Cb - Chroma (Cb) coefficients:: + * + * Cb = a x ((B - G) + b(R - G)) + KCb + * with: + * a = ap, when (B-G) + b(R-G) > 0; a = am, when (B-G) + b(R-G) ≤ 0; + * b = bp when (R-G) > 0; b = bm when (R-G) ≤ 0 + * + * RGB2Cr - Chroma (Cr) coefficients:: + * + * Cr = c x ((R - G) + d(B - G)) + KCr + * with: + * c = cp, when (R-G) + d(B-G) > 0; c = cm, when (R-G) + d(B-G) ≤ 0 + * d = dp when (B-G) > 0; d = dm when (B-G) ≤ 0 + * + * @header: generic block header; @header.type = CAMSS_PARAMS_CHROMA_ENHAN + * @luma_v0: R-to-Y coefficient (12sQ8) + * @luma_v1: G-to-Y coefficient (12sQ8) + * @luma_v2: B-to-Y coefficient (12sQ8) + * @luma_k: Y output offset (9s, 0 = no offset) + * @coeff_ap: Cb positive coefficient (12sQ8) + * @coeff_am: Cb negative coefficient (12sQ8) + * @coeff_bp: Cb positive coefficient (12sQ8) + * @coeff_bm: Cb negative coefficient (12sQ8) + * @coeff_cp: Cr positive coefficient (12sQ8) + * @coeff_cm: Cr negative coefficient (12sQ8) + * @coeff_dp: Cr positive coefficient (12sQ8) + * @coeff_dm: Cr negative coefficient (12sQ8) + * @kcb: Cb output offset (11s) + * @kcr: Cr output offset (11s) + * @_pad: padding for 64-bit alignment, must be zero + */ +struct camss_params_chroma_enhan { + struct v4l2_isp_block_header header; + __s16 luma_v0; + __s16 luma_v1; + __s16 luma_v2; + __s16 luma_k; + __s16 coeff_ap; + __s16 coeff_am; + __s16 coeff_bp; + __s16 coeff_bm; + __s16 coeff_cp; + __s16 coeff_cm; + __s16 coeff_dp; + __s16 coeff_dm; + __s16 kcb; + __s16 kcr; + __u16 _pad[2]; +} __attribute__((aligned(8))); + +/** + * struct camss_params_color_correct - colour correction matrix + * + * Implements the CLC_CC pipeline module. The matrix computes:: + * + * Out_ch0 (G) = a0*G + b0*B + c0*R + k0 + * Out_ch1 (B) = a1*G + b1*B + c1*R + k1 + * Out_ch2 (R) = a2*G + b2*B + c2*R + k2 + * + * The @qfactor member selects the fixed-point format of all coefficients:: + * + * 0 = 12sQ7 (range ~-16.0 .. +15.992) + * 1 = 12sQ8 (range ~-8.0 .. +7.996) + * 2 = 12sQ9 (range ~-4.0 .. +3.998) + * 3 = 12sQ10 (range ~-2.0 .. +1.999) + * + * @header: block header; @header.type = CAMSS_PARAMS_COLOR_CORRECT + * @a: G-input coefficients per output channel (12s; + * a[0]=Out_G, a[1]=Out_B, a[2]=Out_R) + * @b: B-input coefficients (12s) + * @c: R-input coefficients (12s) + * @k: per-output-channel offsets (typically 9s effective) + * @qfactor: Q-format selector (2u), see above + * @_pad: padding for 64-bit alignment, must be zero + */ +struct camss_params_color_correct { + struct v4l2_isp_block_header header; + __s16 a[3]; + __s16 b[3]; + __s16 c[3]; + __s16 k[3]; + __u16 qfactor; + __u16 _pad[3]; +} __attribute__((aligned(8))); + +/** + * struct camss_params_gamma - per-channel gamma correction curves + * + * Implements the CLC_GLUT pipeline module, applied in the RGB domain. It + * holds one independent lookup table per colour channel. Each table is a + * direct (not segmented) map of input level to output level. + * + * Each table has @CAMSS_GAMMA_LUT_SIZE (256) entries of 16-bit unsigned + * output. The number of significant output bits follows the width of the + * engine's internal bus; the upper bits are ignored by the hardware. + * + * The module maps a 12-bit input to an 8-bit output: the top 8 input bits + * index the table and the low 4 bits are used to linearly interpolate + * between adjacent entries. Entry i therefore represents the output for + * input level i/255 of full scale. + * Output range: 0x00 = black, 0xFF = white. + * + * How to fill a curve (same on all three channels for pure luminance + * gamma; different curves per channel additionally shift colour balance):: + * + * Identity (pass-through, gamma 1.0): + * lut[i] = i; // i = 0..255 + * + * Encode with gamma g (e.g. sRGB-like, g = 2.2): + * lut[i] = round(pow(i / 255.0, 1.0 / g) * 255.0); + * + * @header: block header; @header.type = CAMSS_PARAMS_GAMMA + * @glut: green channel gamma curve + * @blut: blue channel gamma curve + * @rlut: red channel gamma curve + */ +struct camss_params_gamma { + struct v4l2_isp_block_header header; + __u16 glut[CAMSS_GAMMA_LUT_SIZE]; + __u16 blut[CAMSS_GAMMA_LUT_SIZE]; + __u16 rlut[CAMSS_GAMMA_LUT_SIZE]; +} __attribute__((aligned(8))); + +#define CAMSS_PARAMS_OPE_MAX_PAYLOAD \ + (sizeof(struct camss_params_wb_gain) +\ + sizeof(struct camss_params_chroma_enhan) +\ + sizeof(struct camss_params_color_correct) +\ + sizeof(struct camss_params_gamma)) + +#endif /* _UAPI_LINUX_QCOM_CAMSS_CONFIG_H */