From patchwork Tue Jul 9 08:38:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727522 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2119.outbound.protection.partner.outlook.cn [139.219.146.119]) (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 ADB2D153820; Tue, 9 Jul 2024 09:12:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.119 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720516351; cv=fail; b=f82a8e0dZ5nZRnkVtIwp9NH2BhSqibk0KtAZ9Qr6bOItCPjuDJTkEcAtmsIaSM6vOwiWOFWrjAdZRCbBPxZ6EDX9R7XIy6I7VnhC5nqqg1zse15H6Swkz/HyjxsWk4tpujqdBvTEKh8UOQpOqYowaaW/AksxbitW+7iX9BwkfIU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720516351; c=relaxed/simple; bh=vuW0MghvQk8lyOzG380nCj7MP1pcGYfW4BjZqCcwbn4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pkD9oIho5QCmk1Lx3i12bazoLKNh17mikbfaHyp9XlLdsajJEoer79A3JDSG6rvRsr+ub13LrFzfrhILfcgPfW8F5MTqKoHSg91EdVCT6cYLGtIlKDgG+rX7fC45g5FIYv7EmFB4DgpLJWAC/F2oEzF9+9dK1P1YY+IANcSBxrA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gpwoQdwA6+RxoFb4TgOPQK2Su0Jz+aT1QlWXcuYh3xnmPQRWeYY2gSq3x7bqUTKOBfhE3yX3y8reUkQdgY5uqtm+FBAJChh0ZSlQ63otFHbzbsKhhcYfOR9NGpJ6AydQxkElOYh7k54nzg+nL41cIW+TC+XKMDN2XPMyGmgBH9XzA6pIcKW52+Ipl/lrNTHLSUiXiL4qzGNqZ3OtyA3ai07RF/2za3mb2GoEyhURK5fqU2gKCXyvUOTUK0vAv58+tDtn0V1zqAPsSizC8bMp84I4pU9Xa3eguhZQhUD0/8NH70NYRYfsFxLksVOaIIWhVMcehcUyOMzqohko47WDtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZmntXUNq1t/9ERF2Yi3c7CL3wjvxFpC22TLPemHaeqE=; b=PhSY8QIkUlCsXOtLS4Esx4IXpnergObxvL6QcOGJWcEeorR7zPS+lnEW7zQ4SA75a/ie8XyCjGKDl+/tDQaIjwBjCaLW5nzOaIuefn89RCRnju9bZ5yXkz0clLVq/jOVeAtr2yVq3zc/1gr9NmyN7c48ell4xOL2gNocVKl9U/FlHeKujjqmf6JkeVfQNAAOZMxuOAgtj5oSb4f4pNHPWbpnop3+ejX0Kaf+1uwG8ydT7IPbeuLyWr/4bpNVp/HVh9iXWuN/AWScGGVjvCCPMzVu50l+Cw3CcHIHKMvnrtRDd3FKpNbWGhnmP2eY5jns5PUprUcgKJsnPyZTK7hvTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:33 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:33 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 01/14] media: starfive: Add JH7110 ISP module definitions Date: Tue, 9 Jul 2024 01:38:11 -0700 Message-Id: <20240709083824.430473-2-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: 87ae9ad8-c412-4a25-7b77-08dc9ff2845e X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: nt5A2ptF5d6HFp3NlkDJJyw27LI+8TtRlrjNCIGxCj50cewCSuVBselpyI58Ceut+8oCBuFJvHuC1cDTypV3CYN7iooAueD6bVpxSDgrnKqfnKhPWIQCinWb5snSk/6kB4MHEkjt+JGMPLw1nGuCYgTB/qRAJGMXqQ8Oi1035L0aVqzI7coroLOkRBJjipkLKsBZBgUXHBxDmAuKH5vnOLSq7va35u66eLNjYCaEWKF1FbQhRRH+nKcrSCYhDILGXROv6eYlgaUxBaQW/W7hCTupSca1CvWgIHUvB+bkitKsNM97qd1CiTXthKauZUatoEVWG4BcUja99oNFq2gW6sY4PlRTFtXkZa7S2eLMd+QQ1ZmsV2VhfdZgO/MUAWz+xlhjo1gAPoJhN1IA816B5yiohp7LXKcFcSMtefmDDMW9IStLTpnJiKvbAiaHjIg/duLBtFJRP6qAhbEXmm2CkPb4frHT+g0gFODIzEM0f1IRdi4V3X2cSow7KkkU1s5pagsrY7D6tVB/xKhs1BT9PyO4M/MphiGaWj558TVzRWaxx9caHLfRz5YIyGCiacJNBxxjiWeBdUC2eoOqz/1YIeVK0tqVwRS0IwEu6oe6Q3zoTWqRzVhSPqjJcotFrhhu X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?HHR48dxjiBRPeuYphNKUX1aTN7eF?= =?utf-8?q?1z1xfRg4qm4hJgrbLh9CbkpPD0Mzk/MgKpn+374EaFI0eHfDmTktss1WM4G7PpGff?= =?utf-8?q?FmqlJkS0XLzZYuqq0UmPvNBO+XGnXmgQHiR2AEule/77O0DZekfrqJvjnnfstByfV?= =?utf-8?q?1aiqBKiJAkxmnf4LyEe3yMV+6/uAOCs7EZSYEQAvPEEpJQp4OIJY/rn3snQIoWCs/?= =?utf-8?q?cO92U7bJw+SGGhCqTku79mJJaAACgKsQApXcDu9gYzEqtf8UmGQO+I5xWNSOejyKK?= =?utf-8?q?+WAag029YkPg9mzJ3aDx4UXs6tGEXwEMlnVrXrXle7VFd/0hUWPgWJ1LEokCbknks?= =?utf-8?q?x7FU4MAj7NHaev2YS39eT1eA3UHOqLtp08Fr+h5nFIWL9JJbj4VAmN4UXL1dmoaid?= =?utf-8?q?nshN3TLMNIS4Py4cBZIYRZp7PfUcLlotBE53CWdCDghLUelmTbdPc0gpYMbMuHJWM?= =?utf-8?q?kqNFjB/WarNu21HxZSl315zS5TM0o1tgJfyh3DaRUzIuWaqTyfW+oSJEH4gWDMTqr?= =?utf-8?q?lCWbFnvbwIJeAndo2PjbB4YOGOePuQzJCdnn5suoSkTRJGdRPdKaGHVExZajFbL8A?= =?utf-8?q?ro1UAMU1jq3AULUitmJNjiGjVd6puJcmQaW7IP+HaGIA75ihzEaspgtPDZI3AigS7?= =?utf-8?q?kEiucX4ZgvgdSbeZV5HBVsVQsig+KvtUI6QFEyLgwvoFoS7ODP0ibD5u7mkdDk1xv?= =?utf-8?q?2Jhb6TBLAclsNgQfTgM/GDfdWQnxWBsY9XIwMCw96tSXVrlvYf4NbBNC421VdNXKY?= =?utf-8?q?5+wh9fUcJ8zbfFgR2JudjW9OXKEHTtQ4Z8qLkFCGLrqL5Y8v+YvJGvVEGDqx/VHVm?= =?utf-8?q?mluA0FccVS9ZmpySYnUqh/j7e7Jf8swUTbFVKnlqSWUaipmykIFK7eiLLwQ5N5Me2?= =?utf-8?q?G/Yyh/ZDROrKrwkiLHbhJ8ZeSchKXfpnShGB2/KCFSwQ8ugIo//xYe5vo5yPM2jhp?= =?utf-8?q?a9p1eq1TVGFG5YuAyes9FyvWJ6a2DoyKzjaTnyElHZIlCh6xHEnpqxJH6dX76BK0t?= =?utf-8?q?fU/6WzhF5xxI5BnivX6KkoXhDMadOoe4M2sOIXbrRwxSHjukMqKhL8QjewFnBsaH6?= =?utf-8?q?pPdpy726ubB7Xp94a7Z9FZ6rhIdDw6eJayTxR9Amlawd8aJl3hq+WR/FhYOClExWU?= =?utf-8?q?KiWREypNYfjNkRk/mQEOYPGOxkk7LmH1pdxgAD5YJS6evosO/zuz3KYfPLeN3WGAn?= =?utf-8?q?fQ3GZe5kqxyYTv1aikPD8PT0AGB2Q+y4B7WPlbZSOvICRGlyhIur3pzKeMXrI+1hR?= =?utf-8?q?i/WaIkwGNuAhUYjfCcV6N9hIcVBDrPUvXcu+JoBW98hSirfYS39D7hpP66rSj2R83?= =?utf-8?q?REQ4/2doFBca9pqwBhpzTT/qmmXJjIks7oOOS3OjoFNE8gJc3SBkptzP9h0nMU8p8?= =?utf-8?q?cwLGVEeuUkMGKrdoPFcw68jIkxkIVAmsB5cwja1WPj+3ywAoHvmMs1orlcT8kvYxC?= =?utf-8?q?G/z0nlHv3pLw7ESIsIpi7KfCVxfALalk1UxJlsj9fNEMCPg8ij/sZbErCMNkscGlu?= =?utf-8?q?MLkRl65IjDraYFX48gJkK2t1F4I70JUue4ZAycsawjhO5Ux5iG26Z/4=3D?= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87ae9ad8-c412-4a25-7b77-08dc9ff2845e X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:33.2787 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: W4wlKUbbHBKtRyD8fFa2MXcjekYr9IAE1i87vmCp1exO+Ln/BYz+leZ7jYBZbnQeGFYmv0C0ZVTrucjWMvpTzfxT2iV+k0J7ZQn/0ecy3NDUU5lbNbo2GfIdNvuTQItR X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 Add JH7110 ISP module definitions for user space. Signed-off-by: Changhuang Liang Signed-off-by: Zejian Su --- MAINTAINERS | 1 + include/uapi/linux/jh7110-isp.h | 739 ++++++++++++++++++++++++++++++++ 2 files changed, 740 insertions(+) create mode 100644 include/uapi/linux/jh7110-isp.h diff --git a/MAINTAINERS b/MAINTAINERS index 507f04a80499..890604eb0d64 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21305,6 +21305,7 @@ S: Maintained F: Documentation/admin-guide/media/starfive_camss.rst F: Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml F: drivers/staging/media/starfive/camss +F: include/uapi/linux/jh7110-isp.h STARFIVE CRYPTO DRIVER M: Jia Jie Ho diff --git a/include/uapi/linux/jh7110-isp.h b/include/uapi/linux/jh7110-isp.h new file mode 100644 index 000000000000..4939cd63e771 --- /dev/null +++ b/include/uapi/linux/jh7110-isp.h @@ -0,0 +1,739 @@ +/* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* + * jh7110-isp.h + * + * JH7110 ISP driver - user space header file. + * + * Copyright © 2023 StarFive Technology Co., Ltd. + * + * Author: Zejian Su + * + */ + +#ifndef __JH7110_ISP_H_ +#define __JH7110_ISP_H_ + +/** + * ISP Module Diagram + * ------------------ + * + * Raw +-----+ +------+ +------+ +----+ + * ---->| OBC |--->| OECF |--->| LCCF |--->| WB |-----+ + * +-----+ +------+ +------+ +----+ | + * | + * +--------------------------------------------------+ + * | + * | +-----+ +-----+ +-----+ +-----+ + * +--->| DBC |--->| CTC |--->| CFA |--->| CAR |------+ + * +-----+ +-----+ +-----+ +-----+ | + * | + * +--------------------------------------------------+ + * | + * | +-----+ +--------+ +-----+ +------+ + * +--->| CCM |--->| GMARGB |--->| R2Y |--->| YCRV |--+ + * +-----+ +--------+ +-----+ +------+ | + * | + * +--------------------------------------------------+ + * | + * | +-------+ +-------+ +-----+ +----+ + * +--->| SHARP |--->| DNYUV |--->| SAT |--->| SC | + * +-------+ +-------+ +-----+ +----+ + * + */ + +/* Auto White Balance */ +#define JH7110_ISP_MODULE_WB_SETTING (1U << 0) +/* Color Artifact Removal */ +#define JH7110_ISP_MODULE_CAR_SETTING (1U << 1) +/* Color Correction Matrix */ +#define JH7110_ISP_MODULE_CCM_SETTING (1U << 2) +/* Color Filter Arrays */ +#define JH7110_ISP_MODULE_CFA_SETTING (1U << 3) +/* Crosstalk Correction */ +#define JH7110_ISP_MODULE_CTC_SETTING (1U << 4) +/* Defect Bad Pixel Correction */ +#define JH7110_ISP_MODULE_DBC_SETTING (1U << 5) +/* Denoise YUV */ +#define JH7110_ISP_MODULE_DNYUV_SETTING (1U << 6) +/* RGB Gamma */ +#define JH7110_ISP_MODULE_GMARGB_SETTING (1U << 7) +/* Lens Correction Cosine Fourth */ +#define JH7110_ISP_MODULE_LCCF_SETTING (1U << 8) +/* Optical Black Correction */ +#define JH7110_ISP_MODULE_OBC_SETTING (1U << 9) +/* Opto-Electric Conversion Function */ +#define JH7110_ISP_MODULE_OECF_SETTING (1U << 10) +/* RGB To YUV */ +#define JH7110_ISP_MODULE_R2Y_SETTING (1U << 11) +/* Saturation */ +#define JH7110_ISP_MODULE_SAT_SETTING (1U << 12) +/* Sharpen */ +#define JH7110_ISP_MODULE_SHARP_SETTING (1U << 13) +/* Y Curve */ +#define JH7110_ISP_MODULE_YCRV_SETTING (1U << 14) +/* Statistics Collection */ +#define JH7110_ISP_MODULE_SC_SETTING (1U << 15) + +/** + * struct jh7110_isp_wb_gain - auto white balance gain + * + * @gain_r: gain value for red component. + * @gain_g: gain value for green component. + * @gain_b: gain value for blue component. + */ +struct jh7110_isp_wb_gain { + __u16 gain_r; + __u16 gain_g; + __u16 gain_b; +}; + +/** + * struct jh7110_isp_wb_setting - Configuration used by auto white balance gain + * + * @enabled: enabled setting flag. + * @gains: auto white balance gain setting. + */ +struct jh7110_isp_wb_setting { + __u32 enabled; + struct jh7110_isp_wb_gain gains; +}; + +/** + * struct jh7110_isp_car_setting - Configuration used by color artifact removal + * + * @enabled: enabled setting flag. + */ +struct jh7110_isp_car_setting { + __u32 enabled; +}; + +/** + * struct jh7110_isp_ccm_smlow - Color correction matrix + * + * @ccm: color transform matrix with size 3 by 3. + * @offsets: the offsets of R, G, B after the transform by the ccm. + */ +struct jh7110_isp_ccm_smlow { + __s32 ccm[3][3]; + __s32 offsets[3]; +}; + +/** + * struct jh7110_isp_ccm_setting - Configuration used by color correction matrix + * + * @enabled: enabled setting flag. + * @ccm_smlow: Color correction matrix. + */ +struct jh7110_isp_ccm_setting { + __u32 enabled; + struct jh7110_isp_ccm_smlow ccm_smlow; +}; + +/** + * struct jh7110_isp_cfa_params - demosaic parameters + * + * @hv_width: detail smooth factor + * @cross_cov: Cross covariance weighting. + */ +struct jh7110_isp_cfa_params { + __s32 hv_width; + __s32 cross_cov; +}; + +/** + * struct jh7110_isp_cfa_params - Configuration used by demosaic module + * + * @enabled: enabled setting flag. + * @settings: demosaic parameters. + */ +struct jh7110_isp_cfa_setting { + __u32 enabled; + struct jh7110_isp_cfa_params settings; +}; + +/** + * struct jh7110_isp_ctc_params - crosstalk remove parameters + * + * @saf_mode: smooth area filter mode. + * @daf_mode: detail area filter mode. + * @max_gt: the threshold for imbalance detection when pixel intensity is close to maximum. + * @min_gt: the threshold for imbalance detection when pixel intensity is close to 0. + */ +struct jh7110_isp_ctc_params { + __u8 saf_mode; + __u8 daf_mode; + __s32 max_gt; + __s32 min_gt; +}; + +/** + * struct jh7110_isp_ctc_params - Configuration used by crosstalk remove + * + * @enabled: enabled setting flag. + * @settings: corsstalk remove parameters. + */ +struct jh7110_isp_ctc_setting { + __u32 enabled; + struct jh7110_isp_ctc_params settings; +}; + +/** + * struct jh7110_isp_dbc_params - defect pixels correction parameters + * + * @bad_gt: bad pixel threshold for the green channel. + * @bad_xt: bad pixel threshold for the red and blue channels. + */ +struct jh7110_isp_dbc_params { + __s32 bad_gt; + __s32 bad_xt; +}; + +/** + * struct jh7110_isp_dbc_params - Configuration used by defect bad pixels correction + * + * @enabled: enabled setting flag. + * @settings: defect pixels correction parameters. + */ +struct jh7110_isp_dbc_setting { + __u32 enabled; + struct jh7110_isp_dbc_params settings; +}; + +/** + * struct jh7110_isp_dnyuv_params - yuv domain denoise parameters + * + * @y_sweight: ten coefficients of 7x7 spatial filter for Y channel. + * @y_curve: intensity difference (similarity) weight lookup table for Y channel. + * @uv_sweight: ten coefficients of 7x7 spatial filter for U and V channel. + * @uv_curve: intensity difference (similarity) weight lookup table for U and V channel. + */ +struct jh7110_isp_dnyuv_params { + __u8 y_sweight[10]; + __u16 y_curve[7]; + __u8 uv_sweight[10]; + __u16 uv_curve[7]; +}; + +/** + * struct jh7110_isp_dnyuv_params - Configuration used by yuv domain denoise + * + * @enabled: enabled setting flag. + * @settings: yuv domain denoise parameters. + */ +struct jh7110_isp_dnyuv_setting { + __u32 enabled; + struct jh7110_isp_dnyuv_params settings; +}; + +/** + * struct jh7110_isp_gmargb_point - RGB Gamma point + * + * @g_val: RGB gamma value. + * @sg_val: RGB gamma slope value. + */ +struct jh7110_isp_gmargb_point { + __u16 g_val; + __u16 sg_val; +}; + +/** + * struct jh7110_isp_gmargb_setting - Configuration used by RGB gamma + * + * @enabled: enabled setting flag. + * @curve: RGB Gamma point table. + */ +struct jh7110_isp_gmargb_setting { + __u32 enabled; + struct jh7110_isp_gmargb_point curve[15]; +}; + +/** + * struct jh7110_isp_lccf_circle - len circle + * + * @center_x: center X distance from capture window. + * @center_y: center Y distance from capture window. + * @radius: len circle radius. + */ +struct jh7110_isp_lccf_circle { + __s16 center_x; + __s16 center_y; + __u8 radius; +}; + +/** + * struct jh7110_isp_lccf_curve_param - lens correction cosine fourth curve param + * + * @f1: F1 parameter. + * @f2: F2 parameter. + */ +struct jh7110_isp_lccf_curve_param { + __s16 f1; + __s16 f2; +}; + +/** + * struct jh7110_isp_lccf_setting - Configuration used by lens correction cosine fourth + * + * @enabled: enabled setting flag. + * @circle: len circle. + * @r_param: lens correction cosine fourth curve param for Bayer pattern R. + * @gr_param: lens correction cosine fourth curve param for Bayer pattern Gr. + * @gb_param: lens correction cosine fourth curve param for Bayer pattern Gb. + * @b_param: lens correction cosine fourth curve param for Bayer pattern B. + */ +struct jh7110_isp_lccf_setting { + __u32 enabled; + struct jh7110_isp_lccf_circle circle; + struct jh7110_isp_lccf_curve_param r_param; + struct jh7110_isp_lccf_curve_param gr_param; + struct jh7110_isp_lccf_curve_param gb_param; + struct jh7110_isp_lccf_curve_param b_param; +}; + +/** + * struct jh7110_isp_obc_win_size - optical black correction window size + * + * @width: window width. + * @height: window height. + */ +struct jh7110_isp_obc_win_size { + __u32 width; + __u32 height; +}; + +/** + * struct jh7110_isp_obc_gain - optical black correction symbol gain + * + * @tl_gain: gain at point A for symbol. + * @tr_gain: gain at point B for symbol. + * @bl_gain: gain at point C for symbol. + * @br_gain: gain at point D for symbol. + */ +struct jh7110_isp_obc_gain { + __u8 tl_gain; + __u8 tr_gain; + __u8 bl_gain; + __u8 br_gain; +}; + +/** + * struct jh7110_isp_obc_offset - optical black correction symbol offset + * + * @tl_offset: offset at point A for symbol. + * @tr_offset: offset at point B for symbol. + * @bl_offset: offset at point C for symbol. + * @br_offset: offset at point D for symbol. + */ +struct jh7110_isp_obc_offset { + __u8 tl_offset; + __u8 tr_offset; + __u8 bl_offset; + __u8 br_offset; +}; + +/** + * struct jh7110_isp_obc_setting - Configuration used by optical black correction + * + * @enabled: enabled setting flag. + * @win_size: optical black correction window size. + * @gain: optical black correction symbol gain. + * @offset: optical black correction symbol offset. + */ +struct jh7110_isp_obc_setting { + __u32 enabled; + struct jh7110_isp_obc_win_size win_size; + struct jh7110_isp_obc_gain gain[4]; + struct jh7110_isp_obc_offset offset[4]; +}; + +/** + * struct jh7110_isp_oecf_point - oecf curve + * + * @x: x coordinate. + * @y: y coordinate. + * @slope: the slope between this point and the next point. + */ +struct jh7110_isp_oecf_point { + __u16 x; + __u16 y; + __s16 slope; +}; + +/** + * struct jh7110_isp_oecf_setting - Configuration used by opto-electric conversion function + * + * @enabled: enabled setting flag. + * @r_curve: red pixel oecf curve. + * @gr_curve: green pixel oecf curve in GR line. + * @gb_curve: green pixel oecf curve in GB line. + * @b_curve: blue pixel oecf curve. + */ +struct jh7110_isp_oecf_setting { + __u32 enabled; + struct jh7110_isp_oecf_point r_curve[16]; + struct jh7110_isp_oecf_point gr_curve[16]; + struct jh7110_isp_oecf_point gb_curve[16]; + struct jh7110_isp_oecf_point b_curve[16]; +}; + +/** + * struct jh7110_isp_r2y_matrix - RGB to YUV color conversion matrix + * + * @m: The 3x3 color conversion matrix coefficient. + */ +struct jh7110_isp_r2y_matrix { + __s16 m[9]; +}; + +/** + * struct jh7110_isp_r2y_setting - Configuration used by RGB To YUV + * + * @enabled: enabled setting flag. + * @matrix: RGB to YUV color conversion matrix. + */ +struct jh7110_isp_r2y_setting { + __u32 enabled; + struct jh7110_isp_r2y_matrix matrix; +}; + +/** + * struct jh7110_isp_sat_curve - Saturation curve + * + * @yi_min: the minimum input Y value. + * @yo_ir: the ratio of Y output range to input range. + * @yo_min: the minimum output Y value. + * @yo_max: the maximum output Y value. + */ +struct jh7110_isp_sat_curve { + __s16 yi_min; + __s16 yo_ir; + __s16 yo_min; + __s16 yo_max; +}; + +/** + * struct jh7110_isp_sat_hue_info - Chroma Saturation Hue Factor + * + * @cos: COS hue factor. + * @sin: SIN hue factor. + */ +struct jh7110_isp_sat_hue_info { + __s16 cos; + __s16 sin; +}; + +/** + * struct jh7110_isp_sat_info - Saturation information + * + * @gain_cmab: Chroma saturation magnitude amplification base for gain. + * @gain_cmmd: Chroma saturation magnitude amplification delta for gain. + * @threshold_cmb: Chroma saturation magnitude base threshold. + * @threshold_cmd: Chroma saturation magnitude delta threshold. + * @offset_u: Chroma saturation U offset. + * @offset_v: Chroma saturation V offset. + * @cmsf: Chroma saturation magnitude scaling factor. + */ +struct jh7110_isp_sat_info { + __s16 gain_cmab; + __s16 gain_cmmd; + __s16 threshold_cmb; + __s16 threshold_cmd; + __s16 offset_u; + __s16 offset_v; + __s16 cmsf; +}; + +/** + * struct jh7110_isp_sat_setting - Configuration used by Saturation + * + * @enabled: enabled setting flag. + * @curve: Saturation curve. + * @hue_info: Chroma Saturation Hue Factor. + * @sat_info: Saturation information.s + */ +struct jh7110_isp_sat_setting { + __u32 enabled; + struct jh7110_isp_sat_curve curve; + struct jh7110_isp_sat_hue_info hue_info; + struct jh7110_isp_sat_info sat_info; +}; + +/** + * struct jh7110_isp_sharp_weight - Sharpe weight + * + * @weight: Sharpen filter weight. + * @recip_wei_sum: Sharpen amplification filter weight normalization factor. + */ +struct jh7110_isp_sharp_weight { + __u8 weight[15]; + __u32 recip_wei_sum; +}; + +/** + * struct jh7110_isp_sharp_strength - Sharpen strength + * + * @diff: Sharpen Edge amplification delta level. + * @f: Sharpen Edge amplification factor. + * @s: Sharpen Edge amplification factor slope. + */ +struct jh7110_isp_sharp_strength { + __s16 diff[4]; + __s16 f[3]; + __s32 s[3]; +}; + +/** + * struct jh7110_isp_sharp_setting - Configuration used by Sharpen + * + * @enabled: enabled setting flag. + * @weight: Sharpe weight. + * @strength: Sharpen strength. + * @pdirf: Positive Factor Multiplier. + * @ndirf: Negative Factor Multiplier. + */ +struct jh7110_isp_sharp_setting { + __u32 enabled; + struct jh7110_isp_sharp_weight weight; + struct jh7110_isp_sharp_strength strength; + __s8 pdirf; + __s8 ndirf; +}; + +/** + * struct jh7110_isp_ycrv_curve - Y Curve parameters table + * + * @y: Y curve L parameters value. + */ +struct jh7110_isp_ycrv_curve { + __s16 y[64]; +}; + +/** + * struct jh7110_isp_ycrv_setting - Configuration used by Y Curve + * + * @enabled: enabled setting flag. + * @curve: Y Curve parameters table. + */ +struct jh7110_isp_ycrv_setting { + __u32 enabled; + struct jh7110_isp_ycrv_curve curve; +}; + +/** + * struct jh7110_isp_sc_config - statistics collection crop configure + * + * @h_start: Horizontal starting point for frame cropping. + * @v_start: Vertical starting point for frame cropping. + * @sw_width: Width of statistics collection sub-window. + * @sw_height: Height of statistics collection sub-window. + * @hperiod: Horizontal period. + * @hkeep: Horizontal keep. + * @vperiod: Vertical period. + * @vkeep: Vertical keep. + */ +struct jh7110_isp_sc_config { + __u16 h_start; + __u16 v_start; + __u8 sw_width; + __u8 sw_height; + __u8 hperiod; + __u8 hkeep; + __u8 vperiod; + __u8 vkeep; +}; + +/** + * struct jh7110_isp_sc_af_config - statistics collection auto focus configure + * + * @es_hor_mode: Horizontal mode. + * @es_sum_mode: sum mode. + * @hor_en: Horizontal enable. + * @ver_en: Vertical enable. + * @es_ver_thr: Vertical threshold. + * @es_hor_thr: Horizontal threshold. + */ +struct jh7110_isp_sc_af_config { + __u8 es_hor_mode; + __u8 es_sum_mode; + __u8 hor_en; + __u8 ver_en; + __u8 es_ver_thr; + __u16 es_hor_thr; +}; + +/** + * struct jh7110_isp_sc_awb_ps - statistics collection auto white balance pixel sum + * + * @awb_ps_rl: Lower boundary of R value for pixel sum. + * @awb_ps_ru: Upper boundary of R value for pixel sum. + * @awb_ps_gl: Lower boundary of G value for pixel sum. + * @awb_ps_gu: Upper boundary of G value for pixel sum. + * @awb_ps_bl: Lower boundary of B value for pixel sum. + * @awb_ps_bu: Upper boundary of B value for pixel sum. + * @awb_ps_yl: Lower boundary of Y value for pixel sum. + * @awb_ps_yu: Upper boundary of Y value for pixel sum. + * @awb_ps_grl: Lower boundary of G/R ratio for pixel sum. + * @awb_ps_gru: Upper boundary of G/R ratio for pixel sum. + * @awb_ps_gbl: Lower boundary of G/B ratio for pixel sum. + * @awb_ps_gbu: Upper boundary of G/B ratio for pixel sum. + * @awb_ps_grbl: Lower boundary of (Gr/R + b/a * Gb/B) for pixel sum. + * @awb_ps_grbu: Upper boundary of (Gr/R + b/a * Gb/B) for pixel sum. + */ +struct jh7110_isp_sc_awb_ps { + __u8 awb_ps_rl; + __u8 awb_ps_ru; + __u8 awb_ps_gl; + __u8 awb_ps_gu; + __u8 awb_ps_bl; + __u8 awb_ps_bu; + __u8 awb_ps_yl; + __u8 awb_ps_yu; + __u16 awb_ps_grl; + __u16 awb_ps_gru; + __u16 awb_ps_gbl; + __u16 awb_ps_gbu; + __u16 awb_ps_grbl; + __u16 awb_ps_grbu; +}; + +/** + * struct jh7110_isp_sc_awb_ws - statistics collection auto white balance weight sum + * + * @awb_ws_rl: Lower boundary of R value for weight sum. + * @awb_ws_ru: Upper boundary of R value for weight sum. + * @awb_ws_grl: Lower boundary of Gr value for weight sum. + * @awb_ws_gru: Upper boundary of Gr value for weight sum. + * @awb_ws_gbl: Lower boundary of Gb value for weight sum. + * @awb_ws_gbu: Upper boundary of Gb value for weight sum. + * @awb_ws_bl: Lower boundary of B value for weight sum. + * @awb_ws_bu: Upper boundary of B value for weight sum. + */ +struct jh7110_isp_sc_awb_ws { + __u8 awb_ws_rl; + __u8 awb_ws_ru; + __u8 awb_ws_grl; + __u8 awb_ws_gru; + __u8 awb_ws_gbl; + __u8 awb_ws_gbu; + __u8 awb_ws_bl; + __u8 awb_ws_bu; +}; + +/** + * struct jh7110_isp_sc_awb_point - statistics collection auto white balance point + * + * @weight: Weighting value at point. + */ +struct jh7110_isp_sc_awb_point { + __u8 weight; +}; + +/** + * struct jh7110_isp_sc_awb_config - statistics collection auto white balance configure + * + * @ps_config: statistics collection auto white balance pixel sum. + * @awb_ps_grb_ba: auto white balance b/a value. + * @sel: input mux for statistics collection auto white balance. + * @ws_config: statistics collection auto white balance weight sum. + * @awb_cw: Weighting value at 13x13 point. + * @pts: statistics collection auto white balance point. + */ +struct jh7110_isp_sc_awb_config { + struct jh7110_isp_sc_awb_ps ps_config; + __u8 awb_ps_grb_ba; + __u8 sel; + struct jh7110_isp_sc_awb_ws ws_config; + __u8 awb_cw[169]; + struct jh7110_isp_sc_awb_point pts[17]; +}; + +/** + * struct jh7110_isp_sc_setting - Configuration used by statistics collection + * + * @enabled: enabled setting flag. + * @crop_config: statistics collection crop configure. + * @af_config: statistics collection auto focus configure. + * @awb_config: statistics collection auto white balance configure. + */ +struct jh7110_isp_sc_setting { + __u32 enabled; + struct jh7110_isp_sc_config crop_config; + struct jh7110_isp_sc_af_config af_config; + struct jh7110_isp_sc_awb_config awb_config; +}; + +/** + * struct jh7110_isp_params_buffer - StarFive JH7110 ISP Parameters Meta Data + * + * @enable_setting: enabled setting module (JH7110_ISP_MODULE_* definitions). + * @wb_setting: Configuration used by auto white balance gain. + * @car_setting: Configuration used by color artifact removal. + * @ccm_setting: Configuration used by color correction matrix. + * @cfa_setting: Configuration used by demosaic module. + * @ctc_setting: Configuration used by crosstalk remove. + * @dbc_setting: Configuration used by defect bad pixels correction. + * @dnyuv_setting: Configuration used by yuv domain denoise. + * @gmargb_setting: Configuration used by RGB gamma. + * @lccf_setting: Configuration used by lens correction cosine fourth. + * @obc_setting: Configuration used by optical black compensation. + * @oecf_setting: Configuration used by opto-electric conversion function. + * @r2y_setting: Configuration used by RGB To YUV. + * @sat_setting: Configuration used by Saturation. + * @sharp_setting: Configuration used by Sharpen. + * @ycrv_setting: Configuration used by Y Curve. + * @sc_setting: Configuration used by statistics collection. + */ +struct jh7110_isp_params_buffer { + __u32 enable_setting; + struct jh7110_isp_wb_setting wb_setting; + struct jh7110_isp_car_setting car_setting; + struct jh7110_isp_ccm_setting ccm_setting; + struct jh7110_isp_cfa_setting cfa_setting; + struct jh7110_isp_ctc_setting ctc_setting; + struct jh7110_isp_dbc_setting dbc_setting; + struct jh7110_isp_dnyuv_setting dnyuv_setting; + struct jh7110_isp_gmargb_setting gmargb_setting; + struct jh7110_isp_lccf_setting lccf_setting; + struct jh7110_isp_obc_setting obc_setting; + struct jh7110_isp_oecf_setting oecf_setting; + struct jh7110_isp_r2y_setting r2y_setting; + struct jh7110_isp_sat_setting sat_setting; + struct jh7110_isp_sharp_setting sharp_setting; + struct jh7110_isp_ycrv_setting ycrv_setting; + struct jh7110_isp_sc_setting sc_setting; +}; + +/** + * Statistics Collection Meta Data Flag + */ +#define JH7110_ISP_SC_FLAG_AWB 0x0 +#define JH7110_ISP_SC_FLAG_AE_AF 0xffff + +#pragma pack(1) + +/** + * struct jh7110_isp_sc_buffer - StarFive JH7110 ISP Statistics Collection Meta Data + * + * @y_histogram: Y histogram data for saturation control. + * @reserv0: reserve byte. + * @bright_sc: bright statistic. If flag is JH7110_ISP_SC_FLAG_AE_AF, This field is + * saved auto exposure and auto focus. If flag is JH7110_ISP_SC_FLAG_AWB, + * This field is saved auto white balance. + * @reserv1: reserve byte. + * @ae_hist_y: Y histogram for auto exposure. + * @reserv2: reserve byte. + * @flag: Statistics Collection Meta Data Flag (JH7110_ISP_SC_FLAG_* definitions) + */ +struct jh7110_isp_sc_buffer { + __u32 y_histogram[64]; + __u32 reserv0[33]; + __u32 bright_sc[4096]; + __u32 reserv1[96]; + __u32 ae_hist_y[128]; + __u32 reserv2[511]; + __u16 flag; +}; + +#pragma pack() + +#endif From patchwork Tue Jul 9 08:38:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727468 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2131.outbound.protection.partner.outlook.cn [139.219.17.131]) (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 DD1DC1534E7; Tue, 9 Jul 2024 08:54:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.131 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720515270; cv=fail; b=V6bP30jUJdRM9bn+FCqrcfde/RktW31qvMOLR7J8aUa/EImYNup5gex+JO20sIcUDggBYd6clAgqMruVJ7nNmWImG5KmEg/fOBkYm82atlJvO2dAe+4Cm4D/7jex0CLIjyPq5/fLjssDBFlqKGKbfl60HxnJrGHEoAKmYvuw/Y0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720515270; c=relaxed/simple; bh=/mxQu4WduGh6JD4sZXvDc1CLTky9/6p47pP4582ec9w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=jnbBcVHN8Xl32DKnEV19FOBU/pdwECRn3wt9I8MNhQHpNymx8WTEOomOYkkg/GjoZHvRQ9/n6LNKQ8BJxDWQ2TqaN4/iqVCGXbJkyZpfTR2Pv40afZYfjG3VX+D3pSNLLpTvlbiaTdNc6N1hzJGmkcSee35yBnjXhSLqz6FiJ08= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iebXpODS6qmxvWY/FJ2otgk76khKVmD9c7N1kuqHmxU87/0cKPHDb2tGF4E+85e5L0OgueZT2kCuN4UP27QF3o9egrLItcdLhg+FGKti6qYLGfxVDet/w5ySsi99ZxLWP+tMaYYMy+cxd3JqQ5QRkG2D9m1GFu0lIvt/qSx5f+hUdZ6JsqYvbtgS0GBlQqMj5PEvhsxLQXVn/AA+Wx+dIYkim7aHj6WuTbILjvA4pkLxYlyEOL5fGn46lUvocqgWUlnTNVcxio5drCiGIFHHt+S6fYnyZtHkluxTgJj/wMPc583iDLD6C8BnUqZDiRZ/tlnOxHApNRqBtmbeAKvyaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PzJBv6I7SOZTWtP6BxFOw4KAIl21sUnsGEZ9hjJVPDc=; b=UFvw4YkDo1ILEZcYrTgtj0tJpKntmanOT+oiU0dwTcsuQZfUmdMEQLUGpwMXsF48EdiN48v2xpnvPNCs3tX10nxdk3QcmQFbudA5Bn5nZnK2xM7uvqU3rT891vYz0dE2KB/bWJ0zfq5OtMs1mks2C5nqCZ+bei+Iv6JlijNTelDsi2t9tBaoL1CklDfwJPchZWCWHugWhiRXul+B54sCa+RILmAGy0Dp8d+kud7AKxP2twwM2x71o0gD9NpvKxjEw1WMUUjXaYijRvHWPm3S0HC9IuYQyrH20F5tcGDwrkDLpeW7CJzW3dBuoWNEd1Dm27feICwdMQdV9bmPmsIksw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:34 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:34 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 02/14] media: Documentation: Add description for StarFive ISP metadata formats Date: Tue, 9 Jul 2024 01:38:12 -0700 Message-Id: <20240709083824.430473-3-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: 222ee995-6f60-4249-6ec1-08dc9ff2851a X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: so+phR7o1IN0Glh0NEJhpZ5q/Yy3ig6RMee5B2U9zUgJQIgsESKeCrKAOXUzuoSI3ie/cGMzgCbIB1peRzuOOEQ9orDConVSBVAWkCa6qm8NzfDM1i42B9F8ZUYXWXJ7EKmXWuEoDT2NOYFWvl39IQcJVCaXSw+Bz5VQKtWnlL1OK6Yye6VZ/8vOpsAbdMEpKqEQViD5tXxjRuoUcQZD+l8D100X0IYJWxfUvwruNnJft+KhCqD1Y7NkB6SiIT90U8KLfGuesDoWZ1Syu0BDPYithzHBvFwY5v6KugsmpcJsNOlqMn1Y9KfE8iiuEW0RA6jKgA7T+FOdm97ZeBocKuDCo1hWeeIHVSZsJVYmSJXlkzijvEYx8piNFeYt9/ej7kpY1VqUY6ZcgjgTu6ZV2wCiLzPc9YVhs9lDc+W7h4wVDW3QXM96Ru7N5TgwtrWF8F59wf0vSvCmH+TvVvlMaT15wwXZdwXtuYLHDNiwt2qZGLpwfsZ9XTU8LXfMj2ZEGTm5Ff33mm7ArSgautf6UtEDqGmLy7FRg8B3OTG8BSAoXyq50iylyPC1zOeWTed/5LTmRVueCHil9aMve4JztTC97Nc+IOOa46U+L8V+SV19uJCBC/bo/FkLEhL2WjSy X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Zae6CNFFcYnprjyK+X4HyedggtaQ3e+MUVVraTQrtZuzsSBcXrg8cxTd2PZPkUHltGK4/ZSNPHpOxvbJRuAiBkVd+JZCpZAZXp567rVVrwUtT1byU811QhXchPnpKO5QyF7dCmJFQdqZ491LbUz39eBdIy8NMKfe1VDEj9+B9m3S2dQgTcLB3LkTK+gR4E7rjr0uo3ed36V1JnmJBPUd9Scj/VNew6JIz4JeqIkuCVM0e/QvkiF8Fzf4hX0Tsm7s+SjbXWURPfU+EVFJT3XRjEg3lxoosFRosRT/mB7qrMRaAaBU+SM8iFHE+VpwXe+rGvzj1bJnVsnJDKvug02soNa8ubJ/A/a3iWIj1T5etLiwH06UoVsVC5VcqopIsFckSrliqCrEr/SnEa3p6g5+wK3dHumEAd1ybtJORne1KXqlVlsi20xZmwz0zjceDKr7wWCi7pp1en8CBI7hbMmCDQIVIg0wsUH03cc8jD3JFeEr2WrjrzdC+zfkukdHBT6D8mfKrstNRs7WX3lNKB2p3ZILIyT7NX2cjT1JTXrYtWyioiHljGHqAZRw5lfHy9WMWH13OelIDZ3E6dFSCojutzoqDSnF3EetkFo9h5kQ5OLgdcVzlOhsvVuC7kcqgDDw5+l3Ca0+m2lg3AEOpro8wuPfXHPgGNiLAp6nZoHwqoqG3//WN5oX9ss3tSXqimhnqXc83JJFud01MbdZNVTS5GlsFmEpYixcHxvMTeP68UypUgvN/R+R72c998mztjOjo0Riae8epXaOj1ODTi4lQGykve8NF22jP5QpJyBy45xCvjLNtNxUx8MqPukjRdnVGT4jc2afmLcRbzKtN33JY6FFsE9Kser/XSmPUg3kJnqdN1dZvONaKHcY5mk3ce6Nl/gR4w7cTwGnbOMY/DkwMDMvQs1j4CGzGjtRF9B9C8W1PQF9xsyKnCJPHwL4oi1Kctu9ARO8R4KYi0ceNw1Wp19G3AlwUyuzrG41lvDR5khAVPe5+TGAySiaVnGSfDMfnAYwkiKQplE82ecIo/0GYUycV1pDrt6sNddLgQnlDjrBSOG0ktvd41qM3Qx2Ww+gQdQf3jo1hg61sjW/NqLd0YiXDYz/v8XXFsyjCT3Wy4rlqzfF/Hp+64ylxcpN3lXWIiLw7S/+9//l+IxdP8dY9sSYRiojrzJ207U0Ozsza/MwlPHC8eGVPfdTC0wBAPEWATzUBIAM63Az02gATjW0LLkGR5jcvk0YxOB577UFrimTFFGE3uzGG8/+t3nluxOjmduhgZLFxqgBoMWBPchPdCwpbagwCOajM/5GOuhj1dP5u6NTLZMu30lLdwED3f8I4FZukjWePzQIxhsw4SWrNFbyAcShud4SXiStVZqdb7u7CDbrxD23MRO3eC4UCdIsw5EXXnII9W0t1NwT/RUMtkTz8WQSUKeUnX3/b7cZDSStmEh+rwi74ryBt+VvsWNY5eMzaoMz1jHscGZ1/9aSszfoWErduw/Wlk2MvIHVfPXzcp1GE9C2PeEjpa1gTg73yr5TIWN/2qnw3s2xsISnWIjJowxhG/OX6vylzbybr6Um3iSxWmOLYUNq03u78TUfdgFPItuOA5AoT2J9A1MwhFRSKrDEJu3ruRBI0ABUjcM= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 222ee995-6f60-4249-6ec1-08dc9ff2851a X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:34.4799 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ab2xpvlk/MJP5Vyqg9yzl3fPI/hxBz3A2TbM96N5DH+vzvtEMYRDHVDLL1JrsHswUCdi3RF8Zvo9++XYjGSmeK0LhpgmWqJsIu4O1hZe31eZ+YpoVXKXyClFQzt3fqi6 X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 Add description for V4L2_META_FMT_STF_ISP_PARAMS and V4L2_META_FMT_STF_ISP_STAT_3A meta data formats. Signed-off-by: Changhuang Liang --- .../media/v4l/metafmt-starfive-isp.rst | 75 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 76 insertions(+) create mode 100644 Documentation/userspace-api/media/v4l/metafmt-starfive-isp.rst diff --git a/Documentation/userspace-api/media/v4l/metafmt-starfive-isp.rst b/Documentation/userspace-api/media/v4l/metafmt-starfive-isp.rst new file mode 100644 index 000000000000..ebb4291833d6 --- /dev/null +++ b/Documentation/userspace-api/media/v4l/metafmt-starfive-isp.rst @@ -0,0 +1,75 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. _v4l2-meta-fmt-stf-isp-params: + +.. _v4l2-meta-fmt-stf-isp-stat-3a: + +***************************************************************************** +V4L2_META_FMT_STF_ISP_PARAMS ('stfp'), V4L2_META_FMT_STF_ISP_STAT_3A ('stfs') +***************************************************************************** + +.. jh7110_isp_params_buffer + +Configuration parameters +======================== + +The configuration parameters are passed to the "output_params" metadata output +video node, using the :c:type:`v4l2_meta_format` interface. They are formatted +as described by the :c:type:`jh7110_isp_params_buffer` structure. + +.. code-block:: c + + struct jh7110_isp_params_buffer { + __u32 enable_setting; + struct jh7110_isp_wb_setting wb_setting; + struct jh7110_isp_car_setting car_setting; + struct jh7110_isp_ccm_setting ccm_setting; + struct jh7110_isp_cfa_setting cfa_setting; + struct jh7110_isp_ctc_setting ctc_setting; + struct jh7110_isp_dbc_setting dbc_setting; + struct jh7110_isp_dnyuv_setting dnyuv_setting; + struct jh7110_isp_gmargb_setting gmargb_setting; + struct jh7110_isp_lccf_setting lccf_setting; + struct jh7110_isp_obc_setting obc_setting; + struct jh7110_isp_oecf_setting oecf_setting; + struct jh7110_isp_r2y_setting r2y_setting; + struct jh7110_isp_sat_setting sat_setting; + struct jh7110_isp_sharp_setting sharp_setting; + struct jh7110_isp_ycrv_setting ycrv_setting; + struct jh7110_isp_sc_setting sc_setting; + }; + +.. jh7110_isp_sc_buffer + +3A and histogram statistics +=========================== + +The ISP device collects different statistics over an input Bayer frame. +Those statistics are obtained from the "capture_scd" metadata capture video +node, using the :c:type:`v4l2_meta_format` interface. They are formatted as +described by the :c:type:`jh7110_isp_sc_buffer` structure. + +.. code-block:: c + + struct jh7110_isp_sc_buffer { + __u32 y_histogram[64]; + __u32 reserv0[33]; + __u32 bright_sc[4096]; + __u32 reserv1[96]; + __u32 ae_hist_y[128]; + __u32 reserv2[511]; + __u16 flag; + }; + +The statistics collected are Auto Exposure, AWB (Auto-white balance), Histogram +and AF (Auto-focus). See :c:type:`jh7110_isp_sc_buffer` for details of the +statistics. + +The 3A statistics and configuration parameters described here are usually +consumed and produced by dedicated user space libraries that comprise the +important tuning tools using software control loop. + +JH7110 ISP uAPI data types +====================== + +.. kernel-doc:: include/uapi/linux/jh7110-isp.h diff --git a/MAINTAINERS b/MAINTAINERS index 890604eb0d64..8fd613c93e62 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21304,6 +21304,7 @@ L: linux-media@vger.kernel.org S: Maintained F: Documentation/admin-guide/media/starfive_camss.rst F: Documentation/devicetree/bindings/media/starfive,jh7110-camss.yaml +F: Documentation/userspace-api/media/v4l/metafmt-starfive-isp.rst F: drivers/staging/media/starfive/camss F: include/uapi/linux/jh7110-isp.h From patchwork Tue Jul 9 08:38:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727755 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2137.outbound.protection.partner.outlook.cn [139.219.17.137]) (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 D2D5D13C3C9; Tue, 9 Jul 2024 12:13:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.137 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720527235; cv=fail; b=odhDp92IDIATf2cYhT68AEmfuwVlMfMDvOogKxUwO+YuzKjrMwuwlSUV5SEjlO0yau38Gq/2DdKCm1PAUpgDbENvadEBJ3gMRtJ5kr2627zrwEsQLW0ol+ixsgyps1FaPoNbUkzA1PMSUKeZW1H7uIZAZdO5ZavlnKM/quHgitE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720527235; c=relaxed/simple; bh=YXVf4i/sN9NU5gh6kvXcYEZKgS+BTdiwt8q4OM1BUc8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=jXbnKluBiDG/GyJit+wJmJD0BGU7FTHaFHNhWqXeWZcKJEVHvOzelNmH+OOBt1eeSBZ6nwNpGUOKNhmVS2ilqkMBtund9Br05IftgzWhVHZK7cSzTqoTih7/nPbMPlq2Ds/HDrkYexezP78QX6Py2FqbCc88Zb+d9t0eH/fuUNQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.137 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P6vObatM8uIQh5TmBD38iST38A+WkouQOFm+c0J6z2Aow7nVP2E8vdNugiySHbMaSLuYMLSS74dBSrY+tR4SFphjSw2Ncbi0qZ546VI8+lWTGUc40NiWt7QbNMSvTggakKl2uwN4tURO0vCa3tHba++bMHsBnEs12NYJ5ZfsRRrN1eNM0TzdI1ocpwIPkFJYQbl52/R4NaNp1a5/QgA0owJVYzmehFwSsjqe64VfsQ8JQXIKXkKdMDU2nxdIRA+t2hjPjfY00ZYVtSkDTG2amvWEFHbLnsAlCashfNJ4FuwctnOlu+L8A/Oyp2Y4aupUZ3sPFZj0J5WvsKbG25v9jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+7QPFBE9U0w7r8drB9DKAoS+4PQ5oP4sBCYlmsaH0hA=; b=URaSewCn4A26Zr0RiNzv3RVZ8wLO8iBdOaVi38fYyKoBLHFG/JAWZ8wGi/bPrtbs6C4NlR/7aHEN73yzgmxSMwlCFDBA/OE7jnRRtQ3T5SH5iBI/D7J8rWU0hHMxSFMUci06LwQyU6MySmHY9LNQNZ6mOPBSC4qypC/HjW4sQ2KMIj6IGPAJh4EtdP31KIGLdRjiCmHUquZ+o77Iw1K/mA+lya8B3UlpepS/Qm6bU32jf847kHPYfEYJONgw3cWsGWC86SWLM7sV8a+vdyq0GR/+DKEJa37kPlrgtTqF9Dk0WcxWkmw5+PdgFlJYugTFyqgm3ZSCqAyjhQUmraEh/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:35 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:35 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 03/14] media: videodev2.h, v4l2-ioctl: Add StarFive ISP meta buffer format Date: Tue, 9 Jul 2024 01:38:13 -0700 Message-Id: <20240709083824.430473-4-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: e98e7261-49af-4425-c8a2-08dc9ff285c6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: 3zeAzqPTbg8RNZZH6UOHa3x+OnTlCep5HB17CCiKG4kyDatL3N3yq6PI1zb3NZQ5HhX5oIm9yFexk/hJammyqZ32LUJL+rnv+CnXyBhSn7IbTyC6ZYrRemRoYFfJ5ll+2dLtl0wb7znJ85KSn4Z96mHqialhxnzOUNOpA+MAh0iNryZFlaWTM+MsqLHbyhyijbVF+l7ECPiCnpLTLomNw0l+3sOqqtsSyMzVU9cqmY6WAfFSEMZGDS8OlV/JxXrXSMfYtyJBpO0Cey9fnFEt1Yz2ZznfOzD4xsWPh0clEjsENf7bUdFG5XmsVAXARYxU3/KygEqzuSC/M2MyG+pJbln4lqqLT42mfgW732hp5RBDspYEqHrF13swlEZWSZAExoMnk0+QixTksUewVdeqx/p3/S3cjnTeka43e6nrMMLENvNVCoTDFEM/kRExnhr6plEmO4AGWJoQYspxknqTeQ+XRIQnWwN5d9PuNn6xle315iGdrH1sH0wKnVChhCTFOAta/7hEU0yv0seJ3dqsWmFS12j0Qp5ly1gQoxCcBKd3Ju5JGaPp2htysL/o98jD6TMzjv+Jg7peUTdTD9gdsgtKliybUq3GXYEXOOJwJEDD/hQJzAO5v4dcVdr3zqrb X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SsdPeC37s9Mg9lqPQwM5fOKx6+AOjgY1ONfdZeTY6GrddXZo2o6blvWqR6F4qyDK+7Kl9XeqOO7lgXJWC76P0JMXYUdXWXKagjJNEFbRaQ9Kn2zDDUrSsgai2/I41HQu9tq076kVUGrwr0yJtXdncRqK8kH+5CSD5KfG0gwFVuqL57BnGjkrP0lL+MGMBdAgAy6bb/XsPoCoX8eh+ClZSIsmUshHSST3Dlh5mxuqhavS9wYCBY8t6Vm1x/IsBLTWMO/+VKxYqfL9IDtDIKZnNX97B68/wUysCLTm/+BasG70NK/pfrkAuKfCdV3cj1hCGmlFegzyDcfFRfj6/iS22rQCCdPKAWiCpbMAg3sGGr9WC60eNBu2SMBaDzdtIjiCUAugA+B3bzyxqRpZajdO+y60J46gAHz22dTZJDICdf/TPN5ZeGgqeIHN6oyvDPP1uR24LaA0G/zQRo8r5Tj0OOyn/Ivt7EE3BUN28Cc6ReuVFVcHeqrJM2cYuVm64nGnVb1RCMQELmefWUB6T9a0nhvD0L+iGZ7mHQOwuiox0Sgju12qTpve7r+Vt6CmFe2C2bCRPSIu7pQY3C+06YX/gjy+gW7i0ntfR/LCz1zspkNftNAewinHy+8jTXsZ7NlkKQH0dZA/QQsb96krz0AMc1IJv2xQjydJ/dMwUj08hZiqlIdhObOvkCUraLiaPhQR6cUeYtTc9S0Rk1GnHGbmrVXHgb3BRhxIWZuw4GbMai6lalr2suBk4gXF2j+KqAi0sP8+mMFzGfG61FoLXPkXeKIl3kAsnH0ARGsm9akvt5TFL9m0ALaaRl/y5FIlu56pH1GAS9gCmA1U4C8dc31fhN83G0drAs7t642L2SqK00gZqgeoj5dPWa//L3oXeikBtkSsULj555ukSntVcaxQitFkfKlVLqHRLJvqCJZbOyrmgAScmUrIh2BlmbAF9U4cNtICHG5V1X9eXl23tui+72dzFsqPXWCcQKhrkMrn7VwcUY8jl+BlwEKcaJzJ5cHJGlj6lex9xyAMTRczj0lewp+7y+FHFBaMfKFPUGrHL60C3TIAxif9A2Z0dX85X1ihfWuhgK4rdjNKcRaEQrW/i4ObQV3/SBBBDHS8hkYVKVjAA86h3AJBC3ftPCEFUmQwWAE2N2/zsnHTbIerKC/GZf1uIJ+WTJKKTrkrL3ES1gca/DSFZONusxJHGi6DEW0+94EJTSsqwAZ9xdf3rb/iCiog5U1NpWA6G3LLNtwEHFMqowILuYiN0JOd42gk+VAO22XE57N25/CcqPIrhhbOrbFlpaecvGPGcAZajuW4ChmlE3SgNdQDZysgfFhY9xJ8cXIhzv/4R+3ANBYrdvQy6aAqoJkbte2PtQkAkUB5kePeWnoNyBNFONfemehve9KD8da7NQyfUFlcauhnxa8B8oWKbn9VzdDykiZRC7d1Naww4NwoLzkvkNPHUS3zKvthrn9UcQYwm/BUM8uzv08iHAMP6Z/vdfQblaadVah195E9o19dLi5sZusnkmk2ELioQga0NiN0UVO56Ft39GsF+pFUNGBKv1cyF2mId+N5u2E11QO/B3TITFdmaZrqnIN0kHQmrqf4hBvNYao819vWZdRt3KYJeMU9mz1fCnlxIcs= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: e98e7261-49af-4425-c8a2-08dc9ff285c6 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:35.6296 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5KRyTcXmWzV3ZGc3QKrD/p292/y3Sn5eddM9Rea7JuGpAD+Mu5Zacsxp6w2/5NEiaPmisOLp56Upd5XOYLbv1rLNyngQgJLlKszhb+dh1BWhxDrdznNV5aThw+bY3WXS X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 Add the StarFive ISP specific metadata format V4L2_META_FMT_STF_ISP_PARAMS & V4L2_META_FMT_STF_ISP_STAT_3A for 3A. Signed-off-by: Changhuang Liang Reviewed-by: Laurent Pinchart --- drivers/media/v4l2-core/v4l2-ioctl.c | 2 ++ include/uapi/linux/videodev2.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 4c76d17b4629..8770bfb31c5c 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1456,6 +1456,8 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) case V4L2_META_FMT_VIVID: descr = "Vivid Metadata"; break; case V4L2_META_FMT_RK_ISP1_PARAMS: descr = "Rockchip ISP1 3A Parameters"; break; case V4L2_META_FMT_RK_ISP1_STAT_3A: descr = "Rockchip ISP1 3A Statistics"; break; + case V4L2_META_FMT_STF_ISP_PARAMS: descr = "StarFive ISP 3A Parameters"; break; + case V4L2_META_FMT_STF_ISP_STAT_3A: descr = "StarFive ISP 3A Statistics"; break; case V4L2_PIX_FMT_NV12_8L128: descr = "NV12 (8x128 Linear)"; break; case V4L2_PIX_FMT_NV12M_8L128: descr = "NV12M (8x128 Linear)"; break; case V4L2_PIX_FMT_NV12_10BE_8L128: descr = "10-bit NV12 (8x128 Linear, BE)"; break; diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index fe6b67e83751..cfcbfe9bf973 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -841,6 +841,10 @@ struct v4l2_pix_format { #define V4L2_META_FMT_RK_ISP1_PARAMS v4l2_fourcc('R', 'K', '1', 'P') /* Rockchip ISP1 3A Parameters */ #define V4L2_META_FMT_RK_ISP1_STAT_3A v4l2_fourcc('R', 'K', '1', 'S') /* Rockchip ISP1 3A Statistics */ +/* Vendor specific - used for StarFive JH7110 ISP camera sub-system */ +#define V4L2_META_FMT_STF_ISP_PARAMS v4l2_fourcc('S', 'T', 'F', 'P') /* StarFive ISP 3A Parameters */ +#define V4L2_META_FMT_STF_ISP_STAT_3A v4l2_fourcc('S', 'T', 'F', 'S') /* StarFive ISP 3A Statistics */ + #ifdef __KERNEL__ /* * Line-based metadata formats. Remember to update v4l_fill_fmtdesc() when From patchwork Tue Jul 9 08:38:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727467 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2131.outbound.protection.partner.outlook.cn [139.219.17.131]) (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 A8BFE28DB3; Tue, 9 Jul 2024 08:54:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.131 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720515268; cv=fail; b=ImSAEt9jaUOKIstU5oQBLYe62B4rFB6eMwK67tIdRThT1E/c2Cr7WzzhX1yfvV5LNeCJ5NFwyp4o0eB6nPxRKdmKzHd1Z7oacQaMnN+vITeON7rbeKp6q/Tu7m8gi3bsUlrXF2rclPdDpqYZNEe4VDWVlNlHR562sZnmKdg8GlU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720515268; c=relaxed/simple; bh=O2TpQH3aYr58MdlMZd0isYo1hG/MrS/qWM/6mVNG860=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=uQdx5qsop9zQL06PH1Bh/dZuBwJjloW+6ULJX+hN+R3nXDh0fKuuIs6gcj5MlO+hugG6/Y2QXxPwzLStgRfimQkurlaXrjnwX8LgND1dpRgJB1/BmMfdttnGUzNt81MGkl3JCALEdKLI/EaSritHM4g2zDzuxlZkbx66uZMJbTU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gbywRAkctt2rsaZtEapae2RKIn20LKMIJ9Kp0lnila0JbJTtdzyilvkIMKtrDpdtbJflg+81N52IAoSqrHRu7LsxGaW522kyH7Xfkkr1lCY/AYvyvvzugsaOOgZwSaCEoK4xrRUWwXJSjSDqX4T+QVc8WB0csFCHEK8zsOUCUp1ixVB0ZSlZOlThdoH34VNc3R8Lsm22tJUfGXVwdZrY+rM7KyDVmvFS57zneuf3o17f3B8qOIxVyleka1mlZQbAqDpuvKL/i1zlZOQspKUYLLv1MJRat6lnIs07bj+isyzz9VP5xsd3QiC/LZ33vBXJvMrHy0Hl71UP/yH3XQ62dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jg8t6KA6xXaAbxDKOd9ejurVsKOaesP3cweja2TCY+4=; b=EC8790c5N4gM9Ov4x/92g7ISxuysJEYAespMAnyWmP7gUSekDI+NynMm/rn0dojZ96+pRImLHocOJrMrdvGySuOL43J91JgqjH9lXD0RK5rqZg3NJP1USkoA2TfyX4AWmTojeja79k6iotMb6ZyeMQmgV9aqnEL0eIkzP2nb5JUkTO1ghy6WkuaGU+1oF/ii/ckzsilboIK/JYhdaPK97lNfMfCWkVjUmb4MBID/1/y0Hg0IIIZZby2mc2D7fN7VNl7tEIxO1sxlqNWaunGshIaDryyWL3OJGvSv8CePX+nYe55gu7EL0H6ASNwm5i/59LLddVvJS2DE6qGnlmx+lA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:36 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:36 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 04/14] staging: media: starfive: Add a params sink pad and a scd source pad for ISP Date: Tue, 9 Jul 2024 01:38:14 -0700 Message-Id: <20240709083824.430473-5-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: e00b2c81-c1c9-4575-912b-08dc9ff28677 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: UaFKij3yCnhLI+aaMuDZiCKi0+v6dhC+6QdbvQdDIfariXivCsboDRrSSuIwxd8htrwywM25mE8KCiBLl6sL8KkXGa01hdVRO52vznYnanXqYSiYzDyEUdRSBo5/617frgysMwCaV9aucZvkfZGmWfssx4IPNZ1vL6jU2TNimHVKuMYsXOdeMf29XvMt8LtIpLDvFYUgq4tNRfSnrBGSAhK/ThDaNu8NHnkgDgvFqCmLbvx01KHt1Z7oKLVJgQORBM5vcZ5vzxc0na73WkuM2xyIMXAY0Ayt4IuNPIj2nWVlbitcG6VV+leKptnPEWgErYvTJPHQfsMSyvYmEd3f+O/r+t2SpKxDvVf1Ovm6kyRs0jocrqFIwykRA5DvDsr2TMFA3Vb+PM4pej2D8WFVjPf9ZHZK2YLJWnp9ohf+oGi1l0cuca93NdTDy6Wf14j9LcMuf9f+bfQSEZtyLjeuFhdH7Knlr2+wbMs+hBbNasrUP2to6Pd1jIQxdk7ut3rGNRthvnq40No33zE+gBOgOU/NZ5nA9qw+fxDfVTrmJMYSQMbGMSPQqfkLDoJGV6K85a9PJHFMuagxS/9TWUb9BDyTVKZXKxn66Ldbc9FckIfYHANTAEp5TyxFLsULUCep X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1GJWlKsuwPnhNPcu1eSzoIPb337lJBj7+X8ERquJisrywN58QD3oBNjww6Mxd703mzMyq9P9gJtR1tVXzHpxmLQFdRQWTZLk+KWz05ZvEU7Tkzgsl9O946S+4MLJsGlpid1iANGX3GrKGeEWJ4Sutc7G/G3Se+IOz48u8iW8UAAW3P2yo+JebLCbPThr4krimo1HTeOEJpMfPcoZrUGvScnz3qzXTRzhR4ib/68D/IgaWJ2ZmRVbnzUXvaC5NSAAXdB2LSWM264TFqN9ExJ3vQ5+uIx4ylvt9arBiB6DQOKGmgyYq42ybanWLqC6trvKAI6WsJU/LrAHoTdGQhm3pqPi60ceRCjSzd8ArmyLIdh08kl34DM3n/Pw9ElVRs0ec+i+qzc2ACCrwYalkrUmYFNq0RHo/FyohaXf20yWQUUPJ9/9aDuOuayMTrlN7E3Q/xZrCCCHXAsxEl3OYcVlUwXECP/PkuduxL0ecpp3EL170RSceSJ9umuugcInkV0mq/hRRuNP6pEC//zSmxYCxh6p6vx6NOfQNLoKI6ArvnD9pN04PNumHRO7I6ffWvIdOeh9whdkX3NloKrb+I4+b3nbCu6fFUFB2+v0EBp6gLfZD77a7svDWROvsNoSuqjdHCJhQW1n0ACfyQGbtCxccg3MQ7BQ9NU+9Y+gkZnG8yUvVlQHqMRGd5AONbpapJEdzoheRyFv0Syx29LAKn5ASWN2aTMYOJOcl8PgpfDyRHZDY6odHkPSZ/xmg5I6bTtVVd/YngN3hII/Wz2AJdZsI47DH+h4D8VqDfTNTvOlS+pExjooLciT7ZjsO2K7sBAr8KytMo/7X8f6/Egaw9d04aryTbkJCfhk9autMpanSsRQEl3k/RDA8yDEe8r9p/wTD6xg5a4I8212CIza34dlSqXhleSxjNdMWn/JnyVqL6rGD4kAzrrjY1INTXdZV/70jiCPF62kpTqRvSb8omYiNew0hp2bxcVAwTUZqlunVmiAku+7z649f2HcXxKOXxth/cb0/CV0QfprAeFKTVjjVsYMs0JJGcs1IQl0oI7WDGawcTe4TnM5lKoJmAg2rv2AQlsxZITE5JEM37Z/w/zYBRdMa5gYEkaIOukZ1F28SoI4kXDM2/mSR60QBKKWXFRoxW4cMTlYgVXGoio+ghcqViTeIqiDyS3QaG3mY4Lx5u/QGWLirLvQeUkm4b1GYe1iZZ9hUxDIdk+6YGc93va3wQXLIgkWjVUdzcAVoQMCUcvvJJ1psyKbWr+9ANbNjiw1wsPpvtFNNNfVnXr+rA+9JNO6L/T0bxCz88eYjaxr2h3ZwxCLczNACEWl/K7dfzqwhbfM9ELSLP/tWXESBSb9OEs/3rLKmqmC8nymSsaYqjIKERPi+iHSwfD/rkFdABa5kOpbCav4g/q1CqcE4SUaBENHLCDRJgZ4fIBmHd5ldlo5BYtb8PM2qvEckRmjT4/pRMkYnGXuKnIWjcUaKmLcyJ7wFqGDJSBTZxKx+7WmFnd7GIsP8ZmgfofunoKWi6HK0dK/7jSlQkk1FDWtuyHSPu8h1lUsVQj2ptCAUP6n7Vtyor5Bg3ML+UHhe1q7G5iA8U9be0As4pJfbYL6JFejTLkaQryqF0xGzhXxAKet2aw= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: e00b2c81-c1c9-4575-912b-08dc9ff28677 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:36.7851 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QqvAFyrJoZ7lEqjlc4Wg77A52/q64iJgyhews/FAb2gD3TEuRAxYRatgZ72hKXc+qwFd99yKjzyfFKzZ3tFZEJkTsJE283gj3uIGh6WrnTUUgdOOsuusZUMc0fKZvUSx X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 StarFive ISP can use params sink pad to transmit ISP parameters and use scd source pad to capture statistics collection data. Signed-off-by: Changhuang Liang Reviewed-by: Jacopo Mondi --- .../staging/media/starfive/camss/stf-isp.c | 77 +++++++++++++++++-- .../staging/media/starfive/camss/stf-isp.h | 2 + 2 files changed, 71 insertions(+), 8 deletions(-) diff --git a/drivers/staging/media/starfive/camss/stf-isp.c b/drivers/staging/media/starfive/camss/stf-isp.c index 4e6e26736852..0ebffd09842a 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.c +++ b/drivers/staging/media/starfive/camss/stf-isp.c @@ -21,13 +21,23 @@ static const struct stf_isp_format isp_formats_sink[] = { { MEDIA_BUS_FMT_SBGGR10_1X10, 10 }, }; +static const struct stf_isp_format isp_formats_sink_params[] = { + { MEDIA_BUS_FMT_METADATA_FIXED }, +}; + static const struct stf_isp_format isp_formats_source[] = { { MEDIA_BUS_FMT_YUYV8_1_5X8, 8 }, }; +static const struct stf_isp_format isp_formats_source_scd[] = { + { MEDIA_BUS_FMT_METADATA_FIXED }, +}; + static const struct stf_isp_format_table isp_formats_st7110[] = { { isp_formats_sink, ARRAY_SIZE(isp_formats_sink) }, + { isp_formats_sink_params, ARRAY_SIZE(isp_formats_sink_params) }, { isp_formats_source, ARRAY_SIZE(isp_formats_source) }, + { isp_formats_source_scd, ARRAY_SIZE(isp_formats_source_scd) }, }; static const struct stf_isp_format * @@ -93,13 +103,19 @@ static void isp_try_format(struct stf_isp_dev *isp_dev, formats = &isp_dev->formats[pad]; - fmt->width = clamp_t(u32, fmt->width, STFCAMSS_FRAME_MIN_WIDTH, - STFCAMSS_FRAME_MAX_WIDTH); - fmt->height = clamp_t(u32, fmt->height, STFCAMSS_FRAME_MIN_HEIGHT, - STFCAMSS_FRAME_MAX_HEIGHT); - fmt->height &= ~0x1; + if (pad != STF_ISP_PAD_SRC_SCD && pad != STF_ISP_PAD_SINK_PARAMS) { + fmt->width = clamp_t(u32, fmt->width, STFCAMSS_FRAME_MIN_WIDTH, + STFCAMSS_FRAME_MAX_WIDTH); + fmt->height = clamp_t(u32, fmt->height, STFCAMSS_FRAME_MIN_HEIGHT, + STFCAMSS_FRAME_MAX_HEIGHT); + fmt->height &= ~0x1; + fmt->colorspace = V4L2_COLORSPACE_SRGB; + } else { + fmt->width = 1; + fmt->height = 1; + } + fmt->field = V4L2_FIELD_NONE; - fmt->colorspace = V4L2_COLORSPACE_SRGB; fmt->flags = 0; if (!stf_g_fmt_by_mcode(formats, fmt->code)) @@ -119,7 +135,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd, formats = &isp_dev->formats[code->pad]; code->code = formats->fmts[code->index].code; - } else { + } else if (code->pad == STF_ISP_PAD_SRC) { struct v4l2_mbus_framefmt *sink_fmt; if (code->index >= ARRAY_SIZE(isp_formats_source)) @@ -131,6 +147,10 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd, code->code = sink_fmt->code; if (!code->code) return -EINVAL; + } else { + if (code->index > 0) + return -EINVAL; + code->code = MEDIA_BUS_FMT_METADATA_FIXED; } code->flags = 0; @@ -151,6 +171,9 @@ static int isp_set_format(struct v4l2_subdev *sd, isp_try_format(isp_dev, state, fmt->pad, &fmt->format); *format = fmt->format; + if (fmt->pad == STF_ISP_PAD_SRC_SCD || fmt->pad == STF_ISP_PAD_SINK_PARAMS) + return 0; + isp_dev->current_fmt = stf_g_fmt_by_mcode(&isp_dev->formats[fmt->pad], fmt->format.code); @@ -202,6 +225,9 @@ static int isp_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_format fmt = { 0 }; struct v4l2_rect *rect; + if (sel->pad == STF_ISP_PAD_SRC_SCD || sel->pad == STF_ISP_PAD_SINK_PARAMS) + return -EINVAL; + switch (sel->target) { case V4L2_SEL_TGT_CROP_BOUNDS: if (sel->pad == STF_ISP_PAD_SINK) { @@ -239,6 +265,9 @@ static int isp_set_selection(struct v4l2_subdev *sd, struct stf_isp_dev *isp_dev = v4l2_get_subdevdata(sd); struct v4l2_rect *rect; + if (sel->pad == STF_ISP_PAD_SRC_SCD || sel->pad == STF_ISP_PAD_SINK_PARAMS) + return -EINVAL; + if (sel->target != V4L2_SEL_TGT_CROP) return -EINVAL; @@ -296,8 +325,38 @@ static int isp_init_formats(struct v4l2_subdev *sd, .height = 1080 } }; + struct v4l2_subdev_format format_params = { + .pad = STF_ISP_PAD_SINK_PARAMS, + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + .format = { + .code = MEDIA_BUS_FMT_METADATA_FIXED, + .width = 1, + .height = 1 + } + }; + struct v4l2_subdev_format format_scd = { + .pad = STF_ISP_PAD_SRC_SCD, + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + .format = { + .code = MEDIA_BUS_FMT_METADATA_FIXED, + .width = 1, + .height = 1 + } + }; + int ret; + + /* Init for STF_ISP_PAD_SINK and STF_ISP_PAD_SRC pad */ + ret = isp_set_format(sd, sd_state, &format); + if (ret < 0) + return ret; + + /* Init for STF_ISP_PAD_SINK_PARAMS pad */ + ret = isp_set_format(sd, sd_state, &format_params); + if (ret < 0) + return ret; - return isp_set_format(sd, sd_state, &format); + /* Init for STF_ISP_PAD_SRC_SCD pad */ + return isp_set_format(sd, sd_state, &format_scd); } static const struct v4l2_subdev_video_ops isp_video_ops = { @@ -338,7 +397,9 @@ int stf_isp_register(struct stf_isp_dev *isp_dev, struct v4l2_device *v4l2_dev) v4l2_set_subdevdata(sd, isp_dev); pads[STF_ISP_PAD_SINK].flags = MEDIA_PAD_FL_SINK; + pads[STF_ISP_PAD_SINK_PARAMS].flags = MEDIA_PAD_FL_SINK; pads[STF_ISP_PAD_SRC].flags = MEDIA_PAD_FL_SOURCE; + pads[STF_ISP_PAD_SRC_SCD].flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = MEDIA_ENT_F_PROC_VIDEO_ISP; sd->entity.ops = &isp_media_ops; diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h index 955cbb048363..bc7e7b0736fa 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.h +++ b/drivers/staging/media/starfive/camss/stf-isp.h @@ -392,7 +392,9 @@ /* pad id for media framework */ enum stf_isp_pad_id { STF_ISP_PAD_SINK = 0, + STF_ISP_PAD_SINK_PARAMS, STF_ISP_PAD_SRC, + STF_ISP_PAD_SRC_SCD, STF_ISP_PAD_MAX }; From patchwork Tue Jul 9 08:38:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727440 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2111.outbound.protection.partner.outlook.cn [139.219.146.111]) (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 4136D154426; Tue, 9 Jul 2024 08:39:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514401; cv=fail; b=pobBi2p5t5pF+vRtR2wCE3vsODAINoCwoULc1JsOqnk0GZyTWrtSSDtqzz7QLf1wZuBX/cn5Bzet4gYaeOoklAnsw4K8u7RZw/2KeLbWmrnalk1IIBgCXcMcObPnbCLfkVKmxkEAGZCsw4KZu8+Os/8A9vjshl40uhiRYHZWLvY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514401; c=relaxed/simple; bh=0FDg1Dj4Neu94iKgf6Vq/84ghq2Tgp84xqp4AdbB87o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=TnUBfj3HV2QJGAZiRXD35wQZCjJagZwpCjyJmwJcGBWyuFGVj223+deduxiaib7Zgq02qoruPVjCIs8nMwMHT5HYRbCFtnHvYNIzaUQVkXslDpYIBp7F+TcNtkJlJr0Nn+k01rmQkFat2R8AS1vAyV2K9Zs1sBs5jhK2xwh1dNA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QrHot2MMCuKAEFCHUn9WpF7+MxpxfrztbppNDJ2qjxJLrJXOUODzFLPcfssMinY5kz6EDJeT7XtAXrz1km2HNV/ZL/kzY2DlR7C7jHpKN5YKnkSdsPHMRVXBf7oS646xh4bI05xIarrYv9MOdyYbdAJ9d2q6KN30XZLxVsxk+0Z1wBkKlzsKsEtrn1JMrPfqxPSvGAxg1nMcGU1Nn3GW+IO9hK5tAvfRbQSKzS19Gi7UrhT8iLtyThf6n9mMAMRv57cUEqgk7Od7t69VJKiFMQaZfShIGxoltG0mseUq9Kgqwpn1AiilJFObynkmsr3kazWou2EdC0SvLmRrsF3dUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=thBwTr7qfYGt42akuCR7XIcF6Ei8+yjyc2yt/SHlfyE=; b=Lyzsk52CyY0SmKnb/sYckLhqNCS/bT4cukVB1N2p1WJD+EUE0TOFaDPtYKE47y3ddAcqQ4Wpf8KtRO4Fr/FrDqS0BOSRGdFNOcpXqLvbhWlb9rfKtUrHwj+gDKybnyhCAyeS/4sEqIfHmnF4Hv3nFBJynLuyap4B3NPiJsUoVJRbD/OsNWP2XmIuEd8hA8pv1T3f4MEI/p7IzmzoYQog/dJvVWcXZfkpoBMZ08XL0bb7vsITeHb+KEgQosGeDEU/BPh647ov4nIDPuvo4TLGpW9I1U/Cx4dlC41qoC0zz+q3G75CNCqp0P0MfU3guRIA+X9z0/hKrm5/Lj2ovr61Yg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:38 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:37 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 05/14] staging: media: starfive: Separate buffer from ISP hardware operation Date: Tue, 9 Jul 2024 01:38:15 -0700 Message-Id: <20240709083824.430473-6-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: 7337e719-7f54-4e8b-c18a-08dc9ff28727 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: yeHI6/WXXV2HG1dOqFy7lwDILtUzd/WKICIqk5xSQ2Y4naWo01xW/Mu7YfQ15vKbPsJgwRLMVie/rDNuHbmNuD/L1se0xxYUc7sdWY1iOQXrUTfnjq56gZClQNLLZxYctWGTB4mvbXyjF4ZzBWc5jYFLpU090U6c1WZnHve/e3bxDCrBS9QtywoG6MZZ2AbI/1/KOacYDlSKx9vS7EJwQw014tKdso9+Io25yevTaxjH+e27FXDk1Xxn0crZnzj9ol/paJRlVyIfqqlPa2aoHa/+UHAhQ+GnGq5f0OBOyioVp2lxovNNcsXqM5RC8GgDccuI0TePpmw2dRAyw4GPmcp1JoUgmUNME2LSBqTPEVSQvWxZzekZqYaLs/QSFcV55+/aID86rc1a4ycSP/C+M7ToP6wbzRzk3PgaCEz4MHreeuK1ttLB7e7raK8ts5RS71nNvUxb9kAiK3NKXaefoVYvglyG+L+pQR379BadbIO5Ce13I3Q0RkohffZXerCCeMFFSmGkWyHW6tn3gPScmkhoHhCw4kmq8D2noyKmFx1qSc9XOepapQYZ3XEBn3MLXOgmz5kHo4hKpfPTe8+gOdyKOsKnv1HK5J9zXixJ9ISfCzUmsJNeSfy4PqJjBoN8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XeAeDfOWDP3ODFJcdEjZ3qTsKD8l/YTm+XkgAO+/Fs9A4bFqPh7F3UPzqBYg2wAAwNnUz62igHjfx5SpdR2RKACioa0u4z9qqUxsa8mjIg99YfuUleMBBBEXowoithvml61lbt1c5NSe+LxEBRsg4jaTx3lVAFWfoAMm15OUyEweB5eqNJ0dchtzPJ/DBJI8V6qlLTm2ZZRgIuE3ITh9InFXo6LL/vE3ac0gu8zYOCpGkk33xnDbXD/kWIKgZJl2mPXdu5N++hd4lgGSRi8KFYXvTvsEC8LGQesNw4igUnRAdvsso2UDEUFVUB0uGxigSxvQg4iL0ksyeP/mHd6s1qGi8y44ZH5lzBUpb2RSPqsNd4wQru3qzcht9dI1F44rLaVvNqLYmeH4lIhPn/cNfluuaqxfLWyyQEMsgBxWZNt8sY0uvsfx3sAxXO1S51tcAEKKK08+N+sJCZCeyRuGRrV/FwJ/qJrMUyQuyEQ6v4sXE+CjadbwO1u/iyodyLR/JGcaw7XrCjZ1KXOFTm4gWvohBIjgjqqw6PHE0Kvh0owyedIQKwZInTJbouf9wvZO9xOpuTf9Ws7URHp53sxc8oXNq00TbrYILCEqXhPGAWc7KSzZf+NkJIOH/8YAG5634ISwwrIoRa+XMhwqWFgPbfGYjv86qogyLfp8YzL6FsD2QKvB9YQ4DbibJcIkDIq8A5xmz6QDwkE90/NQjgUWE9kgR85o2KPENsgdMIZvEKP8kUN2e/Pl9p+xlS6U8EyYVaNslNjgFWoBPPdOFGaSoaJSBOpVn9jW52cWOwS5rE6dpmxCtgg71ZBbT0vzzxcIhFucLCoosVksh0a5+lnFVVAoClrbhM5tWahaOwIVtIYjwfnaG3WAGOhjTPMaklknNgql+1SDE7jrh1GYFfxJ1xsm/IsALOY0Z49QDkoBAEQBvIra4KRADsKjWrerkh860N6jqsAmtSFSAyrYbcjdTUAl/Ffg01HwRRwZOs6uZIsCWObDDI9euW9UTZnMQUQ2t00eBrAklNSEdRzl9UEzYAgLGxVgokW3jxNbA4JhkNKQI7Q4YVJuwmL6OQ56Mi69LW7ppQXbcgnF6Bu1mwA9HabRqChJS3Vy+j4dGEBtEHwtMhQG346J3Cg6ut3+B71/vot/P9n/ajj0nGSTxi+jQZcBJ9NuJU6EE0ja682RBSZ1io6H9vXc+sAESOzd3Edxy7sSuxrpoQjF4uzIh2ZsqDDBDorMGzIKji4+dR43lcUXwSkFNO7IOwfOcxtWMVJ1oFuLfYo48Pi0LWBccHDUrIFXGoSa9R8r4A8Oce81dZMe+q/8xZVNB6iRAy0OLUQtQLFQr+uYUQ74VDtDym29xlBDvu8znsqghN+QVtRUDFlFzTwCvYEQ1z+cElpgJnEguC4T0HFEYZsLd6vLUXek1NUFwrKK7KKij7TNcdM5aa9uO8t+nm+2r+1YJsCLnFm7LxNdSeJDLTF6Q9aOMHh5bWOyXdyREQzCr/xJ/mzLq6srSDF67BydRigT7HU0iCfQ/sBgX/MBXTU1qyaEkXpP30pTwK4PPLhY2qTBad6hU5AeUVpOLY2lRmwk+6CwfpkFAsu4WvvYnCYz0CDg+ArZAExcdJDJC37by5gY0+Yuou4= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7337e719-7f54-4e8b-c18a-08dc9ff28727 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:37.9544 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bVJn9V9c8i4vMP/mGzPaHNje1YtvDeeP3GL1u3Zwefol+f+00auLdVEhRstpeNQZrhMxwsJVDTeegBAUtvmqLIXTpD/4al32wPx/vDUA+ihx09zxWDtJTGx2kFqZ5PSt X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 Separate buffer from ISP hardware operation. Convenient to extract the buffer be a common file. Replace "while" with "if" in stf_buf_done helper function because one interrupt signal only handle one video buffer. Signed-off-by: Changhuang Liang --- .../media/starfive/camss/stf-capture.c | 63 +++++++++++-------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/drivers/staging/media/starfive/camss/stf-capture.c b/drivers/staging/media/starfive/camss/stf-capture.c index ec5169e7b391..494e56e731f0 100644 --- a/drivers/staging/media/starfive/camss/stf-capture.c +++ b/drivers/staging/media/starfive/camss/stf-capture.c @@ -368,7 +368,7 @@ static void stf_buf_flush(struct stf_v_buf *output, enum vb2_buffer_state state) } } -static void stf_buf_done(struct stf_v_buf *output) +static struct stfcamss_buffer *stf_buf_done(struct stf_v_buf *output) { struct stfcamss_buffer *ready_buf; u64 ts = ktime_get_ns(); @@ -376,27 +376,27 @@ static void stf_buf_done(struct stf_v_buf *output) if (output->state == STF_OUTPUT_OFF || output->state == STF_OUTPUT_RESERVED) - return; + return NULL; spin_lock_irqsave(&output->lock, flags); - while ((ready_buf = stf_buf_get_ready(output))) { + ready_buf = stf_buf_get_ready(output); + if (ready_buf) { ready_buf->vb.vb2_buf.timestamp = ts; ready_buf->vb.sequence = output->sequence++; - - vb2_buffer_done(&ready_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); } spin_unlock_irqrestore(&output->lock, flags); + + return ready_buf; } -static void stf_change_buffer(struct stf_v_buf *output) +static struct stfcamss_buffer *stf_change_buffer(struct stf_v_buf *output) { struct stf_capture *cap = container_of(output, struct stf_capture, buffers); struct stfcamss *stfcamss = cap->video.stfcamss; struct stfcamss_buffer *ready_buf; - dma_addr_t *new_addr; unsigned long flags; u32 active_index; @@ -404,7 +404,7 @@ static void stf_change_buffer(struct stf_v_buf *output) output->state == STF_OUTPUT_STOPPING || output->state == STF_OUTPUT_RESERVED || output->state == STF_OUTPUT_IDLE) - return; + return NULL; spin_lock_irqsave(&output->lock, flags); @@ -426,37 +426,37 @@ static void stf_change_buffer(struct stf_v_buf *output) /* Get next buffer */ output->buf[active_index] = stf_buf_get_pending(output); - if (!output->buf[active_index]) { - new_addr = ready_buf->addr; + if (!output->buf[active_index]) stf_buf_update_on_last(output); - } else { - new_addr = output->buf[active_index]->addr; + else stf_buf_update_on_next(output); - } - if (output->state == STF_OUTPUT_STOPPING) { + if (output->state == STF_OUTPUT_STOPPING) output->last_buffer = ready_buf; - } else { - if (cap->type == STF_CAPTURE_RAW) - stf_set_raw_addr(stfcamss, new_addr[0]); - else if (cap->type == STF_CAPTURE_YUV) - stf_set_yuv_addr(stfcamss, new_addr[0], new_addr[1]); - + else stf_buf_add_ready(output, ready_buf); - } out_unlock: spin_unlock_irqrestore(&output->lock, flags); + + return output->buf[active_index]; } irqreturn_t stf_wr_irq_handler(int irq, void *priv) { struct stfcamss *stfcamss = priv; struct stf_capture *cap = &stfcamss->captures[STF_CAPTURE_RAW]; + struct stfcamss_buffer *change_buf; + struct stfcamss_buffer *ready_buf; if (atomic_dec_if_positive(&cap->buffers.frame_skip) < 0) { - stf_change_buffer(&cap->buffers); - stf_buf_done(&cap->buffers); + change_buf = stf_change_buffer(&cap->buffers); + if (change_buf) + stf_set_raw_addr(stfcamss, change_buf->addr[0]); + + ready_buf = stf_buf_done(&cap->buffers); + if (ready_buf) + vb2_buffer_done(&ready_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); } stf_syscon_reg_set_bit(stfcamss, VIN_INRT_PIX_CFG, U0_VIN_INTR_CLEAN); @@ -469,12 +469,16 @@ irqreturn_t stf_isp_irq_handler(int irq, void *priv) { struct stfcamss *stfcamss = priv; struct stf_capture *cap = &stfcamss->captures[STF_CAPTURE_YUV]; + struct stfcamss_buffer *ready_buf; u32 status; status = stf_isp_reg_read(stfcamss, ISP_REG_ISP_CTRL_0); if (status & ISPC_ISP) { - if (status & ISPC_ENUO) - stf_buf_done(&cap->buffers); + if (status & ISPC_ENUO) { + ready_buf = stf_buf_done(&cap->buffers); + if (ready_buf) + vb2_buffer_done(&ready_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + } stf_isp_reg_write(stfcamss, ISP_REG_ISP_CTRL_0, (status & ~ISPC_INT_ALL_MASK) | @@ -488,13 +492,18 @@ irqreturn_t stf_line_irq_handler(int irq, void *priv) { struct stfcamss *stfcamss = priv; struct stf_capture *cap = &stfcamss->captures[STF_CAPTURE_YUV]; + struct stfcamss_buffer *change_buf; u32 status; status = stf_isp_reg_read(stfcamss, ISP_REG_ISP_CTRL_0); if (status & ISPC_LINE) { if (atomic_dec_if_positive(&cap->buffers.frame_skip) < 0) { - if ((status & ISPC_ENUO)) - stf_change_buffer(&cap->buffers); + if ((status & ISPC_ENUO)) { + change_buf = stf_change_buffer(&cap->buffers); + if (change_buf) + stf_set_yuv_addr(stfcamss, change_buf->addr[0], + change_buf->addr[1]); + } } stf_isp_reg_set_bit(stfcamss, ISP_REG_CSIINTS, From patchwork Tue Jul 9 08:38:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727441 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2111.outbound.protection.partner.outlook.cn [139.219.146.111]) (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 C3E9A154C02; Tue, 9 Jul 2024 08:40:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514403; cv=fail; b=aDiyjGDt+mKHGsdXaVw2hBlnpaQFc0xziVDgJuM9Vde7T+ibgpTulX6zHNANawHGsr4e6uaUdQlb+J4uPk7zcGvd/KDAyasdF3g/3fa7/q6lobq2o7FAEuF0y69F1V4YbOhnaA+jMezu/yCaMeakSHqZxwOjuhHsgndwVetqlgA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514403; c=relaxed/simple; bh=sayo4V87xszCiBFe1VAH/qoEodDVGFjtvlKqNeihdsE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=eIXErxWXzppsgGLkh/g/8Jw4e0KeKMhDX/o79I3eWBGgrBc8U/X4bSRP5m1YNfjvY9gNrp8T7jzV+WPD153K1DUUJne7J+fUsqIL+Lg9AL1ws/QmjQO0CICWyYlcRch+RrXWz8XMbUGHtKzQX1wQUbXR7dSrK78VSjQd5ksLzUA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ou+ulvRjz6S8fjwoEZBlWHBh9okwnLKKLPtijQo/z55v5Iedr6U61Swwy8phwnuuiMriMh26BbeMqjQtpJ8bKcrfcLK9qkQARXCkxP/Mzfzl8Bb0YPZ79xIX/O53yi+R04dslcb0N+L7d6pIE9UeOPQZboj7nBSPldGmjUrwhXYyG9HTb886utThzgZRuVs9kQR7EzgZwqWfZQpa8xGoVL0BehX2elVki6ncR8jw0x0dDqSW+DMPHtscZRhVyUK+OYs5JZIJtIATn3bzSJ+dwkYfRpf9+jhdNoqUmLUF++hrhvVzcGefu8KFKYtjS3AJlF5IJvMpZW6JyghSKNGYqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bGPoJG6WZTSrICAiJmktHByWoI1K0yWN+ivdhvmttgQ=; b=AdZwuafO5OGeSTlPZ2hzXjYpOzZF8kSTRQIx7SvqvmvZe8sg7GUrNCh2osNPgbf9135mUkLUs8RJAGbLRdg+lHHXrZY0rMyBIwdPlZQCzPGhK2x3rk9EycwkUj4ksmn/Hz5ESfsen+YT3L6GmMTenfT772k/GK9SivivmPfxubD+v9anBi0sHXbUQ0rlFPs1RDjSQyvE0/66weufY1uUwovpkjONyz2CCJ3E5mYjc+goXtHVm68+09hAhV+h90MYZxbkgjjXUM5rNFf4cFZ4PreKCsD0MEuedgFw5P6W1FmcBi2z7cJ260zhAQp1kvSzpvZshnoj6nMW4WhiyUjtuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:39 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:39 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 06/14] staging: media: starfive: Separate buffer be a common file Date: Tue, 9 Jul 2024 01:38:16 -0700 Message-Id: <20240709083824.430473-7-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: c87b0b65-25b6-47d9-6ca2-08dc9ff287d9 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: LDZyCArPa+aOzBKAxlQP6MW6Av0Q28tjnsE4zQ0Vq8tlZ8Hf4yWhBWCrSN8YaSzAb9H9xfTVzUYWejTXRH4uF02WYCLVSKJup8UeZZUfq7TGnqWsTDqYQYdPZy8nyUAfg4FJNqpSnFuYmUp7e3hR+4AqNgkaTahyvrLi8i3JpDkzqAehQtNPcdD+yEECwfoFlVsCqebJZqHUh/QBllmCUb/QGJqPUDvLXNigS4RcLQmRRLWwqpLos4Eq2LUoPx3dpxbCUAab/qkm3uL7OK2gWFTeEAzBcyIqS0Kx5hV0ORVTG3INI/B8Cg5RHJQH3DfPfjBZ+ghmMzelJSTVdueJroQJ75VchZSfRxPShfLAsvn2sELcP5u82Dx2+OeoF2zY5QXH2D//OeB8FpzmnxiP3satnZ4khdD1uWF3SERfdQ/u946BiEMEdW8hPvv0b4/ud+dj9r8RtGi68eYrOk/Tm0ll6j56UJcxdIQr49A38ZZnxN5MGggjuyYLEl2iojunWFgFXLrCtr+lqTsa9dAwojinCXrZKAS3yf4irDEgyue7qpy4zOzdhDsQrHWS6yQVDqIXY2PpBYhP2PPVBi/nW0HOUxfGZf7pSt0+TRmVAWiQPE77mZgT0Ib6PSVL967w X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Qt+v+16THAsAyg76bXuFiijqyMMXN4lKV53teR8hu/MaqH7Qx0eS/aaNWJLRilpsJ0SgD9aIiDFI6Z8MPriCSM8T5PT9nQyPkjNRei2p5hZUlVfXM0QEpF7fLkUg5rEEn4tQw9uxkrAeKOa1DsnTnvUrIavn/2uA9AwWUxwtmvvXE72CJyhpNMatSHDSp9EQLmjBofqdwc8qgE8UMtvrSp54bILdrKZkLpPob9CxdL8HYqCy0/RhuOLirpel0HJzcTVWx+V7BqrEBj7T+pk3UVC+l6W6OnSefpU1HIKzd5maGyFfKNSuk0cshBvTaMtn8Q37gYILcqH8d7H8emPzr/blc4ZrPQLhdHSM1Vr7qWdQUhsQW9LZ0USMbB5vPdCoYBN4LtR1qKqv5+q7YJoM6aeCrk5O22QoWAF5nTIC3j/6WKF4XXGbxuJWoV0dj4522zUXoDVu9R9syAi46fVMPAOUy+ZZJD/J1zb9XvF2n3oSRiHWfnO2/NYvbms8RZyh8byrAPUtA7adbhz+IwiiuGImdvSzGYDXBbCOuvgIc/N3QH/mOs8aaJ783iJFtXPzFvKolnlDA8/ImP4Fl+3zDamGyza15IHCNhOnsd2UpwqrAKrio/eBawmRs+m2Ziq7T+SknuW389rcgGkbICrO0+tx3HBc3Tj+VC/hqghA27hRPxneBwUkjrwjrSjje9TOxc3z8xgxrhpAQyiCRle3Z4dyhOMFW+2zHBv3/uNJCQbrzRW+kvc578t175UlJ4OTx51qRT7M9MFf5GSmqkyeW+Hsogm3LiJzPkGxV2clliGdPKkxVbIBCJiLKpmcgwH9j+AU51hQdOatfwX6wOoZ6Ad1mfnOnlim23lY0JpYbumzEFNwsIfJaQNhFGRCp2dt7ZwOUVNLuFXfspo86WcgUH/qDTwJEyTZ8qnvm5nBHF5ydye4raO1v8UnprPlewKg1B1DXwaStGzKofDBpjfhHKmXEoUvTHDCZCTaZ63pwZasQthsnVlztAdxwWOHfFhBZbwOPPPgp3iWvef3WKDdVZxrWUO4IzwWQm+v2x35DUvdlhjgv75bdeLOq/Z7GdLqC5Qo91rNqx13h0ESB3frjRtmrRTF4WQXcr4xaN2bAY7Xptlm3Pc/Um0TRq6QvuS44CKt8XqvACTqL5myYuI+o6qaAQJxIUvffJQxWp3DQjWEdx6YC6parFT26GmIdaqHwXFcgVrbTdTS6RfgBep1VY4jYbg23ECgLBqf7A44NcTH4FIpMZyb7NcbYQXsCsCIGeAuwnqEzQweetMHU9sWrmawP2m1T+adD+bwlN08Xkk39JpxJWZCdiAQWg0ZyNKUnUm6ngrxAwboDdsDlJHd34egT8W874V/sxa7QnPQGmSlO0rPf/tQsQbdt6AALZKALRg2NrLMlNbWEm9BiModsAbrQVY6GYlmVXV0vH1ScicGXeJbjfwfaIt01NUOhLkY/S9fdSu0K1qEQX2F4TSrx6g4cgkspErsWZgHsn2x4MYsJR88zSDH1DFo6Qb4pI9lpKrnLPbG2dSYKin2Z1812U3OdkXlrK+9mdtQTelbWEf6KtiqpW29hZa4SXjPDoxSKnncz7k3oyct72JlkJJGCIpXncW8kxhPc6400eUCO6g= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: c87b0b65-25b6-47d9-6ca2-08dc9ff287d9 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:39.1966 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DCr4y8PQuQIOMPLzVciqo5Yyk7/ypL0hv1gxgLHtmKG86aqsJA9VERVeMIU5HHVWAxHxf6/n1YeIspnDiHeUjnXoC5Lz4F5lhGgnFifrnCtruy/JfDVmITT/izWdOp0p X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 Buffer operations is not only applicable to capture device, also can use for output device. So separating it be a common file. Signed-off-by: Changhuang Liang --- drivers/staging/media/starfive/camss/Makefile | 1 + .../staging/media/starfive/camss/stf-buffer.c | 166 ++++++++++++++++++ .../staging/media/starfive/camss/stf-buffer.h | 52 ++++++ .../staging/media/starfive/camss/stf-camss.h | 1 + .../media/starfive/camss/stf-capture.c | 158 ----------------- .../media/starfive/camss/stf-capture.h | 22 --- .../staging/media/starfive/camss/stf-video.h | 10 +- 7 files changed, 222 insertions(+), 188 deletions(-) create mode 100644 drivers/staging/media/starfive/camss/stf-buffer.c create mode 100644 drivers/staging/media/starfive/camss/stf-buffer.h diff --git a/drivers/staging/media/starfive/camss/Makefile b/drivers/staging/media/starfive/camss/Makefile index 005790202e7b..411b45f3fb52 100644 --- a/drivers/staging/media/starfive/camss/Makefile +++ b/drivers/staging/media/starfive/camss/Makefile @@ -4,6 +4,7 @@ # starfive-camss-objs += \ + stf-buffer.o \ stf-camss.o \ stf-capture.o \ stf-isp.o \ diff --git a/drivers/staging/media/starfive/camss/stf-buffer.c b/drivers/staging/media/starfive/camss/stf-buffer.c new file mode 100644 index 000000000000..7272b5ab9eb5 --- /dev/null +++ b/drivers/staging/media/starfive/camss/stf-buffer.c @@ -0,0 +1,166 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * StarFive Camera Subsystem - buffer common + * + * Copyright (C) 2023 StarFive Technology Co., Ltd. + */ + +#include "stf-camss.h" + +void stf_buf_add_pending(struct stf_v_buf *output, + struct stfcamss_buffer *buffer) +{ + INIT_LIST_HEAD(&buffer->queue); + list_add_tail(&buffer->queue, &output->pending_bufs); +} + +struct stfcamss_buffer *stf_buf_get_pending(struct stf_v_buf *output) +{ + struct stfcamss_buffer *buffer = NULL; + + if (!list_empty(&output->pending_bufs)) { + buffer = list_first_entry(&output->pending_bufs, + struct stfcamss_buffer, + queue); + list_del(&buffer->queue); + } + + return buffer; +} + +void stf_buf_add_ready(struct stf_v_buf *output, + struct stfcamss_buffer *buffer) +{ + INIT_LIST_HEAD(&buffer->queue); + list_add_tail(&buffer->queue, &output->ready_bufs); +} + +struct stfcamss_buffer *stf_buf_get_ready(struct stf_v_buf *output) +{ + struct stfcamss_buffer *buffer = NULL; + + if (!list_empty(&output->ready_bufs)) { + buffer = list_first_entry(&output->ready_bufs, + struct stfcamss_buffer, + queue); + list_del(&buffer->queue); + } + + return buffer; +} + +static void stf_buf_update_on_last(struct stf_v_buf *output) +{ + switch (output->state) { + case STF_OUTPUT_CONTINUOUS: + output->state = STF_OUTPUT_SINGLE; + output->active_buf = !output->active_buf; + break; + case STF_OUTPUT_SINGLE: + output->state = STF_OUTPUT_STOPPING; + break; + default: + break; + } +} + +static void stf_buf_update_on_next(struct stf_v_buf *output) +{ + switch (output->state) { + case STF_OUTPUT_CONTINUOUS: + output->active_buf = !output->active_buf; + break; + case STF_OUTPUT_SINGLE: + default: + break; + } +} + +void stf_buf_flush(struct stf_v_buf *output, enum vb2_buffer_state state) +{ + struct stfcamss_buffer *buf; + struct stfcamss_buffer *t; + + list_for_each_entry_safe(buf, t, &output->pending_bufs, queue) { + vb2_buffer_done(&buf->vb.vb2_buf, state); + list_del(&buf->queue); + } + list_for_each_entry_safe(buf, t, &output->ready_bufs, queue) { + vb2_buffer_done(&buf->vb.vb2_buf, state); + list_del(&buf->queue); + } +} + +struct stfcamss_buffer *stf_change_buffer(struct stf_v_buf *output) +{ + struct stf_capture *cap = container_of(output, struct stf_capture, + buffers); + struct stfcamss *stfcamss = cap->video.stfcamss; + struct stfcamss_buffer *ready_buf; + unsigned long flags; + u32 active_index; + + if (output->state == STF_OUTPUT_OFF || + output->state == STF_OUTPUT_STOPPING || + output->state == STF_OUTPUT_RESERVED || + output->state == STF_OUTPUT_IDLE) + return NULL; + + spin_lock_irqsave(&output->lock, flags); + + active_index = output->active_buf; + + ready_buf = output->buf[active_index]; + if (!ready_buf) { + dev_dbg(stfcamss->dev, "missing ready buf %d %d.\n", + active_index, output->state); + active_index = !active_index; + ready_buf = output->buf[active_index]; + if (!ready_buf) { + dev_dbg(stfcamss->dev, + "missing ready buf2 %d %d.\n", + active_index, output->state); + goto out_unlock; + } + } + + /* Get next buffer */ + output->buf[active_index] = stf_buf_get_pending(output); + if (!output->buf[active_index]) + stf_buf_update_on_last(output); + else + stf_buf_update_on_next(output); + + if (output->state == STF_OUTPUT_STOPPING) + output->last_buffer = ready_buf; + else + stf_buf_add_ready(output, ready_buf); + +out_unlock: + spin_unlock_irqrestore(&output->lock, flags); + + return output->buf[active_index]; +} + +struct stfcamss_buffer *stf_buf_done(struct stf_v_buf *output) +{ + struct stfcamss_buffer *ready_buf; + u64 ts = ktime_get_ns(); + unsigned long flags; + + if (output->state == STF_OUTPUT_OFF || + output->state == STF_OUTPUT_RESERVED) + return NULL; + + spin_lock_irqsave(&output->lock, flags); + + ready_buf = stf_buf_get_ready(output); + if (ready_buf) { + ready_buf->vb.vb2_buf.timestamp = ts; + ready_buf->vb.sequence = output->sequence++; + } + + spin_unlock_irqrestore(&output->lock, flags); + + return ready_buf; +} diff --git a/drivers/staging/media/starfive/camss/stf-buffer.h b/drivers/staging/media/starfive/camss/stf-buffer.h new file mode 100644 index 000000000000..9d1670fb05ed --- /dev/null +++ b/drivers/staging/media/starfive/camss/stf-buffer.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * StarFive Camera Subsystem - buffer common + * + * Copyright (C) 2023 StarFive Technology Co., Ltd. + */ + +#ifndef STF_BUFFER_H +#define STF_BUFFER_H + +#include +#include + +enum stf_v_state { + STF_OUTPUT_OFF, + STF_OUTPUT_RESERVED, + STF_OUTPUT_SINGLE, + STF_OUTPUT_CONTINUOUS, + STF_OUTPUT_IDLE, + STF_OUTPUT_STOPPING +}; + +struct stfcamss_buffer { + struct vb2_v4l2_buffer vb; + dma_addr_t addr[2]; + struct list_head queue; +}; + +struct stf_v_buf { + int active_buf; + struct stfcamss_buffer *buf[2]; + struct stfcamss_buffer *last_buffer; + struct list_head pending_bufs; + struct list_head ready_bufs; + enum stf_v_state state; + unsigned int sequence; + /* protects the above member variables */ + spinlock_t lock; + atomic_t frame_skip; +}; + +void stf_buf_add_pending(struct stf_v_buf *output, + struct stfcamss_buffer *buffer); +struct stfcamss_buffer *stf_buf_get_pending(struct stf_v_buf *output); +void stf_buf_add_ready(struct stf_v_buf *output, + struct stfcamss_buffer *buffer); +struct stfcamss_buffer *stf_buf_get_ready(struct stf_v_buf *output); +void stf_buf_flush(struct stf_v_buf *output, enum vb2_buffer_state state); +struct stfcamss_buffer *stf_change_buffer(struct stf_v_buf *output); +struct stfcamss_buffer *stf_buf_done(struct stf_v_buf *output); + +#endif /* STF_BUFFER_H */ diff --git a/drivers/staging/media/starfive/camss/stf-camss.h b/drivers/staging/media/starfive/camss/stf-camss.h index e2b0cfb437bd..ae49c7031ab7 100644 --- a/drivers/staging/media/starfive/camss/stf-camss.h +++ b/drivers/staging/media/starfive/camss/stf-camss.h @@ -18,6 +18,7 @@ #include #include +#include "stf-buffer.h" #include "stf-isp.h" #include "stf-capture.h" diff --git a/drivers/staging/media/starfive/camss/stf-capture.c b/drivers/staging/media/starfive/camss/stf-capture.c index 494e56e731f0..696d79920713 100644 --- a/drivers/staging/media/starfive/camss/stf-capture.c +++ b/drivers/staging/media/starfive/camss/stf-capture.c @@ -93,20 +93,6 @@ static void stf_init_addrs(struct stfcamss_video *video) stf_set_yuv_addr(video->stfcamss, addr0, addr1); } -static struct stfcamss_buffer *stf_buf_get_pending(struct stf_v_buf *output) -{ - struct stfcamss_buffer *buffer = NULL; - - if (!list_empty(&output->pending_bufs)) { - buffer = list_first_entry(&output->pending_bufs, - struct stfcamss_buffer, - queue); - list_del(&buffer->queue); - } - - return buffer; -} - static void stf_cap_s_cfg(struct stfcamss_video *video) { struct stf_capture *cap = to_stf_capture(video); @@ -263,61 +249,6 @@ static void stf_capture_init(struct stfcamss *stfcamss, struct stf_capture *cap) } } -static void stf_buf_add_ready(struct stf_v_buf *output, - struct stfcamss_buffer *buffer) -{ - INIT_LIST_HEAD(&buffer->queue); - list_add_tail(&buffer->queue, &output->ready_bufs); -} - -static struct stfcamss_buffer *stf_buf_get_ready(struct stf_v_buf *output) -{ - struct stfcamss_buffer *buffer = NULL; - - if (!list_empty(&output->ready_bufs)) { - buffer = list_first_entry(&output->ready_bufs, - struct stfcamss_buffer, - queue); - list_del(&buffer->queue); - } - - return buffer; -} - -static void stf_buf_add_pending(struct stf_v_buf *output, - struct stfcamss_buffer *buffer) -{ - INIT_LIST_HEAD(&buffer->queue); - list_add_tail(&buffer->queue, &output->pending_bufs); -} - -static void stf_buf_update_on_last(struct stf_v_buf *output) -{ - switch (output->state) { - case STF_OUTPUT_CONTINUOUS: - output->state = STF_OUTPUT_SINGLE; - output->active_buf = !output->active_buf; - break; - case STF_OUTPUT_SINGLE: - output->state = STF_OUTPUT_STOPPING; - break; - default: - break; - } -} - -static void stf_buf_update_on_next(struct stf_v_buf *output) -{ - switch (output->state) { - case STF_OUTPUT_CONTINUOUS: - output->active_buf = !output->active_buf; - break; - case STF_OUTPUT_SINGLE: - default: - break; - } -} - static void stf_buf_update_on_new(struct stfcamss_video *video, struct stfcamss_buffer *new_buf) { @@ -353,95 +284,6 @@ static void stf_buf_update_on_new(struct stfcamss_video *video, } } -static void stf_buf_flush(struct stf_v_buf *output, enum vb2_buffer_state state) -{ - struct stfcamss_buffer *buf; - struct stfcamss_buffer *t; - - list_for_each_entry_safe(buf, t, &output->pending_bufs, queue) { - vb2_buffer_done(&buf->vb.vb2_buf, state); - list_del(&buf->queue); - } - list_for_each_entry_safe(buf, t, &output->ready_bufs, queue) { - vb2_buffer_done(&buf->vb.vb2_buf, state); - list_del(&buf->queue); - } -} - -static struct stfcamss_buffer *stf_buf_done(struct stf_v_buf *output) -{ - struct stfcamss_buffer *ready_buf; - u64 ts = ktime_get_ns(); - unsigned long flags; - - if (output->state == STF_OUTPUT_OFF || - output->state == STF_OUTPUT_RESERVED) - return NULL; - - spin_lock_irqsave(&output->lock, flags); - - ready_buf = stf_buf_get_ready(output); - if (ready_buf) { - ready_buf->vb.vb2_buf.timestamp = ts; - ready_buf->vb.sequence = output->sequence++; - } - - spin_unlock_irqrestore(&output->lock, flags); - - return ready_buf; -} - -static struct stfcamss_buffer *stf_change_buffer(struct stf_v_buf *output) -{ - struct stf_capture *cap = container_of(output, struct stf_capture, - buffers); - struct stfcamss *stfcamss = cap->video.stfcamss; - struct stfcamss_buffer *ready_buf; - unsigned long flags; - u32 active_index; - - if (output->state == STF_OUTPUT_OFF || - output->state == STF_OUTPUT_STOPPING || - output->state == STF_OUTPUT_RESERVED || - output->state == STF_OUTPUT_IDLE) - return NULL; - - spin_lock_irqsave(&output->lock, flags); - - active_index = output->active_buf; - - ready_buf = output->buf[active_index]; - if (!ready_buf) { - dev_dbg(stfcamss->dev, "missing ready buf %d %d.\n", - active_index, output->state); - active_index = !active_index; - ready_buf = output->buf[active_index]; - if (!ready_buf) { - dev_dbg(stfcamss->dev, - "missing ready buf2 %d %d.\n", - active_index, output->state); - goto out_unlock; - } - } - - /* Get next buffer */ - output->buf[active_index] = stf_buf_get_pending(output); - if (!output->buf[active_index]) - stf_buf_update_on_last(output); - else - stf_buf_update_on_next(output); - - if (output->state == STF_OUTPUT_STOPPING) - output->last_buffer = ready_buf; - else - stf_buf_add_ready(output, ready_buf); - -out_unlock: - spin_unlock_irqrestore(&output->lock, flags); - - return output->buf[active_index]; -} - irqreturn_t stf_wr_irq_handler(int irq, void *priv) { struct stfcamss *stfcamss = priv; diff --git a/drivers/staging/media/starfive/camss/stf-capture.h b/drivers/staging/media/starfive/camss/stf-capture.h index 2f9740b7e500..fe2489d55090 100644 --- a/drivers/staging/media/starfive/camss/stf-capture.h +++ b/drivers/staging/media/starfive/camss/stf-capture.h @@ -48,28 +48,6 @@ #define U0_VIN_P_I_MIPI_HAEDER_EN0_MASK BIT(12) #define U0_VIN_PIX_NUM_MASK GENMASK(16, 13) -enum stf_v_state { - STF_OUTPUT_OFF, - STF_OUTPUT_RESERVED, - STF_OUTPUT_SINGLE, - STF_OUTPUT_CONTINUOUS, - STF_OUTPUT_IDLE, - STF_OUTPUT_STOPPING -}; - -struct stf_v_buf { - int active_buf; - struct stfcamss_buffer *buf[2]; - struct stfcamss_buffer *last_buffer; - struct list_head pending_bufs; - struct list_head ready_bufs; - enum stf_v_state state; - unsigned int sequence; - /* protects the above member variables */ - spinlock_t lock; - atomic_t frame_skip; -}; - struct stf_capture { struct stfcamss_video video; struct stf_v_buf buffers; diff --git a/drivers/staging/media/starfive/camss/stf-video.h b/drivers/staging/media/starfive/camss/stf-video.h index 8052b77e3ad8..59799b65cbe5 100644 --- a/drivers/staging/media/starfive/camss/stf-video.h +++ b/drivers/staging/media/starfive/camss/stf-video.h @@ -10,13 +10,13 @@ #ifndef STF_VIDEO_H #define STF_VIDEO_H -#include #include #include #include #include #include -#include + +#include "stf-buffer.h" #define STFCAMSS_FRAME_MIN_WIDTH 64 #define STFCAMSS_FRAME_MAX_WIDTH 1920 @@ -40,12 +40,6 @@ enum stf_capture_type { STF_CAPTURE_NUM, }; -struct stfcamss_buffer { - struct vb2_v4l2_buffer vb; - dma_addr_t addr[2]; - struct list_head queue; -}; - struct fract { u8 numerator; u8 denominator; From patchwork Tue Jul 9 08:38:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727438 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2111.outbound.protection.partner.outlook.cn [139.219.146.111]) (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 C774F12C481; Tue, 9 Jul 2024 08:39:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514397; cv=fail; b=hcs+JBMwnP2dpZe+5cwww5JL93EE9Tm7phr1V068HH9yQz6sekKdjJnr+qa8AnDCgErdZvlj3ejyLTzZxryTSUKfUJsd+g8anLqOXoyy0xpWDDiFzdrlF5O8IlvGv3Q4tCQBZ0vjMOhgyd9h8VtVSNeELh3dGpdMWZxksJrN250= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514397; c=relaxed/simple; bh=+SiXIlS9xRgB9Uk+id65QRQQdN+77i/KJd0PUD00/po=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Ey913yDaGDRQ0p74oN/P9ryVge8nTQFrT1BRHyGclSXAWqlbnAikasewl0tgsiNmODKgQ0Upq8LjIlg/cRj/cwp8Ka3lT5lVBZ+qtS5s6DdvgImaU6JwSltcIbFwpV1U858WYoS033uJclyAt/AcjxS2pEYjWgNtkwd1nC2WsS4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=noKlIMq/mkW7K59zaVmUpg6NuBcST31y9AhUQonKFYdJyrQJvl7+ZKJCH6qVSmcR0f20OZxCZPGINtRhtHLAtgePWLEInV3rvu5xEO17sSHoBc6f8O26rKqsmq1miq57YeKEZDcuB7yH2BFXdJ6q/NwPGQRXfQkLYxT3b2ZS0Sm4AZf0yJqyZhkFhs+0zzRva4nSTc9APuVwtLhMy6ofLnMh0FqwdMFCZYn6BD/a3iisc+P8g4lV3gQ8U5mBdptitagoFIOtBP5py+YtBcwK5HuygcmH45ATukrdJW1UyVtQ0b3dnbCXCO5ltHLaOm2nFAKDi99LC544K4YPHH3rdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IpNDGY9Z69KwGD7XfHtTW7NF/LKZHWPGrDb6RfSKDWM=; b=DgnXnjfBFS3JwrLccme1eZm2rrepRMqoVl8uYnCiKdODICiol1jfSe1hV1pk/lAz8jHi2+95HgWCGADGoep6KhjLMPFgIAXQ0m5IBhX5eIAT+E8lilxI/m+331CKwfLVgJ2MDKq96NusaCONxMmXg2wY6+9fwApyR68p7J/rqnxppAZL/t7dLLsufvP6RVSf5hA4nyGGfjhPgq0KoEcRLuiN1cUuSOywdM58qXnotWlhbffnSUZ9EgQ5yq9Jsgw/37a9XU0IAt2Q10IMPRX0mbJpCjH2UwoztDNgZs6qL1phC2xYTlfUPJ3ALOl6gQioXqRI72/shTEj0OQnofFoTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:40 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:40 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 07/14] staging: media: starfive: Separate ISP hardware from capture device Date: Tue, 9 Jul 2024 01:38:17 -0700 Message-Id: <20240709083824.430473-8-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f43d708-b2ac-4d77-f33a-08dc9ff28896 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: RCVKTpWi+KW/w9jMwth9c4mTBzogbErcY6ZA9BXT6oLUnm20OS8h9h+zfX3MyE6WA0rmb94CsM2GPPGQO1PLm01cFuVWGpdqhx1ZiyznrnFex/1GrNf8sGC0c7DlRI7mjGqWGFHhDNwR3MHz6vexcQVZnUxkZm0MD7998+FALHXZo3k/B6wnIA312016I3QNwKfj4rEjRCpoqn6/cob8WvWPcvWrfFYEGCrsK/yZW2MpQau+f98V+UTypw+SLdqwncV8zLidQ4WPV22trsNN6GAqfLUqmwAvlQ72aV0zUdT2SfetwtPNBTCCTcP1ZxygOrl2BYucZ6z/PiPbdnycnGWU9cvIGGtjfC3FPzCpwMHhxJnVjk4kVi96ZtZmSGrypLWtCdafUIgys/gjcsLGNECi6dgQo7KilOvez3wKWKndmUA/4ovWstntHnNeqV3mpZalednqTfBhv9vm7OsKmNQRqwViwKq20nkleGnL2vxrKQ1r0T6TnZnFJjg6goMuUrx7cyhkzAnCxMSh6MUNMF/DImxRjl4qOFB0Z1NGYYMI6I9jApYHxG8efRfMeV+8uEmlIKVqQkJCF139IiFLA4rtn3/VNSqm8Z47rJqV9EufI4gLv9151ZTBouQuIjMl X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: l6E1Gca6BcZChFlrGbhSrmTmPJmrDROg6UpSlafmrABkuEJdXJoDj39TBH8jNnipnL4AQgwmPHrv0MXUOAN0e2AL5lBYxEX/haQpNp9hddkyDr8+dODJOqQDeAGReZFIMrZO3d4ARUpg40l8CTEiEmW927aE+PXGt7t9kK/5Dc71jJlv22eYESLepMaFDiSiDPg91SAzbN9XVqeuztOgyuKiOnqncxICL7GZAJ7bzzfNt9xk3eoe8gZJ3/Nkzh4rKwJ83mTIfKR78oCZGpuzUJ+JD5hNomESnMdb/W7kPHrzUrw1BHP4JAbNGJn0AmJDafk9tt3YR5971+jcq2sY1NiGoNzEO5uWWcVmMoWjkl2PibB9Mx/6YXHqJen/kpYyoobonboWgMxMgVehXYBBlyzgGXz0vvCmXVKk4J+1APRaE3FCgMFPvEOjFOg8qRGKfgVdh90MslyK2ID2p/AjUIfuje0ZhoMjsc3BJe2RvUY1GlX+WPF0KLpj67HSe4T+SxENtKPpb7/qO53GBpDpuSgpp7nDh9K8aW7UcaybXr+2ij++aA+5XynaiiScT2bphIqIEq5fBepDH/j34i+ZNOczyewLnBSiuVPqNXCHwPG33KLZ8UyyCge59SIroUsivJHsXq/ZYSJgdBUkO6UOlzz0S5ad4Uj+56gtHNYQqdpxZKJRa6Nmk6OacOj/+5BISABLw8ZnNDTjdcUAnfPuS0mqmO2Pq6fEaDd1o+3vPu2IvwjzlFNn1q/tRw8wjQSd+MtF8d58hJ64FwZnfpg4o0l1m4qY9JHW9JnI27CuQoaK2aQh4Yg/jjSA9JQSoTLfgHlWqPfkfMN3kJPD1xvFEHnwz0B1xmtQYB+LpeLtM+sPYYSd2OUWKllluFqG7PHuELvw2UbSwMumg6uSj4zRDJkWkcVgZEb1Lkmleu5JPPX5/XLXpiT2JuYzLYwBJhIeh9URZ9pCyYtdcYlW6mZjSVVPKXkkG6N20+Sy2Zp3oTLYJ4eZZwCSXWeJBd0qmoGzUyhRn8Y4RiPrrFQTIzpZXMxY0wlm0slFkSBIdI+lg0L5577UNydVsIpl0/Hh+e55sxuniXcJX9Dojxijjm2MQgCRvnFVh0VFjg3hF/AmJHzrolWee939WQOM6Jm+4ysfyixtag8UkyJspV5EqZFRnAmEZjC7OZKlIMgv5Sbv5ugiwg7yE8jWScEzrS7Y2moX9L/w0zZOVqhI2z2Ia7Y7XqNsTBA/Rxpj2ypelgJmSOp2/B4fxEJX+ufKPaHgSXQHstCPp7XfHX0GmbcfOL0ZoMT0AfcAM392kaFvi6srw7B+ftD0Fmts1YHAbnkhX+e/Ep3IotwRBz1SQd88xae2kpWlhHSNoUAbmBXxrq0L+fdWVg3p2JRgQ4s7z4tcKkZQB+U4anLMq0EycXd4xM7jdVSc8Dlbx0GRq2ufyUgws02jYWCJ/juqQUzuqeY3AtPdIlDG9wxGYEYRPH+lDZnzs8BJ7a62kGAKPDCmlpa9jY9QIQZgTE10fW8FRkm0BwEhUwBPVZ0bjsXRZz2Ra11jcV/sPwQOe2ZzY2TvQeBWQK2V9fCrG2zead5SJEAZGFDeSbBJUaujboTvxF37bJ/5NSVsEEn0rM6BdObv+gV4HLY= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f43d708-b2ac-4d77-f33a-08dc9ff28896 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:40.3633 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vK+3cnyHMDMQDkB1/sKfHzTEY+wXyfZR+VIG2QsG3THb3f+S9bl19ZaYrCiNptSLS4OfaWOr1P3nRSOjSVBzUX2fFDF2xV2LcOWRYmvnA+sMuK57Lz0Dn9+lH1NBtBgo X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 Some ISP hardware operations also used for output device, so separate them from capture device, move them to ISP common file. Signed-off-by: Changhuang Liang --- .../media/starfive/camss/stf-capture.c | 60 ------------------- .../media/starfive/camss/stf-isp-hw-ops.c | 60 +++++++++++++++++++ .../staging/media/starfive/camss/stf-isp.h | 3 + 3 files changed, 63 insertions(+), 60 deletions(-) diff --git a/drivers/staging/media/starfive/camss/stf-capture.c b/drivers/staging/media/starfive/camss/stf-capture.c index 696d79920713..75f6ef405e61 100644 --- a/drivers/staging/media/starfive/camss/stf-capture.c +++ b/drivers/staging/media/starfive/camss/stf-capture.c @@ -66,13 +66,6 @@ static void stf_set_raw_addr(struct stfcamss *stfcamss, dma_addr_t addr) stf_syscon_reg_write(stfcamss, VIN_START_ADDR_N, (long)addr); } -static void stf_set_yuv_addr(struct stfcamss *stfcamss, - dma_addr_t y_addr, dma_addr_t uv_addr) -{ - stf_isp_reg_write(stfcamss, ISP_REG_Y_PLANE_START_ADDR, y_addr); - stf_isp_reg_write(stfcamss, ISP_REG_UV_PLANE_START_ADDR, uv_addr); -} - static void stf_init_addrs(struct stfcamss_video *video) { struct stf_capture *cap = to_stf_capture(video); @@ -307,59 +300,6 @@ irqreturn_t stf_wr_irq_handler(int irq, void *priv) return IRQ_HANDLED; } -irqreturn_t stf_isp_irq_handler(int irq, void *priv) -{ - struct stfcamss *stfcamss = priv; - struct stf_capture *cap = &stfcamss->captures[STF_CAPTURE_YUV]; - struct stfcamss_buffer *ready_buf; - u32 status; - - status = stf_isp_reg_read(stfcamss, ISP_REG_ISP_CTRL_0); - if (status & ISPC_ISP) { - if (status & ISPC_ENUO) { - ready_buf = stf_buf_done(&cap->buffers); - if (ready_buf) - vb2_buffer_done(&ready_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); - } - - stf_isp_reg_write(stfcamss, ISP_REG_ISP_CTRL_0, - (status & ~ISPC_INT_ALL_MASK) | - ISPC_ISP | ISPC_CSI | ISPC_SC); - } - - return IRQ_HANDLED; -} - -irqreturn_t stf_line_irq_handler(int irq, void *priv) -{ - struct stfcamss *stfcamss = priv; - struct stf_capture *cap = &stfcamss->captures[STF_CAPTURE_YUV]; - struct stfcamss_buffer *change_buf; - u32 status; - - status = stf_isp_reg_read(stfcamss, ISP_REG_ISP_CTRL_0); - if (status & ISPC_LINE) { - if (atomic_dec_if_positive(&cap->buffers.frame_skip) < 0) { - if ((status & ISPC_ENUO)) { - change_buf = stf_change_buffer(&cap->buffers); - if (change_buf) - stf_set_yuv_addr(stfcamss, change_buf->addr[0], - change_buf->addr[1]); - } - } - - stf_isp_reg_set_bit(stfcamss, ISP_REG_CSIINTS, - CSI_INTS_MASK, CSI_INTS(0x3)); - stf_isp_reg_set_bit(stfcamss, ISP_REG_IESHD, - SHAD_UP_M | SHAD_UP_EN, 0x3); - - stf_isp_reg_write(stfcamss, ISP_REG_ISP_CTRL_0, - (status & ~ISPC_INT_ALL_MASK) | ISPC_LINE); - } - - return IRQ_HANDLED; -} - static int stf_queue_buffer(struct stfcamss_video *video, struct stfcamss_buffer *buf) { diff --git a/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c b/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c index c34631ff9422..6b3966ca18bf 100644 --- a/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c +++ b/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c @@ -443,3 +443,63 @@ void stf_isp_stream_set(struct stf_isp_dev *isp_dev) stf_isp_reg_write_delay(stfcamss, ISP_REG_CSI_INPUT_EN_AND_STATUS, CSI_EN_S, 10); } + +void stf_set_yuv_addr(struct stfcamss *stfcamss, + dma_addr_t y_addr, dma_addr_t uv_addr) +{ + stf_isp_reg_write(stfcamss, ISP_REG_Y_PLANE_START_ADDR, y_addr); + stf_isp_reg_write(stfcamss, ISP_REG_UV_PLANE_START_ADDR, uv_addr); +} + +irqreturn_t stf_line_irq_handler(int irq, void *priv) +{ + struct stfcamss *stfcamss = priv; + struct stf_capture *cap = &stfcamss->captures[STF_CAPTURE_YUV]; + struct stfcamss_buffer *change_buf; + u32 status; + + status = stf_isp_reg_read(stfcamss, ISP_REG_ISP_CTRL_0); + if (status & ISPC_LINE) { + if (atomic_dec_if_positive(&cap->buffers.frame_skip) < 0) { + if ((status & ISPC_ENUO)) { + change_buf = stf_change_buffer(&cap->buffers); + if (change_buf) + stf_set_yuv_addr(stfcamss, change_buf->addr[0], + change_buf->addr[1]); + } + } + + stf_isp_reg_set_bit(stfcamss, ISP_REG_CSIINTS, + CSI_INTS_MASK, CSI_INTS(0x3)); + stf_isp_reg_set_bit(stfcamss, ISP_REG_IESHD, + SHAD_UP_M | SHAD_UP_EN, 0x3); + + stf_isp_reg_write(stfcamss, ISP_REG_ISP_CTRL_0, + (status & ~ISPC_INT_ALL_MASK) | ISPC_LINE); + } + + return IRQ_HANDLED; +} + +irqreturn_t stf_isp_irq_handler(int irq, void *priv) +{ + struct stfcamss *stfcamss = priv; + struct stf_capture *cap = &stfcamss->captures[STF_CAPTURE_YUV]; + struct stfcamss_buffer *ready_buf; + u32 status; + + status = stf_isp_reg_read(stfcamss, ISP_REG_ISP_CTRL_0); + if (status & ISPC_ISP) { + if (status & ISPC_ENUO) { + ready_buf = stf_buf_done(&cap->buffers); + if (ready_buf) + vb2_buffer_done(&ready_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + } + + stf_isp_reg_write(stfcamss, ISP_REG_ISP_CTRL_0, + (status & ~ISPC_INT_ALL_MASK) | + ISPC_ISP | ISPC_CSI | ISPC_SC); + } + + return IRQ_HANDLED; +} diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h index bc7e7b0736fa..fcda0502e3b0 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.h +++ b/drivers/staging/media/starfive/camss/stf-isp.h @@ -427,4 +427,7 @@ int stf_isp_init(struct stfcamss *stfcamss); int stf_isp_register(struct stf_isp_dev *isp_dev, struct v4l2_device *v4l2_dev); int stf_isp_unregister(struct stf_isp_dev *isp_dev); +void stf_set_yuv_addr(struct stfcamss *stfcamss, + dma_addr_t y_addr, dma_addr_t uv_addr); + #endif /* STF_ISP_H */ From patchwork Tue Jul 9 08:38:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727443 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2104.outbound.protection.partner.outlook.cn [139.219.146.104]) (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 AD16E155315; Tue, 9 Jul 2024 08:40:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.104 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514407; cv=fail; b=AhSTs/x6t/CnOV10D0k1uAdShD7qF63w8jsZNhO5d+uZ8hMezO2ZnmdIs+RE+U5oDgFy3kpVb9VIJocci1kYwWmuHFtWT3kh7AQjfVkVxcqTh1TC0a+QsQDG2vOfyPpSfu0JKnrhR3bkmK+3/LKVAvdgXruGXAt9JUiTeOii9xg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514407; c=relaxed/simple; bh=H6CNeJO1utspNcCPfP3iLjZyTMqraVNeYElpi3SWT4s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=egqR/b29eQOvrxV9n1cvw1k/0AFjLRnHd+bLxQ+UD9WiEmh+fe4QlStZWPcUjrZH4vYN22x9Eke+AuBrN5wLtL1jvzpev+aKPg/aNiXyozJzJ15TGPmHd8JHn7lEbRfe1+dmk9RG9/5k65PsyLBu+4GbSj51hGcgyCnQA7h3uEE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.104 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zu+sfLtuRMTSO9BnbPCN+srpS7lToZHmvZKQp1f3Q1AUYeDYGx77iWjkx4hIvnakarf38Wn6iyLoAJpJZ08EYjyNYHGk5YiYZi3e22TY+Bu4NlGPb3hwxkZleyY3gYNSGJEruxUEeRh7gGh9Tw67mIqLZXL/xFN1Kt8kC5tlAcdsmWs5NG293AxcKqLqJvKUmnLdk66XqsPhCFkwgTsKzXSK019vAhzZMBgjX1sflcRiXT/yr0gTdnn5odhW6SYU84qyOCpqup7A+0WZ5eHM7Fdns7ZtxnrKN2aoatxy05ph+k1weECISJq4rRElxsXbXlPmLDR+V/DPsHjVVUFLzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ca7iM1/02fuJY6GUPY1zS3PTuG6NKQuMjf210FAdnxY=; b=KmncWThHEPqQdshF0qSTYRTDDSL/nrJKNpnZ2PW2NHEyHPLo30O1vlSWRZC9GENiQwQHPkF62CYraIGg8cjYb8gAYq0DrSBRwMrpMHtV6wLveRHldE0q2mSo+ElITJ+jn3ID1/PZi7U0j4GJOdZhFrm4pWogCIqxAy0QHjLe019kPlA1EUBHxZdl0JraVAZbiHNnrtUeiDiwDXSW1HH7LBzKoKaaFs5ZrgwcizCGCCIA99kHACCbT8LNzjFZJQRdErwjWLI1Ox+sHONRIN5D+akTE1YwNX/mKAloS6aVm6iJrFJTaA1UmTAoIES24JVb2dZQBJJ42KHMOYH7ljSnYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:41 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:41 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 08/14] staging: media: starfive: Add for StarFive ISP 3A SC Date: Tue, 9 Jul 2024 01:38:18 -0700 Message-Id: <20240709083824.430473-9-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: 3405a2ea-91f8-4ab5-98a5-08dc9ff2894a X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: WFUA7Vkbn9EHL5F397Gm49QLK2jNGyRk6D6njB2yguc9vL4buFNN4rjZfuguNXMIUITIc6w7D8TbQVaPkrYlpjuqvoM5fr7OvLKw1fpM6yfFPpRgc+vkIw12P+k7kcyQgiqXYPemyT8sIHNZoYFO/P1bGfEFGLXUKA8xtjydFxsplyobc2RKFwihUrVMugCXzM7+spymy0FLfw9l++nj1/6sAUHH3wWKR1hvCKcrZHekbJYfLKvZAz0R1xmXWBt8EwrVv4lrj6OYXe3llWzF2l9eWr3FBxfzsEFEEAPLjTOyZUltNVtaKLqVev2qfmMS07V+RzIRgKuQU4QxVtbagkp4z/8NfY7YXh6k1bzV20xzVUewq+ZL5bS7IYgga8sRoxpYmHMn8ujim0ZCjmrik4TFLv6xxNHcRFwmBMZnL8UHaHoPSUY8nIjyThhkdG4azbGoADWYNHsILoaHyWAxv+RGbj7G1QK4Cdbarrwe1aGH5kir0Zt5fP64Og6SfBsf5vgkdr1WAop3ioZjo7nFZx+oq6dDkiEw8PTjdbLnnQ1IPn1Ocdz0IzBNNRh/U+kQHht6AeAYXFfnMNtGuDonLExSBl4+IMASKJR9XlWLj3HN7UOEzRFz0prbK393y3p/ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B/qYHpVo8ozkJEoTVxVPZJEEPMozXxuva3utfGHReEtLEZ2ZoLnIkbfgKUSlQjVDMu2CZRuoXeIO4Q7mGtkHGn1n92nDaUnshuK0QDtxnjJgl97sLd0m41d9UdMn8Vl56yg0/+2obXZmnbhrDXrHLlWwwaBkhxTuqn+qkz/uSVqLGxzoLG5gJL9G97Ada96ad0HOSn3L8JW53WyrcNuKSnK1IGuL1dwkZkCnAFYabeA/eP7zSw1krWO41MK9b0rvBIw+Y+lXDuzDkEu5BQe0JrslDg4xXTj5TqUdofy6QWFUDIfToRcjD6wFbrEF81VyK8lXev0cvcVm4nyYPRu9+mMPRBWoz+NDn2OK220fc1GHrdJ4cMAjp38/snlI3xhHD3YhPaWPODjdH0pCwsV6oRKyFIu+3uhUAlkc6bxrbUezEuHs6IL4iHHQWalAmI+f7BfV7XTGA7baTJuq2aPq5nstZVrDtY/pxUUfgzLqWcBUp3szvxRHMGXj5XTL5LsNMzxdERYREwotoO3RdybfcvyR6nv/88A+WNKmhntODg2EBOgSWumAnZtBwvsI1qltTKa93Wk89Wf8bLtkuL+EB7XIOpl94bg/veLJMFQGYrwWCLKqiqINu9YWWIyHtva9JCwhfamFEMdmuYWS15OFnOuzi1g5oqKluAZ0XHxRPrp0HiJR9p/6QWQBiA5WAPPN58TP7G9zH5hhrqc3hWFfAdb6/u6Yx4aaTucSEgS9qqtZPzCuRfkk54xqm4Srd+IEube+WeVb9SiJcJ9lvR/6wpv4ngfHiE8JwPH5a02d6MwC4e5nngqXQjKv8fJwYpjoq57jwKPtq38xmYUWrOxv8VDEHG7G1hMlu+cNHFI4ZwPXKCUbNZDmRRLWbrVSLXYtNMi+nYaG/Ynlf1kXLQRPX2lypBI7AQ8r2u/VVls26kq5/3xR5CDfSmebISAjUi+WucopjMSetZIzC9tSqR+GeKhM5r+6CC+J3FmpTW3tfy6uG9FPzm7STvXT6trJytUJpu17bfpj4G7TREZ8D9lFv7mTMUhCD8kX/TrXhASfMiM8bReu1miVeQhNxglAY8XIrEoT4JDQU2OBXYJyHoBAr3RYashKima++TLvJWOx9TtVicWijcbiTcDUFKmZNJDuIRhtSaJGtjJ79w9Ya74shfV46VCbz+5o46fE9ALziX6GXPsLfQP/4W++3AIev6pL3DBEyZdbwSEf857sVvta5Hf/nS6j2IgVVTjPNOnB+b3kiiCyB659MZVwnVe84r0E7lPalV1FBwwamnuoHRVoi3Sg+f2jEn4NWRZqKS/weyIYdasI2AOHIiREOWlcdEbI5LYbjAx1FyggtMwuWRr3SO1nJHIJR/wYxT7xWYLQIEcMNbnYqecV+YevNlaZBOJUYVoGY02Pyahz/+azCgEDIOQPgS3iMl/GvRAy0FMFOATFmkPIbFmPnh8i54647+by0PhMO1esRPNyeMyIkWF3ak1UPiTc4rE0/kQmiHa1rZ5t0fnXrcRLP6t+M9GA4xssmgq3efAH8tmq45IzLpFHBCbaXiUl6eUBEoJabutCcUzJGmyhDvbKmkGfQZNNzfMpKQFY+72BJ9eFUsjI2/1SIGp+LS9Uir+mO0+9sZ6NMoM= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3405a2ea-91f8-4ab5-98a5-08dc9ff2894a X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:41.5474 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GyJVTCTmivoIIei87PRS/aN/4sw7CcdyG6NuyE0E+QV0ntfqs5ok3RDoflmE1doJnJNyXSELL23khAdUKpPpSEaQkSfBhNUXGeeEFKHTyHDaJmRXTUTStutcqatu6mSQ X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 Register ISP 3A "capture_scd" video device to receive statistics collection data. Signed-off-by: Changhuang Liang --- .../staging/media/starfive/camss/stf-buffer.h | 1 + .../staging/media/starfive/camss/stf-camss.c | 15 ++ .../media/starfive/camss/stf-capture.c | 21 ++- .../media/starfive/camss/stf-isp-hw-ops.c | 66 ++++++++ .../staging/media/starfive/camss/stf-isp.h | 23 +++ .../staging/media/starfive/camss/stf-video.c | 146 +++++++++++++++++- .../staging/media/starfive/camss/stf-video.h | 1 + 7 files changed, 264 insertions(+), 9 deletions(-) diff --git a/drivers/staging/media/starfive/camss/stf-buffer.h b/drivers/staging/media/starfive/camss/stf-buffer.h index 9d1670fb05ed..727d00617448 100644 --- a/drivers/staging/media/starfive/camss/stf-buffer.h +++ b/drivers/staging/media/starfive/camss/stf-buffer.h @@ -23,6 +23,7 @@ enum stf_v_state { struct stfcamss_buffer { struct vb2_v4l2_buffer vb; dma_addr_t addr[2]; + void *vaddr; struct list_head queue; }; diff --git a/drivers/staging/media/starfive/camss/stf-camss.c b/drivers/staging/media/starfive/camss/stf-camss.c index fecd3e67c7a1..fafa3ce2f6da 100644 --- a/drivers/staging/media/starfive/camss/stf-camss.c +++ b/drivers/staging/media/starfive/camss/stf-camss.c @@ -8,6 +8,7 @@ * * Author: Jack Zhu * Author: Changhuang Liang + * Author: Keith Zhao * */ #include @@ -126,6 +127,7 @@ static int stfcamss_of_parse_ports(struct stfcamss *stfcamss) static int stfcamss_register_devs(struct stfcamss *stfcamss) { struct stf_capture *cap_yuv = &stfcamss->captures[STF_CAPTURE_YUV]; + struct stf_capture *cap_scd = &stfcamss->captures[STF_CAPTURE_SCD]; struct stf_isp_dev *isp_dev = &stfcamss->isp_dev; int ret; @@ -150,8 +152,18 @@ static int stfcamss_register_devs(struct stfcamss *stfcamss) cap_yuv->video.source_subdev = &isp_dev->subdev; + ret = media_create_pad_link(&isp_dev->subdev.entity, STF_ISP_PAD_SRC_SCD, + &cap_scd->video.vdev.entity, 0, 0); + if (ret) + goto err_rm_links0; + + cap_scd->video.source_subdev = &isp_dev->subdev; + return ret; +err_rm_links0: + media_entity_remove_links(&isp_dev->subdev.entity); + media_entity_remove_links(&cap_yuv->video.vdev.entity); err_cap_unregister: stf_capture_unregister(stfcamss); err_isp_unregister: @@ -163,10 +175,12 @@ static int stfcamss_register_devs(struct stfcamss *stfcamss) static void stfcamss_unregister_devs(struct stfcamss *stfcamss) { struct stf_capture *cap_yuv = &stfcamss->captures[STF_CAPTURE_YUV]; + struct stf_capture *cap_scd = &stfcamss->captures[STF_CAPTURE_SCD]; struct stf_isp_dev *isp_dev = &stfcamss->isp_dev; media_entity_remove_links(&isp_dev->subdev.entity); media_entity_remove_links(&cap_yuv->video.vdev.entity); + media_entity_remove_links(&cap_scd->video.vdev.entity); stf_isp_unregister(&stfcamss->isp_dev); stf_capture_unregister(stfcamss); @@ -436,5 +450,6 @@ module_platform_driver(stfcamss_driver); MODULE_AUTHOR("Jack Zhu "); MODULE_AUTHOR("Changhuang Liang "); +MODULE_AUTHOR("Keith Zhao "); MODULE_DESCRIPTION("StarFive Camera Subsystem driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/media/starfive/camss/stf-capture.c b/drivers/staging/media/starfive/camss/stf-capture.c index 75f6ef405e61..328b8c6e351d 100644 --- a/drivers/staging/media/starfive/camss/stf-capture.c +++ b/drivers/staging/media/starfive/camss/stf-capture.c @@ -12,6 +12,7 @@ static const char * const stf_cap_names[] = { "capture_raw", "capture_yuv", + "capture_scd", }; static const struct stfcamss_format_info stf_wr_fmts[] = { @@ -55,6 +56,14 @@ static const struct stfcamss_format_info stf_isp_fmts[] = { }, }; +/* 3A Statistics Collection Data */ +static const struct stfcamss_format_info stf_isp_scd_fmts[] = { + { + .code = MEDIA_BUS_FMT_METADATA_FIXED, + .pixelformat = V4L2_META_FMT_STF_ISP_STAT_3A, + }, +}; + static inline struct stf_capture *to_stf_capture(struct stfcamss_video *video) { return container_of(video, struct stf_capture, video); @@ -84,6 +93,8 @@ static void stf_init_addrs(struct stfcamss_video *video) stf_set_raw_addr(video->stfcamss, addr0); else if (cap->type == STF_CAPTURE_YUV) stf_set_yuv_addr(video->stfcamss, addr0, addr1); + else + stf_set_scd_addr(video->stfcamss, addr0, addr1, TYPE_AWB); } static void stf_cap_s_cfg(struct stfcamss_video *video) @@ -227,18 +238,24 @@ static void stf_capture_init(struct stfcamss *stfcamss, struct stf_capture *cap) INIT_LIST_HEAD(&cap->buffers.ready_bufs); spin_lock_init(&cap->buffers.lock); - cap->video.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; cap->video.stfcamss = stfcamss; cap->video.bpl_alignment = 16 * 8; if (cap->type == STF_CAPTURE_RAW) { + cap->video.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; cap->video.formats = stf_wr_fmts; cap->video.nformats = ARRAY_SIZE(stf_wr_fmts); cap->video.bpl_alignment = 8; } else if (cap->type == STF_CAPTURE_YUV) { + cap->video.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; cap->video.formats = stf_isp_fmts; cap->video.nformats = ARRAY_SIZE(stf_isp_fmts); cap->video.bpl_alignment = 1; + } else { + cap->video.type = V4L2_BUF_TYPE_META_CAPTURE; + cap->video.formats = stf_isp_scd_fmts; + cap->video.nformats = ARRAY_SIZE(stf_isp_scd_fmts); + cap->video.bpl_alignment = 16 * 8; } } @@ -362,9 +379,11 @@ void stf_capture_unregister(struct stfcamss *stfcamss) { struct stf_capture *cap_raw = &stfcamss->captures[STF_CAPTURE_RAW]; struct stf_capture *cap_yuv = &stfcamss->captures[STF_CAPTURE_YUV]; + struct stf_capture *cap_scd = &stfcamss->captures[STF_CAPTURE_SCD]; stf_capture_unregister_one(cap_raw); stf_capture_unregister_one(cap_yuv); + stf_capture_unregister_one(cap_scd); } int stf_capture_register(struct stfcamss *stfcamss, diff --git a/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c b/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c index 6b3966ca18bf..3b18d09f2cc6 100644 --- a/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c +++ b/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c @@ -451,11 +451,57 @@ void stf_set_yuv_addr(struct stfcamss *stfcamss, stf_isp_reg_write(stfcamss, ISP_REG_UV_PLANE_START_ADDR, uv_addr); } +static enum stf_isp_type_scd stf_isp_get_scd_type(struct stfcamss *stfcamss) +{ + int val; + + val = stf_isp_reg_read(stfcamss, ISP_REG_SC_CFG_1); + return (enum stf_isp_type_scd)(val & ISP_SC_SEL_MASK) >> 30; +} + +void stf_set_scd_addr(struct stfcamss *stfcamss, + dma_addr_t yhist_addr, dma_addr_t scd_addr, + enum stf_isp_type_scd type_scd) +{ + stf_isp_reg_set_bit(stfcamss, ISP_REG_SC_CFG_1, ISP_SC_SEL_MASK, + SEL_TYPE(type_scd)); + stf_isp_reg_write(stfcamss, ISP_REG_SCD_CFG_0, scd_addr); + stf_isp_reg_write(stfcamss, ISP_REG_YHIST_CFG_4, yhist_addr); +} + +static void stf_isp_fill_yhist(struct stfcamss *stfcamss, void *vaddr) +{ + struct jh7110_isp_sc_buffer *sc = (struct jh7110_isp_sc_buffer *)vaddr; + u32 reg_addr = ISP_REG_YHIST_ACC_0; + u32 i; + + for (i = 0; i < 64; i++, reg_addr += 4) + sc->y_histogram[i] = stf_isp_reg_read(stfcamss, reg_addr); +} + +static void stf_isp_fill_flag(struct stfcamss *stfcamss, void *vaddr, + enum stf_isp_type_scd *type_scd) +{ + struct jh7110_isp_sc_buffer *sc = (struct jh7110_isp_sc_buffer *)vaddr; + + *type_scd = stf_isp_get_scd_type(stfcamss); + if (*type_scd == TYPE_AWB) { + sc->flag = JH7110_ISP_SC_FLAG_AWB; + *type_scd = TYPE_OECF; + } else { + sc->flag = JH7110_ISP_SC_FLAG_AE_AF; + *type_scd = TYPE_AWB; + } +} + irqreturn_t stf_line_irq_handler(int irq, void *priv) { struct stfcamss *stfcamss = priv; struct stf_capture *cap = &stfcamss->captures[STF_CAPTURE_YUV]; + struct stf_capture *cap_scd = &stfcamss->captures[STF_CAPTURE_SCD]; struct stfcamss_buffer *change_buf; + enum stf_isp_type_scd type_scd; + u32 value; u32 status; status = stf_isp_reg_read(stfcamss, ISP_REG_ISP_CTRL_0); @@ -467,6 +513,17 @@ irqreturn_t stf_line_irq_handler(int irq, void *priv) stf_set_yuv_addr(stfcamss, change_buf->addr[0], change_buf->addr[1]); } + + value = stf_isp_reg_read(stfcamss, ISP_REG_CSI_MODULE_CFG); + if (value & CSI_SC_EN) { + change_buf = stf_change_buffer(&cap_scd->buffers); + if (change_buf) { + stf_isp_fill_flag(stfcamss, change_buf->vaddr, + &type_scd); + stf_set_scd_addr(stfcamss, change_buf->addr[0], + change_buf->addr[1], type_scd); + } + } } stf_isp_reg_set_bit(stfcamss, ISP_REG_CSIINTS, @@ -485,6 +542,7 @@ irqreturn_t stf_isp_irq_handler(int irq, void *priv) { struct stfcamss *stfcamss = priv; struct stf_capture *cap = &stfcamss->captures[STF_CAPTURE_YUV]; + struct stf_capture *cap_scd = &stfcamss->captures[STF_CAPTURE_SCD]; struct stfcamss_buffer *ready_buf; u32 status; @@ -496,6 +554,14 @@ irqreturn_t stf_isp_irq_handler(int irq, void *priv) vb2_buffer_done(&ready_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); } + if (status & ISPC_SC) { + ready_buf = stf_buf_done(&cap_scd->buffers); + if (ready_buf) { + stf_isp_fill_yhist(stfcamss, ready_buf->vaddr); + vb2_buffer_done(&ready_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + } + } + stf_isp_reg_write(stfcamss, ISP_REG_ISP_CTRL_0, (status & ~ISPC_INT_ALL_MASK) | ISPC_ISP | ISPC_CSI | ISPC_SC); diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h index fcda0502e3b0..0af7b367e57a 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.h +++ b/drivers/staging/media/starfive/camss/stf-isp.h @@ -10,6 +10,7 @@ #ifndef STF_ISP_H #define STF_ISP_H +#include #include #include "stf-video.h" @@ -107,6 +108,12 @@ #define Y_COOR(y) ((y) << 16) #define X_COOR(x) ((x) << 0) +#define ISP_REG_SCD_CFG_0 0x098 + +#define ISP_REG_SC_CFG_1 0x0bc +#define ISP_SC_SEL_MASK GENMASK(31, 30) +#define SEL_TYPE(n) ((n) << 30) + #define ISP_REG_LCCF_CFG_2 0x0e0 #define ISP_REG_LCCF_CFG_3 0x0e4 #define ISP_REG_LCCF_CFG_4 0x0e8 @@ -305,6 +312,10 @@ #define DNRM_F(n) ((n) << 16) #define CCM_M_DAT(n) ((n) << 0) +#define ISP_REG_YHIST_CFG_4 0xcd8 + +#define ISP_REG_YHIST_ACC_0 0xd00 + #define ISP_REG_GAMMA_VAL0 0xe00 #define ISP_REG_GAMMA_VAL1 0xe04 #define ISP_REG_GAMMA_VAL2 0xe08 @@ -389,6 +400,15 @@ #define IMAGE_MAX_WIDTH 1920 #define IMAGE_MAX_HEIGH 1080 +#define ISP_YHIST_BUFFER_SIZE (64 * sizeof(__u32)) + +enum stf_isp_type_scd { + TYPE_DEC = 0, + TYPE_OBC, + TYPE_OECF, + TYPE_AWB, +}; + /* pad id for media framework */ enum stf_isp_pad_id { STF_ISP_PAD_SINK = 0, @@ -429,5 +449,8 @@ int stf_isp_unregister(struct stf_isp_dev *isp_dev); void stf_set_yuv_addr(struct stfcamss *stfcamss, dma_addr_t y_addr, dma_addr_t uv_addr); +void stf_set_scd_addr(struct stfcamss *stfcamss, + dma_addr_t yhist_addr, dma_addr_t scd_addr, + enum stf_isp_type_scd type_scd); #endif /* STF_ISP_H */ diff --git a/drivers/staging/media/starfive/camss/stf-video.c b/drivers/staging/media/starfive/camss/stf-video.c index 989b5e82bae9..2203605ec9c7 100644 --- a/drivers/staging/media/starfive/camss/stf-video.c +++ b/drivers/staging/media/starfive/camss/stf-video.c @@ -125,6 +125,14 @@ static int stf_video_init_format(struct stfcamss_video *video) return 0; } +static int stf_video_scd_init_format(struct stfcamss_video *video) +{ + video->active_fmt.fmt.meta.dataformat = video->formats[0].pixelformat; + video->active_fmt.fmt.meta.buffersize = sizeof(struct jh7110_isp_sc_buffer); + + return 0; +} + /* ----------------------------------------------------------------------------- * Video queue operations */ @@ -330,6 +338,78 @@ static const struct vb2_ops stf_video_vb2_q_ops = { .stop_streaming = video_stop_streaming, }; +static int video_scd_queue_setup(struct vb2_queue *q, + unsigned int *num_buffers, + unsigned int *num_planes, + unsigned int sizes[], + struct device *alloc_devs[]) +{ + if (*num_planes) + return sizes[0] < sizeof(struct jh7110_isp_sc_buffer) ? -EINVAL : 0; + + *num_planes = 1; + sizes[0] = sizeof(struct jh7110_isp_sc_buffer); + + return 0; +} + +static int video_scd_buf_init(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct stfcamss_buffer *buffer = to_stfcamss_buffer(vbuf); + dma_addr_t *paddr; + + paddr = vb2_plane_cookie(vb, 0); + buffer->addr[0] = *paddr; + buffer->addr[1] = buffer->addr[0] + ISP_YHIST_BUFFER_SIZE; + buffer->vaddr = vb2_plane_vaddr(vb, 0); + + return 0; +} + +static int video_scd_buf_prepare(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + + if (sizeof(struct jh7110_isp_sc_buffer) > vb2_plane_size(vb, 0)) + return -EINVAL; + + vb2_set_plane_payload(vb, 0, sizeof(struct jh7110_isp_sc_buffer)); + + vbuf->field = V4L2_FIELD_NONE; + + return 0; +} + +static int video_scd_start_streaming(struct vb2_queue *q, unsigned int count) +{ + struct stfcamss_video *video = vb2_get_drv_priv(q); + + video->ops->start_streaming(video); + + return 0; +} + +static void video_scd_stop_streaming(struct vb2_queue *q) +{ + struct stfcamss_video *video = vb2_get_drv_priv(q); + + video->ops->stop_streaming(video); + + video->ops->flush_buffers(video, VB2_BUF_STATE_ERROR); +} + +static const struct vb2_ops stf_video_scd_vb2_q_ops = { + .queue_setup = video_scd_queue_setup, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish = vb2_ops_wait_finish, + .buf_init = video_scd_buf_init, + .buf_prepare = video_scd_buf_prepare, + .buf_queue = video_buf_queue, + .start_streaming = video_scd_start_streaming, + .stop_streaming = video_scd_stop_streaming, +}; + /* ----------------------------------------------------------------------------- * V4L2 ioctls */ @@ -448,6 +528,37 @@ static const struct v4l2_ioctl_ops stf_vid_ioctl_ops = { .vidioc_streamoff = vb2_ioctl_streamoff, }; +static int video_scd_g_fmt(struct file *file, void *fh, struct v4l2_format *f) +{ + struct stfcamss_video *video = video_drvdata(file); + struct v4l2_meta_format *meta = &f->fmt.meta; + + if (f->type != video->type) + return -EINVAL; + + meta->dataformat = video->active_fmt.fmt.meta.dataformat; + meta->buffersize = video->active_fmt.fmt.meta.buffersize; + + return 0; +} + +static const struct v4l2_ioctl_ops stf_vid_scd_ioctl_ops = { + .vidioc_querycap = video_querycap, + .vidioc_enum_fmt_meta_cap = video_enum_fmt, + .vidioc_g_fmt_meta_cap = video_scd_g_fmt, + .vidioc_s_fmt_meta_cap = video_scd_g_fmt, + .vidioc_try_fmt_meta_cap = video_scd_g_fmt, + .vidioc_reqbufs = vb2_ioctl_reqbufs, + .vidioc_querybuf = vb2_ioctl_querybuf, + .vidioc_qbuf = vb2_ioctl_qbuf, + .vidioc_expbuf = vb2_ioctl_expbuf, + .vidioc_dqbuf = vb2_ioctl_dqbuf, + .vidioc_create_bufs = vb2_ioctl_create_bufs, + .vidioc_prepare_buf = vb2_ioctl_prepare_buf, + .vidioc_streamon = vb2_ioctl_streamon, + .vidioc_streamoff = vb2_ioctl_streamoff, +}; + /* ----------------------------------------------------------------------------- * V4L2 file operations */ @@ -473,6 +584,9 @@ static int stf_link_validate(struct media_link *link) struct stfcamss_video *video = video_get_drvdata(vdev); int ret; + if (video->type == V4L2_BUF_TYPE_META_CAPTURE) + return 0; + ret = stf_video_check_format(video); return ret; @@ -506,7 +620,11 @@ int stf_video_register(struct stfcamss_video *video, q = &video->vb2_q; q->drv_priv = video; q->mem_ops = &vb2_dma_contig_memops; - q->ops = &stf_video_vb2_q_ops; + + if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) + q->ops = &stf_video_vb2_q_ops; + else + q->ops = &stf_video_scd_vb2_q_ops; q->type = video->type; q->io_modes = VB2_DMABUF | VB2_MMAP; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; @@ -529,16 +647,28 @@ int stf_video_register(struct stfcamss_video *video, goto err_mutex_destroy; } - ret = stf_video_init_format(video); - if (ret < 0) { - dev_err(video->stfcamss->dev, - "Failed to init format: %d\n", ret); - goto err_media_cleanup; + if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { + ret = stf_video_init_format(video); + if (ret < 0) { + dev_err(video->stfcamss->dev, + "Failed to init format: %d\n", ret); + goto err_media_cleanup; + } + vdev->ioctl_ops = &stf_vid_ioctl_ops; + vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE; + } else { + ret = stf_video_scd_init_format(video); + if (ret < 0) { + dev_err(video->stfcamss->dev, + "Failed to init format: %d\n", ret); + goto err_media_cleanup; + } + vdev->ioctl_ops = &stf_vid_scd_ioctl_ops; + vdev->device_caps = V4L2_CAP_META_CAPTURE; } vdev->fops = &stf_vid_fops; - vdev->ioctl_ops = &stf_vid_ioctl_ops; - vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; + vdev->device_caps |= V4L2_CAP_STREAMING; vdev->entity.ops = &stf_media_ops; vdev->vfl_dir = VFL_DIR_RX; vdev->release = stf_video_release; diff --git a/drivers/staging/media/starfive/camss/stf-video.h b/drivers/staging/media/starfive/camss/stf-video.h index 59799b65cbe5..53a1cf4e59b7 100644 --- a/drivers/staging/media/starfive/camss/stf-video.h +++ b/drivers/staging/media/starfive/camss/stf-video.h @@ -37,6 +37,7 @@ enum stf_v_line_id { enum stf_capture_type { STF_CAPTURE_RAW = 0, STF_CAPTURE_YUV, + STF_CAPTURE_SCD, STF_CAPTURE_NUM, }; From patchwork Tue Jul 9 08:38:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727439 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2111.outbound.protection.partner.outlook.cn [139.219.146.111]) (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 47537153582; Tue, 9 Jul 2024 08:39:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514399; cv=fail; b=mQeDcXt17Xvo6S8uU25fePATM8qjWMY7O43W0YGEbr+UUPp7KiF+sKDMSjRYq4wc/QWh4P40v8jydzIbbeMM1xUDI481Bf1gUFvsOEtUnaeCocvjaQyaw9ymbJl1DKyqPmHtRxvJQ2jPJGs4ArO/npLiuFennP3DN8F0JEfdCRA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514399; c=relaxed/simple; bh=pFAFH5nqcgUyjxT4/ObOrkt7mfrFPzk7iNLCb3InQnM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Z4E7GpEAj02OQYqYMIio33tzY5sqvtjq805nlAPxFXiGXtBfgcrSmNsXfm7GF27KQ88/PtOvFdesu22sy7bRC9fw3jecC4TkDQR7Mzb+JEcW3xn4Uuhc2PSFnheiFgCyER0xGXQCMI/BojMvpLumyMVUihX6EVtHEy0fslut2D0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OjWC/vE+tbNHhaURnZTeiYZqia0wIasa2i9hHuNYgneVbbASV8fPvl/xhJuPsTRi/U7XDkQlUBfXK2du3D35wby8OW5jqYP9O7B7rKT36fdWz1GukFP6iGplGGS5T9PFqD2MQBc0Iye/gqnqxLc9Qyk4qqM09X8hqWmDsrB8fMvfCZpHZpKS5vqJRXOXE0PQm6NQ8wzDyW2SlxFCyG4/0wlabbSMDXcQrJ5cfEweM34xxvyLEYS9wSxHwnsZXUxyXvOEEI61+E4K+Sehkw4nnOW3aKbi+7snI19ULToCJb1xwrm4a+ri1FNMYPyiU7gdWA4/7wX93MQsE5w6rXJeNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xGpyPzRRm17ntogV+3bvGdPa+rVfC9YEIC5vX1kewGI=; b=HS93KLtX+fuz4VTkH3pxoBOu449sx/JH92EcxlXvQAn6b5IIxH11HDa3a0UK6fZmBaKoit6ZJk6yd0octOb70IOwRrzswN6NO5SkIIPTFl7ms+28ZUf4x6TgSbsKy3S9TnAdbGtkoAr3MIKiunFUSeXaTJUkupdAzOsu0/s196yCwDDhBNwuLqLb97PvQxoC+cpGOoUKvPfY3/FztobK5id28JbfdexVskMuApTRrakkd/qwj/hTmDoNtv5r3xtJQl9qIgP51vuWirdya8rdUPAwYybX8dpadQo3HdQ0Trf7XZ3lFb2FgCsQQrw1WyNzWMWUKkx276LZk2o592YrGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:42 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:42 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 09/14] staging: media: starfive: Update ISP initialise config for 3A Date: Tue, 9 Jul 2024 01:38:19 -0700 Message-Id: <20240709083824.430473-10-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a652380-6162-4e52-a2fd-08dc9ff28a01 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: 5pG1jZnnHzGudLxD0iRAO9oK7HuCfQ0grfC/qMRL/09Hd6C0GGf9nXp36hOq/OSS2Heegg7Bi6P1dhI7UMywM0HqMYSDbAMiLDwZmVoucSXg16TjUBjc1z+04FioCkvitTUw1tid+5gQpmVH3tHfaKyJPE8xPP84hqzvWREQZhYDnPWAKqeWDp+FenEv3MhjJdY8HFtXoXtvSGqOr4v1l7aj+6kPf5qRjz9ic21nSVxddWX98Nns20OFLjSpCiJRM91zPjVCPIy0lJIpH8J1uGEVmXn91NEMc0Sx7+DPsvCBgClaeVW6NWsAJhLUKqY0pgWnK7fabu8xGhPMPNXN5x+k35Mj8T1Pvbfd74RFvnszv9GkOD7NV8yAbD7YvmBkVEDnfAtPAUizAkW4boyLynzv9Zvc8PYZois7SOnaVHdpkApXGpQy0cUIdVH2AUpmRccW6W3m4JCTHUAm6K7hsSpmisVQxdxfkIXqbFGw/BSGmwP6fIqwQikmSWfE4s1EG2B2NhjA/lB0aF6f5frtnYLysUz8Rkwgpju4ACfdpUcsEGSZTyBWD0nd3JHn+PVYAn78gAqLX7QN5EkV92EQ4syRclNN2XKfa2+SoCCEsYaRIooTU3rgwxKdXmEnS0r8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IWYUVbTwBk+piTq4Yr0O69Zg8AksYhrBrpIcYbU6ltJ7NnphnLzerEGnW8AQTFm0ozkoz7yb4NmBZ06qxaTdin9hWLT7HpnUYsDUWqfvtlwTgP5uN5GD0NPYDlqNaV4uF+BpYD3QBifgHYXM4L+f+9UHfcTd7ZHIRCaSjfkfOsUq6Jhcvh1+9wpucPk5P6TwnF+tELpcfj2tt605c+tE2869gtJo8TV6ZvPLzOAMdvj1K4g/eUHZ3p1Gqdkd1w2rOYbnpdsRjMSd9lbTQGSvUmW0M1HYjtQVlxTcjj8NpcXLA5cjlpLJCOpm3TGrYzTdcBcVEJign7iakXbKfuNKYRSdZfwGrRRstqVM9QG0mrnJq0FJy1lgqEzJoaVr+NuhKs+VCiQh/6sIZM8QQh1Kv9jH1IFuwdeET8kWs2LqPoRh1EPsbQ8DmasM0VIC/fTXcUCxlz4sKvxWRp/JP26slkU5lqawnz7Xvo8+E9P63LQhDMNxeyMzPCoNRDV9ZaRkeUTDk3WXvL/Fsgtm2sDH43tkXaA7vcwSe2L4N+u/GuNjr3mS9R4WtdhZPEwm/1Cme9LJy20xLyZtY6n2qkDOqYhluOKnDE6e7IF6nlZSv8kvKyx/PZFt1leOhoE68+JGqVU+7d5zCTvxIZ7xtHHZtEDCcgALiGNneEWAqQ5bSKfi7abKn563524vsMz0fNXwBcBZ/XXiMAFlqq2HEixnQr9JlJT9CYJiRH2fgk3vDg2LPQ2ccwQD2+GM3Ghc4NtYrmz4xrByCfYi+fAy2SuFbX6ct0L76tbTT4hfAgpL6EuC4fBnCQEQhBnysy7GUA9ogVb2tzh49QGAQ4xwQpxHSyOaBqk5YawRaAo0DZWzMc9gxIu2iAueevMLY50fqmU5DxKHDpas33ZYCIFON9E7391R0LNFyK3E09qqmRWVcIMdRYgLTkxdASLLFi1+bJ2gKsrnWdbon93nD47Iw2xp/sO7KMxcCIC8DCUOVQnGu2Gb6C7kxCzmHxWE/BwdcqI77rPCHbNLEZgRfSXr1HaxXfOEC3F59KGdzGFW12k3jHmgn+HEzqw676t2xzXdNLvllVqK1lpOhGRtRcwzyTDlM/TbkGbSzcn+TuBMVaeplO+saUPbpgtDa5PfRpVd+3aO3Ojx9PaECC4JKZBFiSYCNyJX+HW9s4H0qYAV8yq/r1OeFdwFx6uIprJdJX6yw8gzaqQqTExT8naKWmw3TH3+WqaGl0EK0N+nRe4FLhKEWwWWnSwYz2WhxNDPrIqUb2kxhfcHqZME/XrKOJ0xRVgGyzwnNReREq16enX62Fo5RMmMhJj5NG5FXqTIZCtC/mKcnWgQj5F6JiZJdiVs71GugxESFsO4MnBxax2re7Rz2jVNgymz1Aj7v7JVqXveS52omLV+cBZrzar35cUBynKJjfD+72/0jbvlLFoDJR3krIm1WGjeO6ITIZUA+if68bkeuXojfInJaB/ZXzMLwZGJKPH6ybYdA+/Hkccq6CDzOUYl8wL/G0RoIrkm+qVGhqa1D1mbMXCKYC7Tc7ZLIc6vgjJ7yiWRtlq3RUFZ4kGp0s/dp7z3r0M//y6qNs62h8o8sTsZMbsK55nNEKeFjYaYYunyvbokPBd/nOqAjiR1Y9E= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a652380-6162-4e52-a2fd-08dc9ff28a01 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:42.6754 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bSuQR366FA9KTvb687SPbp80AegVOD5H5c9hthfSoNQAQef6I9FL8a8LuqhbqmOOhZnZliiQonHHOGUMQO+NnK3KIn7RrwjW/Lyl4Y92BP7TpVEWWeznVreC8BxVN1HE X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 Upadte ISP initialise for 3A statistics collection data. Signed-off-by: Changhuang Liang --- .../media/starfive/camss/stf-isp-hw-ops.c | 23 +++++++++++++++++++ .../staging/media/starfive/camss/stf-isp.h | 21 +++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c b/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c index 3b18d09f2cc6..0bc5e36f952e 100644 --- a/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c +++ b/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c @@ -300,6 +300,25 @@ static void stf_isp_config_sat(struct stfcamss *stfcamss) stf_isp_reg_write(stfcamss, ISP_REG_YADJ1, YOMAX(0x3ff) | YOMIN(0x1)); } +static void stf_isp_config_sc(struct stfcamss *stfcamss) +{ + stf_isp_reg_write(stfcamss, ISP_REG_SCD_CFG_1, AXI_ID(0)); + stf_isp_reg_write(stfcamss, ISP_REG_SC_CFG_0, HSTART(0) | VSTART(0xc)); + stf_isp_reg_write(stfcamss, ISP_REG_SC_CFG_1, + SC_WIDTH(0x1d) | SC_HEIGHT(0x15) | + AWB_PS_GRB_BA(0x10) | SEL_TYPE(0x3)); +} + +static void stf_isp_config_yhist(struct stfcamss *stfcamss) +{ + stf_isp_reg_write(stfcamss, ISP_REG_YHIST_CFG_0, 0); + stf_isp_reg_write(stfcamss, ISP_REG_YHIST_CFG_1, + YH_WIDTH(0x77f) | YH_HEIGHT(0x437)); + stf_isp_reg_write(stfcamss, ISP_REG_YHIST_CFG_2, + YH_DEC_ETW(2) | YH_DEC_ETH(1)); + stf_isp_reg_write(stfcamss, ISP_REG_YHIST_CFG_3, 0); +} + int stf_isp_reset(struct stf_isp_dev *isp_dev) { stf_isp_reg_set_bit(isp_dev->stfcamss, ISP_REG_ISP_CTRL_0, @@ -332,7 +351,11 @@ void stf_isp_init_cfg(struct stf_isp_dev *isp_dev) stf_isp_config_sharpen(isp_dev->stfcamss); stf_isp_config_dnyuv(isp_dev->stfcamss); stf_isp_config_sat(isp_dev->stfcamss); + stf_isp_config_sc(isp_dev->stfcamss); + stf_isp_config_yhist(isp_dev->stfcamss); + stf_isp_reg_write(isp_dev->stfcamss, ISP_REG_DUMP_CFG_1, + DUMP_BURST_LEN(3) | DUMP_SD(0xb80)); stf_isp_reg_write(isp_dev->stfcamss, ISP_REG_CSI_MODULE_CFG, CSI_DUMP_EN | CSI_SC_EN | CSI_AWB_EN | CSI_LCCF_EN | CSI_OECF_EN | CSI_OBC_EN | CSI_DEC_EN); diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h index 0af7b367e57a..eca3ba1ade75 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.h +++ b/drivers/staging/media/starfive/camss/stf-isp.h @@ -110,9 +110,19 @@ #define ISP_REG_SCD_CFG_0 0x098 +#define ISP_REG_SCD_CFG_1 0x09c +#define AXI_ID(n) ((n) << 24) + +#define ISP_REG_SC_CFG_0 0x0b8 +#define VSTART(n) ((n) << 16) +#define HSTART(n) ((n) << 0) + #define ISP_REG_SC_CFG_1 0x0bc #define ISP_SC_SEL_MASK GENMASK(31, 30) #define SEL_TYPE(n) ((n) << 30) +#define AWB_PS_GRB_BA(n) ((n) << 16) +#define SC_HEIGHT(n) ((n) << 8) +#define SC_WIDTH(n) ((n) << 0) #define ISP_REG_LCCF_CFG_2 0x0e0 #define ISP_REG_LCCF_CFG_3 0x0e4 @@ -312,6 +322,17 @@ #define DNRM_F(n) ((n) << 16) #define CCM_M_DAT(n) ((n) << 0) +#define ISP_REG_YHIST_CFG_0 0xcc8 + +#define ISP_REG_YHIST_CFG_1 0xccc +#define YH_HEIGHT(n) ((n) << 16) +#define YH_WIDTH(n) ((n) << 0) + +#define ISP_REG_YHIST_CFG_2 0xcd0 +#define YH_DEC_ETH(n) ((n) << 16) +#define YH_DEC_ETW(n) ((n) << 0) + +#define ISP_REG_YHIST_CFG_3 0xcd4 #define ISP_REG_YHIST_CFG_4 0xcd8 #define ISP_REG_YHIST_ACC_0 0xd00 From patchwork Tue Jul 9 08:38:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727442 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2111.outbound.protection.partner.outlook.cn [139.219.146.111]) (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 E16251552FC; Tue, 9 Jul 2024 08:40:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514405; cv=fail; b=FLdLyeoWxHv/L7cWP80miNtR9DlZbfO2Jw88og3RR9Wje4vALJ9+zpG/C8MEHB3gxwXJsd/M8AU3WeISouNT3W24Rq0Ysdv2Ceatcl9lw4PGTxGqAdNqahRyZq67O4pjDz5qjH1Py1EXkap7gmM2JVmN56XDoEe2i4x/1yI2DfQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514405; c=relaxed/simple; bh=XjJKkics5oMbBQtYcpr9yL22hoFeuD/czTzMkW9bu0Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=FZPhsC/B5cNW2CQfb82RGVHaMu0Dtnr1uDug4j7dSGSCSY/d1CYQw21V1aYjk+PmaQDVZ/RPvjGc0sdjwfddUglEvHlVtavsHUoAK2KngPvzf0eXkDOCkvhRPmy7Ejn92Y4LJcE9St3u/6IUk26it7voPFvw8wzVefEEgv6ow2o= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ixyh6j+lT3mx+5si5iOGnmpIFWMTkUfoybgfu/4EQiCJ/Pc1u4yQRxfIEs7hkT4VhVDoZ1Ex4n7NJy8uHD3vInizmTgDVrPLSHCNl6hWzOf6PN14xIB8AbwF1TnJw9X3tCYT+GyigroGsWbKB5A3f7DpYrigimRWWUY6Ihp5uMpS2V19Zc3V5yIgln02WUFKarpHSTViDM8MTVVyp8+W1Gw8K4NRwkZr8JzopAUkX3yhCL9Gc2lIsIPoeG2PXr3Citj76RO943/SS2y1yeE9FgxEfoGuBdKa7YNvXKgNvwce258uUPUaWqrEfsMlZ92sICnwCS4hplnJih0qm9Pb1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=379HMc1/LSUOcf9HcMn7Zcj0bVXtl3Wt0/nMNbeCe5o=; b=SdxjGE7BUUfoLqlI3ueB6pXooL0Q26nVVMoJmTzIT+3UKogRFe20NiVpE8Rz4g91wNTyaOCQVshMJUiTSeF9FVU3pDu9DW3tXs4BjBl8gcMjXRAsYyPJkou7xFo9p2TzVlbYkbdtKf5TRsD/3hKFfmRslrUBUGExxvCcnWm6bfc7VMuPBNaxyyG2FFlasryJ999kQ/MKdNrbWjcdc2Wq8IE+oYK5OLNBtIP63c/AmCSCKN5FUAEbRSegPU7p889bLP/oPa/bzZnBJpJboYJKHMd68uWSiVGlcjR1xHAdQNJ6KfeSRNMrPfk2wHdCQ9D4ngR8QX+GY1H9h8tAwaRz8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:43 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:43 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 10/14] staging: media: starfive: Add V4L2_CAP_IO_MC capability Date: Tue, 9 Jul 2024 01:38:20 -0700 Message-Id: <20240709083824.430473-11-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c97d4d9-a910-4e36-928a-08dc9ff28aaa X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: 0UQ8+xBk2k/3pI7ljw8Dm8R/LOJAAvj9Vawt3uaHPuzYtXYEfuAb1XkHzMuERR10kFTh+ndrLVYFv3w88jrpQ2jh4EWR9eB2LSmS1hR8rXFdzf7OBis0S+nU4nr+rVwiZ3ejmVoKHRzXpo8fq5n2xNO2LUGsAII0sLu2q+4R6TESpBasg4qZ3ySaDiSana9UaUyryktc5yEGd6HKedExYbmrohcNxK5uYHVWC9+Ap30YyMGW6Qlcvhcr9V7Q089qLXKwyqMDUXLNRx7rKtaYBigHh4RrxZOvCIcuSmBeuoaCBUf2uKZ0k6qeFkBdxKZr2wwqeGB7iaxdafX1ReTWSUVY0loi1KUswzxRU7BLM2FyeKPNy9EBGEtPeVgvP4v5nsYqOL6qQ4qEQCp3OhUmKC4iLjUHT2PPZcEtX5/sFHQ0GakyeFaXzLP8l7hId4GLA4Pg1MnX8AIv0Ba6cbEVPH8HCUcIm8mQCJVVwNg71KGzdJdzsBGYzxi5OFraSCLJonBWzZuGGdmmY2z+zZeDqtguizs8tUGlKVoEr2xppQQjGLoN5QxlAdcsVtiJYGvwRh82oBCG2PS8UVogmpIppugJyrM8kC6UwgoSLZOnRETdh8/tdUyYWzYYtx2VBXV0 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vS/hfPhqo8wZisFlGbNIr4pNM5iM7uwVC6iXexyZepe8qQ18gX+GzUrM10gsfGJ/L311a496ZP/75A5DskUzqYCa6K/qT3uBjC1bvCt8mTRT9qJgrpBXk7nKS23fBSAPjBi5uqqI2U7NS3N1ti1Wm5RFOdFjSOwSDTBn0qwAVoJKPChUyP6gR709msYMiD4jIulJMH6VKg8FlJppAO/X0oWavyds7uRzUNcL5oKiE4Nb2q0vjbwRhMmm2udrbsjvW4m//pt7bKjYv7Uy38MSYVm7fJAP/IsCaydH+Z9XALwcOaf6en+ZxPB7QcidZ6RH/GqPtLhPPqKJGFClw/95DD/GFJF1htqF7Eo6FRe26guqU8rJDxNEts8zzM1N4Uc4vZKn6kACYU0jZtVHkdUDWxCFyhDx4S2ZAc4GVp2+QHuHllB442NPp8XWJmZ6czchzVuXf9bDnIvhGAx5mb2I9TWWjOde1m7zcEBtVw9nnDJat8mXiuDfayB54HXxvxJzAefT+KSQpjWuJb6A71AnR4IHHYCnoLkKpoI8INX1rp6nY0LNxL2Fpd0dsUeyMPqJL0PrfG+TsggeeCx9QvBirLApo2LjjRzVRxD4GGr6zEgd3aFeVO7Ts8UoRHDT7qO79Au5fA9lmZ8rOrezlOJLuXXeoHzVj2fBFBTPYpdqeg9sCyDxzNvcvuKlKE1D7jBGvj+nTwuCGB10J+AVjcah2DsYzMPxjICQJX7N6rlD2/yXzKdmGLwH/RRh3XNbGlgnmiyBzWQzUxkZZGb0MMvaRHvKmfAWLYqDaMDrKbzxmI3J0vviv9pl0riTlyEerCTqVCJxBMoue4/27jdFvZsWRvMzRZ2Jy8l9z04Jg8A83tLk19tgddGXK7KaO3lrWPgS1ZGhod8t29CeZJ5T6bebu+SKr4t4PamOhYgEmQiPtA2CR8/MlfyZDut7ft/gsQ9XfVYPYa7as2rCCzyDXtDDlNBc9T+25mWiDtt1dY7uDqwMwRo+flv94zPgn9QEphc1rZ/iuzFiU6FCVEPNSFw9/Otb3VfEOl9YCcTEoK/EG6Ko9Xn3CX2+l+HzzpE2rFUTmRiV4/qHNw2geNP+Jn6kwkDQ5DAIzezKqcTcQOvI21mtqetpj1wz3U9G6gwRSuUwmg/xZAa0oIUIqjfP0+pU44/VfBnYioqSrYntZ/0k66ywOY0c6hYRD27UnHqWb96Smy+vuJvFq/9VtMC3A3DGVnYR6l2VeBGGOzLGkMAlc3EYIfSWjpOPJHHr5ukiO6CGpo8GgryqqOwxrz2JTDshr7NZeU4weTxAc9Jij31qrToiCRxSe2jhPeDek6vhJOb2WfYBm4v2hehJfYugs3GFOApaJHqYD9Odc/hy4ZAKzEAemhU1D9vCEjq+peuNma6RsQ86mECf+3h5ZrKIckOcEm2BYdnoAYT7eJP1UPFJxTaGS0tEdY/VsvlqeV7EifoK4Uvmc6VRt9VsDsHpN4C+bB2s7dVYXSNd9hwqXe8mvauNOVsFE0MCRu+rNyHwMyHZ1ID37erfzb4fv5Q/6n96Sh92hNtM1HO2OkAKaWmsC3MStR1qdHkosAt8owqPSjlzcyzLMw8G1FnVpe2qmDjYiIGQYU3m5c6ONfSe0XPJ0MM= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c97d4d9-a910-4e36-928a-08dc9ff28aaa X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:43.8109 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MY8CWRGFkPWHsoxjQNshVcxnec1IioFDFpyv+zCVdK1mI9SiMmUn/IBTZhbeX1FrJXFpbuD4G/RQE6Ghn+7C5pwJTLOi9q0EaYGTnMPmqZyeC59a4T9e+p4ojCVT52ss X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 Add V4L2_CAP_IO_MC capabality for video device. User space can enumerate formats by mbus code. Signed-off-by: Changhuang Liang --- drivers/staging/media/starfive/camss/stf-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/starfive/camss/stf-video.c b/drivers/staging/media/starfive/camss/stf-video.c index 2203605ec9c7..8c6c45d8b7a1 100644 --- a/drivers/staging/media/starfive/camss/stf-video.c +++ b/drivers/staging/media/starfive/camss/stf-video.c @@ -668,7 +668,7 @@ int stf_video_register(struct stfcamss_video *video, } vdev->fops = &stf_vid_fops; - vdev->device_caps |= V4L2_CAP_STREAMING; + vdev->device_caps |= V4L2_CAP_STREAMING | V4L2_CAP_IO_MC; vdev->entity.ops = &stf_media_ops; vdev->vfl_dir = VFL_DIR_RX; vdev->release = stf_video_release; From patchwork Tue Jul 9 08:38:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727444 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2111.outbound.protection.partner.outlook.cn [139.219.146.111]) (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 9C477155345; Tue, 9 Jul 2024 08:40:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514407; cv=fail; b=JAOIy5/SjTwa77Bb42KhdfSFVIZElvlFhsdfz9KF+SblIYHN9NGKoM4uNuJaiWKgzWtjGq12PyZljX0q179JiYxGa101q6HD8R9v/m6aemQqPZUOB5MYSKC/vaOJZ9vc2l1VkyeVCxmlC6/NvremDqYZdTG4sIwb/d7yZWeerfU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514407; c=relaxed/simple; bh=NTxVxwz2g4JQC9C6loXZIUi8h4JIBZUJTXKzu97cKb0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nKXkdIGKD79yxILouO/Nyj33YwIOqh7JfDrxEK2KDq8jZclzNF8i/a07gSz6lgpWHORmBoMTO+HN0QGvnI0RyW0xWV5kXUBlzjMkosLKmV8E8sSMvYiOIAGjK77vAHooP0XjZkbpKpds1z0YDJ6JAkNVQ4H9TIMEeGHEKlB/ytk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vv/1hH7KuwQ7OVgbuWjT86sKY0FVH6kr2/cG4VeqtjIDP5G/fsTOjRLrNs14vfnmmqiZtK3fQZ5I3caO1nQdhw0vaXRru3fAzvKyYL1n/lRt+zkxX2DQ6k6ehwNMoec+sqt5k1tS0wRjdvxAZ0U10Qic3Xjf9HMoUVl+sXiKcPUnWK0OurIX+EwjP2dkyKx24ZcJv0uFkM+PCUSvN5HMOkHUoyuBq3W2Q86jv1jgKjDf4NKb8UxyNWObyoLyO6W2OS4QJ+VQsP7D8qneMGysi2y7E/EaZyHadp9JxGv+b1DcavyjToiQpd7mj3y7gQDHFMEEp1EJrbbQ2hgUGPa+LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yPMStqwazjedOtqNt0Nty1QEoyzkAh86Bo3z5i/GBwQ=; b=kEfVvFqezkYyVENtRqSNQovKM4YvnQmmvJK/5KZKCOdxPhQ96lISnFdCkoqfvr8M7Jj6/j/Qhd6uj5k1vywLLX0NSRJX8ztDmyLqTJus2lNe2Xg4kdGXJUeTl0RGZ2Q8OVSDP+PFHwvTVdLPQCMP0/Y0u6ICBwGv/0yTIyTYgUB+bnEFrt10NyWDKq0rsEt6VliYo4+DHoeznHGzMJbzyDbCSLL9tOyUAtshXcasx2s6rqtmtrCRx61+ZDXfY8Luvc0AstMyiWu0GIfw13vexnsDMzkFUJveov9V22Z0cTc0MkO08CtJA8RPh1SBe9hJd0C699Ajzxdpwwx43dJ8Mg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:45 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:45 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 11/14] staging: media: starfive: Add ISP params video device Date: Tue, 9 Jul 2024 01:38:21 -0700 Message-Id: <20240709083824.430473-12-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b2b63ab-fed9-40f3-9a3d-08dc9ff28b57 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: pVJPuOUPWlM63msAhsxeSUp6F7qfNmkUY+HUOh5vQzVE6KHvrNrwYwOMf29gTMK6e9lnpWMTyQiMXah3uq+pO3Y2ulxkmCs1ZIVztoRlBPutEoVIY8ZM3wLN3UI8/q3+i0Xv+wPmv1pWjvOCerNQ4QMXNDC1mzvfQr8v1/ZNRWee3BlVdlC9SSLzVYb20ezNheoUemQrme0IxvQnifKW14dC7I9UjTZRZGQ5uIkJ4bkgOFlOyT6OZh3KgoWQufsJ2alh0rG+69hkFqgpPqWx+JVM7KeB+WKAKpH3H3O0V7cA03TczmPcp3GcFyebIJzEtFtqc26zsdT62lU+gYhInh/9K5nkmYDRBVVolzY2uhWb8jj1cYXJOQLeqatz27jHX9BwH5wVFl3tXFK+WqGP/SYcQQlhATXhHCG7/K9mzKy+on3aLvU2ymkDPDsp/ZNVQ+4ueGFU0D1Ytshuw44YyI41tYI4NZ000Jg4XikWLlvtN4rYp7y6+IT94QFH8EM0fAB6nD7cGrCnCExYR1FDFi0htU3CTJp9v/iiONxKjfnabLDSN483Pm0P/JsFrQsMDhKbyRX5kQpDfYNUQfBiLyTUEJmIFLRlBmGwMA4sVAm2k/mgP2b76RW+d3GDGA1N X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yREPdw56cPSzqlzIdH7ZgVYcGj7i/3sfbb6VddVLnF6TTnccSozvdui8cxhr5DoQjU3DwOsn7D0CPZOEfVgdAkPXwpDQrn3cDKkAsqQBj0ElXpDuQovIfSUMVVpHyJXK+yV3gFDXTYUaxSuy/TPOGN2ZMGkg3vC7lMM05H/j4QxI2KcsFFgnVOM/sIbXdAMEbDpGNkioQlKNrPMODVBwWe7A6pPo9b3MY+t60l/nKWaNKkoKY6HTkKvvTQuvK/wMQ8Fau4ua9U1u5vDpwaUaPb8fynT9FQ3CkouGv/bQ8f2zkqpf2gWCvNu+IZDkXGRXKOk8fK6CWkyoX39kjngJ/DjIATgEJ0O+C6h45oWU4W5YSi1642Mi7eyI+mdFKipRMmLCtmFexxhXUhftRX0rUsy2UY/zPunNrB8QEZEBkZMzi9IvXKO6QuPmBocYWEfwtTzneqVFO3zrBz6HSc+ToW2XmgbBWKaVdFX4t8x1AxDTGs/qsonMDRpu7mQw+MTn9GT6sKBdaZT2VXJP41rYLh0BAPvuy0wDTg1DN6nxaaFRogtbHkZAU1p6cbzkFdmqkVPL+ncGxkaW8TeUAHg9jI4M2Q+Ce/VLujusxdXv6vu2C13myVJhP5z14ZHVQIfkEwXTVNSbJ35fpYMnbviz1Nq9HOGLl3NdFWyxECl7D5d2BqVyDJxDgB+d2xjI9hAa9hhv4Szd5xmq+zki/y6mIJJlZI/Nr3bzDBuT7g4EUgi08Fl9+D/4Xns4kHpYEwlsatguyFCc0KWTA1du0thRYO1anpkWOTtjH3JTVWLeCbs3Hwmxm+GNPcgsT0ScQzAyM4K7/wCJwIReAKvlA3uiyhvwie6ONdDa++S7uO/sP5GGGY8SMt/o6ZLJozJ6kT+99yq+5cK3qUJ+rmh2DipyQWlRsyV2FpB8IeQWG4VJsPKhv7onGCP6q6HEOTdCZQc+fHsF4whJaSl6tXcJI5xrD/sNO6jK6Yf1Ls5BKe9e04r0BAYZh/O8OwB+7dgF7K7585dCSGfUyDwr6wB+pp9spz4GOyll6sMeohdufbfXP1/pFbj90xhMPTNs+KrnhzpFDzMIWDbv084JI4Kt2NU/vofNjfihjNd1cSQcWvz3Nm3esRhfwe/C390QExDhkppDu+HHwFEFPF4BxI4G/jyJHvTMfnETglXl4py15ADcF5cCYRgITqC4yr1cvNY0ZQlUnO/F1AtGSJ+lN5PXEWEqRlpEfDMuda9HudIl7LXjW3hxjmv9lQ11jR7YnCmcF80+fmq+33WGyn20FJgakCLtNi39YfWKivKrDcu1uZh50Ha0UVxgtllWGf+apGwnWpo91rCnrny8yoxChG5yRPIKWhZCK8uF1A/c/KPuIMLrDRb3vH9uylHi1M+3gldB4CJc/5vaeqCLScNlNB0tZn3uyU+ofPfWgwasRXl+r3H5pp3KoLmJ7gDXA19Uw2Xvg0cFPmBkR7iPMastQqLAs8o4Eh7VOyA0qf42MtF/TDYwRG5xRGHvTHbrhARjQ8oXzHf+bAo7ohcFLOP5dLw4rkB/fCQioJ5jcAD3yqc9PaTKC6zGiDLr0y6nvrmXJ69gGERX3YST70xJqF/Ixy3+BMCKx+jN447ytckedKBXaK+xyDY= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b2b63ab-fed9-40f3-9a3d-08dc9ff28b57 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:44.9805 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DANyWu8TerDCeGjBIPBPsgZnDiyfw9MDR0qUF0IUZksr13O2T60PRNpfNYr1xKPcyHfmJzs+3OI2Wn6pKvDNAexbeIsC0SjkyLJLXmy/UpUiqAiCrroGVL3Bn3R5PeRx X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 Add ISP params video device to write ISP parameters for 3A. Signed-off-by: Changhuang Liang --- drivers/staging/media/starfive/camss/Makefile | 2 + .../staging/media/starfive/camss/stf-camss.c | 23 +- .../staging/media/starfive/camss/stf-camss.h | 3 + .../media/starfive/camss/stf-isp-params.c | 240 ++++++++++++++++++ .../staging/media/starfive/camss/stf-isp.h | 4 + .../staging/media/starfive/camss/stf-output.c | 83 ++++++ .../staging/media/starfive/camss/stf-output.h | 22 ++ 7 files changed, 376 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/media/starfive/camss/stf-isp-params.c create mode 100644 drivers/staging/media/starfive/camss/stf-output.c create mode 100644 drivers/staging/media/starfive/camss/stf-output.h diff --git a/drivers/staging/media/starfive/camss/Makefile b/drivers/staging/media/starfive/camss/Makefile index 411b45f3fb52..077165cbba7a 100644 --- a/drivers/staging/media/starfive/camss/Makefile +++ b/drivers/staging/media/starfive/camss/Makefile @@ -9,6 +9,8 @@ starfive-camss-objs += \ stf-capture.o \ stf-isp.o \ stf-isp-hw-ops.o \ + stf-isp-params.o \ + stf-output.o \ stf-video.o obj-$(CONFIG_VIDEO_STARFIVE_CAMSS) += starfive-camss.o diff --git a/drivers/staging/media/starfive/camss/stf-camss.c b/drivers/staging/media/starfive/camss/stf-camss.c index fafa3ce2f6da..4b2288c3199c 100644 --- a/drivers/staging/media/starfive/camss/stf-camss.c +++ b/drivers/staging/media/starfive/camss/stf-camss.c @@ -128,6 +128,7 @@ static int stfcamss_register_devs(struct stfcamss *stfcamss) { struct stf_capture *cap_yuv = &stfcamss->captures[STF_CAPTURE_YUV]; struct stf_capture *cap_scd = &stfcamss->captures[STF_CAPTURE_SCD]; + struct stf_output *output = &stfcamss->output; struct stf_isp_dev *isp_dev = &stfcamss->isp_dev; int ret; @@ -138,13 +139,20 @@ static int stfcamss_register_devs(struct stfcamss *stfcamss) return ret; } - ret = stf_capture_register(stfcamss, &stfcamss->v4l2_dev); + ret = stf_output_register(stfcamss, &stfcamss->v4l2_dev); if (ret < 0) { dev_err(stfcamss->dev, "failed to register capture: %d\n", ret); goto err_isp_unregister; } + ret = stf_capture_register(stfcamss, &stfcamss->v4l2_dev); + if (ret < 0) { + dev_err(stfcamss->dev, + "failed to register capture: %d\n", ret); + goto err_out_unregister; + } + ret = media_create_pad_link(&isp_dev->subdev.entity, STF_ISP_PAD_SRC, &cap_yuv->video.vdev.entity, 0, 0); if (ret) @@ -159,13 +167,23 @@ static int stfcamss_register_devs(struct stfcamss *stfcamss) cap_scd->video.source_subdev = &isp_dev->subdev; + ret = media_create_pad_link(&output->video.vdev.entity, 0, + &isp_dev->subdev.entity, STF_ISP_PAD_SINK_PARAMS, + 0); + if (ret) + goto err_rm_links1; + return ret; +err_rm_links1: + media_entity_remove_links(&cap_scd->video.vdev.entity); err_rm_links0: media_entity_remove_links(&isp_dev->subdev.entity); media_entity_remove_links(&cap_yuv->video.vdev.entity); err_cap_unregister: stf_capture_unregister(stfcamss); +err_out_unregister: + stf_output_unregister(stfcamss); err_isp_unregister: stf_isp_unregister(&stfcamss->isp_dev); @@ -176,14 +194,17 @@ static void stfcamss_unregister_devs(struct stfcamss *stfcamss) { struct stf_capture *cap_yuv = &stfcamss->captures[STF_CAPTURE_YUV]; struct stf_capture *cap_scd = &stfcamss->captures[STF_CAPTURE_SCD]; + struct stf_output *output = &stfcamss->output; struct stf_isp_dev *isp_dev = &stfcamss->isp_dev; + media_entity_remove_links(&output->video.vdev.entity); media_entity_remove_links(&isp_dev->subdev.entity); media_entity_remove_links(&cap_yuv->video.vdev.entity); media_entity_remove_links(&cap_scd->video.vdev.entity); stf_isp_unregister(&stfcamss->isp_dev); stf_capture_unregister(stfcamss); + stf_output_unregister(stfcamss); } static int stfcamss_subdev_notifier_bound(struct v4l2_async_notifier *async, diff --git a/drivers/staging/media/starfive/camss/stf-camss.h b/drivers/staging/media/starfive/camss/stf-camss.h index ae49c7031ab7..3f84f1a1e997 100644 --- a/drivers/staging/media/starfive/camss/stf-camss.h +++ b/drivers/staging/media/starfive/camss/stf-camss.h @@ -21,6 +21,7 @@ #include "stf-buffer.h" #include "stf-isp.h" #include "stf-capture.h" +#include "stf-output.h" enum stf_port_num { STF_PORT_DVP = 0, @@ -55,6 +56,7 @@ struct stfcamss { struct device *dev; struct stf_isp_dev isp_dev; struct stf_capture captures[STF_CAPTURE_NUM]; + struct stf_output output; struct v4l2_async_notifier notifier; void __iomem *syscon_base; void __iomem *isp_base; @@ -132,4 +134,5 @@ static inline void stf_syscon_reg_clear_bit(struct stfcamss *stfcamss, value = ioread32(stfcamss->syscon_base + reg); iowrite32(value & ~bit_mask, stfcamss->syscon_base + reg); } + #endif /* STF_CAMSS_H */ diff --git a/drivers/staging/media/starfive/camss/stf-isp-params.c b/drivers/staging/media/starfive/camss/stf-isp-params.c new file mode 100644 index 000000000000..e015857815f0 --- /dev/null +++ b/drivers/staging/media/starfive/camss/stf-isp-params.c @@ -0,0 +1,240 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * stf-isp-params.c + * + * StarFive Camera Subsystem - V4L2 device node + * + * Copyright (C) 2021-2023 StarFive Technology Co., Ltd. + */ + +#include + +#include "stf-camss.h" +#include "stf-video.h" + +static inline struct stfcamss_buffer * +to_stfcamss_buffer(struct vb2_v4l2_buffer *vbuf) +{ + return container_of(vbuf, struct stfcamss_buffer, vb); +} + +static int stf_isp_params_queue_setup(struct vb2_queue *q, + unsigned int *num_buffers, + unsigned int *num_planes, + unsigned int sizes[], + struct device *alloc_devs[]) +{ + if (*num_planes) + return sizes[0] < sizeof(struct jh7110_isp_params_buffer) ? -EINVAL : 0; + + *num_planes = 1; + sizes[0] = sizeof(struct jh7110_isp_params_buffer); + + return 0; +} + +static int stf_isp_params_buf_init(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct stfcamss_buffer *buffer = to_stfcamss_buffer(vbuf); + dma_addr_t *paddr; + + paddr = vb2_plane_cookie(vb, 0); + buffer->addr[0] = *paddr; + buffer->vaddr = vb2_plane_vaddr(vb, 0); + + return 0; +} + +static int stf_isp_params_buf_prepare(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + + if (sizeof(struct jh7110_isp_params_buffer) > vb2_plane_size(vb, 0)) + return -EINVAL; + + vb2_set_plane_payload(vb, 0, sizeof(struct jh7110_isp_params_buffer)); + + vbuf->field = V4L2_FIELD_NONE; + + return 0; +} + +static void stf_isp_params_buf_queue(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct stfcamss_video *video = vb2_get_drv_priv(vb->vb2_queue); + struct stfcamss_buffer *buffer = to_stfcamss_buffer(vbuf); + + video->ops->queue_buffer(video, buffer); +} + +static void stf_isp_params_stop_streaming(struct vb2_queue *q) +{ + struct stfcamss_video *video = vb2_get_drv_priv(q); + + video->ops->flush_buffers(video, VB2_BUF_STATE_ERROR); +} + +static const struct vb2_ops stf_isp_params_vb2_q_ops = { + .queue_setup = stf_isp_params_queue_setup, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish = vb2_ops_wait_finish, + .buf_init = stf_isp_params_buf_init, + .buf_prepare = stf_isp_params_buf_prepare, + .buf_queue = stf_isp_params_buf_queue, + .stop_streaming = stf_isp_params_stop_streaming, +}; + +static int stf_isp_params_init_format(struct stfcamss_video *video) +{ + video->active_fmt.fmt.meta.dataformat = V4L2_META_FMT_STF_ISP_PARAMS; + video->active_fmt.fmt.meta.buffersize = sizeof(struct jh7110_isp_params_buffer); + + return 0; +} + +static int stf_isp_params_querycap(struct file *file, void *fh, + struct v4l2_capability *cap) +{ + strscpy(cap->driver, "starfive-camss", sizeof(cap->driver)); + strscpy(cap->card, "Starfive Camera Subsystem", sizeof(cap->card)); + + return 0; +} + +static int stf_isp_params_enum_fmt(struct file *file, void *priv, + struct v4l2_fmtdesc *f) +{ + struct stfcamss_video *video = video_drvdata(file); + + if (f->index > 0 || f->type != video->type) + return -EINVAL; + + f->pixelformat = video->active_fmt.fmt.meta.dataformat; + return 0; +} + +static int stf_isp_params_g_fmt(struct file *file, void *fh, struct v4l2_format *f) +{ + struct stfcamss_video *video = video_drvdata(file); + struct v4l2_meta_format *meta = &f->fmt.meta; + + if (f->type != video->type) + return -EINVAL; + + meta->dataformat = video->active_fmt.fmt.meta.dataformat; + meta->buffersize = video->active_fmt.fmt.meta.buffersize; + + return 0; +} + +static const struct v4l2_ioctl_ops stf_isp_params_ioctl_ops = { + .vidioc_querycap = stf_isp_params_querycap, + .vidioc_enum_fmt_meta_out = stf_isp_params_enum_fmt, + .vidioc_g_fmt_meta_out = stf_isp_params_g_fmt, + .vidioc_s_fmt_meta_out = stf_isp_params_g_fmt, + .vidioc_try_fmt_meta_out = stf_isp_params_g_fmt, + .vidioc_reqbufs = vb2_ioctl_reqbufs, + .vidioc_querybuf = vb2_ioctl_querybuf, + .vidioc_qbuf = vb2_ioctl_qbuf, + .vidioc_expbuf = vb2_ioctl_expbuf, + .vidioc_dqbuf = vb2_ioctl_dqbuf, + .vidioc_create_bufs = vb2_ioctl_create_bufs, + .vidioc_prepare_buf = vb2_ioctl_prepare_buf, + .vidioc_streamon = vb2_ioctl_streamon, + .vidioc_streamoff = vb2_ioctl_streamoff, +}; + +static const struct v4l2_file_operations stf_isp_params_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = video_ioctl2, + .open = v4l2_fh_open, + .release = vb2_fop_release, + .poll = vb2_fop_poll, + .mmap = vb2_fop_mmap, +}; + +static void stf_isp_params_release(struct video_device *vdev) +{ + struct stfcamss_video *video = video_get_drvdata(vdev); + + media_entity_cleanup(&vdev->entity); + + mutex_destroy(&video->q_lock); + mutex_destroy(&video->lock); +} + +int stf_isp_params_register(struct stfcamss_video *video, + struct v4l2_device *v4l2_dev, + const char *name) +{ + struct video_device *vdev = &video->vdev; + struct vb2_queue *q; + struct media_pad *pad = &video->pad; + int ret; + + mutex_init(&video->q_lock); + mutex_init(&video->lock); + + q = &video->vb2_q; + q->drv_priv = video; + q->mem_ops = &vb2_dma_contig_memops; + q->ops = &stf_isp_params_vb2_q_ops; + q->type = video->type; + q->io_modes = VB2_DMABUF | VB2_MMAP; + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; + q->buf_struct_size = sizeof(struct stfcamss_buffer); + q->dev = video->stfcamss->dev; + q->lock = &video->q_lock; + q->min_queued_buffers = STFCAMSS_MIN_BUFFERS; + ret = vb2_queue_init(q); + if (ret < 0) { + dev_err(video->stfcamss->dev, + "Failed to init vb2 queue: %d\n", ret); + goto err_mutex_destroy; + } + + pad->flags = MEDIA_PAD_FL_SOURCE; + ret = media_entity_pads_init(&vdev->entity, 1, pad); + if (ret < 0) { + dev_err(video->stfcamss->dev, + "Failed to init video entity: %d\n", ret); + goto err_mutex_destroy; + } + + ret = stf_isp_params_init_format(video); + if (ret < 0) { + dev_err(video->stfcamss->dev, + "Failed to init format: %d\n", ret); + goto err_media_cleanup; + } + vdev->ioctl_ops = &stf_isp_params_ioctl_ops; + vdev->device_caps = V4L2_CAP_META_OUTPUT; + vdev->fops = &stf_isp_params_fops; + vdev->device_caps |= V4L2_CAP_STREAMING | V4L2_CAP_IO_MC; + vdev->vfl_dir = VFL_DIR_TX; + vdev->release = stf_isp_params_release; + vdev->v4l2_dev = v4l2_dev; + vdev->queue = &video->vb2_q; + vdev->lock = &video->lock; + strscpy(vdev->name, name, sizeof(vdev->name)); + + video_set_drvdata(vdev, video); + + ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1); + if (ret < 0) { + dev_err(video->stfcamss->dev, + "Failed to register video device: %d\n", ret); + goto err_media_cleanup; + } + + return 0; + +err_media_cleanup: + media_entity_cleanup(&vdev->entity); +err_mutex_destroy: + mutex_destroy(&video->lock); + mutex_destroy(&video->q_lock); + return ret; +} diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h index eca3ba1ade75..76ea943bfe98 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.h +++ b/drivers/staging/media/starfive/camss/stf-isp.h @@ -474,4 +474,8 @@ void stf_set_scd_addr(struct stfcamss *stfcamss, dma_addr_t yhist_addr, dma_addr_t scd_addr, enum stf_isp_type_scd type_scd); +int stf_isp_params_register(struct stfcamss_video *video, + struct v4l2_device *v4l2_dev, + const char *name); + #endif /* STF_ISP_H */ diff --git a/drivers/staging/media/starfive/camss/stf-output.c b/drivers/staging/media/starfive/camss/stf-output.c new file mode 100644 index 000000000000..8eaf4979cafa --- /dev/null +++ b/drivers/staging/media/starfive/camss/stf-output.c @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * StarFive Camera Subsystem - output device + * + * Copyright (C) 2023 StarFive Technology Co., Ltd. + */ + +#include "stf-camss.h" + +static inline struct stf_output *to_stf_output(struct stfcamss_video *video) +{ + return container_of(video, struct stf_output, video); +} + +static int stf_output_queue_buffer(struct stfcamss_video *video, + struct stfcamss_buffer *buf) +{ + struct stf_output *output = to_stf_output(video); + struct stf_v_buf *v_bufs = &output->buffers; + unsigned long flags; + + spin_lock_irqsave(&v_bufs->lock, flags); + stf_buf_add_ready(v_bufs, buf); + spin_unlock_irqrestore(&v_bufs->lock, flags); + + return 0; +} + +static int stf_output_flush_buffers(struct stfcamss_video *video, + enum vb2_buffer_state state) +{ + struct stf_output *output = to_stf_output(video); + struct stf_v_buf *v_bufs = &output->buffers; + unsigned long flags; + + spin_lock_irqsave(&v_bufs->lock, flags); + stf_buf_flush(v_bufs, state); + spin_unlock_irqrestore(&v_bufs->lock, flags); + + return 0; +} + +static const struct stfcamss_video_ops stf_output_ops = { + .queue_buffer = stf_output_queue_buffer, + .flush_buffers = stf_output_flush_buffers, +}; + +static void stf_output_init(struct stfcamss *stfcamss, struct stf_output *out) +{ + out->buffers.state = STF_OUTPUT_OFF; + out->buffers.buf[0] = NULL; + out->buffers.buf[1] = NULL; + out->buffers.active_buf = 0; + INIT_LIST_HEAD(&out->buffers.pending_bufs); + INIT_LIST_HEAD(&out->buffers.ready_bufs); + spin_lock_init(&out->buffers.lock); + + out->video.stfcamss = stfcamss; + out->video.type = V4L2_BUF_TYPE_META_OUTPUT; +} + +void stf_output_unregister(struct stfcamss *stfcamss) +{ + struct stf_output *output = &stfcamss->output; + + if (!video_is_registered(&output->video.vdev)) + return; + + media_entity_cleanup(&output->video.vdev.entity); + vb2_video_unregister_device(&output->video.vdev); +} + +int stf_output_register(struct stfcamss *stfcamss, + struct v4l2_device *v4l2_dev) +{ + struct stf_output *output = &stfcamss->output; + + output->video.ops = &stf_output_ops; + stf_output_init(stfcamss, output); + stf_isp_params_register(&output->video, v4l2_dev, "output_params"); + + return 0; +} diff --git a/drivers/staging/media/starfive/camss/stf-output.h b/drivers/staging/media/starfive/camss/stf-output.h new file mode 100644 index 000000000000..d3591a0b609b --- /dev/null +++ b/drivers/staging/media/starfive/camss/stf-output.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Starfive Camera Subsystem driver + * + * Copyright (C) 2023 StarFive Technology Co., Ltd. + */ + +#ifndef STF_OUTPUT_H +#define STF_OUTPUT_H + +#include "stf-video.h" + +struct stf_output { + struct stfcamss_video video; + struct stf_v_buf buffers; +}; + +int stf_output_register(struct stfcamss *stfcamss, + struct v4l2_device *v4l2_dev); +void stf_output_unregister(struct stfcamss *stfcamss); + +#endif From patchwork Tue Jul 9 08:38:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727446 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2104.outbound.protection.partner.outlook.cn [139.219.146.104]) (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 428DD1553AA; Tue, 9 Jul 2024 08:40:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.104 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514410; cv=fail; b=ZaInfZ2Jw6my3PbM6Mczeg/YOHaiPmil7ZBlUF9w86SZxYByCuj42NGtp6moedCVGGyYmpIGRrH/4i7G4fYwEZVqiYvKmJSQkcf9OX2c15t9gzWf+Ad0EgMduM6XeVPvc5wnNj/3+jCTtxGU/nAwAsmUpVMR+HlFK5GK159kS10= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514410; c=relaxed/simple; bh=IZR271Z9L/LCP8WXziUR04qxg9o8HMj5O53fstadKIA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=XIzNVaZQifft34B9WJkuKbrWXrQq57LB7e+PNzfXhPS35FBuPmfDeYOX82B4zy0o69fbJn5bI/g0I7P4dJpDY9iddQXxcLwxIV7ZF1rs97L6SbZVaHucq1wqHKqbyPC5Z/S1ZuUN6lHGQNtvEcq2eZseNqOb6iOm2ytz2dtUaS0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.104 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WhCOn3SD6Akhm/Z7USToGbe0DjQlAPmnXikDuswuz8FP6PvSjsFesZ3Ei1LMnmKSQsCzo8rDu1lhij90gFray92yPAizH9ySvRGEWDfjjBK9V05RTYaXVA3gd0q/OB4GZSmUcrQb3hT37CbfcT97tPhqvUzcYZyG3wmfbjAf5hV8oeUR29zZt/M44cEN1aNX/maNuQaOjpuvUpn47yr2LBEfWEK0XlpTLLX+GIo20crpWHqJKZGhil63wXig3+Ym+9BKIdr5LneCY/lxLvzN3FPeps2YcxY1rU5oDvpP5uKIpjMWJoDekhVtRUHaZu4g8EnxcXr4l0gui5I1bG8zeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DSU67noKEm/zCC2luXSFb1H/bnIrgY+i6RMPDptYL6E=; b=jak9B11oIiamqpSW2SWcK5cWuOOKPNL7hIgGMnomPFpWtWEmHsFMKBGEarMqykTzecDbDzRuMTZPaO2axi1BXmLrvfe38mIi28HWORPJxkrAVaW2dImfEbjtIkVDMEpsKCzxFu9nudfY3MBvHvPevTHGYT5mnF95T0VeKYAz6qy+Oyha4dczOlNMVC5lTIUIS5WvAqqahzm5ptq8+wZIM9Cp/UECpf4G8glsIIYcksR9pS5a7gIdLUxvcaEgH2f4gG8VvraXNMUN5uqYy57ZwcoHSRycfHzSn2poYzqfRRS8J67Dck64If1JmNt8xQE3QS/2obn/DNhwYDyVJ+HaCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:46 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:46 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 12/14] staging: media: starfive: Add ISP parameters hardware configure Date: Tue, 9 Jul 2024 01:38:22 -0700 Message-Id: <20240709083824.430473-13-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: b7dcbebd-7420-43d9-366d-08dc9ff28c0b X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: VyImPnE9MhHCtAIWW3xowbDe7NBIeYParcM4neCtb7x6lV3wPj+npBguD8Td4ixFuHT2ijKqOOULZUVQVpdnbj7F+yddnpfggTNt/LiX9wCm7BVcnTdiBUKJkd6szrkbha6pbhEEL+G+saDy9vsoPcaW4uq0jnswoPDArc1QHAvvKK8FwoFf0Szo+NA2I1hOhPCea1+xwTKQ4j1KUryNw0fvqfRs6rRlgVIJ0QqP30Bd7oYZq7TZ95lLXFA5yCFzN/RlUHCOIoEhgMLWyR/iVhnwyLnuYtihTMxgRHcIjadPNrwvDmKHtR/+10mMUxPfuTSbBtokV9Mn7Nbv/9XEw6IUW0Rt5kYYAP8RDHecAWSD6C6F9uz59t3dwA6tM9+ZKSougI46rkMK8WL3oHRZhB3vNPVL0k00YuQGyfqtP9vLv16wXEQD/N97syctOzo4bPnVkRIvNWwJ+nlecFb10efftHqBaNuxKrLkMuqHW34FIKwKJVXXJfUfwFLREuEA02unTQcjav6D1LyYBx1GrwfJ8ryYRX6CzYPtuEDQ+v4sN5ZBq/FT3HZ2sB/bhVy7/N5QvCMm6WXAc8b8gDaniddk5QPgCJrs6v4e+TxCYW3CVkSy+Bx67k/wmgrNryWs X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NnEgVmjnhF0jjiE3DCUTuqrp1yHqqiDSvBr4COoBU87PhZKfJnYsF21m9mUKsoFmdsrTMWsK5AfQ7C0qUBhI7YPm0HJIAbTpc8Xz1WK5c7Pp92AZCoPWBktcboL+ityOHvnC+V5jruT5D8goxssG7Wd0l04DWnKLv4Vf2rWnVjWKZGDCJamoEzpxRgDTV0wDlKf4hcgGBKnubaV1DwED0/os8SeF2UlRUViqNqjqKocTxC6QN764VV8MzG354qqZLlfTDtDIzoRwF83mNHHZ9jCI4+BwkKiqBqUGNMAhYDCdV7WIeXlh0Sv8EyE3JeChl6ymSjIXmKaVcWpbl380VCxXa+wrdMN2KLJIMcgqoJcgnCyDb0Tyz6l6PeMu/2A0DAScekBEfH64h7Cvvwdf0NYgf4HeUOrA/bu8180A3fxBM1nsUnfv1VKnoCX8nfWBm98oXiIVZNXWG0x2oY5L/GXtni9f7qGce7irelj4XIj6nvI1CgnIBZaPXcmd7aeU30F1DbvA8jxjEb8hNqEpFbVszrp5rFI+zx6yizUBYkQV7/J9ZjACGs1a3inI99KGwmaQKEc+R0Po32KcNLNiI4ho+1ODJbje9sGL1jDrsoKY0xY0uor+EWiQVfLBhQ5P5USIBRzTAOtwWbWsbXmT1IpUO2TXphjdbhwBaT2ISFbQ3HpfkwvSS80OQlZMNfsWa7VU73MlCNX044chRA35CsVMRT8nk6rPlOSp+3sb2hAgGPsNjiEGT5+GTxh06Nha7meChShlw4RM1MeD+v4R31UmvOjb+4YaTep2MaG+N9tVRnWDUGH579hZBimn9aKTmEJqKqovNMbdr4QiUwBQGZxOyOS24zWOU8xYUpM4DexXDmic1NUXeotx3zdmzc9n6jksXsexX2h/QIV0TtXgrCfajI7rpOujU3nKGr6OjMY8BNl78EaeRnOWU4+iLwvtpgSaTRgA3x9pr2HXYvCqhtJLN3gGBCs78TGbDS8XUKzZ7UYOBfKGUOiB1wt9kzTBvSb8Chc+SDXBwH43TCiDZDH6ZKreXjrc/SiHPCZTXlSJRtkutd5Op84WZPigAFqr6GA2Z8nKIbQ/L3bUXnsub4Sb7l1biTW5FyJtXMa7uTAQ+tIdV3cCO7Yh9NMwP4HAQoLNPHmdRx1blgR9uJm/cuT2hfR6flHJ92xpOWGMd4qoM4i1MM+B7A1ADAlHufDfjLi4DBK/2bU/Rek4CtOBOzU0wDjemNA51xXoVxOmotoJnQhCrovlMyUxS/xj1L82y8OWO1TenUWhswGM3nZPrnGlinoB8irPeUo192tvkGwxP2RCx5ufD8otdWsMimSP94CTdEOq5hhj/C1nFOA+LiWGe3sg6LnJQxt62KGBdPo0H5+Ctjth5/UMH4PDLmqg+PTyLFjuQE/vWDrHoZUQSko1xwUYSB/RzqFde+2huVhcbFqR0Dhad2E9sLvRBYAgCpI6VxUIKkdageYN3GijsodMdppXbEFOulpeqPFVmMQ9QlY5+NdVYs6ag1YMMcR7vFFtyRh6zbj3QaWhGeecq+SG7jJGHGUKECOVuwZJOv8BLNQhEjvIrWvSVYl+vHs4KBBnMdYZL3wPuezQtJnPUbl9n7rSIoJcF7cCPYr7wwI= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7dcbebd-7420-43d9-366d-08dc9ff28c0b X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:46.1800 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tFx2+IBw/8VA+bcRk+GWdNbR5ImtvcyiJIBtEprWxfiiKe6Oqkrj1k7f+waMPdmEERClBaPj2CD7OOzvmWbU/L9Dj5lVi9B69XZrDYd+5nDb8kn1MoMltmE5rUq+9u+W X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 Add ISP parameters hardware configure. Signed-off-by: Changhuang Liang --- .../staging/media/starfive/camss/stf-camss.h | 8 + .../media/starfive/camss/stf-isp-hw-ops.c | 573 ++++++++++++++++++ .../staging/media/starfive/camss/stf-isp.h | 135 +++++ 3 files changed, 716 insertions(+) diff --git a/drivers/staging/media/starfive/camss/stf-camss.h b/drivers/staging/media/starfive/camss/stf-camss.h index 3f84f1a1e997..328318d61c6b 100644 --- a/drivers/staging/media/starfive/camss/stf-camss.h +++ b/drivers/staging/media/starfive/camss/stf-camss.h @@ -106,6 +106,14 @@ static inline void stf_isp_reg_set(struct stfcamss *stfcamss, u32 reg, u32 mask) stfcamss->isp_base + reg); } +static inline void stf_isp_reg_fill_zero(struct stfcamss *stfcamss, u32 reg, u32 size) +{ + u32 i; + + for (i = 0; i < size; i++, reg += 4) + iowrite32(0, stfcamss->isp_base + reg); +} + static inline u32 stf_syscon_reg_read(struct stfcamss *stfcamss, u32 reg) { return ioread32(stfcamss->syscon_base + reg); diff --git a/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c b/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c index 0bc5e36f952e..e54368910906 100644 --- a/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c +++ b/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c @@ -10,6 +10,25 @@ #include "stf-camss.h" +static const struct stf_isp_module_info mod_info[] = { + { ISP_REG_CSI_MODULE_CFG, 2 }, + { ISP_REG_CSI_MODULE_CFG, 4 }, + { ISP_REG_CSI_MODULE_CFG, 6 }, + { ISP_REG_CSI_MODULE_CFG, 7 }, + { ISP_REG_CSI_MODULE_CFG, 17 }, + { ISP_REG_ISP_CTRL_1, 1 }, + { ISP_REG_ISP_CTRL_1, 2 }, + { ISP_REG_ISP_CTRL_1, 3 }, + { ISP_REG_ISP_CTRL_1, 4 }, + { ISP_REG_ISP_CTRL_1, 5 }, + { ISP_REG_ISP_CTRL_1, 7 }, + { ISP_REG_ISP_CTRL_1, 8 }, + { ISP_REG_ISP_CTRL_1, 17 }, + { ISP_REG_ISP_CTRL_1, 19 }, + { ISP_REG_ISP_CTRL_1, 21 }, + { ISP_REG_ISP_CTRL_1, 22 }, +}; + static void stf_isp_config_obc(struct stfcamss *stfcamss) { u32 reg_val, reg_add; @@ -517,6 +536,59 @@ static void stf_isp_fill_flag(struct stfcamss *stfcamss, void *vaddr, } } +static void stf_isp_set_params(struct stfcamss *stfcamss, void *vaddr) +{ + struct jh7110_isp_params_buffer *params = (struct jh7110_isp_params_buffer *)vaddr; + + if (params->enable_setting & JH7110_ISP_MODULE_WB_SETTING) + isp_set_ctrl_wb(stfcamss, ¶ms->wb_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_CAR_SETTING) + isp_set_ctrl_car(stfcamss, ¶ms->car_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_CCM_SETTING) + isp_set_ctrl_ccm(stfcamss, ¶ms->ccm_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_CFA_SETTING) + isp_set_ctrl_cfa(stfcamss, ¶ms->cfa_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_CTC_SETTING) + isp_set_ctrl_ctc(stfcamss, ¶ms->ctc_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_DBC_SETTING) + isp_set_ctrl_dbc(stfcamss, ¶ms->dbc_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_DNYUV_SETTING) + isp_set_ctrl_dnyuv(stfcamss, ¶ms->dnyuv_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_GMARGB_SETTING) + isp_set_ctrl_gmargb(stfcamss, ¶ms->gmargb_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_LCCF_SETTING) + isp_set_ctrl_lccf(stfcamss, ¶ms->lccf_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_OBC_SETTING) + isp_set_ctrl_obc(stfcamss, ¶ms->obc_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_OECF_SETTING) + isp_set_ctrl_oecf(stfcamss, ¶ms->oecf_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_R2Y_SETTING) + isp_set_ctrl_r2y(stfcamss, ¶ms->r2y_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_SAT_SETTING) + isp_set_ctrl_sat(stfcamss, ¶ms->sat_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_SHARP_SETTING) + isp_set_ctrl_sharp(stfcamss, ¶ms->sharp_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_YCRV_SETTING) + isp_set_ctrl_ycrv(stfcamss, ¶ms->ycrv_setting); + + if (params->enable_setting & JH7110_ISP_MODULE_SC_SETTING) + isp_set_ctrl_sc(stfcamss, ¶ms->sc_setting); +} + irqreturn_t stf_line_irq_handler(int irq, void *priv) { struct stfcamss *stfcamss = priv; @@ -566,11 +638,20 @@ irqreturn_t stf_isp_irq_handler(int irq, void *priv) struct stfcamss *stfcamss = priv; struct stf_capture *cap = &stfcamss->captures[STF_CAPTURE_YUV]; struct stf_capture *cap_scd = &stfcamss->captures[STF_CAPTURE_SCD]; + struct stf_output *output = &stfcamss->output; struct stfcamss_buffer *ready_buf; u32 status; status = stf_isp_reg_read(stfcamss, ISP_REG_ISP_CTRL_0); if (status & ISPC_ISP) { + ready_buf = stf_buf_get_ready(&output->buffers); + if (ready_buf) { + stf_isp_set_params(stfcamss, ready_buf->vaddr); + ready_buf->vb.vb2_buf.timestamp = ktime_get_ns(); + ready_buf->vb.sequence = output->buffers.sequence++; + vb2_buffer_done(&ready_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + } + if (status & ISPC_ENUO) { ready_buf = stf_buf_done(&cap->buffers); if (ready_buf) @@ -591,4 +672,496 @@ irqreturn_t stf_isp_irq_handler(int irq, void *priv) } return IRQ_HANDLED; +}; + +int isp_set_ctrl_wb(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_awb]; + const struct jh7110_isp_wb_setting *setting = + (const struct jh7110_isp_wb_setting *)value; + const struct jh7110_isp_wb_gain *gains = &setting->gains; + + stf_isp_reg_fill_zero(stfcamss, ISP_REG_AWB_X0_CFG_0, 16); + + stf_isp_reg_write(stfcamss, ISP_REG_AWB_S0_CFG_0, + AWB_S_SYMBOL_H(gains->gain_r) | AWB_S_SYMBOL_L(gains->gain_r)); + stf_isp_reg_write(stfcamss, ISP_REG_AWB_S0_CFG_1, + AWB_S_SYMBOL_H(gains->gain_r) | AWB_S_SYMBOL_L(gains->gain_r)); + stf_isp_reg_write(stfcamss, ISP_REG_AWB_S1_CFG_0, + AWB_S_SYMBOL_H(gains->gain_g) | AWB_S_SYMBOL_L(gains->gain_g)); + stf_isp_reg_write(stfcamss, ISP_REG_AWB_S1_CFG_1, + AWB_S_SYMBOL_H(gains->gain_g) | AWB_S_SYMBOL_L(gains->gain_g)); + stf_isp_reg_write(stfcamss, ISP_REG_AWB_S2_CFG_0, + AWB_S_SYMBOL_H(gains->gain_g) | AWB_S_SYMBOL_L(gains->gain_g)); + stf_isp_reg_write(stfcamss, ISP_REG_AWB_S2_CFG_1, + AWB_S_SYMBOL_H(gains->gain_g) | AWB_S_SYMBOL_L(gains->gain_g)); + stf_isp_reg_write(stfcamss, ISP_REG_AWB_S3_CFG_0, + AWB_S_SYMBOL_H(gains->gain_b) | AWB_S_SYMBOL_L(gains->gain_b)); + stf_isp_reg_write(stfcamss, ISP_REG_AWB_S3_CFG_1, + AWB_S_SYMBOL_H(gains->gain_b) | AWB_S_SYMBOL_L(gains->gain_b)); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_car(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_car]; + const struct jh7110_isp_car_setting *setting = + (const struct jh7110_isp_car_setting *)value; + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_ccm(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_ccm]; + const struct jh7110_isp_ccm_setting *setting = + (const struct jh7110_isp_ccm_setting *)value; + const struct jh7110_isp_ccm_smlow *ccm = &setting->ccm_smlow; + + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_0, DNRM_F(6)); + stf_isp_reg_fill_zero(stfcamss, ISP_REG_ICAMD_1, 11); + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_12, ccm->ccm[0][0]); + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_13, ccm->ccm[0][1]); + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_14, ccm->ccm[0][2]); + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_15, ccm->ccm[1][0]); + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_16, ccm->ccm[1][1]); + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_17, ccm->ccm[1][2]); + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_18, ccm->ccm[2][0]); + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_19, ccm->ccm[2][1]); + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_20, ccm->ccm[2][2]); + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_21, ccm->offsets[0]); + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_22, ccm->offsets[1]); + stf_isp_reg_write(stfcamss, ISP_REG_ICAMD_23, ccm->offsets[2]); + stf_isp_reg_fill_zero(stfcamss, ISP_REG_ICAMD_24, 2); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_cfa(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_cfa]; + const struct jh7110_isp_cfa_setting *setting = + (const struct jh7110_isp_cfa_setting *)value; + const struct jh7110_isp_cfa_params *cfa = &setting->settings; + + stf_isp_reg_write(stfcamss, ISP_REG_ICFAM, + HV_W(cfa->hv_width) | CROSS_COV(cfa->cross_cov)); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_ctc(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_ctc]; + const struct jh7110_isp_ctc_setting *setting = + (const struct jh7110_isp_ctc_setting *)value; + const struct jh7110_isp_ctc_params *ctc = &setting->settings; + + stf_isp_reg_write(stfcamss, ISP_REG_ICTC, + MINGT(ctc->min_gt) | MAXGT(ctc->max_gt) | + GF_MODE(ctc->saf_mode | ctc->daf_mode)); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_dbc(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_dbc]; + const struct jh7110_isp_dbc_setting *setting = + (const struct jh7110_isp_dbc_setting *)value; + const struct jh7110_isp_dbc_params *dbc = &setting->settings; + + stf_isp_reg_write(stfcamss, ISP_REG_IDBC, + BADXT(dbc->bad_xt) | BADGT(dbc->bad_gt)); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_dnyuv(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_dnyuv]; + const struct jh7110_isp_dnyuv_setting *setting = + (const struct jh7110_isp_dnyuv_setting *)value; + const struct jh7110_isp_dnyuv_params *cfg = &setting->settings; + + stf_isp_reg_write(stfcamss, ISP_REG_DNYUV_YSWR0, + YUVSW0(cfg->y_sweight[0]) | YUVSW1(cfg->y_sweight[1]) | + YUVSW2(cfg->y_sweight[2]) | YUVSW3(cfg->y_sweight[3]) | + YUVSW4(cfg->y_sweight[4]) | YUVSW5(cfg->y_sweight[5])); + stf_isp_reg_write(stfcamss, ISP_REG_DNYUV_YSWR1, + YUVSW0(cfg->y_sweight[6]) | YUVSW1(cfg->y_sweight[7]) | + YUVSW2(cfg->y_sweight[8]) | YUVSW3(cfg->y_sweight[9])); + stf_isp_reg_write(stfcamss, ISP_REG_DNYUV_CSWR0, + YUVSW0(cfg->uv_sweight[0]) | YUVSW1(cfg->uv_sweight[1]) | + YUVSW2(cfg->uv_sweight[2]) | YUVSW3(cfg->uv_sweight[3]) | + YUVSW4(cfg->uv_sweight[4]) | YUVSW5(cfg->uv_sweight[5])); + stf_isp_reg_write(stfcamss, ISP_REG_DNYUV_CSWR1, + YUVSW0(cfg->uv_sweight[6]) | YUVSW1(cfg->uv_sweight[7]) | + YUVSW2(cfg->uv_sweight[8]) | YUVSW3(cfg->uv_sweight[9])); + stf_isp_reg_write(stfcamss, ISP_REG_DNYUV_YDR0, + CURVE_D_L(cfg->y_curve[0]) | CURVE_D_H(cfg->y_curve[1])); + stf_isp_reg_write(stfcamss, ISP_REG_DNYUV_YDR1, + CURVE_D_L(cfg->y_curve[2]) | CURVE_D_H(cfg->y_curve[3])); + stf_isp_reg_write(stfcamss, ISP_REG_DNYUV_YDR2, + CURVE_D_L(cfg->y_curve[4]) | CURVE_D_H(cfg->y_curve[5])); + stf_isp_reg_write(stfcamss, ISP_REG_DNYUV_CDR0, + CURVE_D_L(cfg->uv_curve[0]) | CURVE_D_H(cfg->uv_curve[1])); + stf_isp_reg_write(stfcamss, ISP_REG_DNYUV_CDR1, + CURVE_D_L(cfg->uv_curve[2]) | CURVE_D_H(cfg->uv_curve[3])); + stf_isp_reg_write(stfcamss, ISP_REG_DNYUV_CDR2, + CURVE_D_L(cfg->uv_curve[4]) | CURVE_D_H(cfg->uv_curve[5])); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_gmargb(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_gmargb]; + const struct jh7110_isp_gmargb_setting *setting = + (const struct jh7110_isp_gmargb_setting *)value; + const struct jh7110_isp_gmargb_point *curve = setting->curve; + u32 reg_addr = ISP_REG_GAMMA_VAL0; + u32 i; + + for (i = 0; i < 15; i++, reg_addr += 4) + stf_isp_reg_write(stfcamss, reg_addr, + GAMMA_S_VAL(curve[i].sg_val) | GAMMA_VAL(curve[i].g_val)); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_lccf(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_lccf]; + const struct jh7110_isp_lccf_setting *setting = + (const struct jh7110_isp_lccf_setting *)value; + const struct jh7110_isp_lccf_circle *circle = &setting->circle; + const struct jh7110_isp_lccf_curve_param *r_param = &setting->r_param; + const struct jh7110_isp_lccf_curve_param *gr_param = &setting->gr_param; + const struct jh7110_isp_lccf_curve_param *gb_param = &setting->gb_param; + const struct jh7110_isp_lccf_curve_param *b_param = &setting->b_param; + + stf_isp_reg_write(stfcamss, ISP_REG_LCCF_CFG_0, + Y_DISTANCE(circle->center_y) | X_DISTANCE(circle->center_x)); + stf_isp_reg_write(stfcamss, ISP_REG_LCCF_CFG_1, + LCCF_MAX_DIS(circle->radius)); + stf_isp_reg_write(stfcamss, ISP_REG_LCCF_CFG_2, + LCCF_F1_PAR(r_param->f1) | LCCF_F2_PAR(r_param->f2)); + stf_isp_reg_write(stfcamss, ISP_REG_LCCF_CFG_3, + LCCF_F1_PAR(gr_param->f1) | LCCF_F2_PAR(gr_param->f2)); + stf_isp_reg_write(stfcamss, ISP_REG_LCCF_CFG_4, + LCCF_F1_PAR(gb_param->f1) | LCCF_F2_PAR(gb_param->f2)); + stf_isp_reg_write(stfcamss, ISP_REG_LCCF_CFG_5, + LCCF_F1_PAR(b_param->f1) | LCCF_F2_PAR(b_param->f2)); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_obc(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_obc]; + const struct jh7110_isp_obc_setting *setting = + (const struct jh7110_isp_obc_setting *)value; + const struct jh7110_isp_obc_win_size *win_size = &setting->win_size; + const struct jh7110_isp_obc_gain *gain = setting->gain; + const struct jh7110_isp_obc_offset *offset = setting->offset; + + stf_isp_reg_write(stfcamss, ISP_REG_OBC_CFG, + OBC_W_W(win_size->width) | OBC_W_H(win_size->height)); + stf_isp_reg_write(stfcamss, ISP_REG_OBCG_CFG_0, + GAIN_A_POINT(gain[0].tl_gain) | GAIN_B_POINT(gain[0].tr_gain) | + GAIN_C_POINT(gain[0].bl_gain) | GAIN_D_POINT(gain[0].br_gain)); + stf_isp_reg_write(stfcamss, ISP_REG_OBCG_CFG_1, + GAIN_A_POINT(gain[1].tl_gain) | GAIN_B_POINT(gain[1].tr_gain) | + GAIN_C_POINT(gain[1].bl_gain) | GAIN_D_POINT(gain[1].br_gain)); + stf_isp_reg_write(stfcamss, ISP_REG_OBCG_CFG_2, + GAIN_A_POINT(gain[2].tl_gain) | GAIN_B_POINT(gain[2].tr_gain) | + GAIN_C_POINT(gain[2].bl_gain) | GAIN_D_POINT(gain[2].br_gain)); + stf_isp_reg_write(stfcamss, ISP_REG_OBCG_CFG_3, + GAIN_A_POINT(gain[3].tl_gain) | GAIN_B_POINT(gain[3].tr_gain) | + GAIN_C_POINT(gain[3].bl_gain) | GAIN_D_POINT(gain[3].br_gain)); + stf_isp_reg_write(stfcamss, ISP_REG_OBCO_CFG_0, + OFFSET_A_POINT(offset[0].tl_offset) | + OFFSET_B_POINT(offset[0].tr_offset) | + OFFSET_C_POINT(offset[0].bl_offset) | + OFFSET_D_POINT(offset[0].br_offset)); + stf_isp_reg_write(stfcamss, ISP_REG_OBCO_CFG_1, + OFFSET_A_POINT(offset[1].tl_offset) | + OFFSET_B_POINT(offset[1].tr_offset) | + OFFSET_C_POINT(offset[1].bl_offset) | + OFFSET_D_POINT(offset[1].br_offset)); + stf_isp_reg_write(stfcamss, ISP_REG_OBCO_CFG_2, + OFFSET_A_POINT(offset[2].tl_offset) | + OFFSET_B_POINT(offset[2].tr_offset) | + OFFSET_C_POINT(offset[2].bl_offset) | + OFFSET_D_POINT(offset[2].br_offset)); + stf_isp_reg_write(stfcamss, ISP_REG_OBCO_CFG_3, + OFFSET_A_POINT(offset[3].tl_offset) | + OFFSET_B_POINT(offset[3].tr_offset) | + OFFSET_C_POINT(offset[3].bl_offset) | + OFFSET_D_POINT(offset[3].br_offset)); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_oecf(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_oecf]; + const struct jh7110_isp_oecf_setting *setting = + (const struct jh7110_isp_oecf_setting *)value; + const struct jh7110_isp_oecf_point *oecf = setting->r_curve; + u32 reg_x_addr = ISP_REG_OECF_X0_CFG0; + u32 reg_y_addr = ISP_REG_OECF_Y0_CFG0; + u32 reg_s_addr = ISP_REG_OECF_S0_CFG0; + u32 i; + + for (i = 0; i < 64; i += 2, reg_x_addr += 4, reg_y_addr += 4, reg_s_addr += 4) { + stf_isp_reg_write(stfcamss, reg_x_addr, + OCEF_PAR_L(oecf[i].x) | OCEF_PAR_H(oecf[i + 1].x)); + stf_isp_reg_write(stfcamss, reg_y_addr, + OCEF_PAR_L(oecf[i].y) | OCEF_PAR_H(oecf[i + 1].y)); + stf_isp_reg_write(stfcamss, reg_s_addr, + OCEF_PAR_L(oecf[i].slope) | OCEF_PAR_H(oecf[i + 1].slope)); + } + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_r2y(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_r2y]; + const struct jh7110_isp_r2y_setting *setting = + (const struct jh7110_isp_r2y_setting *)value; + const struct jh7110_isp_r2y_matrix *matrix = &setting->matrix; + u32 reg_addr = ISP_REG_R2Y_0; + u32 i; + + for (i = 0; i < 9; i++, reg_addr += 4) + stf_isp_reg_write(stfcamss, reg_addr, matrix->m[i]); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_sat(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_sat]; + const struct jh7110_isp_sat_setting *setting = + (const struct jh7110_isp_sat_setting *)value; + const struct jh7110_isp_sat_info *sat = &setting->sat_info; + const struct jh7110_isp_sat_hue_info *hue = &setting->hue_info; + const struct jh7110_isp_sat_curve *curve = &setting->curve; + + stf_isp_reg_write(stfcamss, ISP_REG_CS_GAIN, + CMAB(sat->gain_cmab) | CMAD(sat->gain_cmmd)); + stf_isp_reg_write(stfcamss, ISP_REG_CS_THRESHOLD, + CMB(sat->threshold_cmb) | CMD(sat->threshold_cmd)); + stf_isp_reg_write(stfcamss, ISP_REG_CS_OFFSET, + UOFF(sat->offset_u) | VOFF(sat->offset_v)); + stf_isp_reg_write(stfcamss, ISP_REG_CS_SCALE, sat->cmsf); + stf_isp_reg_write(stfcamss, ISP_REG_CS_HUE_F, + COS(hue->cos) | SIN(hue->sin)); + stf_isp_reg_write(stfcamss, ISP_REG_YADJ0, + YIMIN(curve->yi_min) | YOIR(curve->yo_ir)); + stf_isp_reg_write(stfcamss, ISP_REG_YADJ1, + YOMIN(curve->yo_min) | YOMAX(curve->yo_max)); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_sharp(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_shrp]; + const struct jh7110_isp_sharp_setting *setting = + (const struct jh7110_isp_sharp_setting *)value; + const struct jh7110_isp_sharp_weight *weight = &setting->weight; + const struct jh7110_isp_sharp_strength *strength = &setting->strength; + u32 reg_addr = ISP_REG_SHARPEN0; + u32 i; + + for (i = 0; i < 4; i++, reg_addr += 4) + stf_isp_reg_write(stfcamss, reg_addr, + S_WEIGHT(weight->weight[i]) | S_DELTA(strength->diff[i])); + + for (; i < 15; i++, reg_addr += 4) + stf_isp_reg_write(stfcamss, reg_addr, S_WEIGHT(weight->weight[i])); + + reg_addr = ISP_REG_SHARPEN_FS0; + + for (i = 0; i < 3; i++, reg_addr += 4) + stf_isp_reg_write(stfcamss, reg_addr, + S_SLOPE(strength->s[i]) | S_FACTOR(strength->f[i])); + + stf_isp_reg_write(stfcamss, ISP_REG_SHARPEN_WN, + WSUM(weight->recip_wei_sum) | NDIRF(setting->ndirf) | + PDIRF(setting->pdirf)); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_ycrv(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_ycrv]; + const struct jh7110_isp_ycrv_setting *setting = + (const struct jh7110_isp_ycrv_setting *)value; + const struct jh7110_isp_ycrv_curve *curve = &setting->curve; + u32 reg_addr = ISP_REG_YCURVE_0; + u32 i; + + for (i = 0; i < 64; i++, reg_addr += 4) + stf_isp_reg_write(stfcamss, reg_addr, curve->y[i]); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; +} + +int isp_set_ctrl_sc(struct stfcamss *stfcamss, const void *value) +{ + const struct stf_isp_module_info *reg_info = &mod_info[imi_sc]; + const struct jh7110_isp_sc_setting *setting = + (const struct jh7110_isp_sc_setting *)value; + const struct jh7110_isp_sc_config *crop = &setting->crop_config; + const struct jh7110_isp_sc_af_config *af = &setting->af_config; + const struct jh7110_isp_sc_awb_config *awb = &setting->awb_config; + const struct jh7110_isp_sc_awb_ps *awb_ps = &awb->ps_config; + const struct jh7110_isp_sc_awb_ws *awb_ws = &awb->ws_config; + const struct jh7110_isp_sc_awb_point *pts = awb->pts; + u32 reg_addr0, reg_addr1; + u32 i; + + stf_isp_reg_write(stfcamss, ISP_REG_SCD_CFG_1, AXI_ID(1)); + stf_isp_reg_write(stfcamss, ISP_REG_SC_CFG_0, + HSTART(crop->h_start) | VSTART(crop->v_start)); + stf_isp_reg_write(stfcamss, ISP_REG_SC_CFG_1, + SC_WIDTH(crop->sw_width) | SC_HEIGHT(crop->sw_height) | + AWB_PS_GRB_BA(awb->awb_ps_grb_ba) | SEL_TYPE(awb->sel)); + stf_isp_reg_write(stfcamss, ISP_REG_SC_DEC, + SC_DEC_H_PERIOD(crop->hperiod) | SC_DEC_H_KEEP(crop->hkeep) | + SC_DEC_V_PERIOD(crop->vperiod) | SC_DEC_V_KEEP(crop->vkeep)); + + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_PS_CFG_0, + AWB_PS_RL(awb_ps->awb_ps_rl) | AWB_PS_RU(awb_ps->awb_ps_ru) | + AWB_PS_GL(awb_ps->awb_ps_gl) | AWB_PS_GU(awb_ps->awb_ps_gu)); + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_PS_CFG_1, + AWB_PS_BL(awb_ps->awb_ps_bl) | AWB_PS_BU(awb_ps->awb_ps_bu) | + AWB_PS_YL(awb_ps->awb_ps_yl) | AWB_PS_YU(awb_ps->awb_ps_yu)); + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_PS_CFG_2, + AWB_PS_GRL(awb_ps->awb_ps_grl) | AWB_PS_GRU(awb_ps->awb_ps_gru)); + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_PS_CFG_3, + AWB_PS_GBL(awb_ps->awb_ps_gbl) | AWB_PS_GBU(awb_ps->awb_ps_gbu)); + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_PS_CFG_4, + AWB_PS_GRBL(awb_ps->awb_ps_grbl) | AWB_PS_GRBU(awb_ps->awb_ps_grbu)); + + stf_isp_reg_write(stfcamss, ISP_REG_SC_AF, + AF_ES_HM(af->es_hor_mode) | AF_ES_SM(af->es_sum_mode) | + AF_ES_HE(af->hor_en) | AF_ES_VE(af->ver_en) | + AF_ES_VTHR(af->es_ver_thr) | AF_ES_HTHR(af->es_hor_thr)); + + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_WS_CFG_0, + AWB_WS_RL(awb_ws->awb_ws_rl) | AWB_WS_RU(awb_ws->awb_ws_ru) | + AWB_WS_GRL(awb_ws->awb_ws_grl) | AWB_WS_GRU(awb_ws->awb_ws_gru)); + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_WS_CFG_1, + AWB_WS_GBL(awb_ws->awb_ws_gbl) | AWB_WS_GBU(awb_ws->awb_ws_gbu) | + AWB_WS_BL(awb_ws->awb_ws_bl) | AWB_WS_BU(awb_ws->awb_ws_bu)); + + reg_addr0 = ISP_REG_SC_AWB_WS_CW0_CFG_0; + reg_addr1 = ISP_REG_SC_AWB_WS_CW0_CFG_1; + + for (i = 0; i < 13; i++, reg_addr0 += 8, reg_addr1 += 8) { + stf_isp_reg_write(stfcamss, reg_addr0, + AWB_WS_CW_W_0(awb->awb_cw[13 * i]) | + AWB_WS_CW_W_1(awb->awb_cw[13 * i + 1]) | + AWB_WS_CW_W_2(awb->awb_cw[13 * i + 2]) | + AWB_WS_CW_W_3(awb->awb_cw[13 * i + 3]) | + AWB_WS_CW_W_4(awb->awb_cw[13 * i + 4]) | + AWB_WS_CW_W_5(awb->awb_cw[13 * i + 5]) | + AWB_WS_CW_W_6(awb->awb_cw[13 * i + 6]) | + AWB_WS_CW_W_7(awb->awb_cw[13 * i + 7])); + stf_isp_reg_write(stfcamss, reg_addr1, + AWB_WS_CW_W_0(awb->awb_cw[13 * i + 8]) | + AWB_WS_CW_W_1(awb->awb_cw[13 * i + 9]) | + AWB_WS_CW_W_2(awb->awb_cw[13 * i + 10]) | + AWB_WS_CW_W_3(awb->awb_cw[13 * i + 11]) | + AWB_WS_CW_W_4(awb->awb_cw[13 * i + 12])); + } + + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_WS_IWV_CFG_0, + AWB_WS_IW_V_0(pts[0].weight) | AWB_WS_IW_V_1(pts[1].weight) | + AWB_WS_IW_V_2(pts[2].weight) | AWB_WS_IW_V_3(pts[3].weight) | + AWB_WS_IW_V_4(pts[4].weight) | AWB_WS_IW_V_5(pts[5].weight) | + AWB_WS_IW_V_6(pts[6].weight) | AWB_WS_IW_V_7(pts[7].weight)); + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_WS_IWV_CFG_1, + AWB_WS_IW_V_0(pts[8].weight) | AWB_WS_IW_V_1(pts[9].weight) | + AWB_WS_IW_V_2(pts[10].weight) | AWB_WS_IW_V_3(pts[11].weight) | + AWB_WS_IW_V_4(pts[12].weight) | AWB_WS_IW_V_5(pts[13].weight) | + AWB_WS_IW_V_6(pts[14].weight) | AWB_WS_IW_V_7(pts[15].weight)); + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_WS_IWS_CFG_0, + AWB_WS_IW_S_0(2 * (pts[1].weight - pts[0].weight)) | + AWB_WS_IW_S_1(2 * (pts[2].weight - pts[1].weight)) | + AWB_WS_IW_S_2(2 * (pts[3].weight - pts[2].weight)) | + AWB_WS_IW_S_3(2 * (pts[4].weight - pts[3].weight))); + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_WS_IWS_CFG_1, + AWB_WS_IW_S_0(2 * (pts[5].weight - pts[4].weight)) | + AWB_WS_IW_S_1(2 * (pts[6].weight - pts[5].weight)) | + AWB_WS_IW_S_2(2 * (pts[7].weight - pts[6].weight)) | + AWB_WS_IW_S_3(2 * (pts[8].weight - pts[7].weight))); + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_WS_IWS_CFG_2, + AWB_WS_IW_S_0(2 * (pts[9].weight - pts[8].weight)) | + AWB_WS_IW_S_1(2 * (pts[10].weight - pts[9].weight)) | + AWB_WS_IW_S_2(2 * (pts[11].weight - pts[10].weight)) | + AWB_WS_IW_S_3(2 * (pts[12].weight - pts[11].weight))); + stf_isp_reg_write(stfcamss, ISP_REG_SC_AWB_WS_IWS_CFG_3, + AWB_WS_IW_S_0(2 * (pts[13].weight - pts[12].weight)) | + AWB_WS_IW_S_1(2 * (pts[14].weight - pts[13].weight)) | + AWB_WS_IW_S_2(2 * (pts[15].weight - pts[14].weight)) | + AWB_WS_IW_S_3(2 * (pts[16].weight - pts[15].weight))); + + stf_isp_reg_set_bit(stfcamss, reg_info->en_reg, 1 << reg_info->en_nbit, + setting->enabled ? 1 << reg_info->en_nbit : 0); + + return 0; } diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h index 76ea943bfe98..80c4571dc522 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.h +++ b/drivers/staging/media/starfive/camss/stf-isp.h @@ -124,6 +124,44 @@ #define SC_HEIGHT(n) ((n) << 8) #define SC_WIDTH(n) ((n) << 0) +#define ISP_REG_SC_AF 0x0c0 +#define AF_ES_HTHR(n) ((n) << 16) +#define AF_ES_VTHR(n) ((n) << 8) +#define AF_ES_VE(n) ((n) << 3) +#define AF_ES_HE(n) ((n) << 2) +#define AF_ES_SM(n) ((n) << 1) +#define AF_ES_HM(n) ((n) << 0) + +#define ISP_REG_SC_AWB_PS_CFG_0 0x0c4 +#define AWB_PS_GU(n) ((n) << 24) +#define AWB_PS_GL(n) ((n) << 16) +#define AWB_PS_RU(n) ((n) << 8) +#define AWB_PS_RL(n) ((n) << 0) + +#define ISP_REG_SC_AWB_PS_CFG_1 0x0c8 +#define AWB_PS_YU(n) ((n) << 24) +#define AWB_PS_YL(n) ((n) << 16) +#define AWB_PS_BU(n) ((n) << 8) +#define AWB_PS_BL(n) ((n) << 0) + +#define ISP_REG_SC_AWB_PS_CFG_2 0x0cc +#define AWB_PS_GRU(n) ((n) << 16) +#define AWB_PS_GRL(n) ((n) << 0) + +#define ISP_REG_SC_AWB_PS_CFG_3 0x0d0 +#define AWB_PS_GBU(n) ((n) << 16) +#define AWB_PS_GBL(n) ((n) << 0) + +#define ISP_REG_SC_AWB_PS_CFG_4 0x0d4 +#define AWB_PS_GRBU(n) ((n) << 16) +#define AWB_PS_GRBL(n) ((n) << 0) + +#define ISP_REG_SC_DEC 0x0d8 +#define SC_DEC_V_KEEP(n) ((n) << 24) +#define SC_DEC_V_PERIOD(n) ((n) << 16) +#define SC_DEC_H_KEEP(n) ((n) << 8) +#define SC_DEC_H_PERIOD(n) ((n) << 0) + #define ISP_REG_LCCF_CFG_2 0x0e0 #define ISP_REG_LCCF_CFG_3 0x0e4 #define ISP_REG_LCCF_CFG_4 0x0e8 @@ -140,6 +178,8 @@ #define ISP_REG_OECF_X0_CFG6 0x118 #define ISP_REG_OECF_X0_CFG7 0x11c +#define ISP_REG_OECF_Y0_CFG0 0x180 + #define ISP_REG_OECF_Y3_CFG0 0x1e0 #define ISP_REG_OECF_Y3_CFG1 0x1e4 #define ISP_REG_OECF_Y3_CFG2 0x1e8 @@ -204,6 +244,49 @@ #define OFFSET_B_POINT(x) ((x) << 8) #define OFFSET_A_POINT(x) ((x) << 0) +#define ISP_REG_SC_AWB_WS_CW0_CFG_0 0x4d0 +#define ISP_REG_SC_AWB_WS_CW0_CFG_1 0x4d4 +#define AWB_WS_CW_W_7(x) ((x) << 28) +#define AWB_WS_CW_W_6(x) ((x) << 24) +#define AWB_WS_CW_W_5(x) ((x) << 20) +#define AWB_WS_CW_W_4(x) ((x) << 16) +#define AWB_WS_CW_W_3(x) ((x) << 12) +#define AWB_WS_CW_W_2(x) ((x) << 8) +#define AWB_WS_CW_W_1(x) ((x) << 4) +#define AWB_WS_CW_W_0(x) ((x) << 0) + +#define ISP_REG_SC_AWB_WS_IWV_CFG_0 0x538 +#define ISP_REG_SC_AWB_WS_IWV_CFG_1 0x53c +#define AWB_WS_IW_V_7(x) ((x) << 28) +#define AWB_WS_IW_V_6(x) ((x) << 24) +#define AWB_WS_IW_V_5(x) ((x) << 20) +#define AWB_WS_IW_V_4(x) ((x) << 16) +#define AWB_WS_IW_V_3(x) ((x) << 12) +#define AWB_WS_IW_V_2(x) ((x) << 8) +#define AWB_WS_IW_V_1(x) ((x) << 4) +#define AWB_WS_IW_V_0(x) ((x) << 0) + +#define ISP_REG_SC_AWB_WS_IWS_CFG_0 0x540 +#define ISP_REG_SC_AWB_WS_IWS_CFG_1 0x544 +#define ISP_REG_SC_AWB_WS_IWS_CFG_2 0x548 +#define ISP_REG_SC_AWB_WS_IWS_CFG_3 0x54c +#define AWB_WS_IW_S_3(x) ((x) << 24) +#define AWB_WS_IW_S_2(x) ((x) << 16) +#define AWB_WS_IW_S_1(x) ((x) << 8) +#define AWB_WS_IW_S_0(x) ((x) << 0) + +#define ISP_REG_SC_AWB_WS_CFG_0 0x5d0 +#define AWB_WS_GRU(n) ((n) << 24) +#define AWB_WS_GRL(n) ((n) << 16) +#define AWB_WS_RU(n) ((n) << 8) +#define AWB_WS_RL(n) ((n) << 0) + +#define ISP_REG_SC_AWB_WS_CFG_1 0x5d4 +#define AWB_WS_BU(n) ((n) << 24) +#define AWB_WS_BL(n) ((n) << 16) +#define AWB_WS_GBU(n) ((n) << 8) +#define AWB_WS_GBL(n) ((n) << 0) + #define ISP_REG_ISP_CTRL_0 0xa00 #define ISPC_LINE BIT(27) #define ISPC_SC BIT(26) @@ -315,8 +398,19 @@ #define CURVE_D_L(n) ((n) << 0) #define ISP_REG_ICAMD_0 0xc40 +#define ISP_REG_ICAMD_1 0xc44 #define ISP_REG_ICAMD_12 0xc70 +#define ISP_REG_ICAMD_13 0xc74 +#define ISP_REG_ICAMD_14 0xc78 +#define ISP_REG_ICAMD_15 0xc7c +#define ISP_REG_ICAMD_16 0xc80 +#define ISP_REG_ICAMD_17 0xc84 +#define ISP_REG_ICAMD_18 0xc88 +#define ISP_REG_ICAMD_19 0xc8c #define ISP_REG_ICAMD_20 0xc90 +#define ISP_REG_ICAMD_21 0xc94 +#define ISP_REG_ICAMD_22 0xc98 +#define ISP_REG_ICAMD_23 0xc9c #define ISP_REG_ICAMD_24 0xca0 #define ISP_REG_ICAMD_25 0xca4 #define DNRM_F(n) ((n) << 16) @@ -439,6 +533,30 @@ enum stf_isp_pad_id { STF_ISP_PAD_MAX }; +enum stf_isp_modules_index { + imi_obc = 0, + imi_oecf, + imi_lccf, + imi_awb, + imi_sc, + imi_cfa, + imi_car, + imi_ccm, + imi_gmargb, + imi_r2y, + imi_shrp, + imi_sat, + imi_dnyuv, + imi_ycrv, + imi_ctc, + imi_dbc, +}; + +struct stf_isp_module_info { + u32 en_reg; + u8 en_nbit; +}; + struct stf_isp_format { u32 code; u8 bpp; @@ -478,4 +596,21 @@ int stf_isp_params_register(struct stfcamss_video *video, struct v4l2_device *v4l2_dev, const char *name); +int isp_set_ctrl_wb(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_car(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_ccm(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_cfa(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_ctc(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_dbc(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_dnyuv(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_gmargb(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_lccf(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_obc(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_oecf(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_r2y(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_sat(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_sharp(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_ycrv(struct stfcamss *stfcamss, const void *value); +int isp_set_ctrl_sc(struct stfcamss *stfcamss, const void *value); + #endif /* STF_ISP_H */ From patchwork Tue Jul 9 08:38:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727445 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2111.outbound.protection.partner.outlook.cn [139.219.146.111]) (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 DBD3415573C; Tue, 9 Jul 2024 08:40:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514409; cv=fail; b=aTSlMXdN5l6lfmgYsv2NmwsssoBS6mpCNIHaJGwMyWRQStcGNbCb44SKYAkhkx/l48hz2VwrK1zlas2TN4pI5BC7JHzTEk1LoXnaO9gwbYbMlEeroGzpcvnmHO5GhEcGnudKP2WNJVWVApei7TqNPSFJb1E41XRD1cA891YkCSc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514409; c=relaxed/simple; bh=cjyZh2DZx8Wh4SZ1svrjrh1m16lN76Fy9TkFfFl+Hi0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pJDG67dv1QR6pKLMciPdTaqYsqpZ7QWVWygjUzPqBIIi6QjUik+yQqxtjWlxjAfmI0Kp1kVri1Q5uU7do7vEljUzon4kF0PRbpsWWEMDQx5iAPfI/mM6XcDw4Vzv6y1Bicn8GCcdltp0tXktTCvPMrlifJErBy9Y3T4FXNZSU7s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z+c7opmCgoRQwwjkU01bRGBHL7/EQIqCvLojI8xxxw4t99TASoVrc/qwtPGWV8tjNRlfBRK/b30Zz/ydkL5jyFot98MHYwwVO5/7oTQhxR2DTBVMWAYXk8cTgYSW4tnNQpKFU27YWanuLy+Xo+9iEPn2o8BwZQXtMclb+D5LZXfnpVHVHBc8jWG+ifICA3oZXoorvbPple9nNx1b/eAoG3nKZzANwixZyDLSGrrbqtmQuhS5zGhVjiVtKg9amkCOpEIlPMUbk7XWDr4L/cgoQ9gQ639904z8vygNMkb6ga5oL3hFl/bq5uhXinSAd5y1JkhwdWT9Ut0W+hjeGD1w7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NCxeJ/zkXFCPOkwt8MN7f14gxtBE3WVzKRnYHHzHmvk=; b=NG8qiKbdMPJYxS6ZCSzfDj8E6/KXhdfifGlCs7oZgEqSYqOEv1elEosmUKXaUPq6S4FyTp9n+IA0rL4k7VPhjL6mx5gBv7jgrkl4uTTGhn0v8qh7bL+u1FjEI49QGKVeWSFR5P+mquCWfgmt1U1w891fvfw/pFc4rwkFkSw1DmEkTqmeLTmcTXgaIGrTsZPMHyVEhl8j6+EkX9XP/1CNflewhHyaheIw8INzbzHMVcDtYAtv3YAjWf6lN72+i6AKXEbY7vUo5Gkifavd8toVSO6xNS6a2zOJ+AJ/loZKOLhii3kuKJxbkzGbqQeecpLlqLrEtyAWthbo8QkJUA323g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:47 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:47 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 13/14] staging: media: starfive: Drop read support for video capture devices Date: Tue, 9 Jul 2024 01:38:23 -0700 Message-Id: <20240709083824.430473-14-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: 64d03c85-1b83-4360-1070-08dc9ff28cd6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: lahEubP316T5xzkQvE5CmHcFw6DJ2uH+W3X+4eYsLfjorPiOCYS8b/19K+WU9QVpsIst9JzUaatE4FqJc734TzqbK4+HfGfRfiettVHOWqs/fnmS/QjpYRSuMq8j2+gymHUSU9A3JJ5l1TGp6jJ5YCbgFaPoybQbg3VM0QpILIItiJnHZ80+GFqtnV4OrITJMn1yWVTyoyxl5UuzMhdh69xzl+nAajjEyps2swpfe7TLYDizLXXZWTaPsNeeakMpkC/Q9OTJeVd7npRIcQ5mQHn4nAai8Rn8i5Xx3RXls2UKU7P3UEneYwWtP71LSoQW97SeK+3jNYWyxNexrssuyeZ3y8oyuAUiiE9Vd0/Y+q26VLoBoICW66f2pH6KsxIdtCxVKnJZOsL3oJl8FZprS/5LU6W+rLoS/r84hwBUg8TY4L5YuHkYHMHZvJwFoiL/Tqwq+vHnaYu+B6jgOsvS4uXITuwnK7ZcXqGnL1R43oT8HxcwVgt2hJsW8IOB9aOMyF5hT+dwzp9ZepagKW2dObuu88TnXe7T/zHskdV0r926HR/sJT4ScjmpXZ5pzeAeziCtXYctCKohKQ07b5y2yzWp98cNIUOo7R0Eaz7Ti9l20ssEjFckAoFUFiYNe+li X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Cb2vRZ7Gfmq9et6z5DxBn62b+shMzMAdOZsJy5qwnZc2lWAHrzDnCr3dDA21624jDx+Wq5yhcQ0SQiIA7w8NR0JrS+nVoJFgv6g3xqMjWthO7QacV2FHwXh7WQ7iFuRVLN2K7HI2DNJXzwFzzKpRy5rLD8XP3yUJfCiB6f1kZ3svU4Sgmshrksh/YXoU39r4PGajL90Yms/hBZ3Cd5zblMkTBxI+YcpOo1992gibvaXai7hC7resGH85evwWnkMJp61QgDklJfVHbcolWd5cSANyF58P7yxcw1ncHVNM6Zzg6TO13DCfrrF689QFAgwMfLANTloB0WOFGmDa/sn7Zda8n4OruMAN9UYZ/fg9oQO7O+adNJoRdvT0JBi2e5TLn0lJR59l/pspN1UISPvur5IeUcN3TUXiRBJksAu68DSAuxlv1HDTwGoUoOK+72R/CqraN6Iv7LhCPzT+O9XvQw860OfpeZD7kQZWpY1a4tiZbDLG2yTOlOPzohn5vgrJfWC7c10jiVTWJIQQKr2wmgdsFjjEEaphCB7dhSgmEcn7NDH+GrL1WMwXsHUljzMzf7UyXeo7unnS62FsitGoQU4JDUyAJV9buCMsoSeMVEIjdp15R9gg9HMfKmHVYdRGfcIyee+a19ncch98fVPB8pl79YfhijhnOpBVtmKvFludqRQ0uTHW2kAZIkxR/jej07gtKxbNotZLfixLs9sgYUf5IS4U4iRJQ06YU075i/7Du4nv014FoTC3lVBy1J92Z/P1pRTpHtWsAgrmih0vP629auYD1BXiCjpF4MVEYxpeG9xACyFZSAAV5oFgfSMzZitiO5JK+UkFuFtRZ2gIwmc4jiU9Xf+YAH3vupilzUA+dRa3nBnlw7J8kOWPaLk/N9DdaiomtSYHEbyH2f3mLj4lgkJVot4FDf+IAHnAaYSqGsiYZ0JUj1g92fwSP+S0PRR/w+rWnChEQc46affqZdQ+7SMEuyiZ+wz72DbZ1ZpEPztvKAso2ph8cbTZKWwp1iRwQ86sKKwlVzYyaKKp8ZzeOd2GaE2E7meuo++OL7OVHgUQspzBX0aGf5byscdZJJbG2hP6M7RtHkKY1pE09z5WnbmUKbmMrBkmtb6J1NizU1CGeQ+umWxXttE8yy7u5c+GDMw45P1bgUupIm3zPTcgGdUKn2LRBjA19l3vu5gQhcY7pV4SgTrht1nKa5GEziILW8YAOyNGxgr01lLPObsSGyd8YlVWlzZQDfa1rOkJ+8y77D8PD+9bpjLtYy0Hh88c+/yDCcE1Qw7vNHkmaxq+IkKzr0kYGxLh4qfmnRISTn++00djO1t1UGZU1n9TwSMM5+ZCnpZm4P/h/7l4uXdJ4K0GXQpermXj/YAhV+XApcLOeFURn+lkYf8zHxIqwAUnnwVvFeYOMk+FMjtwIY4vR9cjVlcBYosAKLcsYWX5jhGTlv8KC8c5pg70e85vnQd8dhnegP2HSOlb6ajwkFQYXa2d+fByIQUGyNPtaBkevaRPjXdvmppxEaAdTC/JeyKc7tvA0aqryxBSL8ykqzNVBzc/e1KA33iln7sd27FgsgEoeaHTluLY6VgFCNsIMh2nnTbF5z2b6rMyfEUyX74zCzHpB1MFOBKuPLFx7gk= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64d03c85-1b83-4360-1070-08dc9ff28cd6 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:47.4870 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: v7aIWalvVNafmMN5XoaSwzbl/bXDn/acU6XGZRb0jLbKQZkLaHgfjF95I2kKRSwhsqwLlBN2vh7pdVplPGHu2/vGf+gktYZHJWj02VU3EXA6otEqainF8LLgd2c4txXB X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 StarFive video capture devices is not support VB2_READ queue access method. Drop the implementation of the read hook. Signed-off-by: Changhuang Liang Reviewed-by: Laurent Pinchart --- drivers/staging/media/starfive/camss/stf-video.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/media/starfive/camss/stf-video.c b/drivers/staging/media/starfive/camss/stf-video.c index 8c6c45d8b7a1..28e6679ee9b9 100644 --- a/drivers/staging/media/starfive/camss/stf-video.c +++ b/drivers/staging/media/starfive/camss/stf-video.c @@ -570,7 +570,6 @@ static const struct v4l2_file_operations stf_vid_fops = { .release = vb2_fop_release, .poll = vb2_fop_poll, .mmap = vb2_fop_mmap, - .read = vb2_fop_read, }; /* ----------------------------------------------------------------------------- From patchwork Tue Jul 9 08:38:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13727447 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2111.outbound.protection.partner.outlook.cn [139.219.146.111]) (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 A3607155C83; Tue, 9 Jul 2024 08:40:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514411; cv=fail; b=YRGubH6qNKd6Mik/soQPjNho4Xo89yX3joWXK+YRuDXia31SVdgxLybq0f1cWlZMpwIWwmKgA0dd+ABmj5Syg9C1ro5OmOQkBLpfdo9+cvWFN/p6r1vA3Cc6CxdG39YlICejTBAumnwmsvie5K0gYaEz9XEebVne8GIHvNAYMDM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720514411; c=relaxed/simple; bh=8vy9iC4xZobNonXX5You5QxmsSOWhQLEJArk/ruFFtk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=iS+6YSFtiQBKxvnarnocGC4HBz8t+hoRzDwpeUOZCTpNUWaht2Pqj8ME1Y+cuYAzL6OZVNLQEDW8ipm+QhBOzuEdFrhOsRpjCU761zxghAydaNeMKhdHkAuE+5NGSvrDrI2aX27pucg6ps3KssQxAGvRDTHcuKlj5P2spu3ZsKs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bZmOfixV5RPirvnRvh7DCTIPCmZzM6Fro4PWEXG9Ao3hWcdFT4qMsxk3M0F29kEO1qhrXXV9EKC0BmfJrGKKHDfN/BV4vaAq8tRxXtmMfrqeiRVXSxyxhhaCCD1N+jEcO8F8v7Bp/hwisa6UMN69clvxsWIeFdUm2vJTtPqu4Y3zS4VbDFlKGEPCfZfuWqhJP7/4OCMSMG8jM59adG/PWx4OdjM+mgDvCqMXRuXyR4sHv+2Dc22kBYgjqAgVXq+sBtMZlJA230nud3nFn/nwx8bzLAH9Q6FIx6rFchaKzO3eoGYHXnYE1YAqDpwafvhdLyV9kYaSuN21mdxi2ZWVgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tpOFUQrZW8GSQTbW3FIMAhf3C7AGEcEZyiE+jejurPc=; b=Ra8KFRhxeEeVpZObHwr3V7rKl7nMkauW85u02SRPXm869NvRPNK69hYsBCv7KEJuHJX7r8lPW1J/rnybjpQP36gJiwGTRwxB/2BdnZMt5GslqEe4NCIL3+fzCxp4iVnCeY2Lauj7ZJrinUYAQ2QdDoWBSCMJMFZbXvUXAtKJeUzh9I1SKPjGCfKUz7tnB3cvE+7d00xC4g1GsiVfl0Omjsg3ft88Fbuo23fFKQHKHY9Gciz/xsQPJt4ySBBxsJRIDpQmitOWn5is9QOJmPDe6IGBQrfXaR5SnVNQPSTl5wD8bthxkX3aw0lGYPTXSW0BcZeG+n+n4Qyqg7ii9EUnfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1271.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Tue, 9 Jul 2024 08:38:48 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 08:38:48 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Jean-Michel Hautbois , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang Cc: Jack Zhu , Keith Zhao , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v5 14/14] admin-guide: media: Update documents for StarFive Camera Subsystem Date: Tue, 9 Jul 2024 01:38:24 -0700 Message-Id: <20240709083824.430473-15-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709083824.430473-1-changhuang.liang@starfivetech.com> References: <20240709083824.430473-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::16) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1271:EE_ X-MS-Office365-Filtering-Correlation-Id: c589b351-b6bb-40b6-c742-08dc9ff28d90 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|41320700013|366016|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: b+TXySufOLaOvpOAwALdHtem7kUn9AV8pohYvrAnU5YKwbx06ph+N43SC+eYKX/XJwmye5E8s9ggPM1z1hzG6yX5RxMYtXocWbownfWAEjovHbadyyCSM22V5LvoMALpRV5XCp6XiMEniymwUCA40Mo6zKzoVexFxcJ18F4DgyH9A8m5za/DNeyB9CBgOaXl8KlpDR5qQXub+f9S0kPmtoTldjHYy4Ig98H3k+ShK8vs7HaB+lIk1vFWfmQsqQWN2OAz6vzhcVy9s3OgauJM5lpiEl62Sin5pV1XLmKPLbO/jXqES4DONOIacO5lTAuStKk2Av7uLVugTxp+LB3DOKZXfPxwm1/oHbdkAYSP26rLeAEq1mQ3Scp6vkNXmFuglgcz6pASg3WTVfnh/1bm30pPq556DhjADC5Tum1BL/rZ+whcyJVD0uhA0CRMHrtlpCoNiJwbj2r6cHdE8xW4CfA3IVTTEY3iVD5Bm/nsmjMpGxBAVBDvQfuYhx1xh3F1TpY2N1srrZpP+8HPMoI3tC6wXimqftV6vkLFMVYbinwczpZ1J76tmufxy7ONxMmMm24lkp6OR6cuoMiU/tsnXgpvrhQFyq4cGLcO/mNBQ51d11u69GEMOiIGqrjqtS57 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(41320700013)(366016)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MFCJt+euPsCHxcsSZ1Nyk26aS2E6s3mA3rAJAqAl2f8NKlQOW1eLhx5lPddxhWmHuR7Q2B/9sSyVr0U6VzGWg/z3mrBUYW6VJ/Wbw/Q2ME9aXsVBTj8Yj51JDHiBSDVqKqPmRWQFGhidv2zb0ACATpZqGjlQwh2oUkdDARHwMV04ZXM813OhikWB1z4OWXngLxHg0ktPdvUoYqnbbif90ZjekHI66TOziZtUlZ63NaFkVkuCAroH9ari7xnCW964SnQh14j302QEOD4mIBBNtoCMsmc4dqWZe+3HaGBcJRdIqx5om0bet7lkotRikgK2ypZii8zfE7ZISe6MpUy8qtZsvDzdO7VTU85DyMBtZR1+Gx64OfdpgtCZm5WMbwRhpy0HVZ1p60lDZLoEr4JZIhGdnl7R5fDIaS72/Q4CYalOA30r00+7Jmac7bgfAE6FuXuZQ791eSgKCDeFxqN2Oih+6X4UcdkL4cl2dMtGuicClDCZ82D0odL58hO7LOWXkGEBri61ffPHOVkIDz+4LlMXybPcuDS80La4Wtrin1LWA0gp2OAFDhBg2RLGFfxJI0CdLmFSBInh2+mX/sfcUvJ/O9bKemj//ho7PYNCABvapwc0dQvqUUr4H7pGesQHTFtTm9/8OrnA5JJF61bakOcZCiZ8f7ZsfRD2vQCWQ/tstKGdDKGPE1XubciY0I6FxIJfxqXPSUWH9woddR/VMNQnw1U9LsH3BjooENdgoN7OybnsJUucjZRG360BTyvBmBENrCGlHB8bAe4lDT69hIhSmJ3/hVbFGEu3PkCJeTm0PVl0huImwuwtxFHmOYd4hs1Czjv0JdbtDe+oK3RAF9d1/LL6bejo+GDsTyFYXP+JGnZJfjhZIjwOXwSgAKlm3qaZexTe9bTaJVmNYZMMLhY6PL4YcRbx+rJKk+/lj2UEQ0XZ6sNgCSxfl2TUYkc+IDf8gORj4hByQ7oJ1TOsgrw1QqERlHoKhXmK4xIybTR+Tkglu1JYlLNdvBc4lr6+Y3DCQpdj2yjfvQM++7oOQHFQZNZ4WOButx3w8YRgyCkxtuBPWi5WQ7uaZ3FoPf8ykCkqX/IS2gqkKvhOvDaOd+Vegz7XMLoEmqpUzZauvDR0nXXBZ6oFs2s/zXC+cz95wddgbwsIB4V9yKrzxsfJjM5WQ61LOglc427L8Q+hGGmzP/9TPMg6XsojvyPxMtrTg+8bhLChiIhU0IwPQ5rxXtbcZ59PvyvqbA+a3mw9EMBRnn87XT14v2u0qUWrWFE2rV8dWd/9DuMvMD9YpfCgi2nll2gajoVGauZqJGlFbYsQlsDB9TiX6C5nHh3IgNtCtOekLFjPOhZ7a5LoOjfADyUqagPWYiRVHzl2/+UQhIUyXQxO+ey5s9WO3SktGQagZKArd+MfMELHtZEk8NnOpXc5suf1hN8HQpL5r5DmjAYKoTyMxKy7IAUnqSxmhmA3IAbcFram/5UT7CXEJqhn/YJMt1r0pML57QXLN+73tgS1pJknMkKQ5sucqcjE20pUcpWYWFPKuvEC7n3iihcEL+nIpoHzSvaxknPqry5SriVytO2iby8Gpj6KT7y29RxBlnBXutI/iaE/U4/pjjwIgcRkhtI/bdC/wXZg5tQCJLA= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: c589b351-b6bb-40b6-c742-08dc9ff28d90 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 08:38:48.6874 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HzbJSkSeYqz76h0EZ6OFv/57yRQb5cNqOoRqi0FhvaifPSLikin1YC6A1iTLF6DBovZI7IGgSO1ZUBWZ/AIyNWlINBHxXApRUYZFma9aDGaiQeByRlqgehXfd/CcRc6l X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1271 Add ISP output parameters and 3A statistisc collection data video device for documents. Signed-off-by: Changhuang Liang --- .../admin-guide/media/starfive_camss.rst | 11 +++++++--- .../media/starfive_camss_graph.dot | 22 +++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Documentation/admin-guide/media/starfive_camss.rst b/Documentation/admin-guide/media/starfive_camss.rst index ca42e9447c47..020f1969e67f 100644 --- a/Documentation/admin-guide/media/starfive_camss.rst +++ b/Documentation/admin-guide/media/starfive_camss.rst @@ -58,15 +58,20 @@ The media controller pipeline graph is as follows: :alt: starfive_camss_graph.dot :align: center -The driver has 2 video devices: +The driver has 4 video devices: +- output_params: The meta output device, transmitting the parameters to ISP + module. - capture_raw: The capture device, capturing image data directly from a sensor. - capture_yuv: The capture device, capturing YUV frame data processed by the - ISP module + ISP module. +- capture_scd: The meta capture device, capturing 3A statistics collection data + processed by the ISP module. The driver has 3 subdevices: -- stf_isp: is responsible for all the isp operations, outputs YUV frames. +- stf_isp: is responsible for all the isp operations, outputs YUV frames + and 3A statistics collection data. - cdns_csi2rx: a CSI-2 bridge supporting up to 4 CSI lanes in input, and 4 different pixel streams in output. - imx219: an image sensor, image data is sent through MIPI CSI-2. diff --git a/Documentation/admin-guide/media/starfive_camss_graph.dot b/Documentation/admin-guide/media/starfive_camss_graph.dot index 8eff1f161ac7..7961255d3ad6 100644 --- a/Documentation/admin-guide/media/starfive_camss_graph.dot +++ b/Documentation/admin-guide/media/starfive_camss_graph.dot @@ -1,12 +1,16 @@ digraph board { rankdir=TB - n00000001 [label="{{ 0} | stf_isp\n/dev/v4l-subdev0 | { 1}}", shape=Mrecord, style=filled, fillcolor=green] - n00000001:port1 -> n00000008 [style=dashed] - n00000004 [label="capture_raw\n/dev/video0", shape=box, style=filled, fillcolor=yellow] - n00000008 [label="capture_yuv\n/dev/video1", shape=box, style=filled, fillcolor=yellow] - n0000000e [label="{{ 0} | cdns_csi2rx.19800000.csi-bridge\n | { 1 | 2 | 3 | 4}}", shape=Mrecord, style=filled, fillcolor=green] - n0000000e:port1 -> n00000001:port0 [style=dashed] - n0000000e:port1 -> n00000004 [style=dashed] - n00000018 [label="{{} | imx219 6-0010\n/dev/v4l-subdev1 | { 0}}", shape=Mrecord, style=filled, fillcolor=green] - n00000018:port0 -> n0000000e:port0 [style=bold] + n00000001 [label="{{ 0 | 1} | stf_isp\n/dev/v4l-subdev0 | { 2 | 3}}", shape=Mrecord, style=filled, fillcolor=green] + n00000001:port2 -> n0000000e + n00000001:port3 -> n00000012 [style=dashed] + n00000006 [label="output_params\n/dev/video0", shape=box, style=filled, fillcolor=yellow] + n00000006 -> n00000001:port1 [style=dashed] + n0000000a [label="capture_raw\n/dev/video1", shape=box, style=filled, fillcolor=yellow] + n0000000e [label="capture_yuv\n/dev/video2", shape=box, style=filled, fillcolor=yellow] + n00000012 [label="capture_scd\n/dev/video3", shape=box, style=filled, fillcolor=yellow] + n0000001c [label="{{ 0} | cdns_csi2rx.19800000.csi-bridge\n/dev/v4l-subdev1 | { 1 | 2 | 3 | 4}}", shape=Mrecord, style=filled, fillcolor=green] + n0000001c:port1 -> n00000001:port0 [style=dashed] + n0000001c:port1 -> n0000000a [style=dashed] + n00000026 [label="{{} | imx219 6-0010\n/dev/v4l-subdev2 | { 0}}", shape=Mrecord, style=filled, fillcolor=green] + n00000026:port0 -> n0000001c:port0 [style=bold] }