Re: [PATCH v1 03/10] media: platform: mediatek: add isp_7x seninf unit

From: CK Hu (胡俊光)
Date: Mon Oct 14 2024 - 05:26:09 EST


Hi, Shu-hsiang:

On Wed, 2024-10-09 at 19:15 +0800, Shu-hsiang Yang wrote:
> Introduces the driver of the MediaTek Sensor Interface,
> focusing on integration with the MediaTek ISP CAMSYS. The
> seninf device bridges camera sensors and the ISP system,
> providing management for sensor data routing and processing.
> Key features include V4L2 framework control, and dynamic
> handling of stream configurations and virtual channels.
>
> Signed-off-by: Shu-hsiang Yang <Shu-hsiang.Yang@xxxxxxxxxxxx>
> ---

[snip]

> +static int set_test_model(struct seninf_ctx *ctx, char enable)
> +{

Without test code, this driver still work, so test code is advanced function.
Separate test code to a test patch.

Regards,
CK

> + struct seninf_vc *vc[] = { NULL, NULL, NULL, NULL, NULL };
> + int i = 0, ret = 0, vc_used = 0;
> + struct seninf_mux *mux;
> + int pref_idx[] = { 0, 1, 2, 3, 4 };
> +
> + if (ctx->is_test_model == 1) {
> + vc[vc_used++] = mtk_cam_seninf_get_vc_by_pad(ctx, PAD_SRC_RAW0);
> + } else if (ctx->is_test_model == 2) {
> + vc[vc_used++] = mtk_cam_seninf_get_vc_by_pad(ctx, PAD_SRC_RAW0);
> + vc[vc_used++] = mtk_cam_seninf_get_vc_by_pad(ctx, PAD_SRC_RAW1);
> + vc[vc_used++] = mtk_cam_seninf_get_vc_by_pad(ctx, PAD_SRC_RAW2);
> + } else if (ctx->is_test_model == 3) {
> + vc[vc_used++] = mtk_cam_seninf_get_vc_by_pad(ctx, PAD_SRC_RAW0);
> + vc[vc_used++] = mtk_cam_seninf_get_vc_by_pad(ctx, PAD_SRC_PDAF0);
> + } else {
> + dev_info(ctx->dev, "testmodel%d invalid\n", ctx->is_test_model);
> + return -1;
> + }
> +
> + for (; i < vc_used; ++i) {
> + if (!vc[i]) {
> + dev_info(ctx->dev, "vc not found\n");
> + return -1;
> + }
> + }
> +
> + if (enable) {
> + ret = pm_runtime_resume_and_get(ctx->dev);
> + if (ret < 0) {
> + dev_info(ctx->dev, "failed at pm_runtime_resume_and_get\n");
> + return ret;
> + }
> +
> + if (ctx->core->clk[CLK_TOP_CAMTM])
> + ret = clk_prepare_enable(ctx->core->clk[CLK_TOP_CAMTM]);
> + if (ret)
> + return ret;
> +
> + for (i = 0; i < vc_used; ++i) {
> + mux = mtk_cam_seninf_mux_get_pref(ctx,
> + pref_idx,
> + ARRAY_SIZE(pref_idx));
> + if (!mux)
> + return -EBUSY;
> + vc[i]->mux = mux->idx;
> + vc[i]->cam = ctx->pad2cam[vc[i]->out_pad];
> + vc[i]->enable = 1;
> +
> + dev_info(ctx->dev,
> + "test mode mux %d, cam %d, pixel mode %d\n",
> + vc[i]->mux, vc[i]->cam, vc[i]->pixel_mode);
> +
> + mtk_cam_seninf_set_test_model(ctx, vc[i]->mux,
> + vc[i]->cam,
> + vc[i]->pixel_mode);
> +
> + if (vc[i]->out_pad == PAD_SRC_PDAF0)
> + mdelay(40);
> + else
> + usleep_range(40, 60);
> + }
> + } else {
> + mtk_cam_seninf_set_idle(ctx);
> + mtk_cam_seninf_release_mux(ctx);
> +
> + if (ctx->core->clk[CLK_TOP_CAMTM])
> + clk_disable_unprepare(ctx->core->clk[CLK_TOP_CAMTM]);
> +
> + pm_runtime_put_sync(ctx->dev);
> + }
> +
> + ctx->streaming = enable;
> +
> + return 0;
> +}
> +