From nobody Tue Feb 10 10:54:56 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AA8DEB64D9 for ; Mon, 19 Jun 2023 11:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231455AbjFSLkj (ORCPT ); Mon, 19 Jun 2023 07:40:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231782AbjFSLk2 (ORCPT ); Mon, 19 Jun 2023 07:40:28 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0FBBDA; Mon, 19 Jun 2023 04:40:26 -0700 (PDT) Received: from desky.lan (91-154-35-171.elisa-laajakaista.fi [91.154.35.171]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 397ACDDA; Mon, 19 Jun 2023 13:39:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1687174789; bh=VHa8FwqxJxMZyb+g6bE2eDnxQBC76J4AUz2E56TPpMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ETqf6uvDjZCyXdCbWuTiix5zPg7gjF/7rIpzwc+DA3ekf2HKKw2E0cIn/ys/fHjc0 7TaBatKXk94z3KV2K7Gc8PEefSZROJ8j74/BCHcoQu6sPULW46IARxH8KWBjuQ/Flx u/Dw7/3uO4Z5XrvAkNP6i+QcBw+qR5vSPJobRyME= From: Tomi Valkeinen To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Sakari Ailus , Laurent Pinchart , Jacopo Mondi , Jai Luthra , Vaishnav Achath Cc: Tomi Valkeinen Subject: [PATCH v4 4/4] media: ti: cal: Implement get_frame_desc for camera-rx Date: Mon, 19 Jun 2023 14:40:07 +0300 Message-Id: <20230619114007.297393-5-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230619114007.297393-1-tomi.valkeinen@ideasonboard.com> References: <20230619114007.297393-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" CAL uses get_frame_desc to get the VC and DT for the incoming CSI-2 stream, but does it in a bit hacky way. Clean this up by implementing .get_frame_desc to camera-rx, and calling that from cal.c. No functional change intended. Signed-off-by: Tomi Valkeinen Reviewed-by: Jacopo Mondi --- drivers/media/platform/ti/cal/cal-camerarx.c | 62 +++++++++++--------- drivers/media/platform/ti/cal/cal.c | 30 ++++------ drivers/media/platform/ti/cal/cal.h | 2 - 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/drivers/media/platform/ti/cal/cal-camerarx.c b/drivers/media/p= latform/ti/cal/cal-camerarx.c index bc09c3f1446d..1a4273bbe752 100644 --- a/drivers/media/platform/ti/cal/cal-camerarx.c +++ b/drivers/media/platform/ti/cal/cal-camerarx.c @@ -589,33 +589,6 @@ static int cal_camerarx_parse_dt(struct cal_camerarx *= phy) return ret; } =20 -int cal_camerarx_get_remote_frame_desc(struct cal_camerarx *phy, - struct v4l2_mbus_frame_desc *desc) -{ - struct media_pad *pad; - int ret; - - if (!phy->source) - return -EPIPE; - - pad =3D media_pad_remote_pad_first(&phy->pads[CAL_CAMERARX_PAD_SINK]); - if (!pad) - return -EPIPE; - - ret =3D v4l2_subdev_call(phy->source, pad, get_frame_desc, pad->index, - desc); - if (ret) - return ret; - - if (desc->type !=3D V4L2_MBUS_FRAME_DESC_TYPE_CSI2) { - dev_err(phy->cal->dev, - "Frame descriptor does not describe CSI-2 link"); - return -EINVAL; - } - - return 0; -} - /* ------------------------------------------------------------------ * V4L2 Subdev Operations * ------------------------------------------------------------------ @@ -772,6 +745,40 @@ static int cal_camerarx_sd_init_cfg(struct v4l2_subdev= *sd, return cal_camerarx_sd_set_fmt(sd, state, &format); } =20 +static int cal_camerarx_get_frame_desc(struct v4l2_subdev *sd, unsigned in= t pad, + struct v4l2_mbus_frame_desc *fd) +{ + struct cal_camerarx *phy =3D to_cal_camerarx(sd); + struct v4l2_mbus_frame_desc remote_desc; + const struct media_pad *remote_pad; + int ret; + + remote_pad =3D media_pad_remote_pad_first(&phy->pads[CAL_CAMERARX_PAD_SIN= K]); + if (!remote_pad) + return -EPIPE; + + ret =3D v4l2_subdev_call(phy->source, pad, get_frame_desc, + remote_pad->index, &remote_desc); + if (ret) + return ret; + + if (remote_desc.type !=3D V4L2_MBUS_FRAME_DESC_TYPE_CSI2) { + cal_err(phy->cal, + "Frame descriptor does not describe CSI-2 link"); + return -EINVAL; + } + + if (remote_desc.num_entries > 1) + cal_err(phy->cal, + "Multiple streams not supported in remote frame descriptor, using the f= irst one\n"); + + fd->type =3D V4L2_MBUS_FRAME_DESC_TYPE_CSI2; + fd->num_entries =3D 1; + fd->entry[0] =3D remote_desc.entry[0]; + + return 0; +} + static const struct v4l2_subdev_video_ops cal_camerarx_video_ops =3D { .s_stream =3D cal_camerarx_sd_s_stream, }; @@ -782,6 +789,7 @@ static const struct v4l2_subdev_pad_ops cal_camerarx_pa= d_ops =3D { .enum_frame_size =3D cal_camerarx_sd_enum_frame_size, .get_fmt =3D v4l2_subdev_get_fmt, .set_fmt =3D cal_camerarx_sd_set_fmt, + .get_frame_desc =3D cal_camerarx_get_frame_desc, }; =20 static const struct v4l2_subdev_ops cal_camerarx_subdev_ops =3D { diff --git a/drivers/media/platform/ti/cal/cal.c b/drivers/media/platform/t= i/cal/cal.c index 18d86f6ae809..3c74e461fc50 100644 --- a/drivers/media/platform/ti/cal/cal.c +++ b/drivers/media/platform/ti/cal/cal.c @@ -446,30 +446,24 @@ static bool cal_ctx_wr_dma_stopped(struct cal_ctx *ct= x) } =20 static int -cal_get_remote_frame_desc_entry(struct cal_camerarx *phy, +cal_get_remote_frame_desc_entry(struct cal_ctx *ctx, struct v4l2_mbus_frame_desc_entry *entry) { struct v4l2_mbus_frame_desc fd; + struct media_pad *phy_source_pad; int ret; =20 - ret =3D cal_camerarx_get_remote_frame_desc(phy, &fd); - if (ret) { - if (ret !=3D -ENOIOCTLCMD) - dev_err(phy->cal->dev, - "Failed to get remote frame desc: %d\n", ret); - return ret; - } - - if (fd.num_entries =3D=3D 0) { - dev_err(phy->cal->dev, - "No streams found in the remote frame descriptor\n"); - + phy_source_pad =3D media_pad_remote_pad_first(&ctx->pad); + if (!phy_source_pad) return -ENODEV; - } =20 - if (fd.num_entries > 1) - dev_dbg(phy->cal->dev, - "Multiple streams not supported in remote frame descriptor, using the f= irst one\n"); + ret =3D v4l2_subdev_call(&ctx->phy->subdev, pad, get_frame_desc, + phy_source_pad->index, &fd); + if (ret) + return ret; + + if (fd.num_entries !=3D 1) + return -EINVAL; =20 *entry =3D fd.entry[0]; =20 @@ -481,7 +475,7 @@ int cal_ctx_prepare(struct cal_ctx *ctx) struct v4l2_mbus_frame_desc_entry entry; int ret; =20 - ret =3D cal_get_remote_frame_desc_entry(ctx->phy, &entry); + ret =3D cal_get_remote_frame_desc_entry(ctx, &entry); =20 if (ret =3D=3D -ENOIOCTLCMD) { ctx->vc =3D 0; diff --git a/drivers/media/platform/ti/cal/cal.h b/drivers/media/platform/t= i/cal/cal.h index 55d4736fed18..0856297adc0b 100644 --- a/drivers/media/platform/ti/cal/cal.h +++ b/drivers/media/platform/ti/cal/cal.h @@ -319,8 +319,6 @@ const struct cal_format_info *cal_format_by_code(u32 co= de); =20 void cal_quickdump_regs(struct cal_dev *cal); =20 -int cal_camerarx_get_remote_frame_desc(struct cal_camerarx *phy, - struct v4l2_mbus_frame_desc *desc); void cal_camerarx_disable(struct cal_camerarx *phy); void cal_camerarx_i913_errata(struct cal_camerarx *phy); struct cal_camerarx *cal_camerarx_create(struct cal_dev *cal, --=20 2.34.1