From patchwork Thu Jan 11 08:41: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: 187244 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1314276dyi; Thu, 11 Jan 2024 00:57:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBmAWYrU4kgH9gbVlGIPDi44HNui2/w1HTpEY+/Pu9/xG00yXBopnPtFjJMQksz1f174Yi X-Received: by 2002:aa7:d60f:0:b0:557:77f:9be7 with SMTP id c15-20020aa7d60f000000b00557077f9be7mr390274edr.61.1704963448502; Thu, 11 Jan 2024 00:57:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704963448; cv=pass; d=google.com; s=arc-20160816; b=NeIvzJw3iEwLlBUOPxFJi8uTXBYobYVVt4Fb39oO1VdGvRbZJGvU1v4wVWfHgnIYpP CUPINduKPLhLXGgWfbpuhjo3jQClbrTOW7SmEeJ3F0BlNqW8V17ysSUqd3fPtf4DjcPZ arFaZ4S2JWa4x9Peq6jY0rfgXgF0/i7E4Mr/gp4hoTftMv0Ig4y0nM6YBrFwmt2XxPWx B0Pv2PiwhWYblnq9Crt2bnUa+s9FPygvsv8bXcgiDQi9I6in3q76efWZsk+iYn71TEy4 /vZbJVo7ieFk7cNJ7N17WrL+/FUiKnQMSVJwW6sJYzJlIjsXZ8BKgjRyJI8BskM9XjCP I9cg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from; bh=tys5cIxMnn7dQx/nl7KwEcmxWT/25exDuxXWIufoanU=; fh=AIbhTKVlrbjCdvqTRYm0MrNe3T1Hh+lXyTtmg258gY0=; b=OOL+iKOX4mLdtuwZRCm/kXkP+/16kExMXw8emjBhqEZmp22drf1vGLRl3gN+dYMhsH t7tzEqMZ9U+T+zTgOsU4G+TkjpPtWOYVsHArX/hSag0syXaTcCaCsEgyGsacRPaIMbOO T5sKhCvNv4vJuvMlTMfzc4CvrqGgDJD9L4V0xbHcQyHVYIdgk2w/TzuAsyfX5qFTo/Ck JVzaU1/fRFlAqUvtA/s+iXjJqhIfW/RH2wawJF4WAsGQ8KiJXVV5Vuh/jOZxcJIAolEj 9fA/YcdyWt7IHs377ams38KdAJpZ8dxaKHnbvULBuckqDMjpPZu9gCCaqAbMRUlMKAXu xEYw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23257-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23257-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x99-20020a50baec000000b00554bcef1809si311713ede.380.2024.01.11.00.57.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 00:57:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23257-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23257-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23257-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8897D1F22492 for ; Thu, 11 Jan 2024 08:57:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C42914A98; Thu, 11 Jan 2024 08:56:17 +0000 (UTC) Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2063.outbound.protection.partner.outlook.cn [139.219.146.63]) (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 5D57F12B86; Thu, 11 Jan 2024 08:56:12 +0000 (UTC) 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=QTbbRBbQyBQyds4ejwxMTEa9zXH9BEVqlhVV5/aOaOV0n87Ur6JVF4AImnMNCqQwH8XXV++grWTeLKbaVUHsJO2qbSYPR/UaURk87D9HyRIVD9xtniY1u3JjGwxVuft2mn6FtYDHaLLQyy9CSHR+CRG+fI+InKI5q9UAl2N1nr2CkA1N0nX1Db5avAkOUUm0KL2UJFKTK81fXr08N4N3PKq5s++lU1sjqcxuX9oJVsI61xi8OBE28QqR1di7fJMOXZKE0FD4VmfPmjeCRxNpBbqrohrEmpFtc0mpAdMigOgVaMCEGXcNCnhoVaEEk3VBIIVoN+1C70bMZyrMEgSwUA== 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=tys5cIxMnn7dQx/nl7KwEcmxWT/25exDuxXWIufoanU=; b=h/GLpJAOwQw8xWanBZ2eiz3k0cvOHXlDlWtpR5On1kfJK6iH3awX84CbZqe32RZQwAAUc9ZIqjwfnML7XqQgdcSMRx7S4szXFb9XGu9TiJZM3kGuJ2mDRkhXrDJvQNvVjvom1dOgjXoyPxHc9DfLAjmdg6nSBPfsobZdTmQ4p+c91aJ0YYCjo4xA3AIRST8Dl4YOl/iZFrdsA//10SHDEkgowCLvc1HqYm7OovhKHIT3qyRiXCnejtARhxWgRVIU/6d+9h3XwZa0aKEJDwMcUJXHsxH6zHu1VU6jkAoMvjPhVQqjUpsrmhFI3zxN0bUUtgBBpqjpzd+EV7iUJW+E8g== 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 SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) by SH0PR01MB0747.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:21::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.33; Thu, 11 Jan 2024 08:41:31 +0000 Received: from SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d]) by SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d%3]) with mapi id 15.20.7135.033; Thu, 11 Jan 2024 08:41: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 Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 03/13] media: videodev2.h, v4l2-ioctl: Add StarFive ISP meta buffer format Date: Thu, 11 Jan 2024 00:41:10 -0800 Message-Id: <20240111084120.16685-4-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240111084120.16685-1-changhuang.liang@starfivetech.com> References: <20240111084120.16685-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0009.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::19) To SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SH0PR01MB0667:EE_|SH0PR01MB0747:EE_ X-MS-Office365-Filtering-Correlation-Id: 4753559a-f14a-4735-166d-08dc12811b7f X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: odQ0NRy7d/+5qSuGziey4e8xlz0V9qg6aL7oCZbwobU7HvNWMCd0eYz5g3XyTAEQQ7MNnokrRF4dOsKtLgv7wf58Dxa+sHFjYI8uLRDTb37cludffOu1mNsZhBQJCT52eo1Rmgnst/dOBRC06kQwJQHM2BvmgBPtW7bSutFtvXCDYPK5cIYvY4hN612Gv1yHS6k8P8tpnpGastsiNkunAZ2iUWURkEwYZ4+FKyv8dO2zeLc1WAB6i6iAC5/sZvZePiIRH8KLQYgxPDhfZpsnzjT58AcSHMK8KQcMvrRY8gkD96FDYXySgWZ6Qlx6CvHhWwya4HVABFqH+7jq+JEqaFIaF6BATn3v9SLOtBWvon7Ey7ZfbnCLntI9IEElbrMXNCIuV7LFbfb8yMUGU+dlW+77jSp6AmsdvbXRcKo4kSp15uKxMO7ukj+7suzVUqfoOmRlngmkyICCiYKu/IHGdtT2rW3NWr5EgGGkYKzXpA0keDUpyrbGmW+oh64Okk+j9oPExYarhxTzvf2vDaKRkKjjw8Lsy56r9EP/Pwy2tmo/ud9ltlVyiU5jctZur/z5uPcq0xDYaAj6xyCeXlcmVg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(346002)(136003)(39830400003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(6666004)(52116002)(41300700001)(2616005)(508600001)(38100700002)(40160700002)(1076003)(26005)(86362001)(36756003)(921011)(38350700005)(110136005)(54906003)(66556008)(66946007)(66476007)(8676002)(8936002)(41320700001)(4326008)(44832011)(2906002)(40180700001)(5660300002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CixQOzLsnF8soZDW9cM8f5pjr+1AI2+qPqt5KyUmhao7Mm+tahgJTraL6+NL10JdgN7eokhboumNZtob2PD2YPKRPnCZ8lzjZw4UKBfng6yVbaHxi5STiMOPTchiVwv0tyGq/sEn0cBXtDvHwJs/2ECBq82aDpe/6RvHKgjVoNmLTLN4pgS+Pp+cDXpEe3Tltk5YST+FQfELyoS0D6uuevQmI+dI3dbuFlfL4NXXxThBu/UJDpOJ58CGSXUqoy3JXHa2CMvQHpAK2J9RcZ9+5FfvTFt46OEx/RPXhWLZWz2BQSskaiYZ9tQWlstWEBRwLsDa8kPD0I1B3+o8GeSbJwYzE5qc6HP71Exs/I8LqYNzaG43gEjwC5bz07TvQcgLrIezGmrw8dHCaiD8FMPwG6a0sEDRSaU0Iv7A91KhuCDyVb/iTG1aUgT7oDAMLQ4RJb7fp8Cc6rVeOpl5CJQ2Ci5I8ufHfTKVG/K1dHExGC2oIS0B2klZ9xys3U4KUNT2QYCR48q2r6BCdEKP5b9ucaQsrcOCrkw07uq4goFjGImraIV4+aukc4QKkG8hhIDGbCUkMzBI9aSLf+e2GReVDDFW66on+uoy7HK43VD28DyHAHjuJTj+EWNlP9B2LAT4tLia1Kj64ikWPN988wlpbuCfGeHFhFiZzmMkakklyURyBto9QNtQxNl0KaRRN4LpOXmCUe3J9Aq47M/1ZHZDtcJXjeaejY8P5HNU+bc+VobCgOAwFFCA+AOqX5uwR0NRrLnPUVP0ttJtGVhMTHSHzKQc7+MgxeX3Cd2NxFutstU0xebPpJz1Mqb1VouWOa8ygIC6CEEf/pFpnGISky5dMx8eDNhYrnEuLma2QAUKu8JU/t/l0M/UhKsWsyFwPW+xdXyyx5QeLphSZKYybVk92ZXkqOU1niAdQTtF0fmUpS2yAmtXBsEge6p8brWotdyY3fbJMpoExYR3EOkgFmJCrGKKGHb/nT2mVrmhCyvvH8fCF0N2jDkA+8TQHDnVFf0GYJ6joFDelQueDkVcOa/mvP3eOjw/HCbQ7wQia+E5vutT0lJnzbAPJwa/JNCyESDDAgW85RrHUl5M0ts/1MypiRi2eV1iBWrhzcOF0i/ey+E2vLE6fv5qYXuWLEG9gcT99hjZs+6kcKwteoWQqqW7V3hUy3vsAQsCGnez6Ps9EzqzCwXNUTrz6PQYjO4UyYTWcPjB7rozn98JUECbFxceciMkFPMOyxJRUWCPSJI6nEo2O7j0yB7lXav8Mnqi2+dmRvRwnfKe/oEmY7WelxziZK8FDojtuCkA6aNs7qIxSO8PKBZLetyuZTS3tdvNCtXRtFwiQUVnciT7hJqHu+8YZ/5mTD5Y+1Eor9joxQa5CWEB1zMLKubEe6a6dJLwvNlq20WRrymhmgsCP2pYUQWKcKnfrFf2TgWa3cFtUq9dBaH43IsJMZZrF8Mi++WvplWCVWhDOOw1xFRNSLqnF3fYDqw3E24jJk5wXJfNvL8XzKKw4bL+wC3d2UfzfyvY7Q0hvrR//nccD306/HPfcN9bkg4K236YV/a7ke7BQIK58Ud+HqrQeB9/YuFaWclPn68qUKukmRbLiuLV0IwqS+MAs84UfL7sV/UTZs/SzNms8R0= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4753559a-f14a-4735-166d-08dc12811b7f X-MS-Exchange-CrossTenant-AuthSource: SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2024 08:41:30.2400 (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: q1kt6PpbjHZBs8w/FEf/RU5Rbvx/2ypxUOkgGy97y1XGCAAZPY9W+QuC+pbUAaV8UfpE/OVz9P0o76t+tsf6MuJNEe5nU6CClsvtoBzgM/uLtwnMy19xxWOQ+za1Y9+Z X-MS-Exchange-Transport-CrossTenantHeadersStamped: SH0PR01MB0747 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787783753203722491 X-GMAIL-MSGID: 1787783753203722491 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 33076af4dfdb..12c2104a3626 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1445,6 +1445,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 68e7ac178cc2..349bb8efe28a 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 Thu Jan 11 08:41:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 187253 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1315951dyi; Thu, 11 Jan 2024 01:01:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGuBIGRVxsQkuktkyaMsd65gN/qnkTS8BbaAE4PN+W/J0WgLZH14dzL0iDZ6lV5uMo1Q+7 X-Received: by 2002:a25:8a88:0:b0:dbe:af3e:41a5 with SMTP id h8-20020a258a88000000b00dbeaf3e41a5mr679188ybl.106.1704963680860; Thu, 11 Jan 2024 01:01:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704963680; cv=pass; d=google.com; s=arc-20160816; b=gIt+av7bHInMdpXqhP8x5KSVUYZSQ+KiKqt7EXOH6iBHfkqs1UhtjEBMNmku+eAhmC foobjwtu9qpF6nKzHWuXi4pMfk50f76FIR0luOoxlB92bqnp7zDdxm8uG3VQTZVukY/A KZZL7Utk5CQcKsZG0vBYScdFkI8i6wSOa9W59D9h6OdFsIBOCPMgIHn87HZrysd3iEJt KJeqP3ARyAE0Xs/XbwDl/nRZWtQhrvEtOzvd+Fu5AbkzOAHi8sZJfTmoCo8ZlGB8WqiU TGvRrLMpzihAMDu2AbtSKoVPuXwGV38qWrG0/mzFoHVaXDcedaVf25zHfWj5+rLiNos1 2QgA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from; bh=xSmZQzN78d+etqBy2o5BJkiJz5ehsWeddbIOJIxCv1k=; fh=AIbhTKVlrbjCdvqTRYm0MrNe3T1Hh+lXyTtmg258gY0=; b=okbvNUjSBY/zrorngY+SC88S8g7fn+DK1lRAZpxoGJ6gQdegNANkw4jEvNv2kFaShw zaN9Dtm9ZWWRLS6IyFoq5OC9dcnQpfju86fN8oUfduqckkSUB2VwQipzg3cCPV8jkv/u 5z1y/I3n7l56T6oQkHYs0eHIMm7AGgyJtIPOoyJifLQjLwJ+4kdqtNQ0dCh86+JflAca 3FEHYKGXyIIB9rfvxWwPFy+J6csRgwZ7bY4vfw70+q4LCt74+5yDoVcFL99m1iSMkOLf +2/PYTyMHW/G4elyzNM9wuZqAeFx6Vc6OIjMlBE4g68qIJZf9aEn4TirATQkQ4Fxepsy mrMA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23269-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23269-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a17-20020ac85b91000000b00429bdf9ce17si541833qta.177.2024.01.11.01.01.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 01:01:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23269-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23269-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23269-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9808D1C2286C for ; Thu, 11 Jan 2024 09:01:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AC42171B7; Thu, 11 Jan 2024 08:57:12 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2046.outbound.protection.partner.outlook.cn [139.219.17.46]) (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 4CC1315E9B; Thu, 11 Jan 2024 08:57:06 +0000 (UTC) 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=KlSr0XsOdMyMn73tvm+01Y8Er4XgqNeCDAC78kabCHrAKBcWhSXWADrj4ZbGrwjwGFSxmZITRYPF3q+07rOP5wiOzlou9bzcUnpv6JNdDtMuPEc1GlctwABU77h9RYb90BLKd3f/9bA9MpHtM9ilmQbqhLmQDdASoqhNWurKCwoNDvIiEYbwbkO0R+4pxKFxMrNos6HyLbCJd/lvREe9hblkRk5tYCTckFqMbLynCSCu0/Ep7w2AfAW9KQ5c/o0wJPtqgUKlKOKh7Ja9K7PIjyUJOO8H0U8ohtq9iLQ+1B3wi37FNm3qhYsqeQtUA0CO1Zqh7GarC/PsNy1EeCe66g== 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=xSmZQzN78d+etqBy2o5BJkiJz5ehsWeddbIOJIxCv1k=; b=XcNCljYvSydqTN0R3Xz4lGqKIk5RNOEOSEViPAABsOIBYGHey8maBostj5DXcRYEgQjGwj+ll9x0Szhhpqoto9pS3nba8+Ai6zjry6uTxaseEAAFx8ZQcjxJ9dZyK53CZ0/+n2vo0A2SC2SpkAwjDr/jRSANuUtqgKAcb1U2WuSP0Dt+WNRvC3sCRy7dd69mrqSbP7Cj7R8ywHEn9S58deqdEnutk3E5nwrK9hw3tUK2UQc7otngi2b67sOuQ+aAubPi2wDKrK4BzE34A5Do+dz1sZDMvnNEgVbxpQqN+RScJSUx+QgimpzHxXL5MfqvIeEqYeIIX+WaFGRSerZ5wQ== 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 SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) by SH0PR01MB0747.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:21::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.33; Thu, 11 Jan 2024 08:41:32 +0000 Received: from SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d]) by SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d%3]) with mapi id 15.20.7135.033; Thu, 11 Jan 2024 08:41: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 Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 05/13] staging: media: starfive: Separate buffer from ISP hardware operation Date: Thu, 11 Jan 2024 00:41:12 -0800 Message-Id: <20240111084120.16685-6-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240111084120.16685-1-changhuang.liang@starfivetech.com> References: <20240111084120.16685-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0009.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::19) To SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SH0PR01MB0667:EE_|SH0PR01MB0747:EE_ X-MS-Office365-Filtering-Correlation-Id: ceedce40-7c4b-487e-8f7d-08dc12811c80 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QLBLq+HNkabaOEBG/2GMNYsucyxUd869gymZW22lwyFI7U6i+FW9mO5Obv/FSp3vn660zGxEKTXIv9gzpmLaroVe3jyd1UqS3bq6HOMyoZoMM0HtzPSmjJ8iZ2SdMAVNLwugDnQQuM5ycyFASrJ+8rLpfuCuptT85hoyy7ViJ0aOLaDj0b0RDKIlUlHttOhUTbFV5+yz3J1QmntUqrStFMBug3vqV2uaTDcqdcWpTjH7lIm12DX/ti/XRy7ES8OqITeJLIgHEVJWK4rRnrflreeBS53g4Qn7mV0tkbvsLVkqGFCd0BqTcI14pvPtnreW/FPVlTd558RJLtwgb4MClk7sV3OoA8RNNRGl5YpczkmID6pI6BzG8dqmFT0q7KBF5oTG05zvW5Wm7fs73BDwM/Ys/l93xH/nLfYwYYIHnc2uNSCNHGL4ncHtRtsiYFqxqFc2ndSK67i12qqwwOp4sMXv5JcHokd06pvhodwPguen19uT+Xhh81c1/Dx8Vwf+udY9OZIiBoywD/hCSmuYJUCCNdM4tY78B0K/TavZuQ5g8Dg4Ioe4cnwPqOp1Fdwp/2oq3AvaUpSuSvR71QhTwA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(346002)(136003)(39830400003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(6666004)(52116002)(41300700001)(2616005)(508600001)(38100700002)(40160700002)(1076003)(26005)(86362001)(36756003)(921011)(38350700005)(83380400001)(110136005)(54906003)(66556008)(66946007)(66476007)(8676002)(8936002)(41320700001)(4326008)(44832011)(2906002)(40180700001)(5660300002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ocgDd2OhZzdCDGoFesvBDBYFGBMdkiF+HUrhID98EXDjrQxRskzL2I/JyI/FU+rifewxyjdNlhgC8141L61dbtz+N8Fsgav19qVZ+GQlifsDYQf1A5PFHvEy7WRGIO1ESKz9IiPBMlniX83jsVcEeMJmXTn+e/tvf0ni4Y1Y2IVWREndAhoZb8be347lIO6iLUrUAhoOrz90kKgzC11tjEstFbTmrhsJevOog2xitUqVCHnIAlvIMA3S3JmoXUaLbeXHln4WHo7mT6hj2v62+tk2yA0uF5qeY7SLXDmW0L4waNGWkBgZT2GPchLgVCUlR8XT4JaN5P6gILySl4uSQX+DKlZbuRkdLBXUO8UAx2R+fKsDXRqEcx0H1HnL90Sz24CSybfbJZ1EnyGvGne36YfyQmteeXs/L3Q1s92O8529hrpUBR2E8ZwQH7xliwXLqUTaWsIAmwmo2u+byATkl+W0MTYrAaGRR0/jxqnVU5DPLI1B0r5G1cfdGLW4NalO2kND9HQLtU3yhopklmg0bw12oDYZVKgxUX2B1FK5eu6x94xbSV87SCum3pWFwzgMmkem7laB9pkPSCLB0Z77nmY7kC6mrsg4sTLBd/NJ3GyxG7sVJ9P7uXG7DM6wKg4ZM1qEFjbxJHUPz8aetdzQkMgFtzOw3JUrrTSUtxcevhkuQBVlCdBfvl+qu72omI2Or1R0mVs5TGevda+ZhFs6n3ucXnGkJn3PywSyGqhRoDo5nprpHKI/VKl+1LOgbqE8+fz6cN2v/JNdiMhLt9ZnoKsiBJAKkcAifOMw0W6IaKUALQOEnbpeiSHpnzZyD2sSRcSqAmOyfOatgnPX5Kp+PIw1vfTT3O9Rd5+lgri9Vg/6lY5tmx8qZDLZoRnmroBps9MflFBemqZjnP/SbLNq9uwSgN7DQEIdnCoUymiCqOQOMw+HIb2DCRCF5L/qcQPOP0kjVAFTfPW7vYRIIBgtTGtfvu7wT0wjxRFj4TxPsf8CcnrP6wHdxU9Wv2HXsLEyomoJA3kj9ha2vfhLBcW+Fz0NDKwY4+pyspX8DVBXNpm9pDVg2veIdPVdwS866InbrRhc2tOVGHYAMm6RhgJM0apsyDzpSe6P92SxMRdGUHsR23ijeXF5gYg9MwS5OSL5pp4o8IYu2S4yN8Azjt/+o89IzznBSL5xAQ9h3l5t2EVh3k21unoI3Wqwj6OZ/Ng2m1cl+YBDiLcLl9XIobzj2Uqko1pEREy9/FDnuJ6eSPr+eSdZzayo1lYdU0TBgKClvLxOuxbWJxzBhLRn2EzJWovQpfUff1K+9fplHAaidUgatuHl6R1Jz9RMBIgfXEvCfIIy5jM+z6qZ7U4vA0jA3iRxEPNbBbAeI1vGmTACP5EYSN4nq6HO/Ej7u84J8AyYxzX5Wy602tUCctLDzwXAYNniCtU3GMH3GP+C+sBykoyI4cAWQP0/jU4ouY3bXufHq0iT2G/N+gZukhMBSMzVAVfrZ2GimWTKm2T/BC8NKzkIBfBYxFhRaA3gQ+tpyjTkzKOip/vgbnxxGzP5r9fg8auMnz++BrqDiSE5ZvM047ugEZEsPIv7VQqx1BPzGsZcTj3I7kIUNisG4hQLmL/evPFbIpP/RADccyEKaOUnY8k= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: ceedce40-7c4b-487e-8f7d-08dc12811c80 X-MS-Exchange-CrossTenant-AuthSource: SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2024 08:41:31.9245 (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: Va/s3YfTBqzf7JcxQ4hlSLjdZ7Npr550isS88ip4b7CVHanbXu657E/d/h9xZZmYh+SbsReBHoB5gkIP7ytz7vGTOneRIHrzt++9DlSH/W1hsdyEDBO12XDioWoaoN/5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SH0PR01MB0747 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787783996591829189 X-GMAIL-MSGID: 1787783996591829189 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 70c24b050a1b..367bdc924fb7 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 Thu Jan 11 08:41:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 187238 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1309552dyi; Thu, 11 Jan 2024 00:43:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEehSlBK6y+vl6KqHRknVrLc/OdJFwstTV/nd+PT7xUDXIPBS3SH71UzLhqxmmPNJoG6lF2 X-Received: by 2002:a05:620a:29d4:b0:783:1cad:9012 with SMTP id s20-20020a05620a29d400b007831cad9012mr1433447qkp.10.1704962622728; Thu, 11 Jan 2024 00:43:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704962622; cv=pass; d=google.com; s=arc-20160816; b=FqJsUvndQHnQ0wNI+M/flbXIkWV7pmXbaSIfEgap+GNXLeCYAubT2wQOvo+y/7oyye lVs4a1H7Vp0qtgVQxeShsUtCbfxV68OQsXqAoL83j3xoQZvEenM8LWwp/yCIEHi9gVIt 1NgfZZpcElxXNoW0DQoeb8XcJtxH0l9xvVNPKbCeLy4F7P8aborpx6O1vx32vtSEYRGf 9Ct9NlE0Tt5u1F5yDcndXl5W060HSOVlGSZ+dyOeGtPnmOkfbSa17mSzoXw8KkgAF1nN pSYzFTC1enu2+qXm6HqDtvgXjOBTiBzXOZ24eEvW9+pCdhLeLoIB3UJ6aduSxyWJVeg4 LbQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from; bh=QBKebo5g8nQNZpo/7QeoJbRcWRwazmkDu4kDf3PuBJQ=; fh=AIbhTKVlrbjCdvqTRYm0MrNe3T1Hh+lXyTtmg258gY0=; b=RsI7/ryeff/kQD9qYYoqpoASXVBnSV9mxsGU7pXW6XWk49+abjDf+ang4nXbzeFnIg jJck/6mS10igpMCYMgc4CUc7Bk7yp75Gk4xSqdEO1ILTjP4ZGKW/CwP/0CHoc76GognJ bOrhhO+o1n45rd25wHOAvmhX8mGX/Q3H8ldkLvB/DKUFxy+wNsMsMKEzqInrbgNSqGtO B0A9xWaSvwIsfj4psOpB/tGGIbaAHMn00oF6hozavjYJBYN3sHn/BPc/q+ZjrH0+e1tk fFjRq+IPiPowE5c2nD7TnKJat7FgmemARFkefizg8F3m7ifOXXlLoCmbX5mh9IjVUYVE gIQA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23234-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23234-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v11-20020a05620a440b00b0078326356ab6si513433qkp.29.2024.01.11.00.43.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 00:43:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23234-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23234-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23234-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 653ED1C21E32 for ; Thu, 11 Jan 2024 08:43:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0AD2B11737; Thu, 11 Jan 2024 08:43:01 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2051.outbound.protection.partner.outlook.cn [139.219.17.51]) (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 63036F9D6; Thu, 11 Jan 2024 08:42:54 +0000 (UTC) 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=EQ3WQukP+RNqoxiDbwDmyGD4+4e+NUB2pCMOESy/OBQDKIItuwmaPCX8killHBscCTeDMM49FAHbP9zVdY8hImqWnw6fFxvWNcJTzjx4iL+6E2CjTuaak47/KLbSVpJlHQlrwX6jvPw9/7S3iQdtoKmhSmXevhLW7xzzcrDXuz+rVM+qqKYLaA30EaGCn162fr9Tn7vQTm2MEMssBi57zQfIZcTiUtQHTWTuCqWMZAxxi1HWiulSvMtASWt6XAZnoJTxHakoTKhAzUWd6Xsm0uRKmCuwumIf0SuBm2YLrHBPtLyzuT/79Chb/4LixCiU2EDUagoZmhKeVFmUMqojsg== 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=QBKebo5g8nQNZpo/7QeoJbRcWRwazmkDu4kDf3PuBJQ=; b=LUmYsH3ueAmi6tMU8dK/9AA/UGVxeY+r4FeYi/wKcwZSoJGaY4FeqeaZfSMaeDQhB4sCqmQznWfhiGNzBJOlcgij+41qEAGysA5rzCkbfOLuhtKDs9nAmtW0g+DgtuHE+f/Eodkm+W/OyfE4uJ4Nz+zbDWw8ufgCFmHkKCPCaD6g7ChQPON8zr+LHzGHB5o+wIGsgGTcFabO+7A94jwBzMEWAYK/kzeqXqhi+ykx+DZw2KDeO1IV0RQ5UWvoIPcuQ4sdWnlRgn9ZzfXvInMbSb1aM+5wSN2G0uaYgit6xekvmwfHYGxOaXNs+RfkO3+yxax0sYSHwWdxzRwbz456QA== 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 SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) by SH0PR01MB0747.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:21::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.33; Thu, 11 Jan 2024 08:41:32 +0000 Received: from SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d]) by SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d%3]) with mapi id 15.20.7135.033; Thu, 11 Jan 2024 08:41: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 Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 06/13] staging: media: starfive: Separate buffer be a common file Date: Thu, 11 Jan 2024 00:41:13 -0800 Message-Id: <20240111084120.16685-7-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240111084120.16685-1-changhuang.liang@starfivetech.com> References: <20240111084120.16685-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0009.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::19) To SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SH0PR01MB0667:EE_|SH0PR01MB0747:EE_ X-MS-Office365-Filtering-Correlation-Id: e74f0fa9-64b1-4b36-4c0a-08dc12811d01 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IuupgDbIc0nHZbB9zxDqBIAnlcptmdYA7aU9lXWnsss6NAWhR2TmJETi71+lQodlDEnBqeJW1vBuf4BER22qMwp0q6E8Mh2w193/EWHHxlBJyahrOs0rl1E4j+92JnoK3xBRkx/vC2PQ61mj3DiG50zebo78Xz1aqiaC7n+hGjYARzSiJZvkBJEf7LZigjQ3Me992YzZezGzOTvzwQtEV6yF1JgTlB7WH8H1cT4wPq1SDlKAfr05781p/tmBBQhiyHrsq4FtQ03WRmXUA+xsxaOShqjxF2htuh2RxhiMxro/11Chl3o2zMjHGWnApz5Xg94gMEbeonz36CzuYmPrRzPuzOdvMW3rhBXmBj+WxQ9LFaB7Lujx4JBn0qsyJhqjfc1HZConY5YvSsdpQVpg9M91KnJoH7l6og9NNc1HQiLbByoO38qlrYVtTwN8R0fnxErdwC94ARY0bbvnrTzjMRRMniJ6HOiQ5Z/nywuRs7TQKye7fWTcDsYLYa4uzj1jN5nRKpZKbC7eIM3n7oBZl4U6Sk4t8YRkRImcURJNaJRmZvaFFdvYOcRbfNVf+IUbzf4msqW0uGH1fZ9ifPWzpA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(346002)(136003)(39830400003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(6666004)(52116002)(41300700001)(2616005)(508600001)(38100700002)(40160700002)(1076003)(26005)(86362001)(36756003)(921011)(38350700005)(83380400001)(110136005)(54906003)(66556008)(66946007)(66476007)(8676002)(8936002)(41320700001)(4326008)(44832011)(2906002)(40180700001)(5660300002)(30864003)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uUY9J6HbpDkAR9Jm9AP6dB1Eqv7aNJTjfViAlQdR5sKVzyRWSKjFCrccwrufZ5Rd3gugS089sf6ppN5psKnCRtpi8GBMJME+LbAOAIHm7C3I5FLE7WD9gLfJU3P6xc/I2SFDiOlryVk4fsPvchD+i6v6YGIq1ZUiuraAsNl3UD4OmjIi3ZSwNJh5QFWUqLWB9oguO019ey7NWHyqLg4AGhmkRjzIyNpMN4606GE2Sf8IuWrzl57egvIPL3YeDrlfJHOOWiwTfq7asGZwv0jNIkJxKGF6rnAIOg7iFJWNxAuNXfUWMJskor5B0cXDKsBhMyo3aIfCtf/IDFloWWGdKDprLTksAJzcQpmy8YmMFGxZjfM908Qv6txiEZ0oo6reVDwoqqJn5mGaF5mvbZfxBKiGKejriv9nIIm4UiyjzJTgImLCFscO0K2upR5HJF2jOW77Lv9Dp/RoWXJ6EHqPsQWJ02wHtadKdpzZRnQNSSLF+VcZhFJ58sFNhHzG9116+TvUpu0Ldet0eDjGVxf4zO0SccvQvC76b8VYnVBznfI3TZ9sR7/ZWWGr6m9+vYAxQ28HIIjLta5Q1v8PqEoxBk6FstTgDhfFA5f7BF69QI+bfqpsgpSnITDX1zBxjr8LJauP7V1jKejrDywqXfx+1aC+ZN86bJ7zoKLdrBknV/Om7FpzTZuzJtkUXkfDgqzPDFpFA77DumWzV/E1QOy0GPEpYH4bdOmXi5uSKoeq+kd6YdOzidXNJinDVXFZKGVo26BzQf3VnabtCxlXgioawwQ3GXwIrR2RM1gFswlPjxaGdC22wun1/YVIz9M/+hemDf0Mt9PwnZp35EBHRd+GJ68yX3Nkc3q6xOjjSQfomX513gonPMNWIyvG6pY3wEKOL5n1E0sLkSvj28IoYe0Yf63CPjYDz86LHT6lhVKZI5zr2gPsTicOXOdwc9alp/cVOJpzlqyYMAI6xFsP8uEYr5G0cFPvzUbxfnr6Wpj1/Vrq5X18cVeZ3F2k4wmy5r722uFyoXXXYHgY31sflDI6deogfHP7JiRRQUMLm3c1sHgZrbFCQlbF8prJl8sAIaOQIintXvoy3J2uktWW2fU3SRoRAt9U1xIuWITZMPpzl3gs3SdGwIWohAA/CLEd+WKfc43QHg0qeLBEtMn5uGAdj7O1GVqiTyCUzBa1MsJpGOl/umxavkGefzU+LibQOXpp1K9w3YOuSD78obOWtYFMXbG/tOVSYuQvusM5lBviMA0UKyfLKnqLX7OByOvcBj5l9VCGhoAnI4pig2PdnMkahW9jKT22MO5UbJH2dyL2JIHxRjI4tTjyZ/gk9whcGNy8KfPsyxjjUENR9Ti3o1PU8IcmYJbXiCJbwYjrzSK2YdJcCZ2ZtyPIUkxNo/DE3EKufNdE1/594WhM/o34LAezFkAAgiJOLencPtr1heQ8JxIr8zhCDobV6SknEHq8N9bdQteNZoELLDrSYNg0WQ+1WfV+6Xm0CXbtKMvMvXXsOtI6FkV5j/eZUhp0CXmVUPtlUegH3Eug9JeBbF0dxdxU5U+3cuYk/JkjorwVaAMBqDO29L9Ax3bLFWcOUOjnn+4srP76cml+82Y6ZP5n/1Dvwe/F7wNnH/QQ5Km8ojxls40= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: e74f0fa9-64b1-4b36-4c0a-08dc12811d01 X-MS-Exchange-CrossTenant-AuthSource: SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2024 08:41:32.7556 (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: KPsXlnthgWlJX/AOyBxWAMHagdWGZZE2kmtuE4ZpnhYQCerRJC0fwyw4VEc6i8AfyX/QzCFO16DOcQ4LIHFCTmYx60Zp6nhmGh/32nejpqvK70IdTvAX/Y0BBYyC68pi X-MS-Exchange-Transport-CrossTenantHeadersStamped: SH0PR01MB0747 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787782887151735625 X-GMAIL-MSGID: 1787782887151735625 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 367bdc924fb7..5cbafac46ee6 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 Thu Jan 11 08:41:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 187258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1317317dyi; Thu, 11 Jan 2024 01:03:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1wnrsmTjr93GkMUVK4fQqHCOc6+fSvliDy96vQ8EbSWvSR2iK8nM01oON2HbbFQ3RF/xu X-Received: by 2002:a17:902:b589:b0:1d3:fa6a:fc88 with SMTP id a9-20020a170902b58900b001d3fa6afc88mr601694pls.17.1704963828063; Thu, 11 Jan 2024 01:03:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704963827; cv=pass; d=google.com; s=arc-20160816; b=n8vFMvR0IWd/aINgG/wZiE/Oly8tPOiprVvJ13ijBfziLOPBdLVl/LtNp1ONiQRxbq X1Zf2mMh6CRjqXEhKXqy6bzyaif/ZY2hsVwk0RZyrD4ke9poCkFHw7CH29H1TvH3wmJp 99NQZmzdBElo/FZtKGE3zaVoI1dzjFiOIEdAgOQ04/sp6cg9bIffNRiM3oBb87wvCTRi IXokQ5nHpxVOd3O8OCYiyQqScC9orpCjA9VWZnns0RBE3GeGExH32SBtnvKszeYDcqIJ 4M4+9/+WBbAakgesUVNq3CzI47l0WnV2i0HgBnlAzWwj9iUiX1pZl57hpU/QADE4UZFq jBww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from; bh=RAQ+A/0fQgLmKDY3N94BwR7948qcaAv5N+2ndR5uUe0=; fh=AIbhTKVlrbjCdvqTRYm0MrNe3T1Hh+lXyTtmg258gY0=; b=A1z0NTrF1iBd8sBvBKdj2OK/NUiXTWzRytOQ0ywcl/eCWzP95O9nDICpIPjl/Xj2K8 vuD8I7S8Rn6WWgTEvuioL20vdmksh8J/YggZGH0lr7dLX1LZM8eL8JNg8TYY5Vj1BTVX aQWgr7TlWUGwqQVRIfnP9tjUkmEvauiqCBxrN8DvJdaajWVdTf2CoQnZOyPao/dBhVed IrEDVCbVsCK7vf63bikPi43cLDdH+JUy6hM1YvPUEwdzHbg2Mb92fxqD1psGICmDU9LA VPIb88OGtR9PRznQA9kbKHYsMuPcHRflnFbZvvce3fhgqMsJ7LvohlrsK0yxNf5IxTU3 JTkg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23277-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23277-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f10-20020a170902860a00b001d4bac05053si634275plo.308.2024.01.11.01.03.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 01:03:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23277-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23277-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23277-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 668482888AA for ; Thu, 11 Jan 2024 09:03:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 229E717751; Thu, 11 Jan 2024 08:58:53 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2070.outbound.protection.partner.outlook.cn [139.219.17.70]) (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 866DF1772E; Thu, 11 Jan 2024 08:58:48 +0000 (UTC) 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=La09VxPw8Ybz0K24uDpm4YlxIqiwxYiu5RqnRHWWC+cLaPWiuspKjBYC4NDOx0IB1NxKEtBBAd6UkSanwcfvqRb9ReIlJZuXeyYzirqUQwuw6PmMdreaesa2LD91vV556NDsquE8u5lZIIieYHj1crfy2vklWE9XRBMaAhdRh6cdFJlolcA+lwpfFK+dDR2l+EyaUzBnIsQBn26W2d/nctjR1vwR9IuALKcSA/25jjDtsD9YI4AI0JxYjobl+iwHiBJGRDJAdQ4eLAXr6peKNH7EJM/MkaJP1Mp8gQcn5SUZUeAdsBKfd4SJr2UMsXAEhn5uuoYhIyoIKjur8x3ZeA== 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=RAQ+A/0fQgLmKDY3N94BwR7948qcaAv5N+2ndR5uUe0=; b=cqcnT25lExHgU0W/lbiTTqYpDHDXTdTrG0cKyqQ/1qEPhvd/y+BdVf6km+4bJ0Fx/HkGLhVJAi5PjPn08OFgrSsmonT1VYa6Sin0y/QeTO0iT0JIFvSUr4113RBShz/7AURdwKflSDjUldmBvCNkRzLO5bVf9LihuGPNJGOIAkk2ioFc4NAtpMLwg09x1ZJIuPYdVnwFs1suogWYerI/1U3pnaqA0KykiUhFXGePQYXOQnuAI6/ziC69ndnbKsru+k2hE62fp6yeAK3giRXyflrvymLrd3b4l6qB8LtpX8bC/4fwMws6QbUhMfXv1RcCSMrlQD7nIEqC0+YOwENZ8g== 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 SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) by SH0PR01MB0747.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:21::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.33; Thu, 11 Jan 2024 08:41:33 +0000 Received: from SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d]) by SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d%3]) with mapi id 15.20.7135.033; Thu, 11 Jan 2024 08:41:33 +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 Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 07/13] staging: media: starfive: Separate ISP hardware from capture device Date: Thu, 11 Jan 2024 00:41:14 -0800 Message-Id: <20240111084120.16685-8-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240111084120.16685-1-changhuang.liang@starfivetech.com> References: <20240111084120.16685-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0009.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::19) To SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SH0PR01MB0667:EE_|SH0PR01MB0747:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b9aa3a9-6e3f-44ab-a64e-08dc12811d7f X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: paS58XrwgkM+vbb2PaxlbE4Sk9ixwLKik/bnVgUgSHa9JjcLNfO9N6AHxZwo0RlZQKHOqsrdwRt5GE94J91ZYGkBXCCTJ0bJIjVOn0/JP4FQ4ijhFbTBmdwaaKN0w2Y7aMDvFB+RRvpGWutsKAmKHmn0wJa2WpfC2/r7zbeOkcBYLkmp1iIdlGfoP5pIvZu1fZE4q6rUXj9Gg4Z7SZo1Z7DJfauxLhqEEB6IkzK1VZM3YuYj2VZ4Vhx86TVU7ZTMFFnTxxAVWmhVDGqfweeG/HqFE1qnTKfglYy6CMgoUR5uKdFfExktWmml3NauwHiVPVUSoZMpoAPi+ckyvt3qKknmHuX6C/+VKsDBunXiPCuIH6v9LErxU2TqyV3Go9AWYwP5K1yGXef4o+0f3UIJaIP4kNmJYZKIoRR+MTY+2h3vC2dPAwvbDWUGVjZ4+F/cJAiPnS6xZW3K2fqDq6Fb3NXLDB3UKVo0OrakaorrM91xBXCFkWS3HPp8YgbeaB8Z/ZVdkzlKM6I6c85pNsUam1CfIjxE3P2QxZvhq8vePaU/TAyHNIHR25HUhVBeZ5SsEc48leg8FHbNkps3qtzSEQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(346002)(136003)(39830400003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(6666004)(52116002)(41300700001)(2616005)(508600001)(38100700002)(40160700002)(1076003)(26005)(86362001)(36756003)(921011)(38350700005)(83380400001)(110136005)(54906003)(66556008)(66946007)(66476007)(8676002)(8936002)(41320700001)(4326008)(44832011)(2906002)(40180700001)(5660300002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5y4GSLcq4G6fg02/HE0gpYACbMwm9YBeEM2UBe9XJKpKtRt+hoJZbEgt9uuPzcWJYEzqZANr+Mp5BOqr5dnBrQCy2gW4UuvYMQLa1MCrQQZboOUajTruk4BjUvO23AwUD5bcwmyVmvXvX5EfUvojQGllZEEx6g5MpuZwNPhzyAEjoD1fuc+4WjIJqHjy2O8sZrOnPOCHeK+RO2Qgc65PjwQ2NEBxjJBNxaOvB1kABLngroE4M61uQbIKIASKwJnLJFFtygkm1CyuZ9zRWyhvHrkzX2n3cEhGuv/zTMkZtUPrDIDuHdkEr6KO6Ce5i71Xz0uVsKeWrq8cXmwzP9lb+zreKuvViaO+rQmSkNu8E0pVOEO2265l0b9i46YQ1lG9Mgim5r8AFEioiaMUImAdPSfwpD0UzLfMKCpxKAR+1hzxDUyAUq7YinRAeyiRuFEYV9w8esJ5FKVuAa6UEmkOaux3MYKArmhyKZIJiFh7YbAh3aTTvlRorcHRIIrgybnv7n5C5z1QXWbFJEzgjbBEFQu58S5X5AQCTSgsJoIqSWb7Rt/79cGrNex80y8ypqSgAK0tAAsGspRWKTWg9CEcvLXrWg3AfNK7lgfEo5K44Dh7KmbFfILAkc9zp6frww9mePC/hdUDwYc671CAN+UoZDg6Tf3k1ZFhYPOfKe9dnItrrjRIlA/MVN4ohCTOo2QeipDFTzIpuEmTctYqTkZs/naYhaIit5xoDy+wFZzhXZiIUkZyWdJWpkSyw8FCm9tlnmv0C9tkWYOUL+SYjZXfGc8FWvWZXcPOi8bUXKBTTxGPY8frvZ2IeF16oTd64J56IJPqYNxZSyvNxO2rRsyDN8BwWujbLW04kns4cq9TOXMUf83vEQoQp0xMNSAKpkQefn7yR/p1V11wQM5jtC7aSIGAzl1Y5bMqVtPRTlDNVvWVrN3K88jXDdCQ5za7fOZ8fO4Z4WLwaX6OKUjxG1qkTjmehH4EvCIoNVmPkHcBKQ8hcRg2bePgPl3+Q0a81e/ccTBeuYsyhMUzzM9S5D+FXf+5p96b7jnDcEywbX9xa4OR38yCBGCnK5SbRMhD9QaOLR2X0708sUOeJQz0+sqjy3gn2/AMVYEsf9nzMDEl4bkOiKh5uzVbQdXGj4iuiJ0SFPzHTSvW1M8B9vhq3wYYPQDoOZlSjkPOqcR9aOagprRsEQ3k1TZur9mENFGwCyuVpk30qPURIdfmuyN5p795uw/d1VIVQJEAyXa8SwbxgkIXRHXuXHmh1uoz4yqaumtCcpMi3+nPjB/Eop7Q0JNvcdOGiT8mvUoAnfQwOtxj3XmuWDj/Stnqb9HjAnN2R1ArTllexDAKl1xooiiT6P4hbUDrKxv17gP0B2BfuwQHhsijs0FjDm26gG5bK8vjEHE3Z5vEBCPUi4gDdllO7h8t7TReud/c5KPTXx3dIAFeCx9YFNvcxh7CLfpDAZnWuzEUsoSMaWoqtx0nEg/ju0x2VI6RDE7RaU3yZ3pkYDXaMTKB09+uoCwcy5GMOBknOnTWciUh/jHh8Y6FzYX7cv1rfhX2nGjm2Vg3pWQlUlNlWHrDpvWOAMUipLUi8hrxLjYUjFBeGN5gDzWbnE1njkwNhGN+lowIAySWNRSLHuUny3w= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b9aa3a9-6e3f-44ab-a64e-08dc12811d7f X-MS-Exchange-CrossTenant-AuthSource: SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2024 08:41:33.5690 (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: LhDplDBkP2ccV47xWni6JLeJu38nHjHPuivgx2Q3VnJOOxiseaeB7kirg5XXD4/+2jT0ik0TUmEMf4DQZkowQzDs39tS0TJzrl//zHYeEJmFuTlM/42ypTTZlgWlJ/zx X-MS-Exchange-Transport-CrossTenantHeadersStamped: SH0PR01MB0747 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787784150187616477 X-GMAIL-MSGID: 1787784150187616477 Some ISP hardware operations also use for output device, so separate it 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 5cbafac46ee6..e91e726a1462 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 Thu Jan 11 08:41:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 187256 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1316862dyi; Thu, 11 Jan 2024 01:02:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+HQ+E7BZTWgRBTU+DQBfNssDQx995iuO4+DcFi5q26nBg3Of36xbhqmUdxTe0g1QB+DmP X-Received: by 2002:ac2:5b0c:0:b0:50e:aed5:ec06 with SMTP id v12-20020ac25b0c000000b0050eaed5ec06mr357642lfn.87.1704963767097; Thu, 11 Jan 2024 01:02:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704963767; cv=pass; d=google.com; s=arc-20160816; b=R7H6nYLed/qV4k5FF9bZUnk0bv+DK2i0roORpz7v9m0xysiU+KYZX1SrlgzOrAZ+PN l8E9SS/d8dvkoR2+h/j6KhWBmeYkr4K9R861qzsNThmNTB5pY18DXlsMoLkJ9ztEgM8T YDe2ZE/9HIGEALOswS3I/jJwjY8/5WViaXz5eTeI8HAiJqKtGcCEsXtM4q/FF9S/7e/g Qg1tcA66LCTO8GQ13LEzJTYgh8G1bhKUwK/r3G6FAkN0lObt59Wt7S2VsoBMPDMP0Iez K/KdRryCC9aMtVPkUN+eATbwPVZfcr5J0Lm5c152/85qZsdaaah6m0CIvHft+oNFQ45c gAyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from; bh=jbrQo/s0w1VWC/wynUGuXozVgj4oEPkEu40VFXe3aSo=; fh=AIbhTKVlrbjCdvqTRYm0MrNe3T1Hh+lXyTtmg258gY0=; b=V/h38P2p4xCXqYyGFOF80c3P3TudzDpgXWGzor11Sc7mbfKIvxNIMNfsP+etlQGBWn tUZOtR1vbWaZ+F/rmFgups/8Tcm2S3/SbGwjTlREnIStPeMcCJeb+jcCiFGlSZYI9nKp /WCqYnWUt2Iou1o31ZJZxEhM/bZ+9kvipxckyl4qNEnJfJ90x9KeAoyEb7PC2bkwdEAc 5Flne2tzOR89nIKtPYr16zfz0sI9frXkJdRqenqlJeOQpWKiQthjIGsaHjoSYyWtHYvc hPUDL0bcFiFGSsHRowX7e60f7TYMOdjfyZLJApbNm0YPlt5p5iZQzVNuFSYHdUYRvFRu 12sg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23274-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23274-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id j20-20020a1709066dd400b00a2b2c49a5c2si302878ejt.840.2024.01.11.01.02.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 01:02:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23274-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23274-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23274-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7EBF81F243B2 for ; Thu, 11 Jan 2024 09:02:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1EAE1549E; Thu, 11 Jan 2024 08:58:32 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2040.outbound.protection.partner.outlook.cn [139.219.17.40]) (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 64E8E14F81; Thu, 11 Jan 2024 08:58:28 +0000 (UTC) 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=AT8okzn+fQw82pWXQnpDQoZKoXwQ13DjNjkyNkFLLqvub+HBy/lMpitnV+8YYlSnOoEL8AQqN8aRH7W/FsRG9DmW3BcX4zBeqywERz/Vua4eodKdljqnSm7LPi6uoY66ftWOMrCqo1bQNeo7l67+atG9JC/WdjW0HAIQ2+IvPUiNGlkSXp30Q21kQL/UI2vxV+ym6LKajX+s3AKPtu0qx4oLVHJROPamOce6MT3AjHetxBEbVQNe/R89A3sm9oz00KJYd30Fn/sQ01Klb4htCPuh3ms8rJCyhaZNojxGxi+CpF6oFJE39iB+lZDl3tRBQwW8jdboA0IqCQ9aaje7wA== 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=jbrQo/s0w1VWC/wynUGuXozVgj4oEPkEu40VFXe3aSo=; b=nrMhve9hJaeBtTHelooKZNFrx9R4Pe1LqUmTukYa8M+XHsBRny4jS2R8PY0PsFUlKZhB4psNTWWMO3yYI/H/vejV6WairEzd4sGxNYNS1p46SaylFebWHN+X2wJVbEQHaPBoFBm6yxNiNFrEF7bcZJk0WY1Og5bcWjuNjGEFuXrGFp8NaFk0pFOU8UQPiC6nvhlxECOnucJPCT0Y11v+9s3HoUQpk0rhvA/P/h+f7FlZmuitZUk5fh3BjQDcVSnrWNMRmLgrxKtMwsuYxX42WrLzunxeOj0xyO7jpT+FxWJw4KCUWYEAcLRZ25/xGq70kB+FDWJFvKaJ6oQ0a4ABtA== 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 SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) by SH0PR01MB0747.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:21::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.33; Thu, 11 Jan 2024 08:41:35 +0000 Received: from SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d]) by SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d%3]) with mapi id 15.20.7135.033; Thu, 11 Jan 2024 08:41:35 +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 Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 09/13] staging: media: starfive: Update ISP initialise config for 3A Date: Thu, 11 Jan 2024 00:41:16 -0800 Message-Id: <20240111084120.16685-10-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240111084120.16685-1-changhuang.liang@starfivetech.com> References: <20240111084120.16685-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0009.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::19) To SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SH0PR01MB0667:EE_|SH0PR01MB0747:EE_ X-MS-Office365-Filtering-Correlation-Id: b6d7e768-6a78-4a5b-81b1-08dc12811e83 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4GMe/ChAOz+QF0uP08DUWA+KlnKrQcAVFpKXiW+sxc0e9ciA3qJdhajoBalGXH2i2DFMIX7Uex7wynTxyNjiLBy8mJsZd/CDFqZ0n5SoPEe7KyNeU1LeM+ucFGw3DAdxwMAEnCmR+4d7th7p5p2dMgtYrZpnFvRCRc/2ojhWaBC+OjMBFRqsB9QXkt0cCJnAUUjB/q0VmQKucVPrMTFOPHeT3gdN741G3BvgEbJ1ou7+DiwlvjgYBozE9oyhezbLqvhojS4WsHdepbtSsrX7i+STE/jsiBpydMZQ1OnB9ScyDuRV5nbvhE92iY2EjSuo0lYU/BwFAeruQAKiCzQdElqKH5dPQpaHayYIL+bDlabDKCM73Jou/9aUtORGxuRXAhObZdiRM6C13Jc6uR0g4ldFDZnfktQ/WkvEBGkpgvXY8qH1+JJhMuqDZX5ToKq5juEvvgu3xO5WqX6QJR+NPicPxPw0vqEqeypIk4sfPVE3RfhYqgMaP5Oy0TvZ2StbfL9+SSZ4u7B2R9tsEUZkkaluTegO1bSTHHPLmdupEqxr6vK84VAGi72RIaFNyvSKVKu6sKCoaysu6ZTwwGYWBg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(346002)(136003)(39830400003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(6666004)(52116002)(41300700001)(2616005)(508600001)(38100700002)(40160700002)(1076003)(26005)(86362001)(36756003)(921011)(38350700005)(110136005)(54906003)(66556008)(66946007)(66476007)(8676002)(8936002)(41320700001)(4326008)(44832011)(2906002)(40180700001)(5660300002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Gt3HAiEu10xpxKjji5PUsz+7UFXmrgI88wqCAtJsqlT/dgEB7Eny2rcsZbxi2zigc9HZ8bFhmPRdU/7+MlH5zVZc0nLVVPZ656FzaJEU4TvJuAUOwdfDbSMuAz4dR1kMCiXw67sgeHnjn3+BWIQ0Y1w/dPWm7SbIS0LnhM3juvw6VSgmXDXo9z8+EMY/98f1/eSEJEugE+ma3JljzDeKUbfKRlixjI4EGFIgevlRYhnQaQyk57+OH54Hyoq7wi/QQbdifJzzcMhWZMgaNhiKaBLAnJ33iplVAiQ06Ub6L1/cccojKZHzH7rJIjMK3v39uJ7rSb0PoN+bzCv4Mt74h0mqViy8AcMmKs17h4GSL2jcAFO6NCmtax4h6nhw6joKks5h7KwR5uddg5wta54wFqTIpyf/fERSSRXH1YfB+ESlQF9LcoASP8JXrqOjuoDmWxKreOT8XIRQsEt2oDVxd03zbdhNSVzhL6RF73TG97gSjwynAH5KpfkxQPdDaZ0V3ggMUw9Z+65zt721oYCJsmf+rbCuLpNdLdApEGhkkipBH7MvSFj+2da1QzQAxBgavtRpaZFwkOuHCjr00OyZw5o+lLttnk6QDxBxnVJZhXmB91II806p9+qPG+FPkMWeNV7N5OQ3soL3/szMHsymz8TJO+mPcrdVRk775gPYxm/xXpZheyHglpS0JdXZHnel7ZSIvNFuGiZHo37H+9GZiVVCNjOmh8UMCjS3I1wTC5K9kGTdLIGZVvn5n3KSjnOAfw0qMTaJy8Gke609FZ8Nn0eYHjbcSKZYvMtTMcr6/hdDX3YjhRo9RP1PefokRd06SkgnQkaeF6sAbdz9g8azsqIkjA07IGHgim3hy3bATSaxGPIwpw+7ZLqbh13Adb+K1zz8jGI2Hhe0MnYCXaPxbNSA/aCYUL/D48sRfFAcNtcz7EGemDS/iLcBDD5rSGLpzvUwsbRf03I89lh4fDESF3BdN2xG31WuIxpBDcFYvQ9LXUZPB2Hzyw7z+guB3h37J5RdLZTVTKI6Q+WZ6uVfo5ghOEotQCcyHEHEHpZ3bggxcxq/yWLd9zOOjQDxJAyv0ynxQrpdY+LhucWDeGMn6u7Kr+NBW5X1VoKbvt9uwj85O8DIqifCD1MO+1BE5fs6UeraGYI2n+42M8nEPTH1KGJfq8RJKNLrmsIFqgsNyHw1ROFfwFazTGilvMnU9NQkNIKMYIsasSyUdf5mV9TYblHlf6XZowTmIPhNpruxJ7zwFLs/3OnKwQH3803kBR6fNs/Vy74isukus5ZisFLzObWCNNSnqyS6Ok6yUQwySq6GEOME1IP5T1gyKaOSc8I9Aq+afHtIExcYVdaD0pTLaF4gZF6QcQBQUEC28vRGmBxwpQGB69upgFw/q2Jxk9L5wz8On1WN/JoK9yfu3Lk1WGbZdhEqSq2N2SIz00KTdBtk7+PNi6Cvl2KtxeRNhrltkyMD1Y6uyii6HQf7bTqtGyhQd/ncXX1g5UcOOqYzGpu1GGCA+gV/8P+XLhYt5T3syMzEp+WyeT9tgrFtocf3i3L1P/AephIdzmgmFZ6kr++J0BLokiGrV1rnk4nCJGUYh8buDqi5mH8a/DLyOVmcM3F1KsZQ1er92+Eym9ajRmo= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6d7e768-6a78-4a5b-81b1-08dc12811e83 X-MS-Exchange-CrossTenant-AuthSource: SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2024 08:41:35.3018 (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: vtqgjyWDFESq0/xVuGL8+EUaTkyv0865WzeKMHzvYlbFYr1QPQNsKn2yTtJSxvME/9MKDMAhPPalZX/khokwCCc+Hdl7zWHBxewc1+/9yxyNgfYStZDywW1AsgqrxO66 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SH0PR01MB0747 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787784086835444278 X-GMAIL-MSGID: 1787784086835444278 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 ae88668e5798..c778251e0024 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 Thu Jan 11 08:41:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 187257 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1317168dyi; Thu, 11 Jan 2024 01:03:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVXhiRgESzuE67Wr5q+v9XRbGlIwGvXZga4vjReTsHPICn5lJB7p8HrEJkI3KHvaJUgsnd X-Received: by 2002:a17:90a:e98c:b0:28d:c7bf:3a12 with SMTP id v12-20020a17090ae98c00b0028dc7bf3a12mr669152pjy.8.1704963805028; Thu, 11 Jan 2024 01:03:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704963805; cv=pass; d=google.com; s=arc-20160816; b=EHkvgyHBrzfSdHlresnsNvvoxmdUli4oMfLJTIOv/w6ek01koQPzcYQEG8aeQpj8JU Hx/Ta5XEBuasOkEKbcN+dxnvXvqCina7HPd+oWi6XXPBNSlRpYVJNptEWMOQDTTdeDUC cY8m3GhneKd15pMKg83Yw+/O+xzxWtl0/xZMtCnldx4+qgXuJgGXKFyvodCX54yWSZdM mMZfVAwmiUpjBc3zF6Efkv418iFJSUlYac8X9NEVKtXyBhRcmeSfFVjHc+oaathPhUdf 7uSu02GuMN1HF7qJ//cZ6FrTP0aKdGPReq/vfprSEFg6xl5zZTiLWKsa3p6Vo8v+RzCz 3skg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from; bh=IpYS+v+cBn1HqDAmhXTHJL+v2aLemV00fes8PvGvKzM=; fh=AIbhTKVlrbjCdvqTRYm0MrNe3T1Hh+lXyTtmg258gY0=; b=HV7PdS6JRLQ1W81oq4doWfXfEzR3MRg4sgYEBLkGezNI3HwJPdl+C035cQX3rDs6V+ fRBkJUvNDsCStYd8Bj678vmMjv7erfexcyHuJs8wrsEDYFPkcOM4Q7llMCHa/k6f5I5p K1au6c25fyukvKAkWeEFUQRGStvkvTvSwxJ0hVfs2bijx9TW3lFchTBVU65uL2XAN15m uu29wGHP0/FPRMlEvVbC6zuZaxLx8WMRDgupu9+WoQHf8RC8AuBWs/suT1Z5aGsYpBQG y8fqIWuvOlYkBk8nQVwUjjsnIyv/IUmUx3XyoT3ftbduwJ5qmiSCOtj7Jc/2y3JOAK1V EjJQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23275-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23275-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e9-20020a17090a728900b0028d2a726a77si636793pjg.181.2024.01.11.01.03.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 01:03:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23275-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23275-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23275-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8B81E28A7C0 for ; Thu, 11 Jan 2024 09:02:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D2A0156CD; Thu, 11 Jan 2024 08:58:34 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2040.outbound.protection.partner.outlook.cn [139.219.17.40]) (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 7276B14F8F; Thu, 11 Jan 2024 08:58:30 +0000 (UTC) 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=kVKfsXypWpy5ShaBPLcA1yXUEIrpetn8UQCG7u3huAUcw/Ut0LQEDNsDU786Khi73V8zElioP7PgBTCecw6LW3pOyQiEO20xY/IrBdXf6M+ASSNLeKp482A6K4UapOocbuu6d+c/eSnaG7ujs8qILqWqqZzhk00yzzn0WSX/+NQYu5T56m4ZcQBhFF8SMo3pplNllVh4iOeee+dB/Plb+/Er6be8WYTW4pOvRckO8kpZ81N0otTaUbFSN8oyR1LeKwtd/2UPIGRxJpaZ3cDG7e7OUMam2y6+PumD+I0kz6lNiMjn/b2FcQ4GUi2AA6FApEwM5Ewk1D6/Z8whsI97pA== 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=hO/Y3TDh+Xl+83aqrrnnaakq+b2XZrech0AO0HNJg8/ys9JCH5RY7MBOFMUBQc7+D5cFZ6kTKMX3WRXMGpd+kyo/sK+KrSlc9lPOi1tGBhbqNd9HnWA0BSGxYd4yaQ1hQuA6BsZ53ZJbcdLY+LRooJBIcHDG+1Y+r1xZJaddUcWJpGOcYSVHMNij02ZTD0AH/CqMQvRHRNGpJJQyPYWdLv4ypvGcAKVffZmJ0WsT5mqp5nF5l7zej7jjOwRe9dWqkF+v8lazIBLWQg5XNEkRtZAeGzcl7CN13cCdpYvaU/+SXGsDau+vfSo75VDqhjErAUfwsn6ZP05GGAWekkOWVg== 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 SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) by SH0PR01MB0747.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:21::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.33; Thu, 11 Jan 2024 08:41:36 +0000 Received: from SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d]) by SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d%3]) with mapi id 15.20.7135.033; Thu, 11 Jan 2024 08:41: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 Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 10/13] staging: media: starfive: Add V4L2_CAP_IO_MC capability Date: Thu, 11 Jan 2024 00:41:17 -0800 Message-Id: <20240111084120.16685-11-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240111084120.16685-1-changhuang.liang@starfivetech.com> References: <20240111084120.16685-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0009.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::19) To SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SH0PR01MB0667:EE_|SH0PR01MB0747:EE_ X-MS-Office365-Filtering-Correlation-Id: 060f83a9-a4dc-4d7b-7996-08dc12811eff X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YcGJbMGfN5k4Zf+exk08/BZCrNKc3+FZ37P+G/TFvFS8NUQqu60o9DXX6CjDDfTkpgzVlvIzJw2GkGjnKwx+/ZkxM1e4NQBOd0ahEwTrosVjQWusF5Na94uErrDFT3xyoMgMQtI8J2Jb1UpK03HaZRkuRpUpo8CxiEjAY4pJIUy6iyuL8CUF4mjvpd+o8owjkdouljnXxy4QI8GWnAYSANKJbcVkv1wBfR1xQ/JaQVAgQX95AynOqdb/i1qR57noKdAIVyIW4v/MEpteTivWu9H9rUKIAo6ewazkYx0JAim7qrS0nOH1IedixKQZB1CIfB71i46/LT6gZaIqVHZOaMvx6l/rzkxkyl1tsgQhNkcU9tYPF7YPh0pHoRaQ9niNFZk5J1EpKl/v7h5pgvM9aPd81YeCUml/w3B7pgKM2bk0kTeNvpLRh13zRj/3i24Ew6HMc3KcwRctXQwWiyMn5ruInRyPDs781U0ZnjIC0zqW8nCxyiC/fr9s7jLxYwBuZHRJfC6kxo6ApLLINWX3nF775ygQxuti2hXMOp2NpJie3aAu2sFvRTyOUuzuGoZ4ZCGhj5JbiFhouuT/kNJIDg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(346002)(136003)(39830400003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(6666004)(52116002)(41300700001)(2616005)(508600001)(38100700002)(40160700002)(1076003)(26005)(86362001)(36756003)(921011)(38350700005)(83380400001)(110136005)(54906003)(66556008)(66946007)(66476007)(8676002)(8936002)(41320700001)(4326008)(44832011)(2906002)(40180700001)(5660300002)(4744005)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WBF96B5Er/5ZrSz3zsGKBWbadtFzp71CA8pUD3WCHmUjOmghW3+ICeGPXzpsbJmt7vdmETcs19w27SidT7yIjhWU3HbraYKo+4qFWas1qPbeNji8LOgNgXPlnr+J2O3HNKGmurtMFcH88P1SpKlZvBMNIYo3wxIK1rgPP0jgPkemmvavzM0ZDvLJSlwp9s4CfgGg6S2gtHIgVTSiIxLQx+0c8eVzBlAthQ5IYC4yqsK8eguroE3DTfvIGqkZTkFxRuldOBZJAp2pGFdJSVGTPZnJLMBuF6KpZdpR95X9O+1r6wWvMqGogYDc58O4uxaS8aDYxjm8fIHok1z4OnXiDCdSkXfcYi6dEHf3AVfLoB3rHaNa+keMMEj9dgNmTQ3C32gVGgyjbuScaXJQaC78jfpGD0I/CD9Wwti5PytqWEFtz1WSc446AT0/n6JNxrsndkHWb0xSyUcW3ORhbV01Lyx9RL52O4FsewxBAbEMx61vDfK/8fE40Vf7cEYlv4UVQprd27LUdfoKwlXry3BdOIJmH/dO1GloWJH3YUwrnkzUAJcYdiBrbWlZWiO/+vANgPD/mjIqFtkvwxFY3RbpMXOrXxPNNDXGxOuwcQZrUf9o8r7+xQLCYTQg9LEgxdRmt5s5GeJfgEugv6loumtZxYuXnKeSAV4Dp5gxxRCT/xW6bo4fhCf/TZfkT6oZndoNeta9ezHnBp2rlJdjC3FzOpYjuEQQcuoEjN11ttBGvSy18RIuZ4ZCi/DbA2HuX3ePr7X7P9/X4Qd/jFW6ovXIu/qb8pT3QmwTjAZ/wiq/cFh5S1VH500Rt3cULQVwwGm/vNZslvA3fB68KGYb+o5JddwfO5299Rn8zBZUku0sfW5RD5oWGG9f3QWfl/uWG3KapgrJGLv9LYO6lyAxBwGT0ri/U6H2yg/Ad8xVBi5Rk7dXRctJILTztsgzKIQu26Ns0aSx712Vv+zKq0glj5MkbdPo907Nlj4+R3ovH1p3t7/foCWNwJfX+a1Me5LxGfiRC4bh+ExQ8MNaSbY8tVEE3KxuC2/fRjgcMUKp58bNAZCl4yVnWellv42t3VM8ccMkGWVFO8aq8j5EMe3NVE93OwnIIAFiOkrAVWTkiRYB3DeLJSG1gWvgc5iNJsobBx4GcI7Ud9dGL/hT4nppkwOcNL1vdOB3oS8JDRsYEKMf/kyixwsuFTR2hptHrdH+V5tFohVbwUS3mTUKY8fkKGSSk6/JyoWnCs5qOex3MVc5jdVAHhov9v/6x/8rGKof7sEQA/oMQnCkjY0nKh2XZ9XYyPriB5mEYtndbVDMdCh7TeLPHj5U1Ql6Pf5cHd32udMTbXe0/AWfewhKTRQjMcfP466fbmLOKKC0F+w25BzKMvoL1nJJAkRyxaOqiqTRXl7oxoQki9UMfxb33zw5+Bopl4bRrChP4+GHoVZ3ROJj730JzPR95GrkoVYXJcWPGlLU7F8ccDC1NFz07NU2GVnNs2Xx7DKnf5mzgG4JHHPECCDFkqTpGuCZ71LaSOlEF3g84sHevmIDUMgNXlft9bl8P+7HOPl7kJIIVv1ZNrBOWmJuQkAAVSCWymzAsXWNxXRTLWEue2VBxocx8kgpKJrQW5fEfmXkYpwZUE1GKYoJwU4= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 060f83a9-a4dc-4d7b-7996-08dc12811eff X-MS-Exchange-CrossTenant-AuthSource: SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2024 08:41:36.1161 (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: OuA4lj49L9ve69LVy7UdgJtnDDYfLLp+0oUz7AAV6JsnUUIAnfEJb3FvtnJ7aYixozm4ASnBts4bzp7HmBdbLpq6kPqr7kCJn0uPZ3PNLufxd5PouBXmiRz/8uwqrOSa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SH0PR01MB0747 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787784126746482889 X-GMAIL-MSGID: 1787784126746482889 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 Thu Jan 11 08:41:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 187255 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1316517dyi; Thu, 11 Jan 2024 01:02:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGS+2FmPlTv+pb9f3hNcBpYJAwT7uXAqN4pnfh46HRfQceiSGIM+LslmRtvFY7P00IaIrqM X-Received: by 2002:ac8:7f04:0:b0:429:7ef9:2148 with SMTP id f4-20020ac87f04000000b004297ef92148mr371531qtk.106.1704963728485; Thu, 11 Jan 2024 01:02:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704963728; cv=pass; d=google.com; s=arc-20160816; b=oXkOfD+GzWvXTRnhRLl3LKMwf2ojvzbSYLfbh921Enxm9eis8b7ZX0bHS860tyc1av aPTR0R/PBTTv8D5Xi0Vz2ZM0ioT29i/ZYSWW2l9X30U1phBuGRiLY4PGv267SFa2RAk0 psPus+xZUtwAafb5Zh5STXHcFP+NFe3FV5Y9PmfFstoeh2MkqIfGsHyW9MtJ6I6H3i1L klV7rr1Ey5KsItrQKxhJ0n8JDS86lsD9nAMLo1bQCDVU7n/1+kZesnsSl/D/Umy01raD x9LQXYYUsjGqUvfU5n6u99iN9EW3W9AXcx13+2jONXHe8wg3djgeUJ0H3G+nXD0gxZhj H7yQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from; bh=nLUIKEQOFP7DwdGLZjRCF2pAtfcyYftOURWGq1yoAI0=; fh=AIbhTKVlrbjCdvqTRYm0MrNe3T1Hh+lXyTtmg258gY0=; b=nL3NAHd805xfjLsLNP8f3w7rmpMTYALOpf9pgvvRa3E04cje3j4xJMqUXkj/I4ogYL IF8lalhWuTl7URGQ1/+KhollKaFrqoqhi8+7a1crhq0IaNHRKxc5oyKbCf9EAXsydlOX 4FiL5rLGizB8FNW6wuw+TlOUq6Ug+sFAoM8HqwNSvyMVWjXbjjWIVLIfnjhTKZ4F43XI aaU3lDhB1JmfMQtbypv8BaPuxMD+fSf3+o4aaeMHVCVB/hkBtMmN7nG1q2/FMWyJggli qPX/0atEcybskKhevU1Huj6hbkGKwkMacn+M9vfOmDW3ZmSbsx/iHiPCOFvv3A69rQ65 6JDA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23272-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23272-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a17-20020ac85b91000000b00429bdf9ce17si541833qta.177.2024.01.11.01.02.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 01:02:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23272-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23272-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23272-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3B3941C256D1 for ; Thu, 11 Jan 2024 09:02:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3062814F62; Thu, 11 Jan 2024 08:57:44 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2048.outbound.protection.partner.outlook.cn [139.219.17.48]) (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 DF1DD1772A; Thu, 11 Jan 2024 08:57:35 +0000 (UTC) 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=hqMF1xSK2TBXo+hN5hMSLey47oSzptIjZ7IpPCCUPV2+RF6X15YDhbniDX0zrP+8cy5Qlox8jRRFzKn12Bb+sfTfXDkp1PYyf1lRqkA446qqxwIQZZp7s6QGQivec76a1XKa2PIzirEhWiyJ3g1fxEl85fcwdP8QrUDLUjbv8A8EhgvgrnjxxFjZ5hzZNqXbpG2ltr5jtqVSMw2spS57J38bcGn5jGd5VRdsy/7JR4aVRBhAE+N1DTWyNVUYqvs3zBY/Bjm3IM67E4cmx+3jzTPOiACviQRw1zwRb4HSSSrj/UeISvo1Y4HwShOBYotrnX1l5v4EAsliBVfD9z/jcw== 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=nLUIKEQOFP7DwdGLZjRCF2pAtfcyYftOURWGq1yoAI0=; b=fbGTU1Lf3nhzZwgMfixnez6rhAilelHDmH4e6+lOQZbwv/+PwvcOz7lexe/SMKF9Ts4iEBF84RX/5vvRZ7qINRXBziylIImfXMywI/ppgfY9ApVkujK2cBb3RWp5QGod4XpjjFZXbKQDyF5zw8gjZLZj83PLsABCRw1uk3doXOl2ykbtT1Pz17gAnzXVsRU3N31M6OfkJEXyLvhUufFEBQaN+vwycYoxt/XMGyK0D+STrDldduqv1LCceCA1cw2t78XSSzleds/9VWwBYsw0hejt1d9l4Z0Q/AH2Kh+TEE2a/2X92SESa89FteJoQ5xzQsutKVr64ZO7KWYavANmGw== 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 SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) by SH0PR01MB0747.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:21::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.33; Thu, 11 Jan 2024 08:41:36 +0000 Received: from SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d]) by SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d%3]) with mapi id 15.20.7135.033; Thu, 11 Jan 2024 08:41: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 Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 11/13] staging: media: starfive: Add ISP params video device Date: Thu, 11 Jan 2024 00:41:18 -0800 Message-Id: <20240111084120.16685-12-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240111084120.16685-1-changhuang.liang@starfivetech.com> References: <20240111084120.16685-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0009.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::19) To SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SH0PR01MB0667:EE_|SH0PR01MB0747:EE_ X-MS-Office365-Filtering-Correlation-Id: 28c01548-62bc-41a4-d3d2-08dc12811f7d X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fueyE9LVBXstFBeW+NxQsNnBiWfh/SMClUZg0zx0KtRKvJYuk5SqGAFpXfiOsY1Gvb6wt/W8ZDncqmNNi1ejP43oNp/ZEKYJpi+3Od4Ga7c87EFiEHCRFI0DgOygXd7RkiIyp3uWpSEkylzxX9WDoC7tjN1kQUEyOoLfi6t0JYhwsaYr3O4MqfwacUolz5MG2vjka1e6ugIFP0NAvJgoPOyA8rm1jRWFxDvdTY986jBC830fUYfuJe3D+yysdfRzTfiUc/rI+RVmCiVtzvp7iztiX4GjCIEmmbdvHJnISkeTqt/wiU1o1D4oWrhw+NHFBnyReuShEwkhD53lo9BNTDvSpYsqorHTWSEyS5dImRVJtA0gb2M4Jl46FeP4p3Q9HjJnHN55NU8rCHj8A/NdyO0OxIQ3WswaASZyWZoyuAjd/0YTbCvZcB9YD4zeZ6JNZlrcDgsDWb78L2qYcX3qRc33EUjoZw2Hpa1kbse0+lO39nY7p6Ke5sg3XLgZAb2ZtTUY45426aUQscfqFMnFhb9z9pF+32+2GtfxTcSpAzzEo7fXgqUSMEKDNoc8idkbR1LUfWM98K+gQC73TIrSkA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(346002)(136003)(39830400003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(6666004)(52116002)(41300700001)(2616005)(508600001)(38100700002)(40160700002)(1076003)(26005)(86362001)(36756003)(921011)(38350700005)(83380400001)(110136005)(54906003)(66556008)(66946007)(66476007)(8676002)(8936002)(41320700001)(4326008)(44832011)(2906002)(40180700001)(5660300002)(30864003)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KkTbOREDLQMIVVeEWy3nig3rMv5htH3p6Ccwx8uexaWrFI6+sxxvgT2gAbE7AKXZmrgw/mmOeb8kBcYD/e4nMhpmfEPBV/vItTTYHH2cZPiA5JNgAzfpvYcu7Zkl+PckMn/XDc3PwtNcFG8KEW6IX55W6yzNsV637QvUDdg1OtLW6+es5w4S7reGVC3ZOYt/oVNcAdY4LoBcjjlagRkAqvDuPO9cjSQgt74O1/lQf7YRQiGc9t/euZYhprQ2k4UN79DXGmpPDaw/YzCcAfEvsK0f7i1zexbqJW0KIlYSg7sw0uCaytj5ryfXyBWYGWJMuh6pmFm072jWH2ib/iP9JI6DGi6bMHuRaFfNQ46tTKyL9slEujXURuzq+PXAv6jusAYUP1dflbf25JaqTwyawis7vZer3lnTJS+D9AaWx+QsFHDdrf4OhjqjvY/fz6tWlBs6UCWSqXCYqgVy551xqUzM66NVbVCQ7I8i5Ow0LWZwEQ95Toeo4ronSnrJm/xj7Xdew8Ppk9tsbgply4D4E9gaApYRsRiQ4itku1Jn6dZIMP0bh/m/vBpNllAbfY+JTIDCBNPTdJDCLxyHkzHKjU8YAsOtNbftOSnHue60VXX2AD0dzlQug4VskA/8d4+nAZTYassr+XLaW6h+8K5AQMa6qiuON8x6rBGd7tA4A0c2NDUkNh3RKFi5/dMNHEWI6Kj/MVwh6HFOo9XoDb+SNqvtPo6E3dL0A3QojD0FQaQABRsyWckLjdhcER/XjE2WQXfaEw9ZUu2V3q+HItVtY/JpG6u5SrcXk2LCaZ0lwttO1/ZGgBSlQ065IaxLFdjNCnZKUDBnCNPTAaVcojj8HW3bdsQcbHQjQTp5kitgHRe183s/m63UWcD8NxkvXyMmvaPWg5girpuH6dZb4vawYzOn5HK4YkLhIddSODfCTeOKsyRUiEdyz1zcE4Y7i+N2rjNvsAgqWWV2Aw7VGSatVPrC+9XNKGpxfxlNAQg3Hp8i3izWPQJUJU02xc3b9E4uovIu9n7BqOEeyCwaoyUJzIULzx4jJC0BN7Ymu6z129TJBH5x1GYUrcCZ89raiNy3OX1pKLuw98q1h+Hhe+Ms2dM+pTG4SHf+PqGvMq3FwW4dhKA/jdLlVansNFFJM4E0NkAbWvsUYUyvMH6DYy7BHeqF5PmyDWt7iZZqcvutRpEn8Lf5+0fvSLoKo9XkuGliMYk5/+AL5fKLxXCcTdmSQy2j5bMELC8/Jre+Uaa66eiE3Z0lQ5jybiSadeyyLSHufJyfmDFQJbbfs/nrKTLQzR9FzSEBJYmXD1HMhSxOy9h4MoAy6ZZGlqD2YBhPH96doYLu3f7KzY7b5olJ8Izok+WLeX75h5Vujd64UNXFgtzDRyejla3DA6VG1FkVDHCbTw2lRhsn07Awb1oDBdwnNyWMxTeHTduzcoqiLiVu9Oh4Yb5+NrJMQhXgM6IiWFSjX+pO1zXUTV4MaAwZu2EkRGvRxKyRLD/UTzLfj3RyaUlB3uYKWelcBoGbwK/ZkRJl2KmbAazFWqHVZP9pcf0xa5VTS6K2sRhfq6KvdkH8mMtyNHN2iToqPjB0ec3ZbtGB4XgazWRSrxpTJssP/tvT320Ho9vDz4OimHyddXwQ5r0= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28c01548-62bc-41a4-d3d2-08dc12811f7d X-MS-Exchange-CrossTenant-AuthSource: SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2024 08:41:36.9134 (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: RabgP1r4XluhLODgEeR3gpvxxbb35dknwW9uxX43PlPD7xxe3AOZNddri6W5KdJzFkqOmxEviNvfv4FfGJVCJMSzV5mpP9uJ4fBTlSDmiavdoia4y0u52ldpLuJ/DfeC X-MS-Exchange-Transport-CrossTenantHeadersStamped: SH0PR01MB0747 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787784046887400729 X-GMAIL-MSGID: 1787784046887400729 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 | 19 +- .../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, 370 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 3175d0d9a05c..51357f905a42 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,26 @@ 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(&output->video.vdev.entity, 0, + &isp_dev->subdev.entity, STF_ISP_PAD_SINK_PARAMS, + 0); + if (ret) + goto err_cap_unregister; + ret = media_create_pad_link(&isp_dev->subdev.entity, STF_ISP_PAD_SRC, &cap_yuv->video.vdev.entity, 0, 0); if (ret) @@ -162,6 +176,8 @@ static int stfcamss_register_devs(struct stfcamss *stfcamss) err_cap_unregister: stf_capture_unregister(stfcamss); +err_out_unregister: + stf_output_unregister(stfcamss); err_isp_unregister: stf_isp_unregister(&stfcamss->isp_dev); @@ -172,6 +188,7 @@ static void stfcamss_unregister_devs(struct stfcamss *stfcamss) { 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 Thu Jan 11 08:41:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 187239 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1309609dyi; Thu, 11 Jan 2024 00:43:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtRgoAkZwRiwiR1eTqkZgXz1rV3BSrA79C7ggybI3ai7ML7oZ1pEKZAO2/K+27Usmof7+x X-Received: by 2002:a05:6a00:390d:b0:6d9:abd3:765c with SMTP id fh13-20020a056a00390d00b006d9abd3765cmr619171pfb.25.1704962637344; Thu, 11 Jan 2024 00:43:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704962637; cv=pass; d=google.com; s=arc-20160816; b=C0PTbFTYa2d7iX5F8N+yIqSkOoAxWAerH3ZOLHqwLMTgKhZaT0As+Wf+crg4AzHgFd gumslsuYf/KQs+5fGUxb4znRcuT0/F7MP5U3gtOKuSpEgSHD/dhTaBQIzCnyvIaOA92v cMG0Jo0narLIr9FAri1bVVP+CmnNzs9CvAbuwx90+nzFRv3DxWQqWfudP/OQakm8DChO jlh2tBH2GH3qZorGusu17TB2WT/lzOe+i5MzoZPWiznbgTAL4D52LdyvAtsokCi/SXd5 7ZKbTdbopZoRLlWKznX2eUQvkuSbrmV7wF+K5DHRqzVLac1eNhGj3ZMNIavBPu0s4QSH lVyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from; bh=xm2VuAHXxV0FZwwGbnZD1quf2ysDfHXpqolBHkNwZ2w=; fh=AIbhTKVlrbjCdvqTRYm0MrNe3T1Hh+lXyTtmg258gY0=; b=qku3CtqG6anxqCVif9uN/W2futg5ceJ2XNBek9m/iq9e8fW50ONxb4u1q3sXSzcQK5 ge/JXIML+U7+jT5FyZjP9vQpJ5QbFxep9e1CEC8U3oYluUWbyHCCtuLbF5wGPtltTjSD N31I3uS3s3j7GDNTGszAZLZ3P1ICXtlU3S1EM+ybTPZSp84yW7z0XufWqr1Y4L6Vqa+F dpRt28fpLv9+8o5/qSjyAZguoKcJIkRVwthW0jqTAelphWSZ9JAYfF1JUO9noAk5+Nqc eMj+mVcEm+OboYt9mtSgJWb6kz/eJswRM/U0CW+FQBlHyxOk45OaR6DGQKZ5XCVQx5oe aJxw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23235-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23235-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x42-20020a056a0018aa00b006d0e1cc26a8si599974pfh.197.2024.01.11.00.43.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 00:43:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23235-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23235-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23235-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 32429B21B73 for ; Thu, 11 Jan 2024 08:43:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BCA9D12B76; Thu, 11 Jan 2024 08:43:06 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2051.outbound.protection.partner.outlook.cn [139.219.17.51]) (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 683E1FC15; Thu, 11 Jan 2024 08:42:56 +0000 (UTC) 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=KbFljfI4wQhY4puM3r5WbCFj/eBhLxY81avYqk6odFrm90lfvEQv3iNO+IEEpV6lgM4W1R30lssCg1gsnBXQ9n5ifIn7hp2yGCUqubFIobRIK/JRm4D82rXVuZZNROu9tT0D5qZgXGym+WTviZrEf8p15F1GtPCEJq0Irmd6gh8PKdoWdY/J1fUN1BZgNA0GlZQ0JdXMjsN9Ey7R8XXTdazIurL3hQbt5sVwjUA732wT8qZhUqcCnGtWXaEPF+U/sMxspSCq+Vgjjv6m2RI57JO5VfjokXdgFVsvhdQReNRWlrSycD8WdgRlmzC6TfoqtWt8s+NzhiTtaANJcEWiyg== 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=xm2VuAHXxV0FZwwGbnZD1quf2ysDfHXpqolBHkNwZ2w=; b=V5U8WCH7G0N3vPMYaxbqeHafJILPfJIeN1kECT6PbJhG2rsfshUdmUp6lI53+Qnsl6C0OYJ/JTco9cjjCu5a0qYPfCYtO2F//YZ0ho3nKweeypWJry0rambFzfS5gu/KegSjY5rFAYGXKpWcchTHuw6XFdM9axfqD7Dszcif5ZWBz4bYKGHv1EhtvMjpxazwYvSjZULnQNpvpcfwYq2rzA0aiiID9kUCYu4+4cJYn40GrfbBq+fwLX3BJxWcJIEtvw9yXEeSQaoXcTmYjCx3500+2fRERdqj7hYa6b3ptJajFJvQe+Fn89+eU4qx07mqggh6s8Tl3d0MGx6FWsqPFQ== 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 SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) by SH0PR01MB0747.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:21::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.33; Thu, 11 Jan 2024 08:41:37 +0000 Received: from SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d]) by SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d%3]) with mapi id 15.20.7135.033; Thu, 11 Jan 2024 08:41: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 Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 12/13] staging: media: starfive: Add ISP parameters hardware configure Date: Thu, 11 Jan 2024 00:41:19 -0800 Message-Id: <20240111084120.16685-13-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240111084120.16685-1-changhuang.liang@starfivetech.com> References: <20240111084120.16685-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0009.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::19) To SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SH0PR01MB0667:EE_|SH0PR01MB0747:EE_ X-MS-Office365-Filtering-Correlation-Id: 859d476b-be70-4522-cbc0-08dc12811ff9 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 44dIOmtc9wFAAOlmDR7FGeYENirgV3uLWfJXmFh5gdPUCxhmE0lOzscUBf03nNVdLZcpogeHeFtieV0BailPZx89iKE0BEYfAPaV8FUIpPRyqKcRViYr4Gz7RFrUmYjyRjx4SA85TxPeloNAp/SqDlWofw8fo6PnRVDjIi6cYa6FkwtQElltAz5D5qsOlH77mK5Sw1IaBZwq6on4ONWKYeYR7bu8f63s/mP1eaBdI5IlWAGbIdE36rJxap/oc7FVsm/xhhnuABPbVhoptbmDJaO2cAjmWeK6Rcd9cl+/eFIoAHh2tkmXX2VYmFYGajo2o0vRJdSIbGRftKzfdwTERfAWa/xZiQhTHOq+vMucjZKW4qpy7BxLC1zrBrPVTgXyYBn5VmBx3ApizNXFDfaIzKDDZ/5fJ0xSeETWteoG5viZG0LF91enr5jb0jR+hb9XQYPhrFgNah7UKyfFtpgUngg7+f1yZQVhNxUz7GQ7o7L7Ti/EKX4rDsRvExifPHIqMRbNIxq2CEv7adpV7oPyIvmSvudE3wFivOzxXg5xyRxPt5fPQx/3+e8Eapq17pKCvM1HVSs8/4Mct7KQ/XAhFA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(346002)(136003)(39830400003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(6666004)(52116002)(41300700001)(2616005)(508600001)(38100700002)(40160700002)(1076003)(26005)(86362001)(36756003)(921011)(38350700005)(110136005)(54906003)(66556008)(66946007)(66476007)(8676002)(8936002)(41320700001)(4326008)(44832011)(2906002)(40180700001)(5660300002)(30864003)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XziWQLWcQM1CJWHafwleUJY5aN9XhT1BoI4r8lzhWeixat7m+/80K2ZPNpZ40r99R3YVuOcJacQ2aoAsc4JEvQe0p4UugmcqvvDGomPkU0sEsgR7v6TI5qv7KoamrFZWFSM62RQpXb/EynBcGdrnay34cfIfIs2k1kLv6p7Ynvo2N5nbveco7Yod53pbpg79CDbVr2XxrSTWLVNgCnAlG7aMEdLy+3fnEK+wOCU1eWuojB9NJGGUui80GH+O9j2VW7uaeOtyo+14M/l8yI60jOFsFK9ImNyQiX64DPitUS2tiX8AYXSoJ1Fw1qvnkCtO69Ynnw9wXuzm5Qx6KkJSlWce9TfYg/YmUtpbIgiulFCW+j0LW51wG8SZANRXEH1gdqb4qExxi2Eq9KHWZCxbSM3cAQWJPwCLQ1mSk3N6gAiK9o96f3mzyuTPo335DdgPFIZeQ5EmnfqUJpEtkUKLUnEh7war53ZmJDVC7HqXzOlh7kRuf1liQ/MLdP2nMslRKiRZKPZVmrHd6mGYXPMg4ZWnU3WPtiCqjxqnC4nLyJiJgaVb/3l/4N4yqcvNQCqiGLkxRU/gVtZleEjxxojF1aLJxqThm1ivh7TzYepfR8JQObM/uB3j9fPLQGIIKGCokNEkqTxN8RZ8GSwrkStsISGT7NfOCFJ+PZiUJaaImFa+KaPzH7RaH/HzYW5GAh436g/mEE7GsCRDeZbz4AFtyj8hGwSEGtue5wZshtH+GkQdvMErm1OQP0Ta19DtP7NQ3l5OWJ6I9rZh7ydQlagVYTwGDTfvznjXKq7Z3sAuEYsCfCXvDhqVIHoHrC+3t/HtPRggtg+nD6a4TXCNMRrjx+8l0GqTw4Lf1OrA2LqUCWOjy7ehEu4VDFv/fo+gezqUMsXOU4elqWTtiVPhs3Zvn+tzv/DTxaPpBoltC/3Zw5yozGb75Obhi20p7P40dqzlXVRf+M9kU/mREmQTmJWbBNHX+JupPAXTP/dlzuFjdzm+vOf5EXoR3JJEUgloSeaU2YleaB4BszhgeeVC0/WkwM6Ne/fdMCWP4t3DDv85LMbQx3Uz8RQnoLQ9szWScRhLOK+ZGu7W5zUXT7V/3H27MuNyoXb1LhUaqTOVNI8dAmkqx/SF/3wLb9uONVGc0XcfsFtBAOBLn3STD7z0x7a0J8VIFOEqasRUH/2Xy1h9tcVAXu9cSgBGXX3P2bMFXTFuigMyhDlm4LeZCi32efj91LgvuP7i7yxMx6OKzo0SgLEnMEGL0iA0ReJ8EIERTpFYDrcipq5LLqjYLk+fRM2+xbSmV7RUEHAbqKSJ9UYikv+vE7raLxlSs4prmos2/t2umCF2v4JNz/gzIcsm3ro95A3u4XDcP65buxh0h7est2Yy9r9hZlgD8VaMkf1ZuaNHHM2Y77nwRy5nMUaphgl0mV0i4aWCqiZv5A2k2Bu2ro77nnkhf0EpC8gk0Blwyf8VB6TOkMr99jRK/LYBePPHhtk2/8XPSYJgmQH4U9Qz1i4Vd/elfVjNmZVk83+kQmnpKH+jtsaXoy6YNommxvnivmBeARZx9PvrjccZ8HGw5pOQL5d4wn9ubhkmn09WhR9apD1o/VNzogPXlC+upSJ/c7I9zil07AT7kBgHJr7Y0uc= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 859d476b-be70-4522-cbc0-08dc12811ff9 X-MS-Exchange-CrossTenant-AuthSource: SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2024 08:41:37.7907 (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: 3XRtIDt5/PO/pLCMvZrRCsdwTs1YeOZfnbMx7EjvI6WdWymwtctqw+iaIS6K5cYpsP5eURwHfi8QUBqCHRxwNfWBqGkEmcXwObi3n7dXY8bcyrJihzIjC0JE917oGJ/x X-MS-Exchange-Transport-CrossTenantHeadersStamped: SH0PR01MB0747 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787782902383103046 X-GMAIL-MSGID: 1787782902383103046 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 c778251e0024..a0c8b021a3ba 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 Thu Jan 11 08:41:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 187240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1309776dyi; Thu, 11 Jan 2024 00:44:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGK4gzjxzXI52qBheu4/iea8keMI9/W0TZoOZW4zloATKpJTKF6syeMS7m4Oa1M9+Fs+XDN X-Received: by 2002:a17:907:c09:b0:a28:aef6:9964 with SMTP id ga9-20020a1709070c0900b00a28aef69964mr551234ejc.14.1704962669161; Thu, 11 Jan 2024 00:44:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704962669; cv=pass; d=google.com; s=arc-20160816; b=j25XUJ/+n4NuRdijLOO/oh20rc519uY262/VL1V32wjv7fEhmp84P4ZL5NY80Xv0Ap QpyUgHF5/z+mvKfx4bDe5ttPLc9JJsgErrwZG1iqX8BH7C/9QGuCYmKwUh8q4AZqRAct Jv2fU6egsGh/9vgbQfwpf9cpoYVUqpF/meP6hWfNAdwjGsP2eba3waI2vcGjFFffQZkH yWAbU/rIkZrSEf/m175tzpmHKCBF5+8k55c9xe2OP1vCkTF6uHe21vglVMkWppQFi5s5 gZG3nkXkP9yPwSBPMHoIpsaNWTUcEwb2IWYWz3ZRRPqDQUQ56EhRkxmiLvloQj6aQLdd 1AbA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from; bh=tpOFUQrZW8GSQTbW3FIMAhf3C7AGEcEZyiE+jejurPc=; fh=AIbhTKVlrbjCdvqTRYm0MrNe3T1Hh+lXyTtmg258gY0=; b=R2zDdvTxcUszZe/1lA1ew7L/qLKiQH64zetgPk4bmuLupSNGRydMhOrSY5YeVjVWDU 5vyURepx/6kgLPdePRg4Y5c1Mtjl9GZeXUveskjuX0nIfKHJB4Cc6kJfGdLX4hYP/4Sl UPbv0Iaf1EmgSenLOcun7q6CIOpJI8UyVxd1fsKfHwLiKVb/ukym16zKsBbFWiU5AJOd ygN2lDy6qMoc2r5cnr1HtMA60/u/S9sJhwP0Kgp3OucVBvxDbkghFpPEb76hSWBmFFUj 5ptGdgrE25yCu+StgZRxF2PHipu8fHGTIQLvmIQWzHwpPPErYyo8xiv4T2BZi08f+GyS u3mA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23236-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23236-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s17-20020a170906a19100b00a2a399a9bd1si285024ejy.714.2024.01.11.00.44.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 00:44:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23236-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com dkim=pass dkdomain=starfivetech.com dmarc=pass fromdomain=starfivetech.com); spf=pass (google.com: domain of linux-kernel+bounces-23236-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23236-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9A16D1F25D04 for ; Thu, 11 Jan 2024 08:44:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CDCC7FC1E; Thu, 11 Jan 2024 08:44:08 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2078.outbound.protection.partner.outlook.cn [139.219.17.78]) (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 E7EA112E4C; Thu, 11 Jan 2024 08:44:04 +0000 (UTC) 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=fIxeOipYEthRXY4VNYER2SdrT8spMDhUbVfT+mwFE2DsJdHCKMv84f5+tU3GBppEY5+n4QoFyzkciyIHT8DNuicELelNdg11hS7bOC/GOHi/S7tBmXXauOD23rV1BS8LPaaK3Devjri5xu15+K2WwqzkvuoOL2geZ0pAF+sZ2Qz++hM7Au2MOEKxa45qSUh0E++EfRtCqkM8DpkB9VNgtn4EhiIKMpvykF1m4ZIIWdxxQpkjVRNr6gx4CYf3/MGarfn7gDnEPXB/MoPRcj7UVNTho518YXX+Lj1JidckuwTEGL70MQ4Gy8m2RlKpAy03HaQ6aJtbJ30sqaDnkaQIPw== 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=ChtAX8/hG7mft9bC8R0UOLo8tZd3JQhymB9F4Srx5a2MTUcBziMhXylIc1tbwznM4mVSxmm/7lk0tnCQqc3u+Tol+Wu/pU9OeJI4/jNqEmIzHtbcXllCWZhOPY79JaWADApKBrqNZZTHf+KNKVLjNjjS6UEZR+XkwdKrFiv9sepOjEeSAJq6OH+rFOhKqONm/M6JAVMoo4BJlf+IM8LjwnjtB+HRnXfHyMbschPSHSvA3evizO4b0jAYK7s3SJyc8ldEuCOHVqscYcbUZswnIOIFIiU5uYFANa231je7NKwkRPuIo7EndzNl6PW85woHhacuadBBmkYpxECGWXleKA== 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 SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) by SH0PR01MB0747.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:21::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.33; Thu, 11 Jan 2024 08:41:38 +0000 Received: from SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d]) by SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn ([fe80::e255:98f3:ba27:8c7d%3]) with mapi id 15.20.7135.033; Thu, 11 Jan 2024 08:41:38 +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 Cc: Jack Zhu , Changhuang Liang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 13/13] admin-guide: media: Update documents for StarFive Camera Subsystem Date: Thu, 11 Jan 2024 00:41:20 -0800 Message-Id: <20240111084120.16685-14-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240111084120.16685-1-changhuang.liang@starfivetech.com> References: <20240111084120.16685-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0009.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::19) To SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:20::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SH0PR01MB0667:EE_|SH0PR01MB0747:EE_ X-MS-Office365-Filtering-Correlation-Id: 4adeefe5-fffa-4d7c-884f-08dc1281207a X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s9vPfPawBswxprqsK+nmVRHIKN9qLyoAoEibmBgh4kcjdqesmdPpytKVoxSqrdKIpuNCb0KjQ8wwTp/cKrQi55is87JZ3T7+Y7AHRyQg2mkqUKsJPuBHH5Fo7f7uQ1l+STAhYiqfbwR4ffjLmhr+UWYoJDVhC23mPm3jUvBj57gP/ZyWuw1pildkvs8Ns2qFV/qSbU+IdlHCxe8kxGb9bv2LiYmtUqQQRH9rp8xvBF0mxc+VNMSNgwDc69f8dsunsdhiuBHFVAHO6KMxEOr/PvQAG1mehU/rQvKPTrYk7GY7wp0UAp6O6FS05BqZnlnb1C6JMsAVVn5jfkQgd1LrcIwa7D+zjBvxwDFujlbtWaADrL9O3cRIYU8tz2sjYMJaVe33my4EY4AD5icDhd06B3Sc5MWNXQk/HOEs1lvZfUDldOct+1QzpzQVOI3/5I1cAE1umWYt6Ng+3HguHYnf5sr2sAYbkAXxTa0FlQWsxZkUvo/JmgGpczl9w8dwQ6Vxhu0C/Eq8xd3p/hfwtAXY7Z9upj0Qix13GJZr6ckwOj7IsERUuycKyWvTsCYlBkBJjiEAPq3zYoXBAz/4Z9Z52Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(346002)(136003)(39830400003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(6666004)(52116002)(41300700001)(2616005)(508600001)(38100700002)(40160700002)(1076003)(26005)(86362001)(36756003)(921011)(38350700005)(83380400001)(110136005)(54906003)(66556008)(66946007)(66476007)(8676002)(8936002)(41320700001)(4326008)(44832011)(2906002)(40180700001)(5660300002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UfbBV4WjX1MUy8Gss0IqLtkjxJbwiBDkrLzJmanWA+UmwmnQp9f6VcO5e4SQmcM52jelNzUVX1aEA/h+g2qtHLoP1qof0jaf/l4VLYqrlsK3BO9jpJzbHGN12n3LjO2e7KOZqVmd+1RwmU2jcEtBKUNTKgN79y2LvgqCuqw4DdHeJeym86+NuORR0PZmmW9CkR7UgboovVu7YjW+trzDrL5ueSi4J6zga1UgPGfTqrp4J7nS9SsnnSKZlduXo8q3Nkw5X2Q6aCfk1lZFKODFn98xtUOMzgXXRuZejgwlnyA5QV9iGNe0vgwqSMwtXH9P40YURgOX4y/PROlul9JlD5VRb6/A4tcpKGqlj6OcUYIUQ85k53Px/SmVWGZS7aAN+N4VxV7DZsY9AAvpTBZxEaWk4wADSZW5mYjFHQ0uYSeV/azRUsqtwl7rG4a3+0Jyid7OdrXbeavHALxTHAshvaTGkPqxMzjDmegN8gX5fkIrnVD9sGWgUXOb0ZrleWFFYJlFENIL83i5oM2jlH1tzhRofy9fqZP6ZWGwAdIpD/Rpof0NCD+UMkjh0+RwmvWfcqqOXGRtQaohOLEjnlxPnFHU2DU39Iy6EgQHxd9EwnOhFzo2A56YuKsLu7kVj4YVDpF0K+d0AxldxZhAY00vwlQHrNVJSO0CyHGLN3VcpFpdq21ol7OkXhFk6JrxvT65e6mD3q8BZVEKQqOjf/tX1A05l8hib/79mozdgc8Y09y6lNUrAhiH81HXrfywWBvJwQLkSJwDnSz7wDP16epO4NHXNEF/uLkKyl1zi/9azg5FymYV3RXau+FSotDk1HO/J4azaRn4VdA/KkVIFc0j7WcXNwdxGdc/xNQCWGxX3fCyOlp7OC9j+a5QoMwMdE/AtpHjiQRWOqgmGvOEn3aMggIVZ/tHuuluO+FvzqkwR9kMsVq6uot0zaQSApOC2MyHbScmZmgNv2Rt/JcoGejuAemXyKdMBtauqz/ta2w7bv3e0jdFFSEVkqTj9JE1rZACQwPzz2N39xx77jhthZj+IyVZCfmYAKxcrUMqj+8kgBt9uuxE/Jr2q2IR9k8Vz0H/cpcKUmaMoLyEbGMp87nwqCBOBRG8nq25vhmRCGQoU6n9NEd2hFwvKJw/+zd+tsKb///ynjjaU0wjYPeoybqbVxBAb0G/zrOUikKLTCfxPluEUTwRvj1iDhrsnmSn7hrk0zcL0nPNaBn9pdvw0JXBP+b26S6DPPCBNbdNrWCdi8uxhFIQRgxCTCHBhN50IMx3WPZWOb3O4xV03IcsyXsgbBbaXyZYIyHd2edjoK98ecakCkkvXE8b64FbTGwa+X2EE+s0EL+q7tdS6xJofhssN2FLmac5jPXR1mP+Rr0qlhUCl+suBeNj7cVvVjMXh/Q13p4FOI9t/ZM6PuQ6VjHfCIPhBam3YEl96RJA1JgR+8I/32szJZsKkSUc8JZSs9F95rzPhMB+hTKl8vg5y3JItjn+4UuXhgPdrIeYZiJC/y7XXufH89hMjr+BTM2kWk+1lY2ZD/8e5cMPDTdIRMD3qwDWgZUw37l/qhkj3HUSL+qGmX1qIkyvCoWT2FrW9GNOMOovQKC8PsAfC4AaIq2P37ZnH5/ZuRDm90hvwqDcxCM= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4adeefe5-fffa-4d7c-884f-08dc1281207a X-MS-Exchange-CrossTenant-AuthSource: SH0PR01MB0667.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2024 08:41:38.6081 (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: fDqW2SKFUzz/7OTyOhbeYbu+cyA726nbYdZeRVvIBJ4oiMiLiOsSW1gFM6UCRvKJSh/o1CeIblTJEck3ZR9Svh2aer7r9DsbsoGdaJMawQ6DMg2o3sImdZD19li3tAyx X-MS-Exchange-Transport-CrossTenantHeadersStamped: SH0PR01MB0747 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787782936122778329 X-GMAIL-MSGID: 1787782936122778329 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] }