From patchwork Tue Apr 2 09:59:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613635 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2136.outbound.protection.partner.outlook.cn [139.219.146.136]) (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 75FDD58AAF; Tue, 2 Apr 2024 10:00:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.136 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052040; cv=fail; b=TKbuO/w2q3vZ6lRD1I9lHG9gvuBOuVIZamWNPol/ZCjeS6dlZqaAXErKDpeLhAVqtZkkArNq1s1Ubcq42OVlSs5/eHY5nnY2CVM9FSFxekp1DrhDPKD5OjjMzrRImG3wwA8bslFYTQnfPxhcZFLdGoq7ao9r7Ev02AyXukh4Kt4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052040; c=relaxed/simple; bh=psKjk8lY4xkCZjyovCvvAwOqtqQWHZsp74ASjK+koTw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nb6N2KXOCGS+nOCW5OFLtlSXb8YZm2q3zziGSDQv8l4wvU9tQPNVhImBEsfKjvCRpxgTXfJOe3ydqWAkKcr4B/+0WJGtBl8dh99fC+qBhU6kh7Odku/C0RnuiXzbI2boVQmzl55VE2tseKtnEcLZDnla460BpOQrdumASX7/gug= 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.136 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=J6K+3UQlTNSyveDCd4zE6jY+Vmb4oiMYimQ9gzHG7DWKYvoDKV5ihvUvysW+aknD+fGwO4n4SH7IZ+VkiRriF6N3PkRBwRluCBbRa2e47aWIEL++dz83/xiAZWAscII0KbPKwLl6lrbkNnzSbNA1LYm6Z8A0dXKNCNjIDUBbDBKX+kBdHGdFGnBWWDL9NoQ2dYvvcw3SO3ujQzYvaqhquzwEX3l+WFU7mY31dxx++R8WXvHTwBIbhzft0oSOOfF+8WcpG3BFSQm1fmhMvlILjD00V8wOamGnR7YMcvPVRPbF8furDOnqGeJbMKVlCUiSHaNWTO61mpONHqw4WnYhlg== 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=fQXDmgtuv7pIMPNQ9nG9CHZHF1Mb2rssyvCxM2x9gZA=; b=m0L0thWE7I+gfYPVbcYlBpx7Sd30o56SoeHbgE5t8jfamT1FwKL0YnC90WkPj9c/IINTLOmKpF+iuujrM6NvUq91M7A3bbYxdutS5LnJMwM4D4pBKIFkvgZR6FBbG6KpO2hPn8lcLcyB+1CFzOp9q+s3HSJjIvyOoqeCKgK1XEFcD7xRh6zb4mF8muWpRbtlssnGA0n51vUSxMTR5VzP3hPP9F9gYeSUDhMfWc6aRbpCdYf9Th9XTWM2wetgQmN3VzxSGJUPH3NwAjoPIiUWblBY51M/vK2qYFZitaP30RZgGh6cG/MNmfvxUJiQX6+Za69YxXj40ukSkI5PW63L/Q== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0669.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:27::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.40; Tue, 2 Apr 2024 10:00:22 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:22 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 01/13] media: starfive: Add JH7110 ISP module definitions Date: Tue, 2 Apr 2024 02:59:59 -0700 Message-Id: <20240402100011.13480-2-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0669:EE_ X-MS-Office365-Filtering-Correlation-Id: a0133740-c809-490c-d32c-08dc52fbb5c6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fOmuy2dXMIzelQRwIsxwbQV4HL6FpC5ua/oMIhZAKeqfM5DL8nOVkMwWDZsUKqqFIm8Bhl7TvssNSRx2JOQzEMfu6ur8DPp/IdxydiYoTIfPr7oHgsxeonun0mwOvjPdysmBzwHNcC5dtlNXfqXAVW54Pyd98+REI52QoU2FCnSwEwSiO9FyBjmcKKRt3Vg5nWQfj/05GwGtI6zVvu1vgQlRcBDFBDJpvt87g8ZqbLky4aMCbcUcbfpu1/iQQSuiNoNDnvcxS869v7ZrXDBJ4n3WrPl9SEF3r4g2wEvekRWWQTWAC1mMox1AK/bDuBSeAyXauT5f5+x7RY5P2GB3PackRw0wYU7xWzFHlXhpHQx8RnUmuoWTfhaMHkiIEXkIXDGg48jaHoiM9sF3CDUGMLKhkP2M7demgLAXpGn99vK13E/fuaq3NCn8hV9KDTW65iR0xUxDrZyig4igHyd3Hjy/yyOLMKQoYgqPI5GMU/F0tDlVO26EaWU3cGVOkM6B+x3n+jIDa5TsiH+vKVQjKiY/kmB9UQ7tXg6GrlQuvHyD2CxThUovAu+iqBT0Wrb34BfIcMEHd7Wo4HrupBId+lwWr+VbSdOsZb3IVvJljv7tVlpBMEAnJ2sOl1cxAn+mP4LMil8643MUjb1RfZ+RCA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(41320700004)(366007)(1800799015)(52116005)(7416005)(921011)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?vZgiQj4G+7InHlteaqotG9tIBjb9?= =?utf-8?q?IlUs0du+B2ULVq/yYEh9Hg8KYZ9zVefdme8vWtnUCcWKW+jjx8o5tVRnSWrWK4tWL?= =?utf-8?q?7W4a0vYkLXFR8gFh8n7imGS9kjkjUuTsiYm6AeGg/jDl49x4HJ5DqtJquDKIUUAEU?= =?utf-8?q?52QsVDt++y8PqqnQ12Bi5aW4pCfVWFed5ZDleYbSCEbPHZniwjX2zIK9bsyQXmVDl?= =?utf-8?q?pxd/nupwS9jtLub4Qz72Y8u1cirEutF9EGSSCpESU27XzyrZkffaGJd9NTJPH1J06?= =?utf-8?q?XzGrJYHrRjkl72wCcGxi5X5VPy4ebB/0e3xbF/nNuGjNSyP2K8HDgI/difWgqjm1J?= =?utf-8?q?Jho+SutJtaQwFYwc3yb1RrkKKPtjzoTobGkWSGGeEeVFstnUtSLEFF0EAUN5APHfv?= =?utf-8?q?TuKxmOTwuQ8fZbI1Ut5cL7R+YReQdZRsKeSDqDC02EJB0bh9pK/hsnUKxxIWxHFTI?= =?utf-8?q?7p/jpp+7W9ycSXkFlYYqWPipKi+NzNq/LYEZc508X/qXeO02jVOpGrweiX0rpPHhn?= =?utf-8?q?izjekfPCvkX1QLwkI06OJsctsyVdV31TR7gLmCYGhmPaRMVjTxumf24Q7xTS0oyKc?= =?utf-8?q?ZRfWXGI+YoC0jxYVjXrhfakz8N64M8Rq+Y2wlz7C3L6pL1hfw3pUhnybfsdEusC4X?= =?utf-8?q?4gkCG5aNOoOCT/wjClgomcnDO05ZarLPr845lKU0VScTt/o8vX3cpxiSbDzEXqYYQ?= =?utf-8?q?3nJmxvfNYouy8TvIhNWTez8fvpEj2APHEuRhg/Q9qYd1VPJi4+tE2vBc7DTxzcC7C?= =?utf-8?q?B2rv2Xb8wcO6u+pvp6GL2eYM1b+/3szvXwg8RB+Ydlf7dGrQUmMw8YQgv8NwbiL/S?= =?utf-8?q?whPADX5xfxf6x3tcKwrc2yXiuHasc1ffCTx5bgjZ22orVmnpHoNoLIIMfyGidbx7X?= =?utf-8?q?2Q1ctT/YIM735wCgAAspRfimcVdTPjSqm0z3VqrMLXvJQFyqanzOTyiQ/BAnWJG6q?= =?utf-8?q?dpVZPk5L5C38zWHkUrD92mpBkgIQhgHeWXx9SyJYGJPcE7M2VbN8kiz6sNP3xr8rG?= =?utf-8?q?LWnDZW1agSg9on2dCITZvFGllvY3B5zJOd6TFFDUFZ8ntTl8QFCuwuGA8SkHcYj56?= =?utf-8?q?BA32saTn7jDBekHaN6oH7tVSGWhDdN4cDvmnlKfT9vO8lx0yoGDoaFRVfcvxcx4vQ?= =?utf-8?q?fmEEseDxZImT1FbF65Wyt+L+dY8tvM/JEJwUXCUG2AaQLEbwEDOoKwOU6BfhdAnKB?= =?utf-8?q?OFWSRPrU3a/ASr0O7KJoGcQGTr0Hkg4skZA9aCuj2y473tycH72N+JJJLdolJTFmf?= =?utf-8?q?qJwI1DKgxMXz/5krWVW295kruYwqzo2x+k4BGRD7vLzBEd21hSqTm1fpCd94d+cxy?= =?utf-8?q?chphW84KYlgrq6taQIWPwV8pbjl0bsLwRHUYuwml7AtrxVxBtf1gm6lNg4s/Zjmqm?= =?utf-8?q?pl7VP/Gt4XHTEU+0cYE+1v8yF7+cPYrtFyr2I3b7jaje44/ElegbzZBJcM0OEOt6U?= =?utf-8?q?TUpHcPJ73pQGU7Gy3PQKcKaUUQ0aZQW58mV29DIJJy00/wbuk0c3iTdurSZKpQkMH?= =?utf-8?q?UFT2aVgo6p1/tFDBhOjFodPWhrZPhK8j6aToMPKKvzcHaaNGvoliBB0=3D?= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0133740-c809-490c-d32c-08dc52fbb5c6 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:22.0988 (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: QbAvjYd6eo2XwZdSzBHHicW6PYzyooYCxJPhxWiaLkwrZ220llKBcBSOGBrS0/cFYPZFsU0cbUiM+T5F7rquqh2ycVQJQPHDbpm36YJhmUae5RqgALG83GqkNI3sJrP+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0669 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 88b4cdde1ad8..e5ed3c876a55 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20955,6 +20955,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..e9857995068b --- /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: corsstakl 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 balck 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 balck 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 balck 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 balck correction + * + * @enabled: enabled setting flag. + * @win_size: optical balck correction window size. + * @gain: optical balck correction symbol gain. + * @offset: optical balck 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 magbitude delta threshold. + * @offset_u: Chroma saturation U offset. + * @offset_v: Chroma saturation V offset. + * @cmsf: Chroma saturation magbitude 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 balck 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_FALG_AE_AF 0x0 +#define JH7110_ISP_SC_FALG_AWB 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_FALG_AE_AF, This field is + * saved auto exposure and auto focus. If flag is JH7110_ISP_SC_FALG_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_FALG_* 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 Apr 2 10:00:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613649 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2121.outbound.protection.partner.outlook.cn [139.219.17.121]) (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 BE5675A0F8; Tue, 2 Apr 2024 10:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.121 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052914; cv=fail; b=n4WRFeSWffRjuvq98Uq8l8CoNbV0UyeCtG8r192Y7VOK1+7+X0F/4RA6L5k+8nhbFpo5wnutRiIcLPuPAOcXJZiPKiKjvCRSrrjN8rDbgI0l0plpKNMn7NtJdGn5rcq1A2wp9T6+Q4muRXEMA4RAQj0op9cSpyTCQySrhNw2MLY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052914; c=relaxed/simple; bh=TDXU8RUqlzGoA+hzvWweTNEW3CLTN2X9MzsUkwR4wqI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=jysqRBPstAOh+Wya5YDHo1O1x+C/4veLMIAbVn+l/gvd1XpfpyNMOp8HZkiO6yuWYPhqrPti38BPlJJvBL5szwfkL+Z7IpZcYL74EWNYyZmYXOWbvUmmRLCoCiPaZJv3FursRif19xFmO8HRw8s0fipq9wVr4AB6uBGUZEHJYLA= 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.121 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=QaGZuRVDHin6auN6e6TDD9CAMqLtsL+LjFocalwSJnv91LinpRLKbYEmxh+sDeXhNrnJaPDaDqy80axQBB1Smlw9zK1YkuZQAfQ2QZ50d1dvEyzSCRoLB04ukygnItQJ8OJlKEp4SdDUZJvuwh9hWjA6Bi8L/s34rh5iil87e/iwBRFcHZeIcXxUqQW5eWD8pFf4wgb9CtOVxrzy0uwEHPuYtrEqBBKrkIoBCRKpGprqq2mf96T8t4xFc4EVJN7bv5bD4HoybyUdJYc2zM6ISNxWi5It2e82NE2SNR+agAWFAjKBj9B2/91OylFoXGsbM8nnEqb8ehMpQ/SZNjLvfw== 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=3nP0ImCN8olp+giiPSCpnkcLg6XZ7h9WXElBHd0WYGw=; b=JE/lflMwfxwAt324K7gZ3PerfASQ6NVC+Zr7lnlGPGBhavCXsDTTfsFOS4wXimXDWJHeLCYIUKwJ/B7IkVvDqp/SVCa91j+lWaWSSFxVad0+sGmUVc0o6trBKb2/SINIQT5LpvOJArjC7pbdzd3uA3ZKD1JF0PuHJcs6lLBkEyO6LFlnfQDolIVa7bHGg/bmnhas4ZpcI9g1tJ/0W4OwHObrNh1R/PocpIEVC07zR8ixoqMulh1EgH2T9hSFldPnWE1WurruSTZhu8PT7mYLp3XBUZLVse0seF4bOtniBJ1BY35B0S/N/wjm5c5hTioxiW56OePVRq7LiY6nCQEJHg== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0669.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:27::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.40; Tue, 2 Apr 2024 10:00:23 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:23 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 02/13] media: Documentation: Add description for StarFive ISP metadata formats Date: Tue, 2 Apr 2024 03:00:00 -0700 Message-Id: <20240402100011.13480-3-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0669:EE_ X-MS-Office365-Filtering-Correlation-Id: 79a7474a-3e54-4000-ed8b-08dc52fbb6d7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: py2RntqVf118LZf6RWWVIgXeRSuqXEbX2pS8+dPpSpNYDJQxm+g8fciLz+k8ow+YmgunPmDbs2wq0YUxQI+tUJDgBFIenFEOvGRoiawvzEVbz/mLSHnWe2x3vUBJ2GetgMUVzWzc8tTe7SXcebC0820XT07JZHjw5YI+bGZqnIUvzvSmsTKLgrxChTSYZq/7XMbKCvk2XJ87Cqm/zpYOvPa3GCr9yz8+84ZD9c93FdsU3cxNar6Qs0IhRfXtn8Lp4jf1zULbnB3kWff8bBFdDInj2naP7SVh1+QWR7Lj2kECcesGs2vi7hA1OdJ/hihUaxe7AEyDXamtvRL1ue/BmnCjITLCMBMf7cYcBByVJ9WONsBQow70xuXvhMQdaBZro1iDvYEgPUNNYInaHeUEnPjIbAA9FV+9KNVE2AyMbmLbMNg1fevfIWgXtqaePvDInRLxRv/pD6bAyyA0Wr1AGWGNIjSwkH7j9hvnf6awP4Ne79hvC+NpnfRb1y4saIMFn/7vJyD+MkPVosav7Jj0KA7NrRWcPwUn/Bk8aBYl7sro6rEizoWqnyxg7JxfNZKxaHBkTIkm1vLb+UAyCiEj+cce9nFccz5gKa/qE8c6ZfSRaVoT/vbU7hZJhn2kpWx+TEErvhsyLyszyT3jcE18IQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(41320700004)(366007)(1800799015)(52116005)(7416005)(921011)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z79VuK5CgD5TiT22eA6L081JkQ3Q/945ZCAXzv0311oKx02rlgT4OCZZKrYPz+17NCOwtmIzz0rgGHL56cAkXQl4VsN26U6J9ibtxACZ88uOn6AQdYG4GQb4yF5oa3AWCan2gygTznokiPJ9jwkMoaHDAF4bHIpjYSNtQGrLPKvgfHe6UuUM74c4PuKuluQSAv23TRMbhercOv8+KocYrY/tQ+bfrsL/BF0sjYj4wrPI+B4bipzrOVSwWcByp+Iai4oeor2TRFTiMDZbtxfVV7ZzPliyJhVNFqjd+ZjiXj4QOsyaiCSIw9+gom81wYwjLz7obKs6+x3jGZ5E497JTeTOn/+m3Q8t7Ioq52viGjll3KNOyKkG2b2Xf80lidfIFNqqxZlRBNgTd2LadY9qrosnFYn0Okbqvp05qcP3ujJ8YTS5uC5leUIzrMAtS+RuBdxbFaylv0DwjPS8OJbr/UvC+1rg+PsE6xwVflBh/7gRdRpHzrYI1xQI7K+YBk1YPetOtHZbD1UQfWc/6IXAxI0UDMJ7eoBxKBeBepHJjDnPqFgCmL5VNYw79q4CKF15iACV4Gofq8J8ScPi22kOMc2/m3v3CyL0cneLvrL02uQzKmPnLswrJ0/QmxEWHS9o8EOhUqBdvmJUn7erm0e8f+y1um3eaX7KBJUf72RUqKfRXVFupFRJK2jvBpU7NMmOqhndeZkrJoh39EZm34cJNwp+JG0ywonpw9o8M9giVqcqivVatN5ZchSkgJiA+GtTlVaNs6nHT7hq0+k+GOCA0g60gh2pRoOBnoQeGhOz7ci8rfRxkLEts4QcYecfvpICS3G/Ps18NL0dotFTWaDFpZ83c4q+pWNQX9IFcfPqhZE7PtYuOQU66vDvC6WGY8Ho3OQIFUOZ2x9XNSZQQGDXnEv0IVz5V0/SbB3cL1X+In4XSBmaL819N24eq3+vJPhwIwhu0fR9gk4DYHEKNoSHAt69XhGdNy+NyiIqr8GLcH4Ao7NxxqE1caGZhCCMWbB7VxKD+ySw03Kmbdu+ZXPe5bjvf4wPi+ZUOoOM8rkXFx5Ybb7Os0wVIUtdnC7UjBCjqn1RxfmOrkB1LNmaaOkhDewkBHyFwLLBCxjC7kpK6nrmuP9RD6187ufZZlDaNqR8nB/JgrEK8NsCaflprnUIDNUc3dYeJE6gCVamiWDVjGAm1HddZ99CMJcuS9MKuUxNEfyfa2UiTT0eoE5Qugr37PKm4F6fDH+aTdpwt6tB1DmYaWz63TfbK8DFMdUxCWDjokzboJzEeVsj55qAjpOJYcVCf0YO1ZANQoF3UZqf1TSPvfT+jBCg8HuASP2jsGedPqh1UFjIDFSeVmZpNpa2AckftWZ0xiSxNlCC7oWM6hmbE3f+7+cNkF0F/ThENL2ZXSP8JkJ2bf9+B3NWMN0K0avHuMgSdzYFsfGo+myyiVIEG4m/ksblawqtDu7tAwjNcVgHLvd5yCf+QlvzQ5sGGjUvKC7TMpaBMXr3tMUODFFxMoKBxEMfoRpN3SHwLd4vMjEoRfqk8zxfEMUtJwUr1XhwBLz84L8b2Ux4A10rAwEIdBY4xBl7v0Hqx4kebA3zQl7JyTdaimA37oos5SlIuDvAIGsaFgz76Tr0nLD7Ezw= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79a7474a-3e54-4000-ed8b-08dc52fbb6d7 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:23.8786 (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: i/cMMO0ovOyfDe16Hm98Cr7adb/aiRmi3ZJOWnMHNbyJLLdTVsk9U5Te+blfNcX2LkNEa7Lhc3PZ+H4IHl1EjTtZaEElTYXLmrN+2lRhqQj4K/dGHP0B3+kB8II2FU2i X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0669 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 e5ed3c876a55..4ec5977a47f4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20954,6 +20954,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 Apr 2 10:00:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613651 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2124.outbound.protection.partner.outlook.cn [139.219.17.124]) (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 2E0095D749; Tue, 2 Apr 2024 10:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.124 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052953; cv=fail; b=KRCdpwdpUhWwnmioEvjW4qs375EXSl4JX9t0tHzboOCXeHblnU5XsRdsBhZ5+NglT1P4GdX/R5LRPQAlyi2/pZVhjMVv4KtIHgk4oYary5lc8zmrEXwKosWN7yll+kBe1i9X56BIRMO6ECHyT7jrGbpX2ytAtF1RSVGomxJHlFU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052953; c=relaxed/simple; bh=BPOTdn9PqZIjRRaxsBjsW0oQegeY1gBtb92b60WIuSk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mWWTfwCHYYkJBpGXAb8xU5b1MceL4olEmujGZW0JSIPWi4nzGjq7sSdfsRakDGksOpZC16BDr4cw7CiO9WV1jVlTUwz/BEal1NHl3AHDohqwNTIEDIMKhqGV2I7PnnFoaFV7AXaTEmIFqwz0EhZIodKdpYVezseSkFVAG98nWAU= 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.124 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=XeK3rzgt+VzdggXrkZvk1KbSu3bYshYVIUjCm+XicYGvGg9fQCl477FI+irIAuwkr58ePmy/fmvrOX5aTh8Ktq6Qy6uY5xZqniOX4mqMnNVNz7A1SxHt7FAQHAEUvanhKo7rKyQ9439Iw3aV5PE8luRzg9CHv8L6Q9VjdaBX1SpQ9ITtZRsC5PyRdzCu+ZL9yVQzRuGmRy97HEue3jVClRCZL4eOECyPGeymmbAnXxloC4osUxPJjz2dgApeZw4yF9+mJbnqzuYgblG7bM/uvpRJvXFVcIFY0jx+UVFRJiuk7plsByesaPcfKDFqe9I7p2AYLI6aXStCyNPVthmdOw== 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=2+3pg0h1rxF1CLiHTkvZO7Y0N4g9pCr1wHeur26bsDQ=; b=czbWBaoCsz6ibTIT/fz815GHKja8HRmM9kNBquoM08iX72uHlHdjVGSgtz8sJFls7gez0L5pI4NUc0wJ+uik/EQo7wyyOo8wQCsYYgcxKHEZVhHyqBRAORDQmVrt7IEiwMolef6jmjdKRmK6x+oGUrlZTZywSeC2lbayspQ1gA6Jf6vx13XweHjeggiXZy/AjCnqhAfqGyk+rCQmcUbknya4lo4GT12MJCNpICKVu7j25BB+84Ai2Gw3LBTJOlhRJQTEqxH+XE5k7rebJZk4h9XRHpXoRdww6HZ8xEHirAkNWI/NKUSvxSYQuGy05ge8sq2uVi7daoydYVnzd5LzVw== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0669.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:27::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.40; Tue, 2 Apr 2024 10:00:25 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:25 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 03/13] media: videodev2.h, v4l2-ioctl: Add StarFive ISP meta buffer format Date: Tue, 2 Apr 2024 03:00:01 -0700 Message-Id: <20240402100011.13480-4-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0669:EE_ X-MS-Office365-Filtering-Correlation-Id: 659f9687-1706-4c94-b2cd-08dc52fbb7e8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QiWF6RtaDeKUhn6jGssstwLXPgDOmE5aRWE58zRTEa498zUuphAGAe9PBqCqefvpAEh5ob8EgwT4F0Gkx12DGVTRO4ysotUkrJDdMTvXGESNMC2fGZJiRlq+x3BjL0HKBsfP+H/Gv+hmix4QPBVgUjvQvaaCshyfdgeVZxxdBkym28thwSxcg8QJg2t0W6Kcw7PJcTlk6L/LMPGu8Y6ZZAz6tlDZ5MPPT3pzNxdxL0xNAEJmQBUTcMqS/XDwAFpxYzJet54dLFYDIGXv6RdxSxD9XkUeAOetTSQBGhjQilX8BfF45pIgZk8XsXed97Sze0JVPYH3gOhEtzdT6Xq12UT14Vi8JIKsQul75bBZeQkl4quyctlkHEduuJMXvKK2BPhBl8bGncmyEpXFtFEmjX6XuozlKiAFU3Bu0VInvVKzZXhjI47Ef9bBf8Asj8TAYI9WAT2wlvkEHmZx6vtf7HLSGGToNzQtLToPRjQzBbw9TvPwKPDMswAvKmFNQLkIHa+MEzMxqaT26HJ+l4KbS8GuzPqglRc0GZa3zCt/qlND4pb5HopCzl8MgYc0rkCCy8r6Fpx0is9NN7xm8DyXDGEFOi0aAbmmHg1+nEOWDEuuAPUKm03w+qzuEfL/1SNXtpAn2dQAhGaI9NcxhgyjgA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(41320700004)(366007)(1800799015)(52116005)(7416005)(921011)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IufWn+1Fm0xmqg5rnAcSChSm4S72AokLQ5xL0gqV0h7xNN6wMiOLCXiEtxY+Bf2FhNjZfMEXl35iiROtq7l8+gTpEHecV20O8UeJXEPrMeZ7MRzOXMiM2ot5d/VlYlyVQ2r+IiAmbIrYSqQGmlG0Xsjpl+qBgZUnGTESMRDVNH2P1E1+I5it648eu0EkOI1yWjqH6/pAFm3Tlz7NPDafaAxShAkUOSqBaizGHK8uEJMcMaeExTITts7e73VW1OUUGsuGx83DyV93RdmwGYAxSMsxWD2ACIX5Jz2t5ttQ9DzeKxfXS5az2j4hHDn08i47Uoez4Ol7MJ78MWSJTvuBb1vKE6BDiXy8rnbzHBiv4RgXuhEQx+CD7fhjtBScKGaGrGzG+M9VnLam9UIaY2TrW/GDhI/Wyp6dqvwGviogW/GUzv49d7GDqEPZWpEGn+b9hXJTHijsGtGY4QvqAELHuY1j63FWIdWppV5teLDkKyYWrYuAT2dR0kYHlbwhcTduUln0DccmxXlUP2nrIGeDDYocnI+nXWLjptQWIMaoGgUoV1iqx+HG3PdzGII692XyrDSeVPFUONkjousP9FdC/lhM5khvGOdH+WxDA4V8cIBPDuk6iCaI2lhtEs9GfjKwFS/ekey/mYBEQTjX4X82DOE7+dgOepujFEuNjzQYaf5wf9gsLZ1WPUV2CD2afgpM4Su4KB2p4+dFbpsDBeqZHc9h2gD+ErKpUi+8Apcu+q6VTVAAzTcuR4eD+cLrFLmB7vzmilL3Ma2qyWaauMtU/p/bpYt9eKesRxIO0lZxpQYz+GSq9ZZ3g2d7MFaxlrZCWrmxz031s/34z+N9Udglifb7eqvsmrQ/EW3DYFQnVHPi9lj3zuTCTDJVlmVuE17lkgVmL7y73qlDwL1/4dADpFfoCJq2HgfIwhHrJR9QCLzxwIYrwc9pE2D2CGEQhwnr3rLv9/7NH61mgzqLIJPb6L+muxIcjJjezv8vm7Nb/FZfy4LpgX/VXM9A6iKK1D7II/z7Zi184EjRDNv9U3mmMQYTtq1RIkajOhdqNwSpL9obHMkidAw7qJAFQHEhcgPnd6VUqQ9ATE+kE3vo7qmvyU4CWdhiLIh+4kA2ET+RUGFAtvI/qWWMbdQIpylrp/XbrS5ID71j/wgeSx0CcrPimi48T54iZel1+gyPQZ+uHVKCkvDhC0zGTWondO5f3vKOkx2omZn7bEokzZQf0x2nToxxcU2qiFZBAQBG3EE8YRo3UuD/cDSoqgg/6Lf+/M9Ubpk2fdV6q8di8Tj5Y2B4Vl8GPtSQZZ24XGliALUN01FXu4sMClf4tH3K2G5eMTIKumTJoA4UDK+QUJYzntqY/iWkf5o6NFBb+I3GB9mYbAoUXlEDJOfHo8O45y/O5ig4FcxK8f0vOfDhscuvszHNybPO4FH9gMo2OukQmvI0jV3/gyV3bBTHN2IXRi7kxiqST37CwaWRn99wom1TxICnqrluJxNomxbQNcd72o1gu+tq4eYJGsG96dJfTLy955OcKW724gLOVIUtx0j5cFEWkXIE3Aq1pJBA2glC0Tg53fmK6e9ZZVEPXS1lpgNOaj4Cz1Mlg0To+XRcB1epHp9HafYJo6gqGB5/A3k8Vwn7lYo= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 659f9687-1706-4c94-b2cd-08dc52fbb7e8 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:25.6831 (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: ojEgmDFL+M7xr2DmqvtQ05nWASj+IJBc+hBZSuTnWv95T0CB8zynMjxBeoGDkmYAhrufzQtePnDRTj6sT0la2O+DAxLztaF4gOppJGz4pnuzn/+4aRrNHdWZjEPawsi9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0669 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 --- 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 5aeff5519407..9fb8f9c510a9 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1453,6 +1453,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 2663213b76a4..8fb9f2f20832 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -839,6 +839,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 */ + /* priv field value to indicates that subsequent fields are valid. */ #define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe From patchwork Tue Apr 2 10:00:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613650 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2121.outbound.protection.partner.outlook.cn [139.219.17.121]) (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 587BD5B5BE; Tue, 2 Apr 2024 10:15:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.121 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052917; cv=fail; b=ScW3sFvJi0F+yNYHb4oUXS609mY5ZyyhbwGF3ThpdOwqaIWSnGTmTJ1qmSD213V64XoOGwZCBp/b+Eo1sE7QmdmZ7mTylv+IvArAwIIOkSQyCdYljf+oY5R+C6yY84HQlRvRRfPIUlbdbq9jmsAYv9G/xYaBAxEmDO10m3z9sPk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052917; 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=ZTVvvnWG9o+ZLzYGHD86vXou6/46IrfkIUB7ibS3X56lttQruhmANoVgu58ZZR3sP1BS0j4JSP4FgjO2rsdD43z0Z3oAQ84bOUIgtDMcDncSI2FHW0o2Q2SsFYrTNeVVIESRaKVBeAkGM6eLVcUAkizPT7gAKq81epcK6U1Pnu8= 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.121 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=dS+DeLYj3fwuwtPM+r9VHNSdF3/3e1bAS6DkYhqK9OEj5vmEG5FMTm10GSUZKo4dN1G+5EbqBs6Ajta2/ls8fzI4QHWld/8nOphl1UnzRHiKhhiNZzqfBKyC4grNtT+RXW/yFoIFxb23YRkR5MCpk6njkNRhMVZWnhgwdqe3mVOCCb4pkMBZwqG9oOlqa7YSRLs0cV0X6u8nz0fXRu1jzzmCknqdxUukTg/mpexnui72hZOVpmKCT9zvOFF2Nb4sFZf6OzlNMC9wrSRFacVGMd08bYwg51lm7eOEohTHXavIy8MRKvYE7z5lx3+zL8kTzM6TE899mLpyu9ogLl+UBQ== 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=MjycnmaQDIoinB5FlK/wvre4eqrkBO4St564qsKG0kKbYRC8p1P5+5GTsdDqNE7JcZvIN/nkns+3BdulSQHDn9kyA644RQoPLLZbzAXtNehZCG7KJ3owuH/HeX1/L9CkrvhDpVHifLfR4P62S7Z1fdM8uWgrn+OgKAT2Bh5/OSYruANhzLHnn+rtQ9qemZfjHmNkxjEFBExdaKA3Ozg6XxLi+WScGmCxJHgxiRIJMq0K2P3RchG6Nv6A4spEEczHIAp4uKKSQKYNU/duQfNmugeACWr1QEII1OdiIZbCw3RQXB4FHz9z5JqrbrtegnWhUEHrJQJVJdf464eArT4pnA== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0669.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:27::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.40; Tue, 2 Apr 2024 10:00:27 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:27 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 04/13] staging: media: starfive: Add a params sink pad and a scd source pad for ISP Date: Tue, 2 Apr 2024 03:00:02 -0700 Message-Id: <20240402100011.13480-5-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0669:EE_ X-MS-Office365-Filtering-Correlation-Id: ba0e15b9-0835-497a-24d8-08dc52fbb8f4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lk/+w/QHiKMkx23pa0vliVaEcozfPcUOO002m5GH/z08ZpPqHf0vlOuBZasIacDVJQokfBpQ+7ZQpyzHFgaha8SBuY+D7f0eibnQD/aqWe3+5llnG6UDaxcTyJZJBbuXF/HfAmAhRoy9H6qO+aQ5jVMCxoJljjm+EPxiRVoUsnYeWFu0+fwUUt9pOwLdMHNnLVZE6rFV91qk65nYPsMm/e/bIpep9GHq241aUQuxUdYvY6Huz5HJGgn/npbGYfY9yreAedxtIYRn40z5gGxYv/6e6Xv+2h8wjyrebdqNylpMZGtoHakHdBChGlncb0l5anx3jprqRew2b8LaXDTqV2RKlqIQoeQZcmkEGY846QlyKyVFGO+u3y4lsSIjUJ4wy+vm5IpWAIo4BCPW5ony679Ds6krVIpQQ+rz2wMkeA1U8qV6F+Icc4dBczLCfT31hdLwzSSj3e286yZ8TJTWGBrTIXq4WJDV1G53bk835UXYqimvwF8xn/z0Z30akLBaq4lJSHlcJv0Ovwnwau49dQFk1c8R1WKspASgHz/g15jtdVw/Qpwk1esgZrtntWO2dOG2E3N0CXTcQwwKdtSb7aG4CZNqauRjIK+Gn8ogBcT9/PdsMuYiEEh+B5N8SZ0kZJrNeS5VF38x/Kil5tsY8g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(41320700004)(366007)(1800799015)(52116005)(7416005)(921011)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UW+Bk1XaX5LaUn4kxHtIibWqM8vegRY8WN46SrMPCAXUIs8vXu/w3YjQSymLUKjuJBxX1QKfmKjKZHlT6/8cn3Sf/F3XKVSYLN/COrgpFwH6+QyPzU7go5K1OQbq4xdcr9C0zaa27O8BHRFwuP8QPivDqhPT3D1OAwBg+CMFbv299efct9Wbe6VdS48IpH51UsYMkvGf91SDquvw1xia/M7hhq0bLFv3SowFFO5A5joxrXU/XQ6vQw7Tg6SU506jS2i79XhdgwaXLQSkABDBNV9ySxezVRMaj3MalNvqahZ3ni1J3MXl2uMTfFwVOOJrnlrRx1DTZPsjqUAl2wdABxeJE+rq+BVaSCuLTZ67QD3mSu6uQrHOFuCmJEDh/VIzTZIpHQHv3hTS8/sl0Aqby+hSHWKe63g/gkMH5lpb6MJvL1RaqqeEPjm2xMG1R8X1JiVXK3yaNv2I/avH3zQeyNuNj+bA59AXxfTS/SskjaNx4osoxRCXGBmaYASkOpFn8quWO+vXweRjmvjUX583IxOBvFcO4w+ORq7720C0yF6IxGRfyHGNrhAE7wEhTU8KoDDIIam+CiCfjKQgjftmiTs4Ze28poFtcBzMu28V9weJZuvDwAfYTXLIlY3IINBiDpOO0RnSZwCfrFj962Z17yKql4zFEkf2dls2DqbCLDr/sv/X/GSqfFAIL3Uxbm8wrYWykjHL+karJKSbVQmdpNZQJpl+C86bKGaHsRcLeCFEr7AKuZKo2xmtgO34pJ03bq1XJBK4IqyVloLv5x2eggL4klGTDkN3AahqhnCKMBVu9HEDeaapNRwkAen75jMGtLSAw1AXIYvJv+Gg9A0YEygP38EgM/asyMvfR8T8TBb+7j+DBCFTq0M27eCSg2s11xdFUH4pfZy/YvK3KhMagwPD+dv4dCpyCnnQo7WINvW1ehsCqBBu4lb0BaWyVRfbxUpCmiA3RepBx5n7TIFoirGqZy3zGDy3n7BVqp/CENn2qJ8h7Qv++reFA12JsET/DmETKU44UvUNfPPicRUcVxRdTUlP+8zLYZAiWS74zIyPUkEnzkuksbclMwmAcl574EBiD4tmtBrLJ4OJ8IitCu/1x0b6X7C1Vn8d6Nz+sOskHrJua//ESzcQLyHwsa2OLlSYeooORecIR01lAJM2kn765/1eNRoAV/VRw4h5iutwgUE4pzNAbxTR1LWOh2UfSe/tig8sYRVImUJkAHV0wAijpAe1kEekZREgMqyfVQ0lZlXrponJdg/nSnj8RAovAW5P/kLnpuZ47KZrO3w2Gq7kL5bd/oVye9f4gswPuBeuYMYJrka0fqUjNFdD1BMxZBuEYaAjJIjcUkxtPtntcbb3oSvD8niPptF3tSpyETyedpt/ds9jVaY7hKmJWjMh2RmdQFcclTXIgNoB487diAYM/01e3lj4PotNFpEB+oy+b79B/knJibCN9DkFiOwimvqvYyOpcunQEUIiB3iUoy5misM/Iw0SWt4NqBz42ylNkVkW6W4tIbmAQLcmR8faDBP8SBcrIy2/DN6rw/cDBS049TDb3pOhwaAgE0oEaMFh0ZxZ7HfooxgxWRfkYxUfUEMaxZu8o8/Apmoul6hQOJvJIAcB+PfSlo/Mrn/ez6c= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba0e15b9-0835-497a-24d8-08dc52fbb8f4 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:27.4148 (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: jXwEmNcospHv8UAOP/e4cznaH7BM+6nfUcUV+o0N6Wwei92qitnU/RubCdcI2Okp5BjyGIA9w+u1XMunK1lXvGMgOzcpeGykO9AGtDE9OwaCVuqLh7Mfu8gJ0/axOHul X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0669 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 --- .../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 Apr 2 10:00:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613637 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2136.outbound.protection.partner.outlook.cn [139.219.146.136]) (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 229175A4C0; Tue, 2 Apr 2024 10:00:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.136 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052043; cv=fail; b=tyKtjPcTgEU1Y1zpGQcoN7dpijAUwDumUTiQ81aQ5tkooFFmhS1bysPElvwzXmJe5G/cOfPcv6SqkYSIklemz5KHXphKV2J7dOG7blmEzWUJfIXgTOyY3zJMIe+oDbMo7sLkoFRxv+yND7SvmXEbYsFtOh0Ln3Y8Fp5IFrTQ7v4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052043; c=relaxed/simple; bh=0FDg1Dj4Neu94iKgf6Vq/84ghq2Tgp84xqp4AdbB87o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=cEQYTOvs9mklFVy/fZ6KDlh+s72Injf/3IL6IpiUE3/G3z8ikMyJzE+/1Fz43MXUmGOR8DzprtukLAunb4xtqMdFDQBno+CBXrXTJ5HyAOjAhfoPGvW3bDjXGuhut7/zrxx+5NAYfXP7y3EWmbQA3WaQsHLYAw8g+C/qmSGHDII= 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.136 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=SiSaYdrGZsfERfC28g9figfyDzXVbTLVzsWJX6wagjJjm8HENmpG4LNVft+vGpBs74vkhWyLX3jI/jmZdi2B3yvep9WxZlEreh1futbXHh4aBLC22RXGpWsX09xCGVC/QTfuJ/qVCWCrungtIbtFZws5W7XJaCSZxwjqZsOmXmWbSdcDptGITakBpR+2gT7B50UPX0O1AiNr8EkEj/xxi4tiLkQqgU6ientqK26/o6yh5QL+6rTjefD15MiALN/1izrGtsh3SebyLPtHYHiH6pTzqZT/sQDsFBWwQ4H8+AeXv2kYoifqPXxWAQRT56THEboD4pn7W1qVDFhQVG4PCQ== 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=LRybeGzZRPgJr6s6KGRosNmMoEYZvH0Jecc6j8L45xBHAGRi+FYtTQMZJ2sXZ07pd71i2Td9jWkdONyOt5lkvS8lXiF9qPBvba37AXJpqb++bBIasIvxJl4Gh/F9jFlRJetLMmbaMH3x0y6mPREsunGijSVtRG++p+djH7MYKnXiQ3H0tRMBKwSn3eaiJkPxccYoI0LFlhcMfa6UcTCR/0ScfqibpKPr8iqRp0NRrTDRbugpXL2ST5F0GUAiF+mSCvKHDZ8VRUMwzqecQ9gbA1D2V5ER2UmmQbfw069sJfxBBhqvAEXdO+o3A96Ghq0YoBJx6mk4Px9FNwGpDpjn6w== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0669.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:27::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.40; Tue, 2 Apr 2024 10:00:29 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:29 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 05/13] staging: media: starfive: Separate buffer from ISP hardware operation Date: Tue, 2 Apr 2024 03:00:03 -0700 Message-Id: <20240402100011.13480-6-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0669:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c200a57-f78b-4c3a-80c6-08dc52fbba13 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A1vFuUABxnhbZlOQZujFOz61v4zBoV8kPfZiIi2+DQjKurR2Z9EKRPmFwV5vHk7XZGjPF66lIqbHaxLqusHplQFMfquzzDRCSfOMAh7HLeu+6E4mAzZKNcuhZpcY4S1EGJX1XSC7tKgro/OXxuLbHVJ1JpYpHFbt19dXp6GYmVjbPPYVjSvD2bidWIGLiCkRokO8tKgbXhpC+ns/I3HrmSLBOpWnwbSSb8hz8nVZXX3+MjYXH8xK0mLnROLTVBC2Be6YMMGnVc/S/02Qg9ZzXxR0X/zOVwoLi8pw6/rT5DanUIw9gFHAFhqr+AMHeVqlBgVGKwNfomU5EJ1WxrfIXuCZcKlH27KH8jeE9/weINqN0szpKzIOLG3+1gXevCBz8A2e7Axjn6/NjEcI84wxUaerakyjpd8PC/4az58WFpPof2az5aqf+amQtXhwEsCL4tnAG8NDwy8lIB0MAoxRAvAZco74E+lvUiRj0/faGVamjuyjYBcul1zsJ/o50otFplF495BuTorBEbyIOCm8riNLxuqjPwyPzFTwRYbmpdaY1/V8A3jkZz5xYjGqXT6avqsrmgKvE5ndUVVW30+/4YHj6FMqwGyz5CyGpQrRf0TBXvfZe0amacWVZp8+TpU/iKcLYhRmA1E5HQsS9rykdQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(41320700004)(366007)(1800799015)(52116005)(7416005)(921011)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: opvNdLQ4q/EcEMbVgr0Hjcydx2SqeGqur8jLce6WB1U6LgYPHddRuFLWU+TR7mxf9aurwVM37CwQg6+u9Lo46yv9X+KrWEouRBhnbo7VV437w5yvHRqNijpwaYdm846stWrHMvTP1K8YnfFl/vxvNDlO5Cb4uKkKZffqu0ZobVdbE1qnQYbpnzN8fEcEQy/w6UELPJzgxwlFFUetJw0BpkIEehffXDw4GU1vDzzxBo1BBnTng9X3aacDhZh0AsStBFh8iL7c29HBMdZ6Tgu0Zbxjb+hXMVto1bpXBICa+kD3eWqOiM4QeRj7o4FqE4PZSB/5j4qlTp3PXyQT9JCacuhALYcwD1EXIf1qbE4idrEzVlR/6ESrIAtZ3kjrvu7ukzlPUsKnObbpSjJKmhw5NFHghzFR6fPXCquIJL4ZJelxWtOCKMBrjyIJqgGppu4QWK7l7ZFdtIftCcLVc6659Hba4agGAPocZyY+MzazBjKdqrKYdniK9DVsm5gX2i+pPIR/8aI+90CvSHvB5TVUDvMe3xeRWNTF21SQzDhGUaE0+4H0Lq/7ERev6MlS4+/7MB+C0oi+zy5alC8hoPMQD9TuB7ZgyvWrDGYL6/IRMH8CJrEl3ZYVtBxS1KsaTPM0fYovKbKudzVyzEypnL/gTGP9Zm699s/2tEys+aVmcHYJnEpUgYe1eoND949gnA0FzFrx/JMsu+kRBVOUm2HWii3hWFWGcfMJhDErfx1WCwZm3cG9bRMQQ+rxEqZVqILFwTzeUgscXcMa2tNxE5AjCpH4QRFpi3CiRjz8LLifYbgb7ClFrMWvcQuedzbENJXmht/vvzElwnOlBbpfzIsjjobUrTNPkUD4vZv7dy5zwBRhc6aczjKY7VCZdoAdeKOHSywUlvShWQ6mgT+EV5clL+o1FSa1Fa9tCbcjk/l3CfNBM9HB/dC58ujbwHgi4/pR/rRlYjq/nIwpwnSlrm08BAYB3jjuevKgRZ6P16cjTm96nEEPEBvetuovz+dNXEvwZUUAOy746VjRfPVOJ2UrG6Dpn4CQU7Cs83NF2LQMCM1Og+VHk12EZFfa83ZRCGI2S6jgKQbFwLFGxUb/IRSGv10mS2HMsugGqC3NZuEwVuVuQ5pN9OYbNNfnrw1a6co4CLpGg+hPa6u7/aGi30miw2m1Sl1WTQ7mG6yv4jzrWC7rR4AxFqMZ4mEMKdKHnW/bjkirmdTFBJvNHhnbILLUPYwnfb/8vUQ5qfhlEaXJ5yfSyWHKzOHz2vFhICvbYCjNWwu7Ckm45P4mqIjvs0eElu8TQNsxqNguVT/fJAHXZ7FbM7ambGD+/mmHZAzXqMbAWBEBYshLw3CUOpwk7a4NzQFcgeQXRUS0qof56AorJFLOM2pE1n8NQ5EwW8XkrcmhjAabylYVncTtqORNPllfKrI44HpbkVrR00wOwVe4jHBpKUzHVw/WYZQR5OrQl1rdiaRmMGr7fu+C7y/uyfUZcC6v4NYjtqW9F7UFsvHqGCl2JIjcpBORyKQrnMXxSZh4M8ZrmpcLfJ2iSm3kOTQh4UDFgjuNUrQslgpKgDGYi9cwL/JH86zjvaVPC2bzkeQtBXe8OSEsam1BrylrXUCrH175T4MMZF9KlE2vKIXDCf0= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c200a57-f78b-4c3a-80c6-08dc52fbba13 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:29.2455 (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: WKTcZDL4WKTTOd6QTfdyXpx2eS1j1cYnFqOE9qmf28dtJJ2qAc1L3/TED5Y1+VEOrarV3BxKAIimU0IfDq5ZgFtD35NtQeqnxVHjKtqxnQpOPaiB2r4nIMyy5oWfitmB X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0669 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 Apr 2 10:00:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613636 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2134.outbound.protection.partner.outlook.cn [139.219.146.134]) (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 AFE605A0E5; Tue, 2 Apr 2024 10:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.134 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052042; cv=fail; b=CuZ/sqh8HH0F5ARTb27Rl7iMgNwyyicoJrs/ZcEQCWnc3WOx6KvTwEF8USXSTyYDr75dCUbah9Do30EZb6hI5m9dBHMusv8Fj7BOxUsAhzC2ben9CdvTW8JwO362xK6qEpVMv+h+u9NK1WQ0yF7HAWvHuV1vFpAWJtvoHw95iM8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052042; c=relaxed/simple; bh=sayo4V87xszCiBFe1VAH/qoEodDVGFjtvlKqNeihdsE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=czvLfSzvhk4Zx1XCiIHwLOzyUXWEQy1iq7Y7F7U5OBamVWUAFKbP872w6hcHi6rqr8NtVSgXn4sFbGlmShXdkUVyu7qOvyrCuyxOAy7LcEfe5GsYkDxqEKKRabkXzYnGUzq8u/UPARDyD+3uGx5eBhnRA4frjU/3koBeCtWqw7I= 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.134 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=ArJ8TetSvsuXPOzNThG5rtFSLidHuTvnoWgWpO3h1K6qMaKVDtymsLZ0yIrmnzj4EbOeWagU8hER3Q0qKVztEpAkQI32sQzypR+8OKaY+dfsdfmdEGy2UEi2epKnxNmnur5LCYOGXbkEcZBE0bL9DwmzHg2SYUb4CeRMP1WcMS1cqFT6tEb2U+H2jmJBOtagu4xAZnWujZRuIu71Bcy+TyESl6q1Sox+pq5ZZMAcheuFyfhgQk2HOxxcLWRLfs+/a4EGcM2IYHrV/M+tamKNWZjJ4yW7m95kDi2wbVyf+B8E/OzWM7nreq+xU7NvrAbtsw+TzXWfaMiRgk1gL6aYCA== 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=oaYFQx+TLqRESdB1QsTkkLH7jzb7tyGcJjzMN0ghDfTSYtZkLU+GLJZbXuiFoBXzBezYpwItuWD1b9LbyapyHXal8fTb7ZTqhjDdeR5DrKaN3Egm2iyreVGd8dkR0YJ1tKqnyMbpLDCdpfZk/NYWIRHmPFWvYz4MZ2KDzSSFMpf9Y497nOGTOWq2VJ9yzxTlRgBbcA4KV8HNMFGud7Bh6NMep31K+qqa7g6bMxuifKAMi8MC0dbaeC5vWp1AuksJF6p2dAJ2d5EA9b7F+eMIuV3UCHI1OS3ODyRO5V2fXBbjfWM+iROLl2m+kslrTp3yItasH2NAy0VMuAP6Rqksrw== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0862.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:27::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 2 Apr 2024 10:00:31 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:31 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 06/13] staging: media: starfive: Separate buffer be a common file Date: Tue, 2 Apr 2024 03:00:04 -0700 Message-Id: <20240402100011.13480-7-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0862:EE_ X-MS-Office365-Filtering-Correlation-Id: ca6852c0-f69f-4353-f52e-08dc52fbbb13 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OVpWn3tQYTTomH0+0RkmhXZf+tTgW1cLMhJcublAaX152r1rJ6zyGNjrdABi07c9cYKQ4Rec2oTCg0JgjDhuQghPyWr753JQ+CWFsQmzpzuctusMSH9zk5rKRZ/OGg/p98nvjKWrOT1X37tJMYKQBrX1lFg1na75zXc4SfZrBAXVOYZ13lvEVUmjvPF5CvKr/Pw+YOj2+JF9ww/n+qlw6EYqwA6GPqwNbFaEYGanY5F8ee0jCol1M4ReAxIAWdaeDZNHFj09aMNum6K6e/MjPS9bdplmhLJv8cdO5Wcu6ZgeYXx9TJkcMcecd3hBhACyU2LaQfY/Oe0j31I63q7PKmPOWlq4hHso7Dr8JlkDePJgGk5H5MW1Hipuox+VsX4wGC3YUsvvMyFD4/a4IeDf9VVjqTu+P2HILV/ZwBHfAWFBWYhTXyDICeFBtwcXTrZhSSWXuQPpu57Pb5eHVJSec+Efi+DG38/Jk1iK00q272OvFXi8Su9Bc6gKgYH/+XuqrwlVUEcNMshytzkEgdnfRHWcjbCcZulJwImSMjJg1tHAAEPI86wZL31gzA0+y0xT8r9MoL5Gft4BJAnyWwfYdZIndOXkyOfpUn8+Jp+vza60NywFKwz0d6D7OlJIWDKv44b4C317wpKeNlC/qKLHEg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(41320700004)(366007)(1800799015)(7416005)(52116005)(38350700005)(921011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cQ8faRxwXZmVwnKvHa8p4q2zOrcNb8YrzqJiW9tChxR4sTxORAVvd+8wEPyYBKBqc32oWgYtyqzbg2CSz73/LsSgb/Im73lj9VlhwQb4WIbhc5UJIgwjEzqmA0sxSZAIKL0iG+SZF6FbDGnaTRogDhKWFgPS+UNf05lFEZDFYO4d9dqly5JcO52b5XGv/23wbkErE0YSCmEqAj4DyhVTbhxuv1UQ2BOG9q8Y9C3oeUEVuaUTUWWmvM6cHu3MBE5AzhYW2l6axUXOa9KJlRC/IVpHxJLJjwz9pr71IqFUznUq66We3tHOdz75ggACjuc6ZXOjQo3yfeLcbQ9XwFncbdnjHHUz0s6/vJLIMJ/VziaEd88UJ2n08UCenECceDm0/8iAy0ZQs5UVB0nK+ZmaG6KpNobZ8uMoboICQWrY4mGyhOdbQIsjwJzTLZoX6GD7/6Ev7JxtlxKzU5OZSGK8ZXMIjBoYAtMJq43tTzcwjCIhw6DEMDsF5vN11xhHXBFBdz1SGPfC/tiRGLN+7fW6ErupnvI/ovabhcArPNKXD8JaEhryUmiut/HJFUdB8hDCu2ODHO1YB77QFrrnuDH/G6/WCeI96FteDqj8ftjQeCc/9dykvuN10GeigUo3/JaCkVEfIrci5jvpx1OyHVFVnovrMeoMlSwN4Q6KPpZRbQVNzhcTRmCz5y7yNj4kFeqIcl4e7sMvE4jiTUpi0UWu0Qb5Bw53G2jF/3WOxQW1xihh7r4BfNzYONeS7n46HVGncqFsxORxR9hbQ9d5RLlRlhfA5HKBTD9XQHz1U/Pumqif1U1bJIP4MEBDUS9m8q2PCmZvPU0mRTja6kjn+JGL6GvG4TF9gBKrruv1zZ4YjGO5/7gdOrKK8tH6UNC9MIHKNq6SlPtgK0kOZC7pcF7CKCqIDtwfahER44xyOX6ZRprY7jJAFOqHn4BGkkvLCggLYsj4JimSh6mCjKtFUOVJY0lWEHv+ozok6k74QQsJDl1zV+PVZjnB9fNXcfn2JjwX2PZ2j6nioB7+I17fybwVY1kM/cwGXlt2sTnit9lgUl7oRJF6nprpumxbrdnErAsf8P9v2DPuB73QoYzCtzVE8gZSPErhaTpqjby2I4FnOOSjAfimeKpK4Kv4lAUc75dwkLBKnfuNAgC5BCOVu2qhKuGF7iZuO2JA+rBxWfR2AI9eIaUfXmBGszDhEWNzCsuFUkX4A6YPfuEM59mn7RpXWUIcrdRdewsRJlvdYqdwcOiWdkTKXSKa968UFq2kfBjuE43DJbN2F/LCH399TRM5PPlwA2/WsQFiysbb261bfVdv4WUi+ev4hgB2hYD7pLPufmZ+46jd3QyRSRKTz99k6A0x/R+9iZQm/g+f6VFmRKgz6MU42DL2fPtEi7tmL+2Xu41LritmAyFyOVTw9LeTsgaJp7LrMOh9AO2rxv6kf8MNi9KEchuZawWHgFNGfMwsOBnTf4urBUyj4thfXcs+RJIHqTTxMeag8XeiNP/ibj1wSNWdOqd2WivB+ObK8cYUBXubCVT+WFJrrKfkKdMUatd7aJ7kuFVWyQWf6UhnSO8B/xxX2bOW6NCdq74GPQcHGwVJZVF3bJcL2L0Tzkqlhg5ZqIqsjO1YMvL1EBPAcqY= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca6852c0-f69f-4353-f52e-08dc52fbbb13 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:30.9835 (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: RlwMvvQsgoD3+PZ8/MyscuKgUxKrh7azegWcTaWR6y1DFprPV3h1F+qkW8maIV9VcvkvER5mMHtD7LlszWbh+5vKOkPiTpzkIEJ7ZC7VuCAdMRqKDK/+CxkWvdDdEA1w X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0862 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 Apr 2 10:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613638 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2134.outbound.protection.partner.outlook.cn [139.219.146.134]) (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 909785B5D3; Tue, 2 Apr 2024 10:00:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.134 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052044; cv=fail; b=dsbnjJte67nn0bVfY/wCxKTi8yhP9jc9k2PSsGXrjomIQfUQd/2G4vd0jFM5uyOm4SSWZrslciXNFcRH/PCXtDfMbenaij3HQzWR3ng4+wvciJGEfsYvN6ZKbn2i4h+FfNkV9jxRZYJbfajF+E0JfF+74B2RQMxuL9V0kWwaezM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052044; 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=CGVRb7EBV+LwfGEw8lnyX0eW3b4ReOJIfTvIMhY3KbIn9FH+kCcywmpJgXCg1vyEodHhF/KYMpJVT9XsChchWhCg4flD1bTjt3swC5SZqF6Vr+gOnw2AIEuel5W5bKMwf3Xx+fuTuO63Wpcojhysa5Bcydw5pU5kDlR7tHIfSXE= 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.134 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=nbgP1xoEFh2PcgrPzG4+itL2LnCtHltF55Fq0p/PVoi+y6RSVXP8ehFXjDV6rmX04XMUkUXFcVpRpYB940TIdcjWr/OEksRI412F0nwRiF1klCOpxcpXdv8NdEOFwmx4cxTiRYGEdjexNP7JT6w3t8AgiXN1xbgDEatfOtellcjHhb/BM7ki9HJH4I5LjG4zQ6thCLobHldiB80Vuvg2EHJIGYB4R2s5CFFdWXgatwy6KYJtJY9wOhdfv/rD0CFc9/PdP5+QNX3Dz1e+SH6qJswH3Qo0jx3Ek7+jozTEFz8nFzOn0Kx8SDz134JTzzQfbYES4u00n5MwtsxM99cKnw== 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=ejlZirW5PYAxJt/T2otnw7iVT3X5RKqiKmjMp5Tol4p34Uv5xnrpY1g1IGpCzdgNybM33PTlw7DyzYD3blST/NRHGuhwaIztBIMyoxmVMbfQRrEFQmXq4O2uh39sNzyGp9k6eRTvnpZCte5YXaBL8/i6Fqkos68qdNotJIqOfxpV3gTbmnH07de4dnkaMnKmx9di+hdHEynMe6Tip2hLOk6HC2IRyQdQrdS3lGnGMAzBk1FljnFib19GKZxht/XpcEyzMBmc2NQOoEyposR/uw9p8EZd1YmZg86jdBnNwwR/Yt78eiigun/QDoiHnR++3thhYmTAGUzab1UtGvNXKA== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0862.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:27::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 2 Apr 2024 10:00:32 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:32 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 07/13] staging: media: starfive: Separate ISP hardware from capture device Date: Tue, 2 Apr 2024 03:00:05 -0700 Message-Id: <20240402100011.13480-8-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0862:EE_ X-MS-Office365-Filtering-Correlation-Id: 941a7dd1-2438-4d9f-ebc1-08dc52fbbc1c X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZvtzNRAga71ntLfhHgQIAzh8zcdlPeN6X27/rPSoiIIk13JTr3+dHpNZeYNvHooqr5yt34GSWru5zKx7QK2KUGOe03LWKhwASEevu8wXwKg+TdZkpjFKL67t7SUcXWKMgBI5kah5L7kkIGFVVHaD8TCYmVepLlKNu4WXa0FFW3T8GpfkdGyJqndPDWzDtgeH+P7CSn9u2B3h2d2AZh2ACkyuqyTjhV3+hBCGQlTt1UJ9HbN0K/Q6EwENEKwDa808JYMl12YPauAukS9+XOqx26o+QcYWX/sSeZSRDffoAlcBSUNv4GFX9mUnicd2qLQX9wArykvWPdNsS1Uf7qBww0AGt2qG+wRVQJQWIeZs1BWrj7gZH2r3m7jycndIWwY9o+4OPSO5a4mpQ+DPWncGeduMdqP5p4TOANUD1uDx3L1atdDPvheEaIKAezixlqEfJlWuAi+pCujcFmqAZL8ih/3ayPQWJLoD4O0ntLdXhAsMzAe2rCLQAhCoE9U+Z3vJ5QA7ae/bHTGfLAxkP5Y4a3gHOhRNVz1uL2djgCpJkC0R+o2l2TRUzckdcno5eNQ0Zto5hGryMrOW0188YYbgcAaGNnqHvvIA78JyQG8jZmFvWnb1S4z4qsZNYp/MmmGRC83KrPCee8qjEjGUqG1Y7w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(41320700004)(366007)(1800799015)(7416005)(52116005)(38350700005)(921011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LLLPJA4V3wPrkSqFj+UZz+YDRBvWAAvuLw4A3lmbbeptw8dtoNZGbDZkOcfilBAver7oNEoXJJvoVZ/uAUqZPVOAGJ0t6nzxcWmQp14Fc1leEG3ZzSCoIiZsWkFvdo3D8qaVpT9vUEfPQuho8tICUEmTtPU+dB9dSnaeUBFuBj7QSSlYgfA5ax8zcBbMLK1yee1TuL6amAvX+npTvRlPbkhQv+OvTrGos3VIT4tvWudboy5NgsaKf+Q2KCAfK++EsB+u3dHODZysaYKr2eBNUFE9yk55N82JgUz/6VL9eMhSwprEdtBpP210/FsfOAV1suArsgdjZzm39+qZEB9qYruGYlUpQ1ii/YRH1owUcRQJEHZuGuWXrLWn6pi6r0MiOVQJakYVpH4OzVZL/VeZtQOWx6OhICQ+/ZBX9VlPB2r3bF8XXWq8/96/Ci6qgIkbomFxXlYA5fEyIoJxZq1NR8jcNXgLqicSQKEHUng3LEleNqlqqMCJ50IQZS1+IzO8HIUaKtupDUMH/gxEC5MpjAhxxBM3xNHwI+tF7z04cnCArTJvBqo1NojUCuaLWMazCtL6/fxgtblrDixe/+OFNmF1jkocV91YRx3XxtGI1nWOLWNMIyuTfY/szxpK/m+IaSzgYXVR9cWtLf8bF/jjwIZBhgKSCAX3NBneV3cQuYR0PtQOiU/4aHJcWDpBHa21s5GRE7tcfe7CzO2QuhAhrIh1DVY0r2VIVya0O2ei5QdK6/zePBFRkRPfVvOd+S4g0JqDi+eJz2g8FAPnaXnpmxH/kJd7ne2OzSSqssv50Ow264x9ZPIEsOXZGs5Pc60PxGLJLJisgRkPojYoExAbRJs6UkqSw/rZaSCp0wTI2MUvpEZ+igJ1T7wyNGb9zDPOcDdBrUONnC0iqnx5VZbp+AaH8QpWZ4HZ31390C17TgeIU2i/RNNJbfycZMttIp1QvLUDs40qCgq5j6Df972QwmqtQvHP4arhRSRziJsiks6Kr2AdWZJ/z+J/c2Pn678l8gLrS4iLHadnf306P0xEsTAxnrIz+5HFg7FJJ2cuRSN2pH4W14oL8AtXzU9Rp7nMHZdZkdhcHN7VxSWf+T7CcwXqm1JnwM1RkTtBGnIF8KmGnf3yqsXygFMyEmAM2Oz3qqxgoWMPmXlCIWMvwDv+KyNceEjSedePpl07ttmqkYuVLhx8VU6xHzaBvj5OyjIRCKi3Pmmy1Q81EjGdLa9IhfnjRr+HQLykTC9o8Rrh2YbrSNtcF3zAEpefuvdUc1pn+Av18WPoqO5tIgx4Y9KT2szU1CL+ljapUcPosTjMmZ6Zj3oxx/9wXYe3w/2NXDDUZ8SMv7lEDgMyAFDQC57vXUWitmbhYTPndpmZQPt1sgeJj3/6W2VtwGot7LS+zDoa7DN7dNw7rCyzNoU8VUFJHDXtS+Ea6T3cI/Luhm0j6ClVUi36W2IEBsL/gXiC7sd/1MAsVjA69xeBFRn5mEMPsmgFr81W9hH1oLMdho0BZe+8yBFWLupfq1BRokUXDiSbWfzY3+Ym9Ghh96nxTPWQ0n3GzZDInYGwN4a/vX9mje3F4obzrGcrJeafzsSXKP/wbQJ4UNiDM7IM9iRBINLX/lObKzwJYkSl/8dyFQtvNRQ= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 941a7dd1-2438-4d9f-ebc1-08dc52fbbc1c X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:32.7187 (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: RDcJh/B2YBxHyYr8oZMHTZdXXXETrhYam0oCU2vlPjmZ7y5casuDcVr5SctaAUEWQYJdc7lPN/ZXjKtvD5M7ZJO08emj8PvH8gxs92W2cbj4hFLX/UwZufqHoR7FcEfa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0862 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 Apr 2 10:00:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613639 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2134.outbound.protection.partner.outlook.cn [139.219.146.134]) (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 D0A665EE97; Tue, 2 Apr 2024 10:00:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.134 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052047; cv=fail; b=cq2K7pDk1XfjakWfVJ9vjRvwKY2FciwtQTyhQj3nq1lvap8XSJISbsENs+MpSeAqRfDpNnnNJODXP7k/DhpQRyqsfRurBIJwkinTz2IlyfJSUcfye/W5YNlliKDi/l+fZwmxtP8p6Fazy69VL89z1dp/1gyLRmqQ77nbEbXefms= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052047; c=relaxed/simple; bh=thuUBZn6WEQ7V9/XqRBOxoUV9tG2qm++7+sBUJNoNc8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=RgUG3lGHEiDn9Tj+3ixTwIKHE8yjxnjGc0MNJle1VB/ZUSIM/icciDVH4M+7PW2FzSSayiC0j7qfBpGub/SCG3qGKckjFgG0woPbRFwDPDihDObhXbE1eT3BziEDfYY4s8C79lm7j5tulZqMVt7jRn9Ci1pdjq2mBGnMcbiQIq4= 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.134 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=beG92suycSO4ZupaFZFqWoFcuFJ/O+pq747aBzqXK4aXBFaLpVN/PEUseuhDIP7IEwxAQZVIGFNaYVvUTbF5v6paO7hijH9+WDQEQt5rG+Z4FKm/ns7XX0vAlOi9IxeQ51Z+cNslJ1pIwojSMTmRbQ6KUjglB3FBjaOcQApCAeQz6nQBZokBGeqD0p5EAmWvTdd8FC3yvQH5FYMM6W2rwvmJiRj+VXTzHT0bWsCsZQHVEI2AK4g1wmhcNhvsgdFHttD+onrEqR0Nwvx2GuEg+NxdcEwCYeWMv8X0QRcoEHdzJixC6/vhKyRDABPwsbbYHXY/Q1ht7xHRO70qyZ8RmA== 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=hqgLyFITePX6RyQniAWmO+v05oRBpAbNPKhuvXfdp/8=; b=XQ2cltQc09rosjFxu7yOZ4sko7jYMvdLSOs/ylRbbWMFLxf70pmgyKBkaI3M3FB6j9Cd+B2IWfmXwl0sxzI+2Peoh67qW9viOSqvyURMjFQmifu89SyL3cwWVqArtoMB621mkwh91J/WtXZuc7fQ7rw0CXajQNB6F1iW4hl23EeTpsYk8isVnD/Gt5O5RMNtPc/1a5VZ00JcBIVDTAfQW/R5D9ydlEygzv11mxTv51HG2EPYDjaBVkdiSRBlHlJKOeafYpL5ODUDZYRYExp5zuBS8ZUpKZJ0SSbGGQ0fgojZ82PANC6gJePOTz34Eo4yegUbOBazDH5mw3M3tJcbXQ== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0862.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:27::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 2 Apr 2024 10:00:34 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:34 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 08/13] staging: media: starfive: Add for StarFive ISP 3A SC Date: Tue, 2 Apr 2024 03:00:06 -0700 Message-Id: <20240402100011.13480-9-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0862:EE_ X-MS-Office365-Filtering-Correlation-Id: f9f68321-6e10-4481-9970-08dc52fbbd24 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pTirFKNmTD/+vWZkDrdYaJWgez2Ly57J9YkWiq0CZCFGH5tuRKD5hDnbykVgBDBn7aDeGPq0nGPr5BgjHnBRH1sI6c9XQ3EqJOaFgLTJyXKQUT0UrauF88oJkQIG927ZBtwMcUltSmhJ6t+gORpEWe5XZ2edJzNIwBep6mIcdZmPgVSkyBmid39IadVv4p87/6aQbjbz3rQB38b85b46fFFpSqIYe3mawvIHwtZ02DV8KV1aQQKu9gaxEkj/PmYfJLy7E9PTLnQFT1N2kVwzSSrH9wmc30xnvSDVxC403VMZCKToBn8TP7w7rqkpFBpL2eaNSYHV97eWXC/k9do+78u+Huvleaa4grzysYAmYW4N7Plw2hGUC2Luw9i5dOOFYARuU/oyWVBBFSH+UdCEZ2/rW6ZKzgu9ZfIdnfiyA4Mllw4zlFxgn/E4sBSgV5vCa+waUZvQZA9vdhPLeodOHEBq/eIPjGbNmtSXF2XDqxFjJq8oQfv2b+cQW/WLSzdxQxIQLI50JzJGDOo5FG2vU/3eomKs0BI3p0J3IiPSf5iem6Upe/7rsvmOHYnPwXKnf/yd+tVOaVl8mTSnllgnbZkiG2VLR+2wQ4Zp1dB6tlsh+LNx5YYYe6T+M5omQymVL5BLt9Y96KmoW8q+Ywx0TA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(41320700004)(366007)(1800799015)(7416005)(52116005)(38350700005)(921011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eHhi1M6VP9lHcu+1bdwebuB+TdSyNASoNF+jVDXQAEpEskF6D7Z6Sx2tvELXstmfFXXfGzOYuxibs/xYy3AP+2ulTbXA7rNgKWItPqq/+LinEJuWc+CmY8wnvQoXAKnMxQYOyyuBmWLZacDi/LvDkDlIE1UBIPd9wQDdRpPMIL561WU8nrrRl+d5LgIg3wYScoiWkG5rSIfXJ3EvRQviI0gt0udZFSS46xMNAGU4Hi90rv8KlPjHo+t+AyoqZJrlrEGMoYXJG5BYrg13T565grFMEpBSql+wpIits2cl9CrIdMRqPhTYlk6qlpdBIyFxDVFclHCMCaBcrjh8s4RKTcFhC1OniGY1iw2SYvx5kjLp+R5xB2k1S6ZtIyQHwQkeoMzxHwW1ml2AE5S3OZUpjmdKvrCWnJw68RdzeHQRI4CGFxigBBsBiaeoq5wHR5FVtLVk6IuL9KNhBz1KSBwgtsIXD/Jx9LXwjQLM65EIOxOLkiHGCkLEco7b2oomVTY7Mg0ievqPT29WltSfGwCOID+hVlCckfhOnf589+nVdYyThf0E5MCNFbFsJ7zfeKqe0qVHmVVeTEcpyMVeW3QLdCkVztS8BIKulz/fWX33+Mali4dqqEu6+CpYJBhEY91XpO2z1qdT6EsCPmG+8AEzle7JvSSCfjxYC8jQEaP33mWhQ5KytbJPYrZH1UnmLflZ0tkjh2EDARVcV4Rcvj/Zy71ROouy5Tb24RYnbBTYSYoVzFb1rRhF7nWREF0c1ZuqwLf1W8XSCP8VbUYK2OmVQdzur4fkcYZuGmv3ESdzcoELAeS1B5KNqpwFDhx8XhbPa7l9kXCtpJGffTmfD1N6XYbz7M4MihHaW1hHiyTWKnPc27+s9jO8kdmZD4AHO6jNh4irmc7QqQtBZ/s74rOkjsxcOfaFCdpZm+6+9F3J2orlj+4/ce/l15x6JuszD6FxjdISWJwEbIRUm0shD1f4c4wp4EnzRadD6Asu5S9CTscPn0L7SMZSGeNmj1wdQQuOk3C7HmIod9F3FMkOY5VYk/d9yvEMcTi4BA8XFwjHSuXIo/pWzanVc0bqY9w74B/i33XS4RXl3X+nrCXmeWOghfV3UbTZlbjib0d6RVny4mzDv6EvW6DRY629usvlsXL9MW9L5+kjqsX72QvNDpcFtCyTfxAIkvjJifz/DnuBbWjVZ0NoxbBQBRDDLCfbHUKCuO6pf/nteqNMxkNr26Z/UNkct1TWonxbM6wzM5WR7nFkCM245NmaPbZSvLsu801s6wLXhaoRN+HrzBOt/LhIoH5k8dTJbVpNvRFl2Mj6FgxFCD9OhZXmI2vbYx3poT5TbbMLMysBQG1SMN+5oHmo9xJ2AR2v1JnyG/lZ8dlJxhoeu2zIXYy3iz66TQ16h+HLDdkZ+nbNKxMbbKYbDeZqFOG5DtXcNwaLD0rM4X120rwpSdE09exBiJuwLoImDXMDJ7h7pWsd0WJCewDA1bLNLZ/ONjY5Jo5jGuwVQQyr1DdSRRYV4nBF/hd63Ptu3kULpSWjhMFcErNi7ySCFUj3sZogiDeuBSS4qSSVnqTMJSWpnG09mkLbSo7l6fqQRPsFV4FsOst17V5hqaHsZfVqaj7m+hNRVundaHMSn16XoY8= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9f68321-6e10-4481-9970-08dc52fbbd24 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:34.4393 (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: ES/5aO8rtR2va8FFbcSeVbsnzNeXVUxAqf3uUdzrIG0orJE89C+1HyTwS2M4JoSKVLt6QiHEXE3j+YvraUUkUo6kmS4iyNTYRt6b3/OPJVcGyH7TMzY3KptZ1VgCRhsG X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0862 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 | 13 ++ .../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 | 143 +++++++++++++++++- .../staging/media/starfive/camss/stf-video.h | 1 + 7 files changed, 259 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 323aa70fdeaf..3fe4e3332719 100644 --- a/drivers/staging/media/starfive/camss/stf-camss.c +++ b/drivers/staging/media/starfive/camss/stf-camss.c @@ -126,6 +126,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 +151,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 +174,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); 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..abdfa4417145 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_FALG_AWB; + *type_scd = TYPE_OECF; + } else { + sc->flag = JH7110_ISP_SC_FALG_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..d9e51d4e2004 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,75 @@ 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[]) +{ + *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 +525,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 +581,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 +617,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 +644,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 Apr 2 10:00:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613653 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2100.outbound.protection.partner.outlook.cn [139.219.146.100]) (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 680DC5B1E4; Tue, 2 Apr 2024 10:16:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.100 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712053011; cv=fail; b=hS8Cm6YZXRJLYcUT4htSR9uMZD3/9fJRzmYFjxCrhzSbp6HT6JTJNClFqU51/MxvR2FFNZ5aITFVtOV0Cs9XoKm+7MhuiVasc8SZ4sM2WmCZ5yl+oDqnuZW5qbnzfwg73CDfkX7favmVEOGROsiUms87fc5GhOlQ99ZYXNKMEhU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712053011; c=relaxed/simple; bh=1jsNSzcZJQxwnztZGcLKpgcyMoi6HgGenOf9AFmjySE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UD6kIfU7qMFt6n24AkaFKy5uc545K3q0EMyGlk+7qaQqtRN2Bd36BJgRL3GcAbr8Zyaynj7cX9zCOtur+hLuzR70jJUOsdxGVAXE46aniUWjhpcIxBd/qgXRACFW5vGAM0GUTIZ6bAPS32efmEkyncdl/PaD+yRgHWWwZxUzp3w= 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.100 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=hijIz2dPSs/rrsptoLXV0rZ3kczby4U02Gadb/InielvfdZzzC4+cFIqgpymJeam4klYYRmiMCm2nJCT3BRkShDZrc3AVK+x0seqACIp1qPfFRxoWaqyhvI5KCl6IzsAmVNAx/DdsH+UEipXLN7jdBin6npXQR+GMlvBxwKuJUKCRaSczl1UpXM5HiEZGB7f+2P5QcnF+pVaDoA4EDxli2vII88plsl26CShNp4oynZQgRTlcrFuuPh7+QPeykj381kNqn9zLLOy5+99BybwEa0wV/A87JqKlVbISw59wub6zcRw4j6foa+dOdI27JDYOnET2EctqFPB7wNYSwfkGA== 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=aTyRtTjTprt5edZgI0pRawIc56nV6QnENHlmP/oD6YY=; b=iZD01BkkGjSv927L2VwvOPllBB2xnnhL5ENpo3BLUwqKj4NY3xjYAcpOSrG5N1pB+NHvwei2kDwHG/pVBpXk/qLewYmUGE4TkhlZ4fXLvAiLPWzfGBYgPGuflQT5aDUhMJwjWIa82oHRh1aFG5GHVFUKMtt+r9AC3qg5nJXgZWLx7iQ6PO+E0sgoiTz8XCrEu+nDoPJvE+NCyfHg2iu5ezjbHveWUBHbFNn9ycp5T3IL0Do88phxzBc5GzwdbP/nraKEhuGpYAYmlpzGah+Xz8mWrCo3tVpkq3QU2j7xvBCCkfkkfe+njleg+p13iNUQQeXBcQc2HA7w9xiWeHOQxg== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0462.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 2 Apr 2024 10:00:36 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:36 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 09/13] staging: media: starfive: Update ISP initialise config for 3A Date: Tue, 2 Apr 2024 03:00:07 -0700 Message-Id: <20240402100011.13480-10-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0462:EE_ X-MS-Office365-Filtering-Correlation-Id: 228ab50b-6775-4adf-a629-08dc52fbbe29 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lSBdTQvul5hpVeubjjuG2xS/yUP/OukHClyKQZ8ZcWnHMTl2kKPh9JL7ym5Lt3Ro30i1Xe2mkEMYkFHew553hJc2+hI1YQim2zU1bDyyJP3EBiseOc/6/Ch0kCy2wGU6Ls9L2caZAm0gnPWN9DZm20pfRYV6aYmh8xHJx8NWvCO1oewCvLBeHDx4deDK5be5PYoA58L67Rrbf+tIUdSBbAm1xtHhUYgmGJi58slPvLlhcQEle1fMaTQc9TY4i6Ozkx8cQeBiRruUXRYAcL5kZVyqOqF0ldnI4q9mtp4E7Ri54xz/y4blTKVf6i5cTe1hwKjlG14PTTGMCrPFy/p6qrD1bI/gnmjptlma+cCVZFjsbGoOpS70pTMh93FtHtG+jmdd3ctmNHOohX0/ZeHUvqarDSylXMxyhQINIAKNLxPg5oj+7zaigtcyKbgMvzYZE1PwEZPuhUtUZq/nRVAhw8JtlmgBdcVh3yBllq5Ewkcuyu42/WfSW8KF5JSCYJeV9DRzR2wsNP1KRZPkE9KsbWMd8bXlrCsjNau3EowO5bYULGthvE6725G2gDMnm2MQ0mprzfXl0oLeaDwkuRyHOzZ1OSWIZsiNBaWtEj4OZa/VScvRgEt9WsYTS8KK4952p7mJSwJhaxDKpVUdNRT37Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(52116005)(7416005)(41320700004)(366007)(38350700005)(921011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N1TZoTMwLsaK8EIt/1OQvq3fy1DynULwr4hPLCzlez4EzOHto5aRLIY2QwG3kcidopEAwv11YHG0FkCid5WCw0De1ZnXRrAFqDgSbggFeT1q93T8RDFIkWlqbC5i2MCaAABvqJHmsGYudFaTEh47GT5typhsGh0DjdZNUZ4Uh8/odX0U7v77ezckesuyF8SaVfX6toS6MsXiWhv61rkK7kP/SL6QfH1XIJd1Tc1IZWIxV/M7G8956MDfywJtUMq8Yfh6Le3gLxD/s1ToPHonOyV5n3JP4VsFBxn1ARCXvae0qxNDm7OCAfCbCf45FPPkWT0FXA3fPDGP+bCDoMj/0HE9STsFFJ9Kj0Fx4hmF+M3JoJvjTKhdtAyIQ4Udc8OiTmtIeHQhy4FxnqLVN5tEnK7Xru8dswRI3Li4NDSuAKGeOPeduOaGGK0Y3gKmnlyb79RI6eV5GgE8fIjf+0kZ+ZjAvaK5+XMZkm+S//9E9a5is01CCow1cDx4YHmlFOTPVEbHwz6orhxCvPuPFtcJO71TH6xOXTQ7Vn0VhrY+kA2OaEVv9cUaCiYEUvEWk96/5aiXpbFs94mADy7a5vlZR1YhV29gpULstNa4Aav4n6d6T9+lE88KNCvM0ZaH+ppzzps20zpiCiY3UlsID4iBWF6gFbdFFpFp/prKjYbjGfNsNcakpFMUkeJpHFAhItVGc5gs7TObFyuOwVmiCxgDAgGKDLCT/hHK89UB7AUocKKh4zsTzyzTdSJrCpjZQdkWKBdTz2Mxtm++atoVNOFTxdGvs7K7ujh8f7j6mk+EcsLLL7bVtziSGC/E9FWn0Phb17gEQ/qbmQauX1FxZITGczwGtx/jW0iChE1xSphCAL0p45GOn6r1hy4dWP/vkHJwbxc/LnjW4DlN8IYf/RLlfSyFY8exTKd+u7Kc0S7zvQR2Zdpbha80xEXRQgtxN2uknWGUsbaJTpqj7VfbqEHQRgn6ZzAg0B9sbpabmqMct8y7WPhVeU5SfQ2cweqHcPS6oKasyOOE02Na/Ydkl2iVv9jnLoBqzlQIdLwgPVmxPRDHCK6/QO50QDacQtQIkiN+dX50D7oj50DQLImU5nTnmyWcqJbScPpYdSLfvNeTL1TKrLEHY/hrAuKIW3MiHXd+oUGAQOQkarWq3FXYzPvBjBBkDhZGfeMswJW/a+OP8QD8j+v7a4txb6PqDW9ufY2F9ohTo0nqXGKmU4rZ7KtbdlqPagROeBOSot9uRiSw0CHPO8r8gKbipXZ7rGzPpiWlYyZMdtv1VObFJzlhMkaZczqP83SmIK9tdennnGn5xzn3737AAT8XtMxD106MHgGQ1yjdGYghKsg/o35TwNZZzw9MrGPDmXBPDAyxPHMqY3OKguUVWblY1OZQzMnP902TAzLJG/RxXtdMn4/TrdvJtyB9JwQxZ7puB35LcP7YtvMHGFIM6Uj16HJNx4wY2o3+Wy/Oqaf3a4S3DVBF1tqEdL3pCZmem4eEy6w30sB7n+yFRFMirPjPIfxSb8eiqtVKk3+P9A57mTUhSDEOBHCNdZOtkFw/ODQ69uUWN+6yTT0EIM9nSnQRhhjlVS9RsZCmND6OJPDDP9drSPvtA06g9TNSSJC0ChlE2qIvRAA+bvI= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 228ab50b-6775-4adf-a629-08dc52fbbe29 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:36.1542 (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: tqK2DaHGv6rJFyrgnbJG4G771U4FQIEGkNLkF+mK2WyeM67gEOrzy+bz/J7nGpp/sq6psckjhq0vSzW5DLHIBpps9yziHJj4cCQscylpF5fTm0JlK7+NILxhXZ76yAE+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0462 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 abdfa4417145..7b2cc596e967 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 Apr 2 10:00:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613778 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2099.outbound.protection.partner.outlook.cn [139.219.17.99]) (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 9B4536996E; Tue, 2 Apr 2024 11:34:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.99 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712057666; cv=fail; b=U3rqN8+310x+lC1g0riHZNlPfhYbaHG1WzJdAU6NaN2B+5EBGC5vjS0A8LrsNusVqNx4vwoVcFng1BsnuY9Pt8+eiyZcg6r8CvGoEtd0sQMN2qnbgODFYGsQe7Odp6l02HztennMLFSPuWkJB8aIpjYOOhTBPqoZBdMnP05tpzg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712057666; c=relaxed/simple; bh=ZqS10ZAMwMKng4bCcyIYliSH0HU2nzc9NUI+fmHqPks=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=HAoFBt1AzQVfk6UIQ0DE3hOndAwMprk/Tykk2Dje1ajsuSkkbMZBr0n4CK2XN62fhrFsNa3uuu6qz1sEYIsAYFZibMUqZzbNWiyPhCGEagnB3ke55IavUeYwj5jDKaKtd5MywMoD1vawl2/NTxODeNjwWXMGBPhDzYu2LA4u4w8= 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.99 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=daYlQVy0dvMGPWZ7c8gBbo/98HrnklsMOMLfAQR06P9O+LKwIetX5rTzLBMl+LxlOGagDNSA2cxOvs89EMyu7ujtYm9lYj3gPZci3o+XAmZLB9X7MK8GAWot5q4nWW1g+Uw/KiznEPy+FqeFbe7QpN1eZptTtaNU0axhjCDRxZw9wkkzvFuC9PQp7htHvH+i46GA6r4un0plgrugE49CnyFMwvoAeMU735UY08bMKo73r9/7I6cLz2M+T4tj4U0Iusd6zz+af8QgZa0y5i24R2jU8nUzLIJzRkkhqg/t75kdoUOTtB8y2jU61kv2MMFtpAfmziYALIfk9DM2hKVu+A== 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=IpYS+v+cBn1HqDAmhXTHJL+v2aLemV00fes8PvGvKzM=; b=YD8DStXGF3TibSz/ydKCXpnkOFbP1pKPYh7az9HwpM6gTSgvPXo8cgVsEad77RhqqkLygWwkuyT8ojApFDafym4tz7gTAE5IHqo993co+qHsuUmHRLPYq/jjBhDV4ROWvkqTfM+mjS6fH33apSjKp3nNjLCnANxcORWPhi8SBmjU8GULmoELw661ljKtYl00pnkwq7NBLIOjmxqLNRKgAxdWx6tBIbSnY9BqUO09xlsoc6ZNI4IlkaHaImHV9ugkSn80+iPf3035Ko45PI528gHF330KlvC0uFqXcKvJBkevawzX42aO2zIcTRAhe7/QtUHgXNwInsUDWya1+pHITQ== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0462.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 2 Apr 2024 10:00:38 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:37 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 10/13] staging: media: starfive: Add V4L2_CAP_IO_MC capability Date: Tue, 2 Apr 2024 03:00:08 -0700 Message-Id: <20240402100011.13480-11-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0462:EE_ X-MS-Office365-Filtering-Correlation-Id: 19475ed6-e837-4fe2-7130-08dc52fbbf37 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jC2asqYZDPvM7257TdOE38s6girr4yTXNr+Z1FQdqcOSxSl4+vD2PdQ+UXut/nc/h7Yj73Ch0Bt2BBO10t3/UjiUhtC8nhcG5EfLPlC1Zv1eWPHq7Vn6wWID/vpdaVxFXsa7g31rJScXftHEGBV8a910XuGm80v5Ocm7xv/fnCjveuJExxQ8n/kJcf4D8LsNpoDH+1dLDjXI3LUDX8OYXszoaOn0tVom3pfB0oeepnWUtluA9Xkb2BmK31ubLDs13PTM6t9Ypx40ddCWiRSfENkbbI6RSavz6ayit0gUDozwLNqg0Vcg3k1tuU4WeeJOil08//PfTGf6eL7JdPx7gMeQyDERimxI7IbKW/GpOda9roNyNRo+d/WcFfjZay3WSy0XefRhzGW0NLA23pzCuSFNSvg87pXMQ7oyRZx/wSQImf/79NunB1LET44TmbnKSCqo+q7XpGV8dnzlht9R2vXSVX+YKAPp0dbHcyrJNPSRN6M88vm/JBN6P0cphNzWrohEBBigK2mFZYrfAVA57HiSVFL3RKfjnJKbY05erDAITHFd9qbof0J8TDj/ia+CJLwwjVr3dQ1prQAsafeWW86h6wWJPIEDj7LFJq4BpHNyhF7TvYhHCBdXVty8MBLhdMjyriLv/r3Cj7CueTOYZA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(52116005)(7416005)(41320700004)(366007)(38350700005)(921011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TtLTMtOAhQ3yKSjXXB2ZSmv4xrSpfNMoekM7kO6NoPEJSJd10koWCiED79Jvl93V+sqYxpaMLZdT/ZttzXbXYKd6xhq0Ji5nD7TWfhPPGYFY9whSCLhKZ90UTVuD5yfvp4s5GupgIM5lhHK4/nUgL2rNGNAQpCt6dYgxNYiZuWLidSRGq4cW5mfgllO2tvQPSEbCUHrmRZ+bBaWwJcDKNq2ycGmiJPQp4hu5GyGxy5dZqLR8y4Ooz3Xe3pCoPrx04zh577GavvMZUf5t9ZWEhGk2mmXUoJAi68BoiDlsh01TJrS+V/0QkIwLdxJy1sb2UzxYxmV8m96lNnjSSlOnLrp7Y9EhsClXRPqX7Vtr5zuCP2a2L6F88CG/ocaT3GRq0/pbVAvipKuSUXJuYlyDXcgeGvZkB9s/DNVRKYeCeVJbPV7T28PVHk/gTtBeUHCHwL9kpneJkBOVLzfzVivulzSKpSgUvWCExN74pP1doDjKr2FVsd0DmgklpbDaofjTMmUdI4NURzpWNub5om4UHbGrXjFvfW+cFi5CC3Bxj7LIIAIOvzeOU/OmPPSYFCnp15PM3t8QajD8G68HuBP77fcQD5bAAiWaQQ5RD4dXd05n2ZepaBmquIlST8bprN2d5d5HMqmO5q0XkUnCrqe/MMtHvqvyUS7YQES9dNLJsIjRDGBgA408pyUF8LveFEt8wWSvDysnZIUU49HPxobv11o9oNV3po81Ew5HkOtfmEp/mPECxF81OMB8WeynnwkZ0j+bAmmJXZZpHmAxr5F/z5rwfTPg6O5hyM8LUzS07xNs1RLm/qdNS1ULSsds+HcIxqtcE4lW7gd3XBngvO+sS77fYSJz/ARKzJeA30z9OXqODcNjI1P1Vk+cjPHssrDWUHNnmoBeREnUndTjtvNKqRydAXKsItQpv0UvHLLi3/RXf1FhTcYxi63NJ3UGOfdTClt2ncZPUK05xhwI3A9i3q4XWx1YREsbUr8hI24awK+RWBQcybtKdPS6xmQaD12W7bz1/i91bu8XKH66ELBQG0O1kpjCIjxHQ92FCb3MDq1TA8NrSRBlDIVOjKjIOyY20KiWB33+gjnPdKXVmBkJr4nXYl0/e4egZkBCnMrBSEsIvGn0QLA05EpF/IEaPAd0Rf1GehffvgGCdrYys5VbUYwXdaNAM9OcOrznS2aMXd4AlpGBHjde0bBGAbg0YDRpDQa0+PfshlB7abcZNV0DbS2Yw3E7LbDaCflNB35tlcU+Af56rOB9HXebprZVl6Nz3tplVAIAsdBT1XMJ4W+NZb36cQOsadXX6oVyJnAMJ1CDCclhS7oZGkMIWObTZV0DOgrj2VbbItVx3XirP9OMoX9QMONtgfglEbrQ02/6/1bloUTipuuxAqIiLeb4Y133HKpiAsNSV5afsAvzMI+TWBBKmO/mRQNpYfTrHVptIHiE5QW9Gi2IeFG0DbSuqYefWipJsKqr3C3QoJ/aq3Ex1w6QvJvziW1bcI20XJn+ETGeojZeyOkdF460V5zCbuvVMpSI3mYWR0hxqKR2khrrc5YDyT2rXFZMsnnYND3mknKMo6ke+FOvNBJjaZzcOnZSxBwUV09S5ds7v9lC2uEyxt7JCIa9yo3BwXgZ+7lJZT0= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19475ed6-e837-4fe2-7130-08dc52fbbf37 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:37.9349 (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: V4h5e6lKJaPFZk5uVM0u8Ch3dT2aehoqFcS641D6ZiqVo+Hncu7rP5CniAWpfHe85Kbw8WF2Bpu7W1dgmC6izRIhT3M49s6UabvY95FpADQWTXFU/jR/JmpyYHtEKa71 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0462 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 d9e51d4e2004..4ca889a7b757 100644 --- a/drivers/staging/media/starfive/camss/stf-video.c +++ b/drivers/staging/media/starfive/camss/stf-video.c @@ -665,7 +665,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 Apr 2 10:00:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613689 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2115.outbound.protection.partner.outlook.cn [139.219.146.115]) (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 881025D749; Tue, 2 Apr 2024 10:34:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.115 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712054050; cv=fail; b=YrcjRLVW9mSzqpv5mcdJtwNQFIe/fHLh14rM/TTXYGqsNp0WImZg0r9eJqAiFfrL7wVknnGd3GYIQ8tspHSApE/7+h3exW1ZcWOmD55INfC88kWuQ6faAMs716YYg3tb4TsYm3HS9jWevRqK69/XVqVJezbrlqz/V3sa+C1mR0A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712054050; c=relaxed/simple; bh=3wPJeuqg+XjtvRChC7cZeMIpVlM/VxDZB37ms6ho46Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=P+bODGDzH28poopMW6f6yLatK/kTkdA64YXZKyeg92qiiEyUaMTfeJAlRWCd4I4jjLRQS+KSdhKmRN8wqhZ5Bpg25wa3/3eIEdfRjbx8jSfEuelEJqFqfaGZQHf2qhnBsiSBHvW+S2rmLvlcvoAkDnosq8Qppju4Ehq0o019lQw= 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.115 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=OKCgr4tQC+3JWSYW1RbbkN5tkttHk77DbMOl3ExKNR+DkPCTWHctMTQV12OfsaXiD0/UnnXQGdAH5qbi8wnRBLaRIITWg6UTy15xerI7b4vHPpWIZ+63ItZODzJYK5CUY51XPPrTHGUxs1MS96RvSQS5teMZ2xKmNuwgDb0uvLKF07MvU0j0kfzvvYxySHB9t4TL5zLT4XGRBL8hKZ+BEAh7eJbzdjjj9Fe4/ixWb3F03E+259Ed9+Q67n8/Z4E5vheBSV9Y74g08xCLiVH13C5Ix1KU5hz7hSKIP3rWd9En7V+pAVu7a+BHqAB8Pm/F16UVbX6RNaXEsZrey8M/ZQ== 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=1Aac1iEzUkOA0iE0SzMFYIYlDMtGQLHNrnjiiQQSCUA=; b=JwbgBdY4PgDsTsDd1zrvpsMXZMdIfgCou11IrFK7gwUwNDPt16VZje+Ni+hviGFedCDFB25GpafpnUeBccHDoH0zulgN2H54x4YMT8Gmr9ENu7WGM86HisD1jMjmpCv7BaeyifPYMNnPyXP1pwW3LkRhNyVcMZ4Dzy9+Y7hzipxmfc2u8XtNO5pptD6/9PAVPZ0JIUwqWi4gP86j7GcEjO0CwsvU2GUHz9c8tWJ0177zmX2N3ii0ksXTtrJE6gf2Fxjvxj+L25pTqiLgQJlPlrAF2EAbiQ0Y0V918RT+pxC5g5El6yZYD9IJtOzK2X1M/rYADXC5tFuu/GVuJQpAOA== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0462.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 2 Apr 2024 10:00:39 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:39 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 11/13] staging: media: starfive: Add ISP params video device Date: Tue, 2 Apr 2024 03:00:09 -0700 Message-Id: <20240402100011.13480-12-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0462:EE_ X-MS-Office365-Filtering-Correlation-Id: 61abdbe4-3d9a-45ad-b00a-08dc52fbc049 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wBmFJQiqYjALFV7o8z8xn4OBvmlk1D9/lBGr9pBxFequTj1r4+6dd/5aSv9g0tLgeHs687YIIxvc5nufswVujTjnV58mRNIPcuJi/voGeSZ0smT3vqV6Rx06wq9TfMnNwICPgUo9BiqGQaxTNUGUJG+JdQ6hjs53Lbe0ExGBbmUVUZjAcg/U9IyIZrVNQD9+xaYgK2t1ZccLhNvk8PDsFmZUHYUg4WXmIaonlodi+jzibmFJmsnsmRe0YCTOTgoBWfaR+NUMIE8WU4nUNI+3bSzYMBE3hQAmO5MK9Ur4kNCWZcPZKJwQX652j98TBXmYuMRvmYl30ZnVTQ82aZfDvV8CcpB3c6ZrZYcjrOVwX4E4ES+Nxq124vmYAnsp5bbS8FrJDrR7q0UAlSD2kwcbYCbZCgyLjY+yCMdslictHPwjMyIgb81TKwYjC4wDyktNVdK4BULKCp3i+vTOXY3IA9zQaY0qKR23omRxOuJ+Tkla+oWdW9G1CwevrI9pYisZR8zp52PQyO/PKSoX+HGwZzKU8IZPILKofhBkmtZdzToyAGJ8Ws1WoC0CkHayzLvPIM8mLdOM//YG6SmasE6fBrm1LXFkQ8XGanlaex5Geg5Smdq4V9AtszZVolcvti6GPjnSehe4+3igwc3/nnVNNA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(52116005)(7416005)(41320700004)(366007)(38350700005)(921011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uTBtORuk4tYyFG/HV+8N8sCEBH5xeq+SoBkLhg6cjDmBezUaD+gbSavIlpaCsa/TJFWPacsBXi7DHU80sCR/oQ1074IOAZjN1lHRQZPpdHsZFc31yGE9P/AoS4rrhZRf8s2yCNKpTYnAf8NaERqcBm2WfPsKCLtOBIsdamH3fN/6pojETBYxsTMX8PDJIcr5hgOgTLqhGKotuYgBh5s+Fwkm8fM3lgtym01pdSGL0nLn6ZGAxa/j3Rkv5wM1hFdB3avl1xFBCyWiJXsiYFKZ3zeBeYIlaHoWg/SRoHjky/B1gRD9JyWEyqKKCk2ePA088RpnfM/n90GvbI/3aLW2UQyDHBznJFA0vPTY85TsFp02zo0+GEKwkQTJK2Q9IdRiPjyq6Rzh3GlZe8ogU5fwpewsJulW3zJxXgjyExmFqGUxZxvPRB2Adi+an5ARr+fguWDuf7RtSJjZLMDq9ckDvpxk3sDapS2/KD9M6IKc/GMP/4Z1jnXSnLt0gQmIoUKczajpwpL6jkpgXrRAJ4/ECqExMPyNelj+WVqrEUlRHAAzvB4GPmnYjWsmg4hkU2kM0c10i1pNItbP0miIyI7hUyakvopdPGep9KdJCQmrNrGGjKM7uZDU3WMvEMy7b2ju8L+u20PvRWR43bu7eV39Ef5kHuhtfqtDVCl+8jZHjzLhtJv1UPgFc8d3k4248T99wWmSpRcKdST73w3E2SNuGGiEFjDAbM6t/P4Hgc4ua6zjaUuaF+rEZDFLBCzyGrbl/NSdKNVe+0zSOdTXWUOxBOrHAmGNhqjc+0cTILNpOMZ2ysHyEBBXM45+4KChSTNZlNh4rTBGRynoV4uSlX1JG0scSEQyB+cfb1QeESxA04Se65KNltpXiQA2INMUwCD6WBQUul3x17d49QePUYs94o550UmeInuiLgWUbtQ+taLvRy2tpsSaJjKtuJumZvM+9AAZQYxgi3VzMafPiMd15xmgKSUHyNMnCSZ89ui7LGL0uXVz1U1f3E1OaqNIywKQERKaSc8R8GfBxkDkaIhXrFObZjg8aK9pbgoyDssJv6wuU2qRiH+VGUha8MRYoe6w1gSHYU4IOwWKpi+VwyH6frz1JPuEqzyRg50VZF1tMEshYDdMa+sbsKukBZLtwBr7JYGcNklxvBJnA7UouaoHJot5A+X0hRlOThkvrXr0PeXAB3DpMAtKS+rcfP7MEpsa35ylaew+VapyUG5qTlJTNff6A0TdcQgRQlXQ2PA82EQ7tS8BWbzQydp8tDKnmFQKyVVSAH0D5awpLsYS8TowF3iZiJJCD5rummQanz1D6T0BNpQodE+xLJnLEbQIVau/0b09c/0hoyPhx1wqBz/4V2mHYyH274OWK94vVDJoMY/AfLoERDkhmQca1M+HZTMFynwMqNp6oQjkQclC3EY6YJDznDPSThdtBItmbwilTcSMdFebIyxV3V6TwzeeotCtQdjBU+tQYqskYkXGiaJmQAbet/hMQX2eNKzx05hEvQiQi44GfpMiYqgTHPZOeA4e9/uCql36IhlZ0JTox5Blm00I08uG23JbgflLBSkDR9ac1H+duKsBQwlvAQasJq7rlwI9+Aflbiotk1y0rCUaU1Nn/229kg1vv+aXEn2nrgg= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61abdbe4-3d9a-45ad-b00a-08dc52fbc049 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:39.7196 (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: P6PebLRtqWHeYidfTBjkfZJY7vd9/hVunOSYqZ7SVIx5mdHBWpz0F6FKHTBlBMphKVZurObT6ghTwvaCF7GPHNIihLraqi08K4/5S5X+Az2ZmJNVo/ebL0pFR3Z1cw2/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0462 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 | 238 ++++++++++++++++++ .../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, 374 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 3fe4e3332719..20eef0daccbe 100644 --- a/drivers/staging/media/starfive/camss/stf-camss.c +++ b/drivers/staging/media/starfive/camss/stf-camss.c @@ -127,6 +127,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; @@ -137,13 +138,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) @@ -158,13 +166,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); @@ -175,14 +193,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..dbf50f31709e --- /dev/null +++ b/drivers/staging/media/starfive/camss/stf-isp-params.c @@ -0,0 +1,238 @@ +// 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[]) +{ + *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, + .read = vb2_fop_read, +}; + +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 Apr 2 10:00:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613652 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2114.outbound.protection.partner.outlook.cn [139.219.146.114]) (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 236AE5FBB1; Tue, 2 Apr 2024 10:16:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.114 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052989; cv=fail; b=B0LPYX0pEc9nlAIRqG2iOsei11SXHFSk+yRxU5QEhEy+C4FI9wO0+5vgmdbMjSPPOEaBoxI95QxQCHg6LvmOxp8cQJrVpUjMvhUkg+INrxfiPZQuX/K6JKsxDTszIxHtFa49i213BXxEdSS/UA5NmCqcqhM03885b45OXu7dFf0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052989; c=relaxed/simple; bh=cCmmSgd4/uW2O5O4z2vD7vxISIuFEbs0n+HAEvhxg5k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=TWBdN5kRbkfyi/FhYqnn3X7tYMvh8bOz4Ankr6yLulIx/nSgVSwkvovccobb4b1eS4Q3HbiD38bTSTjs+AlExS5m72/sahg8o2UfXka+nI2PrGHnl8jn9Or1UThVI6t+nKx6HACMhonS3pvYaMvUj9vs2xzmOD0WSI85UIMDNT8= 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.114 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=K6bOq7Y2MkwGpZAdFkcdkXo1/TS27ZQnEhjG65w82fcqWfi84zIQLtBDlpjWoryA9yEJvVEysWsn0T3xrJGphx+xFER4NecsT3bO0Pvl+vkgmBd617L3/5i8aTCvYF3k7B6nmbwCZ6t4i8skJK6bDITASA34ijEfZa8pDRXz6A8UWSu6UDi834QnOyfSskKlM2DrLDc0b2Z6uxXp/QyhplGHdgUPCBrrHpzEH+zP7bOvzJNP9ziVAgJhxbR1l0jQ42pOSmXIHiiYuctBIOTrdj3wofvkzG9IO6aMiQ5RZ1SCMkXZs5MvFjzzzYQNW1KgHY+UE9yeKN7kze5AZyp8zQ== 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=lOkr7bbPPlAtOA3wVsOJ+TvEBrl2/hV49jHr8UFMyu0=; b=P7etz9B9QAXmqL67H52XQZ1xe2E6zGEQdCPh+FjvhaQrU9+4QiEIFHOvEmMsy0VFmkm9AZv+UCgv40fohXexwBrz0QVOujaImXE71Gv05wcF7XWSgeufQhDagwJ9/3twvPBBLT11ErViBC1L0Iikf+/43idFR/R2SM35f0Tr72rqW1ywZ47Pfj/ljco7wPRpzUmIzh7T8K4Vm0o7NjZ+khSidYo3PZVzhwOz/EU4QGXzgEoeiKS8V0dJNtZYaMu73h0OJvjxCcMTbjghEAQ/irpIyuXdOPDSlzdhRgS/6OEYqc7c59BXnjHD051sjwoOveihpE774mAzn9374+8W2Q== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0462.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 2 Apr 2024 10:00:41 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:41 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 12/13] staging: media: starfive: Add ISP parameters hardware configure Date: Tue, 2 Apr 2024 03:00:10 -0700 Message-Id: <20240402100011.13480-13-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0462:EE_ X-MS-Office365-Filtering-Correlation-Id: ca5bc9e7-899d-43f5-b466-08dc52fbc14f X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XUe4S8SKCGlKYGasgxzp6McfWITWCZ3lJbW/sv5+W1LoJ5MWj2SDOnnVPU+vohGpnkUPOqGguZUmmICWjQqfmdpd0XJip+nY77JgZuErOidV7DD5qt+Jw5NCQ756REM241Wg3xn2V1gXXOn5GNBMS/G74sqNiB/zh9UgqQLDhgLg8RpDSNWLgQZyTqbPy73RcNuXZ5Xo/6//pMjZQEYM3l1vIQ5lM9rQdPfUBwqyESouwpr+ZfY62KTnh1QSrH+G9TzutfFlqKva2UurWk/SJjIcSYKSG+04HkjCUqyob9BQFOCpHZfrEzxgkxiePfUmeRUTS05phZkO91gmPkB4AC7/YzLreyzx5QGLfYZAHfOQUCw6ix6L7HTI7ELjfSvPkwHv4pD/eRNYFeIJ9m/Nh5wmoq+ZAGmvpYbNF3+aeFC9WnGYtcHqKY+1KORetOpA4XM2HxzUsYXH0nOK75PGYoQSKqDIxCKRPL+54zzCq2zRqqOn8ZCHW3lb4UPRkuqFCSdwGALEcLbXUa6/HDvLuEf6Ti88XW4MDLxzj9MWMfsteCGiHmCGQh7x/XRM+TJvkbOA/FhWTJjAs86G6tNnsi8fJtW+YHD+b5c2FitvQ/QW8/4gPaDrSwyMkrEN31nr4Pfa5idFO/KsGjYfSSwz7Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(52116005)(7416005)(41320700004)(366007)(38350700005)(921011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GoBXGZ+V+B1r4xYLcA5TVdXKUyBTRI7TGMyZW8RsEuAnemOVWi2iQkmB7gVQxQk0i6tGtI1zQLM9+VpwWu+F+tqiw/+s+TbWEHaI2y9PHqLvkDhZSMC3BnhMF+vjt2LBndk7MCmH8yiS1k3NoEV4FhMKY4GDvhcSERH/KzNckNpuyhpAfFHOw/kzFdG9LRzu6dZ2/0Pg2KDSJbG61HPWiPgftrYIqFGNw8AphhBgQSHXcDd4AuzSGdnWsmYlRJjGuqCWlHAsCeUbE4V5cUnxIk9NnFvJBUdrxFgar/jXo3OyycTacptv5uCrMmH1b32uqqDiHBq+oJjpZHc3v1v5IHkTcuqitenOpJqFJNAeHwnxZy2XbUjQ4oVgzHZ74d+fXy2Ssz71Qv6dSWA0hJKWk4Lr2JlMa3YKCqWVHPX/6PDVSsl0n81MQXpvLraSJC/ePsMf5AhiPeih5qCcw3IYMwdF6SDpAt0IdQP1FbsodnXbSkCXxzUGp6kboSIFNCeU0S4JhU5gDLVvTicwjwzGXSkLB0b5OLDVv4Vjoprx43iFaBEsn1fYr3zCX7gGwhMToYXjy/t+iRbXbXWlT/pjmHVzEWIA76DpNokpriLqa0ndVJo579Nnuqb76i6xTTkh7LOzu+0b9ucwWe1Ebm6otkbZizcJw8f0W5Vz1ElMBnnkiC4WIT8UnW5stp4Up1wvhu83IPHrtOysN9+0GSKJEzZHPJx+Fm6kw7Gbxf4mUXw7McwBh4R57jAcnqXxeTPAx7gOgjqPG6CTzjCk2BpafDMhtbBaBd6WZuYvZ6L4qf4RAwVxZmxdQIgxHTRxjVkonX1zoVBnw/J+myIRYRL6QJS8S3hka3X3qhz834q4jnVGLL8cB/k71lFyVJ0ND+74tBcHqqpZRRkBQ9Ulz/K3ht2+4h/Stt5t10jAEX0CK1DxTa6DaPYs6v2mbhMfYmYb4BTfnXBL8UIbRARu7QLXnAnWH+Z1yL4IPwdPUGKyBUxK8DlCedkD2gUPlBzcBQoB+Pgn3xF2wEhDpaqYXOoeXa4st0hVLP4GENAya6oRVtHDJW7e6T/Ep27spY/st2D+LZJr553ka51q+sH3Unt/Gt7LOWtchh0m84N/XJZGB19+8ExDUkz9TkRhcmpr9lkpElXFS82kMkSkhzkOPhYbKrfZOMuN6IFhLIINFDnIUommC10pB4AwAVYAoMiZm0554kaCLopJh4mwQ8UpWUxGuzQyMJW/WP+HTt9pNHSOBnBQ53yGueLOsAt0L3E9Qb/Od6v1sI5MJ5m1rO9nt8VMzvCfJByY2HJwm4r9IgLJW0oZbDaTkbIDO84YJcTQRdWkkWr9gD3/xbSG0NBiyeC5Jk6qTDLFnqajNw/mN/g2MYThdo7Z289xZpL4NBjFmyxkLmoiGavrLyq3qz7av0h6BEhoLFEoLqu1z9R5X4qXUgzLsasJs81QMtIl4m+6W2kXXBA+gCmGxUI9eZXEZ0R4nVD79jSpcd01EOp0MbN2zb18G3Ct5kv3GBQIIP1R5xLX2Rpz7VqohThysrBJXRVWhyhIfjZleXHKJnY3mtkjZopCsSpZzlc8pE/IsDwdLebm8iyAJdIQhFZSBrbGkJha7e1CFm4ayoz4qIqYm2Uv/m4= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca5bc9e7-899d-43f5-b466-08dc52fbc14f X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:41.4897 (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: KZvGrPncFupvNQ9K3Dhz7FHrEzwNf9IyfaJcZcUN3DvlQHkcHQF1xClc3yWMrVlXpo5X/Y52N1cXZ+4lW/eeJh63G0PN0HzFQECyyjZHgsU+mkoHc1oFx8OIJXtpnXl6 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0462 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 | 571 ++++++++++++++++++ .../staging/media/starfive/camss/stf-isp.h | 135 +++++ 3 files changed, 714 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 7b2cc596e967..84716c809ab1 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,18 @@ 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); + 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 +670,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 Apr 2 10:00:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13613640 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2113.outbound.protection.partner.outlook.cn [139.219.17.113]) (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 89ADA17C8D; Tue, 2 Apr 2024 10:01:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.113 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052117; cv=fail; b=kT1enF8S1FP2t4+bAb6JUau/NZrKWXgtNzs/YhAS+Ub6+r9Uhq49VBS0B1r+g34XnatR3NhZFGI/a8pJKQsMUaKsrgLqFd3HaDcdThqiriwlFayz11nx3prFduP7v7WKPoTvJyfsKatthhnUU/aqf7Hbp/KD927bHCW+pycJv9c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712052117; c=relaxed/simple; bh=8vy9iC4xZobNonXX5You5QxmsSOWhQLEJArk/ruFFtk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=aoeqw2ZQx/vyhEYIf4XfFx2gjV77yBJr0YNW2S7w7p54d73DkI6Z1nVhZkFmfI6LmD0PLWZAEVFZPSaV5XHvtu8suJWd9hJYgt4bG00MK1BBiZ3s6RwnV8pUWylJ40T5KsrMR5y6UfWezZf29zdfcW3MfdewSp51+/E129YiN5g= 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.113 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=Ub5vR5cVFA9FDUklV+/Dsp3HSwCRQ0a90qhKilbQdEhCl4Enxc+axVVbCTgfPrhBOhtsjgTHyykGSXEotiioaW2e3AXI+y7mv1mO9qZNJmVbgnGk0n4CMX/I0yf4I47ZvwfGNbe+SchDwOScIkllz4dkd04Z/TDMPVQ0hlkNsh+nq3tA/ND8bKj7SVrwReo8PzthFM+KWqzVgB2EKRZLAX+qzvAZo+VWXSfEBxEtqQFBS3EAcxfPwoKaycPwxUPypfOrmoaWBFwQX1vRxwo2qQzFU8xbLbHOi7Q2Q9nQMQon5+0rVgjJ5BTrcWkiqJAgm5UnbjGLd0FnFJT3+dHeCw== 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=CnD6LJUw1998zvLYzQy2qvjt8gRAGaju+NBVagkSITTFY36n2KlTCmJBxgpdO/1fmCodnQiAZFJcHOMZqX5EzbVMvCdwzqfvNkDAg+5cNBHnUjpFKfe1kAlf4/u33GHgKmomoB2qJBSXtl3eDHapJoYgbhkoEEHIcLa7D9kfm77dv1l0mLkFXVFNlYo5Zh9scm5mZAu19rRyxXz0oIui3POPeTvUxuXEMnkE3xkduI4e5c2PylGhoQT5JlVErP02ht82GzLUC5baRzIzg7s9iYELyvTMGO0k79PGdQLKJV1q5P0/piVns479qSA+h3K9CyYsOeCETHZDG1MT0ZWtNA== 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 SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) by SHXPR01MB0462.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 2 Apr 2024 10:00:43 +0000 Received: from SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344]) by SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn ([fe80::b0af:4c9d:2058:a344%7]) with mapi id 15.20.7409.038; Tue, 2 Apr 2024 10:00:43 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Matthias Brugger , Hans Verkuil , Ming Qian , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Marvin Lin Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v4 13/13] admin-guide: media: Update documents for StarFive Camera Subsystem Date: Tue, 2 Apr 2024 03:00:11 -0700 Message-Id: <20240402100011.13480-14-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240402100011.13480-1-changhuang.liang@starfivetech.com> References: <20240402100011.13480-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0005.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::11) To SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::10) 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: SHXPR01MB0671:EE_|SHXPR01MB0462:EE_ X-MS-Office365-Filtering-Correlation-Id: 369657c0-cf06-4450-7317-08dc52fbc263 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qF9niEURcctatKjlD3lhalEvypwVvxLLjdZF13+XQnOp/Uopuh1+b+G7vpSYIdZm90P+F79coDzxQch41b1ydp291ZKcxwGPPjNqHeaeXD1Q/fchgKVhsfIJ4JWHWKQ1WtQoRKvPv0SeoBGQxdcNoXsGtgTLl/zEnGWV2LFp0DYIv5g0x36Bb/gY93ESLbgX+uRKuGxcmyJ7mQj3ycBy4AzoV8pxeu836mJFemF6mHuT+LlSAUalLDjqvzEAF05/JBecKs7zpvrmW+0P9xCms0Paf/XkLEvMe76mnCk0WrFQzgWhTbY+nOx1KaGOMrvBUmxlJjk/92tQ9Lk2dSSy5hT7gn5YJVnHGUcFH4Zn8JLIDfPCM+A1INYVoTcT+QJ+EOwSawVodvBR0jYSAYZtqlQ0tUCbfwYg7tC6eEdwut5FrW2Y/B4Ji8+tlG4YuG5jesmuUHUOfmOwm9uEWZVqss14wx6Bz7qodoAr+AV6kt8IiiJWSq5+5crZPXIjOcqj4aM7sl8OHFpcWfpuoRSmkXOot1ORbaDRrFlzWjBTk4WNfH+A8owi5QhtRPFV84Bho/0r2PXzcq1CHpKLN9ubyNvNQLjUv4h18XgCl5ZsvOPm7w8ygQnBXy6DtSj2kOLp9X7m2E0qFsx9k47S2ic6Bg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(52116005)(7416005)(41320700004)(366007)(38350700005)(921011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W+AhEdW/0gzVZgaxNxUI4clDiZDXsAmrWX5NvFkRcixewka7tLzoBkt60lUkSvrtWdWonNvfeXpHj3c+eoWTtzzICcm1FG2Jmd6C8/vnfpmW7ogdiPUlN7rTrHnUSS3h20z0jlUJn4KaiZWLBYNZWRSmRtxIa3OJbilj5ZWgTCUXAMqfFWQwCoB7wibtauMEDu3lH0J+qxgSGkxwRN5Jc7ow64V+k25CLSaXTstH0vw3rzEg/zzTJcsxyhOcEEBAHay7F14vO/1w1AGLBxCV+LoLspqLkRtBgJ/Ey37ptW7FkGQu2H0Y3xqahkqgemLk2Jb9qXfvNCyiI3JGsmCh+SUwYzXM1mm1EiINhnWNCuFn+F+5wnc/BfwQ3cUzxx9Lrfqd5tcSzW1dbbU6rCqcA2ziMxhPKoOpsxUmzoqmBX7FNtnf0kvApF8jW18QXWK/OHdi2jaZAtKibP+dzgi97Kk0oU8hbQKAcV9D0/CBD81vdbGqDvDCC46UbltOtmCwzX3A9RfIN0GOgVIiZdVQr2d6At5NChzyOm1fEOzqPOvA93a7+olF2xdfY1lZDus9lCPekCYjwr/p9mrrDS9lOsKqx2fAt6hm9sVgqwTc/67jvf3T++WuKoNZ9fQAr2rHCjWYQkSV/WmC6OaZqTx8y1jHyqr1oPKqvqJfbDAHQrYIuNNtkhxLFJ++2rMO3otw47cNHI+jcOnpqDXtkJXfBiCk3mGkVkt5OI3KEm9pvaju+nkyrRS2DKXR91caBNUj3KbnMCNhwsFM1rILWs7Qbq2Tm14cDLaSLESxOG4YubodZGtbjMDtbj23wOW/L7U3osz8VBAv2yQuUDFDGPR8/W3Kx6cAln76zIKV1wXyF6zO3Oo9cSVKhr6+KTY4P2Zb/DxCRxRh4UpAMu+NL5Zo3D881sji8J1yeUUXHVXwXJ92LV53qo9fLbZTjZGY6u7Nlfnbw+PQPtiqQcGAItrRPqIklYONPRaxUmOAK4Z0YRQcRN+9iuHXXslYvnnRgkW95y6FlrifLpKJ6rm5UdIOHIIYjXgoNPmx1stISSsiF3wqfdb6LpgrBSoZqKzjg5bH7pmjn7bgEzF0fNDaErq84hDVOkaMaU5WQAbJzllJFFWVaFSqF0Bp2SJw0nPEdG0kFaIeCvKcAP48osAJjBE9fEcUFhwGttMEgcqIfuhKyt+1FY5Y7P1XzCqOXXcwyyUvTtrV2sFB1SaYbybWtxTbo/wCmvLojY6qpJIZVoNEBlt5rlLO3nCi8LTNmPrMhgb5HXFVCxgZVFDucCyy0dN9slLQYwlXayTA07PVXQuWYccM84zOzu1ohhgrCcoIN+6xVAiPwDbXjUUOQjq2smGplcAbPX5vOJzxTVzl3NFQ/OsblayhU7monz+ZiNIFE4p5DmVMfSgtgzGvp2IQ2yc9MHuZU1dm0musAU6bqEE9odWDDIekte3k9DhWLzQiJFuJLq2kGR1of1ClfaPsvVfWGPBZeL1+lv8yuNSs9MIhiixrz7nLn6/Xji6KxAjLlvJCcn40tqNYf5ansrEJgBiUqujgXRwaTPwEwu+W6hu3+rviEK7Ps3YfVW/yobTnh3lL2q5qUz9wDdvQ/IqBdKBvQI6pE4X7BFZT9Z1zqbUGiEE= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 369657c0-cf06-4450-7317-08dc52fbc263 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0671.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 10:00:43.2395 (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: Ssf3/xkxlETVX7GX8jpaLoteFOGve+r8i9pAgyY4M7AdT2carv90tAjB05r+SUepyIxgnKbDVU2nZDbppPVlUmmtQ9A7pPJowYM+RmIx6JGn1gf/DcJbhPsDmNjwUgiP X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0462 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] }