From patchwork Thu Jan 11 08:41:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13516990 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2065.outbound.protection.partner.outlook.cn [139.219.17.65]) (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 84DDA17727; Thu, 11 Jan 2024 08:57:20 +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=HiDYwprjCFr4cPa2XEGfFIn5Gak5giIxtSDGWV/hn3kRqgtUSZVXZD2+sU+InLyyUw+1ZdZ7qJ5Cc39Ocy5+lqq1riMHWofwslF0uv1YgPmI/tQOipoxYgnldw11+rWQVUXpRiJtz+tFQNdTVJYIX+eftmu9vcK26ENPy4xYwFnbmu7TgHxbxLpe4+6ch+exGba5fV1X+7k6aIQOHhzvhQSuH8uCoPt78fy+//xTqFp5I6EXlujCwIn5hjmcCzGYhu6GGpOuUb30O+DGW3X2ncVJZaGgJYo1C0OMlIyhEWWTlZk60RHzUyB6GZGd936RZe56g8KjGfzn8MVrF+aXCA== 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=myCz3x19pdBLyepP22aXlUVVrVPBvbaFTbiJbWyXl5U=; b=YMaor2rZGXVerJq15TB+VDQsgvJiPRBH49ryYrU1zXAugbptPKh6DHwiKFpK/O+43W3rurL1H6eBBGo+avWTICeQwlKa2FcRtmeAN2hnamSe3z3Q35NnI0ywfV+W9dUdIQQwwMsZiOnXDEXAHOrUvk7jHaqRUGO2kKExoC/aQA8bRq8bSa5PEJrxMWulNZGPHpU9uE/SiuK21DRwgwoxyVFbnnrFcH2wO2E42EK5QB4wP4LZUhoSuescQBa5HV671lx5CuCDeCdj6LE8jgsXnkSgOPpvUo2LjwfzBpVPiOHkP8B1RnGrQe00kcYMBCcmKjsZDaUEZn5ZGjcx/mtMWA== 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 04/13] staging: media: starfive: Add a params sink pad and a scd source pad for ISP Date: Thu, 11 Jan 2024 00:41:11 -0800 Message-Id: <20240111084120.16685-5-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-media@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: ea2347cb-bce9-496a-d2f0-08dc12811bff X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JGIzBUIgsRWN/PT2iQoehm5WouSkXotqEe3jRzlIaPxmNKyOzcWjG7luLj0RsU42PtnIXtchxWs2L4rqnEBcVf/CZWwZ1luTE0/u/sj8hPlVo1HLU82LmGmAYhmWw+2p8avBpSMkeq/36iXr9IrKpa9yj4hBdIoPL7NPMHM7Db75GrpbUk+qslvhGKnVW1OHtjD9JK7xhHAmajjVI48X+RCHp/O4BVhx+Mz6ZlTQtH667mPw20zveEDEmF7L40La+syi5AB3TrbwwlK9EM1p8UUtsIib2VHB/dASgwHz8ITzYjY9o7kWWrxgv6LmrQWP13XCg/LdyV3zguWRa7trvcIqA8NB1U9oWLJVWzoSbKKyzKW4Jy5XS9A6JkeD+56oroT9oE+e1bMJLvnZeeyXTdWeGBWApDmIDms8kpPslWC6G5WRz7XbwVNekegaw3p/DTpVZ5K3cW3DYJp7jKLjKsEkiAfMWCXdexBHpSW7qkVA+Jc8jGhQRWuILNhQru4XDcxnC5GrhsSCDKzThyRLAHwXR0L5GuBdYqlPL321viaGkzR2NFSDeXK8E4ZvvmO10yIjBmDnmAusl1DLqktRsA== 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: TWuEsLbUZE7Zg+cKrDI9vE2jm4tReDCFiQD7DzHgGEJfnigWavHKVaCx1o9Sw2Ri5Kjpp98f57Sdt01hXtBOAxEFT9q5myunByaSeGpOnOqNxZaf4WB11ecqwvhCuW2e6fq6s/qlUlFvoOx37iyPdm5HbRoSGTn+cqH0FOivcPCZmMKlAhCchnarfK0i5SECb/h1BYxMvdmHdy/Dmm4jRtw7zrea2WwL+LEU2wSv6GLiLq31Q0Ll+FI+NzlmuJmIUOGWXPLvW5sWf/4e87Wnuo98m6vmyyj67upAWASvbkVkM6P+eciXf2GEGOvrc9j2nm8RkxMngoXXyWCr0k3aiNer5wfVSezW6om9fdjLEvTjl0bVK+FHP3iq7ox/sU4qxT6HyAm4ntyC69z5aogjSuvLssOABiiHmvzeUYbhECzsjViC109WjcEZcBHnE27XC1Y54Du1xlCHCHL7dOZkymoiji/AZi8s6AzT1soOWWkD2f+PZ9qlLqnrM66kYmZzMXaEmHhGYiEmzjQckBPem8/A9v0SkTFM1ZUcV+S60UrBHv9xBUcTfM7M+T94mvAjkS3JoUG4r32+Ks+JMdfmx7/gPng9A2tmMlC57vY9nsvJtxpweKWINuWwjGzVfUbiUwqbZlfHaNM/uV+tlDLltjn54Lol14bqFvHJT0I+/4hgbNI4WEES1V0IDcRghzZDDUjgciVyd9gk68WpXQD4GC4NTb3HXw+2mmYYxDBJxZu2GHoHRnHZGSUyg1vYRqw4wy5cnD5zDVkfTCiQVkDC255aYblP+O606R5jUZFCnfgcYrGCVi2GAZdmbJWGUKgBnrKIYMGBrRiokV91aOOTL1lu8jzv0d2Qtutuu2J6PMo8eiLUbgRklvlcd7haZC1VeJ3m1azZ7FLO6yGmYra+ybldpzEqnwp9aYVDWvD+RYSlH3XBWs15h//GCZkDlONz2kJV3X1mV2BdgN9z6zgsZXefxvU4muizJ/QeyqqORjd7EwAjre798JS9gHXmW8qQScbS8W+BANyf3wBOOr8lTKf92hlCE5h2gKPHvWgZaVF96K7nuW8dWqnAf0g2zftsTM6uBnK5DZ+y5kwRhiVUpBLyGz4rnjenOw0ptP2rkvPUe0kC8f6Mp3+BUqLm4EtbwKEcrx3t78DOd70eO3vRfAYGEI51j+2ACG0tmgar2X5V+OnfRciX2dOTax44/5eZpK66YkdppvFRlCLbe9FTyki/OrPcFo+Ved2tVvfRfQ2wN3+HM4tyyuIP57I0L/5W8rD2yNXJ1uCMEF3qLD9Z5/K8dw3CHtRIPrQM4eMGUsNqNbhdgrZeCFRZW/6nMv7SHI3LY7ImtQNytJ8SIhXEnsoRStUfQFf2plCWI9aAjmu/Lz+i5w37bYfpk8VKeWOIsY8Dg5gg5lvVzKcq9KkCJiJ+haTZdIu69WCtCoQa78nkzvMs3YauwTG40dvhGfaJevhrs9agNB5Vy6eyXRyDa0pESOrJWA42C/SQTKRIyK4+46jqYtIoJuLh8R29xkw4ceq73kztCQp1y58HpQZxgUBl2Q95hy9ARyFC3C+uAAM+W9AYHl6J6chDroudTvQ7oTgYRa9j/6fe4y+bhFT5H/GGe0/cXYA8zup3aA7WbvM= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea2347cb-bce9-496a-d2f0-08dc12811bff 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.0961 (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: Ae51Hp2OPx1ZAbRGKW2iWyog6av1ZCpy991csWYEl455UFlwbPwUcF6JkOmbSiSrzifaDSyPW8DhJnWWny7TUhRGdi2LVkAfCaKj8C1rNbr1wp4qa4NXoD4EAmhaM2nA X-MS-Exchange-Transport-CrossTenantHeadersStamped: SH0PR01MB0747 StarFive ISP can use params sink pad to transmit ISP parameters and use scd source pad to capture statistics collection data. Signed-off-by: Changhuang Liang --- .../staging/media/starfive/camss/stf-isp.c | 87 +++++++++++++++---- .../staging/media/starfive/camss/stf-isp.h | 2 + 2 files changed, 73 insertions(+), 16 deletions(-) diff --git a/drivers/staging/media/starfive/camss/stf-isp.c b/drivers/staging/media/starfive/camss/stf-isp.c index d50616ef351e..0ebffd09842a 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.c +++ b/drivers/staging/media/starfive/camss/stf-isp.c @@ -10,9 +10,6 @@ #include "stf-camss.h" -#define SINK_FORMATS_INDEX 0 -#define SOURCE_FORMATS_INDEX 1 - static int isp_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, struct v4l2_subdev_selection *sel); @@ -24,13 +21,23 @@ static const struct stf_isp_format isp_formats_sink[] = { { MEDIA_BUS_FMT_SBGGR10_1X10, 10 }, }; +static const struct stf_isp_format isp_formats_sink_params[] = { + { MEDIA_BUS_FMT_METADATA_FIXED }, +}; + static const struct stf_isp_format isp_formats_source[] = { { MEDIA_BUS_FMT_YUYV8_1_5X8, 8 }, }; +static const struct stf_isp_format isp_formats_source_scd[] = { + { MEDIA_BUS_FMT_METADATA_FIXED }, +}; + static const struct stf_isp_format_table isp_formats_st7110[] = { { isp_formats_sink, ARRAY_SIZE(isp_formats_sink) }, + { isp_formats_sink_params, ARRAY_SIZE(isp_formats_sink_params) }, { isp_formats_source, ARRAY_SIZE(isp_formats_source) }, + { isp_formats_source_scd, ARRAY_SIZE(isp_formats_source_scd) }, }; static const struct stf_isp_format * @@ -94,18 +101,21 @@ static void isp_try_format(struct stf_isp_dev *isp_dev, return; } - if (pad == STF_ISP_PAD_SINK) - formats = &isp_dev->formats[SINK_FORMATS_INDEX]; - else if (pad == STF_ISP_PAD_SRC) - formats = &isp_dev->formats[SOURCE_FORMATS_INDEX]; + formats = &isp_dev->formats[pad]; + + if (pad != STF_ISP_PAD_SRC_SCD && pad != STF_ISP_PAD_SINK_PARAMS) { + fmt->width = clamp_t(u32, fmt->width, STFCAMSS_FRAME_MIN_WIDTH, + STFCAMSS_FRAME_MAX_WIDTH); + fmt->height = clamp_t(u32, fmt->height, STFCAMSS_FRAME_MIN_HEIGHT, + STFCAMSS_FRAME_MAX_HEIGHT); + fmt->height &= ~0x1; + fmt->colorspace = V4L2_COLORSPACE_SRGB; + } else { + fmt->width = 1; + fmt->height = 1; + } - fmt->width = clamp_t(u32, fmt->width, STFCAMSS_FRAME_MIN_WIDTH, - STFCAMSS_FRAME_MAX_WIDTH); - fmt->height = clamp_t(u32, fmt->height, STFCAMSS_FRAME_MIN_HEIGHT, - STFCAMSS_FRAME_MAX_HEIGHT); - fmt->height &= ~0x1; fmt->field = V4L2_FIELD_NONE; - fmt->colorspace = V4L2_COLORSPACE_SRGB; fmt->flags = 0; if (!stf_g_fmt_by_mcode(formats, fmt->code)) @@ -123,9 +133,9 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd, if (code->index >= ARRAY_SIZE(isp_formats_sink)) return -EINVAL; - formats = &isp_dev->formats[SINK_FORMATS_INDEX]; + formats = &isp_dev->formats[code->pad]; code->code = formats->fmts[code->index].code; - } else { + } else if (code->pad == STF_ISP_PAD_SRC) { struct v4l2_mbus_framefmt *sink_fmt; if (code->index >= ARRAY_SIZE(isp_formats_source)) @@ -137,6 +147,10 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd, code->code = sink_fmt->code; if (!code->code) return -EINVAL; + } else { + if (code->index > 0) + return -EINVAL; + code->code = MEDIA_BUS_FMT_METADATA_FIXED; } code->flags = 0; @@ -157,6 +171,9 @@ static int isp_set_format(struct v4l2_subdev *sd, isp_try_format(isp_dev, state, fmt->pad, &fmt->format); *format = fmt->format; + if (fmt->pad == STF_ISP_PAD_SRC_SCD || fmt->pad == STF_ISP_PAD_SINK_PARAMS) + return 0; + isp_dev->current_fmt = stf_g_fmt_by_mcode(&isp_dev->formats[fmt->pad], fmt->format.code); @@ -208,6 +225,9 @@ static int isp_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_format fmt = { 0 }; struct v4l2_rect *rect; + if (sel->pad == STF_ISP_PAD_SRC_SCD || sel->pad == STF_ISP_PAD_SINK_PARAMS) + return -EINVAL; + switch (sel->target) { case V4L2_SEL_TGT_CROP_BOUNDS: if (sel->pad == STF_ISP_PAD_SINK) { @@ -245,6 +265,9 @@ static int isp_set_selection(struct v4l2_subdev *sd, struct stf_isp_dev *isp_dev = v4l2_get_subdevdata(sd); struct v4l2_rect *rect; + if (sel->pad == STF_ISP_PAD_SRC_SCD || sel->pad == STF_ISP_PAD_SINK_PARAMS) + return -EINVAL; + if (sel->target != V4L2_SEL_TGT_CROP) return -EINVAL; @@ -302,8 +325,38 @@ static int isp_init_formats(struct v4l2_subdev *sd, .height = 1080 } }; + struct v4l2_subdev_format format_params = { + .pad = STF_ISP_PAD_SINK_PARAMS, + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + .format = { + .code = MEDIA_BUS_FMT_METADATA_FIXED, + .width = 1, + .height = 1 + } + }; + struct v4l2_subdev_format format_scd = { + .pad = STF_ISP_PAD_SRC_SCD, + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + .format = { + .code = MEDIA_BUS_FMT_METADATA_FIXED, + .width = 1, + .height = 1 + } + }; + int ret; + + /* Init for STF_ISP_PAD_SINK and STF_ISP_PAD_SRC pad */ + ret = isp_set_format(sd, sd_state, &format); + if (ret < 0) + return ret; + + /* Init for STF_ISP_PAD_SINK_PARAMS pad */ + ret = isp_set_format(sd, sd_state, &format_params); + if (ret < 0) + return ret; - return isp_set_format(sd, sd_state, &format); + /* Init for STF_ISP_PAD_SRC_SCD pad */ + return isp_set_format(sd, sd_state, &format_scd); } static const struct v4l2_subdev_video_ops isp_video_ops = { @@ -344,7 +397,9 @@ int stf_isp_register(struct stf_isp_dev *isp_dev, struct v4l2_device *v4l2_dev) v4l2_set_subdevdata(sd, isp_dev); pads[STF_ISP_PAD_SINK].flags = MEDIA_PAD_FL_SINK; + pads[STF_ISP_PAD_SINK_PARAMS].flags = MEDIA_PAD_FL_SINK; pads[STF_ISP_PAD_SRC].flags = MEDIA_PAD_FL_SOURCE; + pads[STF_ISP_PAD_SRC_SCD].flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = MEDIA_ENT_F_PROC_VIDEO_ISP; sd->entity.ops = &isp_media_ops; diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h index 955cbb048363..bc7e7b0736fa 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.h +++ b/drivers/staging/media/starfive/camss/stf-isp.h @@ -392,7 +392,9 @@ /* pad id for media framework */ enum stf_isp_pad_id { STF_ISP_PAD_SINK = 0, + STF_ISP_PAD_SINK_PARAMS, STF_ISP_PAD_SRC, + STF_ISP_PAD_SRC_SCD, STF_ISP_PAD_MAX };